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