Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VisCommandsTouchableSet.cc
이 파일의 문서화 페이지로 가기
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: G4VisCommandsTouchableSet.cc 104163 2017-05-15 06:52:42Z gcosmo $
28 
29 // /vis/touchable/set commands - John Allison 8th October 2012
30 
32 
33 #include "G4UImanager.hh"
34 #include "G4UIcommand.hh"
35 #include "G4UIcmdWithABool.hh"
36 #include "G4UIcmdWithADouble.hh"
37 #include "G4UIcmdWithAnInteger.hh"
38 #include "G4UIcmdWithAString.hh"
39 
40 #include <sstream>
41 
43 
45 {
46  G4bool omitable;
47  G4UIparameter* parameter;
48 
50  ("/vis/touchable/set/colour", this);
51  fpCommandSetColour->SetGuidance("Set colour of current touchable.");
53  ("Use \"/vis/set/touchable\" to set current touchable.");
55  parameter = new G4UIparameter("red", 's', omitable = true);
56  parameter->SetDefaultValue("1.");
57  fpCommandSetColour->SetParameter(parameter);
58  parameter = new G4UIparameter("green", 'd', omitable = true);
59  parameter->SetDefaultValue(1.);
60  fpCommandSetColour->SetParameter(parameter);
61  parameter = new G4UIparameter("blue", 'd', omitable = true);
62  parameter->SetDefaultValue(1.);
63  fpCommandSetColour->SetParameter(parameter);
64  parameter = new G4UIparameter("opacity", 'd', omitable = true);
65  parameter->SetDefaultValue(1.);
66  fpCommandSetColour->SetParameter(parameter);
67 
69  ("/vis/touchable/set/daughtersInvisible", this);
71  ("Daughters of current touchable invisible: true/false.");
73  ("Use \"/vis/set/touchable\" to set current touchable.");
74  fpCommandSetDaughtersInvisible->SetParameterName("daughtersInvisible", omitable = true);
76 
78  ("/vis/touchable/set/forceAuxEdgeVisible", this);
80  ("Force auxiliary (soft) edges of current touchable to be visible: true/false.");
82  ("Use \"/vis/set/touchable\" to set current touchable.");
83  fpCommandSetForceAuxEdgeVisible->SetParameterName("forceAuxEdgeVisible", omitable = true);
85 
87  ("/vis/touchable/set/lineSegmentsPerCircle", this);
89  ("For current touchable, set number of line segments per circle, the"
90  "\nprecision with which a curved line or surface is represented by a"
91  "\npolygon or polyhedron, regardless of the view parameters."
92  "\nNegative to pick up G4Polyhedron default value.");
94  ("Use \"/vis/set/touchable\" to set current touchable.");
95  fpCommandSetLineSegmentsPerCircle->SetParameterName("lineSegmentsPerCircle", omitable = true);
97 
99  ("/vis/touchable/set/forceSolid", this);
101  ("Force current touchable always to be drawn solid (surface drawing).");
103  ("Use \"/vis/set/touchable\" to set current touchable.");
104  fpCommandSetForceSolid->SetParameterName("forceSolid", omitable = true);
106 
108  ("/vis/touchable/set/forceWireframe", this);
110  ("Force current touchable always to be drawn as wireframe.");
112  ("Use \"/vis/set/touchable\" to set current touchable.");
113  fpCommandSetForceWireframe->SetParameterName("forceWireframe", omitable = true);
115 
117  ("/vis/touchable/set/lineStyle", this);
118  fpCommandSetLineStyle->SetGuidance("Set line style of current touchable drawing.");
120  ("Use \"/vis/set/touchable\" to set current touchable.");
121  fpCommandSetLineStyle->SetParameterName("lineStyle", omitable = true);
122  fpCommandSetLineStyle->SetCandidates("unbroken dashed dotted");
124 
126  ("/vis/touchable/set/lineWidth", this);
127  fpCommandSetLineWidth->SetGuidance("Set line width of current touchable.");
129  ("Use \"/vis/set/touchable\" to set current touchable.");
130  fpCommandSetLineWidth->SetParameterName("lineWidth", omitable = true);
132 
134  ("/vis/touchable/set/visibility", this);
136  ("Set visibility of current touchable: true/false.");
138  ("Use \"/vis/set/touchable\" to set current touchable.");
139  fpCommandSetVisibility->SetParameterName("visibility", omitable = true);
141 }
142 
144  delete fpCommandSetVisibility;
145  delete fpCommandSetLineWidth;
146  delete fpCommandSetLineStyle;
148  delete fpCommandSetForceSolid;
152  delete fpCommandSetColour;
153 }
154 
156  return "";
157 }
158 
160 (G4UIcommand* command,G4String newValue)
161 {
162  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
163 
164  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
165  if (!currentViewer) {
166  if (verbosity >= G4VisManager::errors) {
167  G4cerr <<
168  "ERROR: G4VisCommandsTouchableSet::SetNewValue: no current viewer."
169  << G4endl;
170  }
171  return;
172  }
173 
174  G4ViewParameters workingVP = currentViewer->GetViewParameters();
175  G4VisAttributes workingVisAtts;
176 
177  if (command == fpCommandSetColour)
178  {
179  G4String redOrString;
180  G4double green, blue, opacity;
181  std::istringstream iss(newValue);
182  iss >> redOrString >> green >> blue >> opacity;
183  G4Colour colour(1,1,1,1); // Default white and opaque.
184  ConvertToColour(colour, redOrString, green, blue, opacity);
185  workingVisAtts.SetColour(colour);
186  workingVP.AddVisAttributesModifier
188  (workingVisAtts,
190  fCurrentTouchablePath));
191  }
192 
193  else if (command == fpCommandSetDaughtersInvisible) {
194  workingVisAtts.SetDaughtersInvisible(G4UIcommand::ConvertToBool(newValue));
195  workingVP.AddVisAttributesModifier
197  (workingVisAtts,
199  fCurrentTouchablePath));
200  }
201 
202  else if (command == fpCommandSetForceAuxEdgeVisible) {
203  workingVisAtts.SetForceAuxEdgeVisible(G4UIcommand::ConvertToBool(newValue));
204  workingVP.AddVisAttributesModifier
206  (workingVisAtts,
208  fCurrentTouchablePath));
209  }
210 
211  else if (command == fpCommandSetLineSegmentsPerCircle) {
212  workingVisAtts.SetForceLineSegmentsPerCircle
213  (G4UIcommand::ConvertToInt(newValue));
214  workingVP.AddVisAttributesModifier
216  (workingVisAtts,
218  fCurrentTouchablePath));
219  }
220 
221  else if (command == fpCommandSetForceSolid) {
222  workingVisAtts.SetForceSolid(G4UIcommand::ConvertToBool(newValue));
223  workingVP.AddVisAttributesModifier
225  (workingVisAtts,
227  fCurrentTouchablePath));
228  }
229 
230  else if (command == fpCommandSetForceWireframe) {
231  workingVisAtts.SetForceWireframe(G4UIcommand::ConvertToBool(newValue));
232  workingVP.AddVisAttributesModifier
234  (workingVisAtts,
236  fCurrentTouchablePath));
237  }
238 
239  else if (command == fpCommandSetLineStyle) {
241  if (newValue == "dashed") {
242  lineStyle = G4VisAttributes::dashed;
243  } else if (newValue == "dotted") {
244  lineStyle = G4VisAttributes::dotted;
245  }
246  // All other values are "unbroken".
247  workingVisAtts.SetLineStyle(lineStyle);
248  workingVP.AddVisAttributesModifier
250  (workingVisAtts,
252  fCurrentTouchablePath));
253  }
254 
255  else if (command == fpCommandSetLineWidth) {
256  workingVisAtts.SetLineWidth(G4UIcommand::ConvertToDouble(newValue));
257  workingVP.AddVisAttributesModifier
259  (workingVisAtts,
261  fCurrentTouchablePath));
262  }
263 
264  else if (command == fpCommandSetVisibility) {
265  workingVisAtts.SetVisibility(G4UIcommand::ConvertToBool(newValue));
266  workingVP.AddVisAttributesModifier
268  (workingVisAtts,
270  fCurrentTouchablePath));
271  }
272 
273  else {
274  if (verbosity >= G4VisManager::errors) {
275  G4cerr <<
276  "ERROR: G4VisCommandsTouchableSet::SetNewValue: unrecognised command."
277  << G4endl;
278  }
279  return;
280  }
281 
282  SetViewParameters(currentViewer,workingVP);
283 
284  // To update all views
285  G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
286 }
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetForceAuxEdgeVisible(G4bool=true)
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:457
void SetLineStyle(LineStyle)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void SetDefaultValue(G4bool defVal)
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
G4UIcmdWithABool * fpCommandSetDaughtersInvisible
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:439
G4UIcmdWithAString * fpCommandSetLineStyle
const G4ViewParameters & GetViewParameters() const
void SetDefaultValue(const char *defVal)
Definition: test07.cc:36
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:449
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetDefaultValue(const char *theDefaultValue)
void SetForceLineSegmentsPerCircle(G4int nSegments)
G4UIcmdWithABool * fpCommandSetForceAuxEdgeVisible
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithADouble * fpCommandSetLineWidth
G4UIcmdWithAnInteger * fpCommandSetLineSegmentsPerCircle
void SetCandidates(const char *candidateList)
const G4String & ConvertToColourGuidance()
G4GLOB_DLL std::ostream G4cerr
void SetForceSolid(G4bool=true)
void SetVisibility(G4bool=true)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4double defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDaughtersInvisible(G4bool=true)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
void SetLineWidth(G4double)
void SetColour(const G4Colour &)
void SetForceWireframe(G4bool=true)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithABool * fpCommandSetForceWireframe
void SetNewValue(G4UIcommand *command, G4String newValue)