Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VisCommandsTouchableSet Class Reference

#include <G4VisCommandsTouchableSet.hh>

Inheritance diagram for G4VisCommandsTouchableSet:
Collaboration diagram for G4VisCommandsTouchableSet:

Public Member Functions

 G4VisCommandsTouchableSet ()
 
virtual ~G4VisCommandsTouchableSet ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandViewer
 G4VVisCommandViewer ()
 
virtual ~G4VVisCommandViewer ()
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
static const G4ColourGetCurrentColour ()
 
static G4double GetCurrentLineWidth ()
 
static const G4ColourGetCurrentTextColour ()
 
static G4Text::Layout GetCurrentTextLayout ()
 
static G4double GetCurrentTextSize ()
 
- Protected Member Functions inherited from G4VVisCommandViewer
void SetViewParameters (G4VViewer *, const G4ViewParameters &)
 
void RefreshIfRequired (G4VViewer *)
 
- Protected Member Functions inherited from G4VVisCommand
void UpdateVisManagerScene (const G4String &sceneName="")
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static void ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fErrorCode = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static
G4ModelingParameters::PVNameCopyNoPath 
fCurrentTouchablePath
 

Detailed Description

Definition at line 42 of file G4VisCommandsTouchableSet.hh.

Constructor & Destructor Documentation

G4VisCommandsTouchableSet::G4VisCommandsTouchableSet ( )

Definition at line 45 of file G4VisCommandsTouchableSet.cc.

