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


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