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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 4.0.p2)


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