Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VSceneHandler Class Referenceabstract

#include <G4VSceneHandler.hh>

Inheritance diagram for G4VSceneHandler:

Classes

struct  NameAndVisAtts
class  PseudoSceneFor3DRectMeshPositions
class  PseudoSceneForTetVertices

Public Types

enum  MarkerSizeType { world , screen }

Public Member Functions

 G4VSceneHandler (G4VGraphicsSystem &system, G4int id, const G4String &name="")
virtual ~G4VSceneHandler ()
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void PostAddSolid ()
virtual void AddSolid (const G4Box &)
virtual void AddSolid (const G4Cons &)
virtual void AddSolid (const G4Orb &)
virtual void AddSolid (const G4Para &)
virtual void AddSolid (const G4Sphere &)
virtual void AddSolid (const G4Torus &)
virtual void AddSolid (const G4Trap &)
virtual void AddSolid (const G4Trd &)
virtual void AddSolid (const G4Tubs &)
virtual void AddSolid (const G4Ellipsoid &)
virtual void AddSolid (const G4Polycone &)
virtual void AddSolid (const G4Polyhedra &)
virtual void AddSolid (const G4TessellatedSolid &)
virtual void AddSolid (const G4VSolid &)
virtual void AddCompound (const G4VTrajectory &)
virtual void AddCompound (const G4VHit &)
virtual void AddCompound (const G4VDigi &)
virtual void AddCompound (const G4THitsMap< G4double > &)
virtual void AddCompound (const G4THitsMap< G4StatDouble > &)
virtual void AddCompound (const G4Mesh &)
virtual void BeginModeling ()
virtual void EndModeling ()
virtual void BeginPrimitives (const G4Transform3D &objectTransformation=G4Transform3D())
virtual void EndPrimitives ()
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())
virtual void EndPrimitives2D ()
virtual void AddPrimitive (const G4Polyline &)=0
virtual void AddPrimitive (const G4Text &)=0
virtual void AddPrimitive (const G4Circle &)=0
virtual void AddPrimitive (const G4Square &)=0
virtual void AddPrimitive (const G4Polymarker &)
virtual void AddPrimitive (const G4Polyhedron &)=0
virtual void AddPrimitive (const G4Plotter &)
virtual const G4VisExtentGetExtent () const
const G4StringGetName () const
G4int GetSceneHandlerId () const
G4int GetViewCount () const
G4VGraphicsSystemGetGraphicsSystem () const
G4SceneGetScene () const
const G4ViewerListGetViewerList () const
G4VModelGetModel () const
G4VViewerGetCurrentViewer () const
G4bool GetMarkForClearingTransientStore () const
G4bool IsReadyForTransients () const
G4bool GetTransientsDrawnThisEvent () const
G4bool GetTransientsDrawnThisRun () const
const G4Transform3DGetObjectTransformation () const
void SetName (const G4String &)
void SetCurrentViewer (G4VViewer *)
virtual void SetScene (G4Scene *)
G4ViewerListSetViewerList ()
void SetModel (G4VModel *)
void SetMarkForClearingTransientStore (G4bool)
void SetTransientsDrawnThisEvent (G4bool)
void SetTransientsDrawnThisRun (G4bool)
void SetObjectTransformation (const G4Transform3D &)
const G4ColourGetColour ()
const G4ColourGetColor ()
const G4ColourGetColour (const G4Visible &)
const G4ColourGetColor (const G4Visible &)
const G4ColourGetTextColour (const G4Text &)
const G4ColourGetTextColor (const G4Text &)
G4double GetLineWidth (const G4VisAttributes *)
G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes *)
G4int GetNumberOfCloudPoints (const G4VisAttributes *) const
G4bool GetAuxEdgeVisible (const G4VisAttributes *)
G4int GetNoOfSides (const G4VisAttributes *)
G4double GetMarkerSize (const G4VMarker &, MarkerSizeType &)
G4double GetMarkerDiameter (const G4VMarker &, MarkerSizeType &)
G4double GetMarkerRadius (const G4VMarker &, MarkerSizeType &)
G4ModelingParametersCreateModelingParameters ()
void DrawEvent (const G4Event *)
void DrawEndOfRunModels ()
template<class T>
void AddSolidT (const T &solid)
template<class T>
void AddSolidWithAuxiliaryEdges (const T &solid)
G4int IncrementViewCount ()
virtual void ClearStore ()
virtual void ClearTransientStore ()
void AddViewerToList (G4VViewer *pView)
void RemoveViewerFromList (G4VViewer *pView)
Public Member Functions inherited from G4VGraphicsScene
 G4VGraphicsScene ()
virtual ~G4VGraphicsScene ()
G4int GetMaxGeometryDepth () const
void SetMaxGeometryDepth (G4int maxDepth)

Protected Member Functions

virtual void ProcessScene ()
virtual void ProcessTransients ()
virtual void RequestPrimitives (const G4VSolid &solid)
virtual G4DisplacedSolidCreateSectionSolid ()
virtual G4DisplacedSolidCreateCutawaySolid ()
void LoadAtts (const G4Visible &, G4AttHolder *)
void StandardSpecialMeshRendering (const G4Mesh &)
void Draw3DRectMeshAsDots (const G4Mesh &)
void Draw3DRectMeshAsSurfaces (const G4Mesh &)
void DrawTetMeshAsDots (const G4Mesh &)
void DrawTetMeshAsSurfaces (const G4Mesh &)
G4ThreeVector GetPointInBox (const G4ThreeVector &pos, G4double halfX, G4double halfY, G4double halfZ) const
G4ThreeVector GetPointInTet (const std::vector< G4ThreeVector > &vertices) const

Protected Attributes

G4VGraphicsSystemfSystem
const G4int fSceneHandlerId
G4String fName
G4int fViewCount
G4ViewerList fViewerList
G4VViewerfpViewer
G4ScenefpScene
G4bool fMarkForClearingTransientStore
G4bool fReadyForTransients
G4bool fTransientsDrawnThisEvent
G4bool fTransientsDrawnThisRun
G4bool fProcessingSolid
G4bool fProcessing2D
G4VModelfpModel
G4Transform3D fObjectTransformation
G4int fNestingDepth
const G4VisAttributesfpVisAttribs
const G4Transform3D fIdentityTransformation
std::map< G4VPhysicalVolume *, G4StringfProblematicVolumes
Protected Attributes inherited from G4VGraphicsScene
G4int fMaxGeometryDepth = 0

Friends

class G4VViewer
std::ostream & operator<< (std::ostream &os, const G4VSceneHandler &s)

Detailed Description

Definition at line 54 of file G4VSceneHandler.hh.

Member Enumeration Documentation

◆ MarkerSizeType

Enumerator
world 
screen 

Definition at line 61 of file G4VSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4VSceneHandler()

G4VSceneHandler::G4VSceneHandler ( G4VGraphicsSystem & system,
G4int id,
const G4String & name = "" )

Definition at line 99 of file G4VSceneHandler.cc.

99 :
100 fSystem (system),
101 fSceneHandlerId (id),
102 fViewCount (0),
103 fpViewer (0),
104 fpScene (0),
105 fMarkForClearingTransientStore (true), // Ready for first
106 // ClearTransientStoreIfMarked(),
107 // e.g., at end of run (see
108 // G4VisManager.cc).
109 fReadyForTransients (true), // Only false while processing scene.
110 fProcessingSolid (false),
111 fProcessing2D (false),
112 fpModel (0),
113 fNestingDepth (0),
114 fpVisAttribs (0)
115{
116 G4VisManager* pVMan = G4VisManager::GetInstance ();
117 fpScene = pVMan -> GetCurrentScene ();
118 if (name == "") {
119 std::ostringstream ost;
120 ost << fSystem.GetName () << '-' << fSceneHandlerId;
121 fName = ost.str();
122 }
123 else {
124 fName = name;
125 }
128}
G4bool fTransientsDrawnThisEvent
const G4int fSceneHandlerId
G4bool fMarkForClearingTransientStore
const G4VisAttributes * fpVisAttribs
G4VGraphicsSystem & fSystem
G4bool GetTransientsDrawnThisEvent() const
G4bool GetTransientsDrawnThisRun() const
static G4VisManager * GetInstance()
const char * name(G4int ptype)

Referenced by G4DAWNFILESceneHandler::G4DAWNFILESceneHandler(), G4GMocrenFileSceneHandler::G4GMocrenFileSceneHandler(), G4OpenGLSceneHandler::G4OpenGLSceneHandler(), G4OpenInventorSceneHandler::G4OpenInventorSceneHandler(), G4RayTracerSceneHandler::G4RayTracerSceneHandler(), G4VRML2FileSceneHandler::G4VRML2FileSceneHandler(), G4VtkSceneHandler::G4VtkSceneHandler(), G4VTreeSceneHandler::G4VTreeSceneHandler(), G4VViewer, and G4ToolsSGSceneHandler::Messenger::SetNewValue().

◆ ~G4VSceneHandler()

G4VSceneHandler::~G4VSceneHandler ( )
virtual

Definition at line 130 of file G4VSceneHandler.cc.

130 {
131 G4VViewer* last;
132 while( ! fViewerList.empty() ) {
133 last = fViewerList.back();
134 fViewerList.pop_back();
135 delete last;
136 }
137}
friend class G4VViewer
G4ViewerList fViewerList

Member Function Documentation

◆ AddCompound() [1/6]

void G4VSceneHandler::AddCompound ( const G4Mesh & mesh)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4OpenInventorSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 429 of file G4VSceneHandler.cc.

430{
431 G4warn <<
432 "There has been an attempt to draw a mesh with option \""
433 << fpViewer->GetViewParameters().GetSpecialMeshRenderingOption()
434 << "\":\n" << mesh
435 << "but it is not of a recognised type or is not implemented"
436 "\nby the current graphics driver. Instead we draw its"
437 "\ncontainer \"" << mesh.GetContainerVolume()->GetName() << "\"."
438 << G4endl;
439 const auto& pv = mesh.GetContainerVolume();
440 const auto& lv = pv->GetLogicalVolume();
441 const auto& solid = lv->GetSolid();
442 const auto& transform = mesh.GetTransform();
443 // Make sure container is visible
444 G4VisAttributes tmpVisAtts; // Visible, white, not forced.
445 const auto& saveVisAtts = lv->GetVisAttributes();
446 if (saveVisAtts) {
447 tmpVisAtts = *saveVisAtts;
448 tmpVisAtts.SetVisibility(true);
449 auto colour = saveVisAtts->GetColour();
450 colour.SetAlpha(1.);
451 tmpVisAtts.SetColour(colour);
452 }
453 // Draw container
454 PreAddSolid(transform,tmpVisAtts);
455 solid->DescribeYourselfTo(*this);
456 PostAddSolid();
457 // Restore vis attributes
458 lv->SetVisAttributes(saveVisAtts);
459}
#define G4warn
Definition G4Scene.cc:41
#define G4endl
Definition G4ios.hh:67
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetContainerVolume() const
Definition G4Mesh.hh:73
const G4Transform3D & GetTransform() const
Definition G4Mesh.hh:77
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
virtual void PostAddSolid()
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)

◆ AddCompound() [2/6]

void G4VSceneHandler::AddCompound ( const G4THitsMap< G4double > & hits)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4OpenInventorSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 345 of file G4VSceneHandler.cc.

345 {
346 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
347 //G4cout << "AddCompound: hits: " << &hits << G4endl;
348 G4bool scoreMapHits = false;
349 G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManagerIfExist();
350 if (scoringManager) {
351 std::size_t nMeshes = scoringManager->GetNumberOfMesh();
352 for (std::size_t iMesh = 0; iMesh < nMeshes; ++iMesh) {
353 G4VScoringMesh* mesh = scoringManager->GetMesh((G4int)iMesh);
354 if (mesh && mesh->IsActive()) {
355 MeshScoreMap scoreMap = mesh->GetScoreMap();
356 const G4String& mapNam = const_cast<G4THitsMap<G4double>&>(hits).GetName();
357 for(const auto& i : scoreMap) {
358 const G4String& scoreMapName = i.first;
359 if (scoreMapName == mapNam) {
360 G4DefaultLinearColorMap colorMap("G4VSceneHandlerColorMap");
361 scoreMapHits = true;
362 mesh->DrawMesh(scoreMapName, &colorMap);
363 }
364 }
365 }
366 }
367 }
368 if (scoreMapHits) {
369 static G4bool first = true;
370 if (first) {
371 first = false;
372 G4cout <<
373 "Scoring map drawn with default parameters."
374 "\n To get gMocren file for gMocren browser:"
375 "\n /vis/open gMocrenFile"
376 "\n /vis/viewer/flush"
377 "\n Many other options available with /score/draw... commands."
378 "\n You might want to \"/vis/viewer/set/autoRefresh false\"."
379 << G4endl;
380 }
381 } else { // Not score map hits. Just call DrawAllHits.
382 // Cast away const because DrawAllHits is non-const!!!!
383 const_cast<G4THitsMap<G4double>&>(hits).DrawAllHits();
384 }
385}
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
G4VScoringMesh * GetMesh(G4int i) const
std::size_t GetNumberOfMesh() const
static G4ScoringManager * GetScoringManagerIfExist()
const G4String & GetName() const
G4bool IsActive() const
std::map< G4String, RunScore * > MeshScoreMap
void DrawMesh(const G4String &psName, G4VScoreColorMap *colorMap, G4int axflg=111)
MeshScoreMap GetScoreMap() const

◆ AddCompound() [3/6]

void G4VSceneHandler::AddCompound ( const G4THitsMap< G4StatDouble > & hits)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4OpenInventorSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 387 of file G4VSceneHandler.cc.

