0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_togl_textcontextgroup.cxx
1 /***********************************************************************
2
3 FONCTION :
4 ----------
5 File OpenGl_textcontextgroup :
6
7
8 REMARQUES:
9 ---------- 
10
11 HISTORIQUE DES MODIFICATIONS   :
12 --------------------------------
13 xx-xx-xx : xxx ; Creation.
14 03-09-97 : FMN ; Ajout traitement Begin/EndPrimitives()
15 03-03-98 : CAL ; Modification des structures CALL_DEF_GROUP et STRUCTURE
16 30-11-98 : FMN ; S4069 : Textes toujours visibles
17
18 ************************************************************************/
19
20 /*----------------------------------------------------------------------*/
21 /*
22 * Includes
23 */ 
24
25
26 #include <OpenGl_tgl_all.hxx>
27 #include <InterfaceGraphic_Graphic3d.hxx>
28 #include <OpenGl_tgl.hxx>
29 #include <OpenGl_tgl_funcs.hxx>
30 #include <OpenGl_tgl_subrs.hxx>
31 #include <OpenGl_context.hxx>
32 #include <OpenGl_tgl_utilgr.hxx>
33
34 #include <OSD_FontAspect.hxx>
35
36 /*----------------------------------------------------------------------*/
37
38 void EXPORT
39 call_togl_textcontextgroup
40 (
41  CALL_DEF_GROUP * agroup,
42  int noinsert
43  )
44 {
45   /* for the group */
46   Tchar    *fontid=NULL;
47   Tfloat    textr, textg, textb;
48   Tfloat    textrs, textgs, textbs;
49   Tfloat    textspace;
50   Tfloat    textexpan;
51   int       textstyle, textdisplaytype; 
52   int       textzoomable;
53   float     textangle;
54   OSD_FontAspect textfontaspect;
55
56   /* for the structure */
57   Tchar    *Fontid=NULL;
58   Tfloat    Textr, Textg, Textb;
59   Tfloat    Textrs, Textgs, Textbs;
60   Tfloat    Textspace;
61   Tfloat    Textexpan;
62   int       Textstyle, Textdisplaytype;
63   int       Textzoomable;
64   float     Textangle;
65   OSD_FontAspect Textfontaspect;
66
67   /*
68   * Si le groupe est ouvert cela signifie que BeginPrimitives
69   * a ete utilise.
70   * Dans le cas des markers composes, il faut refermer temporairement
71   * le groupe pour eviter des insertions d'attributs aleatoires.
72   */
73   if (agroup->IsOpen) call_togl_closegroup (agroup);
74
75 #ifdef TRACE
76
77   cout << "TKOpenGl::OpenGl_togl_textcontextgroup"
78     << "\t is defined : " << agroup->ContextText.IsDef << endl;
79 #endif
80   if( agroup->ContextText.IsDef )
81   {
82     textr  = agroup->ContextText.Color.r;
83     textg  = agroup->ContextText.Color.g;
84     textb  = agroup->ContextText.Color.b;
85     textrs = agroup->ContextText.ColorSubTitle.r;
86     textgs = agroup->ContextText.ColorSubTitle.g;
87     textbs = agroup->ContextText.ColorSubTitle.b;
88
89     fontid = new Tchar[strlen((char*)agroup->ContextText.Font)+1];
90     strcpy((char*)fontid,(char*)agroup->ContextText.Font);
91
92     textspace = (Tfloat) agroup->ContextText.Space;
93     textexpan = (Tfloat) agroup->ContextText.Expan;
94     textstyle = (int) agroup->ContextText.Style;
95     textdisplaytype = (int) agroup->ContextText.DisplayType;
96     textzoomable = (int) agroup->ContextText.TextZoomable; 
97     textangle = (float) agroup->ContextText.TextAngle; 
98     textfontaspect = (OSD_FontAspect) agroup->ContextText.TextFontAspect;         
99
100     Textr = agroup->Struct->ContextText.Color.r;
101     Textg = agroup->Struct->ContextText.Color.g;
102     Textb = agroup->Struct->ContextText.Color.b;
103
104     Textrs = agroup->Struct->ContextText.ColorSubTitle.r;
105     Textgs = agroup->Struct->ContextText.ColorSubTitle.g;
106     Textbs = agroup->Struct->ContextText.ColorSubTitle.b;
107
108     Fontid = new Tchar[strlen((char*)agroup->Struct->ContextText.Font)+1];
109     strcpy((char*)Fontid,(char*)agroup->Struct->ContextText.Font);
110
111     Textspace = (Tfloat) agroup->Struct->ContextText.Space;
112     Textexpan = (Tfloat) agroup->Struct->ContextText.Expan;
113     Textstyle = (int) agroup->Struct->ContextText.Style;
114     Textdisplaytype = (int) agroup->Struct->ContextText.DisplayType;
115     Textzoomable = (int) agroup->Struct->ContextText.TextZoomable;
116     Textangle = (float) agroup->Struct->ContextText.TextAngle;
117     Textfontaspect = (OSD_FontAspect) agroup->Struct->ContextText.TextFontAspect;
118
119     if( noinsert )
120     {
121       if( agroup->ContextText.IsSet )
122         call_func_set_edit_mode( CALL_PHIGS_EDIT_REPLACE );
123       else
124         call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
125       call_func_open_struct( agroup->Struct->Id );
126
127       call_func_set_elem_ptr( 0 );
128       call_func_set_elem_ptr_label( agroup->LabelBegin );
129       if( agroup->PickId.IsSet )
130         call_func_offset_elem_ptr( 1 );
131       if( agroup->ContextLine.IsSet )
132         call_func_offset_elem_ptr( CALL_DEF_CONTEXTLINE_SIZE );
133       if( agroup->ContextFillArea.IsSet )
134         call_func_offset_elem_ptr( CALL_DEF_CONTEXTFILLAREA_SIZE );
135       if( agroup->ContextMarker.IsSet )
136         call_func_offset_elem_ptr( CALL_DEF_CONTEXTMARKER_SIZE );
137       if( agroup->ContextText.IsSet )
138         call_func_offset_elem_ptr( 1 );
139       call_func_set_text_zoomable( textzoomable );   
140       call_func_set_text_angle( textangle );   
141       call_func_set_text_fontaspect( textfontaspect );   
142
143       if( agroup->ContextText.IsSet )
144         call_func_offset_elem_ptr( 1 );
145       call_func_set_text_font( fontid );
146       if( agroup->ContextText.IsSet )
147         call_func_offset_elem_ptr( 1 );
148       call_func_set_char_space( textspace );
149       if( agroup->ContextText.IsSet )
150         call_func_offset_elem_ptr( 1 );
151       call_func_set_char_expan( textexpan );
152       if( agroup->ContextText.IsSet )
153         call_func_offset_elem_ptr( 1 );
154       call_subr_set_text_colr( textr, textg, textb );
155       if( agroup->ContextText.IsSet )
156         call_func_offset_elem_ptr( 1 );
157       call_func_set_text_style( textstyle );
158       if( agroup->ContextText.IsSet )
159         call_func_offset_elem_ptr( 1 );
160       call_func_set_text_display_type( textdisplaytype );
161       if( agroup->ContextText.IsSet )
162         call_func_offset_elem_ptr( 1 );
163       call_subr_set_text_colr_subtitle( textrs, textgs, textbs );
164
165       call_func_set_elem_ptr_label( agroup->LabelEnd );
166       call_func_offset_elem_ptr(-call_util_context_group_place(agroup)-1);
167       if( agroup->ContextLine.IsSet )
168         call_func_offset_elem_ptr( CALL_DEF_CONTEXTLINE_SIZE );
169       if( agroup->ContextFillArea.IsSet )
170         call_func_offset_elem_ptr( CALL_DEF_CONTEXTFILLAREA_SIZE );
171       if( agroup->ContextMarker.IsSet )
172         call_func_offset_elem_ptr( CALL_DEF_CONTEXTMARKER_SIZE );
173       if( agroup->ContextText.IsSet )
174         call_func_offset_elem_ptr( 1 );             
175       call_func_set_text_zoomable( Textzoomable);
176       call_func_set_text_angle( Textangle);
177       call_func_set_text_fontaspect( Textfontaspect);   
178
179       if( agroup->ContextText.IsSet )
180         call_func_offset_elem_ptr( 1 );
181       call_func_set_text_font( Fontid );
182       if( agroup->ContextText.IsSet )
183         call_func_offset_elem_ptr( 1 );
184       call_func_set_char_space( Textspace );
185       if( agroup->ContextText.IsSet )
186         call_func_offset_elem_ptr( 1 );
187       call_func_set_char_expan( Textexpan );
188       if( agroup->ContextText.IsSet )
189         call_func_offset_elem_ptr( 1 );
190       call_subr_set_text_colr( Textr, Textg, Textb );
191       if( agroup->ContextText.IsSet )
192         call_func_offset_elem_ptr( 1 );
193       call_func_set_text_style( Textstyle );
194       if( agroup->ContextText.IsSet )
195         call_func_offset_elem_ptr( 1 );
196       call_func_set_text_display_type( Textdisplaytype );
197       if( agroup->ContextText.IsSet )
198         call_func_offset_elem_ptr( 1 );
199       call_subr_set_text_colr_subtitle( Textrs, Textgs, Textbs );
200       call_func_close_struct();
201     } /* no insert */
202
203     if( noinsert == 0 )
204     {
205       call_func_set_edit_mode( CALL_PHIGS_EDIT_INSERT );
206       call_func_open_struct( agroup->Struct->Id );
207
208       call_func_set_elem_ptr( 0 );
209       call_func_set_elem_ptr_label( agroup->LabelEnd );
210       call_func_offset_elem_ptr(-call_util_context_group_place(agroup)-1);
211       call_func_set_text_zoomable( textzoomable );  
212       call_func_set_text_angle( textangle );  
213       call_func_set_text_fontaspect( textfontaspect );  
214
215       call_func_set_text_font( fontid );
216       call_func_set_char_space( textspace );
217       call_func_set_char_expan( textexpan );
218       call_subr_set_text_colr( textr, textg, textb );
219       call_func_set_text_style( textstyle );
220       call_func_set_text_display_type( textdisplaytype );
221       call_subr_set_text_colr_subtitle( textrs, textgs, textbs );
222
223       if( agroup->ContextLine.IsSet )
224         call_func_offset_elem_ptr( CALL_DEF_CONTEXTLINE_SIZE );
225       if( agroup->ContextFillArea.IsSet )
226         call_func_offset_elem_ptr( CALL_DEF_CONTEXTFILLAREA_SIZE );
227       if( agroup->ContextMarker.IsSet )
228         call_func_offset_elem_ptr( CALL_DEF_CONTEXTMARKER_SIZE );
229       if( !agroup->ContextText.IsSet )
230       {
231         call_func_set_text_zoomable( Textzoomable );
232         call_func_set_text_angle( Textangle ); 
233         call_func_set_text_fontaspect( Textfontaspect );     
234         call_func_set_text_font( Fontid );
235         call_func_set_char_space( Textspace );
236         call_func_set_char_expan( Textexpan );
237         call_subr_set_text_colr( Textr, Textg, Textb );
238         call_func_set_text_style( Textstyle );
239         call_func_set_text_display_type( Textdisplaytype );
240         call_subr_set_text_colr_subtitle( Textrs, Textgs, Textbs );
241       }
242       call_func_close_struct();
243     } /* insert */
244   }
245   /* Voir commentaire en debut de fonction */
246   if (agroup->IsOpen) call_togl_opengroup (agroup);
247   return;
248 }