Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ToolsSGSceneHandler Class Reference

#include <G4ToolsSGSceneHandler.hh>

+ Inheritance diagram for G4ToolsSGSceneHandler:

Classes

class  Messenger
 

Public Member Functions

virtual void AddPrimitive (const G4Polyline &)
 
virtual void AddPrimitive (const G4Text &)
 
virtual void AddPrimitive (const G4Circle &)
 
virtual void AddPrimitive (const G4Square &)
 
virtual void AddPrimitive (const G4Polymarker &)
 
virtual void AddPrimitive (const G4Polyhedron &)
 
virtual void AddPrimitive (const G4Plotter &)
 
virtual void AddCompound (const G4Mesh &)
 
virtual void ClearStore ()
 
virtual void ClearTransientStore ()
 
 G4ToolsSGSceneHandler (G4VGraphicsSystem &system, const G4String &name)
 
virtual ~G4ToolsSGSceneHandler ()
 
tools::sg::separator & GetTransient2DObjects ()
 
tools::sg::separator & GetPersistent2DObjects ()
 
tools::sg::separator & GetTransient3DObjects ()
 
tools::sg::separator & GetPersistent3DObjects ()
 
void TouchPlotters (tools::sg::node &)
 
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 &)
 
- Public Member Functions inherited from G4VSceneHandler
 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 ()
 
virtual void PreAddSolid (const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
 
virtual void PostAddSolid ()=0
 
virtual void AddSolid (const G4Box &)=0
 
virtual void AddSolid (const G4Cons &)=0
 
virtual void AddSolid (const G4Orb &)=0
 
virtual void AddSolid (const G4Para &)=0
 
virtual void AddSolid (const G4Sphere &)=0
 
virtual void AddSolid (const G4Torus &)=0
 
virtual void AddSolid (const G4Trap &)=0
 
virtual void AddSolid (const G4Trd &)=0
 
virtual void AddSolid (const G4Tubs &)=0
 
virtual void AddSolid (const G4Ellipsoid &)=0
 
virtual void AddSolid (const G4Polycone &)=0
 
virtual void AddSolid (const G4Polyhedra &)=0
 
virtual void AddSolid (const G4TessellatedSolid &)=0
 
virtual void AddSolid (const G4VSolid &)=0
 
virtual void AddCompound (const G4VTrajectory &)=0
 
virtual void AddCompound (const G4VHit &)=0
 
virtual void AddCompound (const G4VDigi &)=0
 
virtual void AddCompound (const G4THitsMap< G4double > &)=0
 
virtual void AddCompound (const G4THitsMap< G4StatDouble > &)=0
 
virtual void AddCompound (const G4Mesh &)=0
 
virtual void BeginPrimitives (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives ()=0
 
virtual void BeginPrimitives2D (const G4Transform3D &objectTransformation=G4Transform3D())=0
 
virtual void EndPrimitives2D ()=0
 
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 &)=0
 
virtual void AddPrimitive (const G4Polyhedron &)=0
 
virtual void AddPrimitive (const G4Plotter &)=0
 
virtual const G4VisExtentGetExtent () const
 

Protected Types

using Region_h1 = std::pair< unsigned int, int >
 
using Region_h2 = std::pair< unsigned int, int >
 

Protected Member Functions

 G4ToolsSGSceneHandler (const G4ToolsSGSceneHandler &)
 
G4ToolsSGSceneHandleroperator= (const G4ToolsSGSceneHandler &)
 
void CreateSG ()
 
void EstablishBaseNodes ()
 
tools::sg::separator * GetOrCreateNode ()
 
void SetPlotterHistograms (tools::sg::plots &)
 
- Protected Member Functions inherited from G4VSceneHandler
virtual void ProcessScene ()
 
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

tools::sg::separator fpTransient2DObjects
 
tools::sg::separator fpPersistent2DObjects
 
tools::sg::separator fpTransient3DObjects
 
tools::sg::separator fpPersistent3DObjects
 
std::vector< G4ToolsSGNode * > fpPhysicalVolumeObjects
 
tools::sg::base_freetype * fFreetypeNode
 
std::vector< Region_h1fRegionH1s
 
std::vector< Region_h2fRegionH2s
 
- Protected Attributes inherited from G4VSceneHandler
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
 

Static Protected Attributes

static G4int fSceneIdCount = 0
 

Additional Inherited Members

- Public Types inherited from G4VSceneHandler
enum  MarkerSizeType { world , screen }
 

Detailed Description

Definition at line 44 of file G4ToolsSGSceneHandler.hh.

Member Typedef Documentation

◆ Region_h1

using G4ToolsSGSceneHandler::Region_h1 = std::pair<unsigned int,int>
protected

Definition at line 94 of file G4ToolsSGSceneHandler.hh.

◆ Region_h2

using G4ToolsSGSceneHandler::Region_h2 = std::pair<unsigned int,int>
protected

Definition at line 95 of file G4ToolsSGSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4ToolsSGSceneHandler() [1/2]

G4ToolsSGSceneHandler::G4ToolsSGSceneHandler ( G4VGraphicsSystem system,
const G4String name 
)

Definition at line 76 of file G4ToolsSGSceneHandler.cc.

78:parent(system, fSceneIdCount++, name)
80{
81 //::printf("debug : G4ToolsSGSceneHandler : %lu, %s\n",this,name.c_str());
83#if defined(TOOLS_USE_FREETYPE)
84 fFreetypeNode = new toolx::sg::text_freetype();
85 fFreetypeNode->add_embedded_font(tools::sg::font_lato_regular_ttf(),tools::font::lato_regular_ttf);
86 fFreetypeNode->add_embedded_font(tools::sg::font_roboto_bold_ttf(),tools::font::roboto_bold_ttf);
87#else
88 fFreetypeNode = new tools::sg::dummy_freetype();
89#endif
91}
tools::sg::base_freetype * fFreetypeNode

◆ ~G4ToolsSGSceneHandler()

G4ToolsSGSceneHandler::~G4ToolsSGSceneHandler ( )
virtual

Definition at line 93 of file G4ToolsSGSceneHandler.cc.

94{
95 //::printf("debug : ~G4ToolsSGSceneHandler : %lu\n",this);
96 //WARNING : nodes may refer graphics managers (as tools/sg/[GL_manager,gl2ps_manager,zb_manager]
97 // used by viewers) to handle gstos (for GPU) or textures, then we have to delete them first.
98 // It is assumed that we pass here BEFORE the attached/managed viewers are deleted.
100 fpPersistent2DObjects.clear();
101 fpTransient3DObjects.clear();
102 fpPersistent3DObjects.clear();
103 delete fFreetypeNode;
104}
tools::sg::separator fpPersistent2DObjects
tools::sg::separator fpTransient3DObjects
tools::sg::separator fpTransient2DObjects
tools::sg::separator fpPersistent3DObjects

◆ G4ToolsSGSceneHandler() [2/2]

G4ToolsSGSceneHandler::G4ToolsSGSceneHandler ( const G4ToolsSGSceneHandler )
protected

Member Function Documentation

◆ AddCompound() [1/7]

void G4VSceneHandler::AddCompound ( const G4Mesh mesh)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 133 of file G4VSceneHandler.cc.

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

◆ AddCompound() [2/7]

void G4ToolsSGSceneHandler::AddCompound ( const G4Mesh mesh)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 586 of file G4ToolsSGSceneHandler.cc.

587{
589}
void StandardSpecialMeshRendering(const G4Mesh &)

◆ AddCompound() [3/7]

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

Reimplemented from G4VSceneHandler.

Definition at line 131 of file G4VSceneHandler.cc.

345 {
346 using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
347 //G4cout << "AddCompound: hits: " << &hits << G4endl;
348 G4bool scoreMapHits = false;
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(MeshScoreMap::const_iterator i = scoreMap.cbegin();
358 i != scoreMap.cend(); ++i) {
359 const G4String& scoreMapName = i->first;
360 if (scoreMapName == mapNam) {
361 G4DefaultLinearColorMap colorMap("G4VSceneHandlerColorMap");
362 scoreMapHits = true;
363 mesh->DrawMesh(scoreMapName, &colorMap);
364 }
365 }
366 }
367 }
368 }
369 if (scoreMapHits) {
370 static G4bool first = true;
371 if (first) {
372 first = false;
373 G4cout <<
374 "Scoring map drawn with default parameters."
375 "\n To get gMocren file for gMocren browser:"
376 "\n /vis/open gMocrenFile"
377 "\n /vis/viewer/flush"
378 "\n Many other options available with /score/draw... commands."
379 "\n You might want to \"/vis/viewer/set/autoRefresh false\"."
380 << G4endl;
381 }
382 } else { // Not score map hits. Just call DrawAllHits.
383 // Cast away const because DrawAllHits is non-const!!!!
384 const_cast<G4THitsMap<G4double>&>(hits).DrawAllHits();
385 }
386}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
G4VScoringMesh * GetMesh(G4int i) const
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() [4/7]

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