387 {
388 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
389 //G4cout << "AddCompound: hits: " << &hits << G4endl;
390 G4bool scoreMapHits = false;
391 G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManagerIfExist();
392 if (scoringManager) {
393 std::size_t nMeshes = scoringManager->GetNumberOfMesh();
394 for (std::size_t iMesh = 0; iMesh < nMeshes; ++iMesh) {
395 G4VScoringMesh* mesh = scoringManager->GetMesh((G4int)iMesh);
396 if (mesh && mesh->IsActive()) {
397 MeshScoreMap scoreMap = mesh->GetScoreMap();
398 for(const auto& i : scoreMap) {
399 const G4String& scoreMapName = i.first;
400 const G4THitsMap<G4StatDouble>* foundHits = i.second;
401 if (foundHits == &hits) {
402 G4DefaultLinearColorMap colorMap("G4VSceneHandlerColorMap");
403 scoreMapHits = true;
404 mesh->DrawMesh(scoreMapName, &colorMap);
405 }
406 }
407 }
408 }
409 }
410 if (scoreMapHits) {
411 static G4bool first = true;
412 if (first) {
413 first = false;
414 G4cout <<
415 "Scoring map drawn with default parameters."
416 "\n To get gMocren file for gMocren browser:"
417 "\n /vis/open gMocrenFile"
418 "\n /vis/viewer/flush"
419 "\n Many other options available with /score/draw... commands."
420 "\n You might want to \"/vis/viewer/set/autoRefresh false\"."
421 << G4endl;
422 }
423 } else { // Not score map hits. Just call DrawAllHits.
424 // Cast away const because DrawAllHits is non-const!!!!
425 const_cast<G4THitsMap<G4StatDouble>&>(hits).DrawAllHits();
426 }
427}

◆ AddCompound() [4/6]

void G4VSceneHandler::AddCompound ( const G4VDigi & digi)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4OpenInventorSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 340 of file G4VSceneHandler.cc.

340 {
341 // Cast away const because Draw is non-const!!!!
342 const_cast<G4VDigi&>(digi).Draw();
343}

◆ AddCompound() [5/6]

void G4VSceneHandler::AddCompound ( const G4VHit & hit)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4OpenInventorSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 335 of file G4VSceneHandler.cc.

335 {
336 // Cast away const because Draw is non-const!!!!
337 const_cast<G4VHit&>(hit).Draw();
338}

◆ AddCompound() [6/6]

void G4VSceneHandler::AddCompound ( const G4VTrajectory & traj)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4OpenInventorSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 323 of file G4VSceneHandler.cc.

323 {
324 G4TrajectoriesModel* trajectoriesModel =
325 dynamic_cast<G4TrajectoriesModel*>(fpModel);
326 if (trajectoriesModel)
327 traj.DrawTrajectory();
328 else {
330 ("G4VSceneHandler::AddCompound(const G4VTrajectory&)",
331 "visman0105", FatalException, "Not a G4TrajectoriesModel.");
332 }
333}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
virtual void DrawTrajectory() const

Referenced by G4GMocrenFileSceneHandler::AddCompound(), G4GMocrenFileSceneHandler::AddCompound(), G4GMocrenFileSceneHandler::AddCompound(), G4OpenGLSceneHandler::AddCompound(), G4OpenGLSceneHandler::AddCompound(), G4OpenGLSceneHandler::AddCompound(), G4OpenGLSceneHandler::AddCompound(), G4OpenGLSceneHandler::AddCompound(), G4VRML2FileSceneHandler::AddSolid(), G4OpenInventorSceneHandler::G4OpenInventorViewer, and StandardSpecialMeshRendering().

◆ AddPrimitive() [1/7]

◆ AddPrimitive() [2/7]

void G4VSceneHandler::AddPrimitive ( const G4Plotter & )
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLImmediateSceneHandler, G4OpenGLSceneHandler, G4OpenGLStoredSceneHandler, G4OpenInventorSceneHandler, G4RayTracerSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, G4VtkSceneHandler, and G4VTreeSceneHandler.

Definition at line 508 of file G4VSceneHandler.cc.

508 {
509 G4warn << "WARNING: Plotter not implemented for " << fSystem.GetName() << G4endl;
510 G4warn << " Open a plotter-aware graphics system or remove plotter with" << G4endl;
511 G4warn << " /vis/scene/removeModel Plotter" << G4endl;
512}

◆ AddPrimitive() [3/7]

◆ AddPrimitive() [4/7]

◆ AddPrimitive() [5/7]

void G4VSceneHandler::AddPrimitive ( const G4Polymarker & polymarker)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLImmediateSceneHandler, G4OpenGLSceneHandler, G4OpenGLStoredSceneHandler, G4OpenInventorSceneHandler, G4RayTracerSceneHandler, G4ToolsSGSceneHandler, G4VRML2FileSceneHandler, G4VtkQtSceneHandler, G4VtkSceneHandler, and G4VTreeSceneHandler.

Definition at line 465 of file G4VSceneHandler.cc.

465 {
466 switch (polymarker.GetMarkerType()) {
467 default:
469 {
470 G4Circle dot (polymarker);
471 dot.SetWorldSize (0.);
472 dot.SetScreenSize (0.1); // Very small circle.
473 for (const auto& iPoint : polymarker) {
474 dot.SetPosition (iPoint);
475 AddPrimitive (dot);
476 }
477 }
478 break;
480 {
481 G4Circle circle (polymarker); // Default circle
482 for (const auto& iPoint : polymarker) {
483 circle.SetPosition (iPoint);
484 AddPrimitive (circle);
485 }
486 }
487 break;
489 {
490 G4Square square (polymarker); // Default square
491 for (const auto& iPoint : polymarker) {
492 square.SetPosition (iPoint);
493 AddPrimitive (square);
494 }
495 }
496 break;
497 }
498}
MarkerType GetMarkerType() const
virtual void AddPrimitive(const G4Polyline &)=0

◆ AddPrimitive() [6/7]

◆ AddPrimitive() [7/7]

◆ AddSolid() [1/14]

void G4VSceneHandler::AddSolid ( const G4Box & box)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 252 of file G4VSceneHandler.cc.

252 {
253 AddSolidT (box);
254 // If your graphics system is sophisticated enough to handle a
255 // particular solid shape as a primitive, in your derived class write a
256 // function to override this.
257 // Your function might look like this...
258 // void G4MySceneHandler::AddSolid (const G4Box& box) {
259 // Get and check applicable vis attributes.
260 // fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
261 // Do not draw if not visible.
262 // if (fpVisAttribs->IsVisible()) {
263 // Get parameters of appropriate object, e.g.:
264 // G4double dx = box.GetXHalfLength ();
265 // G4double dy = box.GetYHalfLength ();
266 // G4double dz = box.GetZHalfLength ();
267 // ...
268 // and Draw or Store in your display List.
269}
void AddSolidT(const T &solid)

Referenced by G4GMocrenFileSceneHandler::AddSolid(), G4VtkSceneHandler::AddSolid(), G4DAWNFILESceneHandler::EndPrimitives(), and G4VRML2FileSceneHandler::G4VRML2FileViewer.

◆ AddSolid() [2/14]

void G4VSceneHandler::AddSolid ( const G4Cons & cons)
virtual

◆ AddSolid() [3/14]

void G4VSceneHandler::AddSolid ( const G4Ellipsoid & ellipsoid)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 303 of file G4VSceneHandler.cc.

303 {
304 AddSolidWithAuxiliaryEdges (ellipsoid);
305}
void AddSolidWithAuxiliaryEdges(const T &solid)

◆ AddSolid() [4/14]

void G4VSceneHandler::AddSolid ( const G4Orb & orb)
virtual

◆ AddSolid() [5/14]

void G4VSceneHandler::AddSolid ( const G4Para & para)
virtual

◆ AddSolid() [6/14]

void G4VSceneHandler::AddSolid ( const G4Polycone & polycone)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 307 of file G4VSceneHandler.cc.

307 {
308 AddSolidT (polycone);
309}

◆ AddSolid() [7/14]

void G4VSceneHandler::AddSolid ( const G4Polyhedra & polyhedra)
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLSceneHandler, G4VRML2FileSceneHandler, and G4VtkSceneHandler.

Definition at line 311 of file G4VSceneHandler.cc.

311 {
312 AddSolidT (polyhedra);
313}

◆ AddSolid() [8/14]

void G4VSceneHandler::AddSolid ( const G4Sphere & sphere)
virtual

◆ AddSolid() [9/14]

void G4VSceneHandler::AddSolid ( const G4TessellatedSolid & tess)
virtual

◆ AddSolid() [10/14]

void G4VSceneHandler::AddSolid ( const G4Torus & torus)
virtual

◆ AddSolid() [11/14]

void G4VSceneHandler::AddSolid ( const G4Trap & trap)
virtual

◆ AddSolid() [12/14]

void G4VSceneHandler::AddSolid ( const G4Trd & trd)
virtual

◆ AddSolid() [13/14]

void G4VSceneHandler::AddSolid ( const G4Tubs & tubs)
virtual

◆ AddSolid() [14/14]

void G4VSceneHandler::AddSolid ( const G4VSolid & solid)
virtual

◆ AddSolidT()

template<class T>
void G4VSceneHandler::AddSolidT ( const T & solid)

Definition at line 225 of file G4VSceneHandler.cc.

227{
228 // Get and check applicable vis attributes.
229 fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
230 RequestPrimitives (solid);
231}
virtual void RequestPrimitives(const G4VSolid &solid)

Referenced by AddSolid(), AddSolid(), AddSolid(), AddSolid(), AddSolid(), AddSolid(), AddSolid(), AddSolid(), AddSolid(), and AddSolid().

◆ AddSolidWithAuxiliaryEdges()

template<class T>
void G4VSceneHandler::AddSolidWithAuxiliaryEdges ( const T & solid)

Definition at line 233 of file G4VSceneHandler.cc.

235{
236 // Get and check applicable vis attributes.
237 fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
238 // Draw with auxiliary edges unless otherwise specified.
239 if (!fpVisAttribs->IsForceAuxEdgeVisible()) {
240 // Create a vis atts object for the modified vis atts.
241 // It is static so that we may return a reliable pointer to it.
242 static G4VisAttributes visAttsWithAuxEdges;
243 // Initialise it with the current vis atts and reset the pointer.
244 visAttsWithAuxEdges = *fpVisAttribs;
245 // Force auxiliary edges visible.
246 visAttsWithAuxEdges.SetForceAuxEdgeVisible();
247 fpVisAttribs = &visAttsWithAuxEdges;
248 }
249 RequestPrimitives (solid);
250}
void SetForceAuxEdgeVisible(G4bool=true)

Referenced by AddSolid(), AddSolid(), AddSolid(), and AddSolid().

◆ AddViewerToList()

void G4VSceneHandler::AddViewerToList ( G4VViewer * pView)

Definition at line 461 of file G4VSceneHandler.cc.

461 {
462 fViewerList.push_back (pViewer);
463}

◆ BeginModeling()

◆ BeginPrimitives()

void G4VSceneHandler::BeginPrimitives ( const G4Transform3D & objectTransformation = G4Transform3D())
virtual

Implements G4VGraphicsScene.

Reimplemented in G4DAWNFILESceneHandler, G4GMocrenFileSceneHandler, G4OpenGLImmediateSceneHandler, G4OpenGLSceneHandler, G4OpenGLStoredSceneHandler, G4OpenInventorSceneHandler, and G4VRML2FileSceneHandler.

Definition at line 165 of file G4VSceneHandler.cc.

166 {
167 //static G4int count = 0;
168 //G4cout << "G4VSceneHandler::BeginPrimitives: " << count++ << G4endl;
170 if (fNestingDepth > 1)
172 ("G4VSceneHandler::BeginPrimitives",
173 "visman0101", FatalException,
174 "Nesting detected. It is illegal to nest Begin/EndPrimitives.");
175 fObjectTransformation = objectTransformation;
176}
G4Transform3D fObjectTransformation

Referenced by G4GMocrenFileSceneHandler::BeginPrimitives(), G4OpenGLSceneHandler::BeginPrimitives(), G4OpenInventorSceneHandler::BeginPrimitives(), Draw3DRectMeshAsDots(), Draw3DRectMeshAsSurfaces(), DrawTetMeshAsDots(), DrawTetMeshAsSurfaces(), RequestPrimitives(), and StandardSpecialMeshRendering().

◆ BeginPrimitives2D()

void G4VSceneHandler::BeginPrimitives2D ( const G4Transform3D & objectTransformation = G4Transform3D())
virtual

Implements G4VGraphicsScene.

Reimplemented in G4OpenGLImmediateSceneHandler, G4OpenGLSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 189 of file G4VSceneHandler.cc.

190 {
192 if (fNestingDepth > 1)
194 ("G4VSceneHandler::BeginPrimitives2D",
195 "visman0103", FatalException,
196 "Nesting detected. It is illegal to nest Begin/EndPrimitives.");
197 fObjectTransformation = objectTransformation;
198 fProcessing2D = true;
199}

Referenced by G4OpenGLSceneHandler::BeginPrimitives2D().

◆ ClearStore()

◆ ClearTransientStore()

◆ CreateCutawaySolid()

G4DisplacedSolid * G4VSceneHandler::CreateCutawaySolid ( )
protectedvirtual

Reimplemented in G4OpenGLSceneHandler.

Definition at line 1052 of file G4VSceneHandler.cc.

