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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/management/src/G4VisCommandsTouchableSet.cc (Version 11.3.0) and /visualization/management/src/G4VisCommandsTouchableSet.cc (Version 1.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27                                                   
 28 // /vis/touchable/set commands - John Allison     
 29                                                   
 30 #include "G4VisCommandsTouchableSet.hh"           
 31                                                   
 32 #include "G4UImanager.hh"                         
 33 #include "G4UIcommand.hh"                         
 34 #include "G4UIcmdWithABool.hh"                    
 35 #include "G4UIcmdWithADouble.hh"                  
 36 #include "G4UIcmdWithAnInteger.hh"                
 37 #include "G4UIcmdWithAString.hh"                  
 38                                                   
 39 #include <sstream>                                
 40                                                   
 41 #define G4warn G4cout                             
 42                                                   
 43 ////////////// /vis/touchable/set/colour /////    
 44                                                   
 45 G4VisCommandsTouchableSet::G4VisCommandsToucha    
 46 {                                                 
 47   G4bool omitable;                                
 48   G4UIparameter* parameter;                       
 49                                                   
 50   fpCommandSetColour = new G4UIcommand            
 51   ("/vis/touchable/set/colour", this);            
 52   fpCommandSetColour->SetGuidance("Set colour     
 53   fpCommandSetColour->SetGuidance                 
 54   ("Use \"/vis/set/touchable\" to set current     
 55   fpCommandSetColour->SetGuidance(ConvertToCol    
 56   parameter = new G4UIparameter("red", 's', om    
 57   parameter->SetDefaultValue("1.");               
 58   fpCommandSetColour->SetParameter(parameter);    
 59   parameter = new G4UIparameter("green", 'd',     
 60   parameter->SetDefaultValue(1.);                 
 61   fpCommandSetColour->SetParameter(parameter);    
 62   parameter = new G4UIparameter("blue", 'd', o    
 63   parameter->SetDefaultValue(1.);                 
 64   fpCommandSetColour->SetParameter(parameter);    
 65   parameter = new G4UIparameter("opacity", 'd'    
 66   parameter->SetDefaultValue(1.);                 
 67   fpCommandSetColour->SetParameter(parameter);    
 68                                                   
 69   fpCommandSetDaughtersInvisible = new G4UIcmd    
 70   ("/vis/touchable/set/daughtersInvisible", th    
 71   fpCommandSetDaughtersInvisible->SetGuidance     
 72   ("Daughters of current touchable invisible:     
 73   fpCommandSetDaughtersInvisible->SetGuidance     
 74   ("Use \"/vis/set/touchable\" to set current     
 75   fpCommandSetDaughtersInvisible->SetParameter    
 76   fpCommandSetDaughtersInvisible->SetDefaultVa    
 77                                                   
 78   fpCommandSetForceAuxEdgeVisible = new G4UIcm    
 79   ("/vis/touchable/set/forceAuxEdgeVisible", t    
 80   fpCommandSetForceAuxEdgeVisible->SetGuidance    
 81     ("Force auxiliary (soft) edges of current     
 82   fpCommandSetForceAuxEdgeVisible->SetGuidance    
 83   ("Use \"/vis/set/touchable\" to set current     
 84   fpCommandSetForceAuxEdgeVisible->SetParamete    
 85   fpCommandSetForceAuxEdgeVisible->SetDefaultV    
 86                                                   
 87   fpCommandSetForceCloud = new G4UIcmdWithABoo    
 88   ("/vis/touchable/set/forceCloud", this);        
 89   fpCommandSetForceCloud->SetGuidance             
 90   ("Force current touchable always to be drawn    
 91   fpCommandSetForceCloud->SetGuidance             
 92   ("Use \"/vis/set/touchable\" to set current     
 93   fpCommandSetForceCloud->SetParameterName("fo    
 94   fpCommandSetForceCloud->SetDefaultValue(true    
 95                                                   
 96   fpCommandSetForceSolid = new G4UIcmdWithABoo    
 97   ("/vis/touchable/set/forceSolid", this);        
 98   fpCommandSetForceSolid->SetGuidance             
 99   ("Force current touchable always to be drawn    
100   fpCommandSetForceSolid->SetGuidance             
101   ("Use \"/vis/set/touchable\" to set current     
102   fpCommandSetForceSolid->SetParameterName("fo    
103   fpCommandSetForceSolid->SetDefaultValue(true    
104                                                   
105   fpCommandSetForceWireframe = new G4UIcmdWith    
106   ("/vis/touchable/set/forceWireframe", this);    
107   fpCommandSetForceWireframe->SetGuidance         
108   ("Force current touchable always to be drawn    
109   fpCommandSetForceWireframe->SetGuidance         
110   ("Use \"/vis/set/touchable\" to set current     
111   fpCommandSetForceWireframe->SetParameterName    
112   fpCommandSetForceWireframe->SetDefaultValue(    
113                                                   
114   fpCommandSetLineSegmentsPerCircle = new G4UI    
115   ("/vis/touchable/set/lineSegmentsPerCircle",    
116   fpCommandSetLineSegmentsPerCircle->SetGuidan    
117     ("For current touchable, set number of lin    
118      "\nprecision with which a curved line or     
119      "\npolygon or polyhedron, regardless of t    
120      "\nNegative to pick up G4Polyhedron defau    
121   fpCommandSetLineSegmentsPerCircle->SetGuidan    
122   ("Use \"/vis/set/touchable\" to set current     
123   fpCommandSetLineSegmentsPerCircle->SetParame    
124   fpCommandSetLineSegmentsPerCircle->SetDefaul    
125                                                   
126   fpCommandSetLineStyle = new G4UIcmdWithAStri    
127   ("/vis/touchable/set/lineStyle", this);         
128   fpCommandSetLineStyle->SetGuidance("Set line    
129   fpCommandSetLineStyle->SetGuidance              
130   ("Use \"/vis/set/touchable\" to set current     
131   fpCommandSetLineStyle->SetParameterName("lin    
132   fpCommandSetLineStyle->SetCandidates("unbrok    
133   fpCommandSetLineStyle->SetDefaultValue("unbr    
134                                                   
135   fpCommandSetLineWidth = new G4UIcmdWithADoub    
136   ("/vis/touchable/set/lineWidth", this);         
137   fpCommandSetLineWidth->SetGuidance("Set line    
138   fpCommandSetLineWidth->SetGuidance              
139   ("Use \"/vis/set/touchable\" to set current     
140   fpCommandSetLineWidth->SetParameterName("lin    
141   fpCommandSetLineWidth->SetDefaultValue(1.);     
142                                                   
143   fpCommandSetNumberOfCloudPoints = new G4UIcm    
144   ("/vis/touchable/set/numberOfCloudPoints", t    
145   fpCommandSetNumberOfCloudPoints->SetGuidance    
146   ("For current touchable, set number of cloud    
147    "\n<= 0 means under control of viewer.");      
148   fpCommandSetNumberOfCloudPoints->SetGuidance    
149   ("Use \"/vis/set/touchable\" to set current     
150   fpCommandSetNumberOfCloudPoints->SetParamete    
151   fpCommandSetNumberOfCloudPoints->SetDefaultV    
152                                                   
153   fpCommandSetVisibility = new G4UIcmdWithABoo    
154   ("/vis/touchable/set/visibility", this);        
155   fpCommandSetVisibility->SetGuidance             
156   ("Set visibility of current touchable: true/    
157   fpCommandSetVisibility->SetGuidance             
158   ("Use \"/vis/set/touchable\" to set current     
159   fpCommandSetVisibility->SetParameterName("vi    
160   fpCommandSetVisibility->SetDefaultValue(true    
161 }                                                 
162                                                   
163 G4VisCommandsTouchableSet::~G4VisCommandsTouch    
164   delete fpCommandSetVisibility;                  
165   delete fpCommandSetNumberOfCloudPoints;         
166   delete fpCommandSetLineWidth;                   
167   delete fpCommandSetLineStyle;                   
168   delete fpCommandSetForceWireframe;              
169   delete fpCommandSetForceSolid;                  
170   delete fpCommandSetForceCloud;                  
171   delete fpCommandSetLineSegmentsPerCircle;       
172   delete fpCommandSetForceAuxEdgeVisible;         
173   delete fpCommandSetDaughtersInvisible;          
174   delete fpCommandSetColour;                      
175 }                                                 
176                                                   
177 G4String G4VisCommandsTouchableSet::GetCurrent    
178   return "";                                      
179 }                                                 
180                                                   
181 void G4VisCommandsTouchableSet::SetNewValue       
182 (G4UIcommand* command,G4String newValue)          
183 {                                                 
184   G4VisManager::Verbosity verbosity = fpVisMan    
185                                                   
186   G4VViewer* currentViewer = fpVisManager->Get    
187   if (!currentViewer) {                           
188     if (verbosity >= G4VisManager::errors) {      
189       G4warn <<                                   
190       "ERROR: G4VisCommandsTouchableSet::SetNe    
191       << G4endl;                                  
192     }                                             
193     return;                                       
194   }                                               
195                                                   
196   G4ViewParameters workingVP = currentViewer->    
197   G4VisAttributes workingVisAtts;                 
198                                                   
199   if (command == fpCommandSetColour)              
200   {                                               
201     G4String redOrString;                         
202     G4double green, blue, opacity;                
203     std::istringstream iss(newValue);             
204     iss >> redOrString >> green >> blue >> opa    
205     G4Colour colour(1,1,1,1);  // Default whit    
206     ConvertToColour(colour, redOrString, green    
207     workingVisAtts.SetColour(colour);             
208     workingVP.AddVisAttributesModifier            
209     (G4ModelingParameters::VisAttributesModifi    
210      (workingVisAtts,                             
211       G4ModelingParameters::VASColour,            
212       fCurrentTouchableProperties.fTouchablePa    
213   }                                               
214                                                   
215   else if (command == fpCommandSetDaughtersInv    
216     workingVisAtts.SetDaughtersInvisible(G4UIc    
217     workingVP.AddVisAttributesModifier            
218     (G4ModelingParameters::VisAttributesModifi    
219      (workingVisAtts,                             
220       G4ModelingParameters::VASDaughtersInvisi    
221       fCurrentTouchableProperties.fTouchablePa    
222   }                                               
223                                                   
224   else if (command == fpCommandSetForceAuxEdge    
225     workingVisAtts.SetForceAuxEdgeVisible(G4UI    
226     workingVP.AddVisAttributesModifier            
227     (G4ModelingParameters::VisAttributesModifi    
228      (workingVisAtts,                             
229       G4ModelingParameters::VASForceAuxEdgeVis    
230       fCurrentTouchableProperties.fTouchablePa    
231   }                                               
232                                                   
233   else if (command == fpCommandSetLineSegments    
234     workingVisAtts.SetForceLineSegmentsPerCirc    
235     (G4UIcommand::ConvertToInt(newValue));        
236     workingVP.AddVisAttributesModifier            
237     (G4ModelingParameters::VisAttributesModifi    
238      (workingVisAtts,                             
239       G4ModelingParameters::VASForceLineSegmen    
240       fCurrentTouchableProperties.fTouchablePa    
241   }                                               
242                                                   
243   else if (command == fpCommandSetForceCloud)     
244     workingVisAtts.SetForceCloud(G4UIcommand::    
245     workingVP.AddVisAttributesModifier            
246     (G4ModelingParameters::VisAttributesModifi    
247      (workingVisAtts,                             
248       G4ModelingParameters::VASForceCloud,        
249       fCurrentTouchableProperties.fTouchablePa    
250   }                                               
251                                                   
252   else if (command == fpCommandSetForceSolid)     
253     workingVisAtts.SetForceSolid(G4UIcommand::    
254     workingVP.AddVisAttributesModifier            
255     (G4ModelingParameters::VisAttributesModifi    
256      (workingVisAtts,                             
257       G4ModelingParameters::VASForceSolid,        
258       fCurrentTouchableProperties.fTouchablePa    
259   }                                               
260                                                   
261   else if (command == fpCommandSetForceWirefra    
262     workingVisAtts.SetForceWireframe(G4UIcomma    
263     workingVP.AddVisAttributesModifier            
264     (G4ModelingParameters::VisAttributesModifi    
265      (workingVisAtts,                             
266       G4ModelingParameters::VASForceWireframe,    
267       fCurrentTouchableProperties.fTouchablePa    
268   }                                               
269                                                   
270   else if (command == fpCommandSetLineStyle) {    
271     G4VisAttributes::LineStyle lineStyle = G4V    
272     if (newValue == "dashed") {                   
273       lineStyle = G4VisAttributes::dashed;        
274     } else if (newValue == "dotted") {            
275       lineStyle = G4VisAttributes::dotted;        
276     }                                             
277     // All other values are "unbroken".           
278     workingVisAtts.SetLineStyle(lineStyle);       
279     workingVP.AddVisAttributesModifier            
280     (G4ModelingParameters::VisAttributesModifi    
281      (workingVisAtts,                             
282       G4ModelingParameters::VASLineStyle,         
283       fCurrentTouchableProperties.fTouchablePa    
284   }                                               
285                                                   
286   else if (command == fpCommandSetLineWidth) {    
287     workingVisAtts.SetLineWidth(G4UIcommand::C    
288     workingVP.AddVisAttributesModifier            
289     (G4ModelingParameters::VisAttributesModifi    
290      (workingVisAtts,                             
291       G4ModelingParameters::VASLineWidth,         
292       fCurrentTouchableProperties.fTouchablePa    
293   }                                               
294                                                   
295   else if (command == fpCommandSetNumberOfClou    
296     workingVisAtts.SetForceNumberOfCloudPoints    
297     (G4UIcommand::ConvertToInt(newValue));        
298     workingVP.AddVisAttributesModifier            
299     (G4ModelingParameters::VisAttributesModifi    
300      (workingVisAtts,                             
301       G4ModelingParameters::VASForceNumberOfCl    
302       fCurrentTouchableProperties.fTouchablePa    
303   }                                               
304                                                   
305   else if (command == fpCommandSetVisibility)     
306     workingVisAtts.SetVisibility(G4UIcommand::    
307     workingVP.AddVisAttributesModifier            
308     (G4ModelingParameters::VisAttributesModifi    
309      (workingVisAtts,                             
310       G4ModelingParameters::VASVisibility,        
311       fCurrentTouchableProperties.fTouchablePa    
312     if (verbosity >= G4VisManager::warnings) {    
313       static G4bool first = true;                 
314       if (first) {                                
315         first = false;                            
316         G4warn << "WARNING: If \"/vis/touchabl    
317         "\n  work, check that opacity (4th com    
318         G4warn << "ALSO: The volume must be in    
319         "\n  not in the \"base path\". E.g., i    
320         "\n    /vis/drawVolume volume-name"       
321         "\n  there is no way to make a parent     
322         "\n  explicitly adding the parent:"       
323         "\n    /vis/scene/add/volume parent-na    
324       }                                           
325     }                                             
326   }                                               
327                                                   
328   else {                                          
329     if (verbosity >= G4VisManager::errors) {      
330       G4warn <<                                   
331       "ERROR: G4VisCommandsTouchableSet::SetNe    
332       << G4endl;                                  
333     }                                             
334     return;                                       
335   }                                               
336                                                   
337   SetViewParameters(currentViewer,workingVP);     
338                                                   
339   // To update all views                          
340   G4UImanager::GetUIpointer()->ApplyCommand("/    
341 }                                                 
342