Reimplemented from G4VSceneHandler.

Definition at line 132 of file G4VSceneHandler.cc.

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

◆ AddCompound() [5/7]

void G4VSceneHandler::AddCompound ( const G4VDigi digi)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 130 of file G4VSceneHandler.cc.

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

◆ AddCompound() [6/7]

void G4VSceneHandler::AddCompound ( const G4VHit hit)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 129 of file G4VSceneHandler.cc.

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

◆ AddCompound() [7/7]

void G4VSceneHandler::AddCompound ( const G4VTrajectory traj)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 128 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)
Definition: G4Exception.cc:59
virtual void DrawTrajectory() const

◆ AddPrimitive() [1/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Circle a_circle)
virtual

Implements G4VSceneHandler.

Definition at line 415 of file G4ToolsSGSceneHandler.cc.

416{
417 G4Polymarker oneCircle(a_circle);
418 oneCircle.push_back(a_circle.GetPosition());
419 oneCircle.SetMarkerType(G4Polymarker::circles);
420 // Call this AddPrimitive to avoid re-doing sub-class code.
422}
virtual void AddPrimitive(const G4Polyline &)
G4Point3D GetPosition() const

◆ AddPrimitive() [2/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Plotter a_plotter)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 815 of file G4ToolsSGSceneHandler.cc.