1053{
1054 const auto& vp = fpViewer->GetViewParameters();
1055 const auto& nPlanes = vp.GetCutawayPlanes().size();
1056
1057 if (nPlanes == 0) return nullptr;
1058
1059 std::vector<G4DisplacedSolid*> cutaway_solids;
1060
1061 G4double radius = fpScene->GetExtent().GetExtentRadius();
1062 G4double safe = radius + fpScene->GetExtent().GetExtentCentre().mag();
1063 auto cutawayBox = new G4Box("_cutaway_box", safe, safe, safe);
1064
1065 // if (vp.GetCutawayMode() == G4ViewParameters::cutawayUnion) we need a subtractor that is
1066 // the intersection of displaced cutaway boxes, displaced so that a subtraction keeps the
1067 // positive values a*x+b*y+c*z+d>0, so we have to invert the normal. This may appear
1068 // "back to front". The parameter "cutawayUnion" means "the union of volumes
1069 // that remain *after* cutaway", because we base the concept on OpenGL cutaway planes and make
1070 // a "union" of what remains by superimposing up to 3 passes - see G4OpenGLViewer::SetView
1071 // and G4OpenGLImmediate/StoredViewer::ProcessView. So we have to create a subtractor
1072 // that is the intersection of inverted cutaway planes.
1073
1074 // Conversely, if (vp.GetCutawayMode() == G4ViewParameters::cutawayIntersection) we have to
1075 // create an intersector that is the intersector of intersected non-inverted cutaway planes.
1076
1077 for (size_t plane_no = 0; plane_no < nPlanes; plane_no++)
1078 {
1079 const G4Plane3D& sp = vp.GetCutawayPlanes()[plane_no];
1080 G4Transform3D requiredTransform;
1081 G4ThreeVector normal;
1082 switch (vp.GetCutawayMode()) {
1084 normal = -sp.normal(); // Invert normal - we want a subtractor
1085 requiredTransform = G4Translate3D(normal*(safe + sp.d())) *
1086 G4Rotate3D(G4ThreeVector(0,0,1), G4ThreeVector(0,1,0), normal, normal.orthogonal());
1087 break;
1089 normal = sp.normal();
1090 requiredTransform = G4Translate3D(normal*(safe - sp.d())) *
1091 G4Rotate3D(G4ThreeVector(0,0,1), G4ThreeVector(0,1,0), normal, normal.orthogonal());
1092 break;
1093 }
1094 cutaway_solids.push_back
1095 (new G4DisplacedSolid("_displaced_cutaway_box", cutawayBox, requiredTransform));
1096 }
1097
1098 if (nPlanes == 1) return (G4DisplacedSolid*) cutaway_solids[0];
1099
1100 G4IntersectionSolid *union2 = nullptr, *union3 = nullptr;
1101 G4IntersectionSolid *intersection2 = nullptr, *intersection3 = nullptr;
1102 switch (vp.GetCutawayMode()) {
1103
1105 // Here we make a subtractor of intersections of inverted cutaway planes.
1106 union2 = new G4IntersectionSolid("_union_2", cutaway_solids[0], cutaway_solids[1]);
1107 if (nPlanes == 2) return (G4DisplacedSolid*)union2;
1108 else if (nPlanes == 3) {
1109 union3 = new G4IntersectionSolid("_union_3", union2, cutaway_solids[2]);
1110 return (G4DisplacedSolid*)union3;
1111 }
1112 break;
1113
1115 // And here we make an intersector of intersections of non-inverted cutaway planes.
1116 intersection2
1117 = new G4IntersectionSolid("_intersection_2", cutaway_solids[0], cutaway_solids[1]);
1118 if (nPlanes == 2) return (G4DisplacedSolid*)intersection2;
1119 else if (nPlanes == 3) {
1120 intersection3
1121 = new G4IntersectionSolid("_intersection_3", intersection2, cutaway_solids[2]);
1122 return (G4DisplacedSolid*)intersection3;
1123 }
1124 break;
1125 }
1126
1127 G4Exception("G4VSceneHandler::CreateCutawaySolid", "visman0107", JustWarning,
1128 "Not programmed for more than 3 cutaway planes");
1129 return nullptr;
1130}
@ JustWarning
HepGeom::Plane3D< G4double > G4Plane3D
Definition G4Plane3D.hh:34
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Transform3D G4Transform3D
HepGeom::Translate3D G4Translate3D
HepGeom::Rotate3D G4Rotate3D
double G4double
Definition G4Types.hh:83
Hep3Vector orthogonal() const

Referenced by CreateModelingParameters().

◆ CreateModelingParameters()

G4ModelingParameters * G4VSceneHandler::CreateModelingParameters ( )

Definition at line 947 of file G4VSceneHandler.cc.

948{
949 // Create modeling parameters from View Parameters...
950 if (!fpViewer) return NULL;
951
952 const G4ViewParameters& vp = fpViewer -> GetViewParameters ();
953
954 // Convert drawing styles...
955 G4ModelingParameters::DrawingStyle modelDrawingStyle =
957 switch (vp.GetDrawingStyle ()) {
958 default:
960 modelDrawingStyle = G4ModelingParameters::wf;
961 break;
963 modelDrawingStyle = G4ModelingParameters::hlr;
964 break;
966 modelDrawingStyle = G4ModelingParameters::hsr;
967 break;
969 modelDrawingStyle = G4ModelingParameters::hlhsr;
970 break;
972 modelDrawingStyle = G4ModelingParameters::cloud;
973 break;
974 }
975
976 // Decide if covered daughters are really to be culled...
977 G4bool reallyCullCovered =
978 vp.IsCullingCovered() // Culling daughters depends also on...
979 && !vp.IsSection () // Sections (DCUT) not requested.
980 && !vp.IsCutaway () // Cutaways not requested.
981 ;
982
983 G4ModelingParameters* pModelingParams = new G4ModelingParameters
985 modelDrawingStyle,
986 vp.IsCulling (),
987 vp.IsCullingInvisible (),
988 vp.IsDensityCulling (),
989 vp.GetVisibleDensity (),
990 reallyCullCovered,
991 vp.GetNoOfSides ()
992 );
993
994 pModelingParams->SetNumberOfCloudPoints(vp.GetNumberOfCloudPoints());
995 pModelingParams->SetWarning
997
998 pModelingParams->SetCBDAlgorithmNumber(vp.GetCBDAlgorithmNumber());
999 pModelingParams->SetCBDParameters(vp.GetCBDParameters());
1000
1001 pModelingParams->SetExplodeFactor(vp.GetExplodeFactor());
1002 pModelingParams->SetExplodeCentre(vp.GetExplodeCentre());
1003
1004 pModelingParams->SetSectionSolid(CreateSectionSolid());
1005
1010 }
1011
1012 pModelingParams->SetCutawaySolid(CreateCutawaySolid());
1013 // The polyhedron objects are deleted in the modeling parameters destructor.
1014
1016
1017 pModelingParams->SetTimeParameters(vp.GetTimeParameters());
1018
1019 pModelingParams->SetSpecialMeshRendering(vp.IsSpecialMeshRendering());
1020 pModelingParams->SetSpecialMeshVolumes(vp.GetSpecialMeshVolumes());
1021
1022 pModelingParams->SetTransparencyByDepth(vp.GetTransparencyByDepth());
1024
1025 return pModelingParams;
1026}
void SetCBDParameters(const std::vector< G4double > &)
void SetWarning(G4bool)
void SetTransparencyByDepth(G4double)
void SetNumberOfCloudPoints(G4int)
void SetCBDAlgorithmNumber(G4int)
void SetExplodeFactor(G4double explodeFactor)
void SetVisAttributesModifiers(const std::vector< VisAttributesModifier > &)
void SetExplodeCentre(const G4Point3D &explodeCentre)
void SetCutawayMode(CutawayMode)
void SetCutawaySolid(G4DisplacedSolid *pCutawaySolid)
void SetTimeParameters(const TimeParameters &)
void SetSectionSolid(G4DisplacedSolid *pSectionSolid)
void SetSpecialMeshVolumes(const std::vector< PVNameCopyNo > &)
void SetSpecialMeshRendering(G4bool)
void SetTransparencyByDepthOption(G4int)
virtual G4DisplacedSolid * CreateSectionSolid()
virtual G4DisplacedSolid * CreateCutawaySolid()
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
G4int GetNoOfSides() const
G4bool IsSpecialMeshRendering() const
CutawayMode GetCutawayMode() const
G4double GetExplodeFactor() const
const G4ModelingParameters::TimeParameters & GetTimeParameters() const
G4int GetNumberOfCloudPoints() const
G4bool IsCutaway() const
G4bool IsSection() const
G4bool IsCulling() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
const std::vector< G4ModelingParameters::PVNameCopyNo > & GetSpecialMeshVolumes() const
G4int GetTransparencyByDepthOption() const
G4bool IsCullingInvisible() const
const G4VisAttributes * GetDefaultVisAttributes() const
G4bool IsDensityCulling() const
G4double GetVisibleDensity() const
const G4Point3D & GetExplodeCentre() const
G4bool IsCullingCovered() const
DrawingStyle GetDrawingStyle() const
G4double GetTransparencyByDepth() const
static Verbosity GetVerbosity()

Referenced by DrawEndOfRunModels(), DrawEvent(), and ProcessScene().

◆ CreateSectionSolid()

G4DisplacedSolid * G4VSceneHandler::CreateSectionSolid ( )
protectedvirtual

Reimplemented in G4OpenGLSceneHandler.

Definition at line 1028 of file G4VSceneHandler.cc.

1029{
1030 G4DisplacedSolid* sectioner = 0;
1031
1032 const G4ViewParameters& vp = fpViewer->GetViewParameters();
1033 if (vp.IsSection () ) {
1034
1035 G4double radius = fpScene->GetExtent().GetExtentRadius();
1036 G4double safe = radius + fpScene->GetExtent().GetExtentCentre().mag();
1037 G4VSolid* sectionBox =
1038 new G4Box("_sectioner", safe, safe, 1.e-5 * radius); // Thin in z-plane...
1039
1040 const G4Plane3D& sp = vp.GetSectionPlane ();
1041 G4ThreeVector normal = sp.normal();
1042 G4Transform3D requiredTransform = G4Translate3D(normal*(-sp.d())) *
1043 G4Rotate3D(G4ThreeVector(0,0,1), G4ThreeVector(0,1,0), normal, normal.orthogonal());
1044
1045 sectioner = new G4DisplacedSolid
1046 ("_displaced_sectioning_box", sectionBox, requiredTransform);
1047 }
1048
1049 return sectioner;
1050}
const G4Plane3D & GetSectionPlane() const

Referenced by CreateModelingParameters(), and G4OpenGLSceneHandler::CreateSectionSolid().

◆ Draw3DRectMeshAsDots()

void G4VSceneHandler::Draw3DRectMeshAsDots ( const G4Mesh & mesh)
protected

Definition at line 1473 of file G4VSceneHandler.cc.

