File indexing completed on 2025-01-31 09:21:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #ifndef CEXMC_SCENE_PRIMITIVES_HH
0045 #define CEXMC_SCENE_PRIMITIVES_HH
0046
0047 #include <vector>
0048 #include <map>
0049 #include <G4Colour.hh>
0050 #include <G4ThreeVector.hh>
0051 #include <G4VModel.hh>
0052 #include <G4VVisManager.hh>
0053
0054 class G4VGraphicsScene;
0055 class CexmcSetup;
0056 class CexmcScenePrimitivesMessenger;
0057
0058
0059 enum CexmcSPType
0060 {
0061 CexmcTargetCenterMark_SP,
0062 CexmcRadialLine_SP,
0063 CexmcInnerCrystalsHl_SP
0064 };
0065
0066
0067 class CexmcScenePrimitives : public G4VModel
0068 {
0069 private:
0070 struct CexmcRadialLine
0071 {
0072 CexmcRadialLine( const G4ThreeVector & line ) :
0073 theta( line.x() ), phi( line.y() ), length( line.z() )
0074 {}
0075
0076 G4double theta;
0077
0078 G4double phi;
0079
0080 G4double length;
0081 };
0082
0083 typedef std::vector< CexmcRadialLine > CexmcRadialLines;
0084
0085 typedef std::map< CexmcSPType, G4Colour > CexmcSPColourMap;
0086
0087 public:
0088 explicit CexmcScenePrimitives( CexmcSetup * setup );
0089
0090 ~CexmcScenePrimitives();
0091
0092 public:
0093 void DescribeYourselfTo( G4VGraphicsScene & scene );
0094
0095 public:
0096 void MarkTargetCenter( G4bool on = true );
0097
0098 void DrawRadialLine( const G4ThreeVector & line );
0099
0100 void HighlightInnerCrystals( G4bool = true );
0101
0102 void ClearRadialLines( void );
0103
0104 void SetColour( CexmcSPType primitive, const G4Colour & colour );
0105
0106 private:
0107 void DrawRadialLine( G4VGraphicsScene & scene,
0108 const CexmcRadialLine * rLine );
0109
0110 void MarkTargetCenter( G4VGraphicsScene & scene );
0111
0112 void HighlightInnerCrystals( G4VGraphicsScene & scene );
0113
0114 private:
0115 void UpdateScene( void );
0116
0117 private:
0118 CexmcSetup * setup;
0119
0120 G4bool markTargetCenter;
0121
0122 G4bool highlightInnerCrystals;
0123
0124 CexmcRadialLines radialLines;
0125
0126 CexmcSPColourMap spColours;
0127
0128 private:
0129 CexmcScenePrimitivesMessenger * messenger;
0130 };
0131
0132
0133 inline void CexmcScenePrimitives::SetColour( CexmcSPType primitive,
0134 const G4Colour & colour )
0135 {
0136 spColours[ primitive ] = colour;
0137 }
0138
0139
0140 inline void CexmcScenePrimitives::DrawRadialLine( const G4ThreeVector & line )
0141 {
0142 radialLines.push_back( line );
0143 UpdateScene();
0144 }
0145
0146
0147 inline void CexmcScenePrimitives::MarkTargetCenter( G4bool on )
0148 {
0149 markTargetCenter = on;
0150 UpdateScene();
0151 }
0152
0153
0154 inline void CexmcScenePrimitives::HighlightInnerCrystals( G4bool on )
0155 {
0156 highlightInnerCrystals = on;
0157 UpdateScene();
0158 }
0159
0160
0161 inline void CexmcScenePrimitives::ClearRadialLines( void )
0162 {
0163 radialLines.clear();
0164 UpdateScene();
0165 }
0166
0167
0168 inline void CexmcScenePrimitives::UpdateScene( void )
0169 {
0170 G4VVisManager * visManager( G4VVisManager::GetConcreteInstance() );
0171 if ( visManager )
0172 visManager->NotifyHandlers();
0173 }
0174
0175
0176 #endif
0177