816{
817//G4cout << "debug : G4ToolsSGSceneHandler::AddPrimitive : 004" << std::endl;
818 if(!fpViewer) return;
819
820 auto currentNode = GetOrCreateNode();
821 if (!currentNode) return; // Node not available
822
823 currentNode->add(new tools::sg::light_off());
824
825 tools::sg::plots* _plots = new tools::sg::plots(*fFreetypeNode);
826 currentNode->add(_plots);
827
828 _plots->view_border = false;
829 _plots->set_regions(a_plotter.GetColumns(),a_plotter.GetRows());
830
831 {tools::sg::event_dispatcher* dpt = new tools::sg::event_dispatcher;
832 dpt->add_callback(new plots_cbk(*_plots));
833 currentNode->add(dpt);}
834
835 SetPlotterStyles(*_plots,a_plotter.GetStyles(),a_plotter.GetRegionStyles());
836
837 tools::sg::cmaps_t _cmaps;
838 _cmaps["default"] = tools::sg::style_default_colormap();
839 _cmaps["ROOT"] = tools::sg::style_ROOT_colormap();
840
841 SetPlotterParameters(_cmaps,*_plots,a_plotter.GetRegionParameters());
842
843 fRegionH1s = a_plotter.GetRegionH1s();
844 fRegionH2s = a_plotter.GetRegionH2s();
845
846 SetPlotterHistograms(*_plots);
847}
void SetPlotterParameters(tools::sg::cmaps_t &a_cmaps, tools::sg::plots &a_plots, const std::vector< G4Plotter::RegionParameter > &a_region_parameters)
void SetPlotterStyles(tools::sg::plots &a_plots, const std::vector< G4String > &a_plotter_styles, const std::vector< G4Plotter::RegionStyle > &a_region_styles)
unsigned int GetRows() const
Definition: G4Plotter.hh:68
const std::vector< RegionParameter > & GetRegionParameters() const
Definition: G4Plotter.hh:71
const std::vector< G4String > & GetStyles() const
Definition: G4Plotter.hh:69
const std::vector< Region_h2 > & GetRegionH2s() const
Definition: G4Plotter.hh:76
const std::vector< RegionStyle > & GetRegionStyles() const
Definition: G4Plotter.hh:70
const std::vector< Region_h1 > & GetRegionH1s() const
Definition: G4Plotter.hh:75
unsigned int GetColumns() const
Definition: G4Plotter.hh:67
void SetPlotterHistograms(tools::sg::plots &)
std::vector< Region_h1 > fRegionH1s
tools::sg::separator * GetOrCreateNode()
std::vector< Region_h2 > fRegionH2s

◆ AddPrimitive() [3/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Polyhedron a_polyhedron)
virtual

Implements G4VSceneHandler.

Definition at line 433 of file G4ToolsSGSceneHandler.cc.