1476{
1477 // Check
1478 if (mesh.GetMeshType() != G4Mesh::rectangle &&
1481 ed << "Called with a mesh that is not rectangular:" << mesh;
1482 G4Exception("G4VSceneHandler::Draw3DRectMeshAsDots","visman0108",JustWarning,ed);
1483 return;
1484 }
1485
1486 static G4bool firstPrint = true;
1487 const auto& verbosity = G4VisManager::GetVerbosity();
1488 G4bool print = firstPrint && verbosity >= G4VisManager::errors;
1489 if (print) {
1490 G4cout
1491 << "Special case drawing of 3D rectangular G4VNestedParameterisation as dots:"
1492 << '\n' << mesh
1493 << G4endl;
1494 }
1495
1496 const auto& container = mesh.GetContainerVolume();
1497
1498 // This map is static so that once filled it stays filled.
1499 static std::map<G4String,std::map<const G4Material*,G4Polymarker>> dotsByMaterialAndMesh;
1500 auto& dotsByMaterial = dotsByMaterialAndMesh[mesh.GetContainerVolume()->GetName()];
1501
1502 // Fill map if not already filled
1503 if (dotsByMaterial.empty()) {
1504
1505 // Get positions and material one cell at a time (using PseudoSceneFor3DRectMeshPositions).
1506 // The pseudo scene allows a "private" descent into the parameterisation.
1507 // Instantiate a temporary G4PhysicalVolumeModel
1508 G4ModelingParameters tmpMP;
1509 tmpMP.SetCulling(true); // This avoids drawing transparent...
1510 tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
1511 const G4bool useFullExtent = true; // To avoid calculating the extent
1512 G4PhysicalVolumeModel tmpPVModel
1513 (container,
1515 G4Transform3D(), // so that positions are in local coordinates
1516 &tmpMP,
1517 useFullExtent);
1518 // Accumulate information in temporary maps by material
1519 std::multimap<const G4Material*,const G4ThreeVector> positionByMaterial;
1520 std::map<const G4Material*,G4VSceneHandler::NameAndVisAtts> nameAndVisAttsByMaterial;
1521 // Instantiate the pseudo scene
1523 (&tmpPVModel,&mesh,positionByMaterial,nameAndVisAttsByMaterial);
1524 // Make private descent into the parameterisation
1525 tmpPVModel.DescribeYourselfTo(pseudoScene);
1526 // Now we have a map of positions by material.
1527 // Also a map of name and colour by material.
1528
1529 const auto& prms = mesh.GetThreeDRectParameters();
1530 const auto& halfX = prms.fHalfX;
1531 const auto& halfY = prms.fHalfY;
1532 const auto& halfZ = prms.fHalfZ;
1533
1534 // Fill the permanent (static) map of dots by material
1535 G4int nDotsTotal = 0;
1536 for (const auto& entry: nameAndVisAttsByMaterial) {
1537 G4int nDots = 0;
1538 const auto& material = entry.first;
1539 const auto& nameAndVisAtts = nameAndVisAttsByMaterial[material];
1540 const auto& name = nameAndVisAtts.fName;
1541 const auto& visAtts = nameAndVisAtts.fVisAtts;
1542 G4Polymarker dots;
1543 dots.SetInfo(name);
1544 dots.SetVisAttributes(visAtts);
1546 // Enter empty polymarker into the map
1547 dotsByMaterial[material] = dots;
1548 // Now fill it in situ
1549 auto& dotsInMap = dotsByMaterial[material];
1550 const auto& range = positionByMaterial.equal_range(material);
1551 for (auto posByMat = range.first; posByMat != range.second; ++posByMat) {
1552 dotsInMap.push_back(GetPointInBox(posByMat->second, halfX, halfY, halfZ));
1553 ++nDots;
1554 }
1555
1556 if (print) {
1557 G4cout
1558 << std::setw(30) << std::left << name.substr(0,30) << std::right
1559 << ": " << std::setw(7) << nDots << " dots"
1560 << ": colour " << std::fixed << std::setprecision(2)
1561 << visAtts.GetColour() << std::defaultfloat
1562 << G4endl;
1563 }
1564
1565 nDotsTotal += nDots;
1566 }
1567
1568 if (print) {
1569 G4cout << "Total number of dots: " << nDotsTotal << G4endl;
1570 }
1571 }
1572
1573 // Some subsequent expressions apply only to G4PhysicalVolumeModel
1574 auto pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1575
1576 G4String parameterisationName;
1577 if (pPVModel) {
1578 parameterisationName = pPVModel->GetFullPVPath().back().GetPhysicalVolume()->GetName();
1579 }
1580
1581 // Draw the dots by material
1582 // Ensure they are "hidden", i.e., use the z-buffer as non-marker primitives do
1583 auto keepVP = fpViewer->GetViewParameters();
1584 auto vp = fpViewer->GetViewParameters();
1585 vp.SetMarkerHidden();
1586 fpViewer->SetViewParameters(vp);
1587 // Now we transform to world coordinates
1589 for (const auto& entry: dotsByMaterial) {
1590 const auto& dots = entry.second;
1591 // The current "leaf" node in the PVPath is the parameterisation. Here it has
1592 // been converted into polymarkers by material. So...temporarily...change
1593 // its name to that of the material (whose name has been stored in Info)
1594 // so that its appearance in the scene tree of, e.g., G4OpenGLQtViewer, has
1595 // an appropriate name and its visibility and colour may be changed.
1596 if (pPVModel) {
1597 const auto& fullPVPath = pPVModel->GetFullPVPath();
1598 auto leafPV = fullPVPath.back().GetPhysicalVolume();
1599 leafPV->SetName(dots.GetInfo());
1600 }
1601 // Add dots to the scene
1602 AddPrimitive(dots);
1603 }
1604 EndPrimitives ();
1605 // Restore view parameters
1606 fpViewer->SetViewParameters(keepVP);
1607 // Restore parameterisation name
1608 if (pPVModel) {
1609 pPVModel->GetFullPVPath().back().GetPhysicalVolume()->SetName(parameterisationName);
1610 }
1611
1612 firstPrint = false;
1613 return;
1614}
std::ostringstream G4ExceptionDescription
void print(G4double elem)
MeshType GetMeshType() const
Definition G4Mesh.hh:75
@ rectangle
Definition G4Mesh.hh:53
@ nested3DRectangular
Definition G4Mesh.hh:54
const ThreeDRectangleParameters & GetThreeDRectParameters() const
Definition G4Mesh.hh:78
void SetCulling(G4bool)
void SetCullingInvisible(G4bool)
void SetMarkerType(MarkerType)
virtual void EndPrimitives()
G4ThreeVector GetPointInBox(const G4ThreeVector &pos, G4double halfX, G4double halfY, G4double halfZ) const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())
void SetVisAttributes(const G4VisAttributes *)
Definition G4Visible.cc:108
virtual void SetInfo(const G4String &info)
virtual const G4String & GetInfo() const

Referenced by StandardSpecialMeshRendering().

◆ Draw3DRectMeshAsSurfaces()

void G4VSceneHandler::Draw3DRectMeshAsSurfaces ( const G4Mesh & mesh)
protected

Definition at line 1616 of file G4VSceneHandler.cc.

1619{
1620 // Check
1621 if (mesh.GetMeshType() != G4Mesh::rectangle &&
1624 ed << "Called with a mesh that is not rectangular:" << mesh;
1625 G4Exception("G4VSceneHandler::Draw3DRectMeshAsSurfaces","visman0108",JustWarning,ed);
1626 return;
1627 }
1628
1629 static G4bool firstPrint = true;
1630 const auto& verbosity = G4VisManager::GetVerbosity();
1631 G4bool print = firstPrint && verbosity >= G4VisManager::errors;
1632 if (print) {
1633 G4cout
1634 << "Special case drawing of 3D rectangular G4VNestedParameterisation as surfaces:"
1635 << '\n' << mesh
1636 << G4endl;
1637 }
1638
1639 const auto& container = mesh.GetContainerVolume();
1640
1641 // This map is static so that once filled it stays filled.
1642 static std::map<G4String,std::map<const G4Material*,G4Polyhedron>> boxesByMaterialAndMesh;
1643 auto& boxesByMaterial = boxesByMaterialAndMesh[mesh.GetContainerVolume()->GetName()];
1644
1645 // Fill map if not already filled
1646 if (boxesByMaterial.empty()) {
1647
1648 // Get positions and material one cell at a time (using PseudoSceneFor3DRectMeshPositions).
1649 // The pseudo scene allows a "private" descent into the parameterisation.
1650 // Instantiate a temporary G4PhysicalVolumeModel
1651 G4ModelingParameters tmpMP;
1652 tmpMP.SetCulling(true); // This avoids drawing transparent...
1653 tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
1654 const G4bool useFullExtent = true; // To avoid calculating the extent
1655 G4PhysicalVolumeModel tmpPVModel
1656 (container,
1658 G4Transform3D(), // so that positions are in local coordinates
1659 &tmpMP,
1660 useFullExtent);
1661 // Accumulate information in temporary maps by material
1662 std::multimap<const G4Material*,const G4ThreeVector> positionByMaterial;
1663 std::map<const G4Material*,G4VSceneHandler::NameAndVisAtts> nameAndVisAttsByMaterial;
1664 // Instantiate the pseudo scene
1666 (&tmpPVModel,&mesh,positionByMaterial,nameAndVisAttsByMaterial);
1667 // Make private descent into the parameterisation
1668 tmpPVModel.DescribeYourselfTo(pseudoScene);
1669 // Now we have a map of positions by material.
1670 // Also a map of name and colour by material.
1671
1672 const auto& prms = mesh.GetThreeDRectParameters();
1673 const auto& sizeX = 2.*prms.fHalfX;
1674 const auto& sizeY = 2.*prms.fHalfY;
1675 const auto& sizeZ = 2.*prms.fHalfZ;
1676
1677 // Fill the permanent (static) map of boxes by material
1678 G4int nBoxesTotal = 0, nFacetsTotal = 0;
1679 for (const auto& entry: nameAndVisAttsByMaterial) {
1680 G4int nBoxes = 0;
1681 const auto& material = entry.first;
1682 const auto& nameAndVisAtts = nameAndVisAttsByMaterial[material];
1683 const auto& name = nameAndVisAtts.fName;
1684 const auto& visAtts = nameAndVisAtts.fVisAtts;
1685 // Transfer positions into a vector ready for creating polyhedral surface
1686 std::vector<G4ThreeVector> positionsForPolyhedron;
1687 const auto& range = positionByMaterial.equal_range(material);
1688 for (auto posByMat = range.first; posByMat != range.second; ++posByMat) {
1689 const auto& position = posByMat->second;
1690 positionsForPolyhedron.push_back(position);
1691 ++nBoxes;
1692 }
1693 // The polyhedron will be in local coordinates
1694 // Add an empty place-holder to the map and get a reference to it
1695 auto& polyhedron = boxesByMaterial[material];
1696 // Replace with the desired polyhedron (uses efficient "move assignment")
1697 polyhedron = G4PolyhedronBoxMesh(sizeX,sizeY,sizeZ,positionsForPolyhedron);
1698 polyhedron.SetVisAttributes(visAtts);
1699 polyhedron.SetInfo(name);
1700
1701 if (print) {
1702 G4cout
1703 << std::setw(30) << std::left << name.substr(0,30) << std::right
1704 << ": " << std::setw(7) << nBoxes << " boxes"
1705 << " (" << std::setw(7) << 6*nBoxes << " faces)"
1706 << ": reduced to " << std::setw(7) << polyhedron.GetNoFacets() << " facets ("
1707 << std::setw(2) << std::fixed << std::setprecision(2) << 100*polyhedron.GetNoFacets()/(6*nBoxes)
1708 << "%): colour " << std::fixed << std::setprecision(2)
1709 << visAtts.GetColour() << std::defaultfloat
1710 << G4endl;
1711 }
1712
1713 nBoxesTotal += nBoxes;
1714 nFacetsTotal += polyhedron.GetNoFacets();
1715 }
1716
1717 if (print) {
1718 G4cout << "Total number of boxes: " << nBoxesTotal << " (" << 6*nBoxesTotal << " faces)"
1719 << ": reduced to " << nFacetsTotal << " facets ("
1720 << std::setw(2) << std::fixed << std::setprecision(2) << 100*nFacetsTotal/(6*nBoxesTotal) << "%)"
1721 << G4endl;
1722 }
1723 }
1724
1725 // Some subsequent expressions apply only to G4PhysicalVolumeModel
1726 auto pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1727
1728 G4String parameterisationName;
1729 if (pPVModel) {
1730 parameterisationName = pPVModel->GetFullPVPath().back().GetPhysicalVolume()->GetName();
1731 }
1732
1733 // Draw the boxes by material
1734 // Now we transform to world coordinates
1736 for (const auto& entry: boxesByMaterial) {
1737 const auto& poly = entry.second;
1738 // The current "leaf" node in the PVPath is the parameterisation. Here it has
1739 // been converted into polyhedra by material. So...temporarily...change
1740 // its name to that of the material (whose name has been stored in Info)
1741 // so that its appearance in the scene tree of, e.g., G4OpenGLQtViewer, has
1742 // an appropriate name and its visibility and colour may be changed.
1743 if (pPVModel) {
1744 const auto& fullPVPath = pPVModel->GetFullPVPath();
1745 auto leafPV = fullPVPath.back().GetPhysicalVolume();
1746 leafPV->SetName(poly.GetInfo());
1747 }
1748 AddPrimitive(poly);
1749 }
1750 EndPrimitives ();
1751 // Restore parameterisation name
1752 if (pPVModel) {
1753 pPVModel->GetFullPVPath().back().GetPhysicalVolume()->SetName(parameterisationName);
1754 }
1755
1756 firstPrint = false;
1757 return;
1758}

Referenced by StandardSpecialMeshRendering().

◆ DrawEndOfRunModels()

void G4VSceneHandler::DrawEndOfRunModels ( )

Definition at line 918 of file G4VSceneHandler.cc.

919{
920 if(!fpViewer->ReadyToDraw()) return;
921 const std::vector<G4Scene::Model>& EORModelList =
922 fpScene -> GetEndOfRunModelList ();
923 std::size_t nModels = EORModelList.size();
924 if (nModels) {
925 G4ModelingParameters* pMP = CreateModelingParameters();
926 pMP->SetEvent(0);
927 for (std::size_t i = 0; i < nModels; ++i) {
928 if (EORModelList[i].fActive) {
929 fpModel = EORModelList[i].fpModel;
930 fpModel -> SetModelingParameters(pMP);
931
932 // Describe to the current scene handler
933 fpModel -> DescribeYourselfTo (*this);
934
935 // Enter models in the scene tree
936 fpViewer->InsertModelInSceneTree(fpModel);
937
938 // Reset modeling parameters pointer
939 fpModel -> SetModelingParameters(0);
940 }
941 }
942 fpModel = 0;
943 delete pMP;
944 }
945}
void SetEvent(const G4Event *pEvent)
G4ModelingParameters * CreateModelingParameters()

Referenced by ProcessTransients().

◆ DrawEvent()

void G4VSceneHandler::DrawEvent ( const G4Event * event)

Definition at line 889 of file G4VSceneHandler.cc.

890{
891 if(!fpViewer->ReadyToDraw()) return;
892 const std::vector<G4Scene::Model>& EOEModelList =
893 fpScene -> GetEndOfEventModelList ();
894 std::size_t nModels = EOEModelList.size();
895 if (nModels) {
896 G4ModelingParameters* pMP = CreateModelingParameters();
897 pMP->SetEvent(event);
898 for (std::size_t i = 0; i < nModels; ++i) {
899 if (EOEModelList[i].fActive) {
900 fpModel = EOEModelList[i].fpModel;
901 fpModel -> SetModelingParameters(pMP);
902
903 // Describe to the current scene handler
904 fpModel -> DescribeYourselfTo (*this);
905
906 // Enter models in the scene tree
907 fpViewer->InsertModelInSceneTree(fpModel);
908
909 // Reset modeling parameters pointer
910 fpModel -> SetModelingParameters(0);
911 }
912 }
913 fpModel = 0;
914 delete pMP;
915 }
916}

Referenced by G4VisManager::G4VisSubThread(), and ProcessTransients().

◆ DrawTetMeshAsDots()

void G4VSceneHandler::DrawTetMeshAsDots ( const G4Mesh & mesh)
protected

