Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 28 #include "G4OpenGLXmViewerMessenger.hh" 29 30 #include "G4SystemOfUnits.hh" 31 #include "G4OpenGLXmViewer.hh" 32 #include "G4OpenGLXmSliderBar.hh" 33 34 #include "G4UImanager.hh" 35 #include "G4UIcommand.hh" 36 #include "G4UIdirectory.hh" 37 #include "G4UIcmdWithADoubleAndUnit.hh" 38 #include "G4UIcmdWithADouble.hh" 39 40 #include "G4VisManager.hh" 41 42 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMes 43 44 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMes 45 { 46 if (!fpInstance) fpInstance = new G4OpenGLXm 47 return fpInstance; 48 } 49 50 G4OpenGLXmViewerMessenger::G4OpenGLXmViewerMes 51 { 52 G4bool omitable; 53 54 fpDirectory = new G4UIdirectory("/vis/oglxm/ 55 fpDirectory->SetGuidance("G4OpenGLXmViewer c 56 57 fpDirectorySet = new G4UIdirectory ("/vis/og 58 fpDirectorySet->SetGuidance("G4OpenGLXmViewe 59 60 fpCommandSetDollyHigh = 61 new G4UIcmdWithADoubleAndUnit("/vis/oglxm/ 62 fpCommandSetDollyHigh->SetGuidance("Higher l 63 fpCommandSetDollyHigh->SetParameterName("dol 64 65 fpCommandSetDollyLow = 66 new G4UIcmdWithADoubleAndUnit("/vis/oglxm/ 67 fpCommandSetDollyLow->SetGuidance("Lower lim 68 fpCommandSetDollyLow->SetParameterName("doll 69 70 fpCommandSetPanHigh = 71 new G4UIcmdWithADoubleAndUnit("/vis/oglxm/ 72 fpCommandSetPanHigh->SetGuidance("Higher lim 73 fpCommandSetPanHigh->SetParameterName("pan-h 74 75 fpCommandSetRotationHigh = 76 new G4UIcmdWithADoubleAndUnit("/vis/oglxm/ 77 fpCommandSetRotationHigh->SetGuidance("Highe 78 fpCommandSetRotationHigh->SetParameterName(" 79 80 fpCommandSetZoomHigh = 81 new G4UIcmdWithADouble("/vis/oglxm/set/zoo 82 fpCommandSetZoomHigh->SetGuidance("Higher li 83 fpCommandSetZoomHigh->SetParameterName("zoom 84 85 fpCommandSetZoomLow = 86 new G4UIcmdWithADouble("/vis/oglxm/set/zoo 87 fpCommandSetZoomLow->SetGuidance("Lower limi 88 fpCommandSetZoomLow->SetParameterName("zoom- 89 } 90 91 G4OpenGLXmViewerMessenger::~G4OpenGLXmViewerMe 92 { 93 delete fpCommandSetZoomLow; 94 delete fpCommandSetZoomHigh; 95 delete fpCommandSetRotationHigh; 96 delete fpCommandSetPanHigh; 97 delete fpCommandSetDollyLow; 98 delete fpCommandSetDollyHigh; 99 delete fpDirectorySet; 100 delete fpDirectory; 101 } 102 103 void G4OpenGLXmViewerMessenger::SetNewValue 104 (G4UIcommand* command, G4String newValue) 105 { 106 G4VisManager* pVisManager = G4VisManager::Ge 107 108 G4VViewer* pVViewer = pVisManager->GetCurren 109 110 if (!pVViewer) { 111 G4cout << 112 "G4OpenGLXmViewerMessenger::SetNewValue: 113 "\n \"/vis/open\", or similar, to get o 114 << G4endl; 115 return; 116 } 117 118 G4OpenGLXmViewer* pViewer = dynamic_cast<G4O 119 120 if (!pViewer) { 121 G4cout << 122 "G4OpenGLXmViewerMessenger::SetNewValue: 123 "\n OGLIXm or OGLSXm. Use \"/vis/viewe 124 << G4endl; 125 return; 126 } 127 128 G4bool panningControlPanel = true; 129 G4bool rotationControlPanel = true; 130 131 if (command == fpCommandSetDollyHigh) 132 { 133 if (pViewer->fpdolly_slider) 134 { 135 pViewer->dolly_high = 136 fpCommandSetDollyHigh->GetNewDoubleValue 137 pViewer->fpdolly_slider->SetMaxValue (pVie 138 if (pViewer->fVP.GetDolly() > pViewer->dol 139 { 140 pViewer->fpdolly_slider->SetInitialVal 141 pViewer->fVP.SetDolly(pViewer->dolly_h 142 } 143 else 144 { 145 pViewer->fpdolly_slider->SetInitialVal 146 } 147 } 148 else 149 { 150 panningControlPanel = false; 151 } 152 } 153 154 else if (command == fpCommandSetDollyLow) 155 { 156 if (pViewer->fpdolly_slider) 157 { 158 pViewer->dolly_low = 159 fpCommandSetDollyLow->GetNewDoubleValue( 160 pViewer->fpdolly_slider->SetMinValue (pVie 161 if (pViewer->fVP.GetDolly() < pViewer->dol 162 { 163 pViewer->fpdolly_slider->SetInitialVal 164 pViewer->fVP.SetDolly(pViewer->dolly_l 165 } 166 else 167 { 168 pViewer->fpdolly_slider->SetInitialVal 169 } 170 } 171 else 172 { 173 panningControlPanel = false; 174 } 175 } 176 177 else if (command == fpCommandSetPanHigh) 178 { 179 if (pViewer->fppanning_slider) 180 { 181 pViewer->pan_sens_limit = 182 fpCommandSetPanHigh->GetNewDoubleValue(n 183 pViewer->fppanning_slider->SetMaxValue (pV 184 pViewer->fppanning_slider->SetInitialValue 185 } 186 else 187 { 188 panningControlPanel = false; 189 } 190 } 191 192 else if (command == fpCommandSetRotationHigh 193 { 194 if (pViewer->fprotation_slider) 195 { 196 // Internally in OpenGLXm, it's in degrees 197 pViewer->rot_sens_limit = 198 fpCommandSetRotationHigh->GetNewDoubleVa 199 pViewer->fprotation_slider->SetMaxValue (p 200 pViewer->fprotation_slider->SetInitialValu 201 } 202 else 203 { 204 rotationControlPanel = false; 205 } 206 } 207 208 else if (command == fpCommandSetZoomHigh) 209 { 210 if (pViewer->fpzoom_slider) 211 { 212 pViewer->zoom_high = 213 fpCommandSetZoomHigh->GetNewDoubleValue( 214 pViewer->fpzoom_slider->SetMaxValue (pView 215 pViewer->fpzoom_slider->SetInitialValue (p 216 if (pViewer->fVP.GetZoomFactor() > pViewer 217 { 218 pViewer->fpzoom_slider->SetInitialValu 219 pViewer->fVP.SetZoomFactor(pViewer->zo 220 } 221 else 222 { 223 pViewer->fpzoom_slider->SetInitialValu 224 } 225 } 226 else 227 { 228 panningControlPanel = false; 229 } 230 } 231 232 else if (command == fpCommandSetZoomLow) 233 { 234 if (pViewer->fpzoom_slider) 235 { 236 pViewer->zoom_low = 237 fpCommandSetZoomLow->GetNewDoubleValue(n 238 pViewer->fpzoom_slider->SetMinValue (pView 239 pViewer->fpzoom_slider->SetInitialValue (p 240 if (pViewer->fVP.GetZoomFactor() < pViewer 241 { 242 pViewer->fpzoom_slider->SetInitialValu 243 pViewer->fVP.SetZoomFactor(pViewer->zo 244 } 245 else 246 { 247 pViewer->fpzoom_slider->SetInitialValu 248 } 249 } 250 else 251 { 252 panningControlPanel = false; 253 } 254 } 255 256 if (!panningControlPanel) 257 { 258 G4cout << 259 "G4OpenGLXmViewerMessenger::SetNewValue: 260 "\n control panel and re-issue command. 261 << G4endl; 262 return; 263 } 264 265 if (!rotationControlPanel) 266 { 267 G4cout << 268 "G4OpenGLXmViewerMessenger::SetNewValue: 269 "\n control panel and re-issue command. 270 << G4endl; 271 return; 272 } 273 274 G4UImanager::GetUIpointer()->ApplyCommand("/ 275 } 276