434{
435 if (a_polyhedron.GetNoFacets() == 0) return;
436
437 //::printf("debug : G4ToolsSGSceneHandler::AddPrimitive(const G4Polyhedron&) : %d\n",a_polyhedron.GetNoFacets());
438
440
441 // Roll out vertices and normals for the faces. Note that this means vertices
442 // are duplicated. For example a box has 8 vertices, but to define 6 faces
443 // you need 12 triangles and 36 vertices. If it was just a matter of vertices
444 // we could restrict the number to 8 and use the indices to define the
445 // triangles, but we also have to consider the normals. A vertex can be have
446 // more than one normal, depending on which face it is being used to define.
447 // So we roll out all the vertices and normals for each triangle.
448 std::vector<G4Point3D> vertices;
449 std::vector<G4Normal3D> normals;
450
451 // Also roll out edges (as lines) for wireframe. Avoid duplicate lines,
452 // including those that differ only in the order of vertices.
453 typedef std::pair<G4Point3D,G4Point3D> Line;
454 std::vector<Line> lines;
455 auto insertIfNew = [&lines](const Line& newLine) {
456// for (const auto& line: lines) {
457// if ((newLine.first==line.first && newLine.second==line.second) ||
458// (newLine.first==line.second && newLine.second==line.first))
459// return;
460// }
461 lines.push_back(newLine);
462 };
463
464 G4bool isAuxilaryEdgeVisible = fpViewer->GetViewParameters().IsAuxEdgeVisible();
465 G4bool notLastFace;
466 do {
467 G4int nEdges;
468 G4Point3D vertex [4];
469 G4int edgeFlag[4];
470 G4Normal3D normal [4];
471 notLastFace = a_polyhedron.GetNextFacet(nEdges, vertex, edgeFlag, normal);
472 vertices.push_back(vertex[0]);
473 vertices.push_back(vertex[1]);
474 vertices.push_back(vertex[2]);
475 normals.push_back(normal[0]);
476 normals.push_back(normal[1]);
477 normals.push_back(normal[2]);
478 if(isAuxilaryEdgeVisible||edgeFlag[0]>0)insertIfNew(Line(vertex[0],vertex[1]));
479 if(isAuxilaryEdgeVisible||edgeFlag[1]>0)insertIfNew(Line(vertex[1],vertex[2]));
480 if (nEdges == 3) {
481 // Face is a triangle
482 // One more line for wireframe, triangles for surfaces are complete
483 if(isAuxilaryEdgeVisible||edgeFlag[2]>0)insertIfNew(Line(vertex[2],vertex[0]));
484 } else if (nEdges == 4) {
485 // Face is a quadrilateral
486 // Create another triangle for surfaces, add two more lines for wireframe
487 vertices.push_back(vertex[2]);
488 vertices.push_back(vertex[3]);
489 vertices.push_back(vertex[0]);
490 normals.push_back(normal[2]);
491 normals.push_back(normal[3]);
492 normals.push_back(normal[0]);
493 if(isAuxilaryEdgeVisible||edgeFlag[2]>0)insertIfNew(Line(vertex[2],vertex[3]));
494 if(isAuxilaryEdgeVisible||edgeFlag[3]>0)insertIfNew(Line(vertex[3],vertex[0]));
495 } else {
496 G4cerr
497 << "ERROR: polyhedron face with unexpected number of edges (" << nEdges << ')'
498 << "\n Tag: " << fpModel->GetCurrentTag()
499 << G4endl;
500 return;
501 }
502 } while (notLastFace);
503
505 switch (drawing_style) {
507 //vertices.clear();
508 break;
510 break;
512 //lines.clear();
513 break;
515 break;
517 // Shouldn't happen in this function (it's a polyhedron!) - ignore
518 return;
519 }
520
521 auto currentNode = GetOrCreateNode();
522 if (!currentNode) return; // Node not available
523
524 tools::sg::separator* sep = new tools::sg::separator;
525 currentNode->add(sep);
526
527 // Transformation
528 {tools::sg::matrix* mtx = new tools::sg::matrix;
530 mtx->mtx.value().set_matrix(elem(0,0),elem(0,1),elem(0,2),elem(0,3),
531 elem(1,0),elem(1,1),elem(1,2),elem(1,3),
532 elem(2,0),elem(2,1),elem(2,2),elem(2,3),
533 0, 0, 0, 1);
534 sep->add(mtx);}
535
536 {const auto& colour = GetColour(a_polyhedron);
537 tools::sg::rgba* mat = new tools::sg::rgba();
538 mat->color =
539 tools::colorf(float(colour.GetRed()),
540 float(colour.GetGreen()),
541 float(colour.GetBlue()),
542 float(colour.GetAlpha()));
543 sep->add(mat);}
544
545 if (drawing_style == G4ViewParameters::hlr ||
546 drawing_style == G4ViewParameters::hsr ||
547 drawing_style == G4ViewParameters::hlhsr) {
548
549 {tools::sg::draw_style* ds = new tools::sg::draw_style;
550 ds->style = tools::sg::draw_filled;
551 //ds->cull_face = true;
552 sep->add(ds);}
553
554 tools::sg::atb_vertices* vtxs = new tools::sg::atb_vertices;
555 vtxs->mode = tools::gl::triangles();
556 sep->add(vtxs);
557
558 const auto nVerts = vertices.size();
559 for (size_t i = 0; i < nVerts; i++) {
560 vtxs->add(float(vertices[i].x()),float(vertices[i].y()),float(vertices[i].z()));
561 vtxs->add_normal(float(normals[i].x()),float(normals[i].y()),float(normals[i].z()));
562 }
563 }
564
565 if (drawing_style == G4ViewParameters::wireframe ||
566 drawing_style == G4ViewParameters::hlr ||
567 drawing_style == G4ViewParameters::hlhsr) {
568
569 {tools::sg::draw_style* ds = new tools::sg::draw_style;
570 ds->style = tools::sg::draw_lines;
571 ds->line_width = 1;
572 sep->add(ds);}
573
574 tools::sg::vertices* vtxs = new tools::sg::vertices;
575 vtxs->mode = tools::gl::lines(); //segments
576 sep->add(vtxs);
577
578 for (const auto& line: lines) {
579 vtxs->add(float(line.first.x()),float(line.first.y()),float(line.first.z()));
580 vtxs->add(float(line.second.x()),float(line.second.y()),float(line.second.z()));
581 }
582
583 }
584}
#define elem(i, j)
G4GLOB_DLL std::ostream G4cerr
virtual G4String GetCurrentTag() const
Definition: G4VModel.cc:46
const G4Colour & GetColour()
G4Transform3D fObjectTransformation
const G4VisAttributes * fpVisAttribs
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
G4bool IsAuxEdgeVisible() const
const G4VisAttributes * GetVisAttributes() const
G4int GetNoFacets() const
G4bool GetNextFacet(G4int &n, G4Point3D *nodes, G4int *edgeFlags=nullptr, G4Normal3D *normals=nullptr) const

◆ AddPrimitive() [4/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Polyline a_polyline)
virtual

Implements G4VSceneHandler.

Definition at line 213 of file G4ToolsSGSceneHandler.cc.