Definition at line 1760 of file G4VSceneHandler.cc.

1763{
1764 // Check
1765 if (mesh.GetMeshType() != G4Mesh::tetrahedron) {
1767 ed << "Called with mesh that is not a tetrahedron mesh:" << mesh;
1768 G4Exception("G4VSceneHandler::DrawTetMeshAsDots","visman0108",JustWarning,ed);
1769 return;
1770 }
1771
1772 static G4bool firstPrint = true;
1773 const auto& verbosity = G4VisManager::GetVerbosity();
1774 G4bool print = firstPrint && verbosity >= G4VisManager::errors;
1775
1776 if (print) {
1777 G4cout
1778 << "Special case drawing of tetrahedron mesh as dots"
1779 << '\n' << mesh
1780 << G4endl;
1781 }
1782
1783 const auto& container = mesh.GetContainerVolume();
1784
1785 // This map is static so that once filled it stays filled.
1786 static std::map<G4String,std::map<const G4Material*,G4Polymarker>> dotsByMaterialAndMesh;
1787 auto& dotsByMaterial = dotsByMaterialAndMesh[mesh.GetContainerVolume()->GetName()];
1788
1789 // Fill map if not already filled
1790 if (dotsByMaterial.empty()) {
1791
1792 // Get vertices and colour one cell at a time (using PseudoSceneForTetVertices).
1793 // The pseudo scene allows a "private" descent into the parameterisation.
1794 // Instantiate a temporary G4PhysicalVolumeModel
1795 G4ModelingParameters tmpMP;
1796 tmpMP.SetCulling(true); // This avoids drawing transparent...
1797 tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
1798 const G4bool useFullExtent = true; // To avoid calculating the extent
1799 G4PhysicalVolumeModel tmpPVModel
1800 (container,
1802 G4Transform3D(), // so that positions are in local coordinates
1803 &tmpMP,
1804 useFullExtent);
1805 // Accumulate information in temporary maps by material
1806 std::multimap<const G4Material*,std::vector<G4ThreeVector>> verticesByMaterial;
1807 std::map<const G4Material*,G4VSceneHandler::NameAndVisAtts> nameAndVisAttsByMaterial;
1808 // Instantiate a pseudo scene
1809 PseudoSceneForTetVertices pseudoScene
1810 (&tmpPVModel,&mesh,verticesByMaterial,nameAndVisAttsByMaterial);
1811 // Make private descent into the parameterisation
1812 tmpPVModel.DescribeYourselfTo(pseudoScene);
1813 // Now we have a map of vertices by material.
1814 // Also a map of name and colour by material.
1815
1816 // Fill the permanent (static) map of dots by material
1817 G4int nDotsTotal = 0;
1818 for (const auto& entry: nameAndVisAttsByMaterial) {
1819 G4int nDots = 0;
1820 const auto& material = entry.first;
1821 const auto& nameAndVisAtts = nameAndVisAttsByMaterial[material];
1822 const auto& name = nameAndVisAtts.fName;
1823 const auto& visAtts = nameAndVisAtts.fVisAtts;
1824 G4Polymarker dots;
1825 dots.SetVisAttributes(visAtts);
1827 dots.SetInfo(name);
1828 // Enter empty polymarker into the map
1829 dotsByMaterial[material] = dots;
1830 // Now fill it in situ
1831 auto& dotsInMap = dotsByMaterial[material];
1832 const auto& range = verticesByMaterial.equal_range(material);
1833 for (auto vByMat = range.first; vByMat != range.second; ++vByMat) {
1834 dotsInMap.push_back(GetPointInTet(vByMat->second));
1835 ++nDots;
1836 }
1837
1838 if (print) {
1839 G4cout
1840 << std::setw(30) << std::left << name.substr(0,30) << std::right
1841 << ": " << std::setw(7) << nDots << " dots"
1842 << ": colour " << std::fixed << std::setprecision(2)
1843 << visAtts.GetColour() << std::defaultfloat
1844 << G4endl;
1845 }
1846
1847 nDotsTotal += nDots;
1848 }
1849
1850 if (print) {
1851 G4cout << "Total number of dots: " << nDotsTotal << G4endl;
1852 }
1853 }
1854
1855 // Some subsequent expressions apply only to G4PhysicalVolumeModel
1856 auto pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1857
1858 G4String parameterisationName;
1859 if (pPVModel) {
1860 parameterisationName = pPVModel->GetFullPVPath().back().GetPhysicalVolume()->GetName();
1861 }
1862
1863 // Draw the dots by material
1864 // Ensure they are "hidden", i.e., use the z-buffer as non-marker primitives do
1865 auto keepVP = fpViewer->GetViewParameters();
1866 auto vp = fpViewer->GetViewParameters();
1867 vp.SetMarkerHidden();
1868 fpViewer->SetViewParameters(vp);
1869
1870 // Now we transform to world coordinates
1872 for (const auto& entry: dotsByMaterial) {
1873 const auto& dots = entry.second;
1874 // The current "leaf" node in the PVPath is the parameterisation. Here it has
1875 // been converted into polymarkers by material. So...temporarily...change
1876 // its name to that of the material (whose name has been stored in Info)
1877 // so that its appearance in the scene tree of, e.g., G4OpenGLQtViewer, has
1878 // an appropriate name and its visibility and colour may be changed.
1879 if (pPVModel) {
1880 const auto& fullPVPath = pPVModel->GetFullPVPath();
1881 auto leafPV = fullPVPath.back().GetPhysicalVolume();
1882 leafPV->SetName(dots.GetInfo());
1883 }
1884 AddPrimitive(dots);
1885 }
1886 EndPrimitives ();
1887
1888 // Restore view parameters
1889 fpViewer->SetViewParameters(keepVP);
1890 // Restore parameterisation name
1891 if (pPVModel) {
1892 pPVModel->GetFullPVPath().back().GetPhysicalVolume()->SetName(parameterisationName);
1893 }
1894
1895 firstPrint = false;
1896 return;
1897}
@ tetrahedron
Definition G4Mesh.hh:57
G4ThreeVector GetPointInTet(const std::vector< G4ThreeVector > &vertices) const

Referenced by StandardSpecialMeshRendering().

◆ DrawTetMeshAsSurfaces()

void G4VSceneHandler::DrawTetMeshAsSurfaces ( const G4Mesh & mesh)
protected

Definition at line 1899 of file G4VSceneHandler.cc.

1902{
1903 // Check
1904 if (mesh.GetMeshType() != G4Mesh::tetrahedron) {
1906 ed << "Called with mesh that is not a tetrahedron mesh:" << mesh;
1907 G4Exception("G4VSceneHandler::DrawTetMeshAsSurfaces","visman0108",JustWarning,ed);
1908 return;
1909 }
1910
1911 static G4bool firstPrint = true;
1912 const auto& verbosity = G4VisManager::GetVerbosity();
1913 G4bool print = firstPrint && verbosity >= G4VisManager::errors;
1914
1915 if (print) {
1916 G4cout
1917 << "Special case drawing of tetrahedron mesh as surfaces"
1918 << '\n' << mesh
1919 << G4endl;
1920 }
1921
1922 // This map is static so that once filled it stays filled.
1923 static std::map<G4String,std::map<const G4Material*,G4Polyhedron>> surfacesByMaterialAndMesh;
1924 auto& surfacesByMaterial = surfacesByMaterialAndMesh[mesh.GetContainerVolume()->GetName()];
1925
1926 // Fill map if not already filled
1927 if (surfacesByMaterial.empty()) {
1928
1929 // Get vertices and colour one cell at a time (using PseudoSceneForTetVertices).
1930 // The pseudo scene allows a "private" descent into the parameterisation.
1931 // Instantiate a temporary G4PhysicalVolumeModel
1932 G4ModelingParameters tmpMP;
1933 tmpMP.SetCulling(true); // This avoids drawing transparent...
1934 tmpMP.SetCullingInvisible(true); // ... or invisble volumes.
1935 const G4bool useFullExtent = true; // To avoid calculating the extent
1936 G4PhysicalVolumeModel tmpPVModel
1937 (mesh.GetContainerVolume(),
1939 G4Transform3D(), // so that positions are in local coordinates
1940 &tmpMP,
1941 useFullExtent);
1942 // Accumulate information in temporary maps by material
1943 std::multimap<const G4Material*,std::vector<G4ThreeVector>> verticesByMaterial;
1944 std::map<const G4Material*,G4VSceneHandler::NameAndVisAtts> nameAndVisAttsByMaterial;
1945 // Instantiate a pseudo scene
1946 PseudoSceneForTetVertices pseudoScene
1947 (&tmpPVModel,&mesh,verticesByMaterial,nameAndVisAttsByMaterial);
1948 // Make private descent into the parameterisation
1949 tmpPVModel.DescribeYourselfTo(pseudoScene);
1950 // Now we have a map of vertices by material.
1951 // Also a map of name and colour by material.
1952
1953 // Fill the permanent (static) map of surfaces by material
1954 G4int nTetsTotal = 0, nFacetsTotal = 0;
1955 for (const auto& entry: nameAndVisAttsByMaterial) {
1956 G4int nTets = 0;
1957 const auto& material = entry.first;
1958 const auto& nameAndVisAtts = nameAndVisAttsByMaterial[material];
1959 const auto& name = nameAndVisAtts.fName;
1960 const auto& visAtts = nameAndVisAtts.fVisAtts;
1961 // Transfer vertices into a vector ready for creating polyhedral surface
1962 std::vector<G4ThreeVector> verticesForPolyhedron;
1963 const auto& range = verticesByMaterial.equal_range(material);
1964 for (auto vByMat = range.first; vByMat != range.second; ++vByMat) {
1965 const std::vector<G4ThreeVector>& vertices = vByMat->second;
1966 for (const auto& vertex: vertices)
1967 verticesForPolyhedron.push_back(vertex);
1968 ++nTets;
1969 }
1970 // The polyhedron will be in local coordinates
1971 // Add an empty place-holder to the map and get a reference to it
1972 auto& polyhedron = surfacesByMaterial[material];
1973 // Replace with the desired polyhedron (uses efficient "move assignment")
1974 polyhedron = G4PolyhedronTetMesh(verticesForPolyhedron);
1975 polyhedron.SetVisAttributes(visAtts);
1976 polyhedron.SetInfo(name);
1977
1978 if (print) {
1979 G4cout
1980 << std::setw(30) << std::left << name.substr(0,30) << std::right
1981 << ": " << std::setw(7) << nTets << " tetrahedra"
1982 << " (" << std::setw(7) << 4*nTets << " faces)"
1983 << ": reduced to " << std::setw(7) << polyhedron.GetNoFacets() << " facets ("
1984 << std::setw(2) << std::fixed << std::setprecision(2) << 100*polyhedron.GetNoFacets()/(4*nTets)
1985 << "%): colour " << std::fixed << std::setprecision(2)
1986 << visAtts.GetColour() << std::defaultfloat
1987 << G4endl;
1988 }
1989
1990 nTetsTotal += nTets;
1991 nFacetsTotal += polyhedron.GetNoFacets();
1992 }
1993
1994 if (print) {
1995 G4cout << "Total number of tetrahedra: " << nTetsTotal << " (" << 4*nTetsTotal << " faces)"
1996 << ": reduced to " << nFacetsTotal << " facets ("
1997 << std::setw(2) << std::fixed << std::setprecision(2) << 100*nFacetsTotal/(4*nTetsTotal) << "%)"
1998 << G4endl;
1999 }
2000 }
2001
2002 // Some subsequent expressions apply only to G4PhysicalVolumeModel
2003 auto pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
2004
2005 G4String parameterisationName;
2006 if (pPVModel) {
2007 parameterisationName = pPVModel->GetFullPVPath().back().GetPhysicalVolume()->GetName();
2008 }
2009
2010 // Draw the surfaces by material
2011 // Now we transform to world coordinates
2013 for (const auto& entry: surfacesByMaterial) {
2014 const auto& poly = entry.second;
2015 // The current "leaf" node in the PVPath is the parameterisation. Here it has
2016 // been converted into polyhedra by material. So...temporarily...change
2017 // its name to that of the material (whose name has been stored in Info)
2018 // so that its appearance in the scene tree of, e.g., G4OpenGLQtViewer, has
2019 // an appropriate name and its visibility and colour may be changed.
2020 if (pPVModel) {
2021 const auto& fullPVPath = pPVModel->GetFullPVPath();
2022 auto leafPV = fullPVPath.back().GetPhysicalVolume();
2023 leafPV->SetName(poly.GetInfo());
2024 }
2025 AddPrimitive(poly);
2026 }
2027 EndPrimitives ();
2028
2029 // Restore parameterisation name
2030 if (pPVModel) {
2031 pPVModel->GetFullPVPath().back().GetPhysicalVolume()->SetName(parameterisationName);
2032 }
2033
2034 firstPrint = false;
2035 return;
2036}

Referenced by StandardSpecialMeshRendering().

◆ EndModeling()

◆ EndPrimitives()

◆ EndPrimitives2D()

void G4VSceneHandler::EndPrimitives2D ( )
virtual

Implements G4VGraphicsScene.

Reimplemented in G4OpenGLImmediateSceneHandler, G4OpenGLSceneHandler, and G4OpenGLStoredSceneHandler.

Definition at line 201 of file G4VSceneHandler.cc.

201 {
202 if (fNestingDepth <= 0)
203 G4Exception("G4VSceneHandler::EndPrimitives2D",
204 "visman0104", FatalException, "Nesting error.");
209 }
210 fProcessing2D = false;
211}

Referenced by G4OpenGLSceneHandler::EndPrimitives2D().

