Geant4  10.02.p03
PerspectiveVisAction Class Reference

#include <PerspectiveVisAction.hh>

Inheritance diagram for PerspectiveVisAction:
Collaboration diagram for PerspectiveVisAction:

Public Member Functions

 PerspectiveVisAction ()
 
void SetOptionString (const G4String &optionString)
 
void SetScene (const G4String &scene)
 
virtual void Draw ()
 
- Public Member Functions inherited from G4VUserVisAction
 G4VUserVisAction ()
 
virtual ~G4VUserVisAction ()
 
void operator() (G4VGraphicsScene &, const G4Transform3D &)
 

Private Member Functions

void ExtendedDraw (const G4VSolid &, const G4VisAttributes &, const G4Transform3D &objectTransformation=G4Transform3D())
 
void RoomAndChair ()
 
void Chair (const G4VisAttributes &, const G4Transform3D &)
 

Private Attributes

G4VVisManagerfpVisManager
 
G4String fOptionString
 
G4String fScene
 
G4double fRoomX
 
G4double fRoomY
 
G4double fRoomZ
 
G4double fWindowX
 
G4double fWindowY
 
G4double fWindowZ
 
G4double fWindowSillHeight
 
G4double fWindowOffset
 
G4double fDoorFrameX
 
G4double fDoorFrameY
 
G4double fDoorFrameZ
 
G4double fDoorFrameOffset
 
G4double fDoorX
 
G4double fDoorY
 
G4double fDoorZ
 
G4double fChairX
 
G4double fChairY
 
G4double fChairZ
 
G4double fChairSeat
 
G4double fChairThickness
 

Detailed Description

Definition at line 50 of file PerspectiveVisAction.hh.

Constructor & Destructor Documentation

◆ PerspectiveVisAction()

PerspectiveVisAction::PerspectiveVisAction ( )

Definition at line 46 of file PerspectiveVisAction.cc.

46  :
48  fpVisManager(0),
49  fOptionString("none"),
50  fScene("room-and-chair"),
51  fRoomX(2.5*m), // Half-lengths...
52  fRoomY(2.5*m),
53  fRoomZ(1.3*m),
54  fWindowX(10*cm),
55  fWindowY(75*cm),
56  fWindowZ(50*cm),
58  fWindowOffset(-50*cm),
59  fDoorFrameX(10*cm),
60  fDoorFrameY(50*cm),
61  fDoorFrameZ(1*m),
62  fDoorFrameOffset(1.5*m),
63  fDoorX(2*cm),
64  fDoorY(50*cm),
65  fDoorZ(1*m),
66  fChairX(20*cm), // Half overall width.
67  fChairY(20*cm), // Half overall depth.
68  fChairZ(45*cm), // Half overall height.
69  fChairSeat(20*cm), // Half height of top of seat.
70  fChairThickness(3.*cm) // Half thicknes of back, seat, legs.
71 {
73 }
static const double cm
Definition: G4SIunits.hh:118
G4VVisManager * fpVisManager
static const double m
Definition: G4SIunits.hh:128

Member Function Documentation

◆ Chair()

void PerspectiveVisAction::Chair ( const G4VisAttributes visAtts,
const G4Transform3D transform 
)
private

Definition at line 145 of file PerspectiveVisAction.cc.

