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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenGL/src/G4OpenGLXmStyleCallbacks.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLXmStyleCallbacks.cc (Version 9.6.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id$
 27 //                                                 28 //
 28 //                                                 29 // 
 29 // Andrew Walkden  16th April 1997                 30 // Andrew Walkden  16th April 1997
 30 // G4OpenGLXmStyleCallbacks :                      31 // G4OpenGLXmStyleCallbacks : 
 31 //                       Several callback func     32 //                       Several callback functions used by
 32 //                       elements of the contr     33 //                       elements of the control panel to
 33 //                       determine how to visu     34 //                       determine how to visualize the view.
 34                                                    35 
                                                   >>  36 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
                                                   >>  37 
 35 #include "G4OpenGLXmViewer.hh"                     38 #include "G4OpenGLXmViewer.hh"
 36 #include "G4SystemOfUnits.hh"                      39 #include "G4SystemOfUnits.hh"
 37                                                    40 
 38 void G4OpenGLXmViewer::drawing_style_callback      41 void G4OpenGLXmViewer::drawing_style_callback (Widget w, 
 39                XtPointer clientData,               42                XtPointer clientData, 
 40                XtPointer)                          43                XtPointer) 
 41 {                                                  44 {
 42   G4long choice = (G4long)clientData;              45   G4long choice = (G4long)clientData;
 43   G4OpenGLXmViewer* pView;                         46   G4OpenGLXmViewer* pView;
 44   XtVaGetValues (XtParent(w),                      47   XtVaGetValues (XtParent(w),
 45      XmNuserData, &pView,                          48      XmNuserData, &pView,
 46      NULL);                                        49      NULL);
 47   G4ViewParameters::DrawingStyle style;            50   G4ViewParameters::DrawingStyle style;
 48                                                    51 
 49   switch (choice) {                                52   switch (choice) {
 50                                                    53     
 51   case 0:                                          54   case 0:
 52     style = G4ViewParameters::wireframe;           55     style = G4ViewParameters::wireframe;
 53     break;                                         56     break;
 54                                                    57 
 55   case 1:                                          58   case 1:
 56     style = G4ViewParameters::hlr;                 59     style = G4ViewParameters::hlr;
 57     break;                                         60     break;
 58                                                    61 
 59   case 2:                                          62   case 2:
 60     style = G4ViewParameters::hsr;                 63     style = G4ViewParameters::hsr;
 61     break;                                         64     break;
 62                                                    65 
 63   case 3:                                          66   case 3:
 64     style = G4ViewParameters::hlhsr;               67     style = G4ViewParameters::hlhsr;
 65     break;                                         68     break;
 66                                                    69 
 67   default:                                         70   default:
 68     style = G4ViewParameters::wireframe;           71     style = G4ViewParameters::wireframe;
 69     G4Exception                                    72     G4Exception
 70       ("G4OpenGLXmViewer::drawing_style_callba     73       ("G4OpenGLXmViewer::drawing_style_callback",
 71        "opengl2006", FatalException,               74        "opengl2006", FatalException,
 72        "Unrecognised case in drawing_style_cal     75        "Unrecognised case in drawing_style_callback.");
 73   }                                                76   }
 74                                                    77 
 75   pView->fVP.SetDrawingStyle (style);              78   pView->fVP.SetDrawingStyle (style);
 76                                                    79   
 77   pView->SetView ();                               80   pView->SetView ();
 78   pView->ClearView ();                             81   pView->ClearView ();
 79   pView->DrawView ();                              82   pView->DrawView ();
 80 }                                                  83 }
 81                                                    84 
                                                   >>  85 void G4OpenGLXmViewer::rep_style_callback (Widget w, 
                                                   >>  86            XtPointer clientData, 
                                                   >>  87            XtPointer) 
                                                   >>  88 {
                                                   >>  89   G4long choice = (G4long)clientData;
                                                   >>  90   G4OpenGLXmViewer* pView;
                                                   >>  91   XtVaGetValues (XtParent(w),
                                                   >>  92      XmNuserData, &pView,
                                                   >>  93      NULL);
                                                   >>  94   G4ViewParameters::RepStyle style;
                                                   >>  95 
                                                   >>  96   switch (choice) {
                                                   >>  97     
                                                   >>  98   case 0:
                                                   >>  99     style = G4ViewParameters::polyhedron;
                                                   >> 100     break;
                                                   >> 101 
                                                   >> 102   case 1:
                                                   >> 103     style = G4ViewParameters::nurbs;
                                                   >> 104     break;
                                                   >> 105 
                                                   >> 106   default:
                                                   >> 107     style = G4ViewParameters::polyhedron;
                                                   >> 108     G4Exception
                                                   >> 109       ("G4OpenGLXmViewer::rep_style_callback",
                                                   >> 110        "opengl2007", FatalException,
                                                   >> 111        "Unrecognised case in rep_style_callback.");
                                                   >> 112   }
                                                   >> 113 
                                                   >> 114   pView->fVP.SetRepStyle (style);
                                                   >> 115 
                                                   >> 116   pView->SetView ();
                                                   >> 117   pView->ClearView ();
                                                   >> 118   pView->DrawView ();
                                                   >> 119 }
                                                   >> 120 
 82 void G4OpenGLXmViewer::background_color_callba    121 void G4OpenGLXmViewer::background_color_callback (Widget w, 
 83             XtPointer clientData,                 122             XtPointer clientData, 
 84             XtPointer)                            123             XtPointer) 
 85 {                                                 124 {
 86   G4long choice = (G4long)clientData;             125   G4long choice = (G4long)clientData;
 87   G4OpenGLXmViewer* pView;                        126   G4OpenGLXmViewer* pView;
 88   XtVaGetValues (XtParent(w),                     127   XtVaGetValues (XtParent(w),
 89      XmNuserData, &pView,                         128      XmNuserData, &pView,
 90      NULL);                                       129      NULL);
 91                                                   130 
 92                                                   131 
 93   //I need to revisit the kernel if the backgr    132   //I need to revisit the kernel if the background colour changes and
 94   //hidden line removal is enabled, because hl    133   //hidden line removal is enabled, because hlr drawing utilises the
 95   //background colour in its drawing...           134   //background colour in its drawing...
 96   // (Note added by JA 13/9/2005) Background n    135   // (Note added by JA 13/9/2005) Background now handled in view
 97   // parameters.  A kernel visit is triggered     136   // parameters.  A kernel visit is triggered on change of background.
 98   switch (choice) {                               137   switch (choice) {
 99                                                   138     
100   case 0:                                         139   case 0:
101     ((G4ViewParameters&)pView->GetViewParamete    140     ((G4ViewParameters&)pView->GetViewParameters()).
102       SetBackgroundColour(G4Colour(1.,1.,1.));    141       SetBackgroundColour(G4Colour(1.,1.,1.));  // White
103     break;                                        142     break;
104                                                   143 
105   case 1:                                         144   case 1:
106     ((G4ViewParameters&)pView->GetViewParamete    145     ((G4ViewParameters&)pView->GetViewParameters()).
107       SetBackgroundColour(G4Colour(0.,0.,0.));    146       SetBackgroundColour(G4Colour(0.,0.,0.));  // Black
108     break;                                        147     break;
109                                                   148 
110   default:                                        149   default:
111     G4Exception                                   150     G4Exception
112       ("G4OpenGLXmViewer::background_color_cal    151       ("G4OpenGLXmViewer::background_color_callback",
113        "opengl2008", FatalException,              152        "opengl2008", FatalException,
114        "Unrecognised case in background_color_    153        "Unrecognised case in background_color_callback.");
115   }                                               154   }
116                                                   155 
117   pView->SetView ();                              156   pView->SetView ();
118   pView->ClearView ();                            157   pView->ClearView ();
119   pView->DrawView ();                             158   pView->DrawView ();
120 }                                                 159 }
121                                                   160 
122 void G4OpenGLXmViewer::transparency_callback (    161 void G4OpenGLXmViewer::transparency_callback (Widget w, 
123               XtPointer clientData,               162               XtPointer clientData, 
124               XtPointer)                          163               XtPointer) 
125 {                                                 164 {
126   G4long choice = (G4long)clientData;             165   G4long choice = (G4long)clientData;
127   G4OpenGLXmViewer* pView;                        166   G4OpenGLXmViewer* pView;
128   XtVaGetValues (XtParent(w),                     167   XtVaGetValues (XtParent(w),
129      XmNuserData, &pView,                         168      XmNuserData, &pView,
130      NULL);                                       169      NULL);
131                                                   170 
132   switch (choice) {                               171   switch (choice) {
133                                                   172     
134   case 0:                                         173   case 0:
135     pView->transparency_enabled = false;          174     pView->transparency_enabled = false;
136     break;                                        175     break;
137                                                   176 
138   case 1:                                         177   case 1:
139     pView->transparency_enabled = true;           178     pView->transparency_enabled = true;
140     break;                                        179     break;
141                                                   180 
142   default:                                        181   default:
143     G4Exception                                   182     G4Exception
144       ("G4OpenGLXmViewer::transparency_callbac    183       ("G4OpenGLXmViewer::transparency_callback",
145        "opengl2009", FatalException,              184        "opengl2009", FatalException,
146        "Unrecognised case in transparency_call    185        "Unrecognised case in transparency_callback.");
147   }                                               186   }
148                                                   187 
149   pView->SetNeedKernelVisit (true);               188   pView->SetNeedKernelVisit (true);
150   pView->SetView ();                              189   pView->SetView ();
151   pView->ClearView ();                            190   pView->ClearView ();
152   pView->DrawView ();                             191   pView->DrawView ();
153 }                                                 192 }
154                                                   193 
155 void G4OpenGLXmViewer::antialias_callback (Wid    194 void G4OpenGLXmViewer::antialias_callback (Widget w, 
156            XtPointer clientData,                  195            XtPointer clientData, 
157            XtPointer)                             196            XtPointer) 
158 {                                                 197 {
159   G4long choice = (G4long)clientData;             198   G4long choice = (G4long)clientData;
160   G4OpenGLXmViewer* pView;                        199   G4OpenGLXmViewer* pView;
161   XtVaGetValues (XtParent(w),                     200   XtVaGetValues (XtParent(w),
162      XmNuserData, &pView,                         201      XmNuserData, &pView,
163      NULL);                                       202      NULL);
164                                                   203 
165   switch (choice) {                               204   switch (choice) {
166                                                   205     
167   case 0:                                         206   case 0:
168     pView->antialiasing_enabled = false;          207     pView->antialiasing_enabled = false;
169     glDisable (GL_LINE_SMOOTH);                   208     glDisable (GL_LINE_SMOOTH);
170     glDisable (GL_POLYGON_SMOOTH);                209     glDisable (GL_POLYGON_SMOOTH);
171     break;                                        210     break;
172                                                   211 
173   case 1:                                         212   case 1:
174     pView->antialiasing_enabled = true;           213     pView->antialiasing_enabled = true;
175     glEnable (GL_LINE_SMOOTH);                    214     glEnable (GL_LINE_SMOOTH);
176     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);      215     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
177     glEnable (GL_POLYGON_SMOOTH);                 216     glEnable (GL_POLYGON_SMOOTH);
178     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST)    217     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
179     break;                                        218     break;
180                                                   219 
181   default:                                        220   default:
182     G4Exception                                   221     G4Exception
183       ("G4OpenGLXmViewer::antialias_callback",    222       ("G4OpenGLXmViewer::antialias_callback",
184        "opengl2010", FatalException,              223        "opengl2010", FatalException,
185        "Unrecognised case in antialiasing_call    224        "Unrecognised case in antialiasing_callback.");
186   }                                               225   }
187                                                   226 
188   pView->SetView ();                              227   pView->SetView ();
189   pView->ClearView ();                            228   pView->ClearView ();
190   pView->DrawView ();                             229   pView->DrawView ();
191 }                                                 230 }
192                                                   231 
193 void G4OpenGLXmViewer::haloing_callback (Widge    232 void G4OpenGLXmViewer::haloing_callback (Widget w, 
194                XtPointer clientData,              233                XtPointer clientData, 
195                XtPointer)                         234                XtPointer) 
196 {                                                 235 {
197   G4long choice = (G4long)clientData;             236   G4long choice = (G4long)clientData;
198   G4OpenGLXmViewer* pView;                        237   G4OpenGLXmViewer* pView;
199   XtVaGetValues (XtParent(w),                     238   XtVaGetValues (XtParent(w),
200      XmNuserData, &pView,                         239      XmNuserData, &pView,
201      NULL);                                       240      NULL);
202                                                   241 
203   switch (choice) {                               242   switch (choice) {
204                                                   243     
205   case 0:                                         244   case 0:
206     pView->haloing_enabled = false;               245     pView->haloing_enabled = false;
207     break;                                        246     break;
208                                                   247 
209   case 1:                                         248   case 1:
210     pView->haloing_enabled = true;                249     pView->haloing_enabled = true;
211     break;                                        250     break;
212                                                   251 
213   default:                                        252   default:
214     G4Exception                                   253     G4Exception
215       ("G4OpenGLXmViewer::haloing_callback",      254       ("G4OpenGLXmViewer::haloing_callback",
216        "opengl2011", FatalException,              255        "opengl2011", FatalException,
217        "Unrecognised case in haloing_callback.    256        "Unrecognised case in haloing_callback.");
218   }                                               257   }
219                                                   258 
220   pView->SetView ();                              259   pView->SetView ();
221   pView->ClearView ();                            260   pView->ClearView ();
222   pView->DrawView ();                             261   pView->DrawView ();
223 }                                                 262 }
224                                                   263 
225 void G4OpenGLXmViewer::aux_edge_callback (Widg    264 void G4OpenGLXmViewer::aux_edge_callback (Widget w, 
226                XtPointer clientData,              265                XtPointer clientData, 
227                XtPointer)                         266                XtPointer) 
228 {                                                 267 {
229   G4long choice = (G4long)clientData;             268   G4long choice = (G4long)clientData;
230   G4OpenGLXmViewer* pView;                        269   G4OpenGLXmViewer* pView;
231   XtVaGetValues (XtParent(w),                     270   XtVaGetValues (XtParent(w),
232      XmNuserData, &pView,                         271      XmNuserData, &pView,
233      NULL);                                       272      NULL);
234                                                   273 
235   switch (choice) {                               274   switch (choice) {
236                                                   275     
237   case 0:                                         276   case 0:
238     pView->fVP.SetAuxEdgeVisible(false);          277     pView->fVP.SetAuxEdgeVisible(false);
239     break;                                        278     break;
240                                                   279 
241   case 1:                                         280   case 1:
242     pView->fVP.SetAuxEdgeVisible(true);           281     pView->fVP.SetAuxEdgeVisible(true);
243     break;                                        282     break;
244                                                   283 
245   default:                                        284   default:
246     G4Exception                                   285     G4Exception
247       ("G4OpenGLXmViewer::aux_edge_callback",     286       ("G4OpenGLXmViewer::aux_edge_callback",
248        "opengl2012", FatalException,              287        "opengl2012", FatalException,
249        "Unrecognised case in aux_edge_callback    288        "Unrecognised case in aux_edge_callback.");
250   }                                               289   }
251                                                   290 
252   pView->SetNeedKernelVisit (true);               291   pView->SetNeedKernelVisit (true);
253   pView->SetView ();                              292   pView->SetView ();
254   pView->ClearView ();                            293   pView->ClearView ();
255   pView->DrawView ();                             294   pView->DrawView ();
256 }                                                 295 }
257                                                   296 
258 void G4OpenGLXmViewer::projection_callback (Wi    297 void G4OpenGLXmViewer::projection_callback (Widget w, 
259             XtPointer clientData,                 298             XtPointer clientData, 
260             XtPointer)                            299             XtPointer) 
261 {                                                 300 {
262   G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*    301   G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
263                                                   302 
264   G4int choice = get_int_userData (w);            303   G4int choice = get_int_userData (w);
265                                                   304 
266   switch (choice) {                               305   switch (choice) {
267   case 0:                                         306   case 0:
268     {                                             307     {
269       pView->fVP.SetFieldHalfAngle (0.);          308       pView->fVP.SetFieldHalfAngle (0.);
270       break;                                      309       break;
271     }                                             310     }
272                                                   311 
273   case 1:                                         312   case 1:
274     {                                             313     {
275       if (pView->fov > 89.5 || pView->fov <= 0    314       if (pView->fov > 89.5 || pView->fov <= 0.0) {
276   G4cout << "Field half angle should be 0 < an    315   G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
277   G4cout << G4endl;                               316   G4cout << G4endl;
278       }                                           317       }
279       else {                                      318       else {
280   pView->fVP.SetFieldHalfAngle (pView->fov * d    319   pView->fVP.SetFieldHalfAngle (pView->fov * deg);
281       }                                           320       }
282       break;                                      321       break;
283     }                                             322     }
284   default:                                        323   default:
285     {                                             324     {
286       G4Exception                                 325       G4Exception
287   ("G4OpenGLXmViewer::projection_callback",       326   ("G4OpenGLXmViewer::projection_callback",
288    "opengl2013", FatalException,                  327    "opengl2013", FatalException,
289    "Unrecognised choice made in projection_cal    328    "Unrecognised choice made in projection_callback");
290     }                                             329     }
291   }                                               330   }
292                                                   331 
293   pView->SetView ();                              332   pView->SetView ();
294   pView->ClearView ();                            333   pView->ClearView ();
295   pView->DrawView ();                             334   pView->DrawView ();
296 }                                                 335 }  
                                                   >> 336 
                                                   >> 337 #endif
                                                   >> 338 
297                                                   339