◆ GetAuxEdgeVisible()

G4bool G4VSceneHandler::GetAuxEdgeVisible ( const G4VisAttributes * pVisAttribs)

Definition at line 1279 of file G4VSceneHandler.cc.

1279 {
1280 G4bool isAuxEdgeVisible = fpViewer->GetViewParameters().IsAuxEdgeVisible ();
1281 if (pVisAttribs -> IsForceAuxEdgeVisible()) {
1282 isAuxEdgeVisible = pVisAttribs->IsForcedAuxEdgeVisible();
1283 }
1284 return isAuxEdgeVisible;
1285}
G4bool IsForcedAuxEdgeVisible() const

Referenced by G4OpenGLSceneHandler::AddPrimitive().

◆ GetColor() [1/2]

const G4Colour & G4VSceneHandler::GetColor ( )

◆ GetColor() [2/2]

const G4Colour & G4VSceneHandler::GetColor ( const G4Visible & )

◆ GetColour() [1/2]

const G4Colour & G4VSceneHandler::GetColour ( )

Definition at line 1192 of file G4VSceneHandler.cc.

1192 {
1193 fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
1194 const G4Colour& colour = fpVisAttribs -> GetColour ();
1195 return colour;
1196}
const G4Colour & GetColour()

Referenced by G4ToolsSGSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), and GetColour().

◆ GetColour() [2/2]

const G4Colour & G4VSceneHandler::GetColour ( const G4Visible & visible)

Definition at line 1198 of file G4VSceneHandler.cc.

1198 {
1199 auto pVA = visible.GetVisAttributes();
1200 if (!pVA) pVA = fpViewer->GetViewParameters().GetDefaultVisAttributes();
1201 return pVA->GetColour();
1202}
const G4VisAttributes * GetVisAttributes() const

◆ GetCurrentViewer()

G4VViewer * G4VSceneHandler::GetCurrentViewer ( ) const

◆ GetDrawingStyle()

G4ViewParameters::DrawingStyle G4VSceneHandler::GetDrawingStyle ( const G4VisAttributes * pVisAttribs)

Definition at line 1219 of file G4VSceneHandler.cc.

1220 {
1221 // Drawing style is normally determined by the view parameters, but
1222 // it can be overriddden by the ForceDrawingStyle flag in the vis
1223 // attributes.
1224 const G4ViewParameters& vp = fpViewer->GetViewParameters();
1225 const G4ViewParameters::DrawingStyle viewerStyle = vp.GetDrawingStyle();
1226 G4ViewParameters::DrawingStyle resultantStyle = viewerStyle;
1227 if (pVisAttribs -> IsForceDrawingStyle ()) {
1229 pVisAttribs -> GetForcedDrawingStyle ();
1230 // This is complicated because if hidden line and surface removal
1231 // has been requested we wish to preserve this sometimes.
1232 switch (forcedStyle) {
1234 switch (viewerStyle) {
1235 case (G4ViewParameters::hlr):
1236 resultantStyle = G4ViewParameters::hlhsr;
1237 break;
1239 resultantStyle = G4ViewParameters::hsr;
1240 break;
1242 resultantStyle = G4ViewParameters::hsr;
1243 break;
1245 case (G4ViewParameters::hsr):
1246 break;
1247 }
1248 break;
1250 resultantStyle = G4ViewParameters::cloud;
1251 break;
1253 default:
1254 // But if forced style is wireframe, do it, because one of its
1255 // main uses is in displaying the consituent solids of a Boolean
1256 // solid and their surfaces overlap with the resulting Booean
1257 // solid, making a mess if hlr is specified.
1258 resultantStyle = G4ViewParameters::wireframe;
1259 break;
1260 }
1261 }
1262 return resultantStyle;
1263}

Referenced by G4OpenGLSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), G4VtkSceneHandler::AddPrimitive(), and RequestPrimitives().

◆ GetExtent()

const G4VisExtent & G4VSceneHandler::GetExtent ( ) const
virtual

Reimplemented from G4VGraphicsScene.

Definition at line 139 of file G4VSceneHandler.cc.

140{
141 if (fpScene) {
142 return fpScene->GetExtent();
143 } else {
144 static const G4VisExtent defaultExtent = G4VisExtent();
145 return defaultExtent;
146 }
147}

◆ GetGraphicsSystem()

◆ GetLineWidth()

G4double G4VSceneHandler::GetLineWidth ( const G4VisAttributes * pVisAttribs)

Definition at line 1210 of file G4VSceneHandler.cc.

1211{
1212 G4double lineWidth = pVisAttribs->GetLineWidth();
1213 if (lineWidth < 1.) lineWidth = 1.;
1214 lineWidth *= fpViewer -> GetViewParameters().GetGlobalLineWidthScale();
1215 if (lineWidth < 1.) lineWidth = 1.;
1216 return lineWidth;
1217}
G4double GetLineWidth() const

Referenced by G4OpenGLSceneHandler::AddPrimitive(), G4OpenGLSceneHandler::AddPrimitive(), G4OpenGLSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), and G4ToolsSGSceneHandler::AddPrimitive().

◆ GetMarkerDiameter()

G4double G4VSceneHandler::GetMarkerDiameter ( const G4VMarker & ,
MarkerSizeType &  )

◆ GetMarkerRadius()

G4double G4VSceneHandler::GetMarkerRadius ( const G4VMarker & ,
MarkerSizeType &  )

◆ GetMarkerSize()

G4double G4VSceneHandler::GetMarkerSize ( const G4VMarker & marker,
G4VSceneHandler::MarkerSizeType & markerSizeType )

Definition at line 1287 of file G4VSceneHandler.cc.

1290{
1291 // Deal with G4Polymarker::dots
1292 const auto& vp = fpViewer->GetViewParameters();
1293 try {
1294 const auto& polymarker = dynamic_cast<const G4Polymarker&>(marker);
1295 if (polymarker.GetMarkerType() == G4Polymarker::dots) {
1296 return vp.GetDotsSize();
1297 }
1298 }
1299 catch (const std::bad_cast&) {} // Continue
1300
1301 // Other markers
1302 G4bool userSpecified = marker.GetWorldSize() || marker.GetScreenSize();
1303 const G4VMarker& defaultMarker =
1304 fpViewer -> GetViewParameters().GetDefaultMarker();
1305 G4double size = userSpecified ?
1306 marker.GetWorldSize() : defaultMarker.GetWorldSize();
1307 if (size) {
1308 // Draw in world coordinates.
1309 markerSizeType = world;
1310 }
1311 else {
1312 size = userSpecified ?
1313 marker.GetScreenSize() : defaultMarker.GetScreenSize();
1314 // Draw in screen coordinates.
1315 markerSizeType = screen;
1316 }
1317 size *= fpViewer -> GetViewParameters().GetGlobalMarkerScale();
1318 if (markerSizeType == screen && size < 1.) size = 1.;
1319 return size;
1320}
G4double GetScreenSize() const
G4double GetWorldSize() const

Referenced by G4OpenGLSceneHandler::AddPrimitive(), G4OpenInventorSceneHandler::AddPrimitive(), G4OpenInventorSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), G4VtkSceneHandler::AddPrimitive(), and G4VtkSceneHandler::AddPrimitive().

◆ GetMarkForClearingTransientStore()

G4bool G4VSceneHandler::GetMarkForClearingTransientStore ( ) const

◆ GetModel()

◆ GetName()

◆ GetNoOfSides()

G4int G4VSceneHandler::GetNoOfSides ( const G4VisAttributes * pVisAttribs)

Definition at line 1322 of file G4VSceneHandler.cc.

1323{
1324 // No. of sides (lines segments per circle) is normally determined
1325 // by the view parameters, but it can be overriddden by the
1326 // ForceLineSegmentsPerCircle in the vis attributes.
1327 G4int lineSegmentsPerCircle = fpViewer->GetViewParameters().GetNoOfSides();
1328 if (pVisAttribs) {
1329 if (pVisAttribs->IsForceLineSegmentsPerCircle())
1330 lineSegmentsPerCircle = pVisAttribs->GetForcedLineSegmentsPerCircle();
1331 if (lineSegmentsPerCircle < pVisAttribs->GetMinLineSegmentsPerCircle()) {
1332 lineSegmentsPerCircle = pVisAttribs->GetMinLineSegmentsPerCircle();
1333 G4warn <<
1334 "G4VSceneHandler::GetNoOfSides: attempt to set the"
1335 "\nnumber of line segments per circle < " << lineSegmentsPerCircle
1336 << "; forced to " << pVisAttribs->GetMinLineSegmentsPerCircle() << G4endl;
1337 }
1338 }
1339 return lineSegmentsPerCircle;
1340}
G4bool IsForceLineSegmentsPerCircle() const
G4int GetForcedLineSegmentsPerCircle() const
static G4int GetMinLineSegmentsPerCircle()

Referenced by G4OpenGLSceneHandler::AddPrimitive(), and RequestPrimitives().

◆ GetNumberOfCloudPoints()

G4int G4VSceneHandler::GetNumberOfCloudPoints ( const G4VisAttributes * pVisAttribs) const

Definition at line 1265 of file G4VSceneHandler.cc.

1266 {
1267 // Returns no of cloud points from current view parameters, unless the user
1268 // has forced through the vis attributes, thereby over-riding the
1269 // current view parameter.
1270 G4int numberOfCloudPoints = fpViewer->GetViewParameters().GetNumberOfCloudPoints();
1271 if (pVisAttribs -> IsForceDrawingStyle() &&
1272 pVisAttribs -> GetForcedDrawingStyle() == G4VisAttributes::cloud &&
1273 pVisAttribs -> GetForcedNumberOfCloudPoints() > 0) {
1274 numberOfCloudPoints = pVisAttribs -> GetForcedNumberOfCloudPoints();
1275 }
1276 return numberOfCloudPoints;
1277}

Referenced by RequestPrimitives().

◆ GetObjectTransformation()

const G4Transform3D & G4VSceneHandler::GetObjectTransformation ( ) const

◆ GetPointInBox()

G4ThreeVector G4VSceneHandler::GetPointInBox ( const G4ThreeVector & pos,
G4double halfX,
G4double halfY,
G4double halfZ ) const
protected

Definition at line 2039 of file G4VSceneHandler.cc.

2043{
2044 G4double x = pos.getX() + (2.*G4QuickRand() - 1.)*halfX;
2045 G4double y = pos.getY() + (2.*G4QuickRand() - 1.)*halfY;
2046 G4double z = pos.getZ() + (2.*G4QuickRand() - 1.)*halfZ;
2047 return G4ThreeVector(x, y, z);
2048}
G4double G4QuickRand(uint32_t seed=0)

Referenced by Draw3DRectMeshAsDots().

◆ GetPointInTet()

G4ThreeVector G4VSceneHandler::GetPointInTet ( const std::vector< G4ThreeVector > & vertices) const
protected

Definition at line 2051 of file G4VSceneHandler.cc.

2052{
2053 G4double p = G4QuickRand();
2054 G4double q = G4QuickRand();
2055 G4double r = G4QuickRand();
2056 if (p + q > 1.)
2057 {
2058 p = 1. - p;
2059 q = 1. - q;
2060 }
2061 if (q + r > 1.)
2062 {
2063 G4double tmp = r;
2064 r = 1. - p - q;
2065 q = 1. - tmp;
2066 }
2067 else if (p + q + r > 1.)
2068 {
2069 G4double tmp = r;
2070 r = p + q + r - 1.;
2071 p = 1. - q - tmp;
2072 }
2073 G4double a = 1. - p - q - r;
2074 return vertices[0]*a + vertices[1]*p + vertices[2]*q + vertices[3]*r;
2075}

Referenced by DrawTetMeshAsDots().

◆ GetScene()

◆ GetSceneHandlerId()

G4int G4VSceneHandler::GetSceneHandlerId ( ) const

◆ GetTextColor()

const G4Colour & G4VSceneHandler::GetTextColor ( const G4Text & )

◆ GetTextColour()

const G4Colour & G4VSceneHandler::GetTextColour ( const G4Text & text)

Definition at line 1204 of file G4VSceneHandler.cc.

1204 {
1205 auto pVA = text.GetVisAttributes();
1206 if (!pVA) pVA = fpViewer->GetViewParameters().GetDefaultTextVisAttributes();
1207 return pVA->GetColour();
1208}

Referenced by G4OpenInventorSceneHandler::AddPrimitive(), and G4ToolsSGSceneHandler::AddPrimitive().

◆ GetTransientsDrawnThisEvent()

G4bool G4VSceneHandler::GetTransientsDrawnThisEvent ( ) const

◆ GetTransientsDrawnThisRun()

G4bool G4VSceneHandler::GetTransientsDrawnThisRun ( ) const

◆ GetViewCount()

G4int G4VSceneHandler::GetViewCount ( ) const

◆ GetViewerList()

const G4ViewerList & G4VSceneHandler::GetViewerList ( ) const

◆ IncrementViewCount()

G4int G4VSceneHandler::IncrementViewCount ( )

◆ IsReadyForTransients()

G4bool G4VSceneHandler::IsReadyForTransients ( ) const

◆ LoadAtts()

void G4VSceneHandler::LoadAtts ( const G4Visible & visible,
G4AttHolder * holder )
protected

Definition at line 1132 of file G4VSceneHandler.cc.

