Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VViewer Class Referenceabstract

#include <G4VViewer.hh>

Inheritance diagram for G4VViewer:
Collaboration diagram for G4VViewer:

Classes

class  G4Spline
 

Public Member Functions

 G4VViewer (G4VSceneHandler &, G4int id, const G4String &name="")
 
virtual ~G4VViewer ()
 
virtual void Initialise ()
 
virtual void ResetView ()
 
virtual void SetView ()=0
 
virtual void ClearView ()=0
 
virtual void DrawView ()=0
 
void RefreshView ()
 
virtual void ShowView ()
 
virtual void FinishView ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
const G4StringGetName () const
 
const G4StringGetShortName () const
 
void SetName (const G4String &)
 
G4int GetViewId () const
 
G4VSceneHandlerGetSceneHandler () const
 
const G4ViewParametersGetViewParameters () const
 
const G4ViewParametersGetDefaultViewParameters () const
 
virtual const std::vector
< G4ModelingParameters::VisAttributesModifier > * 
GetPrivateVisAttributesModifiers () const
 
void SetViewParameters (const G4ViewParameters &vp)
 
void SetDefaultViewParameters (const G4ViewParameters &vp)
 
const G4VisAttributesGetApplicableVisAttributes (const G4VisAttributes *) const
 
void SetNeedKernelVisit (G4bool need)
 
void NeedKernelVisit ()
 
void ProcessView ()
 

Protected Member Functions