46 {
47  G4bool omitable;
48  G4UIparameter* parameter;
49 
50  fpCommandSetColour = new G4UIcommand
51  ("/vis/touchable/set/colour", this);
52  fpCommandSetColour->SetGuidance("Set colour of current touchable.");
53  fpCommandSetColour->SetGuidance
54  ("Use \"/vis/set/touchable\" to set current touchable.");
55  fpCommandSetColour->SetGuidance
56  ("If \"red\" is a string understood by the vis system it will be taken."
57  "\n Otherwise the values of \red\", \"green\", etc., are used.");
58  parameter = new G4UIparameter("red", 's', omitable = true);
59  parameter->SetDefaultValue("1.");
60  fpCommandSetColour->SetParameter(parameter);
61  parameter = new G4UIparameter("green", 'd', omitable = true);
62  parameter->SetDefaultValue(1.);
63  fpCommandSetColour->SetParameter(parameter);
64  parameter = new G4UIparameter("blue", 'd', omitable = true);
65  parameter->SetDefaultValue(1.);
66  fpCommandSetColour->SetParameter(parameter);
67  parameter = new G4UIparameter("opacity", 'd', omitable = true);
68  parameter->SetDefaultValue(1.);
69  fpCommandSetColour->SetParameter(parameter);
70 
71  fpCommandSetDaughtersInvisible = new G4UIcmdWithABool
72  ("/vis/touchable/set/daughtersInvisible", this);
73  fpCommandSetDaughtersInvisible->SetGuidance
74  ("Daughters of current touchable invisible: true/false.");
75  fpCommandSetDaughtersInvisible->SetGuidance
76  ("Use \"/vis/set/touchable\" to set current touchable.");
77  fpCommandSetDaughtersInvisible->SetParameterName("daughtersInvisible", omitable = true);
78  fpCommandSetDaughtersInvisible->SetDefaultValue(true);
79 
80  fpCommandSetForceAuxEdgeVisible = new G4UIcmdWithABool
81  ("/vis/touchable/set/forceAuxEdgeVisible", this);
82  fpCommandSetForceAuxEdgeVisible->SetGuidance
83  ("Force auxiliary (soft) edges of current touchable to be visible: true/false.");
84  fpCommandSetForceAuxEdgeVisible->SetGuidance
85  ("Use \"/vis/set/touchable\" to set current touchable.");
86  fpCommandSetForceAuxEdgeVisible->SetParameterName("forceAuxEdgeVisible", omitable = true);
87  fpCommandSetForceAuxEdgeVisible->SetDefaultValue(true);
88 
89  fpCommandSetLineSegmentsPerCircle = new G4UIcmdWithAnInteger
90  ("/vis/touchable/set/lineSegmentsPerCircle", this);
91  fpCommandSetLineSegmentsPerCircle->SetGuidance
92  ("For current touchable, set number of line segments per circle, the"
93  "\nprecision with which a curved line or surface is represented by a"
94  "\npolygon or polyhedron, regardless of the view parameters."
95  "\nNegative to pick up G4Polyhedron default value.");
96  fpCommandSetLineSegmentsPerCircle->SetGuidance
97  ("Use \"/vis/set/touchable\" to set current touchable.");
98  fpCommandSetLineSegmentsPerCircle->SetParameterName("lineSegmentsPerCircle", omitable = true);
99  fpCommandSetLineSegmentsPerCircle->SetDefaultValue(0);
100 
101  fpCommandSetForceSolid = new G4UIcmdWithABool
102  ("/vis/touchable/set/forceSolid", this);
103  fpCommandSetForceSolid->SetGuidance
104  ("Force current touchable always to be drawn solid (surface drawing).");
105  fpCommandSetForceSolid->SetGuidance
106  ("Use \"/vis/set/touchable\" to set current touchable.");
107  fpCommandSetForceSolid->SetParameterName("forceSolid", omitable = true);
108  fpCommandSetForceSolid->SetDefaultValue(true);
109 
110  fpCommandSetForceWireframe = new G4UIcmdWithABool
111  ("/vis/touchable/set/forceWireframe", this);
112  fpCommandSetForceWireframe->SetGuidance
113  ("Force current touchable always to be drawn as wireframe.");
114  fpCommandSetForceWireframe->SetGuidance
115  ("Use \"/vis/set/touchable\" to set current touchable.");
116  fpCommandSetForceWireframe->SetParameterName("forceWireframe", omitable = true);
117  fpCommandSetForceWireframe->SetDefaultValue(true);
118 
119  fpCommandSetLineStyle = new G4UIcmdWithAString
120  ("/vis/touchable/set/lineStyle", this);
121  fpCommandSetLineStyle->SetGuidance("Set line style of current touchable drawing.");
122  fpCommandSetLineStyle->SetGuidance
123  ("Use \"/vis/set/touchable\" to set current touchable.");
124  fpCommandSetLineStyle->SetParameterName("lineStyle", omitable = true);
125  fpCommandSetLineStyle->SetCandidates("unbroken dashed dotted");
126  fpCommandSetLineStyle->SetDefaultValue("unbroken");
127 
128  fpCommandSetLineWidth = new G4UIcmdWithADouble
129  ("/vis/touchable/set/lineWidth", this);
130  fpCommandSetLineWidth->SetGuidance("Set line width of current touchable.");
131  fpCommandSetLineWidth->SetGuidance
132  ("Use \"/vis/set/touchable\" to set current touchable.");
133  fpCommandSetLineWidth->SetParameterName("lineWidth", omitable = true);
134  fpCommandSetLineWidth->SetDefaultValue(1.);
135 
136  fpCommandSetVisibility = new G4UIcmdWithABool
137  ("/vis/touchable/set/visibility", this);
138  fpCommandSetVisibility->SetGuidance
139  ("Set visibility of current touchable: true/false.");
140  fpCommandSetVisibility->SetGuidance
141  ("Use \"/vis/set/touchable\" to set current touchable.");
142  fpCommandSetVisibility->SetParameterName("visibility", omitable = true);
143  fpCommandSetVisibility->SetDefaultValue(true);
144 }
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *theDefaultValue)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
bool G4bool
Definition: G4Types.hh:79
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4double defVal)
void SetCandidates(const char *candidateList)
void SetDefaultValue(G4int defVal)

Here is the call graph for this function:

G4VisCommandsTouchableSet::~G4VisCommandsTouchableSet ( )
virtual

Definition at line 146 of file G4VisCommandsTouchableSet.cc.

146  {
147  delete fpCommandSetVisibility;
148  delete fpCommandSetLineWidth;
149  delete fpCommandSetLineStyle;
150  delete fpCommandSetForceWireframe;
151  delete fpCommandSetForceSolid;
152  delete fpCommandSetLineSegmentsPerCircle;
153  delete fpCommandSetForceAuxEdgeVisible;
154  delete fpCommandSetDaughtersInvisible;
155  delete fpCommandSetColour;
156 }

Member Function Documentation

G4String G4VisCommandsTouchableSet::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 158 of file G4VisCommandsTouchableSet.cc.

158  {
159  return "";
160 }
void G4VisCommandsTouchableSet::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 163 of file G4VisCommandsTouchableSet.cc.

