00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "G4VisCommandsViewerSet.hh"
00032
00033 #include "G4UIcommand.hh"
00034 #include "G4UIcmdWithAString.hh"
00035 #include "G4UIcmdWithABool.hh"
00036 #include "G4UIcmdWithAnInteger.hh"
00037 #include "G4UIcmdWithADouble.hh"
00038 #include "G4UIcmdWith3VectorAndUnit.hh"
00039 #include "G4UnitsTable.hh"
00040 #include "G4VisManager.hh"
00041 #include "G4Polyhedron.hh"
00042 #include "G4SystemOfUnits.hh"
00043
00044 #include <sstream>
00045 #include <cctype>
00046
00047 G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
00048 fLightsVector (G4ThreeVector(1.,1.,1.)),
00049 fUpVector (G4ThreeVector(0.,1.,0.)),
00050 fViewpointVector (G4ThreeVector(0.,0.,1.))
00051 {
00052 G4bool omitable;
00053 G4UIparameter* parameter;
00054
00055 fpCommandAll = new G4UIcmdWithAString ("/vis/viewer/set/all",this);
00056 fpCommandAll->SetGuidance
00057 ("Copies view parameters.");
00058 fpCommandAll->SetGuidance
00059 ("Copies view parameters (except the autoRefresh status) from"
00060 "\nfrom-viewer to current viewer.");
00061 fpCommandAll->SetParameterName ("from-viewer-name",omitable = false);
00062
00063 fpCommandAutoRefresh = new G4UIcmdWithABool
00064 ("/vis/viewer/set/autoRefresh",this);
00065 fpCommandAutoRefresh->SetGuidance("Sets auto-refresh.");
00066 fpCommandAutoRefresh->SetGuidance
00067 ("If true, view is automatically refreshed after a change of"
00068 "\nview parameters.");
00069 fpCommandAutoRefresh->SetParameterName("auto-refresh",omitable = true);
00070 fpCommandAutoRefresh->SetDefaultValue(true);
00071
00072 fpCommandAuxEdge = new G4UIcmdWithABool
00073 ("/vis/viewer/set/auxiliaryEdge",this);
00074 fpCommandAuxEdge->SetGuidance("Sets visibility of auxiliary edges");
00075 fpCommandAuxEdge->SetGuidance
00076 ("Auxiliary edges, i.e., those that are part of a curved surface,"
00077 "\nsometimes called soft edges, become visible/invisible.");
00078 fpCommandAuxEdge->SetParameterName("edge",omitable = true);
00079 fpCommandAuxEdge->SetDefaultValue(true);
00080
00081 fpCommandBackground = new G4UIcommand
00082 ("/vis/viewer/set/background",this);
00083 fpCommandBackground->SetGuidance
00084 ("Set background colour and transparency (default black and opaque).");
00085 fpCommandBackground->SetGuidance
00086 ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
00087 "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
00088 "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
00089 "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
00090 "\n e.g. \"! ! ! 0.\" for a transparent background.");
00091 parameter = new G4UIparameter("red_or_string", 's', omitable = true);
00092 parameter -> SetDefaultValue ("0.");
00093 fpCommandBackground -> SetParameter (parameter);
00094 parameter = new G4UIparameter("green", 'd', omitable = true);
00095 parameter -> SetDefaultValue (0.);
00096 fpCommandBackground -> SetParameter (parameter);
00097 parameter = new G4UIparameter ("blue", 'd', omitable = true);
00098 parameter -> SetDefaultValue (0.);
00099 fpCommandBackground -> SetParameter (parameter);
00100 parameter = new G4UIparameter ("opacity", 'd', omitable = true);
00101 parameter -> SetDefaultValue (1.);
00102 fpCommandBackground -> SetParameter (parameter);
00103
00104 fpCommandCulling = new G4UIcommand("/vis/viewer/set/culling",this);
00105 fpCommandCulling->SetGuidance ("Set culling options.");
00106 fpCommandCulling->SetGuidance
00107 ("\"global\": enables/disables all other culling options.");
00108 fpCommandCulling->SetGuidance
00109 ("\"coveredDaughters\": culls, i.e., eliminates, volumes that would not"
00110 "\nbe seen because covered by ancester volumes in surface drawing mode,"
00111 "\nand then only if the ancesters are visible and opaque, and then only"
00112 "\nif no sections or cutaways are in operation. Intended solely to"
00113 "\nimprove the speed of rendering visible volumes.");
00114 fpCommandCulling->SetGuidance
00115 ("\"invisible\": culls objects with the invisible attribute set.");
00116 fpCommandCulling->SetGuidance
00117 ("\"density\": culls volumes with density lower than threshold. Useful"
00118 "\nfor eliminating \"container volumes\" with no physical correspondence,"
00119 "\nwhose material is usually air. If this is selected, provide threshold"
00120 "\ndensity and unit (g/cm3 mg/cm3 or kg/m3)."
00121 );
00122 parameter = new G4UIparameter("culling-option",'s',omitable = false);
00123 parameter->SetParameterCandidates
00124 ("global coveredDaughters invisible density");
00125 fpCommandCulling->SetParameter(parameter);
00126 parameter = new G4UIparameter("action",'b',omitable = true);
00127 parameter->SetDefaultValue(1);
00128 fpCommandCulling->SetParameter(parameter);
00129 parameter = new G4UIparameter("density-threshold",'d',omitable = true);
00130 parameter->SetDefaultValue("0.01");
00131 fpCommandCulling->SetParameter(parameter);
00132 parameter = new G4UIparameter("unit",'s',omitable = true);
00133 parameter->SetParameterCandidates ("g/cm3, mg/cm3 kg/m3");
00134 parameter->SetDefaultValue("g/cm3");
00135 fpCommandCulling->SetParameter(parameter);
00136
00137 fpCommandCutawayMode =
00138 new G4UIcmdWithAString ("/vis/viewer/set/cutawayMode", this);
00139 fpCommandCutawayMode->SetGuidance
00140 ("Sets cutaway mode - add (union) or multiply (intersection).");
00141 fpCommandCutawayMode->SetParameterName ("cutaway-mode",omitable = false);
00142 fpCommandCutawayMode->SetCandidates ("add union multiply intersection");
00143 fpCommandCutawayMode->SetDefaultValue("union");
00144
00145 fpCommandDefaultColour = new G4UIcommand
00146 ("/vis/viewer/set/defaultColour",this);
00147 fpCommandDefaultColour->SetGuidance
00148 ("Set defaultColour colour and transparency (default white and opaque).");
00149 fpCommandDefaultColour->SetGuidance
00150 ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
00151 "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
00152 "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
00153 "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
00154 "\n e.g. \"! ! ! 0.\" for a transparent colour.");
00155 parameter = new G4UIparameter("red_or_string", 's', omitable = true);
00156 parameter -> SetDefaultValue ("1.");
00157 fpCommandDefaultColour -> SetParameter (parameter);
00158 parameter = new G4UIparameter("green", 'd', omitable = true);
00159 parameter -> SetDefaultValue (1.);
00160 fpCommandDefaultColour -> SetParameter (parameter);
00161 parameter = new G4UIparameter ("blue", 'd', omitable = true);
00162 parameter -> SetDefaultValue (1.);
00163 fpCommandDefaultColour -> SetParameter (parameter);
00164 parameter = new G4UIparameter ("opacity", 'd', omitable = true);
00165 parameter -> SetDefaultValue (1.);
00166 fpCommandDefaultColour -> SetParameter (parameter);
00167
00168 fpCommandDefaultTextColour = new G4UIcommand
00169 ("/vis/viewer/set/defaultTextColour",this);
00170 fpCommandDefaultTextColour->SetGuidance
00171 ("Set defaultTextColour colour and transparency (default white and opaque).");
00172 fpCommandDefaultTextColour->SetGuidance
00173 ("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
00174 "\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
00175 "\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
00176 "\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
00177 "\n e.g. \"! ! ! 0.\" for a transparent colour.");
00178 parameter = new G4UIparameter("red_or_string", 's', omitable = true);
00179 parameter -> SetDefaultValue ("1.");
00180 fpCommandDefaultTextColour -> SetParameter (parameter);
00181 parameter = new G4UIparameter("green", 'd', omitable = true);
00182 parameter -> SetDefaultValue (1.);
00183 fpCommandDefaultTextColour -> SetParameter (parameter);
00184 parameter = new G4UIparameter ("blue", 'd', omitable = true);
00185 parameter -> SetDefaultValue (1.);
00186 fpCommandDefaultTextColour -> SetParameter (parameter);
00187 parameter = new G4UIparameter ("opacity", 'd', omitable = true);
00188 parameter -> SetDefaultValue (1.);
00189 fpCommandDefaultTextColour -> SetParameter (parameter);
00190
00191 fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
00192 fpCommandEdge->SetGuidance
00193 ("Edges become visible/invisible in surface mode.");
00194 fpCommandEdge->SetParameterName("edge",omitable = true);
00195 fpCommandEdge->SetDefaultValue(true);
00196
00197 fpCommandExplodeFactor = new G4UIcommand
00198 ("/vis/viewer/set/explodeFactor", this);
00199 fpCommandExplodeFactor->SetGuidance
00200 ("Moves top-level drawn volumes by this factor from this centre.");
00201 parameter = new G4UIparameter("explodeFactor", 'd', omitable=true);
00202 parameter->SetParameterRange("explodeFactor>=1.");
00203 parameter->SetDefaultValue(1.);
00204 fpCommandExplodeFactor->SetParameter(parameter);
00205 parameter = new G4UIparameter("x",'d',omitable = true);
00206 parameter->SetDefaultValue (0);
00207 parameter->SetGuidance ("Coordinate of explode centre.");
00208 fpCommandExplodeFactor->SetParameter(parameter);
00209 parameter = new G4UIparameter("y",'d',omitable = true);
00210 parameter->SetDefaultValue (0);
00211 parameter->SetGuidance ("Coordinate of explode centre.");
00212 fpCommandExplodeFactor->SetParameter(parameter);
00213 parameter = new G4UIparameter("z",'d',omitable = true);
00214 parameter->SetDefaultValue (0);
00215 parameter->SetGuidance ("Coordinate of explode centre.");
00216 fpCommandExplodeFactor->SetParameter(parameter);
00217 parameter = new G4UIparameter("unit",'s',omitable = true);
00218 parameter->SetDefaultValue ("m");
00219 parameter->SetGuidance ("Unit of explode centre.");
00220 fpCommandExplodeFactor->SetParameter(parameter);
00221
00222 fpCommandGlobalLineWidthScale = new G4UIcmdWithADouble
00223 ("/vis/viewer/set/globalLineWidthScale", this);
00224 fpCommandGlobalLineWidthScale->SetGuidance
00225 ("Multiplies line widths by this factor.");
00226 fpCommandGlobalLineWidthScale->
00227 SetParameterName("scale-factor", omitable=true);
00228 fpCommandGlobalLineWidthScale->SetDefaultValue(1.);
00229
00230 fpCommandGlobalMarkerScale = new G4UIcmdWithADouble
00231 ("/vis/viewer/set/globalMarkerScale", this);
00232 fpCommandGlobalMarkerScale->SetGuidance
00233 ("Multiplies marker sizes by this factor.");
00234 fpCommandGlobalMarkerScale->
00235 SetParameterName("scale-factor", omitable=true);
00236 fpCommandGlobalMarkerScale->SetDefaultValue(1.);
00237
00238 fpCommandHiddenEdge =
00239 new G4UIcmdWithABool("/vis/viewer/set/hiddenEdge",this);
00240 fpCommandHiddenEdge->SetGuidance
00241 ("Edges become hidden/seen in wireframe or surface mode.");
00242 fpCommandHiddenEdge->SetParameterName("hidden-edge",omitable = true);
00243 fpCommandHiddenEdge->SetDefaultValue(true);
00244
00245 fpCommandHiddenMarker =
00246 new G4UIcmdWithABool("/vis/viewer/set/hiddenMarker",this);
00247 fpCommandHiddenMarker->SetGuidance
00248 ("If true, closer objects hide markers. Otherwise, markers always show.");
00249 fpCommandHiddenMarker->SetParameterName("hidden-marker",omitable = true);
00250 fpCommandHiddenMarker->SetDefaultValue(true);
00251
00252 fpCommandLightsMove = new G4UIcmdWithAString
00253 ("/vis/viewer/set/lightsMove",this);
00254 fpCommandLightsMove->SetGuidance
00255 ("Lights move with camera or with object");
00256 fpCommandLightsMove->SetParameterName("lightsMove",omitable = false);
00257 fpCommandLightsMove->SetCandidates
00258 ("cam camera with-camera obj object with-object");
00259
00260 fpCommandLightsThetaPhi = new G4UIcommand
00261 ("/vis/viewer/set/lightsThetaPhi", this);
00262 fpCommandLightsThetaPhi->SetGuidance
00263 ("Set direction from target to lights.");
00264 parameter = new G4UIparameter("theta", 'd', omitable = true);
00265 parameter -> SetDefaultValue(60.);
00266 fpCommandLightsThetaPhi -> SetParameter (parameter);
00267 parameter = new G4UIparameter("phi", 'd', omitable = true);
00268 parameter -> SetDefaultValue(45.);
00269 fpCommandLightsThetaPhi -> SetParameter (parameter);
00270 parameter = new G4UIparameter ("unit", 's', omitable = true);
00271 parameter -> SetDefaultValue ("deg");
00272 fpCommandLightsThetaPhi -> SetParameter (parameter);
00273
00274 fpCommandLightsVector = new G4UIcommand
00275 ("/vis/viewer/set/lightsVector", this);
00276 fpCommandLightsVector->SetGuidance
00277 ("Set direction from target to lights.");
00278 parameter = new G4UIparameter("x", 'd', omitable = true);
00279 parameter -> SetDefaultValue (1);
00280 fpCommandLightsVector -> SetParameter (parameter);
00281 parameter = new G4UIparameter("y", 'd', omitable = true);
00282 parameter -> SetDefaultValue (1);
00283 fpCommandLightsVector -> SetParameter (parameter);
00284 parameter = new G4UIparameter ("z", 'd', omitable = true);
00285 parameter -> SetDefaultValue (1);
00286 fpCommandLightsVector -> SetParameter (parameter);
00287
00288 fpCommandLineSegments = new G4UIcmdWithAnInteger
00289 ("/vis/viewer/set/lineSegmentsPerCircle",this);
00290 fpCommandLineSegments->SetGuidance
00291 ("Set number of sides per circle for polygon/polyhedron drawing.");
00292 fpCommandLineSegments->SetGuidance
00293 ("Refers to graphical representation of objects with curved lines/surfaces.");
00294 fpCommandLineSegments->SetParameterName("line-segments",omitable = true);
00295 fpCommandLineSegments->SetDefaultValue(24);
00296
00297 fpCommandPicking = new G4UIcmdWithABool
00298 ("/vis/viewer/set/picking",this);
00299 fpCommandPicking->SetGuidance("Sets picking, if available.");
00300 fpCommandPicking->SetGuidance
00301 ("If true, view is set up for picking, if available.");
00302 fpCommandPicking->SetGuidance
00303 ("You may need to issue \"/vis/viewer/update\".");
00304 fpCommandPicking->SetGuidance
00305 ("For required actions, watch for instructions for viewer.");
00306 fpCommandPicking->SetParameterName("picking",omitable = true);
00307 fpCommandPicking->SetDefaultValue(true);
00308
00309 fpCommandProjection = new G4UIcommand("/vis/viewer/set/projection",this);
00310 fpCommandProjection->SetGuidance
00311 ("Orthogonal or perspective projection.");
00312 parameter = new G4UIparameter("projection",'s',omitable = true);
00313 parameter->SetParameterCandidates("o orthogonal p perspective");
00314 parameter->SetDefaultValue("orthogonal");
00315 fpCommandProjection->SetParameter(parameter);
00316 parameter = new G4UIparameter("field-half-angle",'d',omitable = true);
00317 parameter->SetDefaultValue(30.);
00318
00319 fpCommandProjection->SetParameter(parameter);
00320 parameter = new G4UIparameter("unit",'s',omitable = true);
00321 parameter->SetDefaultValue("deg");
00322
00323 fpCommandProjection->SetParameter(parameter);
00324
00325 fpCommandRotationStyle = new G4UIcmdWithAString
00326 ("/vis/viewer/set/rotationStyle",this);
00327 fpCommandRotationStyle->SetGuidance
00328 ("Set style of rotation - constrainUpDirection or freeRotation.");
00329 fpCommandRotationStyle->SetGuidance
00330 ("constrainUpDirection: conventional HEP view.");
00331 fpCommandRotationStyle->SetGuidance
00332 ("freeRotation: Google-like rotation, using mouse-grab.");
00333 fpCommandRotationStyle->SetParameterName ("style",omitable = false);
00334 fpCommandRotationStyle->SetCandidates("constrainUpDirection freeRotation");
00335
00336 fpCommandSectionPlane = new G4UIcommand("/vis/viewer/set/sectionPlane",this);
00337 fpCommandSectionPlane -> SetGuidance
00338 ("Set plane for drawing section (DCUT).");
00339 fpCommandSectionPlane -> SetGuidance
00340 ("E.g., for a y-z plane at x = 1 cm:"
00341 "\n\"/vis/viewer/set/sectionPlane on 1 0 0 cm 1 0 0\"."
00342 "\nTo turn off: /vis/viewer/set/sectionPlane off");
00343 parameter = new G4UIparameter("Selector",'c',true);
00344 parameter -> SetDefaultValue ("on");
00345 fpCommandSectionPlane->SetParameter(parameter);
00346 parameter = new G4UIparameter("x",'d',omitable = true);
00347 parameter -> SetDefaultValue (0);
00348 parameter -> SetGuidance ("Coordinate of point on the plane.");
00349 fpCommandSectionPlane->SetParameter(parameter);
00350 parameter = new G4UIparameter("y",'d',omitable = true);
00351 parameter -> SetDefaultValue (0);
00352 parameter -> SetGuidance ("Coordinate of point on the plane.");
00353 fpCommandSectionPlane->SetParameter(parameter);
00354 parameter = new G4UIparameter("z",'d',omitable = true);
00355 parameter -> SetDefaultValue (0);
00356 parameter -> SetGuidance ("Coordinate of point on the plane.");
00357 fpCommandSectionPlane->SetParameter(parameter);
00358 parameter = new G4UIparameter("unit",'s',omitable = true);
00359 parameter -> SetDefaultValue ("m");
00360 parameter -> SetGuidance ("Unit of point on the plane.");
00361 fpCommandSectionPlane->SetParameter(parameter);
00362 parameter = new G4UIparameter("nx",'d',omitable = true);
00363 parameter -> SetDefaultValue (1);
00364 parameter -> SetGuidance ("Component of plane normal.");
00365 fpCommandSectionPlane->SetParameter(parameter);
00366 parameter = new G4UIparameter("ny",'d',omitable = true);
00367 parameter -> SetDefaultValue (0);
00368 parameter -> SetGuidance ("Component of plane normal.");
00369 fpCommandSectionPlane->SetParameter(parameter);
00370 parameter = new G4UIparameter("nz",'d',omitable = true);
00371 parameter -> SetDefaultValue (0);
00372 parameter -> SetGuidance ("Component of plane normal.");
00373 fpCommandSectionPlane->SetParameter(parameter);
00374
00375 fpCommandStyle = new G4UIcmdWithAString ("/vis/viewer/set/style",this);
00376 fpCommandStyle->SetGuidance
00377 ("Set style of drawing - w[ireframe] or s[urface].");
00378 fpCommandStyle->SetGuidance
00379 ("(Hidden line drawing is controlled by \"/vis/viewer/set/hiddenEdge\".)");
00380 fpCommandStyle->SetParameterName ("style",omitable = false);
00381
00382 fpCommandTargetPoint = new G4UIcmdWith3VectorAndUnit
00383 ("/vis/viewer/set/targetPoint", this);
00384 fpCommandTargetPoint->SetGuidance
00385 ("Set target point.");
00386 fpCommandTargetPoint->SetGuidance
00387 ("This sets the \"Current Target Point\" relative to the \"Standard");
00388 fpCommandTargetPoint->SetGuidance
00389 ("Target Point\" so that the actual target point is as requested.");
00390 fpCommandTargetPoint->SetGuidance
00391 ("(See G4ViewParameters.hh for an explanation of target points.)");
00392 fpCommandTargetPoint->SetParameterName("x", "y", "z", omitable = false);
00393 fpCommandTargetPoint->SetUnitCategory("Length");
00394
00395 fpCommandUpThetaPhi = new G4UIcommand
00396 ("/vis/viewer/set/upThetaPhi", this);
00397 fpCommandUpThetaPhi -> SetGuidance ("Set up vector.");
00398 fpCommandUpThetaPhi -> SetGuidance
00399 ("Viewer will attempt always to show this direction upwards.");
00400 parameter = new G4UIparameter("theta", 'd', omitable = true);
00401 parameter -> SetDefaultValue (90.);
00402 fpCommandUpThetaPhi -> SetParameter (parameter);
00403 parameter = new G4UIparameter("phi", 'd', omitable = true);
00404 parameter -> SetDefaultValue (90.);
00405 fpCommandUpThetaPhi -> SetParameter (parameter);
00406 parameter = new G4UIparameter ("unit", 's', omitable = true);
00407 parameter -> SetDefaultValue ("deg");
00408 fpCommandUpThetaPhi -> SetParameter (parameter);
00409
00410 fpCommandUpVector = new G4UIcommand
00411 ("/vis/viewer/set/upVector", this);
00412 fpCommandUpVector -> SetGuidance ("Set up vector.");
00413 fpCommandUpVector -> SetGuidance
00414 ("Viewer will attempt always to show this direction upwards.");
00415 parameter = new G4UIparameter("x", 'd', omitable = true);
00416 parameter -> SetDefaultValue (0.);
00417 fpCommandUpVector -> SetParameter (parameter);
00418 parameter = new G4UIparameter("y", 'd', omitable = true);
00419 parameter -> SetDefaultValue (1.);
00420 fpCommandUpVector -> SetParameter (parameter);
00421 parameter = new G4UIparameter ("z", 'd', omitable = true);
00422 parameter -> SetDefaultValue (0.);
00423 fpCommandUpVector -> SetParameter (parameter);
00424
00425 fpCommandViewpointThetaPhi = new G4UIcommand
00426 ("/vis/viewer/set/viewpointThetaPhi", this);
00427 fpCommandViewpointThetaPhi -> SetGuidance
00428 ("Set direction from target to camera.");
00429 fpCommandViewpointThetaPhi -> SetGuidance
00430 ("Also changes lightpoint direction if lights are set to move with camera.");
00431 parameter = new G4UIparameter("theta", 'd', omitable = true);
00432 parameter -> SetDefaultValue (60.);
00433 fpCommandViewpointThetaPhi -> SetParameter (parameter);
00434 parameter = new G4UIparameter("phi", 'd', omitable = true);
00435 parameter -> SetDefaultValue (45.);
00436 fpCommandViewpointThetaPhi -> SetParameter (parameter);
00437 parameter = new G4UIparameter ("unit", 's', omitable = true);
00438 parameter -> SetDefaultValue ("deg");
00439 fpCommandViewpointThetaPhi -> SetParameter (parameter);
00440
00441 fpCommandViewpointVector = new G4UIcommand
00442 ("/vis/viewer/set/viewpointVector", this);
00443 fpCommandViewpointVector -> SetGuidance
00444 ("Set direction from target to camera.");
00445 fpCommandViewpointVector -> SetGuidance
00446 ("Also changes lightpoint direction if lights are set to move with camera.");
00447 parameter = new G4UIparameter("x", 'd', omitable = true);
00448 parameter -> SetDefaultValue (1.);
00449 fpCommandViewpointVector -> SetParameter (parameter);
00450 parameter = new G4UIparameter("y", 'd', omitable = true);
00451 parameter -> SetDefaultValue (1.);
00452 fpCommandViewpointVector -> SetParameter (parameter);
00453 parameter = new G4UIparameter ("z", 'd', omitable = true);
00454 parameter -> SetDefaultValue (1.);
00455 fpCommandViewpointVector -> SetParameter (parameter);
00456 }
00457
00458 G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
00459 delete fpCommandAll;
00460 delete fpCommandAuxEdge;
00461 delete fpCommandAutoRefresh;
00462 delete fpCommandBackground;
00463 delete fpCommandCulling;
00464 delete fpCommandCutawayMode;
00465 delete fpCommandDefaultColour;
00466 delete fpCommandDefaultTextColour;
00467 delete fpCommandEdge;
00468 delete fpCommandExplodeFactor;
00469 delete fpCommandGlobalLineWidthScale;
00470 delete fpCommandGlobalMarkerScale;
00471 delete fpCommandHiddenEdge;
00472 delete fpCommandHiddenMarker;
00473 delete fpCommandLineSegments;
00474 delete fpCommandLightsMove;
00475 delete fpCommandLightsThetaPhi;
00476 delete fpCommandLightsVector;
00477 delete fpCommandPicking;
00478 delete fpCommandProjection;
00479 delete fpCommandRotationStyle;
00480 delete fpCommandSectionPlane;
00481 delete fpCommandStyle;
00482 delete fpCommandTargetPoint;
00483 delete fpCommandUpThetaPhi;
00484 delete fpCommandUpVector;
00485 delete fpCommandViewpointThetaPhi;
00486 delete fpCommandViewpointVector;
00487 }
00488
00489 G4String G4VisCommandsViewerSet::GetCurrentValue(G4UIcommand*) {
00490 return "";
00491 }
00492
00493 void G4VisCommandsViewerSet::SetNewValue
00494 (G4UIcommand* command,G4String newValue) {
00495
00496 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
00497
00498 G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
00499 if (!currentViewer) {
00500 if (verbosity >= G4VisManager::errors) {
00501 G4cout <<
00502 "ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
00503 << G4endl;
00504 }
00505 return;
00506 }
00507
00508 G4ViewParameters vp = currentViewer->GetViewParameters();
00509
00510 if (command == fpCommandAll) {
00511 G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
00512 if (!fromViewer) {
00513 if (verbosity >= G4VisManager::errors) {
00514 G4cout <<
00515 "ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
00516 "\n unrecognised from-viewer."
00517 << G4endl;
00518 }
00519 return;
00520 }
00521 if (fromViewer == currentViewer) {
00522 if (verbosity >= G4VisManager::warnings) {
00523 G4cout <<
00524 "WARNING: G4VisCommandsViewerSet::SetNewValue: all:"
00525 "\n from-viewer and current viewer are identical."
00526 << G4endl;
00527 }
00528 return;
00529 }
00530
00531 G4bool currentAutoRefresh =
00532 currentViewer->GetViewParameters().IsAutoRefresh();
00533 vp = fromViewer->GetViewParameters();
00534 vp.SetAutoRefresh(currentAutoRefresh);
00535 if (verbosity >= G4VisManager::confirmations) {
00536 G4cout << "View parameters of viewer \"" << currentViewer->GetName()
00537 << "\"\n set to those of viewer \"" << fromViewer->GetName()
00538 << "\"."
00539 << G4endl;
00540 }
00541 }
00542
00543 else if (command == fpCommandAutoRefresh) {
00544 G4bool autoRefresh = G4UIcommand::ConvertToBool(newValue);
00545 const G4ViewParameters& defaultVP =
00546 currentViewer->GetDefaultViewParameters();
00547 if (autoRefresh && !defaultVP.IsAutoRefresh()) {
00548 if (verbosity >= G4VisManager::warnings) {
00549 G4cout
00550 << "WARNING: "
00551 << currentViewer->GetName() << " is NOT auto-refesh by default"
00552 << "\n so cannot be set to auto-refresh."
00553 << G4endl;
00554 return;
00555 }
00556 }
00557 vp.SetAutoRefresh(autoRefresh);
00558 if (verbosity >= G4VisManager::confirmations) {
00559 G4cout << "Views will ";
00560 if (!vp.IsAutoRefresh()) G4cout << "not ";
00561 G4cout << "be automatically refreshed after a change of view parameters."
00562 << G4endl;
00563 }
00564 if (!vp.IsAutoRefresh()) {
00565 currentViewer->SetViewParameters(vp);
00566 return;
00567 }
00568 }
00569
00570 else if (command == fpCommandAuxEdge) {
00571 vp.SetAuxEdgeVisible(G4UIcommand::ConvertToBool(newValue));
00572 if (verbosity >= G4VisManager::confirmations) {
00573 G4cout << "Auxiliary edges will ";
00574 if (!vp.IsAuxEdgeVisible()) G4cout << "not ";
00575 G4cout << "be visible." << G4endl;
00576 }
00577 }
00578
00579 else if (command == fpCommandBackground) {
00580 G4String redOrString;
00581 G4double green, blue, opacity;
00582 std::istringstream iss(newValue);
00583 iss >> redOrString >> green >> blue >> opacity;
00584 G4Colour colour(0.,0.,0.);
00585 const size_t iPos0 = 0;
00586 if (std::isalpha(redOrString[iPos0])) {
00587 if (!G4Colour::GetColour(redOrString, colour)) {
00588 if (verbosity >= G4VisManager::warnings) {
00589 G4cout << "WARNING: Text colour \"" << redOrString
00590 << "\" not found. Defaulting to black and opaque."
00591 << G4endl;
00592 }
00593 }
00594 } else {
00595 colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
00596 }
00597
00598 colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
00599 vp.SetBackgroundColour(colour);
00600 if (verbosity >= G4VisManager::confirmations) {
00601 G4cout << "Background colour "
00602 << vp.GetBackgroundColour()
00603 << " requested."
00604 << G4endl;
00605 }
00606 }
00607
00608 else if (command == fpCommandCulling) {
00609 G4String cullingOption, stringFlag, unit;
00610 G4double density;
00611 std::istringstream is (newValue);
00612 is >> cullingOption >> stringFlag >> density >> unit;
00613 G4bool boolFlag = G4UIcommand::ConvertToBool(stringFlag);
00614 if (cullingOption == "global") {
00615 vp.SetCulling(boolFlag);
00616 if (verbosity >= G4VisManager::confirmations) {
00617 G4cout <<
00618 "G4VisCommandsViewerSet::SetNewValue: culling: global culling flag"
00619 " set to " << G4UIcommand::ConvertToString(boolFlag) <<
00620 ".\n Does not change specific culling flags."
00621 << G4endl;
00622 }
00623 }
00624 else if (cullingOption == "coveredDaughters") {
00625 vp.SetCullingCovered(boolFlag);
00626 if (verbosity >= G4VisManager::confirmations) {
00627 G4cout <<
00628 "G4VisCommandsViewerSet::SetNewValue: culling: culling covered"
00629 "\n daughters flag set to "
00630 << G4UIcommand::ConvertToString(boolFlag) <<
00631 ". Daughters covered by opaque mothers"
00632 "\n will be culled, i.e., not drawn, if this flag is true."
00633 "\n Note: this is only effective in surface drawing style,"
00634 "\n and then only if the volumes are visible and opaque, and then"
00635 "\n only if no sections or cutaways are in operation."
00636 << G4endl;
00637 }
00638 }
00639 else if (cullingOption == "invisible") {
00640 vp.SetCullingInvisible(boolFlag);
00641 if (verbosity >= G4VisManager::confirmations) {
00642 G4cout <<
00643 "G4VisCommandsViewerSet::SetNewValue: culling: culling invisible"
00644 "\n flag set to "
00645 << boolFlag << G4UIcommand::ConvertToString(boolFlag) <<
00646 ". Volumes marked invisible will be culled,"
00647 "\n i.e., not drawn, if this flag is true."
00648 << G4endl;
00649 }
00650 }
00651 else if (cullingOption == "density") {
00652 vp.SetDensityCulling(boolFlag);
00653 if (boolFlag) {
00654 density *= G4UnitDefinition::GetValueOf(unit);
00655 vp.SetVisibleDensity(density);
00656 }
00657 else {
00658 density = vp.GetVisibleDensity();
00659 }
00660 if (verbosity >= G4VisManager::confirmations) {
00661 G4cout <<
00662 "G4VisCommandsViewerSet::SetNewValue: culling: culling by density"
00663 "\n flag set to " << G4UIcommand::ConvertToString(boolFlag) <<
00664 ". Volumes with density less than " <<
00665 G4BestUnit(density,"Volumic Mass") <<
00666 "\n will be culled, i.e., not drawn, if this flag is true."
00667 << G4endl;
00668 }
00669 }
00670 else {
00671 if (verbosity >= G4VisManager::errors) {
00672 G4cout <<
00673 "ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
00674 "\n option not recognised."
00675 << G4endl;
00676 }
00677 }
00678 }
00679
00680 else if (command == fpCommandCutawayMode) {
00681 if (newValue == "add" || newValue == "union")
00682 vp.SetCutawayMode(G4ViewParameters::cutawayUnion);
00683 if (newValue == "multiply" || newValue == "intersection")
00684 vp.SetCutawayMode(G4ViewParameters::cutawayIntersection);
00685
00686 if (verbosity >= G4VisManager::confirmations) {
00687 G4cout << "Cutaway mode set to ";
00688 if (vp.GetCutawayMode() == G4ViewParameters::cutawayUnion)
00689 G4cout << "cutawayUnion";
00690 if (vp.GetCutawayMode() == G4ViewParameters::cutawayIntersection)
00691 G4cout << "cutawayIntersection";
00692 G4cout << G4endl;
00693 }
00694 }
00695
00696 else if (command == fpCommandDefaultColour) {
00697 G4String redOrString;
00698 G4double green, blue, opacity;
00699 std::istringstream iss(newValue);
00700 iss >> redOrString >> green >> blue >> opacity;
00701 G4Colour colour(1.,1.,1.);
00702 const size_t iPos0 = 0;
00703 if (std::isalpha(redOrString[iPos0])) {
00704 if (!G4Colour::GetColour(redOrString, colour)) {
00705 if (verbosity >= G4VisManager::warnings) {
00706 G4cout << "WARNING: Text colour \"" << redOrString
00707 << "\" not found. Defaulting to white and opaque."
00708 << G4endl;
00709 }
00710 }
00711 } else {
00712 colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
00713 }
00714
00715 colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
00716 G4VisAttributes va = vp.GetDefaultVisAttributes();
00717 va.SetColour(colour);
00718 vp.SetDefaultVisAttributes(va);
00719 if (verbosity >= G4VisManager::confirmations) {
00720 G4cout << "Default colour "
00721 << vp.GetDefaultVisAttributes()->GetColour()
00722 << " requested."
00723 << G4endl;
00724 }
00725 }
00726
00727 else if (command == fpCommandDefaultTextColour) {
00728 G4String redOrString;
00729 G4double green, blue, opacity;
00730 std::istringstream iss(newValue);
00731 iss >> redOrString >> green >> blue >> opacity;
00732 G4Colour colour(1.,1.,1.);
00733 const size_t iPos0 = 0;
00734 if (std::isalpha(redOrString[iPos0])) {
00735 if (!G4Colour::GetColour(redOrString, colour)) {
00736 if (verbosity >= G4VisManager::warnings) {
00737 G4cout << "WARNING: Text colour \"" << redOrString
00738 << "\" not found. Defaulting to white and opaque."
00739 << G4endl;
00740 }
00741 }
00742 } else {
00743 colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
00744 }
00745
00746 colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
00747 G4VisAttributes va = vp.GetDefaultTextVisAttributes();
00748 va.SetColour(colour);
00749 vp.SetDefaultTextVisAttributes(va);
00750 if (verbosity >= G4VisManager::confirmations) {
00751 G4cout << "Default colour "
00752 << vp.GetDefaultTextVisAttributes()->GetColour()
00753 << " requested."
00754 << G4endl;
00755 }
00756 }
00757
00758 else if (command == fpCommandEdge) {
00759 G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
00760 if (G4UIcommand::ConvertToBool(newValue)) {
00761 switch (existingStyle) {
00762 case G4ViewParameters::wireframe:
00763 break;
00764 case G4ViewParameters::hlr:
00765 break;
00766 case G4ViewParameters::hsr:
00767 vp.SetDrawingStyle(G4ViewParameters::hlhsr);
00768 break;
00769 case G4ViewParameters::hlhsr:
00770 break;
00771 }
00772 }
00773 else {
00774 switch (existingStyle) {
00775 case G4ViewParameters::wireframe:
00776 break;
00777 case G4ViewParameters::hlr:
00778 break;
00779 case G4ViewParameters::hsr:
00780 break;
00781 case G4ViewParameters::hlhsr:
00782 vp.SetDrawingStyle(G4ViewParameters::hsr);
00783 break;
00784 }
00785 }
00786 if (verbosity >= G4VisManager::confirmations) {
00787 G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
00788 << "\" set to " << vp.GetDrawingStyle()
00789 << G4endl;
00790 }
00791 }
00792
00793 else if (command == fpCommandExplodeFactor) {
00794 G4double explodeFactor, x, y, z;
00795 G4String unitString;
00796 std::istringstream is (newValue);
00797 is >> explodeFactor >> x >> y >> z >> unitString;
00798 G4double unit = G4UIcommand::ValueOf(unitString);
00799 vp.SetExplodeFactor(explodeFactor);
00800 vp.SetExplodeCentre(G4Point3D(x * unit, y * unit, z * unit));
00801 if (verbosity >= G4VisManager::confirmations) {
00802 G4cout << "Explode factor changed to " << vp.GetExplodeFactor()
00803 << " from centre " << vp.GetExplodeCentre()
00804 << G4endl;
00805 }
00806 }
00807
00808 else if (command == fpCommandGlobalLineWidthScale) {
00809 G4double globalLineWidthScale
00810 = fpCommandGlobalLineWidthScale->GetNewDoubleValue(newValue);
00811 vp.SetGlobalLineWidthScale(globalLineWidthScale);
00812 if (verbosity >= G4VisManager::confirmations) {
00813 G4cout << "Global Line Width Scale changed to "
00814 << vp.GetGlobalLineWidthScale() << G4endl;
00815 }
00816 }
00817
00818 else if (command == fpCommandGlobalMarkerScale) {
00819 G4double globalMarkerScale
00820 = fpCommandGlobalMarkerScale->GetNewDoubleValue(newValue);
00821 vp.SetGlobalMarkerScale(globalMarkerScale);
00822 if (verbosity >= G4VisManager::confirmations) {
00823 G4cout << "Global Marker Scale changed to "
00824 << vp.GetGlobalMarkerScale() << G4endl;
00825 }
00826 }
00827
00828 else if (command == fpCommandHiddenEdge) {
00829 G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
00830 if (G4UIcommand::ConvertToBool(newValue)) {
00831 switch (existingStyle) {
00832 case G4ViewParameters::wireframe:
00833 vp.SetDrawingStyle(G4ViewParameters::hlr);
00834 break;
00835 case G4ViewParameters::hlr:
00836 break;
00837 case G4ViewParameters::hsr:
00838 vp.SetDrawingStyle(G4ViewParameters::hlhsr);
00839 break;
00840 case G4ViewParameters::hlhsr:
00841 break;
00842 }
00843 }
00844 else {
00845 switch (existingStyle) {
00846 case G4ViewParameters::wireframe:
00847 break;
00848 case G4ViewParameters::hlr:
00849 vp.SetDrawingStyle(G4ViewParameters::wireframe);
00850 break;
00851 case G4ViewParameters::hsr:
00852 break;
00853 case G4ViewParameters::hlhsr:
00854 vp.SetDrawingStyle(G4ViewParameters::hsr);
00855 break;
00856 }
00857 }
00858 if (verbosity >= G4VisManager::confirmations) {
00859 G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
00860 << "\" set to " << vp.GetDrawingStyle()
00861 << G4endl;
00862 }
00863 }
00864
00865 else if (command == fpCommandHiddenMarker) {
00866 G4bool hidden = G4UIcommand::ConvertToBool(newValue);
00867 if (hidden) vp.SetMarkerHidden();
00868 else vp.SetMarkerNotHidden();
00869 if (verbosity >= G4VisManager::confirmations) {
00870 G4cout << "Markers will ";
00871 if (vp.IsMarkerNotHidden()) G4cout << "not ";
00872 G4cout << "be hidden under solid objects." << G4endl;
00873 }
00874 }
00875
00876 else if (command == fpCommandLightsMove) {
00877 if (newValue.find("cam") != G4String::npos)
00878 vp.SetLightsMoveWithCamera(true);
00879 else if(newValue.find("obj") != G4String::npos)
00880 vp.SetLightsMoveWithCamera(false);
00881 else {
00882 if (verbosity >= G4VisManager::errors) {
00883 G4cout << "ERROR: \"" << newValue << "\" not recognised."
00884 " Looking for \"cam\" or \"obj\" in string." << G4endl;
00885 }
00886 }
00887 if (verbosity >= G4VisManager::confirmations) {
00888 G4cout << "Lights move with ";
00889 if (vp.GetLightsMoveWithCamera())
00890 G4cout << "camera (object appears to rotate).";
00891 else G4cout << "object (the viewer appears to be moving).";
00892 G4cout << G4endl;
00893 }
00894 }
00895
00896 else if (command == fpCommandLightsThetaPhi) {
00897 G4double theta, phi;
00898 ConvertToDoublePair(newValue, theta, phi);
00899 G4double x = std::sin (theta) * std::cos (phi);
00900 G4double y = std::sin (theta) * std::sin (phi);
00901 G4double z = std::cos (theta);
00902 fLightsVector = G4ThreeVector (x, y, z);
00903 vp.SetLightpointDirection(fLightsVector);
00904 if (verbosity >= G4VisManager::confirmations) {
00905 G4cout << "Lights direction set to "
00906 << vp.GetLightpointDirection() << G4endl;
00907 }
00908 }
00909
00910 else if (command == fpCommandLightsVector) {
00911 fLightsVector = G4UIcommand::ConvertTo3Vector(newValue);
00912 vp.SetLightpointDirection(fLightsVector);
00913 if (verbosity >= G4VisManager::confirmations) {
00914 G4cout << "Lights direction set to "
00915 << vp.GetLightpointDirection() << G4endl;
00916 }
00917 }
00918
00919 else if (command == fpCommandLineSegments) {
00920 G4int nSides = G4UIcommand::ConvertToInt(newValue);
00921 nSides = vp.SetNoOfSides(nSides);
00922 if (verbosity >= G4VisManager::confirmations) {
00923 G4cout <<
00924 "Number of line segements per circle in polygon approximation is "
00925 << nSides << G4endl;
00926 }
00927 }
00928
00929 else if (command == fpCommandPicking) {
00930 vp.SetPicking(G4UIcommand::ConvertToBool(newValue));
00931 if (verbosity >= G4VisManager::confirmations) {
00932 G4cout << "Picking ";
00933 if (vp.IsPicking()) G4cout << "requested.";
00934 else G4cout << "inhibited.";
00935 G4cout << G4endl;
00936 }
00937 if (verbosity >= G4VisManager::warnings) {
00938 G4cout << "You may need to issue \"/vis/viewer/update\"."
00939 << G4endl;
00940 }
00941 }
00942
00943 else if (command == fpCommandProjection) {
00944 G4double fieldHalfAngle;
00945 const size_t iPos0 = 0;
00946 if (newValue[iPos0] == 'o') {
00947 fieldHalfAngle = 0.;
00948 }
00949 else if (newValue[iPos0] == 'p') {
00950 G4String dummy;
00951 G4String unit;
00952 std::istringstream is (newValue);
00953 is >> dummy >> fieldHalfAngle >> unit;
00954 fieldHalfAngle *= G4UIcommand::ValueOf(unit);
00955 if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
00956 if (verbosity >= G4VisManager::errors) {
00957 G4cout <<
00958 "ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
00959 G4cout << G4endl;
00960 }
00961 return;
00962 }
00963 }
00964 else {
00965 if (verbosity >= G4VisManager::errors) {
00966 G4cout << "ERROR: \"" << newValue << "\" not recognised."
00967 " Looking for 'o' or 'p' first character." << G4endl;
00968 }
00969 return;
00970 }
00971 vp.SetFieldHalfAngle(fieldHalfAngle);
00972 if (verbosity >= G4VisManager::confirmations) {
00973 G4cout << "Projection style of viewer \"" << currentViewer->GetName()
00974 << "\" set to ";
00975 if (fieldHalfAngle == 0.) {
00976 G4cout << "orthogonal.";
00977 }
00978 else {
00979 G4cout << "perspective\n with half angle " << fieldHalfAngle / deg
00980 << " degrees.";
00981 }
00982 G4cout << G4endl;
00983 }
00984 }
00985
00986 else if (command == fpCommandSectionPlane) {
00987 G4String choice, unit;
00988 G4double x, y, z, nx, ny, nz;
00989 std::istringstream is (newValue);
00990 is >> choice >> x >> y >> z >> unit >> nx >> ny >> nz;
00991
00992 G4int iSelector = -1;
00993 if (choice.compareTo("off",G4String::ignoreCase) == 0 ||
00994 !G4UIcommand::ConvertToBool(choice)) iSelector = 0;
00995 if (choice.compareTo("on",G4String::ignoreCase) == 0 ||
00996 G4UIcommand::ConvertToBool(choice)) iSelector = 1;
00997 if (iSelector < 0) {
00998 if (verbosity >= G4VisManager::errors) {
00999 G4cout << "Choice not recognised (on/true or off/false)." << G4endl;
01000 G4cout << "Section drawing is currently: ";
01001 if (vp.IsSection ()) G4cout << "on";
01002 else G4cout << "off";
01003 G4cout << ".\nSection plane is currently: "
01004 << vp.GetSectionPlane ();
01005 G4cout << G4endl;
01006 }
01007 return;
01008 }
01009
01010 G4double F = 1.;
01011
01012 switch (iSelector) {
01013 case 0:
01014 vp.UnsetSectionPlane();
01015 break;
01016 case 1:
01017 F = G4UIcommand::ValueOf(unit);
01018 x *= F; y *= F; z *= F;
01019 vp.SetSectionPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
01020 vp.SetViewpointDirection(G4Normal3D(nx,ny,nz));
01021 break;
01022 }
01023
01024 if (verbosity >= G4VisManager::confirmations) {
01025 G4cout << "Section drawing is now: ";
01026 if (vp.IsSection ()) G4cout << "on";
01027 else G4cout << "off";
01028 G4cout << ".\nSection plane is now: "
01029 << vp.GetSectionPlane ();
01030 G4cout << G4endl;
01031 }
01032 }
01033
01034 else if (command == fpCommandRotationStyle) {
01035 G4ViewParameters::RotationStyle style;
01036 if (newValue == "constrainUpDirection")
01037 style = G4ViewParameters::constrainUpDirection;
01038 else if (newValue == "freeRotation")
01039 style = G4ViewParameters::freeRotation;
01040 else {
01041 if (verbosity >= G4VisManager::errors) {
01042 G4cout << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
01043 }
01044 return;
01045 }
01046 vp.SetRotationStyle(style);
01047 if (verbosity >= G4VisManager::confirmations) {
01048 G4cout << "Rotation style of viewer \"" << currentViewer->GetName()
01049 << "\" set to " << vp.GetRotationStyle()
01050 << G4endl;
01051 }
01052 }
01053
01054 else if (command == fpCommandStyle) {
01055 G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
01056 const size_t iPos0 = 0;
01057 if (newValue[iPos0] == 'w') {
01058 switch (existingStyle) {
01059 case G4ViewParameters::wireframe:
01060 break;
01061 case G4ViewParameters::hlr:
01062 break;
01063 case G4ViewParameters::hsr:
01064 vp.SetDrawingStyle(G4ViewParameters::wireframe);
01065 break;
01066 case G4ViewParameters::hlhsr:
01067 vp.SetDrawingStyle(G4ViewParameters::hlr);
01068 break;
01069 }
01070 }
01071 else if (newValue[iPos0] == 's') {
01072 switch (existingStyle) {
01073 case G4ViewParameters::wireframe:
01074 vp.SetDrawingStyle(G4ViewParameters::hsr);
01075 break;
01076 case G4ViewParameters::hlr:
01077 vp.SetDrawingStyle(G4ViewParameters::hlhsr);
01078 break;
01079 case G4ViewParameters::hsr:
01080 break;
01081 case G4ViewParameters::hlhsr:
01082 break;
01083 }
01084 }
01085 else {
01086 if (verbosity >= G4VisManager::errors) {
01087 G4cout << "ERROR: \"" << newValue << "\" not recognised."
01088 " Looking for 'w' or 's' first character." << G4endl;
01089 }
01090 return;
01091 }
01092 if (verbosity >= G4VisManager::confirmations) {
01093 G4cout << "Drawing style of viewer \"" << currentViewer->GetName()
01094 << "\" set to " << vp.GetDrawingStyle()
01095 << G4endl;
01096 }
01097 }
01098
01099 else if (command == fpCommandTargetPoint) {
01100 G4ThreeVector targetPoint =
01101 fpCommandTargetPoint->GetNew3VectorValue(newValue);
01102 const G4Point3D& standardTargetPoint =
01103 currentViewer->GetSceneHandler()->GetScene()->GetStandardTargetPoint();
01104 vp.SetCurrentTargetPoint(targetPoint - standardTargetPoint);
01105 if (verbosity >= G4VisManager::confirmations) {
01106 G4cout << "Target point set to "
01107 << fpCommandTargetPoint->ConvertToStringWithBestUnit
01108 (targetPoint)
01109 << "\n\"Current Target Point\" set to "
01110 << fpCommandTargetPoint->ConvertToStringWithBestUnit
01111 (vp.GetCurrentTargetPoint())
01112 << "\n\"Standard Target Point\" is "
01113 << fpCommandTargetPoint->ConvertToStringWithBestUnit
01114 (standardTargetPoint)
01115 << G4endl;
01116 }
01117 }
01118
01119 else if (command == fpCommandUpThetaPhi) {
01120 G4double theta, phi;
01121 ConvertToDoublePair(newValue, theta, phi);
01122 G4double x = std::sin (theta) * std::cos (phi);
01123 G4double y = std::sin (theta) * std::sin (phi);
01124 G4double z = std::cos (theta);
01125 fUpVector = G4ThreeVector (x, y, z);
01126 vp.SetUpVector(fUpVector);
01127 if (verbosity >= G4VisManager::confirmations) {
01128 G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
01129 }
01130 }
01131
01132 else if (command == fpCommandUpVector) {
01133 fUpVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
01134 vp.SetUpVector(fUpVector);
01135 if (verbosity >= G4VisManager::confirmations) {
01136 G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
01137 }
01138 }
01139
01140 else if (command == fpCommandViewpointThetaPhi) {
01141 G4double theta, phi;
01142 ConvertToDoublePair(newValue, theta, phi);
01143 G4double x = std::sin (theta) * std::cos (phi);
01144 G4double y = std::sin (theta) * std::sin (phi);
01145 G4double z = std::cos (theta);
01146 fViewpointVector = G4ThreeVector (x, y, z);
01147 vp.SetViewAndLights(fViewpointVector);
01148 if (verbosity >= G4VisManager::confirmations) {
01149 G4cout << "Viewpoint direction set to "
01150 << vp.GetViewpointDirection() << G4endl;
01151 if (vp.GetLightsMoveWithCamera ()) {
01152 G4cout << "Lightpoint direction set to "
01153 << vp.GetActualLightpointDirection () << G4endl;
01154 }
01155 }
01156 }
01157
01158 else if (command == fpCommandViewpointVector) {
01159 fViewpointVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
01160 vp.SetViewAndLights(fViewpointVector);
01161 if (verbosity >= G4VisManager::confirmations) {
01162 G4cout << "Viewpoint direction set to "
01163 << vp.GetViewpointDirection() << G4endl;
01164 if (vp.GetLightsMoveWithCamera ()) {
01165 G4cout << "Lightpoint direction set to "
01166 << vp.GetActualLightpointDirection () << G4endl;
01167 }
01168 }
01169 }
01170
01171 else {
01172 if (verbosity >= G4VisManager::errors) {
01173 G4cout <<
01174 "ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
01175 << G4endl;
01176 }
01177 return;
01178 }
01179
01180 SetViewParameters(currentViewer,vp);
01181 }