void SetTouchable (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
 
void TouchableSetVisibility (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
 
void TouchableSetColour (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
 

Protected Attributes

G4VSceneHandlerfSceneHandler
 
G4int fViewId
 
G4String fName
 
G4String fShortName
 
G4ViewParameters fVP
 
G4ViewParameters fDefaultVP
 
G4bool fNeedKernelVisit
 

Friends

std::ostream & operator<< (std::ostream &os, const G4VViewer &v)
 

Detailed Description

Definition at line 46 of file G4VViewer.hh.

Constructor & Destructor Documentation

G4VViewer::G4VViewer ( G4VSceneHandler sceneHandler,
G4int  id,
const G4String name = "" 
)

Definition at line 46 of file G4VViewer.cc.

47  :
48 fSceneHandler (sceneHandler),
49 fViewId (id),
50 //fModified (true),
51 fNeedKernelVisit (true)
52 {
53  if (name == "") {
54  std::ostringstream ost;
55  ost << fSceneHandler.GetName () << '-' << fViewId;
56  fName = ost.str();
57  }
58  else {
59  fName = name;
60  }
61  fShortName = fName (0, fName.find (' '));
62  fShortName.strip ();
63 
65  fDefaultVP = fVP;
66 }
const XML_Char * name
Definition: expat.h:151
G4int fViewId
Definition: G4VViewer.hh:202
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4String & GetName() const
G4ViewParameters fDefaultVP
Definition: G4VViewer.hh:206
const G4ViewParameters & GetDefaultViewParameters() const
static G4VisManager * GetInstance()
G4ViewParameters fVP
Definition: G4VViewer.hh:205
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:210
G4String fName
Definition: G4VViewer.hh:203
G4String fShortName
Definition: G4VViewer.hh:204
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:201

Here is the call graph for this function:

G4VViewer::~G4VViewer ( )
virtual

Definition at line 68 of file G4VViewer.cc.

68  {
70 }
void RemoveViewerFromList(G4VViewer *pView)
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:201

Here is the call graph for this function:

Member Function Documentation

virtual void G4VViewer::ClearView ( )
pure virtual
std::vector< G4ThreeVector > G4VViewer::ComputeFlyThrough ( G4Vector3D )

Definition at line 206 of file G4VViewer.cc.

207 {
208  enum CurveType {
209  Bezier,
210  G4SplineTest};
211 
212  // Choose a curve type (for testing)
213 // int myCurveType = Bezier;
214 
215  // number if step points
216  int stepPoints = 500;
217 
218 
219  G4Spline spline;
220 
221 
222  // At the moment we don't use the aVect parameters, but build it here :
223  // Good step points for exampleB5
224  spline.AddSplinePoint(G4Vector3D(0,1000,-14000));
225  spline.AddSplinePoint(G4Vector3D(0,1000,0));
226  spline.AddSplinePoint(G4Vector3D(-4000,1000,4000));
227 
228 
229  std::vector <G4ThreeVector> viewVect;
230 
231 // if(myCurveType == Bezier) {
232 
233 
234  // Draw the spline
235 
236  for (int i = 0; i < stepPoints; i++) {
237  float t = (float)i / (float)stepPoints;
238  G4Vector3D cameraPosition = spline.GetInterpolatedSplinePoint(t);
239  // G4Vector3D targetPoint = spline.GetInterpolatedSplinePoint(t);
240 
241  // viewParam->SetViewAndLights(G4ThreeVector (cameraPosition.x(), cameraPosition.y(), cameraPosition.z()));
242  // viewParam->SetCurrentTargetPoint(targetPoint);
243  G4cout << "FLY CR("<< i << "):" << cameraPosition << G4endl;
244  viewVect.push_back(G4ThreeVector (cameraPosition.x(), cameraPosition.y(), cameraPosition.z()));
245  }
246 
247 // } else if (myCurveType == G4SplineTest) {
248  /*
249  This method is a inspire from a Bezier curve. The problem of the Bezier curve is that the path does not go straight between two waypoints.
250  This method add "stay straight" parameter which could be between 0 and 1 where the pass will follow exactly the line between the waypoints
251  Ex : stay straight = 50%
252  m1 = 3*(P1+P0)/2
253 
254  Ex : stay straight = 0%
255  m1 = (P1+P0)/2
256 
257  P1
258  / \
259  / \
260  a--x--b
261  / ° ° \
262  / ° ° \
263  m1 m2
264  / \
265  / \
266  / \
267  / \
268  P0 P2
269 
270  */
271 // G4Vector3D a;
272 // G4Vector3D b;
273 // G4Vector3D m1;
274 // G4Vector3D m2;
275 // G4Vector3D P0;
276 // G4Vector3D P1;
277 // G4Vector3D P2;
278 // G4double stayStraight = 0;
279 // G4double bezierSpeed = 0.4; // Spend 40% time in bezier curve (time between m1-m2 is 40% of time between P0-P1)
280 //
281 // G4Vector3D firstPoint;
282 // G4Vector3D lastPoint;
283 //
284 // float nbBezierSteps = (stepPoints * bezierSpeed*(1-stayStraight)) * (2./spline.GetNumPoints());
285 // float nbFirstSteps = ((stepPoints/2-nbBezierSteps/2) /(1+stayStraight)) * (2./spline.GetNumPoints());
286 //
287 // // First points
288 // firstPoint = spline.GetPoint(0);
289 // lastPoint = (firstPoint + spline.GetPoint(1))/2;
290 //
291 // for( float j=0; j<1; j+= 1/nbFirstSteps) {
292 // G4ThreeVector pt = firstPoint + (lastPoint - firstPoint) * j;
293 // viewVect.push_back(pt);
294 // G4cout << "FLY Bezier A1("<< viewVect.size()<< "):" << pt << G4endl;
295 // }
296 //
297 // for (int i = 0; i < spline.GetNumPoints()-2; i++) {
298 // P0 = spline.GetPoint(i);
299 // P1 = spline.GetPoint(i+1);
300 // P2 = spline.GetPoint(i+2);
301 //
302 // m1 = P1 - (P1-P0)*(1-stayStraight)/2;
303 // m2 = P1 + (P2-P1)*(1-stayStraight)/2;
304 //
305 // // We have to get straight path from (middile of P0-P1) to (middile of P0-P1 + (dist P0-P1) * stayStraight/2)
306 // if (stayStraight >0) {
307 //
308 // firstPoint = (P0 + P1)/2;
309 // lastPoint = (P0 + P1)/2 + (P1-P0)*stayStraight/2;
310 //
311 // for( float j=0; j<1; j+= 1/(nbFirstSteps*stayStraight)) {
312 // G4ThreeVector pt = firstPoint + (lastPoint - firstPoint)* j;
313 // viewVect.push_back(pt);
314 // G4cout << "FLY Bezier A2("<< viewVect.size()<< "):" << pt << G4endl;
315 // }
316 // }
317 // // Compute Bezier curve
318 // for( float delta = 0 ; delta < 1 ; delta += 1/nbBezierSteps)
319 // {
320 // // The Green Line
321 // a = m1 + ( (P1 - m1) * delta );
322 // b = P1 + ( (m2 - P1) * delta );
323 //
324 // // Final point
325 // G4ThreeVector pt = a + ((b-a) * delta );
326 // viewVect.push_back(pt);
327 // G4cout << "FLY Bezier("<< viewVect.size()<< "):" << pt << G4endl;
328 // }
329 //
330 // // We have to get straight path
331 // if (stayStraight >0) {
332 // firstPoint = (P1 + P2)/2 - (P2-P1)*stayStraight/2;
333 // lastPoint = (P1 + P2)/2;
334 //
335 // for( float j=0; j<1; j+= 1/(nbFirstSteps*stayStraight)) {
336 // G4ThreeVector pt = firstPoint + (lastPoint - firstPoint)* j;
337 // viewVect.push_back(pt);
338 // G4cout << "FLY Bezier B1("<< viewVect.size()<< "):" << pt << G4endl;
339 // }
340 // }
341 // }
342 //
343 // // last points
344 // firstPoint = spline.GetPoint(spline.GetNumPoints()-2);
345 // lastPoint = spline.GetPoint(spline.GetNumPoints()-1);
346 // for( float j=1; j>0; j-= 1/nbFirstSteps) {
347 // G4ThreeVector pt = lastPoint - ((lastPoint-firstPoint)*((1-stayStraight)/2) * j );
348 // viewVect.push_back(pt);
349 // G4cout << "FLY Bezier B2("<< viewVect.size()<< "):" << pt << G4endl;
350 // }
351 // }
352  return viewVect;
353 }
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

virtual void G4VViewer::DrawView ( )
pure virtual
void G4VViewer::FinishView ( void  )
virtual

Reimplemented in G4HepRepViewer, G4VRML2FileViewer, and G4VRML1FileViewer.

Definition at line 101 of file G4VViewer.cc.

101 {}

Here is the caller graph for this function:

const G4VisAttributes* G4VViewer::GetApplicableVisAttributes ( const G4VisAttributes ) const

Here is the caller graph for this function:

const G4ViewParameters& G4VViewer::GetDefaultViewParameters ( ) const

Here is the caller graph for this function:

const G4String& G4VViewer::GetName ( ) const

Here is the caller graph for this function:

virtual const std::vector<G4ModelingParameters::VisAttributesModifier>* G4VViewer::GetPrivateVisAttributesModifiers ( ) const
virtual

Here is the caller graph for this function:

G4VSceneHandler* G4VViewer::GetSceneHandler ( ) const

Here is the caller graph for this function:

const G4String& G4VViewer::GetShortName ( ) const
G4int G4VViewer::GetViewId ( ) const

Here is the caller graph for this function:

const G4ViewParameters& G4VViewer::GetViewParameters ( ) const

Here is the caller graph for this function:

virtual void G4VViewer::Initialise ( )
virtual
void G4VViewer::NeedKernelVisit ( )

Definition at line 78 of file G4VViewer.cc.

78  {
79 
80  fNeedKernelVisit = true;
81 
82  // At one time I thought we'd better notify all viewers. But I guess
83  // each viewer can take care of itself, so the following code is
84  // redundant (but keep it commented out for now). (John Allison)
85  // Notify all viewers that a kernel visit is required.
86  // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
87  // G4ViewerListConstIterator i;
88  // for (i = viewerList.begin(); i != viewerList.end(); i++) {
89  // (*i) -> SetNeedKernelVisit ();
90  // }
91  // ??...but, there's a problem in OpenGL Stored which seems to
92  // require *all* viewers to revisit the kernel, so...
93  // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
94  // G4ViewerListConstIterator i;
95  // for (i = viewerList.begin(); i != viewerList.end(); i++) {
96  // (*i) -> SetNeedKernelVisit (true);
97  // }
98  // Feb 2005 - commented out. Let's fix OpenGL if necessary.
99 }
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:210

Here is the caller graph for this function:

void G4VViewer::ProcessView ( )

Definition at line 105 of file G4VViewer.cc.

106 {
107  // If the scene has changed, or if the concrete viewer has decided
108  // that it necessary to visit the kernel, perhaps because the view
109  // parameters have changed significantly (this should be done in the
110  // concrete viewer's DrawView)...
111  if (fNeedKernelVisit) {
112  // Reset flag. This must be done before ProcessScene to prevent
113  // recursive calls when recomputing transients...
114  fNeedKernelVisit = false;
117  }
118 }
virtual void ClearStore()
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:210
virtual void ProcessScene()
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:201

Here is the call graph for this function:

Here is the caller graph for this function:

void G4VViewer::RefreshView ( )

Here is the caller graph for this function:

virtual void G4VViewer::ResetView ( )
virtual

Here is the caller graph for this function:

void G4VViewer::SetDefaultViewParameters ( const G4ViewParameters vp)
void G4VViewer::SetName ( const G4String name)

Definition at line 72 of file G4VViewer.cc.

72  {
73  fName = name;
74  fShortName = fName (0, fName.find (' '));
75  fShortName.strip ();
76 }
const XML_Char * name
Definition: expat.h:151
G4String strip(G4int strip_Type=trailing, char c=' ')
G4String fName
Definition: G4VViewer.hh:203
G4String fShortName
Definition: G4VViewer.hh:204

Here is the call graph for this function:

void G4VViewer::SetNeedKernelVisit ( G4bool  need)
void G4VViewer::SetTouchable ( const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &  fullPath)
protected

Definition at line 125 of file G4VViewer.cc.

126 {
127  // Set the touchable for /vis/touchable/set/... commands.
128  std::ostringstream oss;
129  for (const auto& pvNodeId: fullPath) {
130  oss
131  << ' ' << pvNodeId.GetPhysicalVolume()->GetName()
132  << ' ' << pvNodeId.GetCopyNo();
133  }
134  G4UImanager::GetUIpointer()->ApplyCommand("/vis/set/touchable" + oss.str());
135 }
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function:

virtual void G4VViewer::SetView ( )
pure virtual
void G4VViewer::SetViewParameters ( const G4ViewParameters vp)

Definition at line 120 of file G4VViewer.cc.

120  {
121  fVP = vp;
122 }
G4ViewParameters fVP
Definition: G4VViewer.hh:205

Here is the caller graph for this function:

void G4VViewer::ShowView ( void  )
virtual

Reimplemented in G4GMocrenFileViewer, G4DAWNFILEViewer, G4HepRepFileViewer, G4HepRepViewer, G4XXXFileViewer, G4XXXViewer, G4VRML2FileViewer, G4VRML1FileViewer, G4XXXSGViewer, and G4XXXStoredViewer.

Definition at line 103 of file G4VViewer.cc.

103 {}

Here is the caller graph for this function:

void G4VViewer::TouchableSetColour ( const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &  fullPath,
const G4Colour colour 
)
protected

Definition at line 172 of file G4VViewer.cc.

174 {
175  // Changes the Vis Attribute Modifiers WITHOUT triggering a rebuild.
176 
177  std::ostringstream oss;
178  oss << "/vis/touchable/set/colour "
179  << colour.GetRed() << ' ' << colour.GetGreen()
180  << ' ' << colour.GetBlue() << ' ' << colour.GetAlpha();
181 
182  // The following is equivalent to
183  // G4UImanager::GetUIpointer()->ApplyCommand(oss.str());
184  // (assuming the touchable has already been set), but avoids view rebuild.
185 
186  // Instantiate a working copy of a G4VisAttributes object...
187  G4VisAttributes workingVisAtts;
188  // and set the colour.
189  workingVisAtts.SetColour(colour);
190 
193  (workingVisAtts,
195  fullPath));
196  // G4ModelingParameters::VASColour (VAS = Vis Attribute Signifier)
197  // signifies that it is the colour that should be picked out
198  // and merged with the touchable's normal vis attributes.
199 
200  // Record on G4cout (with #) for information.
201  if (G4UImanager::GetUIpointer()->GetVerboseLevel() >= 2) {
202  G4cout << "# " << oss.str() << G4endl;
203  }
204 }
void SetColour(const G4Colour &)
G4double GetAlpha() const
Definition: G4Colour.hh:142
G4double GetBlue() const
Definition: G4Colour.hh:141
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
G4double GetRed() const
Definition: G4Colour.hh:139
G4double GetGreen() const
Definition: G4Colour.hh:140
G4ViewParameters fVP
Definition: G4VViewer.hh:205
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void G4VViewer::TouchableSetVisibility ( const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &  fullPath,
G4bool  visibility 
)
protected

Definition at line 138 of file G4VViewer.cc.

140 {
141  // Changes the Vis Attribute Modifiers WITHOUT triggering a rebuild.
142 
143  std::ostringstream oss;
144  oss << "/vis/touchable/set/visibility ";
145  if (visibiity) oss << "true"; else oss << "false";
146 
147  // The following is equivalent to
148  // G4UImanager::GetUIpointer()->ApplyCommand(oss.str());
149  // (assuming the touchable has already been set), but avoids view rebuild.
150 
151  // Instantiate a working copy of a G4VisAttributes object...
152  G4VisAttributes workingVisAtts;
153  // and set the visibility.
154  workingVisAtts.SetVisibility(visibiity);
155 
158  (workingVisAtts,
160  fullPath));
161  // G4ModelingParameters::VASVisibility (VAS = Vis Attribute Signifier)
162  // signifies that it is the visibility that should be picked out
163  // and merged with the touchable's normal vis attributes.
164 
165  // Record on G4cout (with #) for information.
166  if (G4UImanager::GetUIpointer()->GetVerboseLevel() >= 2) {
167  G4cout << "# " << oss.str() << G4endl;
168  }
169 }
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
void SetVisibility(G4bool=true)
G4ViewParameters fVP
Definition: G4VViewer.hh:205
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const G4VViewer v 
)
friend

Definition at line 384 of file G4VViewer.cc.

384  {
385  os << "View " << v.fName << ":\n";
386  os << v.fVP;
387  return os;
388 }
G4ViewParameters fVP
Definition: G4VViewer.hh:205
G4String fName
Definition: G4VViewer.hh:203

Member Data Documentation

G4ViewParameters G4VViewer::fDefaultVP
protected

Definition at line 206 of file G4VViewer.hh.

G4String G4VViewer::fName
protected

Definition at line 203 of file G4VViewer.hh.

G4bool G4VViewer::fNeedKernelVisit
protected

Definition at line 210 of file G4VViewer.hh.

G4VSceneHandler& G4VViewer::fSceneHandler
protected

Definition at line 201 of file G4VViewer.hh.

G4String G4VViewer::fShortName
protected

Definition at line 204 of file G4VViewer.hh.

G4int G4VViewer::fViewId
protected

Definition at line 202 of file G4VViewer.hh.

G4ViewParameters G4VViewer::fVP
protected

Definition at line 205 of file G4VViewer.hh.


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