| [531] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4VisCommandsViewerSet.cc,v 1.47 2006/11/14 14:59:55 allison Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-08-02-patch-01 $
|
|---|
| 29 |
|
|---|
| 30 | // /vis/viewer/set commands - John Allison 16th May 2000
|
|---|
| 31 |
|
|---|
| 32 | #include "G4VisCommandsViewerSet.hh"
|
|---|
| 33 |
|
|---|
| 34 | #include "G4UIcommand.hh"
|
|---|
| 35 | #include "G4UIcmdWithAString.hh"
|
|---|
| 36 | #include "G4UIcmdWithABool.hh"
|
|---|
| 37 | #include "G4UIcmdWithAnInteger.hh"
|
|---|
| 38 | #include "G4UIcmdWithADouble.hh"
|
|---|
| 39 | #include "G4UnitsTable.hh"
|
|---|
| 40 | #include "G4VisManager.hh"
|
|---|
| 41 | #include "G4Polyhedron.hh"
|
|---|
| 42 |
|
|---|
| 43 | #include <sstream>
|
|---|
| 44 | #include <cctype>
|
|---|
| 45 |
|
|---|
| 46 | G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
|
|---|
| 47 | fLightsVector (G4ThreeVector(1.,1.,1.)),
|
|---|
| 48 | fUpVector (G4ThreeVector(0.,1.,0.)),
|
|---|
| 49 | fViewpointVector (G4ThreeVector(0.,0.,1.))
|
|---|
| 50 | {
|
|---|
| 51 | G4bool omitable;
|
|---|
| 52 | G4UIparameter* parameter;
|
|---|
| 53 |
|
|---|
| 54 | fpCommandAll = new G4UIcmdWithAString ("/vis/viewer/set/all",this);
|
|---|
| 55 | fpCommandAll->SetGuidance
|
|---|
| 56 | ("Copies view parameters.");
|
|---|
| 57 | fpCommandAll->SetGuidance
|
|---|
| 58 | ("Copies view parameters (except the autoRefresh status) from"
|
|---|
| 59 | "\nfrom-viewer to current viewer.");
|
|---|
| 60 | fpCommandAll->SetParameterName ("from-viewer-name",omitable = false);
|
|---|
| 61 |
|
|---|
| 62 | fpCommandAutoRefresh = new G4UIcmdWithABool
|
|---|
| 63 | ("/vis/viewer/set/autoRefresh",this);
|
|---|
| 64 | fpCommandAutoRefresh->SetGuidance("Sets auto-refresh.");
|
|---|
| 65 | fpCommandAutoRefresh->SetGuidance
|
|---|
| 66 | ("If true, view is automatically refreshed after a change of"
|
|---|
| 67 | "\nview parameters.");
|
|---|
| 68 | fpCommandAutoRefresh->SetParameterName("auto-refresh",omitable = true);
|
|---|
| 69 | fpCommandAutoRefresh->SetDefaultValue(false);
|
|---|
| 70 |
|
|---|
| 71 | fpCommandAuxEdge = new G4UIcmdWithABool
|
|---|
| 72 | ("/vis/viewer/set/auxiliaryEdge",this);
|
|---|
| 73 | fpCommandAuxEdge->SetGuidance("Sets visibility of auxiliary edges");
|
|---|
| 74 | fpCommandAuxEdge->SetGuidance
|
|---|
| 75 | ("Auxiliary edges, i.e., those that are part of a curved surface,"
|
|---|
| 76 | "\nsometimes called soft edges, become visible/invisible.");
|
|---|
| 77 | fpCommandAuxEdge->SetParameterName("edge",omitable = true);
|
|---|
| 78 | fpCommandAuxEdge->SetDefaultValue(false);
|
|---|
| 79 |
|
|---|
| 80 | fpCommandBackground = new G4UIcommand
|
|---|
| 81 | ("/vis/viewer/set/background",this);
|
|---|
| 82 | fpCommandBackground->SetGuidance
|
|---|
| 83 | ("Set background colour and transparency (default black and opaque).");
|
|---|
| 84 | fpCommandBackground->SetGuidance
|
|---|
| 85 | ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
|
|---|
| 86 | "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
|
|---|
| 87 | "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
|
|---|
| 88 | "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
|
|---|
| 89 | "\n e.g. \"! ! ! 0.\" for a transparent background.");
|
|---|
| 90 | parameter = new G4UIparameter("red_or_string", 's', omitable = true);
|
|---|
| 91 | parameter -> SetDefaultValue ("0.");
|
|---|
| 92 | fpCommandBackground -> SetParameter (parameter);
|
|---|
| 93 | parameter = new G4UIparameter("green", 'd', omitable = true);
|
|---|
| 94 | parameter -> SetDefaultValue (0.);
|
|---|
| 95 | fpCommandBackground -> SetParameter (parameter);
|
|---|
| 96 | parameter = new G4UIparameter ("blue", 'd', omitable = true);
|
|---|
| 97 | parameter -> SetDefaultValue (0.);
|
|---|
| 98 | fpCommandBackground -> SetParameter (parameter);
|
|---|
| 99 | parameter = new G4UIparameter ("opacity", 'd', omitable = true);
|
|---|
| 100 | parameter -> SetDefaultValue (1.);
|
|---|
| 101 | fpCommandBackground -> SetParameter (parameter);
|
|---|
| 102 |
|
|---|
| 103 | fpCommandCulling = new G4UIcommand("/vis/viewer/set/culling",this);
|
|---|
| 104 | fpCommandCulling->SetGuidance ("Set culling options.");
|
|---|
| 105 | fpCommandCulling->SetGuidance
|
|---|
| 106 | ("\"global\": enables/disables all other culling options.");
|
|---|
| 107 | fpCommandCulling->SetGuidance
|
|---|
| 108 | ("\"coveredDaughters\": culls, i.e., eliminates, volumes that would not"
|
|---|
| 109 | "\nbe seen because covered by ancester volumes in surface drawing mode,"
|
|---|
| 110 | "\nand then only if the ancesters are visible and opaque, and then only"
|
|---|
| 111 | "\nif no sections or cutaways are in operation. Intended solely to"
|
|---|
| 112 | "\nimprove the speed of rendering visible volumes.");
|
|---|
| 113 | fpCommandCulling->SetGuidance
|
|---|
| 114 | ("\"invisible\": culls objects with the invisible attribute set.");
|
|---|
| 115 | fpCommandCulling->SetGuidance
|
|---|
| 116 | ("\"density\": culls volumes with density lower than threshold. Useful"
|
|---|
| 117 | "\nfor eliminating \"container volumes\" with no physical correspondence,"
|
|---|
| 118 | "\nwhose material is usually air. If this is selected, provide threshold"
|
|---|
| 119 | "\ndensity and unit (g/cm3 mg/cm3 or kg/m3)."
|
|---|
| 120 | );
|
|---|
| 121 | parameter = new G4UIparameter("culling-option",'s',omitable = false);
|
|---|
| 122 | parameter->SetParameterCandidates
|
|---|
| 123 | ("global coveredDaughters invisible density");
|
|---|
| 124 | fpCommandCulling->SetParameter(parameter);
|
|---|
| 125 | parameter = new G4UIparameter("action",'b',omitable = true);
|
|---|
| 126 | parameter->SetDefaultValue(1);
|
|---|
| 127 | fpCommandCulling->SetParameter(parameter);
|
|---|
| 128 | parameter = new G4UIparameter("density-threshold",'d',omitable = true);
|
|---|
| 129 | parameter->SetDefaultValue("0.01");
|
|---|
| 130 | fpCommandCulling->SetParameter(parameter);
|
|---|
| 131 | parameter = new G4UIparameter("unit",'s',omitable = true);
|
|---|
| 132 | parameter->SetParameterCandidates ("g/cm3, mg/cm3 kg/m3");
|
|---|
| 133 | parameter->SetDefaultValue("g/cm3");
|
|---|
| 134 | fpCommandCulling->SetParameter(parameter);
|
|---|
| 135 |
|
|---|
| 136 | fpCommandCutawayMode =
|
|---|
| 137 | new G4UIcmdWithAString ("/vis/viewer/set/cutawayMode", this);
|
|---|
| 138 | fpCommandCutawayMode->SetGuidance
|
|---|
| 139 | ("Sets cutaway mode - add (union) or multiply (intersection).");
|
|---|
| 140 | fpCommandCutawayMode->SetParameterName ("cutaway-mode",omitable = false);
|
|---|
| 141 | fpCommandCutawayMode->SetCandidates ("add union multiply intersection");
|
|---|
| 142 | fpCommandCutawayMode->SetDefaultValue("union");
|
|---|
| 143 |
|
|---|
| 144 | fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
|
|---|
| 145 | fpCommandEdge->SetGuidance
|
|---|
| 146 | ("Edges become visible/invisible in surface mode.");
|
|---|
| 147 | fpCommandEdge->SetParameterName("edge",omitable = true);
|
|---|
| 148 | fpCommandEdge->SetDefaultValue(true);
|
|---|
| 149 |
|
|---|
| 150 | fpCommandExplodeFactor = new G4UIcommand
|
|---|
| 151 | ("/vis/viewer/set/explodeFactor", this);
|
|---|
| 152 | fpCommandExplodeFactor->SetGuidance
|
|---|
| 153 | ("Moves top-level drawn volumes by this factor from this centre.");
|
|---|
| 154 | parameter = new G4UIparameter("explodeFactor", 'd', omitable=true);
|
|---|
| 155 | parameter->SetParameterRange("explodeFactor>=1.");
|
|---|
| 156 | parameter->SetDefaultValue(1.);
|
|---|
| 157 | fpCommandExplodeFactor->SetParameter(parameter);
|
|---|
| 158 | parameter = new G4UIparameter("x",'d',omitable = true);
|
|---|
| 159 | parameter->SetDefaultValue (0);
|
|---|
| 160 | parameter->SetGuidance ("Coordinate of explode centre.");
|
|---|
| 161 | fpCommandExplodeFactor->SetParameter(parameter);
|
|---|
| 162 | parameter = new G4UIparameter("y",'d',omitable = true);
|
|---|
| 163 | parameter->SetDefaultValue (0);
|
|---|
| 164 | parameter->SetGuidance ("Coordinate of explode centre.");
|
|---|
| 165 | fpCommandExplodeFactor->SetParameter(parameter);
|
|---|
| 166 | parameter = new G4UIparameter("z",'d',omitable = true);
|
|---|
| 167 | parameter->SetDefaultValue (0);
|
|---|
| 168 | parameter->SetGuidance ("Coordinate of explode centre.");
|
|---|
| 169 | fpCommandExplodeFactor->SetParameter(parameter);
|
|---|
| 170 | parameter = new G4UIparameter("unit",'s',omitable = true);
|
|---|
| 171 | parameter->SetDefaultValue ("m");
|
|---|
| 172 | parameter->SetGuidance ("Unit of explode centre.");
|
|---|
| 173 | fpCommandExplodeFactor->SetParameter(parameter);
|
|---|
| 174 |
|
|---|
| 175 | fpCommandGlobalLineWidthScale = new G4UIcmdWithADouble
|
|---|
| 176 | ("/vis/viewer/set/globalLineWidthScale", this);
|
|---|
| 177 | fpCommandGlobalLineWidthScale->SetGuidance
|
|---|
| 178 | ("Multiplies line widths by this factor.");
|
|---|
| 179 | fpCommandGlobalLineWidthScale->
|
|---|
| 180 | SetParameterName("scale-factor", omitable=true);
|
|---|
| 181 | fpCommandGlobalLineWidthScale->SetDefaultValue(1.);
|
|---|
| 182 |
|
|---|
| 183 | fpCommandGlobalMarkerScale = new G4UIcmdWithADouble
|
|---|
| 184 | ("/vis/viewer/set/globalMarkerScale", this);
|
|---|
| 185 | fpCommandGlobalMarkerScale->SetGuidance
|
|---|
| 186 | ("Multiplies marker sizes by this factor.");
|
|---|
| 187 | fpCommandGlobalMarkerScale->
|
|---|
| 188 | SetParameterName("scale-factor", omitable=true);
|
|---|
| 189 | fpCommandGlobalMarkerScale->SetDefaultValue(1.);
|
|---|
| 190 |
|
|---|
| 191 | fpCommandHiddenEdge =
|
|---|
| 192 | new G4UIcmdWithABool("/vis/viewer/set/hiddenEdge",this);
|
|---|
| 193 | fpCommandHiddenEdge->SetGuidance
|
|---|
| 194 | ("Edges become hidden/seen in wireframe or surface mode.");
|
|---|
| 195 | fpCommandHiddenEdge->SetParameterName("hidden-edge",omitable = true);
|
|---|
| 196 | fpCommandHiddenEdge->SetDefaultValue(true);
|
|---|
| 197 |
|
|---|
| 198 | fpCommandHiddenMarker =
|
|---|
| 199 | new G4UIcmdWithABool("/vis/viewer/set/hiddenMarker",this);
|
|---|
| 200 | fpCommandHiddenMarker->SetGuidance
|
|---|
| 201 | ("If true, closer objects hide markers. Otherwise, markers always show.");
|
|---|
| 202 | fpCommandHiddenMarker->SetParameterName("hidden-marker",omitable = true);
|
|---|
| 203 | fpCommandHiddenMarker->SetDefaultValue(true);
|
|---|
| 204 |
|
|---|
| 205 | fpCommandLightsMove = new G4UIcmdWithAString
|
|---|
| 206 | ("/vis/viewer/set/lightsMove",this);
|
|---|
| 207 | fpCommandLightsMove->SetGuidance
|
|---|
| 208 | ("Lights move with camera or with object");
|
|---|
| 209 | fpCommandLightsMove->SetParameterName("lightsMove",omitable = false);
|
|---|
| 210 | fpCommandLightsMove->SetCandidates
|
|---|
| 211 | ("cam camera with-camera obj object with-object");
|
|---|
| 212 |
|
|---|
| 213 | fpCommandLightsThetaPhi = new G4UIcommand
|
|---|
| 214 | ("/vis/viewer/set/lightsThetaPhi", this);
|
|---|
| 215 | fpCommandLightsThetaPhi->SetGuidance
|
|---|
| 216 | ("Set direction from target to lights.");
|
|---|
| 217 | parameter = new G4UIparameter("theta", 'd', omitable = true);
|
|---|
| 218 | parameter -> SetDefaultValue(60.);
|
|---|
| 219 | fpCommandLightsThetaPhi -> SetParameter (parameter);
|
|---|
| 220 | parameter = new G4UIparameter("phi", 'd', omitable = true);
|
|---|
| 221 | parameter -> SetDefaultValue(45.);
|
|---|
| 222 | fpCommandLightsThetaPhi -> SetParameter (parameter);
|
|---|
| 223 | parameter = new G4UIparameter ("unit", 's', omitable = true);
|
|---|
| 224 | parameter -> SetDefaultValue ("deg");
|
|---|
| 225 | fpCommandLightsThetaPhi -> SetParameter (parameter);
|
|---|
| 226 |
|
|---|
| 227 | fpCommandLightsVector = new G4UIcommand
|
|---|
| 228 | ("/vis/viewer/set/lightsVector", this);
|
|---|
| 229 | fpCommandLightsVector->SetGuidance
|
|---|
| 230 | ("Set direction from target to lights.");
|
|---|
| 231 | parameter = new G4UIparameter("x", 'd', omitable = true);
|
|---|
| 232 | parameter -> SetDefaultValue (1);
|
|---|
| 233 | fpCommandLightsVector -> SetParameter (parameter);
|
|---|
| 234 | parameter = new G4UIparameter("y", 'd', omitable = true);
|
|---|
| 235 | parameter -> SetDefaultValue (1);
|
|---|
| 236 | fpCommandLightsVector -> SetParameter (parameter);
|
|---|
| 237 | parameter = new G4UIparameter ("z", 'd', omitable = true);
|
|---|
| 238 | parameter -> SetDefaultValue (1);
|
|---|
| 239 | fpCommandLightsVector -> SetParameter (parameter);
|
|---|
| 240 |
|
|---|
| 241 | fpCommandLineSegments = new G4UIcmdWithAnInteger
|
|---|
| 242 | ("/vis/viewer/set/lineSegmentsPerCircle",this);
|
|---|
| 243 | fpCommandLineSegments->SetGuidance
|
|---|
| 244 | ("Set number of sides per circle for polygon/polyhedron drawing.");
|
|---|
| 245 | fpCommandLineSegments->SetGuidance
|
|---|
| 246 | ("Refers to graphical representation of objects with curved lines/surfaces.");
|
|---|
| 247 | fpCommandLineSegments->SetParameterName("line-segments",omitable = true);
|
|---|
| 248 | fpCommandLineSegments->SetDefaultValue(24);
|
|---|
| 249 |
|
|---|
| 250 | fpCommandProjection = new G4UIcommand("/vis/viewer/set/projection",this);
|
|---|
| 251 | fpCommandProjection->SetGuidance
|
|---|
| 252 | ("Orthogonal or perspective projection.");
|
|---|
| 253 | parameter = new G4UIparameter("projection",'s',omitable = true);
|
|---|
| 254 | parameter->SetParameterCandidates("o orthogonal p perspective");
|
|---|
| 255 | parameter->SetDefaultValue("orthogonal");
|
|---|
| 256 | fpCommandProjection->SetParameter(parameter);
|
|---|
| 257 | parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
|
|---|
| 258 | parameter->SetDefaultValue(30.);
|
|---|
| 259 | fpCommandProjection->SetParameter(parameter);
|
|---|
| 260 | parameter = new G4UIparameter("unit",'s',omitable = true);
|
|---|
| 261 | parameter->SetDefaultValue("deg");
|
|---|
| 262 | fpCommandProjection->SetParameter(parameter);
|
|---|
| 263 |
|
|---|
| 264 | fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
|
|---|
| 265 | fpCommandSectionPlane -> SetGuidance
|
|---|
| 266 | ("Set plane for drawing section (DCUT).");
|
|---|
| 267 | fpCommandSectionPlane -> SetGuidance
|
|---|
| 268 | ("E.g., for a y-z plane at x = 1 cm:"
|
|---|
| 269 | "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"."
|
|---|
| 270 | "\nTo turn off: /vis/viewer/set/sectionPlane off");
|
|---|
| 271 | parameter = new G4UIparameter("Selector",'c',true);
|
|---|
| 272 | parameter -> SetDefaultValue ("on");
|
|---|
| 273 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 274 | parameter = new G4UIparameter("x",'d',omitable = true);
|
|---|
| 275 | parameter -> SetDefaultValue (0);
|
|---|
| 276 | parameter -> SetGuidance ("Coordinate of point on the plane.");
|
|---|
| 277 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 278 | parameter = new G4UIparameter("y",'d',omitable = true);
|
|---|
| 279 | parameter -> SetDefaultValue (0);
|
|---|
| 280 | parameter -> SetGuidance ("Coordinate of point on the plane.");
|
|---|
| 281 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 282 | parameter = new G4UIparameter("z",'d',omitable = true);
|
|---|
| 283 | parameter -> SetDefaultValue (0);
|
|---|
| 284 | parameter -> SetGuidance ("Coordinate of point on the plane.");
|
|---|
| 285 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 286 | parameter = new G4UIparameter("unit",'s',omitable = true);
|
|---|
| 287 | parameter -> SetDefaultValue ("m");
|
|---|
| 288 | parameter -> SetGuidance ("Unit of point on the plane.");
|
|---|
| 289 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 290 | parameter = new G4UIparameter("nx",'d',omitable = true);
|
|---|
| 291 | parameter -> SetDefaultValue (1);
|
|---|
| 292 | parameter -> SetGuidance ("Component of plane normal.");
|
|---|
| 293 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 294 | parameter = new G4UIparameter("ny",'d',omitable = true);
|
|---|
| 295 | parameter -> SetDefaultValue (0);
|
|---|
| 296 | parameter -> SetGuidance ("Component of plane normal.");
|
|---|
| 297 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 298 | parameter = new G4UIparameter("nz",'d',omitable = true);
|
|---|
| 299 | parameter -> SetDefaultValue (0);
|
|---|
| 300 | parameter -> SetGuidance ("Component of plane normal.");
|
|---|
| 301 | fpCommandSectionPlane->SetParameter(parameter);
|
|---|
| 302 |
|
|---|
| 303 | fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
|
|---|
| 304 | fpCommandStyle->SetGuidance
|
|---|
| 305 | ("Set style of drawing - w[ireframe] or s[urface].");
|
|---|
| 306 | fpCommandStyle->SetGuidance
|
|---|
| 307 | ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
|
|---|
| 308 | fpCommandStyle->SetParameterName ("style",omitable = false);
|
|---|
| 309 |
|
|---|
| 310 | fpCommandUpThetaPhi = new G4UIcommand
|
|---|
| 311 | ("/vis/viewer/set/upThetaPhi", this);
|
|---|
| 312 | fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
|
|---|
| 313 | fpCommandUpThetaPhi -> SetGuidance
|
|---|
| 314 | ("Viewer will attempt always to show this direction upwards.");
|
|---|
| 315 | parameter = new G4UIparameter("theta", 'd', omitable = true);
|
|---|
| 316 | parameter -> SetDefaultValue (90.);
|
|---|
| 317 | fpCommandUpThetaPhi -> SetParameter (parameter);
|
|---|
| 318 | parameter = new G4UIparameter("phi", 'd', omitable = true);
|
|---|
| 319 | parameter -> SetDefaultValue (90.);
|
|---|
| 320 | fpCommandUpThetaPhi -> SetParameter (parameter);
|
|---|
| 321 | parameter = new G4UIparameter ("unit", 's', omitable = true);
|
|---|
| 322 | parameter -> SetDefaultValue ("deg");
|
|---|
| 323 | fpCommandUpThetaPhi -> SetParameter (parameter);
|
|---|
| 324 |
|
|---|
| 325 | fpCommandUpVector = new G4UIcommand
|
|---|
| 326 | ("/vis/viewer/set/upVector", this);
|
|---|
| 327 | fpCommandUpVector -> SetGuidance ("Set up vector.");
|
|---|
| 328 | fpCommandUpVector -> SetGuidance
|
|---|
| 329 | ("Viewer will attempt always to show this direction upwards.");
|
|---|
| 330 | parameter = new G4UIparameter("x", 'd', omitable = true);
|
|---|
| 331 | parameter -> SetDefaultValue (0.);
|
|---|
| 332 | fpCommandUpVector -> SetParameter (parameter);
|
|---|
| 333 | parameter = new G4UIparameter("y", 'd', omitable = true);
|
|---|
| 334 | parameter -> SetDefaultValue (1.);
|
|---|
| 335 | fpCommandUpVector -> SetParameter (parameter);
|
|---|
| 336 | parameter = new G4UIparameter ("z", 'd', omitable = true);
|
|---|
| 337 | parameter -> SetDefaultValue (0.);
|
|---|
| 338 | fpCommandUpVector -> SetParameter (parameter);
|
|---|
| 339 |
|
|---|
| 340 | fpCommandViewpointThetaPhi = new G4UIcommand
|
|---|
| 341 | ("/vis/viewer/set/viewpointThetaPhi", this);
|
|---|
| 342 | fpCommandViewpointThetaPhi -> SetGuidance
|
|---|
| 343 | ("Set direction from target to camera.");
|
|---|
| 344 | fpCommandViewpointThetaPhi -> SetGuidance
|
|---|
| 345 | ("Also changes lightpoint direction if lights are set to move with camera.");
|
|---|
| 346 | parameter = new G4UIparameter("theta", 'd', omitable = true);
|
|---|
| 347 | parameter -> SetDefaultValue (60.);
|
|---|
| 348 | fpCommandViewpointThetaPhi -> SetParameter (parameter);
|
|---|
| 349 | parameter = new G4UIparameter("phi", 'd', omitable = true);
|
|---|
| 350 | parameter -> SetDefaultValue (45.);
|
|---|
| 351 | fpCommandViewpointThetaPhi -> SetParameter (parameter);
|
|---|
| 352 | parameter = new G4UIparameter ("unit", 's', omitable = true);
|
|---|
| 353 | parameter -> SetDefaultValue ("deg");
|
|---|
| 354 | fpCommandViewpointThetaPhi -> SetParameter (parameter);
|
|---|
| 355 |
|
|---|
| 356 | fpCommandViewpointVector = new G4UIcommand
|
|---|
| 357 | ("/vis/viewer/set/viewpointVector", this);
|
|---|
| 358 | fpCommandViewpointVector -> SetGuidance
|
|---|
| 359 | ("Set direction from target to camera.");
|
|---|
| 360 | fpCommandViewpointVector -> SetGuidance
|
|---|
| 361 | ("Also changes lightpoint direction if lights are set to move with camera.");
|
|---|
| 362 | parameter = new G4UIparameter("x", 'd', omitable = true);
|
|---|
| 363 | parameter -> SetDefaultValue (1.);
|
|---|
| 364 | fpCommandViewpointVector -> SetParameter (parameter);
|
|---|
| 365 | parameter = new G4UIparameter("y", 'd', omitable = true);
|
|---|
| 366 | parameter -> SetDefaultValue (1.);
|
|---|
| 367 | fpCommandViewpointVector -> SetParameter (parameter);
|
|---|
| 368 | parameter = new G4UIparameter ("z", 'd', omitable = true);
|
|---|
| 369 | parameter -> SetDefaultValue (1.);
|
|---|
| 370 | fpCommandViewpointVector -> SetParameter (parameter);
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
|
|---|
| 374 | delete fpCommandAll;
|
|---|
| 375 | delete fpCommandAuxEdge;
|
|---|
| 376 | delete fpCommandAutoRefresh;
|
|---|
| 377 | delete fpCommandBackground;
|
|---|
| 378 | delete fpCommandCulling;
|
|---|
| 379 | delete fpCommandCutawayMode;
|
|---|
| 380 | delete fpCommandEdge;
|
|---|
| 381 | delete fpCommandExplodeFactor;
|
|---|
| 382 | delete fpCommandGlobalLineWidthScale;
|
|---|
| 383 | delete fpCommandGlobalMarkerScale;
|
|---|
| 384 | delete fpCommandHiddenEdge;
|
|---|
| 385 | delete fpCommandHiddenMarker;
|
|---|
| 386 | delete fpCommandLineSegments;
|
|---|
| 387 | delete fpCommandLightsMove;
|
|---|
| 388 | delete fpCommandLightsThetaPhi;
|
|---|
| 389 | delete fpCommandLightsVector;
|
|---|
| 390 | delete fpCommandProjection;
|
|---|
| 391 | delete fpCommandSectionPlane;
|
|---|
| 392 | delete fpCommandStyle;
|
|---|
| 393 | delete fpCommandUpThetaPhi;
|
|---|
| 394 | delete fpCommandUpVector;
|
|---|
| 395 | delete fpCommandViewpointThetaPhi;
|
|---|
| 396 | delete fpCommandViewpointVector;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | G4String G4VisCommandsViewerSet::GetCurrentValue(G4UIcommand*) {
|
|---|
| 400 | return "";
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | void G4VisCommandsViewerSet::SetNewValue
|
|---|
| 404 | (G4UIcommand* command,G4String newValue) {
|
|---|
| 405 |
|
|---|
| 406 | G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
|
|---|
| 407 |
|
|---|
| 408 | G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
|
|---|
| 409 | if (!currentViewer) {
|
|---|
| 410 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 411 | G4cout <<
|
|---|
| 412 | "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
|
|---|
| 413 | << G4endl;
|
|---|
| 414 | }
|
|---|
| 415 | return;
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | G4ViewParameters vp = currentViewer->GetViewParameters();
|
|---|
| 419 |
|
|---|
| 420 | if (command == fpCommandAll) {
|
|---|
| 421 | G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
|
|---|
| 422 | if (!fromViewer) {
|
|---|
| 423 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 424 | G4cout <<
|
|---|
| 425 | "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
|
|---|
| 426 | "\n unrecognised from-viewer."
|
|---|
| 427 | << G4endl;
|
|---|
| 428 | }
|
|---|
| 429 | return;
|
|---|
| 430 | }
|
|---|
| 431 | if (fromViewer == currentViewer) {
|
|---|
| 432 | if (verbosity >= G4VisManager::warnings) {
|
|---|
| 433 | G4cout <<
|
|---|
| 434 | "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
|
|---|
| 435 | "\n from-viewer and current viewer are identical."
|
|---|
| 436 | << G4endl;
|
|---|
| 437 | }
|
|---|
| 438 | return;
|
|---|
| 439 | }
|
|---|
| 440 | // Copy view parameters except for autoRefresh...
|
|---|
| 441 | G4bool currentAutoRefresh =
|
|---|
| 442 | currentViewer->GetViewParameters().IsAutoRefresh();
|
|---|
| 443 | vp = fromViewer->GetViewParameters();
|
|---|
| 444 | vp.SetAutoRefresh(currentAutoRefresh);
|
|---|
| 445 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 446 | G4cout << "View parameters of viewer \"" << currentViewer->GetName()
|
|---|
| 447 | << "\"\n set to those of viewer \"" << fromViewer->GetName()
|
|---|
| 448 | << "\"."
|
|---|
| 449 | << G4endl;
|
|---|
| 450 | }
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | else if (command == fpCommandAutoRefresh) {
|
|---|
| 454 | G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
|
|---|
| 455 | vp.SetAutoRefresh(autoRefresh);
|
|---|
| 456 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 457 | G4cout << "Views will ";
|
|---|
| 458 | if (!vp.IsAutoRefresh()) G4cout << "not ";
|
|---|
| 459 | G4cout << "be automatically refreshed after a change of view parameters."
|
|---|
| 460 | << G4endl;
|
|---|
| 461 | }
|
|---|
| 462 | currentViewer->SetViewParameters(vp);
|
|---|
| 463 | return; // I.e., avoid a refresh for this command.
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | else if (command == fpCommandAuxEdge) {
|
|---|
| 467 | vp.SetAuxEdgeVisible(G4UIcommand::ConvertToBool(newValue));
|
|---|
| 468 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 469 | G4cout << "Auxiliary edges will ";
|
|---|
| 470 | if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
|
|---|
| 471 | G4cout << "be visible." << G4endl;
|
|---|
| 472 | }
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 | else if (command == fpCommandBackground) {
|
|---|
| 476 | G4String redOrString;
|
|---|
| 477 | G4double green, blue, opacity;
|
|---|
| 478 | std::istringstream iss(newValue);
|
|---|
| 479 | iss >> redOrString >> green >> blue >> opacity;
|
|---|
| 480 | G4Colour colour(0.,0.,0.); // Default black and opaque.
|
|---|
| 481 | const size_t iPos0 = 0;
|
|---|
| 482 | if (std::isalpha(redOrString[iPos0])) {
|
|---|
| 483 | G4Colour::GetColour(redOrString, colour); // Remains default (black) if
|
|---|
| 484 | // not found.
|
|---|
| 485 | } else {
|
|---|
| 486 | colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
|
|---|
| 487 | }
|
|---|
| 488 | colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
|
|---|
| 489 | vp.SetBackgroundColour(colour);
|
|---|
| 490 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 491 | G4cout << "Background colour "
|
|---|
| 492 | << vp.GetBackgroundColour()
|
|---|
| 493 | << " requested."
|
|---|
| 494 | << G4endl;
|
|---|
| 495 | }
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | else if (command == fpCommandCulling) {
|
|---|
| 499 | G4String cullingOption, stringFlag, unit;
|
|---|
| 500 | G4double density;
|
|---|
| 501 | std::istringstream is (newValue);
|
|---|
| 502 | is >> cullingOption >> stringFlag >> density >> unit;
|
|---|
| 503 | G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
|
|---|
| 504 | if (cullingOption == "global") {
|
|---|
| 505 | vp.SetCulling(boolFlag);
|
|---|
| 506 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 507 | G4cout <<
|
|---|
| 508 | "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
|
|---|
| 509 | " set to " << G4UIcommand::ConvertToString(boolFlag) <<
|
|---|
| 510 | ".\n Does not change specific culling flags."
|
|---|
| 511 | << G4endl;
|
|---|
| 512 | }
|
|---|
| 513 | }
|
|---|
| 514 | else if (cullingOption == "coveredDaughters") {
|
|---|
| 515 | vp.SetCullingCovered(boolFlag);
|
|---|
| 516 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 517 | G4cout <<
|
|---|
| 518 | "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
|
|---|
| 519 | "\n daughters flag set to "
|
|---|
| 520 | << G4UIcommand::ConvertToString(boolFlag) <<
|
|---|
| 521 | ". Daughters covered by opaque mothers"
|
|---|
| 522 | "\n will be culled, i.e., not drawn, if this flag is true."
|
|---|
| 523 | "\n Note: this is only effective in surface drawing style,"
|
|---|
| 524 | "\n and then only if the volumes are visible and opaque, and then"
|
|---|
| 525 | "\n only if no sections or cutaways are in operation."
|
|---|
| 526 | << G4endl;
|
|---|
| 527 | }
|
|---|
| 528 | }
|
|---|
| 529 | else if (cullingOption == "invisible") {
|
|---|
| 530 | vp.SetCullingInvisible(boolFlag);
|
|---|
| 531 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 532 | G4cout <<
|
|---|
| 533 | "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
|
|---|
| 534 | "\n flag set to "
|
|---|
| 535 | << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
|
|---|
| 536 | ". Volumes marked invisible will be culled,"
|
|---|
| 537 | "\n i.e., not drawn, if this flag is true."
|
|---|
| 538 | << G4endl;
|
|---|
| 539 | }
|
|---|
| 540 | }
|
|---|
| 541 | else if (cullingOption == "density") {
|
|---|
| 542 | vp.SetDensityCulling(boolFlag);
|
|---|
| 543 | if (boolFlag) {
|
|---|
| 544 | density *= G4UnitDefinition::GetValueOf(unit);
|
|---|
| 545 | vp.SetVisibleDensity(density);
|
|---|
| 546 | }
|
|---|
| 547 | else {
|
|---|
| 548 | density = vp.GetVisibleDensity();
|
|---|
| 549 | }
|
|---|
| 550 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 551 | G4cout <<
|
|---|
| 552 | "G4VisCommandsViewerSet::SetNewValue: culling: culling by density"
|
|---|
| 553 | "\n flag set to " << G4UIcommand::ConvertToString(boolFlag) <<
|
|---|
| 554 | ". Volumes with density less than " <<
|
|---|
| 555 | G4BestUnit(density,"Volumic Mass") <<
|
|---|
| 556 | "\n will be culled, i.e., not drawn, if this flag is true."
|
|---|
| 557 | << G4endl;
|
|---|
| 558 | }
|
|---|
| 559 | }
|
|---|
| 560 | else {
|
|---|
| 561 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 562 | G4cout <<
|
|---|
| 563 | "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
|
|---|
| 564 | "\n option not recognised."
|
|---|
| 565 | << G4endl;
|
|---|
| 566 | }
|
|---|
| 567 | }
|
|---|
| 568 | }
|
|---|
| 569 |
|
|---|
| 570 | else if (command == fpCommandCutawayMode) {
|
|---|
| 571 | if (newValue == "add" || newValue == "union")
|
|---|
| 572 | vp.SetCutawayMode(G4ViewParameters::cutawayUnion);
|
|---|
| 573 | if (newValue == "multiply" || newValue == "intersection")
|
|---|
| 574 | vp.SetCutawayMode(G4ViewParameters::cutawayIntersection);
|
|---|
| 575 |
|
|---|
| 576 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 577 | G4cout << "Cutaway mode set to ";
|
|---|
| 578 | if (vp.GetCutawayMode() == G4ViewParameters::cutawayUnion)
|
|---|
| 579 | G4cout << "cutawayUnion";
|
|---|
| 580 | if (vp.GetCutawayMode() == G4ViewParameters::cutawayIntersection)
|
|---|
| 581 | G4cout << "cutawayIntersection";
|
|---|
| 582 | G4cout << G4endl;
|
|---|
| 583 | }
|
|---|
| 584 | }
|
|---|
| 585 |
|
|---|
| 586 | else if (command == fpCommandEdge) {
|
|---|
| 587 | G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
|
|---|
| 588 | if (G4UIcommand::ConvertToBool(newValue)) {
|
|---|
| 589 | switch (existingStyle) {
|
|---|
| 590 | case G4ViewParameters::wireframe:
|
|---|
| 591 | break;
|
|---|
| 592 | case G4ViewParameters::hlr:
|
|---|
| 593 | break;
|
|---|
| 594 | case G4ViewParameters::hsr:
|
|---|
| 595 | vp.SetDrawingStyle(G4ViewParameters::hlhsr);
|
|---|
| 596 | break;
|
|---|
| 597 | case G4ViewParameters::hlhsr:
|
|---|
| 598 | break;
|
|---|
| 599 | }
|
|---|
| 600 | }
|
|---|
| 601 | else {
|
|---|
| 602 | switch (existingStyle) {
|
|---|
| 603 | case G4ViewParameters::wireframe:
|
|---|
| 604 | break;
|
|---|
| 605 | case G4ViewParameters::hlr:
|
|---|
| 606 | break;
|
|---|
| 607 | case G4ViewParameters::hsr:
|
|---|
| 608 | break;
|
|---|
| 609 | case G4ViewParameters::hlhsr:
|
|---|
| 610 | vp.SetDrawingStyle(G4ViewParameters::hsr);
|
|---|
| 611 | break;
|
|---|
| 612 | }
|
|---|
| 613 | }
|
|---|
| 614 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 615 | G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
|
|---|
| 616 | << "\" set to " << vp.GetDrawingStyle()
|
|---|
| 617 | << G4endl;
|
|---|
| 618 | }
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 | else if (command == fpCommandExplodeFactor) {
|
|---|
| 622 | G4double explodeFactor, x, y, z;
|
|---|
| 623 | G4String unitString;
|
|---|
| 624 | std::istringstream is (newValue);
|
|---|
| 625 | is >> explodeFactor >> x >> y >> z >> unitString;
|
|---|
| 626 | G4double unit = G4UIcommand::ValueOf(unitString);
|
|---|
| 627 | vp.SetExplodeFactor(explodeFactor);
|
|---|
| 628 | vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
|
|---|
| 629 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 630 | G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
|
|---|
| 631 | << " from centre " << vp.GetExplodeCentre()
|
|---|
| 632 | << G4endl;
|
|---|
| 633 | }
|
|---|
| 634 | }
|
|---|
| 635 |
|
|---|
| 636 | else if (command == fpCommandGlobalLineWidthScale) {
|
|---|
| 637 | G4double globalLineWidthScale
|
|---|
| 638 | = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue);
|
|---|
| 639 | vp.SetGlobalLineWidthScale(globalLineWidthScale);
|
|---|
| 640 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 641 | G4cout << "Global Line Width Scale changed to "
|
|---|
| 642 | << vp.GetGlobalLineWidthScale() << G4endl;
|
|---|
| 643 | }
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | else if (command == fpCommandGlobalMarkerScale) {
|
|---|
| 647 | G4double globalMarkerScale
|
|---|
| 648 | = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue);
|
|---|
| 649 | vp.SetGlobalMarkerScale(globalMarkerScale);
|
|---|
| 650 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 651 | G4cout << "Global Marker Scale changed to "
|
|---|
| 652 | << vp.GetGlobalMarkerScale() << G4endl;
|
|---|
| 653 | }
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | else if (command == fpCommandHiddenEdge) {
|
|---|
| 657 | G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
|
|---|
| 658 | if (G4UIcommand::ConvertToBool(newValue)) {
|
|---|
| 659 | switch (existingStyle) {
|
|---|
| 660 | case G4ViewParameters::wireframe:
|
|---|
| 661 | vp.SetDrawingStyle(G4ViewParameters::hlr);
|
|---|
| 662 | break;
|
|---|
| 663 | case G4ViewParameters::hlr:
|
|---|
| 664 | break;
|
|---|
| 665 | case G4ViewParameters::hsr:
|
|---|
| 666 | vp.SetDrawingStyle(G4ViewParameters::hlhsr);
|
|---|
| 667 | break;
|
|---|
| 668 | case G4ViewParameters::hlhsr:
|
|---|
| 669 | break;
|
|---|
| 670 | }
|
|---|
| 671 | }
|
|---|
| 672 | else {
|
|---|
| 673 | switch (existingStyle) {
|
|---|
| 674 | case G4ViewParameters::wireframe:
|
|---|
| 675 | break;
|
|---|
| 676 | case G4ViewParameters::hlr:
|
|---|
| 677 | vp.SetDrawingStyle(G4ViewParameters::wireframe);
|
|---|
| 678 | break;
|
|---|
| 679 | case G4ViewParameters::hsr:
|
|---|
| 680 | break;
|
|---|
| 681 | case G4ViewParameters::hlhsr:
|
|---|
| 682 | vp.SetDrawingStyle(G4ViewParameters::hsr);
|
|---|
| 683 | break;
|
|---|
| 684 | }
|
|---|
| 685 | }
|
|---|
| 686 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 687 | G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
|
|---|
| 688 | << "\" set to " << vp.GetDrawingStyle()
|
|---|
| 689 | << G4endl;
|
|---|
| 690 | }
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 | else if (command == fpCommandHiddenMarker) {
|
|---|
| 694 | G4bool hidden = G4UIcommand::ConvertToBool(newValue);
|
|---|
| 695 | if (hidden) vp.SetMarkerHidden();
|
|---|
| 696 | else vp.SetMarkerNotHidden();
|
|---|
| 697 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 698 | G4cout << "Markers will ";
|
|---|
| 699 | if (vp.IsMarkerNotHidden()) G4cout << "not ";
|
|---|
| 700 | G4cout << "be hidden under solid objects." << G4endl;
|
|---|
| 701 | }
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | else if (command == fpCommandLightsMove) {
|
|---|
| 705 | G4String s (newValue);
|
|---|
| 706 | if (s.find("cam") != G4String::npos) vp.SetLightsMoveWithCamera(true);
|
|---|
| 707 | else if(s.find("obj") != G4String::npos) vp.SetLightsMoveWithCamera(false);
|
|---|
| 708 | else {
|
|---|
| 709 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 710 | G4cout << "ERROR: \"" << newValue << "\" not recognised."
|
|---|
| 711 | " Looking for \"cam\" or \"obj\" in string." << G4endl;
|
|---|
| 712 | }
|
|---|
| 713 | }
|
|---|
| 714 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 715 | G4cout << "Lights move with ";
|
|---|
| 716 | if (vp.GetLightsMoveWithCamera())
|
|---|
| 717 | G4cout << "camera (object appears to rotate).";
|
|---|
| 718 | else G4cout << "object (the viewer appears to be moving).";
|
|---|
| 719 | G4cout << G4endl;
|
|---|
| 720 | }
|
|---|
| 721 | }
|
|---|
| 722 |
|
|---|
| 723 | else if (command == fpCommandLightsThetaPhi) {
|
|---|
| 724 | G4double theta, phi;
|
|---|
| 725 | ConvertToDoublePair(newValue, theta, phi);
|
|---|
| 726 | G4double x = std::sin (theta) * std::cos (phi);
|
|---|
| 727 | G4double y = std::sin (theta) * std::sin (phi);
|
|---|
| 728 | G4double z = std::cos (theta);
|
|---|
| 729 | fLightsVector = G4ThreeVector (x, y, z);
|
|---|
| 730 | vp.SetLightpointDirection(fLightsVector);
|
|---|
| 731 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 732 | G4cout << "Lights direction set to "
|
|---|
| 733 | << vp.GetLightpointDirection() << G4endl;
|
|---|
| 734 | }
|
|---|
| 735 | }
|
|---|
| 736 |
|
|---|
| 737 | else if (command == fpCommandLightsVector) {
|
|---|
| 738 | fLightsVector = G4UIcommand::ConvertTo3Vector(newValue);
|
|---|
| 739 | vp.SetLightpointDirection(fLightsVector);
|
|---|
| 740 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 741 | G4cout << "Lights direction set to "
|
|---|
| 742 | << vp.GetLightpointDirection() << G4endl;
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 |
|
|---|
| 746 | else if (command == fpCommandLineSegments) {
|
|---|
| 747 | G4int nSides = G4UIcommand::ConvertToInt(newValue);
|
|---|
| 748 | nSides = vp.SetNoOfSides(nSides);
|
|---|
| 749 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 750 | G4cout <<
|
|---|
| 751 | "Number of line segements per circle in polygon approximation is "
|
|---|
| 752 | << nSides << G4endl;
|
|---|
| 753 | }
|
|---|
| 754 | }
|
|---|
| 755 |
|
|---|
| 756 | else if (command == fpCommandProjection) {
|
|---|
| 757 | G4double fieldHalfAngle;
|
|---|
| 758 | const size_t iPos0 = 0;
|
|---|
| 759 | if (newValue[iPos0] == 'o') { // "orthogonal"
|
|---|
| 760 | fieldHalfAngle = 0.;
|
|---|
| 761 | }
|
|---|
| 762 | else if (newValue[iPos0] == 'p') { // "perspective"
|
|---|
| 763 | G4String dummy;
|
|---|
| 764 | G4String unit;
|
|---|
| 765 | std::istringstream is (newValue);
|
|---|
| 766 | is >> dummy >> fieldHalfAngle >> unit;
|
|---|
| 767 | fieldHalfAngle *= G4UIcommand::ValueOf(unit);
|
|---|
| 768 | if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
|
|---|
| 769 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 770 | G4cout <<
|
|---|
| 771 | "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
|
|---|
| 772 | G4cout << G4endl;
|
|---|
| 773 | }
|
|---|
| 774 | return;
|
|---|
| 775 | }
|
|---|
| 776 | }
|
|---|
| 777 | else {
|
|---|
| 778 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 779 | G4cout << "ERROR: \"" << newValue << "\" not recognised."
|
|---|
| 780 | " Looking for 'o' or 'p' first character." << G4endl;
|
|---|
| 781 | }
|
|---|
| 782 | return;
|
|---|
| 783 | }
|
|---|
| 784 | vp.SetFieldHalfAngle(fieldHalfAngle);
|
|---|
| 785 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 786 | G4cout << "Projection style of viewer \"" << currentViewer->GetName()
|
|---|
| 787 | << "\" set to ";
|
|---|
| 788 | if (fieldHalfAngle == 0.) {
|
|---|
| 789 | G4cout << "orthogonal.";
|
|---|
| 790 | }
|
|---|
| 791 | else {
|
|---|
| 792 | G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
|
|---|
| 793 | << " degrees.";
|
|---|
| 794 | }
|
|---|
| 795 | G4cout << G4endl;
|
|---|
| 796 | }
|
|---|
| 797 | }
|
|---|
| 798 |
|
|---|
| 799 | else if (command == fpCommandSectionPlane) {
|
|---|
| 800 | G4String choice, unit;
|
|---|
| 801 | G4double x, y, z, nx, ny, nz;
|
|---|
| 802 | std::istringstream is (newValue);
|
|---|
| 803 | is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
|
|---|
| 804 |
|
|---|
| 805 | G4int iSelector = -1;
|
|---|
| 806 | if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
|
|---|
| 807 | !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
|
|---|
| 808 | if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
|
|---|
| 809 | G4UIcommand::ConvertToBool(choice)) iSelector = 1;
|
|---|
| 810 | if (iSelector < 0) {
|
|---|
| 811 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 812 | G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
|
|---|
| 813 | G4cout << "Section drawing is currently: ";
|
|---|
| 814 | if (vp.IsSection ()) G4cout << "on";
|
|---|
| 815 | else G4cout << "off";
|
|---|
| 816 | G4cout << ".\nSection plane is currently: "
|
|---|
| 817 | << vp.GetSectionPlane ();
|
|---|
| 818 | G4cout << G4endl;
|
|---|
| 819 | }
|
|---|
| 820 | return;
|
|---|
| 821 | }
|
|---|
| 822 |
|
|---|
| 823 | G4double F = 1.;
|
|---|
| 824 | switch (iSelector) {
|
|---|
| 825 | default:
|
|---|
| 826 | case 0:
|
|---|
| 827 | vp.UnsetSectionPlane();
|
|---|
| 828 | break;
|
|---|
| 829 | case 1:
|
|---|
| 830 | F = G4UIcommand::ValueOf(unit);
|
|---|
| 831 | x *= F; y *= F; z *= F;
|
|---|
| 832 | vp.SetSectionPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
|
|---|
| 833 | vp.SetViewpointDirection(G4Normal3D(nx,ny,nz));
|
|---|
| 834 | break;
|
|---|
| 835 | }
|
|---|
| 836 |
|
|---|
| 837 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 838 | G4cout << "Section drawing is now: ";
|
|---|
| 839 | if (vp.IsSection ()) G4cout << "on";
|
|---|
| 840 | else G4cout << "off";
|
|---|
| 841 | G4cout << ".\nSection plane is now: "
|
|---|
| 842 | << vp.GetSectionPlane ();
|
|---|
| 843 | G4cout << G4endl;
|
|---|
| 844 | }
|
|---|
| 845 | }
|
|---|
| 846 |
|
|---|
| 847 | else if (command == fpCommandStyle) {
|
|---|
| 848 | G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
|
|---|
| 849 | const size_t iPos0 = 0;
|
|---|
| 850 | if (newValue[iPos0] == 'w') { // "wireframe"
|
|---|
| 851 | switch (existingStyle) {
|
|---|
| 852 | case G4ViewParameters::wireframe:
|
|---|
| 853 | break;
|
|---|
| 854 | case G4ViewParameters::hlr:
|
|---|
| 855 | break;
|
|---|
| 856 | case G4ViewParameters::hsr:
|
|---|
| 857 | vp.SetDrawingStyle(G4ViewParameters::wireframe);
|
|---|
| 858 | break;
|
|---|
| 859 | case G4ViewParameters::hlhsr:
|
|---|
| 860 | vp.SetDrawingStyle(G4ViewParameters::hlr);
|
|---|
| 861 | break;
|
|---|
| 862 | }
|
|---|
| 863 | }
|
|---|
| 864 | else if (newValue[iPos0] == 's') { // "surface"
|
|---|
| 865 | switch (existingStyle) {
|
|---|
| 866 | case G4ViewParameters::wireframe:
|
|---|
| 867 | vp.SetDrawingStyle(G4ViewParameters::hsr);
|
|---|
| 868 | break;
|
|---|
| 869 | case G4ViewParameters::hlr:
|
|---|
| 870 | vp.SetDrawingStyle(G4ViewParameters::hlhsr);
|
|---|
| 871 | break;
|
|---|
| 872 | case G4ViewParameters::hsr:
|
|---|
| 873 | break;
|
|---|
| 874 | case G4ViewParameters::hlhsr:
|
|---|
| 875 | break;
|
|---|
| 876 | }
|
|---|
| 877 | }
|
|---|
| 878 | else {
|
|---|
| 879 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 880 | G4cout << "ERROR: \"" << newValue << "\" not recognised."
|
|---|
| 881 | " Looking for 'w' or 's' first character." << G4endl;
|
|---|
| 882 | }
|
|---|
| 883 | return;
|
|---|
| 884 | }
|
|---|
| 885 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 886 | G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
|
|---|
| 887 | << "\" set to " << vp.GetDrawingStyle()
|
|---|
| 888 | << G4endl;
|
|---|
| 889 | }
|
|---|
| 890 | }
|
|---|
| 891 |
|
|---|
| 892 | else if (command == fpCommandUpThetaPhi) {
|
|---|
| 893 | G4double theta, phi;
|
|---|
| 894 | ConvertToDoublePair(newValue, theta, phi);
|
|---|
| 895 | G4double x = std::sin (theta) * std::cos (phi);
|
|---|
| 896 | G4double y = std::sin (theta) * std::sin (phi);
|
|---|
| 897 | G4double z = std::cos (theta);
|
|---|
| 898 | fUpVector = G4ThreeVector (x, y, z);
|
|---|
| 899 | vp.SetUpVector(fUpVector);
|
|---|
| 900 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 901 | G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
|
|---|
| 902 | }
|
|---|
| 903 | }
|
|---|
| 904 |
|
|---|
| 905 | else if (command == fpCommandUpVector) {
|
|---|
| 906 | fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
|
|---|
| 907 | vp.SetUpVector(fUpVector);
|
|---|
| 908 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 909 | G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
|
|---|
| 910 | }
|
|---|
| 911 | }
|
|---|
| 912 |
|
|---|
| 913 | else if (command == fpCommandViewpointThetaPhi) {
|
|---|
| 914 | G4double theta, phi;
|
|---|
| 915 | ConvertToDoublePair(newValue, theta, phi);
|
|---|
| 916 | G4double x = std::sin (theta) * std::cos (phi);
|
|---|
| 917 | G4double y = std::sin (theta) * std::sin (phi);
|
|---|
| 918 | G4double z = std::cos (theta);
|
|---|
| 919 | fViewpointVector = G4ThreeVector (x, y, z);
|
|---|
| 920 | vp.SetViewAndLights(fViewpointVector);
|
|---|
| 921 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 922 | G4cout << "Viewpoint direction set to "
|
|---|
| 923 | << vp.GetViewpointDirection() << G4endl;
|
|---|
| 924 | if (vp.GetLightsMoveWithCamera ()) {
|
|---|
| 925 | G4cout << "Lightpoint direction set to "
|
|---|
| 926 | << vp.GetActualLightpointDirection () << G4endl;
|
|---|
| 927 | }
|
|---|
| 928 | }
|
|---|
| 929 | }
|
|---|
| 930 |
|
|---|
| 931 | else if (command == fpCommandViewpointVector) {
|
|---|
| 932 | fViewpointVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
|
|---|
| 933 | vp.SetViewAndLights(fViewpointVector);
|
|---|
| 934 | if (verbosity >= G4VisManager::confirmations) {
|
|---|
| 935 | G4cout << "Viewpoint direction set to "
|
|---|
| 936 | << vp.GetViewpointDirection() << G4endl;
|
|---|
| 937 | if (vp.GetLightsMoveWithCamera ()) {
|
|---|
| 938 | G4cout << "Lightpoint direction set to "
|
|---|
| 939 | << vp.GetActualLightpointDirection () << G4endl;
|
|---|
| 940 | }
|
|---|
| 941 | }
|
|---|
| 942 | }
|
|---|
| 943 |
|
|---|
| 944 | else {
|
|---|
| 945 | if (verbosity >= G4VisManager::errors) {
|
|---|
| 946 | G4cout <<
|
|---|
| 947 | "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
|
|---|
| 948 | << G4endl;
|
|---|
| 949 | }
|
|---|
| 950 | return;
|
|---|
| 951 | }
|
|---|
| 952 |
|
|---|
| 953 | SetViewParameters(currentViewer,vp);
|
|---|
| 954 | }
|
|---|