214{
215 //G4cout << "debug : G4ToolsSGSceneHandler::AddPrimitive(const G4Polyline&) : \n" << a_polyline << G4endl;
216 if (a_polyline.size() == 0) return;
217
218 tools::sg::separator* parentNode = 0;
219 if(fProcessing2D) {
220 parentNode = new tools::sg::separator;
222 fpTransient2DObjects.add(parentNode);
223 } else {
224 fpPersistent2DObjects.add(parentNode);
225 }
226
227 } else {
228 parentNode = GetOrCreateNode();
229 if(!parentNode) return;
230
231 tools::sg::matrix* mtx = new tools::sg::matrix;
233 mtx->mtx.value().set_matrix(elem(0,0),elem(0,1),elem(0,2),elem(0,3),
234 elem(1,0),elem(1,1),elem(1,2),elem(1,3),
235 elem(2,0),elem(2,1),elem(2,2),elem(2,3),
236 0, 0, 0, 1);
237 parentNode->add(mtx);
238 }
239
240 {const auto& colour = GetColour(a_polyline);
241 tools::sg::rgba* mat = new tools::sg::rgba();
242 mat->color =
243 tools::colorf(float(colour.GetRed()),
244 float(colour.GetGreen()),
245 float(colour.GetBlue()),
246 float(colour.GetAlpha()));
247 parentNode->add(mat);}
248
249 {tools::sg::draw_style* ds = new tools::sg::draw_style;
250 ds->style = tools::sg::draw_lines;
251 ds->line_width = 1;
252 parentNode->add(ds);}
253
254 tools::sg::vertices* vtxs = new tools::sg::vertices;
255 vtxs->mode = tools::gl::line_strip(); //polyline
256 parentNode->add(vtxs);
257
258 {for (size_t i = 0; i < a_polyline.size(); ++i) {
259 vtxs->add(float(a_polyline[i].x()),float(a_polyline[i].y()),float(a_polyline[i].z()));
260 }}
261
262}

Referenced by AddPrimitive().

◆ AddPrimitive() [5/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Polymarker a_polymarker)
virtual

Reimplemented from G4VSceneHandler.

Definition at line 264 of file G4ToolsSGSceneHandler.cc.

265{
266 //::printf("debug G4ToolsSGSceneHandler::AddPrimitive(const G4Polymarker&) : %lu, type %d\n",
267 // a_polymarker.size(),a_polymarker.GetMarkerType());
268 if (a_polymarker.size() == 0) return;
269 auto currentNode = GetOrCreateNode();
270 if (!currentNode) return; // Node not available
271
272 // Transformation
273 {tools::sg::matrix* mtx = new tools::sg::matrix;
275 mtx->mtx.value().set_matrix(elem(0,0),elem(0,1),elem(0,2),elem(0,3),
276 elem(1,0),elem(1,1),elem(1,2),elem(1,3),
277 elem(2,0),elem(2,1),elem(2,2),elem(2,3),
278 0, 0, 0, 1);
279 currentNode->add(mtx);}
280
281 {const auto& colour = GetColour(a_polymarker);
282 tools::sg::rgba* mat = new tools::sg::rgba();
283 mat->color =
284 tools::colorf(float(colour.GetRed()),
285 float(colour.GetGreen()),
286 float(colour.GetBlue()),
287 float(colour.GetAlpha()));
288 currentNode->add(mat);}
289
290 MarkerSizeType markerSizeType;
291 G4double markerSize = GetMarkerSize(a_polymarker, markerSizeType);
292
293 switch (a_polymarker.GetMarkerType()) {
294 default:
295 case G4Polymarker::dots:{
296 //::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : dots\n");
297 tools::sg::draw_style* ds = new tools::sg::draw_style;
298 ds->style = tools::sg::draw_points;
299 ds->point_size = 1;
300 currentNode->add(ds);
301 tools::sg::vertices* vtxs = new tools::sg::vertices;
302 vtxs->mode = tools::gl::points();
303 {for (size_t i = 0; i < a_polymarker.size(); ++i) {
304 vtxs->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
305 }}
306 currentNode->add(vtxs);
307 }break;
309 //::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : circles\n");
310 {tools::sg::markers* markers = new tools::sg::markers;
311 G4double diameter = markerSize; // OK for "screen-size" (the usual case)
312 if (markerSizeType == G4VSceneHandler::world ) {
313 const G4double scale = 200.; // Roughly pixels per scene
314 diameter *= fpScene->GetExtent().GetExtentRadius()/scale;
315 }
316 markers->size = diameter;
317 markers->style = tools::sg::marker_circle_line;
318 for (size_t i = 0; i < a_polymarker.size(); ++i) {
319 markers->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
320 }
321 currentNode->add(markers);}
322 }break;
324 //::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : square\n");
325 {tools::sg::markers* markers = new tools::sg::markers;
326 G4double side = markerSize; // OK for "screen-size" (the usual case)
327 if (markerSizeType == G4VSceneHandler::world ) {
328 const G4double scale = 200.; // Roughly pixels per scene
329 side *= fpScene->GetExtent().GetExtentRadius()/scale;
330 }
331 markers->size = side;
332 markers->style = tools::sg::marker_square_line;
333 for (size_t i = 0; i < a_polymarker.size(); ++i) {
334 markers->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
335 }
336 currentNode->add(markers);}
337 }break;
338 }
339}
double G4double
Definition: G4Types.hh:83
MarkerType GetMarkerType() const
const G4VisExtent & GetExtent() const
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75

◆ AddPrimitive() [6/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Square a_square)
virtual

Implements G4VSceneHandler.

Definition at line 424 of file G4ToolsSGSceneHandler.cc.

