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