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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/G4OpenGLXmViewerMessenger.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLXmViewerMessenger.cc (Version 11.2.1)


  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 #include "G4OpenGLXmViewerMessenger.hh"            28 #include "G4OpenGLXmViewerMessenger.hh"
 29                                                    29 
 30 #include "G4SystemOfUnits.hh"                      30 #include "G4SystemOfUnits.hh"
 31 #include "G4OpenGLXmViewer.hh"                     31 #include "G4OpenGLXmViewer.hh"
 32 #include "G4OpenGLXmSliderBar.hh"                  32 #include "G4OpenGLXmSliderBar.hh"
 33                                                    33 
 34 #include "G4UImanager.hh"                          34 #include "G4UImanager.hh"
 35 #include "G4UIcommand.hh"                          35 #include "G4UIcommand.hh"
 36 #include "G4UIdirectory.hh"                        36 #include "G4UIdirectory.hh"
 37 #include "G4UIcmdWithADoubleAndUnit.hh"            37 #include "G4UIcmdWithADoubleAndUnit.hh"
 38 #include "G4UIcmdWithADouble.hh"                   38 #include "G4UIcmdWithADouble.hh"
 39                                                    39 
 40 #include "G4VisManager.hh"                         40 #include "G4VisManager.hh"
 41                                                    41 
 42 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMes     42 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMessenger::fpInstance = 0;
 43                                                    43 
 44 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMes     44 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMessenger::GetInstance()
 45 {                                                  45 {
 46   if (!fpInstance) fpInstance = new G4OpenGLXm     46   if (!fpInstance) fpInstance = new G4OpenGLXmViewerMessenger;
 47   return fpInstance;                               47   return fpInstance;
 48 }                                                  48 }
 49                                                    49 
 50 G4OpenGLXmViewerMessenger::G4OpenGLXmViewerMes     50 G4OpenGLXmViewerMessenger::G4OpenGLXmViewerMessenger()
 51 {                                                  51 {
 52   G4bool omitable;                                 52   G4bool omitable;
 53                                                    53 
 54   fpDirectory = new G4UIdirectory("/vis/oglxm/     54   fpDirectory = new G4UIdirectory("/vis/oglxm/");
 55   fpDirectory->SetGuidance("G4OpenGLXmViewer c     55   fpDirectory->SetGuidance("G4OpenGLXmViewer commands.");
 56                                                    56 
 57   fpDirectorySet = new G4UIdirectory ("/vis/og     57   fpDirectorySet = new G4UIdirectory ("/vis/oglxm/set/");
 58   fpDirectorySet->SetGuidance("G4OpenGLXmViewe     58   fpDirectorySet->SetGuidance("G4OpenGLXmViewer set commands.");
 59                                                    59 
 60   fpCommandSetDollyHigh =                          60   fpCommandSetDollyHigh =
 61     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/     61     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/set/dolly-high", this);
 62   fpCommandSetDollyHigh->SetGuidance("Higher l     62   fpCommandSetDollyHigh->SetGuidance("Higher limit of dolly slider.");
 63   fpCommandSetDollyHigh->SetParameterName("dol     63   fpCommandSetDollyHigh->SetParameterName("dolly-high", omitable = false);
 64                                                    64 
 65   fpCommandSetDollyLow =                           65   fpCommandSetDollyLow =
 66     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/     66     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/set/dolly-low", this);
 67   fpCommandSetDollyLow->SetGuidance("Lower lim     67   fpCommandSetDollyLow->SetGuidance("Lower limit of dolly slider.");
 68   fpCommandSetDollyLow->SetParameterName("doll     68   fpCommandSetDollyLow->SetParameterName("dolly-low", omitable = false);
 69                                                    69 
 70   fpCommandSetPanHigh =                            70   fpCommandSetPanHigh =
 71     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/     71     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/set/pan-high", this);
 72   fpCommandSetPanHigh->SetGuidance("Higher lim     72   fpCommandSetPanHigh->SetGuidance("Higher limit of pan slider.");
 73   fpCommandSetPanHigh->SetParameterName("pan-h     73   fpCommandSetPanHigh->SetParameterName("pan-high", omitable = false);
 74                                                    74 
 75   fpCommandSetRotationHigh =                       75   fpCommandSetRotationHigh =
 76     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/     76     new G4UIcmdWithADoubleAndUnit("/vis/oglxm/set/rotation-high", this);
 77   fpCommandSetRotationHigh->SetGuidance("Highe     77   fpCommandSetRotationHigh->SetGuidance("Higher limit of rotation slider.");
 78   fpCommandSetRotationHigh->SetParameterName("     78   fpCommandSetRotationHigh->SetParameterName("rotation-high", omitable = false);
 79                                                    79 
 80   fpCommandSetZoomHigh =                           80   fpCommandSetZoomHigh =
 81     new G4UIcmdWithADouble("/vis/oglxm/set/zoo     81     new G4UIcmdWithADouble("/vis/oglxm/set/zoom-high", this);
 82   fpCommandSetZoomHigh->SetGuidance("Higher li     82   fpCommandSetZoomHigh->SetGuidance("Higher limit of zoom slider.");
 83   fpCommandSetZoomHigh->SetParameterName("zoom     83   fpCommandSetZoomHigh->SetParameterName("zoom-high", omitable = false);
 84                                                    84 
 85   fpCommandSetZoomLow =                            85   fpCommandSetZoomLow =
 86     new G4UIcmdWithADouble("/vis/oglxm/set/zoo     86     new G4UIcmdWithADouble("/vis/oglxm/set/zoom-low", this);
 87   fpCommandSetZoomLow->SetGuidance("Lower limi     87   fpCommandSetZoomLow->SetGuidance("Lower limit of zoom slider.");
 88   fpCommandSetZoomLow->SetParameterName("zoom-     88   fpCommandSetZoomLow->SetParameterName("zoom-low", omitable = false);
 89 }                                                  89 }
 90                                                    90 
 91 G4OpenGLXmViewerMessenger::~G4OpenGLXmViewerMe     91 G4OpenGLXmViewerMessenger::~G4OpenGLXmViewerMessenger ()
 92 {                                                  92 {
 93   delete fpCommandSetZoomLow;                      93   delete fpCommandSetZoomLow;
 94   delete fpCommandSetZoomHigh;                     94   delete fpCommandSetZoomHigh;
 95   delete fpCommandSetRotationHigh;                 95   delete fpCommandSetRotationHigh;
 96   delete fpCommandSetPanHigh;                      96   delete fpCommandSetPanHigh;
 97   delete fpCommandSetDollyLow;                     97   delete fpCommandSetDollyLow;
 98   delete fpCommandSetDollyHigh;                    98   delete fpCommandSetDollyHigh;
 99   delete fpDirectorySet;                           99   delete fpDirectorySet;
100   delete fpDirectory;                             100   delete fpDirectory;
101 }                                                 101 }
102                                                   102 
103 void G4OpenGLXmViewerMessenger::SetNewValue       103 void G4OpenGLXmViewerMessenger::SetNewValue
104 (G4UIcommand* command, G4String newValue)         104 (G4UIcommand* command, G4String newValue)
105 {                                                 105 {
106   G4VisManager* pVisManager = G4VisManager::Ge    106   G4VisManager* pVisManager = G4VisManager::GetInstance();
107                                                   107 
108   G4VViewer* pVViewer = pVisManager->GetCurren    108   G4VViewer* pVViewer = pVisManager->GetCurrentViewer();
109                                                   109 
110   if (!pVViewer) {                                110   if (!pVViewer) {
111     G4cout <<                                     111     G4cout <<
112       "G4OpenGLXmViewerMessenger::SetNewValue:    112       "G4OpenGLXmViewerMessenger::SetNewValue: No current viewer."
113       "\n  \"/vis/open\", or similar, to get o    113       "\n  \"/vis/open\", or similar, to get one."
114            << G4endl;                             114            << G4endl;
115     return;                                       115     return;
116   }                                               116   }
117                                                   117 
118   G4OpenGLXmViewer* pViewer = dynamic_cast<G4O    118   G4OpenGLXmViewer* pViewer = dynamic_cast<G4OpenGLXmViewer*>(pVViewer);
119                                                   119 
120   if (!pViewer) {                                 120   if (!pViewer) {
121     G4cout <<                                     121     G4cout <<
122       "G4OpenGLXmViewerMessenger::SetNewValue:    122       "G4OpenGLXmViewerMessenger::SetNewValue: Current viewer is not of type"
123       "\n  OGLIXm or OGLSXm.  Use \"/vis/viewe    123       "\n  OGLIXm or OGLSXm.  Use \"/vis/viewer/select\" or \"/vis/open\"."
124            << G4endl;                             124            << G4endl;
125     return;                                       125     return;
126   }                                               126   }
127                                                   127 
128   G4bool panningControlPanel = true;              128   G4bool panningControlPanel = true;
129   G4bool rotationControlPanel = true;             129   G4bool rotationControlPanel = true;
130                                                   130 
131   if (command == fpCommandSetDollyHigh)           131   if (command == fpCommandSetDollyHigh)
132     {                                             132     {
133       if (pViewer->fpdolly_slider)                133       if (pViewer->fpdolly_slider)
134   {                                               134   {
135     pViewer->dolly_high =                         135     pViewer->dolly_high =
136       fpCommandSetDollyHigh->GetNewDoubleValue    136       fpCommandSetDollyHigh->GetNewDoubleValue(newValue);
137     pViewer->fpdolly_slider->SetMaxValue (pVie    137     pViewer->fpdolly_slider->SetMaxValue (pViewer->dolly_high);
138     if (pViewer->fVP.GetDolly() > pViewer->dol    138     if (pViewer->fVP.GetDolly() > pViewer->dolly_high)
139       {                                           139       {
140         pViewer->fpdolly_slider->SetInitialVal    140         pViewer->fpdolly_slider->SetInitialValue (pViewer->dolly_high);
141         pViewer->fVP.SetDolly(pViewer->dolly_h    141         pViewer->fVP.SetDolly(pViewer->dolly_high);
142       }                                           142       }
143     else                                          143     else
144       {                                           144       {
145         pViewer->fpdolly_slider->SetInitialVal    145         pViewer->fpdolly_slider->SetInitialValue (pViewer->fVP.GetDolly());
146       }                                           146       }
147   }                                               147   }
148       else                                        148       else
149   {                                               149   {
150     panningControlPanel = false;                  150     panningControlPanel = false;
151   }                                               151   }
152     }                                             152     }
153                                                   153 
154   else if (command == fpCommandSetDollyLow)       154   else if (command == fpCommandSetDollyLow)
155     {                                             155     {
156       if (pViewer->fpdolly_slider)                156       if (pViewer->fpdolly_slider)
157   {                                               157   {
158     pViewer->dolly_low =                          158     pViewer->dolly_low =
159       fpCommandSetDollyLow->GetNewDoubleValue(    159       fpCommandSetDollyLow->GetNewDoubleValue(newValue);
160     pViewer->fpdolly_slider->SetMinValue (pVie    160     pViewer->fpdolly_slider->SetMinValue (pViewer->dolly_low);
161     if (pViewer->fVP.GetDolly() < pViewer->dol    161     if (pViewer->fVP.GetDolly() < pViewer->dolly_low)
162       {                                           162       {
163         pViewer->fpdolly_slider->SetInitialVal    163         pViewer->fpdolly_slider->SetInitialValue (pViewer->dolly_low);
164         pViewer->fVP.SetDolly(pViewer->dolly_l    164         pViewer->fVP.SetDolly(pViewer->dolly_low);
165       }                                           165       }
166     else                                          166     else
167       {                                           167       {
168         pViewer->fpdolly_slider->SetInitialVal    168         pViewer->fpdolly_slider->SetInitialValue (pViewer->fVP.GetDolly());
169       }                                           169       }
170   }                                               170   }
171       else                                        171       else
172   {                                               172   {
173     panningControlPanel = false;                  173     panningControlPanel = false;
174   }                                               174   }
175     }                                             175     }
176                                                   176 
177   else if (command == fpCommandSetPanHigh)        177   else if (command == fpCommandSetPanHigh)
178     {                                             178     {
179       if (pViewer->fppanning_slider)              179       if (pViewer->fppanning_slider)
180   {                                               180   {
181     pViewer->pan_sens_limit =                     181     pViewer->pan_sens_limit =
182       fpCommandSetPanHigh->GetNewDoubleValue(n    182       fpCommandSetPanHigh->GetNewDoubleValue(newValue);
183     pViewer->fppanning_slider->SetMaxValue (pV    183     pViewer->fppanning_slider->SetMaxValue (pViewer->pan_sens_limit);
184     pViewer->fppanning_slider->SetInitialValue    184     pViewer->fppanning_slider->SetInitialValue (pViewer->pan_sens_limit / 2.);
185   }                                               185   }
186       else                                        186       else
187   {                                               187   {
188     panningControlPanel = false;                  188     panningControlPanel = false;
189   }                                               189   }
190     }                                             190     }
191                                                   191 
192   else if (command == fpCommandSetRotationHigh    192   else if (command == fpCommandSetRotationHigh)
193     {                                             193     {
194       if (pViewer->fprotation_slider)             194       if (pViewer->fprotation_slider)
195   {                                               195   {
196     // Internally in OpenGLXm, it's in degrees    196     // Internally in OpenGLXm, it's in degrees...
197     pViewer->rot_sens_limit =                     197     pViewer->rot_sens_limit =
198       fpCommandSetRotationHigh->GetNewDoubleVa    198       fpCommandSetRotationHigh->GetNewDoubleValue(newValue) / deg;
199     pViewer->fprotation_slider->SetMaxValue (p    199     pViewer->fprotation_slider->SetMaxValue (pViewer->rot_sens_limit);
200     pViewer->fprotation_slider->SetInitialValu    200     pViewer->fprotation_slider->SetInitialValue (pViewer->rot_sens_limit / 2.);
201   }                                               201   }
202       else                                        202       else
203   {                                               203   {
204     rotationControlPanel = false;                 204     rotationControlPanel = false;
205   }                                               205   }
206     }                                             206     }
207                                                   207 
208   else if (command == fpCommandSetZoomHigh)       208   else if (command == fpCommandSetZoomHigh)
209     {                                             209     {
210       if (pViewer->fpzoom_slider)                 210       if (pViewer->fpzoom_slider)
211   {                                               211   {
212     pViewer->zoom_high =                          212     pViewer->zoom_high =
213       fpCommandSetZoomHigh->GetNewDoubleValue(    213       fpCommandSetZoomHigh->GetNewDoubleValue(newValue);
214     pViewer->fpzoom_slider->SetMaxValue (pView    214     pViewer->fpzoom_slider->SetMaxValue (pViewer->zoom_high);
215     pViewer->fpzoom_slider->SetInitialValue (p    215     pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
216     if (pViewer->fVP.GetZoomFactor() > pViewer    216     if (pViewer->fVP.GetZoomFactor() > pViewer->zoom_high)
217       {                                           217       {
218         pViewer->fpzoom_slider->SetInitialValu    218         pViewer->fpzoom_slider->SetInitialValue (pViewer->zoom_high);
219         pViewer->fVP.SetZoomFactor(pViewer->zo    219         pViewer->fVP.SetZoomFactor(pViewer->zoom_high);
220       }                                           220       }
221     else                                          221     else
222       {                                           222       {
223         pViewer->fpzoom_slider->SetInitialValu    223         pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
224       }                                           224       }
225   }                                               225   }
226       else                                        226       else
227   {                                               227   {
228     panningControlPanel = false;                  228     panningControlPanel = false;
229   }                                               229   }
230     }                                             230     }
231                                                   231 
232   else if (command == fpCommandSetZoomLow)        232   else if (command == fpCommandSetZoomLow)
233     {                                             233     {
234       if (pViewer->fpzoom_slider)                 234       if (pViewer->fpzoom_slider)
235   {                                               235   {
236     pViewer->zoom_low =                           236     pViewer->zoom_low =
237       fpCommandSetZoomLow->GetNewDoubleValue(n    237       fpCommandSetZoomLow->GetNewDoubleValue(newValue);
238     pViewer->fpzoom_slider->SetMinValue (pView    238     pViewer->fpzoom_slider->SetMinValue (pViewer->zoom_low);
239     pViewer->fpzoom_slider->SetInitialValue (p    239     pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
240     if (pViewer->fVP.GetZoomFactor() < pViewer    240     if (pViewer->fVP.GetZoomFactor() < pViewer->zoom_low)
241       {                                           241       {
242         pViewer->fpzoom_slider->SetInitialValu    242         pViewer->fpzoom_slider->SetInitialValue (pViewer->zoom_low);
243         pViewer->fVP.SetZoomFactor(pViewer->zo    243         pViewer->fVP.SetZoomFactor(pViewer->zoom_low);
244       }                                           244       }
245     else                                          245     else
246       {                                           246       {
247         pViewer->fpzoom_slider->SetInitialValu    247         pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
248       }                                           248       }
249   }                                               249   }
250       else                                        250       else
251   {                                               251   {
252     panningControlPanel = false;                  252     panningControlPanel = false;
253   }                                               253   }
254     }                                             254     }
255                                                   255 
256   if (!panningControlPanel)                       256   if (!panningControlPanel)
257     {                                             257     {
258     G4cout <<                                     258     G4cout << 
259       "G4OpenGLXmViewerMessenger::SetNewValue:    259       "G4OpenGLXmViewerMessenger::SetNewValue: pull down panning"
260       "\n  control panel and re-issue command.    260       "\n  control panel and re-issue command."
261      << G4endl;                                   261      << G4endl;
262     return;                                       262     return;
263     }                                             263     }
264                                                   264 
265   if (!rotationControlPanel)                      265   if (!rotationControlPanel)
266     {                                             266     {
267     G4cout <<                                     267     G4cout << 
268       "G4OpenGLXmViewerMessenger::SetNewValue:    268       "G4OpenGLXmViewerMessenger::SetNewValue: pull down rotation"
269       "\n  control panel and re-issue command.    269       "\n  control panel and re-issue command."
270      << G4endl;                                   270      << G4endl;
271     return;                                       271     return;
272     }                                             272     }
273                                                   273 
274   G4UImanager::GetUIpointer()->ApplyCommand("/    274   G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
275 }                                                 275 }
276                                                   276