425{
426 G4Polymarker oneSquare(a_square);
427 oneSquare.push_back(a_square.GetPosition());
428 oneSquare.SetMarkerType(G4Polymarker::squares);
429 // Call this AddPrimitive to avoid re-doing sub-class code.
431}

◆ AddPrimitive() [7/7]

void G4ToolsSGSceneHandler::AddPrimitive ( const G4Text a_text)
virtual

Implements G4VSceneHandler.

Definition at line 341 of file G4ToolsSGSceneHandler.cc.

342{
343 //::printf("debug : G4ToolsSGSceneHandler::AddPrimitive(const G4Text&) : 000 : \"%s\"\n",a_text.GetText().c_str());
344 //::printf("debug : G4ToolsSGSceneHandler::AddPrimitive(const G4Text&) : 2D ? %d\n",fProcessing2D);
345 auto pos = a_text.GetPosition();
346 //::printf("debug : Add Text : pos %g %g %g\n",pos.x(),pos.y(),pos.z());
347
348 tools::sg::separator* parentNode = 0;
349 if(fProcessing2D) {
350 parentNode = new tools::sg::separator;
352 fpTransient2DObjects.add(parentNode);
353 } else {
354 fpPersistent2DObjects.add(parentNode);
355 }
356
357 tools::sg::matrix* mtx = new tools::sg::matrix;
358 mtx->set_translate(pos.x(),pos.y(),pos.z());
359 parentNode->add(mtx);
360
361 } else {
362 parentNode = GetOrCreateNode();
363 if (!parentNode) return;
364
365 tools::sg::matrix* mtx = new tools::sg::matrix;
367 mtx->mtx.value().set_matrix(elem(0,0),elem(0,1),elem(0,2),elem(0,3),
368 elem(1,0),elem(1,1),elem(1,2),elem(1,3),
369 elem(2,0),elem(2,1),elem(2,2),elem(2,3),
370 0, 0, 0, 1);
371 parentNode->add(mtx);
372 }
373
374 MarkerSizeType sizeType;
375 G4double size = GetMarkerSize(a_text, sizeType);
376
377 {const auto& colour = GetTextColour(a_text);
378 tools::sg::rgba* mat = new tools::sg::rgba();
379 mat->color =
380 tools::colorf(float(colour.GetRed()),
381 float(colour.GetGreen()),
382 float(colour.GetBlue()),
383 float(colour.GetAlpha()));
384 parentNode->add(mat);}
385
386#ifdef TOOLS_USE_FREETYPE
387 toolx::sg::text_freetype_marker* text = new toolx::sg::text_freetype_marker;
388 text->add_embedded_font(tools::sg::font_lato_regular_ttf(),tools::font::lato_regular_ttf);
389 text->font = tools::sg::font_lato_regular_ttf();
390 text->front_face = tools::sg::winding_cw;
391//text->modeling = tools::sg::font_pixmap; //problem with Qt/GL. It slows rendering!
392#else
393 tools::sg::text_hershey_marker* text = new tools::sg::text_hershey_marker;
394//text->encoding.value(a_encoding);
395#endif
396 text->height = float(size); //pixels
397 text->strings.add(a_text.GetText());
398 {switch (a_text.GetLayout()) {
399 default:
400 case G4Text::left:
401 text->hjust = tools::sg::left;
402 break;
403 case G4Text::centre:
404 text->hjust = tools::sg::center;
405 break;
406 case G4Text::right:
407 text->hjust = tools::sg::right;
408 break;
409 }}
410//text->vjust.value(a_vjust);
411 parentNode->add(text);
412
413}
HepGeom::Translate3D G4Translate3D
Layout GetLayout() const
G4String GetText() const
@ centre
Definition: G4Text.hh:76
@ right
Definition: G4Text.hh:76
@ left
Definition: G4Text.hh:76
const G4Colour & GetTextColour(const G4Text &)

◆ ClearStore()

void G4ToolsSGSceneHandler::ClearStore ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 198 of file G4ToolsSGSceneHandler.cc.

199{
200 fpTransient2DObjects.clear();
201 fpPersistent2DObjects.clear();
202 fpTransient3DObjects.clear();
203 fpPersistent3DObjects.clear();
205}

◆ ClearTransientStore()

void G4ToolsSGSceneHandler::ClearTransientStore ( )
virtual

Reimplemented from G4VSceneHandler.

Definition at line 207 of file G4ToolsSGSceneHandler.cc.

208{
209 fpTransient2DObjects.clear();
210 fpTransient3DObjects.clear();
211}

◆ CreateSG()

void G4ToolsSGSceneHandler::CreateSG ( )
protected

◆ EstablishBaseNodes()

void G4ToolsSGSceneHandler::EstablishBaseNodes ( )
protected

Definition at line 106 of file G4ToolsSGSceneHandler.cc.

107{
108 // Physical volume objects for each world hang from POs
110 size_t nWorlds = transportationManager->GetNoWorlds();
111 std::vector<G4VPhysicalVolume*>::iterator iterWorld = transportationManager->GetWorldsIterator();
112 fpPhysicalVolumeObjects.resize(nWorlds);
113 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
114 G4VPhysicalVolume* _world = (*iterWorld);
115 auto entity = new G4ToolsSGNode;
116 fpPersistent3DObjects.add(entity);
117 entity->SetPVNodeID(G4PhysicalVolumeModel::G4PhysicalVolumeNodeID(_world));
118 fpPhysicalVolumeObjects[i] = entity;
119 }
120}
std::vector< G4ToolsSGNode * > fpPhysicalVolumeObjects
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const