147 {
148  // Origin is on floor, z = 0, and in the xy centre...
150  (G4Box("chair-back",fChairX, fChairThickness, fChairZ - fChairSeat),
151  visAtts, transform *
154  (G4Box("chair-seat",fChairX, fChairY, fChairThickness),
155  visAtts, transform * G4TranslateZ3D(-fChairThickness + 2.* fChairSeat));
156  for (int i = -1; i < 2; i+=2) {
157  for (int j = -1; j < 2; j+=2) {
159  (G4Box("chair-leg",fChairThickness,
162  visAtts, transform *
164  j * (fChairY - fChairThickness),
166  }
167  }
168 }
Definition: G4Box.hh:64
void ExtendedDraw(const G4VSolid &, const G4VisAttributes &, const G4Transform3D &objectTransformation=G4Transform3D())
HepGeom::Translate3D G4Translate3D
HepGeom::TranslateZ3D G4TranslateZ3D
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw()

void PerspectiveVisAction::Draw ( )
virtual

Implements G4VUserVisAction.

Definition at line 77 of file PerspectiveVisAction.cc.

78 {
80  if (fpVisManager) {
81 
82  // All scenes assume upvector z and origin on "floor"...
83 
84  if (fScene == "room-and-chair" )
85  {
86  RoomAndChair();
87  }
88  }
89 }
static G4VVisManager * GetConcreteInstance()
G4VVisManager * fpVisManager
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtendedDraw()

void PerspectiveVisAction::ExtendedDraw ( const G4VSolid solid,
const G4VisAttributes visAtts,
const G4Transform3D objectTransformation = G4Transform3D() 
)
private

Definition at line 173 of file PerspectiveVisAction.cc.

176 {
177  static const G4double extender = 100.*m;
178  static const G4Vector3D x(1,0,0);
179  static const G4Vector3D y(0,1,0);
180  static const G4Vector3D z(0,0,1);
181 
182  // Draw extended edges as requested...
183  G4bool any = false, A = false, X = false, Y = false, Z = false;
184  if (fOptionString.contains("a")) {A = true; any = true;}
185  if (fOptionString.contains("x")) {X = true; any = true;}
186  if (fOptionString.contains("y")) {Y = true; any = true;}
187  if (fOptionString.contains("z")) {Z = true; any = true;}
188  if (any)
189  {
190  G4Polyhedron* polyhedron = solid.GetPolyhedron();
191  G4bool isAuxEdgeVisible = false; // How do I pick this up??? Can't.
192  G4bool notLastFace;
193  do {
194  G4int n;
195  G4Point3D nodes[4];
196  notLastFace = polyhedron->GetNextFacet(n, nodes);
197  G4bool notLastEdge;
198  do {
199  G4Point3D v1, v2;
200  G4int edgeFlag;
201  notLastEdge = polyhedron->GetNextEdge(v1, v2, edgeFlag);
202  if (isAuxEdgeVisible || edgeFlag > 0) {
203  G4Vector3D v21 = v2 - v1;
204  // Check for components of actual edge...
205  G4Vector3D v21a = v21;
206  v21a.transform(transform);
207  // G4cout << "v21a: " << v21a << G4endl;
208  using namespace std;
209  if (A ||
210  (Z && abs(v21a.z()) >
211  sqrt(v21a.x()*v21a.x()+v21a.y()*v21a.y())) ||
212  (X && abs(v21a.x()) >
213  sqrt(v21a.y()*v21a.y()+v21a.z()*v21a.z())) ||
214  (Y && abs(v21a.y()) >
215  sqrt(v21a.x()*v21a.x()+v21a.x()*v21a.z()))) {
216  G4Polyline edge;
217  edge.SetVisAttributes(G4Colour(.2,.2,.2));
218  edge.push_back(v1 - extender * v21.unit());
219  edge.push_back(v2 + extender * v21.unit());
220  fpVisManager->Draw(edge, transform);
221  }
222  }
223  } while (notLastEdge);
224  } while (notLastFace);
225  }
226 
227  // Draw actual object...
228  fpVisManager->Draw(solid, visAtts, transform);
229 }
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=0, G4Normal3D *normals=0) const
Float_t Y
G4bool contains(const std::string &) const
int G4int
Definition: G4Types.hh:78
virtual G4Polyhedron * GetPolyhedron() const
Definition: G4VSolid.cc:644
Float_t X
Double_t y
Char_t n[5]
double A(double temperature)
G4bool GetNextEdge(G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag) const
Float_t Z
bool G4bool
Definition: G4Types.hh:79
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:80
G4VVisManager * fpVisManager
static const double m
Definition: G4SIunits.hh:128
double G4double
Definition: G4Types.hh:76
BasicVector3D< T > unit() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RoomAndChair()

void PerspectiveVisAction::RoomAndChair ( )
private

Definition at line 93 of file PerspectiveVisAction.cc.

94 {
95  // Simple box, size of a room, translated so origin is on xy "floor"...
96  G4VisAttributes room_visAtts(G4Colour::Red());
97  room_visAtts.SetForceWireframe(true);
99  (G4Box("box",fRoomX,fRoomY,fRoomZ), room_visAtts, G4TranslateZ3D(fRoomZ));
100 
101  // Windows...
102  G4Box ("window",fWindowX,fWindowY,fWindowZ);
104  (G4Box("window-x",fWindowX,fWindowY,fWindowZ),
105  room_visAtts,
108  (G4Box("window-y1",fWindowX,fWindowY,fWindowZ),
109  room_visAtts,
111  G4RotateZ3D(90.*deg));
113  (G4Box("window-y2",fWindowX,fWindowY,fWindowZ),
114  room_visAtts,
116  G4RotateZ3D(-90.*deg));
117 
118  // Door...
120  (G4Box("door-frame",fDoorFrameX,fDoorFrameY,fDoorFrameZ),
121  room_visAtts,
124  (G4Box("door",fDoorX,fDoorY,fDoorZ),
125  room_visAtts,
128  G4RotateZ3D(60.*deg) *
129  G4TranslateY3D(-fDoorY)); // Last transform operates first.
130 
131  // Chair...
132  G4VisAttributes chair_visAtts(G4Colour::Cyan());
133  G4Transform3D A = G4RotateZ3D(90.*deg); // Turn through 90 deg.
134  G4Transform3D B = G4RotateY3D(90.*deg); // Lie down.
135  G4Transform3D C = G4RotateZ3D(-20.*deg) ; // Rotate a little.
136  G4Transform3D D = G4TranslateZ3D(fChairY); // Place on floor.
137  G4Transform3D E = G4TranslateY3D(-0.5 * fRoomY); // Move over to the left...
138  G4Transform3D chair_transform = E*D*C*B*A;
139  Chair(chair_visAtts, chair_transform);
140 }
HepGeom::RotateY3D G4RotateY3D
Definition: G4Box.hh:64
double C(double temp)
HepGeom::TranslateY3D G4TranslateY3D
HepGeom::RotateZ3D G4RotateZ3D
double A(double temperature)
static const double deg
Definition: G4SIunits.hh:151
void ExtendedDraw(const G4VSolid &, const G4VisAttributes &, const G4Transform3D &objectTransformation=G4Transform3D())
static G4Colour Cyan()
Definition: G4Colour.hh:151
void Chair(const G4VisAttributes &, const G4Transform3D &)
double D(double temp)
HepGeom::Translate3D G4Translate3D
static G4Colour Red()
Definition: G4Colour.hh:148
HepGeom::TranslateZ3D G4TranslateZ3D
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOptionString()

void PerspectiveVisAction::SetOptionString ( const G4String optionString)
inline

Definition at line 53 of file PerspectiveVisAction.hh.

54  {fOptionString = optionString;}
Here is the caller graph for this function:

◆ SetScene()

void PerspectiveVisAction::SetScene ( const G4String scene)
inline

Definition at line 55 of file PerspectiveVisAction.hh.

56  {fScene = scene;}
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fChairSeat

G4double PerspectiveVisAction::fChairSeat
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fChairThickness

G4double PerspectiveVisAction::fChairThickness
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fChairX

G4double PerspectiveVisAction::fChairX
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fChairY

G4double PerspectiveVisAction::fChairY
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fChairZ

G4double PerspectiveVisAction::fChairZ
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorFrameOffset

G4double PerspectiveVisAction::fDoorFrameOffset
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorFrameX

G4double PerspectiveVisAction::fDoorFrameX
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorFrameY

G4double PerspectiveVisAction::fDoorFrameY
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorFrameZ

G4double PerspectiveVisAction::fDoorFrameZ
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorX

G4double PerspectiveVisAction::fDoorX
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorY

G4double PerspectiveVisAction::fDoorY
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fDoorZ

G4double PerspectiveVisAction::fDoorZ
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fOptionString

G4String PerspectiveVisAction::fOptionString
private

Definition at line 64 of file PerspectiveVisAction.hh.

◆ fpVisManager

G4VVisManager* PerspectiveVisAction::fpVisManager
private

Definition at line 63 of file PerspectiveVisAction.hh.

◆ fRoomX

G4double PerspectiveVisAction::fRoomX
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fRoomY

G4double PerspectiveVisAction::fRoomY
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fRoomZ

G4double PerspectiveVisAction::fRoomZ
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fScene

G4String PerspectiveVisAction::fScene
private

Definition at line 65 of file PerspectiveVisAction.hh.

◆ fWindowOffset

G4double PerspectiveVisAction::fWindowOffset
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fWindowSillHeight

G4double PerspectiveVisAction::fWindowSillHeight
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fWindowX

G4double PerspectiveVisAction::fWindowX
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fWindowY

G4double PerspectiveVisAction::fWindowY
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fWindowZ

G4double PerspectiveVisAction::fWindowZ
private

Definition at line 66 of file PerspectiveVisAction.hh.


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