1133{
1134 // Load G4Atts from G4VisAttributes, if any...
1135 const G4VisAttributes* va = visible.GetVisAttributes();
1136 if (va) {
1137 const std::map<G4String,G4AttDef>* vaDefs =
1138 va->GetAttDefs();
1139 if (vaDefs) {
1140 holder->AddAtts(visible.GetVisAttributes()->CreateAttValues(), vaDefs);
1141 }
1142 }
1143
1144 G4PhysicalVolumeModel* pPVModel =
1145 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1146 if (pPVModel) {
1147 // Load G4Atts from G4PhysicalVolumeModel...
1148 const std::map<G4String,G4AttDef>* pvDefs = pPVModel->GetAttDefs();
1149 if (pvDefs) {
1150 holder->AddAtts(pPVModel->CreateCurrentAttValues(), pvDefs);
1151 }
1152 }
1153
1154 G4TrajectoriesModel* trajModel = dynamic_cast<G4TrajectoriesModel*>(fpModel);
1155 if (trajModel) {
1156 // Load G4Atts from trajectory model...
1157 const std::map<G4String,G4AttDef>* trajModelDefs = trajModel->GetAttDefs();
1158 if (trajModelDefs) {
1159 holder->AddAtts(trajModel->CreateCurrentAttValues(), trajModelDefs);
1160 }
1161 // Load G4Atts from trajectory...
1162 const G4VTrajectory* traj = trajModel->GetCurrentTrajectory();
1163 if (traj) {
1164 const std::map<G4String,G4AttDef>* trajDefs = traj->GetAttDefs();
1165 if (trajDefs) {
1166 holder->AddAtts(traj->CreateAttValues(), trajDefs);
1167 }
1168 G4int nPoints = traj->GetPointEntries();
1169 for (G4int i = 0; i < nPoints; ++i) {
1170 G4VTrajectoryPoint* trajPoint = traj->GetPoint(i);
1171 if (trajPoint) {
1172 const std::map<G4String,G4AttDef>* pointDefs = trajPoint->GetAttDefs();
1173 if (pointDefs) {
1174 holder->AddAtts(trajPoint->CreateAttValues(), pointDefs);
1175 }
1176 }
1177 }
1178 }
1179 }
1180
1181 G4HitsModel* hitsModel = dynamic_cast<G4HitsModel*>(fpModel);
1182 if (hitsModel) {
1183 // Load G4Atts from hit...
1184 const G4VHit* hit = hitsModel->GetCurrentHit();
1185 const std::map<G4String,G4AttDef>* hitsDefs = hit->GetAttDefs();
1186 if (hitsDefs) {
1187 holder->AddAtts(hit->CreateAttValues(), hitsDefs);
1188 }
1189 }
1190}
void AddAtts(const std::vector< G4AttValue > *values, const std::map< G4String, G4AttDef > *defs)
const G4VHit * GetCurrentHit() const
std::vector< G4AttValue > * CreateCurrentAttValues() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
const G4VTrajectory * GetCurrentTrajectory() const
std::vector< G4AttValue > * CreateCurrentAttValues() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual std::vector< G4AttValue > * CreateAttValues() const
Definition G4VHit.hh:71
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
Definition G4VHit.hh:64
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
virtual G4int GetPointEntries() const =0
virtual std::vector< G4AttValue > * CreateAttValues() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
const std::vector< G4AttValue > * CreateAttValues() const

Referenced by G4OpenInventorSceneHandler::AddPrimitive(), G4OpenInventorSceneHandler::AddPrimitive(), and G4OpenInventorSceneHandler::AddPrimitive().

◆ PostAddSolid()

void G4VSceneHandler::PostAddSolid ( )
virtual

Implements G4VGraphicsScene.

Reimplemented in G4VTreeSceneHandler.

Definition at line 156 of file G4VSceneHandler.cc.

156 {
157 fpVisAttribs = 0;
158 fProcessingSolid = false;
162 }
163}

Referenced by AddCompound().

◆ PreAddSolid()

void G4VSceneHandler::PreAddSolid ( const G4Transform3D & objectTransformation,
const G4VisAttributes & visAttribs )
virtual

◆ ProcessScene()

void G4VSceneHandler::ProcessScene ( )
protectedvirtual

Reimplemented in G4OpenGLSceneHandler.

Definition at line 673 of file G4VSceneHandler.cc.

674{
675 // Assumes graphics database store has already been cleared if
676 // relevant for the particular scene handler.
677
678 if(!fpScene)
679 return;
680
681 if(fpScene->GetExtent() == G4VisExtent::GetNullExtent())
682 {
683 G4Exception("G4VSceneHandler::ProcessScene", "visman0106", JustWarning,
684 "The scene has no extent.");
685 }
686
687 G4VisManager* visManager = G4VisManager::GetInstance();
688
689 if(!visManager->GetConcreteInstance())
690 return;
691
692 G4VisManager::Verbosity verbosity = visManager->GetVerbosity();
693
694 fReadyForTransients = false;
695
696 // Traverse geometry tree and send drawing primitives to window(s).
697
698 const std::vector<G4Scene::Model>& runDurationModelList =
699 fpScene->GetRunDurationModelList();
700
701 if(runDurationModelList.size()) {
702 if(verbosity >= G4VisManager::confirmations) {
703 G4cout << "Traversing scene data..." << G4endl;
704 static G4int first = true;
705 if (first) {
706 first = false;
707 G4cout <<
708 "(This could happen more than once - in fact, up to three times"
709 "\nper rebuild, for opaque, transparent and non-hidden markers.)"
710 << G4endl;
711 }
712 }
713
714 // Reset visibility of all objects to false - visible objects will then set to true
715 fpViewer->AccessSceneTree().ResetVisibility();
716
718
719 // Create modeling parameters from view parameters...
720 G4ModelingParameters* pMP = CreateModelingParameters();
721
722 for(const auto& i : runDurationModelList) {
723 if(i.fActive) {
724 fpModel = i.fpModel;
725 fpModel->SetModelingParameters(pMP);
726
727 // Describe to the current scene handler
728 fpModel->DescribeYourselfTo(*this);
729
730 // To see the extents of each model represented as wireframe boxes,
731 // uncomment the next line and DrawExtent in namespace above.
732 // DrawExtent(fpModel);
733
734 // Enter models in the scene tree. Then for PV models, describe
735 // the model to the scene tree, i.e., enter all the touchables.
736 fpViewer->InsertModelInSceneTree(fpModel);
737 auto pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
738 if (pPVModel) {
739 G4VViewer::SceneTreeScene sceneTreeScene(fpViewer, pPVModel);
740 fpModel->DescribeYourselfTo(sceneTreeScene);
741 const auto& maxDepth = pPVModel->GetMaxFullDepth();
742 if (fMaxGeometryDepth < maxDepth) {fMaxGeometryDepth = maxDepth;}
743 // This will be the maximum geometry depth for this scene handler
744 }
745
746 // Reset modeling parameters pointer
747 fpModel->SetModelingParameters(0);
748 }
749 }
750
751 fpModel = 0;
752 delete pMP;
753
754 EndModeling();
755 }
756
757 // Some printing
758 if(verbosity >= G4VisManager::parameters) {
759 for (const auto& model: runDurationModelList) {
760 if (model.fActive) {
761 auto pvModel = dynamic_cast<G4PhysicalVolumeModel*>(model.fpModel);
762 if (pvModel) {
763
764 G4cout << "Numbers of all touchables by depth \""
765 << pvModel->GetGlobalDescription() << "\":";
766 for (const auto& dn : pvModel->GetMapOfAllTouchables()) {
767 G4cout << "\n Depth " << dn.first << ": " << dn.second;
768 }
769 G4cout << "\n Total number of all touchables: "
770 << pvModel->GetTotalAllTouchables() << G4endl;
771
772 G4cout << "Numbers of touchables drawn by depth \""
773 << pvModel->GetGlobalDescription() << "\":";
774 for (const auto& dn : pvModel->GetMapOfDrawnTouchables()) {
775 G4cout << "\n Depth " << dn.first << ": " << dn.second;
776 }
777 G4cout << "\n Total number of drawn touchables: "
778 << pvModel->GetTotalDrawnTouchables() << G4endl;
779 }
780 }
781 }
782 }
783 if(verbosity >= G4VisManager::warnings) {
784 if (fProblematicVolumes.size() > 0) {
785 G4cout << "Problematic volumes:";
786 for (const auto& prob: fProblematicVolumes) {
787 G4cout << "\n " << prob.first->GetName() << " (" << prob.second << ')';
788 }
789 G4cout << G4endl;
790 }
791 }
792
794}
virtual void BeginModeling()
virtual void EndModeling()
std::map< G4VPhysicalVolume *, G4String > fProblematicVolumes
virtual void ProcessTransients()
static G4VVisManager * GetConcreteInstance()
static const G4VisExtent & GetNullExtent()

Referenced by G4OpenGLSceneHandler::ProcessScene().

◆ ProcessTransients()

void G4VSceneHandler::ProcessTransients ( )
protectedvirtual

Definition at line 796 of file G4VSceneHandler.cc.

797{
798 // Assumes transient store has already been cleared
799
800 // Reset fMarkForClearingTransientStore. (Leaving
801 // fMarkForClearingTransientStore true causes problems with
802 // recomputing transients below.) Restore it again at end...
803 G4bool tmpMarkForClearingTransientStore = fMarkForClearingTransientStore;
805
806 G4VisManager* visManager = G4VisManager::GetInstance();
807 G4VisManager::Verbosity verbosity = visManager->GetVerbosity();
808
809 fReadyForTransients = true;
810
811 // Refresh event from end-of-event model list.
812 // Allow only in Idle or GeomClosed state...
813 G4StateManager* stateManager = G4StateManager::GetStateManager();
814 G4ApplicationState state = stateManager->GetCurrentState();
815 if(state == G4State_Idle || state == G4State_GeomClosed)
816 {
817 visManager->SetEventRefreshing(true);
818
819 if(visManager->GetRequestedEvent())
820 {
821 DrawEvent(visManager->GetRequestedEvent());
822 }
823 else
824 {
825 G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
826 if(runManager)
827 {
828 const G4Run* run = runManager->GetCurrentRun();
829 // Draw a null event in order to pick up models for the scene tree even before a run
830 if (run == nullptr) DrawEvent(0);
831 const std::vector<const G4Event*>* events =
832 run ? run->GetEventVector() : 0;
833 std::size_t nKeptEvents = 0;
834 if(events)
835 nKeptEvents = events->size();
836 if(nKeptEvents)
837 {
838 if(fpScene->GetRefreshAtEndOfEvent())
839 {
840 if(verbosity >= G4VisManager::confirmations)
841 {
842 G4cout << "Refreshing event..." << G4endl;
843 }
844 const G4Event* event = 0;
845 if(events && events->size())
846 event = events->back();
847 if(event)
848 DrawEvent(event);
849 }
850 else
851 { // Accumulating events.
852
853 if(verbosity >= G4VisManager::confirmations)
854 {
855 G4cout << "Refreshing events in run..." << G4endl;
856 }
857 for(const auto& event : *events)
858 {
859 if(event)
860 DrawEvent(event);
861 }
862
863 if(!fpScene->GetRefreshAtEndOfRun())
864 {
865 if(verbosity >= G4VisManager::warnings)
866 {
867 G4warn << "WARNING: Cannot refresh events accumulated over more"
868 "\n than one runs. Refreshed just the last run."
869 << G4endl;
870 }
871 }
872 }
873 }
874 }
875 }
876 visManager->SetEventRefreshing(false);
877 }
878
879 // Refresh end-of-run model list.
880 // Allow only in Idle or GeomClosed state...
881 if(state == G4State_Idle || state == G4State_GeomClosed)
882 {
884 }
885
886 fMarkForClearingTransientStore = tmpMarkForClearingTransientStore;
887}
G4ApplicationState
@ G4State_Idle
@ G4State_GeomClosed
static G4RunManager * GetMasterRunManager()
const G4Run * GetCurrentRun() const
std::vector< const G4Event * > * GetEventVector() const
Definition G4Run.hh:100
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
void DrawEvent(const G4Event *)
void SetEventRefreshing(G4bool)
const G4Event * GetRequestedEvent() const

Referenced by ProcessScene().

◆ RemoveViewerFromList()

void G4VSceneHandler::RemoveViewerFromList ( G4VViewer * pView)

Definition at line 500 of file G4VSceneHandler.cc.

500 {
501 fViewerList.remove(pViewer); // Does nothing if already removed
502 // And reset current viewer
503 auto visManager = G4VisManager::GetInstance();
504 visManager->SetCurrentViewer(nullptr);
505}

◆ RequestPrimitives()

void G4VSceneHandler::RequestPrimitives ( const G4VSolid & solid)
protectedvirtual

Reimplemented in G4ASCIITreeSceneHandler, and G4RayTracerSceneHandler.

Definition at line 523 of file G4VSceneHandler.cc.

