File: colors.c

package info (click to toggle)
xmorph 1%3A20060817
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,688 kB
  • ctags: 2,022
  • sloc: ansic: 19,988; sh: 9,418; cpp: 1,230; makefile: 560; sed: 16
file content (208 lines) | stat: -rw-r--r-- 5,246 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <strings.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>

#include <gtk/gtk.h>

#include "gtk-meta.h"

#ifdef USE_IMLIB
#include <gdk_imlib.h>
#else
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif

#include "gdk-pixbuf-extra.h"

#include "gtktopdata.h"

#include "libmorph/warp.h"
#include "libmorph/warp2.h"
#include "libmorph/warp-gtk.h"
#include "libmorph/resample.h"

#include "callbacks.h"
#include "interface.h"
#include "support.h"
//#include "pixmaps.h"
#include "mesh-gtk.h"
#include "utils.h"
#include "main.h"
#include "settings.h"
#include "dialogs.h"

#include "libmorph/mesh.h"

#if HAVE_LIBPLY_H
#include "../plyview/bind.h"
#endif





/***************************** colors ***************/


/* color flashing */
GdkGC *flash_gc;


GdkColor    colors[] =   {
  //selected points, 
  {    0L,     63 * 1024,     63 * 1024,     40 * 1024   },
  //unselected points. This color is used also for lines
  {    0L,     40 * 1024,     50 * 1024,     40 * 1024   },

  //all these are for features
  //so, to change from feature_n to feature_gc you have to add 2
  //so, to change from feature_n to mesh label you have to add 1
  //{    0L,     63 * 1024,     63 * 1024,     63 * 1024   },
  //{    0L,     63 * 1024,     63 * 1024,     30 * 1024   },
  {    0L,     63 * 1024,     30 * 1024,     30 * 1024   },
  {    0L,     63 * 1024,     30 * 1024,     63 * 1024   },
  {    0L,     30 * 1024,     63 * 1024,     63 * 1024   },
  {    0L,     30 * 1024,     63 * 1024,     30 * 1024   },
  {    0L,     30 * 1024,     30 * 1024,     63 * 1024   },
  {    0L,     30 * 1024,     30 * 1024,     30 * 1024   },

  //{    0L,     63 * 1024,     63 * 1024,     63 * 1024   },
  {    0L,     63 * 1024,     63 * 1024,     50 * 1024   },
  {    0L,     63 * 1024,     50 * 1024,     63 * 1024   },
  {    0L,     63 * 1024,     50 * 1024,     50 * 1024   },
  {    0L,     50 * 1024,     63 * 1024,     63 * 1024   },
  {    0L,     50 * 1024,     63 * 1024,     50 * 1024   },
  {    0L,     50 * 1024,     50 * 1024,     63 * 1024   },
  {    0L,     50 * 1024,     50 * 1024,     50 * 1024   },

  //{    0L,     63 * 1024,     63 * 1024,     63 * 1024   },
  {    0L,     63 * 1024,     63 * 1024,     10 * 1024   },
  {    0L,     63 * 1024,     10 * 1024,     63 * 1024   },
  {    0L,     63 * 1024,     10 * 1024,     10 * 1024   },
  {    0L,     10 * 1024,     63 * 1024,     63 * 1024   },
  {    0L,     10 * 1024,     63 * 1024,     10 * 1024   },
  {    0L,     10 * 1024,     10 * 1024,     63 * 1024   },
  //{    0L,     10 * 1024,     10 * 1024,     10 * 1024   },

  //{    0L,     40 * 1024,     40 * 1024,     40 * 1024   },
  {    0L,     40 * 1024,     40 * 1024,     30 * 1024   },
  {    0L,     40 * 1024,     30 * 1024,     40 * 1024   },
  {    0L,     40 * 1024,     30 * 1024,     30 * 1024   },
  {    0L,     30 * 1024,     40 * 1024,     40 * 1024   },
  {    0L,     30 * 1024,     40 * 1024,     30 * 1024   },
  {    0L,     30 * 1024,     30 * 1024,     40 * 1024   },
  {    0L,     30 * 1024,     30 * 1024,     30 * 1024   }

};
GdkGC  *features_gc[100];
const int features_max_n=sizeof(colors)/sizeof(GdkColor)-2;


/* color for selected points and subimage selection*/
GdkGC   *mps_gc;
/* color for resulting points */
//GdkGC   *mpr_gc;
/* color for mesh lines */
GdkGC *mpl_gc;


void allocate_colors(GtkWidget * widget)
{
  /* allocate colors */
  int lp=sizeof(colors)/sizeof(GdkColor)-1;

  g_debug("allocating colors");

  //features_max_n=lp-2;

  g_assert(widget->window);
  g_assert(lp<100);
  for(;lp>=0;lp--) {
    features_gc[lp] = gdk_gc_new(widget->window);
    gdk_gc_copy(features_gc[lp], widget->style->white_gc );
    if(gdk_colormap_alloc_color (gdk_colormap_get_system (),
				 & (colors[lp]),
				 FALSE , //gboolean writeable,
				 TRUE //gboolean best_match
				 )
       == FALSE)
      g_warning("%s %d : can't allocate color\n",__FILE__,__LINE__);
    else
      gdk_gc_set_foreground ( features_gc[lp], &(colors[lp])); 
    g_assert(features_gc[lp]);
  }

  //FIXME CRUDE PROGRAMMING
  
  mpl_gc=gdk_gc_new(widget->window);
  g_assert(mpl_gc);
  gdk_gc_copy(mpl_gc, features_gc[1] );
  gdk_gc_set_line_attributes (mpl_gc,
			      1, //gint line_width,
			      GDK_LINE_DOUBLE_DASH,//GdkLineStyle line_style,
			      GDK_CAP_BUTT, //GdkCapStyle cap_style,
			      GDK_JOIN_MITER //GdkJoinStyle join_style
			      );

  mps_gc=gdk_gc_new(widget->window);
  g_assert(mps_gc);
  gdk_gc_copy(mps_gc, features_gc[2] );
  gdk_gc_set_line_attributes (mps_gc,
			      1, //gint line_width,
			      GDK_LINE_DOUBLE_DASH,//GdkLineStyle line_style,
			      GDK_CAP_BUTT, //GdkCapStyle cap_style,
			      GDK_JOIN_MITER //GdkJoinStyle join_style
			      );

#ifdef FIXME
  /* the xor method  flashes on/off 
       we should use the same clipping rectangle as above, but we dont */
  gdk_gc_set_function(mpl_gc,GDK_XOR);
#endif

  flash_gc = gdk_gc_new(widget->window);
  gdk_gc_copy(flash_gc,mpl_gc );
  gdk_gc_set_function(flash_gc,GDK_XOR);
    
  //  mps_gc= features_gc[0];
  //mpr_gc= features_gc[1];

}