~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to color.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                color.c
 
6
 
 
7
Purpose:
 
8
        Execute color command: assign the requested color scheme to all
 
9
        currently selected atoms in each caught complex.
 
10
 
 
11
Input:
 
12
        (1) Pointer to MolComplexS structure, with macromol. complexes.
 
13
        (2) The number of macromolecular complexes.
 
14
        (3) Pointer to RuntimeS structure, with some runtime data.
 
15
        (4) Pointer to ConfigS structure, with configuration data.
 
16
        (5) Pointer to GUIS structure, with GUI data.
 
17
        (6) Pointer to NearestAtomS structure.
 
18
        (7) The number of pixels in the main window free area.
 
19
        (8) Pointer to refreshI.
 
20
        (9) String which contains the color scheme name.
 
21
 
 
22
Output:
 
23
        (1) The hiddenF set for each atom in each caught complex.
 
24
        (2) Return value.
 
25
 
 
26
Return value:
 
27
        (1) Positive (command) code on success.
 
28
        (2) Negative (error) code on failure.
 
29
 
 
30
========includes:============================================================*/
 
31
 
 
32
#include <stdio.h>
 
33
 
 
34
#include <string.h>
 
35
 
 
36
#include <X11/Xlib.h>
 
37
#include <X11/Xutil.h>
 
38
#include <X11/Xos.h>
 
39
#include <X11/Xatom.h>
 
40
 
 
41
#include "defines.h"
 
42
#include "commands.h"
 
43
#include "typedefs.h"
 
44
 
 
45
/*======function prototypes:=================================================*/
 
46
 
 
47
int             FullColors_ (MolComplexS *, int, GUIS *, char *);
 
48
char            *ExtractToken_ (char *, int, char *, char *);
 
49
int             ColorSchemes_ (MolComplexS *, int, GUIS *, char *);
 
50
size_t          MainRefresh_ (MolComplexS *, int,
 
51
                              RuntimeS *, ConfigS *, GUIS *,
 
52
                              NearestAtomS *, size_t, unsigned int);
 
53
int             ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
 
54
 
 
55
/*======execute color command:===============================================*/
 
56
 
 
57
int Color_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
58
            RuntimeS *runtimeSP,
 
59
            ConfigS *configSP, GUIS *guiSP,
 
60
            NearestAtomS *nearest_atomSP, size_t pixelsN,
 
61
            unsigned int *refreshIP, char *stringP)
 
62
{
 
63
char            *commandP;
 
64
char            *remainderP;
 
65
char            tokenA[STRINGSIZE];
 
66
int             n;
 
67
 
 
68
/* Try to interpret  the string as  the full color */
 
69
/* specification. Use the original command string: */
 
70
commandP = runtimeSP->curr_commandA;
 
71
if (FullColors_ (mol_complexSP, mol_complexesN, guiSP, commandP) > 0)
 
72
        {
 
73
        (*refreshIP)++;
 
74
        MainRefresh_ (mol_complexSP, mol_complexesN,
 
75
                      runtimeSP, configSP, guiSP,
 
76
                      nearest_atomSP, pixelsN, *refreshIP);
 
77
        ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
 
78
                         configSP, guiSP);
 
79
        return COMMAND_COLOR;
 
80
        }
 
81
 
 
82
/* Extract the color scheme name: */
 
83
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
 
84
if (!remainderP)
 
85
        {
 
86
        strcpy (runtimeSP->messageA, "Color scheme specification missing!");
 
87
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
88
        return ERROR_NO_SCHEME;
 
89
        }
 
90
 
 
91
/* Assign the requested predefined colors to all selected atoms: */
 
92
 
 
93
/** If some simple color scheme is requested: **/
 
94
n = ColorSchemes_ (mol_complexSP, mol_complexesN, guiSP, tokenA);
 
95
 
 
96
/** If scheme is not recognized: **/
 
97
if (n <= 0)
 
98
        {
 
99
        sprintf (runtimeSP->messageA,
 
100
                 "Color scheme %s is not available!", tokenA);
 
101
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
102
        return ERROR_BAD_SCHEME;
 
103
        }
 
104
 
 
105
/* Refresh the main window: */
 
106
(*refreshIP)++;
 
107
MainRefresh_ (mol_complexSP, mol_complexesN, runtimeSP, configSP, guiSP,
 
108
              nearest_atomSP, pixelsN, *refreshIP);
 
109
 
 
110
/* Refresh the control window: */
 
111
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
 
112
 
 
113
/* Return positive value on success: */
 
114
return COMMAND_COLOR;
 
115
}
 
116
 
 
117
/*===========================================================================*/
 
118
 
 
119