Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4XXXFileSceneHandler.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29//
30// John Allison 7th March 2006
31// A template for a file-writing graphics driver.
32//?? Lines beginning like this require specialisation for your driver.
33
35
36#include "G4XXXFileViewer.hh"
39#include "G4VPhysicalVolume.hh"
40#include "G4LogicalVolume.hh"
41#include "G4Box.hh"
42#include "G4Polyline.hh"
43#include "G4Text.hh"
44#include "G4Circle.hh"
45#include "G4Square.hh"
46#include "G4Polyhedron.hh"
47#include "G4UnitsTable.hh"
48
49#include <sstream>
50
52// Counter for XXX scene handlers.
53
55 const G4String& name):
56 G4VSceneHandler(system, fSceneIdCount++, name)
57{}
58
60
61#ifdef G4XXXFileDEBUG
62// Useful function...
63void G4XXXFileSceneHandler::PrintThings() {
64 G4cout <<
65 " with transformation "
66 << (void*)fpObjectTransformation;
67 if (fpModel) {
68 G4cout << " from " << fpModel->GetCurrentDescription()
69 << " (tag " << fpModel->GetCurrentTag()
70 << ')';
71 } else {
72 G4cout << "(not from a model)";
73 }
74 G4PhysicalVolumeModel* pPVModel =
75 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
76 if (pPVModel) {
77 G4cout <<
78 "\n current physical volume: "
79 << pPVModel->GetCurrentPV()->GetName() <<
80 "\n current logical volume: "
81// There might be a problem with the LV pointer if this is a G4LogicalVolumeModel
82 << pPVModel->GetCurrentLV()->GetName() <<
83 "\n current depth of geometry tree: "
84 << pPVModel->GetCurrentDepth();
85 }
86 G4cout << G4endl;
87}
88#endif
89
90// Note: This function overrides G4VSceneHandler::AddSolid(const
91// G4Box&). You may not want to do this, but this is how it's done if
92// you do. Certain other specific solids may be treated this way -
93// see G4VSceneHandler.hh. The simplest possible driver would *not*
94// implement these polymorphic functions, with the effect that the
95// default versions in G4VSceneHandler are used, which simply call
96// G4VSceneHandler::RequestPrimitives to turn the solid into a
97// G4Polyhedron usually.
99#ifdef G4XXXFileDEBUG
100 G4cout <<
101 "G4XXXFileSceneHandler::AddSolid(const G4Box& box) called for "
102 << box.GetName()
103 << G4endl;
104#endif
105 //?? Process your box...
106 std::ostringstream oss;
107 oss << "G4Box(" <<
111 (box.GetXHalfLength(), box.GetYHalfLength(), box.GetZHalfLength()),
112 "Length")).strip() << ')';
113 dynamic_cast<G4XXXFileViewer*>(fpViewer)->
114 GetFileWriter().WriteItem(oss.str());
115}
116
118#ifdef G4XXXFileDEBUG
119 G4cout <<
120 "G4XXXFileSceneHandler::AddPrimitive(const G4Polyline& polyline) called.\n"
121 << polyline
122 << G4endl;
123#endif
124 // Get vis attributes - pick up defaults if none.
125 //const G4VisAttributes* pVA =
126 // fpViewer -> GetApplicableVisAttributes (polyline.GetVisAttributes ());
127 //?? Process polyline.
128 std::ostringstream oss;
129 oss << polyline;
130 dynamic_cast<G4XXXFileViewer*>(fpViewer)->
131 GetFileWriter().WriteItem(oss.str());
132}
133
135#ifdef G4XXXFileDEBUG
136 G4cout <<
137 "G4XXXFileSceneHandler::AddPrimitive(const G4Text& text) called.\n"
138 << text
139 << G4endl;
140#endif
141 // Get text colour - special method since default text colour is
142 // determined by the default text vis attributes, which may be
143 // specified independent of default vis attributes of other types of
144 // visible objects.
145 //const G4Colour& c = GetTextColour (text); // Picks up default if none.
146 //?? Process text.
147 std::ostringstream oss;
148 oss << text;
149 dynamic_cast<G4XXXFileViewer*>(fpViewer)->
150 GetFileWriter().WriteItem(oss.str());
151}
152
154#ifdef G4XXXFileDEBUG
155 G4cout <<
156 "G4XXXFileSceneHandler::AddPrimitive(const G4Circle& circle) called.\n "
157 << circle
158 << G4endl;
159 MarkerSizeType sizeType;
160 G4double size = GetMarkerSize (circle, sizeType);
161 switch (sizeType) {
162 default:
163 case screen:
164 // Draw in screen coordinates.
165 G4cout << "screen";
166 break;
167 case world:
168 // Draw in world coordinates.
169 G4cout << "world";
170 break;
171 }
172 G4cout << " size: " << size << G4endl;
173#endif
174 // Get vis attributes - pick up defaults if none.
175 //const G4VisAttributes* pVA =
176 // fpViewer -> GetApplicableVisAttributes (circle.GetVisAttributes ());
177 //?? Process circle.
178 std::ostringstream oss;
179 oss << circle;
180 dynamic_cast<G4XXXFileViewer*>(fpViewer)->
181 GetFileWriter().WriteItem(oss.str());
182}
183
185#ifdef G4XXXFileDEBUG
186 G4cout <<
187 "G4XXXFileSceneHandler::AddPrimitive(const G4Square& square) called.\n"
188 << square
189 << G4endl;
190 MarkerSizeType sizeType;
191 G4double size = GetMarkerSize (square, sizeType);
192 switch (sizeType) {
193 default:
194 case screen:
195 // Draw in screen coordinates.
196 G4cout << "screen";
197 break;
198 case world:
199 // Draw in world coordinates.
200 G4cout << "world";
201 break;
202 }
203 G4cout << " size: " << size << G4endl;
204#endif
205 // Get vis attributes - pick up defaults if none.
206 //const G4VisAttributes* pVA =
207 // fpViewer -> GetApplicableVisAttributes (square.GetVisAttributes ());
208 //?? Process square.
209 std::ostringstream oss;
210 oss << square;
211 dynamic_cast<G4XXXFileViewer*>(fpViewer)->
212 GetFileWriter().WriteItem(oss.str());
213}
214
216#ifdef G4XXXFileDEBUG
217 G4cout <<
218"G4XXXFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) called.\n"
219 << polyhedron
220 << G4endl;
221#endif
222 //?? Process polyhedron.
223 std::ostringstream oss;
224 oss << polyhedron;
225 dynamic_cast<G4XXXFileViewer*>(fpViewer)->
226 GetFileWriter().WriteItem(oss.str());
227
228 //?? Or... here are some ideas for decomposing into polygons...
229 //Assume all facets are convex quadrilaterals.
230 //Draw each G4Facet individually
231
232 //Get colour, etc..
233 if (polyhedron.GetNoFacets() == 0) return;
234
235 // Get vis attributes - pick up defaults if none.
236 const G4VisAttributes* pVA =
237 fpViewer -> GetApplicableVisAttributes (polyhedron.GetVisAttributes ());
238
239 // Get view parameters that the user can force through the vis
240 // attributes, thereby over-riding the current view parameter.
242 //G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
243
244 //Get colour, etc..
245 //const G4Colour& c = pVA -> GetColour ();
246
247 // Initial action depending on drawing style.
248 switch (drawing_style) {
250 {
251 break;
252 }
254 {
255 break;
256 }
258 {
259 break;
260 }
261 default:
262 {
263 break;
264 }
265 }
266
267 // Loop through all the facets...
268
269 // Look at G4OpenGLSceneHandler::AddPrimitive(const G4Polyhedron&)
270 // for an example of how to get facets out of a G4Polyhedron,
271 // including how to cope with triangles if that's a problem.
272}
273
275#ifdef G4XXXFileDEBUG
276 G4cout <<
277 "G4XXXFileSceneHandler::AddPrimitive(const G4NURBS& nurbs) called."
278 << G4endl;
279#endif
280 //?? Don't bother implementing this. NURBS are not functional.
281}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
Definition: G4Box.hh:55
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4String GetName() const
G4VPhysicalVolume * GetCurrentPV() const
G4LogicalVolume * GetCurrentLV() const
G4String strip(G4int strip_Type=trailing, char c=' ')
Definition: G4Text.hh:73
virtual G4String GetCurrentDescription() const
Definition: G4VModel.cc:54
virtual G4String GetCurrentTag() const
Definition: G4VModel.cc:49
const G4String & GetName() const
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
G4VViewer * fpViewer
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
G4String GetName() const
const G4VisAttributes * GetVisAttributes() const
void AddPrimitive(const G4Polyline &)
G4XXXFileSceneHandler(G4VGraphicsSystem &system, const G4String &name)
void AddSolid(const G4Box &)
G4int GetNoFacets() const