1 /***********************************************************************
5 File OpenGl_togl_markercontextgroup.c :
11 HISTORIQUE DES MODIFICATIONS :
12 --------------------------------
13 xx-xx-xx : xxx ; Creation.
14 03-03-98 : CAL ; Modification des structures CALL_DEF_GROUP et STRUCTURE
16 ************************************************************************/
19 /*----------------------------------------------------------------------*/
24 #include <OpenGl_tgl_all.hxx>
25 #include <InterfaceGraphic_Graphic3d.hxx>
26 #include <OpenGl_context.hxx>
27 #include <OpenGl_tgl.hxx>
28 #include <OpenGl_tgl_funcs.hxx>
29 #include <OpenGl_tgl_subrs.hxx>
30 #include <OpenGl_tgl_utilgr.hxx>
32 /*----------------------------------------------------------------------*/
34 /*--------------------------------generate USERDEFINED marker--------begin-------*/
48 #if defined(HAVE_MALLOC_H) || defined(WNT)
55 GLuint* DisplayIdList;
57 } UserDefineMarkerStruct;
59 static UserDefineMarkerStruct UDMS_Marker = { NULL, NULL, 0 };
61 int EXPORT GenerateMarkerBitmap( int theId, unsigned int theWidth, unsigned int theHeight, unsigned char* theArray )
65 GLint w, h, size, k, l;
67 for( ; i < UDMS_Marker.Quantity; i++ )
69 if( UDMS_Marker.IdList[i] == theId )
72 glDeleteLists( UDMS_Marker.DisplayIdList[i], 1 );
73 if ( glGetError() != GL_NO_ERROR )
80 anIndex = UDMS_Marker.Quantity;
83 UDMS_Marker.IdList = (int*)malloc( sizeof( int ) );
84 UDMS_Marker.DisplayIdList = (GLuint*)malloc( sizeof( GLuint ) );
88 UDMS_Marker.IdList = (int*) realloc( UDMS_Marker.IdList, (UDMS_Marker.Quantity + 1)*sizeof( int ) );
89 UDMS_Marker.DisplayIdList = (GLuint*) realloc( UDMS_Marker.DisplayIdList, (UDMS_Marker.Quantity + 1)*sizeof( GLuint ) );
91 UDMS_Marker.Quantity++;
94 UDMS_Marker.IdList[anIndex] = theId;
95 UDMS_Marker.DisplayIdList[anIndex] = glGenLists( 1 );
96 glNewList( UDMS_Marker.DisplayIdList[anIndex], GL_COMPILE );
98 w = ( GLsizei ) theWidth;
99 h = ( GLsizei ) theHeight;
101 ( float )theWidth / ( float )2.0,
102 ( float )theHeight / ( float )2.0,
103 ( float )30.0, ( float )30.0,
104 ( GLubyte* )theArray );
111 GLuint EXPORT GetListIndex( int theId )
114 for( ; i < UDMS_Marker.Quantity; i++ )
116 if( UDMS_Marker.IdList[i] == theId )
117 return UDMS_Marker.DisplayIdList[i];
122 /*--------------------------------generate USERDEFINED marker---------end--------*/
126 call_togl_markercontextgroup
128 CALL_DEF_GROUP * agroup,
133 Tfloat markr, markg, markb;
137 /* for the structure */
138 Tfloat Markr, Markg, Markb;
143 * Si le groupe est ouvert cela signifie que BeginPrimitives
145 * Dans le cas des markers composes, il faut refermer temporairement
146 * le groupe pour eviter des insertions d'attributs aleatoires.
148 if (agroup->IsOpen) call_togl_closegroup (agroup);
150 if( agroup->ContextMarker.IsDef )
152 markr = agroup->ContextMarker.Color.r;
153 markg = agroup->ContextMarker.Color.g;
154 markb = agroup->ContextMarker.Color.b;
155 markertype = CALL_PHIGS_MARKER_CROSS;
156 switch( agroup->ContextMarker.MarkerType )
158 case 0 : /* Aspect_TOM_POINT */
159 markertype = CALL_PHIGS_MARKER_DOT;
161 case 1 : /* Aspect_TOM_PLUS */
162 markertype = CALL_PHIGS_MARKER_PLUS;
164 case 2 : /* Aspect_TOM_STAR */
165 markertype = CALL_PHIGS_MARKER_ASTERISK;
167 case 3 : /* Aspect_TOM_O */
168 markertype = CALL_PHIGS_MARKER_CIRCLE;
170 case 4 : /* Aspect_TOM_X */
171 markertype = CALL_PHIGS_MARKER_CROSS;
173 case 13 : /* Aspect_TOM_USERDEFINED */
174 markertype = CALL_PHIGS_MARKER_USER_DEFINED;
179 markerscale = (Tfloat)agroup->ContextMarker.Scale;
181 Markr = agroup->Struct->ContextMarker.Color.r;
182 Markg = agroup->Struct->ContextMarker.Color.g;
183 Markb = agroup->Struct->ContextMarker.Color.b;
184 Markertype = CALL_PHIGS_MARKER_CROSS;
185 switch( agroup->Struct->ContextMarker.MarkerType )
187 case 0 : /* Aspect_TOM_POINT */
188 Markertype = CALL_PHIGS_MARKER_DOT;
190 case 1 : /* Aspect_TOM_PLUS */
191 Markertype = CALL_PHIGS_MARKER_PLUS;
193 case 2 : /* Aspect_TOM_STAR */
194 Markertype = CALL_PHIGS_MARKER_ASTERISK;
196 case 3 : /* Aspect_TOM_O */
197 Markertype = CALL_PHIGS_MARKER_CIRCLE;
199 case 4 : /* Aspect_TOM_X */
200 Markertype = CALL_PHIGS_MARKER_CROSS;
202 case 13 : /* Aspect_TOM_USERDEFINED*/
203 markertype = CALL_PHIGS_MARKER_USER_DEFINED;
208 Markerscale = (Tfloat)agroup->Struct->ContextMarker.Scale;
212 if( agroup->ContextMarker.IsSet )
213 call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
215 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
216 call_func_open_struct( agroup->Struct->Id );
218 call_func_set_elem_ptr( 0 );
219 call_func_set_elem_ptr_label( agroup->LabelBegin );
220 if( agroup->PickId.IsSet )
221 call_func_offset_elem_ptr( 1 );
222 if( agroup->ContextLine.IsSet )
223 call_func_offset_elem_ptr( CALL_DEF_CONTEXTLINE_SIZE );
224 if( agroup->ContextFillArea.IsSet )
225 call_func_offset_elem_ptr( CALL_DEF_CONTEXTFILLAREA_SIZE );
226 if( agroup->ContextMarker.IsSet )
227 call_func_offset_elem_ptr( 1 );
228 call_subr_set_marker_colr( markr, markg, markb );
229 if( agroup->ContextMarker.IsSet )
230 call_func_offset_elem_ptr( 1 );
231 call_func_set_marker_type( markertype );
232 if( agroup->ContextMarker.IsSet )
233 call_func_offset_elem_ptr( 1 );
234 call_func_set_marker_size( markerscale );
236 call_func_set_elem_ptr_label( agroup->LabelEnd );
237 call_func_offset_elem_ptr(-call_util_context_group_place(agroup)-1);
238 if( agroup->ContextLine.IsSet )
239 call_func_offset_elem_ptr( CALL_DEF_CONTEXTLINE_SIZE );
240 if( agroup->ContextFillArea.IsSet )
241 call_func_offset_elem_ptr( CALL_DEF_CONTEXTFILLAREA_SIZE );
242 if( agroup->ContextMarker.IsSet )
243 call_func_offset_elem_ptr( 1 );
244 call_subr_set_marker_colr( Markr, Markg, Markb );
245 if( agroup->ContextMarker.IsSet )
246 call_func_offset_elem_ptr( 1 );
247 call_func_set_marker_type( Markertype );
248 if( agroup->ContextMarker.IsSet )
249 call_func_offset_elem_ptr( 1 );
250 call_func_set_marker_size( Markerscale );
252 call_func_close_struct();
257 call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
258 call_func_open_struct( agroup->Struct->Id );
260 call_func_set_elem_ptr( 0 );
261 call_func_set_elem_ptr_label( agroup->LabelEnd );
262 call_func_offset_elem_ptr(-call_util_context_group_place(agroup)-1);
263 call_subr_set_marker_colr( markr, markg, markb );
264 call_func_set_marker_type( markertype );
265 call_func_set_marker_size( markerscale );
267 if( agroup->ContextLine.IsSet )
268 call_func_offset_elem_ptr( CALL_DEF_CONTEXTLINE_SIZE );
269 if( agroup->ContextFillArea.IsSet )
270 call_func_offset_elem_ptr( CALL_DEF_CONTEXTFILLAREA_SIZE );
271 if( !agroup->ContextMarker.IsSet )
273 call_subr_set_marker_colr( Markr, Markg, Markb );
274 call_func_set_marker_type( Markertype );
275 call_func_set_marker_size( Markerscale );
277 call_func_close_struct();
280 /* Voir commentaire en debut de fonction */
281 if (agroup->IsOpen) call_togl_opengroup (agroup);