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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 10.1.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: G4OpenGLXmStyleCallbacks.cc 66373 2012-12-18 09:41:34Z gcosmo $
 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 
 82 void G4OpenGLXmViewer::background_color_callba     85 void G4OpenGLXmViewer::background_color_callback (Widget w, 
 83             XtPointer clientData,                  86             XtPointer clientData, 
 84             XtPointer)                             87             XtPointer) 
 85 {                                                  88 {
 86   G4long choice = (G4long)clientData;              89   G4long choice = (G4long)clientData;
 87   G4OpenGLXmViewer* pView;                         90   G4OpenGLXmViewer* pView;
 88   XtVaGetValues (XtParent(w),                      91   XtVaGetValues (XtParent(w),
 89      XmNuserData, &pView,                          92      XmNuserData, &pView,
 90      NULL);                                        93      NULL);
 91                                                    94 
 92                                                    95 
 93   //I need to revisit the kernel if the backgr     96   //I need to revisit the kernel if the background colour changes and
 94   //hidden line removal is enabled, because hl     97   //hidden line removal is enabled, because hlr drawing utilises the
 95   //background colour in its drawing...            98   //background colour in its drawing...
 96   // (Note added by JA 13/9/2005) Background n     99   // (Note added by JA 13/9/2005) Background now handled in view
 97   // parameters.  A kernel visit is triggered     100   // parameters.  A kernel visit is triggered on change of background.
 98   switch (choice) {                               101   switch (choice) {
 99                                                   102     
100   case 0:                                         103   case 0:
101     ((G4ViewParameters&)pView->GetViewParamete    104     ((G4ViewParameters&)pView->GetViewParameters()).
102       SetBackgroundColour(G4Colour(1.,1.,1.));    105       SetBackgroundColour(G4Colour(1.,1.,1.));  // White
103     break;                                        106     break;
104                                                   107 
105   case 1:                                         108   case 1:
106     ((G4ViewParameters&)pView->GetViewParamete    109     ((G4ViewParameters&)pView->GetViewParameters()).
107       SetBackgroundColour(G4Colour(0.,0.,0.));    110       SetBackgroundColour(G4Colour(0.,0.,0.));  // Black
108     break;                                        111     break;
109                                                   112 
110   default:                                        113   default:
111     G4Exception                                   114     G4Exception
112       ("G4OpenGLXmViewer::background_color_cal    115       ("G4OpenGLXmViewer::background_color_callback",
113        "opengl2008", FatalException,              116        "opengl2008", FatalException,
114        "Unrecognised case in background_color_    117        "Unrecognised case in background_color_callback.");
115   }                                               118   }
116                                                   119 
117   pView->SetView ();                              120   pView->SetView ();
118   pView->ClearView ();                            121   pView->ClearView ();
119   pView->DrawView ();                             122   pView->DrawView ();
120 }                                                 123 }
121                                                   124 
122 void G4OpenGLXmViewer::transparency_callback (    125 void G4OpenGLXmViewer::transparency_callback (Widget w, 
123               XtPointer clientData,               126               XtPointer clientData, 
124               XtPointer)                          127               XtPointer) 
125 {                                                 128 {
126   G4long choice = (G4long)clientData;             129   G4long choice = (G4long)clientData;
127   G4OpenGLXmViewer* pView;                        130   G4OpenGLXmViewer* pView;
128   XtVaGetValues (XtParent(w),                     131   XtVaGetValues (XtParent(w),
129      XmNuserData, &pView,                         132      XmNuserData, &pView,
130      NULL);                                       133      NULL);
131                                                   134 
132   switch (choice) {                               135   switch (choice) {
133                                                   136     
134   case 0:                                         137   case 0:
135     pView->transparency_enabled = false;          138     pView->transparency_enabled = false;
136     break;                                        139     break;
137                                                   140 
138   case 1:                                         141   case 1:
139     pView->transparency_enabled = true;           142     pView->transparency_enabled = true;
140     break;                                        143     break;
141                                                   144 
142   default:                                        145   default:
143     G4Exception                                   146     G4Exception
144       ("G4OpenGLXmViewer::transparency_callbac    147       ("G4OpenGLXmViewer::transparency_callback",
145        "opengl2009", FatalException,              148        "opengl2009", FatalException,
146        "Unrecognised case in transparency_call    149        "Unrecognised case in transparency_callback.");
147   }                                               150   }
148                                                   151 
149   pView->SetNeedKernelVisit (true);               152   pView->SetNeedKernelVisit (true);
150   pView->SetView ();                              153   pView->SetView ();
151   pView->ClearView ();                            154   pView->ClearView ();
152   pView->DrawView ();                             155   pView->DrawView ();
153 }                                                 156 }
154                                                   157 
155 void G4OpenGLXmViewer::antialias_callback (Wid    158 void G4OpenGLXmViewer::antialias_callback (Widget w, 
156            XtPointer clientData,                  159            XtPointer clientData, 
157            XtPointer)                             160            XtPointer) 
158 {                                                 161 {
159   G4long choice = (G4long)clientData;             162   G4long choice = (G4long)clientData;
160   G4OpenGLXmViewer* pView;                        163   G4OpenGLXmViewer* pView;
161   XtVaGetValues (XtParent(w),                     164   XtVaGetValues (XtParent(w),
162      XmNuserData, &pView,                         165      XmNuserData, &pView,
163      NULL);                                       166      NULL);
164                                                   167 
165   switch (choice) {                               168   switch (choice) {
166                                                   169     
167   case 0:                                         170   case 0:
168     pView->antialiasing_enabled = false;          171     pView->antialiasing_enabled = false;
169     glDisable (GL_LINE_SMOOTH);                   172     glDisable (GL_LINE_SMOOTH);
170     glDisable (GL_POLYGON_SMOOTH);                173     glDisable (GL_POLYGON_SMOOTH);
171     break;                                        174     break;
172                                                   175 
173   case 1:                                         176   case 1:
174     pView->antialiasing_enabled = true;           177     pView->antialiasing_enabled = true;
175     glEnable (GL_LINE_SMOOTH);                    178     glEnable (GL_LINE_SMOOTH);
176     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);      179     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
177     glEnable (GL_POLYGON_SMOOTH);                 180     glEnable (GL_POLYGON_SMOOTH);
178     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST)    181     glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
179     break;                                        182     break;
180                                                   183 
181   default:                                        184   default:
182     G4Exception                                   185     G4Exception
183       ("G4OpenGLXmViewer::antialias_callback",    186       ("G4OpenGLXmViewer::antialias_callback",
184        "opengl2010", FatalException,              187        "opengl2010", FatalException,
185        "Unrecognised case in antialiasing_call    188        "Unrecognised case in antialiasing_callback.");
186   }                                               189   }
187                                                   190 
188   pView->SetView ();                              191   pView->SetView ();
189   pView->ClearView ();                            192   pView->ClearView ();
190   pView->DrawView ();                             193   pView->DrawView ();
191 }                                                 194 }
192                                                   195 
193 void G4OpenGLXmViewer::haloing_callback (Widge    196 void G4OpenGLXmViewer::haloing_callback (Widget w, 
194                XtPointer clientData,              197                XtPointer clientData, 
195                XtPointer)                         198                XtPointer) 
196 {                                                 199 {
197   G4long choice = (G4long)clientData;             200   G4long choice = (G4long)clientData;
198   G4OpenGLXmViewer* pView;                        201   G4OpenGLXmViewer* pView;
199   XtVaGetValues (XtParent(w),                     202   XtVaGetValues (XtParent(w),
200      XmNuserData, &pView,                         203      XmNuserData, &pView,
201      NULL);                                       204      NULL);
202                                                   205 
203   switch (choice) {                               206   switch (choice) {
204                                                   207     
205   case 0:                                         208   case 0:
206     pView->haloing_enabled = false;               209     pView->haloing_enabled = false;
207     break;                                        210     break;
208                                                   211 
209   case 1:                                         212   case 1:
210     pView->haloing_enabled = true;                213     pView->haloing_enabled = true;
211     break;                                        214     break;
212                                                   215 
213   default:                                        216   default:
214     G4Exception                                   217     G4Exception
215       ("G4OpenGLXmViewer::haloing_callback",      218       ("G4OpenGLXmViewer::haloing_callback",
216        "opengl2011", FatalException,              219        "opengl2011", FatalException,
217        "Unrecognised case in haloing_callback.    220        "Unrecognised case in haloing_callback.");
218   }                                               221   }
219                                                   222 
220   pView->SetView ();                              223   pView->SetView ();
221   pView->ClearView ();                            224   pView->ClearView ();
222   pView->DrawView ();                             225   pView->DrawView ();
223 }                                                 226 }
224                                                   227 
225 void G4OpenGLXmViewer::aux_edge_callback (Widg    228 void G4OpenGLXmViewer::aux_edge_callback (Widget w, 
226                XtPointer clientData,              229                XtPointer clientData, 
227                XtPointer)                         230                XtPointer) 
228 {                                                 231 {
229   G4long choice = (G4long)clientData;             232   G4long choice = (G4long)clientData;
230   G4OpenGLXmViewer* pView;                        233   G4OpenGLXmViewer* pView;
231   XtVaGetValues (XtParent(w),                     234   XtVaGetValues (XtParent(w),
232      XmNuserData, &pView,                         235      XmNuserData, &pView,
233      NULL);                                       236      NULL);
234                                                   237 
235   switch (choice) {                               238   switch (choice) {
236                                                   239     
237   case 0:                                         240   case 0:
238     pView->fVP.SetAuxEdgeVisible(false);          241     pView->fVP.SetAuxEdgeVisible(false);
239     break;                                        242     break;
240                                                   243 
241   case 1:                                         244   case 1:
242     pView->fVP.SetAuxEdgeVisible(true);           245     pView->fVP.SetAuxEdgeVisible(true);
243     break;                                        246     break;
244                                                   247 
245   default:                                        248   default:
246     G4Exception                                   249     G4Exception
247       ("G4OpenGLXmViewer::aux_edge_callback",     250       ("G4OpenGLXmViewer::aux_edge_callback",
248        "opengl2012", FatalException,              251        "opengl2012", FatalException,
249        "Unrecognised case in aux_edge_callback    252        "Unrecognised case in aux_edge_callback.");
250   }                                               253   }
251                                                   254 
252   pView->SetNeedKernelVisit (true);               255   pView->SetNeedKernelVisit (true);
253   pView->SetView ();                              256   pView->SetView ();
254   pView->ClearView ();                            257   pView->ClearView ();
255   pView->DrawView ();                             258   pView->DrawView ();
256 }                                                 259 }
257                                                   260 
258 void G4OpenGLXmViewer::projection_callback (Wi    261 void G4OpenGLXmViewer::projection_callback (Widget w, 
259             XtPointer clientData,                 262             XtPointer clientData, 
260             XtPointer)                            263             XtPointer) 
261 {                                                 264 {
262   G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*    265   G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*)clientData;
263                                                   266 
264   G4int choice = get_int_userData (w);            267   G4int choice = get_int_userData (w);
265                                                   268 
266   switch (choice) {                               269   switch (choice) {
267   case 0:                                         270   case 0:
268     {                                             271     {
269       pView->fVP.SetFieldHalfAngle (0.);          272       pView->fVP.SetFieldHalfAngle (0.);
270       break;                                      273       break;
271     }                                             274     }
272                                                   275 
273   case 1:                                         276   case 1:
274     {                                             277     {
275       if (pView->fov > 89.5 || pView->fov <= 0    278       if (pView->fov > 89.5 || pView->fov <= 0.0) {
276   G4cout << "Field half angle should be 0 < an    279   G4cout << "Field half angle should be 0 < angle <= 89.5 degrees.";
277   G4cout << G4endl;                               280   G4cout << G4endl;
278       }                                           281       }
279       else {                                      282       else {
280   pView->fVP.SetFieldHalfAngle (pView->fov * d    283   pView->fVP.SetFieldHalfAngle (pView->fov * deg);
281       }                                           284       }
282       break;                                      285       break;
283     }                                             286     }
284   default:                                        287   default:
285     {                                             288     {
286       G4Exception                                 289       G4Exception
287   ("G4OpenGLXmViewer::projection_callback",       290   ("G4OpenGLXmViewer::projection_callback",
288    "opengl2013", FatalException,                  291    "opengl2013", FatalException,
289    "Unrecognised choice made in projection_cal    292    "Unrecognised choice made in projection_callback");
290     }                                             293     }
291   }                                               294   }
292                                                   295 
293   pView->SetView ();                              296   pView->SetView ();
294   pView->ClearView ();                            297   pView->ClearView ();
295   pView->DrawView ();                             298   pView->DrawView ();
296 }                                                 299 }  
                                                   >> 300 
                                                   >> 301 #endif
                                                   >> 302 
297                                                   303