Referenced by ClearStore(), and G4ToolsSGSceneHandler().

◆ GetOrCreateNode()

tools::sg::separator * G4ToolsSGSceneHandler::GetOrCreateNode ( )
protected

Definition at line 122 of file G4ToolsSGSceneHandler.cc.

123{ // Retrieve or create a G4ToolsSGNode node suitable for next solid or primitive
124
125 // For time being, avoid errors in MT mode - see G4ToolsSGViewer::SwitchToMasterThread
126#ifdef G4MULTITHREADED
127 if (!G4Threading::IsMasterThread()) return nullptr;
128#endif
129
130 if (fReadyForTransients) { // All transients hang from this node
131 tools::sg::separator* sep = new tools::sg::separator;
132 fpTransient3DObjects.add(sep);
133 return sep;
134 }
135
136 auto* pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
137
138 if (!pPVModel) { // Persistent objects (e.g., axes)
139 tools::sg::separator* sep = new tools::sg::separator;
140 fpPersistent3DObjects.add(sep);
141 return sep;
142 }
143
144 // So this is a G4PhysicalVolumeModel
146 typedef std::vector<PVNodeID> PVPath;
147 //const PVPath& drawnPVPath = pPVModel->GetDrawnPVPath();
148 const PVPath& fullPVPath = pPVModel->GetFullPVPath();
149 //G4int currentDepth = pPVModel->GetCurrentDepth();
150 //G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
151 //G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
152 //G4Material* pCurrentMaterial = pPVModel->GetCurrentMaterial();
153 // Note: pCurrentMaterial may be zero (parallel world).
154
155 // Find appropriate root
156 const size_t nWorlds = fpPhysicalVolumeObjects.size();
157 size_t iWorld = 0;
158 for (; iWorld < nWorlds; ++iWorld) {
159 if (fullPVPath[0].GetPhysicalVolume() ==
160 fpPhysicalVolumeObjects[iWorld]->GetPVNodeID().GetPhysicalVolume()) break;
161 }
162 if (iWorld == nWorlds) {
163 G4Exception("G4ToolsSGSceneHandler::GetOrCreateNode", "ToolsSG-0000", FatalException,
164 "World mis-match - not possible(!?)");
165 }
166
167 // (Re-)establish pv path of root entity
168 G4ToolsSGNode* _world = fpPhysicalVolumeObjects[iWorld];
169 _world->SetPVNodeID(fullPVPath[0]);
170
171 // Provide nodes as required - may be a new node or a pre-existing node
172 G4ToolsSGNode* node = _world; // Working variable - default to world
173 const size_t depth = fullPVPath.size();
174 size_t iDepth = 1;
175 while (iDepth < depth) {
176 const auto& children = node->children();
177 const G4int nChildren = (G4int)children.size();
178 G4int iChild = 0;
179 G4ToolsSGNode* child = nullptr;
180 for (; iChild < nChildren; ++iChild) {
181 child = static_cast<G4ToolsSGNode*>(children[iChild]);
182 if (child->GetPVNodeID() == fullPVPath[iDepth]) break;
183 }
184 if (iChild != nChildren) { // Existing node found
185 node = child; // Must be the ancestor of new node (subsequent iteration)
186 } else {
187 // Add a new node as child of node
188 G4ToolsSGNode* newNode = new G4ToolsSGNode;
189 node->add(newNode);
190 newNode->SetPVNodeID(fullPVPath[iDepth]);
191 node = newNode;
192 }
193 ++iDepth;
194 }
195 return node;
196}
const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID & GetPVNodeID() const
void SetPVNodeID(const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID &id)
G4bool IsMasterThread()
Definition: G4Threading.cc:124

Referenced by AddPrimitive().

◆ GetPersistent2DObjects()

tools::sg::separator & G4ToolsSGSceneHandler::GetPersistent2DObjects ( )
inline

◆ GetPersistent3DObjects()

tools::sg::separator & G4ToolsSGSceneHandler::GetPersistent3DObjects ( )
inline

◆ GetTransient2DObjects()

tools::sg::separator & G4ToolsSGSceneHandler::GetTransient2DObjects ( )
inline

◆ GetTransient3DObjects()

tools::sg::separator & G4ToolsSGSceneHandler::GetTransient3DObjects ( )
inline

◆ operator=()

G4ToolsSGSceneHandler & G4ToolsSGSceneHandler::operator= ( const G4ToolsSGSceneHandler )
inlineprotected

Definition at line 73 of file G4ToolsSGSceneHandler.hh.

73{return *this;}

◆ SetPlotterHistograms()

void G4ToolsSGSceneHandler::SetPlotterHistograms ( tools::sg::plots &  a_plots)
protected

Definition at line 708 of file G4ToolsSGSceneHandler.cc.