164 {
166 
167  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
168  if (!currentViewer) {
169  if (verbosity >= G4VisManager::errors) {
170  G4cerr <<
171  "ERROR: G4VisCommandsTouchableSet::SetNewValue: no current viewer."
172  << G4endl;
173  }
174  return;
175  }
176 
177  G4ViewParameters workingVP = currentViewer->GetViewParameters();
178  G4VisAttributes workingVisAtts;
179 
180  if (command == fpCommandSetColour)
181  {
182  G4String redOrString;
183  G4double green, blue, opacity;
184  std::istringstream iss(newValue);
185  iss >> redOrString >> green >> blue >> opacity;
186  G4Colour colour(1,1,1,1); // Default white and opaque.
187  const size_t iPos0 = 0;
188  if (std::isalpha(redOrString[iPos0])) {
189  if (!G4Colour::GetColour(redOrString, colour)) {
191  G4cout << "WARNING: Colour \"" << redOrString
192  << "\" not found. Defaulting to white and opaque."
193  << G4endl;
194  }
195  }
196  } else {
197  colour = G4Colour(G4UIcommand::ConvertToDouble(redOrString), green, blue);
198  }
199  colour = G4Colour
200  (colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
201 
202  workingVisAtts.SetColour(colour);
203  workingVP.AddVisAttributesModifier
205  (workingVisAtts,
208  }
209 
210  else if (command == fpCommandSetDaughtersInvisible) {
211  workingVisAtts.SetDaughtersInvisible(G4UIcommand::ConvertToBool(newValue));
212  workingVP.AddVisAttributesModifier
214  (workingVisAtts,
217  }
218 
219  else if (command == fpCommandSetForceAuxEdgeVisible) {
220  workingVisAtts.SetForceAuxEdgeVisible(G4UIcommand::ConvertToBool(newValue));
221  workingVP.AddVisAttributesModifier
223  (workingVisAtts,
226  }
227 
228  else if (command == fpCommandSetLineSegmentsPerCircle) {
229  workingVisAtts.SetForceLineSegmentsPerCircle
230  (G4UIcommand::ConvertToInt(newValue));
231  workingVP.AddVisAttributesModifier
233  (workingVisAtts,
236  }
237 
238  else if (command == fpCommandSetForceSolid) {
239  workingVisAtts.SetForceSolid(G4UIcommand::ConvertToBool(newValue));
240  workingVP.AddVisAttributesModifier
242  (workingVisAtts,
245  }
246 
247  else if (command == fpCommandSetForceWireframe) {
248  workingVisAtts.SetForceWireframe(G4UIcommand::ConvertToBool(newValue));
249  workingVP.AddVisAttributesModifier
251  (workingVisAtts,
254  }
255 
256  else if (command == fpCommandSetLineStyle) {
258  if (newValue == "dashed") {
259  lineStyle = G4VisAttributes::dashed;
260  } else if (newValue == "dotted") {
261  lineStyle = G4VisAttributes::dotted;
262  }
263  // All other values are "unbroken".
264  workingVisAtts.SetLineStyle(lineStyle);
265  workingVP.AddVisAttributesModifier
267  (workingVisAtts,
270  }
271 
272  else if (command == fpCommandSetLineWidth) {
273  workingVisAtts.SetLineWidth(G4UIcommand::ConvertToDouble(newValue));
274  workingVP.AddVisAttributesModifier
276  (workingVisAtts,
279  }
280 
281  else if (command == fpCommandSetVisibility) {
282  workingVisAtts.SetVisibility(G4UIcommand::ConvertToBool(newValue));
283  workingVP.AddVisAttributesModifier
285  (workingVisAtts,
288  }
289 
290  else {
291  if (verbosity >= G4VisManager::errors) {
292  G4cerr <<
293  "ERROR: G4VisCommandsTouchableSet::SetNewValue: unrecognised command."
294  << G4endl;
295  }
296  return;
297  }
298 
299  SetViewParameters(currentViewer,workingVP);
300 
301  // To update all views
302  G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
303 }
void SetColour(const G4Colour &)
static G4ModelingParameters::PVNameCopyNoPath fCurrentTouchablePath
void SetLineStyle(LineStyle)
void SetLineWidth(G4double)
const G4ViewParameters & GetViewParameters() const
static G4bool GetColour(const G4String &key, G4Colour &result)
Definition: G4Colour.cc:126
void SetViewParameters(G4VViewer *, const G4ViewParameters &)
void SetForceSolid(G4bool=true)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:437
void SetVisibility(G4bool=true)
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:455
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
void SetDaughtersInvisible(G4bool=true)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
void SetForceAuxEdgeVisible(G4bool=true)
G4VViewer * GetCurrentViewer() const
double G4double
Definition: G4Types.hh:76
void SetForceWireframe(G4bool=true)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
G4GLOB_DLL std::ostream G4cerr
void SetForceLineSegmentsPerCircle(G4int nSegments)
static G4VisManager * fpVisManager

Here is the call graph for this function:


The documentation for this class was generated from the following files: