Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PerspectiveVisAction Class Reference

#include <Doxymodules_visualization.h>

Inheritance diagram for PerspectiveVisAction:
G4VUserVisAction

Public Member Functions

 PerspectiveVisAction ()
 
void SetOptionString (const G4String &optionString)
 
void SetScene (const G4String &scene)
 
virtual void Draw ()
 

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 18 of file Doxymodules_visualization.h.

Constructor & Destructor Documentation

◆ PerspectiveVisAction()

PerspectiveVisAction::PerspectiveVisAction ( )

Definition at line 45 of file PerspectiveVisAction.cc.

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

Member Function Documentation

◆ SetOptionString()

void PerspectiveVisAction::SetOptionString ( const G4String optionString)
inline

Definition at line 49 of file PerspectiveVisAction.hh.

49{ fOptionString = optionString; }

◆ SetScene()

void PerspectiveVisAction::SetScene ( const G4String scene)
inline

Definition at line 50 of file PerspectiveVisAction.hh.

50{ fScene = scene; }

◆ Draw()

void PerspectiveVisAction::Draw ( )
virtual

Definition at line 76 of file PerspectiveVisAction.cc.

77{
78 fpVisManager = G4VVisManager::GetConcreteInstance();
79 if (fpVisManager) {
80
81 // All scenes assume upvector z and origin on "floor"...
82
83 if (fScene == "room-and-chair" )
84 {
86 }
87 }
88}

◆ ExtendedDraw()

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

Definition at line 171 of file PerspectiveVisAction.cc.

175{
176 static const G4double extender = 100.*m;
177 static const G4Vector3D x(1,0,0);
178 static const G4Vector3D y(0,1,0);
179 static const G4Vector3D z(0,0,1);
180
181 // Draw extended edges as requested...
182 G4bool any = false, A = false, X = false, Y = false, Z = false;
183 if (G4StrUtil::contains(fOptionString, "a")) {A = true; any = true;}
184 if (G4StrUtil::contains(fOptionString, "x")) {X = true; any = true;}
185 if (G4StrUtil::contains(fOptionString, "y")) {Y = true; any = true;}
186 if (G4StrUtil::contains(fOptionString, "z")) {Z = true; any = true;}
187 if (any)
188 {
189 G4Polyhedron* polyhedron = solid.GetPolyhedron();
190 G4bool isAuxEdgeVisible = false; // How do I pick this up??? Can't.
191 G4bool notLastFace;
192 do {
193 G4int n;
194 G4Point3D nodes[4];
195 notLastFace = polyhedron->GetNextFacet(n, nodes);
196 G4bool notLastEdge;
197 do {
198 G4Point3D v1, v2;
199 G4int edgeFlag;
200 notLastEdge = polyhedron->GetNextEdge(v1, v2, edgeFlag);
201 if (isAuxEdgeVisible || edgeFlag > 0) {
202 G4Vector3D v21 = v2 - v1;
203 // Check for components of actual edge...
204 G4Vector3D v21a = v21;
205 v21a.transform(transform);
206 // G4cout << "v21a: " << v21a << G4endl;
207 using namespace std;
208 if (A ||
209 (Z && abs(v21a.z()) >
210 sqrt(v21a.x()*v21a.x()+v21a.y()*v21a.y())) ||
211 (X && abs(v21a.x()) >
212 sqrt(v21a.y()*v21a.y()+v21a.z()*v21a.z())) ||
213 (Y && abs(v21a.y()) >
214 sqrt(v21a.x()*v21a.x()+v21a.x()*v21a.z()))) {
215 G4Polyline edge;
216 edge.SetVisAttributes(G4Colour(.2,.2,.2));
217 edge.push_back(v1 - extender * v21.unit());
218 edge.push_back(v2 + extender * v21.unit());
219 fpVisManager->Draw(edge, transform);
220 }
221 }
222 } while (notLastEdge);
223 } while (notLastFace);
224 }
225
226 // Draw actual object...
227 fpVisManager->Draw(solid, visAtts, transform);
228}
G4bool contains(const G4String &str, std::string_view ss)

◆ RoomAndChair()

void PerspectiveVisAction::RoomAndChair ( )
private

Definition at line 92 of file PerspectiveVisAction.cc.

93{
94 // Simple box, size of a room, translated so origin is on xy "floor"...
95 G4VisAttributes room_visAtts(G4Colour::Red());
96 room_visAtts.SetForceWireframe(true);
98 (G4Box("box",fRoomX,fRoomY,fRoomZ), room_visAtts, G4TranslateZ3D(fRoomZ));
99
100 // Windows...
101 G4Box ("window",fWindowX,fWindowY,fWindowZ);
103 (G4Box("window-x",fWindowX,fWindowY,fWindowZ),
104 room_visAtts,
107 (G4Box("window-y1",fWindowX,fWindowY,fWindowZ),
108 room_visAtts,
109 G4Translate3D(0., -fRoomY - fWindowX, fWindowY + fWindowSillHeight) *
110 G4RotateZ3D(90.*deg));
112 (G4Box("window-y2",fWindowX,fWindowY,fWindowZ),
113 room_visAtts,
114 G4Translate3D(0., fRoomY + fWindowX, fWindowY + fWindowSillHeight) *
115 G4RotateZ3D(-90.*deg));
116
117 // Door...
120 room_visAtts,
121 G4Translate3D(-fRoomX - fDoorFrameX, fDoorFrameOffset, fDoorFrameZ));
123 (G4Box("door",fDoorX,fDoorY,fDoorZ),
124 room_visAtts,
125 G4Translate3D(-fRoomX - fDoorX, fDoorFrameOffset, fDoorZ) *
126 G4TranslateY3D(fDoorY) *
127 G4RotateZ3D(60.*deg) *
128 G4TranslateY3D(-fDoorY)); // Last transform operates first.
129
130 // Chair...
131 G4VisAttributes chair_visAtts(G4Colour::Cyan());
132 G4Transform3D A = G4RotateZ3D(90.*deg); // Turn through 90 deg.
133 G4Transform3D B = G4RotateY3D(90.*deg); // Lie down.
134 G4Transform3D C = G4RotateZ3D(-20.*deg) ; // Rotate a little.
135 G4Transform3D D = G4TranslateZ3D(fChairY); // Place on floor.
136 G4Transform3D E = G4TranslateY3D(-0.5 * fRoomY); // Move over to the left...
137 G4Transform3D chair_transform = E*D*C*B*A;
138 Chair(chair_visAtts, chair_transform);
139}
void Chair(const G4VisAttributes &, const G4Transform3D &)
void ExtendedDraw(const G4VSolid &, const G4VisAttributes &, const G4Transform3D &objectTransformation=G4Transform3D())

◆ Chair()

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

Definition at line 143 of file PerspectiveVisAction.cc.

146{
147 // Origin is on floor, z = 0, and in the xy centre...
150 visAtts, transform *
151 G4Translate3D(0.,-fChairY + fChairThickness, fChairZ + fChairSeat));
153 (G4Box("chair-seat",fChairX, fChairY, fChairThickness),
154 visAtts, transform * G4TranslateZ3D(-fChairThickness + 2.* fChairSeat));
155 for (int i = -1; i < 2; i+=2) {
156 for (int j = -1; j < 2; j+=2) {
158 (G4Box("chair-leg",fChairThickness,
161 visAtts, transform *
162 G4Translate3D(i * (fChairX - fChairThickness),
163 j * (fChairY - fChairThickness),
165 }
166 }
167}

Member Data Documentation

◆ fpVisManager

G4VVisManager* PerspectiveVisAction::fpVisManager
private

Definition at line 58 of file PerspectiveVisAction.hh.

◆ fOptionString

G4String PerspectiveVisAction::fOptionString
private

Definition at line 59 of file PerspectiveVisAction.hh.

◆ fScene

G4String PerspectiveVisAction::fScene
private

Definition at line 60 of file PerspectiveVisAction.hh.

◆ fRoomX

G4double PerspectiveVisAction::fRoomX
private

Definition at line 61 of file PerspectiveVisAction.hh.

◆ fRoomY

G4double PerspectiveVisAction::fRoomY
private

Definition at line 61 of file PerspectiveVisAction.hh.

◆ fRoomZ

G4double PerspectiveVisAction::fRoomZ
private

Definition at line 61 of file PerspectiveVisAction.hh.

◆ fWindowX

G4double PerspectiveVisAction::fWindowX
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fWindowY

G4double PerspectiveVisAction::fWindowY
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fWindowZ

G4double PerspectiveVisAction::fWindowZ
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fWindowSillHeight

G4double PerspectiveVisAction::fWindowSillHeight
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fWindowOffset

G4double PerspectiveVisAction::fWindowOffset
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fDoorFrameX

G4double PerspectiveVisAction::fDoorFrameX
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fDoorFrameY

G4double PerspectiveVisAction::fDoorFrameY
private

Definition at line 62 of file PerspectiveVisAction.hh.

◆ fDoorFrameZ

G4double PerspectiveVisAction::fDoorFrameZ
private

Definition at line 63 of file PerspectiveVisAction.hh.

◆ fDoorFrameOffset

G4double PerspectiveVisAction::fDoorFrameOffset
private

Definition at line 63 of file PerspectiveVisAction.hh.

◆ fDoorX

G4double PerspectiveVisAction::fDoorX
private

Definition at line 63 of file PerspectiveVisAction.hh.

◆ fDoorY

G4double PerspectiveVisAction::fDoorY
private

Definition at line 63 of file PerspectiveVisAction.hh.

◆ fDoorZ

G4double PerspectiveVisAction::fDoorZ
private

Definition at line 63 of file PerspectiveVisAction.hh.

◆ fChairX

G4double PerspectiveVisAction::fChairX
private

Definition at line 64 of file PerspectiveVisAction.hh.

◆ fChairY

G4double PerspectiveVisAction::fChairY
private

Definition at line 65 of file PerspectiveVisAction.hh.

◆ fChairZ

G4double PerspectiveVisAction::fChairZ
private

Definition at line 66 of file PerspectiveVisAction.hh.

◆ fChairSeat

G4double PerspectiveVisAction::fChairSeat
private

Definition at line 67 of file PerspectiveVisAction.hh.

◆ fChairThickness

G4double PerspectiveVisAction::fChairThickness
private

Definition at line 68 of file PerspectiveVisAction.hh.


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

Applications | User Support | Publications | Collaboration