708 {
709 a_plots.clear();
711 if(UI==NULL) return;
712 {tools_vforcit(Region_h1,fRegionH1s,it) {
713 tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
714 if(_plotter) {
715 int hid = (*it).second;
716 std::ostringstream os;
717 os << hid;
718 std::string cmd("/analysis/h1/get ");
719 cmd += std::string(os.str());
720 auto keepControlVerbose = UI->GetVerboseLevel();
721 UI->SetVerboseLevel(0);
722 G4int status = UI->ApplyCommand(cmd.c_str());
723 UI->SetVerboseLevel(keepControlVerbose);
724 if(status==G4UIcommandStatus::fCommandSucceeded) {
725 G4String hexString = UI->GetCurrentValues("/analysis/h1/get");
726 if(hexString.size()) {
727 void* ptr;
728 std::istringstream is(hexString);
729 is >> ptr;
730 tools::histo::h1d* _h = (tools::histo::h1d*)ptr;
731 tools::sg::plottable* p = new tools::sg::h1d2plot_cp(*_h);
732 _plotter->add_plottable(p); //give ownership of p to sg::plotter.
733 }
734 } else {
735 G4cerr <<
736 "G4ToolsSGSceneHandler::SetPlotterHistograms: cannot get histogram - maybe doesn't exist?"
737 "\n Maybe this app does not do analysis at all?"
738 << G4endl;
739 }
740 }
741 }}
742 {tools_vforcit(Region_h2,fRegionH2s,it) {
743 tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
744 if(_plotter) {
745 int hid = (*it).second;
746 std::ostringstream os;
747 os << hid;
748 std::string cmd("/analysis/h2/get ");
749 cmd += std::string(os.str());
750 auto keepControlVerbose = UI->GetVerboseLevel();
751 UI->SetVerboseLevel(0);
752 G4int status = UI->ApplyCommand(cmd.c_str());
753 UI->SetVerboseLevel(keepControlVerbose);
754 if(status==G4UIcommandStatus::fCommandSucceeded) {
755 G4String hexString = UI->GetCurrentValues("/analysis/h2/get");
756 if(hexString.size()) {
757 void* ptr;
758 std::istringstream is(hexString);
759 is >> ptr;
760 tools::histo::h2d* _h = (tools::histo::h2d*)ptr;
761 tools::sg::plottable* p = new tools::sg::h2d2plot_cp(*_h);
762 _plotter->add_plottable(p); //give ownership of p to sg::plotter.
763 }
764 } else {
765 G4cerr <<
766 "G4ToolsSGSceneHandler::SetPlotterHistograms: cannot get histogram - maybe doesn't exist?"
767 "\n Maybe this app does not do analysis at all?"
768 << G4endl;
769 }
770 }
771 }}
772}
std::pair< unsigned int, int > Region_h2
std::pair< unsigned int, int > Region_h1
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:200
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:166
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:199

Referenced by AddPrimitive(), and TouchPlotters().

◆ TouchPlotters()

void G4ToolsSGSceneHandler::TouchPlotters ( tools::sg::node &  a_sg)

Definition at line 804 of file G4ToolsSGSceneHandler.cc.

804 {
805 tools::sg::search_action sa(G4cout);
806 const tools::sg::search_action::paths_t& paths = tools::sg::find_paths<tools::sg::plots>(sa,a_sg);
807 tools_vforcit(tools::sg::path_t,paths,it) {
808 tools::sg::plots* _plots = tools::sg::tail<tools::sg::plots>(*it);
809 if(_plots) {
810 SetPlotterHistograms(*_plots);
811 }
812 }
813}

Referenced by G4ToolsSGOffscreenViewer::DrawView(), G4ToolsSGOffscreenViewer::FinishView(), and G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::FinishView().

Member Data Documentation

◆ fFreetypeNode

tools::sg::base_freetype* G4ToolsSGSceneHandler::fFreetypeNode
protected

◆ fpPersistent2DObjects

tools::sg::separator G4ToolsSGSceneHandler::fpPersistent2DObjects
protected

◆ fpPersistent3DObjects

tools::sg::separator G4ToolsSGSceneHandler::fpPersistent3DObjects
protected

◆ fpPhysicalVolumeObjects

std::vector<G4ToolsSGNode*> G4ToolsSGSceneHandler::fpPhysicalVolumeObjects
protected

Definition at line 90 of file G4ToolsSGSceneHandler.hh.

Referenced by EstablishBaseNodes(), and GetOrCreateNode().

◆ fpTransient2DObjects

tools::sg::separator G4ToolsSGSceneHandler::fpTransient2DObjects
protected

◆ fpTransient3DObjects

tools::sg::separator G4ToolsSGSceneHandler::fpTransient3DObjects
protected

◆ fRegionH1s

std::vector<Region_h1> G4ToolsSGSceneHandler::fRegionH1s
protected

Definition at line 96 of file G4ToolsSGSceneHandler.hh.

Referenced by AddPrimitive(), and SetPlotterHistograms().

◆ fRegionH2s

std::vector<Region_h2> G4ToolsSGSceneHandler::fRegionH2s
protected

Definition at line 97 of file G4ToolsSGSceneHandler.hh.

Referenced by AddPrimitive(), and SetPlotterHistograms().

◆ fSceneIdCount

G4int G4ToolsSGSceneHandler::fSceneIdCount = 0
staticprotected

Definition at line 82 of file G4ToolsSGSceneHandler.hh.


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