524{
525 // Sometimes solids that have no substance get requested. They may
526 // be part of the geometry tree but have been "spirited away", for
527 // example by a Boolean subtraction in which the original volume
528 // is entirely inside the subtractor or an intersection in which
529 // the original volume is entirely outside the intersector.
530 // The problem is that the Boolean Processor still returns a
531 // polyhedron in these cases (IMHO it should not), so the
532 // workaround is to return before the damage is done.
533 // Algorithm by Evgueni Tcherniaev
534 auto pSolid = &solid;
535 auto pBooleanSolid = dynamic_cast<const G4BooleanSolid*>(pSolid);
536 if (pBooleanSolid) {
537 G4ThreeVector bmin, bmax;
538 pBooleanSolid->BoundingLimits(bmin, bmax);
539 G4bool isGood = false;
540 if (dynamic_cast<const G4SubtractionSolid*>(pBooleanSolid)) {
541 auto ptrB = pBooleanSolid->GetConstituentSolid(1);
542 for (G4int i=0; i<10; ++i) {
543 G4double x = bmin.x() + (bmax.x() - bmin.x())*G4QuickRand();
544 G4double y = bmin.y() + (bmax.y() - bmin.y())*G4QuickRand();
545 G4double z = bmin.z() + (bmax.z() - bmin.z())*G4QuickRand();
546 if (ptrB->Inside(G4ThreeVector(x,y,bmin.z())) != kInside) { isGood = true; break; }
547 if (ptrB->Inside(G4ThreeVector(x,y,bmax.z())) != kInside) { isGood = true; break; }
548 if (ptrB->Inside(G4ThreeVector(x,bmin.y(),z)) != kInside) { isGood = true; break; }
549 if (ptrB->Inside(G4ThreeVector(x,bmax.y(),z)) != kInside) { isGood = true; break; }
550 if (ptrB->Inside(G4ThreeVector(bmin.x(),y,z)) != kInside) { isGood = true; break; }
551 if (ptrB->Inside(G4ThreeVector(bmax.x(),y,z)) != kInside) { isGood = true; break; }
552 }
553 } else if (dynamic_cast<const G4IntersectionSolid*>(pBooleanSolid)) {
554 auto ptrB = pBooleanSolid->GetConstituentSolid(1);
555 for (G4int i=0; i<10; ++i) {
556 G4double x = bmin.x() + (bmax.x() - bmin.x())*G4QuickRand();
557 G4double y = bmin.y() + (bmax.y() - bmin.y())*G4QuickRand();
558 G4double z = bmin.z() + (bmax.z() - bmin.z())*G4QuickRand();
559 if (ptrB->Inside(G4ThreeVector(x,y,bmin.z())) == kInside) { isGood = true; break; }
560 if (ptrB->Inside(G4ThreeVector(x,y,bmax.z())) == kInside) { isGood = true; break; }
561 if (ptrB->Inside(G4ThreeVector(x,bmin.y(),z)) == kInside) { isGood = true; break; }
562 if (ptrB->Inside(G4ThreeVector(x,bmax.y(),z)) == kInside) { isGood = true; break; }
563 if (ptrB->Inside(G4ThreeVector(bmin.x(),y,z)) == kInside) { isGood = true; break; }
564 if (ptrB->Inside(G4ThreeVector(bmax.x(),y,z)) == kInside) { isGood = true; break; }
565 }
566 }
567 if (!isGood)
568 {
569 for (G4int i=0; i<10000; ++i) {
570 G4double x = bmin.x() + (bmax.x() - bmin.x())*G4QuickRand();
571 G4double y = bmin.y() + (bmax.y() - bmin.y())*G4QuickRand();
572 G4double z = bmin.z() + (bmax.z() - bmin.z())*G4QuickRand();
573 if (pBooleanSolid->Inside(G4ThreeVector(x,y,z)) == kInside) { isGood = true; break; }
574 }
575 }
576 if (!isGood) return;
577 }
578
580 const G4ViewParameters& vp = fpViewer->GetViewParameters();
581
582 switch (style) {
583 default:
588 {
589 // Use polyhedral representation
591 G4Polyhedron* pPolyhedron = solid.GetPolyhedron ();
593 if (pPolyhedron) {
594 pPolyhedron -> SetVisAttributes (fpVisAttribs);
596 AddPrimitive (*pPolyhedron);
597 EndPrimitives ();
598 break;
599 } else { // Print warnings and drop through to cloud
601 auto pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
602 if (pPVModel) {
603 auto problematicVolume = pPVModel->GetCurrentPV();
604 if (fProblematicVolumes.find(problematicVolume) == fProblematicVolumes.end()) {
605 fProblematicVolumes[problematicVolume] = "Null polyhedron";
606 if (verbosity >= G4VisManager::errors) {
607 G4warn <<
608 "ERROR: G4VSceneHandler::RequestPrimitives"
609 "\n Polyhedron not available for " << solid.GetName ();
610 G4warn << "\n Touchable path: " << pPVModel->GetFullPVPath();
611 static G4bool explanation = false;
612 if (!explanation) {
613 explanation = true;
614 G4warn <<
615 "\n This means it cannot be visualized in the usual way on most systems."
616 "\n 1) The solid may not have implemented the CreatePolyhedron method."
617 "\n 2) For Boolean solids, the BooleanProcessor, which attempts to create"
618 "\n the resultant polyhedron, may have failed."
619 "\n Try RayTracer. It uses Geant4's tracking algorithms instead.";
620 }
621 }
622 G4warn << "\n Drawing solid with cloud of points.";
623 G4warn << G4endl;
624 }
625 }
626 }
627 }
628 [[fallthrough]];
629
631 {
632 // Form solid out of cloud of dots on surface of solid
633 G4Polymarker dots;
634 // Note: OpenGL has a fast implementation of polymarker so it's better
635 // to build a polymarker rather than add a succession of circles.
636 // And anyway, in Qt, in the latter case each circle would be a scene-tree
637 // entry, something we would want to avoid.
640 G4int numberOfCloudPoints = GetNumberOfCloudPoints(fpVisAttribs);
641 if (numberOfCloudPoints <= 0) numberOfCloudPoints = vp.GetNumberOfCloudPoints();
642 for (G4int i = 0; i < numberOfCloudPoints; ++i) {
644 dots.push_back(p);
645 }
647 AddPrimitive(dots);
648 EndPrimitives ();
649 break;
650 }
651 }
652}
double z() const
double x() const
double y() const
G4int GetNumberOfCloudPoints(const G4VisAttributes *) const
G4int GetNoOfSides(const G4VisAttributes *)
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
G4String GetName() const
virtual G4ThreeVector GetPointOnSurface() const
Definition G4VSolid.cc:151
virtual G4Polyhedron * GetPolyhedron() const
Definition G4VSolid.cc:731
static void SetNumberOfRotationSteps(G4int n)
static void ResetNumberOfRotationSteps()
@ kInside
Definition geomdefs.hh:70

Referenced by AddSolidT(), and AddSolidWithAuxiliaryEdges().

◆ SetCurrentViewer()

void G4VSceneHandler::SetCurrentViewer ( G4VViewer * )

◆ SetMarkForClearingTransientStore()

◆ SetModel()

void G4VSceneHandler::SetModel ( G4VModel * )

◆ SetName()

void G4VSceneHandler::SetName ( const G4String & )

◆ SetObjectTransformation()

void G4VSceneHandler::SetObjectTransformation ( const G4Transform3D & )

◆ SetScene()

void G4VSceneHandler::SetScene ( G4Scene * pScene)
virtual

Reimplemented in G4OpenGLStoredQtSceneHandler.

Definition at line 514 of file G4VSceneHandler.cc.

514 {
515 fpScene = pScene;
516 // Notify all viewers that a kernel visit is required.
518 for (i = fViewerList.begin(); i != fViewerList.end(); i++) {
519 (*i) -> SetNeedKernelVisit (true);
520 }
521}
std::vector< G4VViewer * >::iterator G4ViewerListIterator

Referenced by G4OpenGLStoredQtSceneHandler::SetScene().

◆ SetTransientsDrawnThisEvent()

void G4VSceneHandler::SetTransientsDrawnThisEvent ( G4bool )

◆ SetTransientsDrawnThisRun()

void G4VSceneHandler::SetTransientsDrawnThisRun ( G4bool )

◆ SetViewerList()

G4ViewerList & G4VSceneHandler::SetViewerList ( )

◆ StandardSpecialMeshRendering()

void G4VSceneHandler::StandardSpecialMeshRendering ( const G4Mesh & mesh)
protected

Definition at line 1409 of file G4VSceneHandler.cc.

1413{
1414 G4bool implemented = false;
1415 switch (mesh.GetMeshType()) {
1416 case G4Mesh::rectangle: [[fallthrough]];
1418 switch (fpViewer->GetViewParameters().GetSpecialMeshRenderingOption()) {
1420 [[fallthrough]];
1422 Draw3DRectMeshAsDots(mesh); // Rectangular 3-deep mesh as dots
1423 implemented = true;
1424 break;
1426 Draw3DRectMeshAsSurfaces(mesh); // Rectangular 3-deep mesh as surfaces
1427 implemented = true;
1428 break;
1429 }
1430 break;
1432 switch (fpViewer->GetViewParameters().GetSpecialMeshRenderingOption()) {
1434 [[fallthrough]];
1436 DrawTetMeshAsDots(mesh); // Tetrahedron mesh as dots
1437 implemented = true;
1438 break;
1440 DrawTetMeshAsSurfaces(mesh); // Tetrahedron mesh as surfaces
1441 implemented = true;
1442 break;
1443 }
1444 break;
1445 case G4Mesh::cylinder: [[fallthrough]];
1446 case G4Mesh::sphere: [[fallthrough]];
1447 case G4Mesh::invalid: break;
1448 }
1449 if (implemented) {
1450 // Draw container if not marked invisible...
1451 auto container = mesh.GetContainerVolume();
1452 auto containerLogical = container->GetLogicalVolume();
1453 auto containerVisAtts = containerLogical->GetVisAttributes();
1454 if (containerVisAtts == nullptr || containerVisAtts->IsVisible()) {
1455 auto solid = containerLogical->GetSolid();
1456 auto polyhedron = solid->GetPolyhedron();
1457 // Always draw as wireframe
1458 G4VisAttributes tmpVisAtts;
1459 if (containerVisAtts != nullptr) tmpVisAtts = *containerVisAtts;
1460 tmpVisAtts.SetForceWireframe();
1461 polyhedron->SetVisAttributes(tmpVisAtts);
1463 AddPrimitive(*polyhedron);
1464 EndPrimitives();
1465 }
1466 } else {
1467 // Invoke base class function
1469 }
1470 return;
1471}
const G4VisAttributes * GetVisAttributes() const
@ invalid
Definition G4Mesh.hh:52
@ sphere
Definition G4Mesh.hh:56
@ cylinder
Definition G4Mesh.hh:55
void DrawTetMeshAsSurfaces(const G4Mesh &)
void Draw3DRectMeshAsDots(const G4Mesh &)
void DrawTetMeshAsDots(const G4Mesh &)
void Draw3DRectMeshAsSurfaces(const G4Mesh &)
virtual void AddCompound(const G4VTrajectory &)
void SetForceWireframe(G4bool=true)

Referenced by G4OpenGLSceneHandler::AddCompound(), G4OpenInventorSceneHandler::AddCompound(), G4ToolsSGSceneHandler::AddCompound(), and G4VtkSceneHandler::AddCompound().

◆ G4VViewer

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const G4VSceneHandler & s )
friend

Definition at line 1342 of file G4VSceneHandler.cc.

1342 {
1343
1344 os << "Scene handler " << sh.fName << " has "
1345 << sh.fViewerList.size () << " viewer(s):";
1346 for (const auto* i : sh.fViewerList) {
1347 os << "\n " << *i;
1348 }
1349
1350 if (sh.fpScene) {
1351 os << "\n " << *sh.fpScene;
1352 }
1353 else {
1354 os << "\n This scene handler currently has no scene.";
1355 }
1356
1357 return os;
1358}

Member Data Documentation

◆ fIdentityTransformation

const G4Transform3D G4VSceneHandler::fIdentityTransformation
protected

Definition at line 461 of file G4VSceneHandler.hh.

◆ fMarkForClearingTransientStore

G4bool G4VSceneHandler::fMarkForClearingTransientStore
protected

Definition at line 449 of file G4VSceneHandler.hh.

Referenced by G4VtkSceneHandler::AddSolid(), and ProcessTransients().

◆ fName

G4String G4VSceneHandler::fName
protected

Definition at line 444 of file G4VSceneHandler.hh.

Referenced by G4VtkSceneHandler::AddSolid(), and G4VisManager::operator<<.

◆ fNestingDepth

G4int G4VSceneHandler::fNestingDepth
protected

◆ fObjectTransformation

◆ fpModel

◆ fProblematicVolumes

std::map<G4VPhysicalVolume*,G4String> G4VSceneHandler::fProblematicVolumes
protected

Definition at line 462 of file G4VSceneHandler.hh.

Referenced by ProcessScene(), and RequestPrimitives().

◆ fProcessing2D

◆ fProcessingSolid

G4bool G4VSceneHandler::fProcessingSolid
protected

◆ fpScene

◆ fpViewer

G4VViewer* G4VSceneHandler::fpViewer
protected

◆ fpVisAttribs

◆ fReadyForTransients

◆ fSceneHandlerId

const G4int G4VSceneHandler::fSceneHandlerId
protected

Definition at line 443 of file G4VSceneHandler.hh.

Referenced by G4VtkSceneHandler::AddSolid(), and G4VSceneHandler().

◆ fSystem

G4VGraphicsSystem& G4VSceneHandler::fSystem
protected

Definition at line 442 of file G4VSceneHandler.hh.

Referenced by AddPrimitive(), G4VtkSceneHandler::AddSolid(), and G4VSceneHandler().

◆ fTransientsDrawnThisEvent

G4bool G4VSceneHandler::fTransientsDrawnThisEvent
protected

Definition at line 452 of file G4VSceneHandler.hh.

Referenced by EndPrimitives(), EndPrimitives2D(), and PostAddSolid().

◆ fTransientsDrawnThisRun

G4bool G4VSceneHandler::fTransientsDrawnThisRun
protected

Definition at line 453 of file G4VSceneHandler.hh.

Referenced by EndPrimitives(), EndPrimitives2D(), and PostAddSolid().

◆ fViewCount

G4int G4VSceneHandler::fViewCount
protected

Definition at line 445 of file G4VSceneHandler.hh.

Referenced by G4VtkSceneHandler::AddSolid().

◆ fViewerList


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