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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 11.1.3)


  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 //                                                 27 //
 28 //                                                 28 // 
 29 // Andrew Walkden  16th April 1997                 29 // Andrew Walkden  16th April 1997
 30 // G4OpenGLXmStyleCallbacks :                      30 // G4OpenGLXmStyleCallbacks : 
 31 //                       Several callback func     31 //                       Several callback functions used by
 32 //                       elements of the contr     32 //                       elements of the control panel to
 33 //                       determine how to visu     33 //                       determine how to visualize the view.
 34                                                    34 
 35 #include "G4OpenGLXmViewer.hh"                     35 #include "G4OpenGLXmViewer.hh"
 36 #include "G4SystemOfUnits.hh"                      36 #include "G4SystemOfUnits.hh"
 37                                                    37 
 38 void G4OpenGLXmViewer::drawing_style_callback      38 void G4OpenGLXmViewer::drawing_style_callback (Widget w, 
 39                XtPointer clientData,               39                XtPointer clientData, 
 40                XtPointer)                          40                XtPointer) 
 41 {                                                  41 {
 42   G4long choice = (G4long)clientData;              42   G4long choice = (G4long)clientData;
 43   G4OpenGLXmViewer* pView;                         43   G4OpenGLXmViewer* pView;
 44   XtVaGetValues (XtParent(w),                      44   XtVaGetValues (XtParent(w),
 45      XmNuserData, &pView,                          45      XmNuserData, &pView,
 46      NULL);                                        46      NULL);
 47   G4ViewParameters::DrawingStyle style;            47   G4ViewParameters::DrawingStyle style;
 48                                                    48 
 49   switch (choice) {                                49   switch (choice) {
 50                                                    50     
 51   case 0:                                          51   case 0:
 52     style = G4ViewParameters::wireframe;           52     style = G4ViewParameters::wireframe;
 53     break;                                         53     break;
 54                                                    54 
 55   case 1:                                          55   case 1:
 56     style = G4ViewParameters::hlr;                 56     style = G4ViewParameters::hlr;
 57     break;                                         57     break;
 58                                                    58 
 59   case 2:                                          59   case 2:
 60     style = G4ViewParameters::hsr;                 60     style = G4ViewParameters::hsr;
 61     break;                                         61     break;
 62                                                    62 
 63   case 3:                                          63   case 3:
 64     style = G4ViewParameters::hlhsr;               64     style = G4ViewParameters::hlhsr;
 65     break;                                         65     break;
 66                                                    66 
 67   default:                                         67   default:
 68     style = G4ViewParameters::wireframe;           68     style = G4ViewParameters::wireframe;
 69     G4Exception                                    69     G4Exception
 70       ("G4OpenGLXmViewer::drawing_style_callba     70       ("G4OpenGLXmViewer::drawing_style_callback",
 71        "opengl2006", FatalException,               71        "opengl2006", FatalException,
 72        "Unrecognised case in drawing_style_cal     72        "Unrecognised case in drawing_style_callback.");
 73   }                                                73   }
 74                                                    74 
 75   pView->fVP.SetDrawingStyle (style);              75   pView->fVP.SetDrawingStyle (style);
 76                                                    76   
 77   pView->SetView ();                               77   pView->SetView ();
 78   pView->ClearView ();                             78   pView->ClearView ();
 79   pView->DrawView ();                              79   pView->DrawView ();
 80 }                                                  80 }
 81                                                    81 
 82 void G4OpenGLXmViewer::background_color_callba     82 void G4OpenGLXmViewer::background_color_callback (Widget w, 
 83             XtPointer clientData,                  83             XtPointer clientData, 
 84             XtPointer)                             84             XtPointer) 
 85 {                                                  85 {
 86   G4long choice = (G4long)clientData;              86   G4long choice = (G4long)clientData;
 87   G4OpenGLXmViewer* pView;                         87   G4OpenGLXmViewer* pView;
 88   XtVaGetValues (XtParent(w),                      88   XtVaGetValues (XtParent(w),
 89      XmNuserData, &pView,                          89      XmNuserData, &pView,
 90      NULL);                                        90      NULL);
 91                                                    91 
 92                                                    92 
 93   //I need to revisit the kernel if the backgr     93   //I need to revisit the kernel if the background colour changes and
 94   //hidden line removal is enabled, because hl     94   //hidden line removal is enabled, because hlr drawing utilises the
 95   //background colour in its drawing...            95   //background colour in its drawing...
 96   // (Note added by JA 13/9/2005) Background n     96   // (Note added by JA 13/9/2005) Background now handled in view
 97   // parameters.  A kernel visit is triggered      97   // parameters.  A kernel visit is triggered on change of background.
 98   switch (choice) {                                98   switch (choice) {
 99                                                    99     
100   case 0:                                         100   case 0:
101     ((G4ViewParameters&)pView->GetViewParamete    101     ((G4ViewParameters&)pView->GetViewParameters()).
102       SetBackgroundColour(G4Colour(1.,1.,1.));    102       SetBackgroundColour(G4Colour(1.,1.,1.));  // White
103     break;                                        103     break;
104                                                   104 
105   case 1:                                         105   case 1:
106     ((G4ViewParameters&)pView->GetViewParamete    106     ((G4ViewParameters&)pView->GetViewParameters()).
107       SetBackgroundColour(G4Colour(0.,0.,0.));    107       SetBackgroundColour(G4Colour(0.,0.,0.));  // Black
108     break;                                        108     break;
109                                                   109 
110   default:                                        110   default:
111     G4Exception                                   111     G4Exception
112       ("G4OpenGLXmViewer::background_color_cal    112       ("G4OpenGLXmViewer::background_color_callback",
113        "opengl2008", FatalException,              113        "opengl2008", FatalException,
114        "Unrecognised case in background_color_    114        "Unrecognised case in background_color_callback.");
115   }                                               115   }
116                                                   116 
117   pView->SetView ();                              117   pView->SetView ();
118   pView->ClearView ();                            118   pView->ClearView ();
119   pView->DrawView ();                             119   pView->DrawView ();
120 }                                                 120 }
121                                                   121 
122 void G4OpenGLXmViewer::transparency_callback (    122 void G4OpenGLXmViewer::transparency_callback (Widget w, 
123               XtPointer clientData,               123               XtPointer clientData, 
124               XtPointer)                          124               XtPointer) 
125 {                                                 125 {
126   G4long choice = (G4long)clientData;             126   G4long choice = (G4long)clientData;
127   G4OpenGLXmViewer* pView;                        127   G4OpenGLXmViewer* pView;
128   XtVaGetValues (XtParent(w),                     128   XtVaGetValues (XtParent(w),
129      XmNuserData, &pView,                         129      XmNuserData, &pView,
130      NULL);                                       130      NULL);
131                                                   131 
132   switch (choice) {                               132   switch (choice) {
133                                                   133     
134   case 0:                                         134   case 0:
135     pView->transparency_enabled = false;          135     pView->transparency_enabled = false;
136     break;                                        136     break;
137                                                   137 
138   case 1:                                         138   case 1:
139     pView->transparency_enabled = true;           139     pView->transparency_enabled = true;
140     break;                                        140     break;
141                                                   141 
142   default:                                        142   default:
143     G4Exception                                   143     G4Exception
144       ("G4OpenGLXmViewer::transparency_callbac    144       ("G4OpenGLXmViewer::transparency_callback",
145        "opengl2009", FatalException,              145        "opengl2009", FatalException,
146        "Unrecognised case in transparency_call    146        "Unrecognised case in transparency_callback.");
147   }                                               147   }
148                                                   148 
149   pView->SetNeedKernelVisit (true);               149   pView->SetNeedKernelVisit (true);
150   pView->SetView ();                              150   pView->SetView ();
151   pView->ClearView ();                            151   pView->ClearView ();
152   pView->DrawView ();                             152   pView->DrawView ();
153 }                                                 153 }
154                                                   154 
155 void G4OpenGLXmViewer::antialias_callback (Wid    155 void G4OpenGLXmViewer::antialias_callback (Widget w, 
156            XtPointer clientData,                  156            XtPointer clientData, 
157            XtPointer)                             157            XtPointer) 
158 {                                                 158 {
159   G4long choice = (G4long)clientData;             159   G4long choice = (G4long)clientData;
160   G4OpenGLXmViewer* pView;                        160   G4OpenGLXmViewer* pView;
161   XtVaGetValues (XtParent(w),                     161   XtVaGetValues (XtParent(w),
162      XmNuserData, &pView,                         162      XmNuserData, &pView,
163      NULL);                                       163      NULL);
164                                                   164 
165   switch (choice) {                               165   switch (choice) {
166                                                   166     
167   case 0:                                         167   case 0:
168     pView->antialiasing_enabled = false;          168     pView->antialiasing_enabled = false;
169     glDisable (GL_LINE_SMOOTH);                   169     glDisable (GL_LINE_SMOOTH);
170     glDisable (GL_POLYGON_SMOOTH);                170     glDisable (GL_POLYGON_SMOOTH);
171     break;                                        171     break;
172                                                   172 
173   case 1:                                         173   case 1:
174     pView->antialiasing_enabled = true;           174     pView->antialiasing_enabled = true;
175     glEnable (GL_LINE_SMOOTH);                    175     glEnable (GL_LINE_SMOOTH);
176     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);      176     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
177     glEnable (GL_POLYGON_SMOOTH);                 177     glEnable (GL_POLYGON_SMOOTH);
178     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST)    178     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
179     break;                                        179     break;
180                                                   180 
181   default:                                        181   default:
182     G4Exception                                   182     G4Exception
183       ("G4OpenGLXmViewer::antialias_callback",    183       ("G4OpenGLXmViewer::antialias_callback",
184        "opengl2010", FatalException,              184        "opengl2010", FatalException,
185        "Unrecognised case in antialiasing_call    185        "Unrecognised case in antialiasing_callback.");
186   }                                               186   }
187                                                   187 
188   pView->SetView ();                              188   pView->SetView ();
189   pView->ClearView ();                            189   pView->ClearView ();
190   pView->DrawView ();                             190   pView->DrawView ();
191 }                                                 191 }
192                                                   192 
193 void G4OpenGLXmViewer::haloing_callback (Widge    193 void G4OpenGLXmViewer::haloing_callback (Widget w, 
194                XtPointer clientData,              194                XtPointer clientData, 
195                XtPointer)                         195                XtPointer) 
196 {                                                 196 {
197   G4long choice = (G4long)clientData;             197   G4long choice = (G4long)clientData;
198   G4OpenGLXmViewer* pView;                        198   G4OpenGLXmViewer* pView;
199   XtVaGetValues (XtParent(w),                     199   XtVaGetValues (XtParent(w),
200      XmNuserData, &pView,                         200      XmNuserData, &pView,
201      NULL);                                       201      NULL);
202                                                   202 
203   switch (choice) {                               203   switch (choice) {
204                                                   204     
205   case 0:                                         205   case 0:
206     pView->haloing_enabled = false;               206     pView->haloing_enabled = false;
207     break;                                        207     break;
208                                                   208 
209   case 1:                                         209   case 1:
210     pView->haloing_enabled = true;                210     pView->haloing_enabled = true;
211     break;                                        211     break;
212                                                   212 
213   default:                                        213   default:
214     G4Exception                                   214     G4Exception
215       ("G4OpenGLXmViewer::haloing_callback",      215       ("G4OpenGLXmViewer::haloing_callback",
216        "opengl2011", FatalException,              216        "opengl2011", FatalException,
217        "Unrecognised case in haloing_callback.    217        "Unrecognised case in haloing_callback.");
218   }                                               218   }
219                                                   219 
220   pView->SetView ();                              220   pView->SetView ();
221   pView->ClearView ();                            221   pView->ClearView ();
222   pView->DrawView ();                             222   pView->DrawView ();
223 }                                                 223 }
224                                                   224 
225 void G4OpenGLXmViewer::aux_edge_callback (Widg    225 void G4OpenGLXmViewer::aux_edge_callback (Widget w, 
226                XtPointer clientData,              226                XtPointer clientData, 
227                XtPointer)                         227                XtPointer) 
228 {                                                 228 {
229   G4long choice = (G4long)clientData;             229   G4long choice = (G4long)clientData;
230   G4OpenGLXmViewer* pView;                        230   G4OpenGLXmViewer* pView;
231   XtVaGetValues (XtParent(w),                     231   XtVaGetValues (XtParent(w),
232      XmNuserData, &pView,                         232      XmNuserData, &pView,
233      NULL);                                       233      NULL);
234                                                   234 
235   switch (choice) {                               235   switch (choice) {
236                                                   236     
237   case 0:                                         237   case 0:
238     pView->fVP.SetAuxEdgeVisible(false);          238     pView->fVP.SetAuxEdgeVisible(false);
239     break;                                        239     break;
240                                                   240 
241   case 1:                                         241   case 1:
242     pView->fVP.SetAuxEdgeVisible(true);           242     pView->fVP.SetAuxEdgeVisible(true);
243     break;                                        243     break;
244                                                   244 
245   default:                                        245   default:
246     G4Exception                                   246     G4Exception
247       ("G4OpenGLXmViewer::aux_edge_callback",     247       ("G4OpenGLXmViewer::aux_edge_callback",
248        "opengl2012", FatalException,              248        "opengl2012", FatalException,
249        "Unrecognised case in aux_edge_callback    249        "Unrecognised case in aux_edge_callback.");
250   }                                               250   }
251                                                   251 
252   pView->SetNeedKernelVisit (true);               252   pView->SetNeedKernelVisit (true);
253   pView->SetView ();                              253   pView->SetView ();
254   pView->ClearView ();                            254   pView->ClearView ();
255   pView->DrawView ();                             255   pView->DrawView ();
256 }                                                 256 }
257                                                   257 
258 void G4OpenGLXmViewer::projection_callback (Wi    258 void G4OpenGLXmViewer::projection_callback (Widget w, 
259             XtPointer clientData,                 259             XtPointer clientData, 
260             XtPointer)                            260             XtPointer) 
261 {                                                 261 {
262   G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*    262   G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
263                                                   263 
264   G4int choice = get_int_userData (w);            264   G4int choice = get_int_userData (w);
265                                                   265 
266   switch (choice) {                               266   switch (choice) {
267   case 0:                                         267   case 0:
268     {                                             268     {
269       pView->fVP.SetFieldHalfAngle (0.);          269       pView->fVP.SetFieldHalfAngle (0.);
270       break;                                      270       break;
271     }                                             271     }
272                                                   272 
273   case 1:                                         273   case 1:
274     {                                             274     {
275       if (pView->fov > 89.5 || pView->fov <= 0    275       if (pView->fov > 89.5 || pView->fov <= 0.0) {
276   G4cout << "Field half angle should be 0 < an    276   G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
277   G4cout << G4endl;                               277   G4cout << G4endl;
278       }                                           278       }
279       else {                                      279       else {
280   pView->fVP.SetFieldHalfAngle (pView->fov * d    280   pView->fVP.SetFieldHalfAngle (pView->fov * deg);
281       }                                           281       }
282       break;                                      282       break;
283     }                                             283     }
284   default:                                        284   default:
285     {                                             285     {
286       G4Exception                                 286       G4Exception
287   ("G4OpenGLXmViewer::projection_callback",       287   ("G4OpenGLXmViewer::projection_callback",
288    "opengl2013", FatalException,                  288    "opengl2013", FatalException,
289    "Unrecognised choice made in projection_cal    289    "Unrecognised choice made in projection_callback");
290     }                                             290     }
291   }                                               291   }
292                                                   292 
293   pView->SetView ();                              293   pView->SetView ();
294   pView->ClearView ();                            294   pView->ClearView ();
295   pView->DrawView ();                             295   pView->DrawView ();
296 }                                                 296 }  
297                                                   297