Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /* 27 * ============================================================================= 28 * 29 * Filename: CexmcScenePrimitives.hh 30 * 31 * Description: auxiliary scene primitives (radial lines etc.) 32 * 33 * Version: 1.0 34 * Created: 03.01.2011 11:27:34 35 * Revision: none 36 * Compiler: gcc 37 * 38 * Author: Alexey Radkov (), 39 * Company: PNPI 40 * 41 * ============================================================================= 42 */ 43 44 #ifndef CEXMC_SCENE_PRIMITIVES_HH 45 #define CEXMC_SCENE_PRIMITIVES_HH 46 47 #include <vector> 48 #include <map> 49 #include <G4Colour.hh> 50 #include <G4ThreeVector.hh> 51 #include <G4VModel.hh> 52 #include <G4VVisManager.hh> 53 54 class G4VGraphicsScene; 55 class CexmcSetup; 56 class CexmcScenePrimitivesMessenger; 57 58 59 enum CexmcSPType 60 { 61 CexmcTargetCenterMark_SP, 62 CexmcRadialLine_SP, 63 CexmcInnerCrystalsHl_SP 64 }; 65 66 67 class CexmcScenePrimitives : public G4VModel 68 { 69 private: 70 struct CexmcRadialLine 71 { 72 CexmcRadialLine( const G4ThreeVector & line ) : 73 theta( line.x() ), phi( line.y() ), length( line.z() ) 74 {} 75 76 G4double theta; 77 78 G4double phi; 79 80 G4double length; 81 }; 82 83 typedef std::vector< CexmcRadialLine > CexmcRadialLines; 84 85 typedef std::map< CexmcSPType, G4Colour > CexmcSPColourMap; 86 87 public: 88 explicit CexmcScenePrimitives( CexmcSetup * setup ); 89 90 ~CexmcScenePrimitives(); 91 92 public: 93 void DescribeYourselfTo( G4VGraphicsScene & scene ); 94 95 public: 96 void MarkTargetCenter( G4bool on = true ); 97 98 void DrawRadialLine( const G4ThreeVector & line ); 99 100 void HighlightInnerCrystals( G4bool = true ); 101 102 void ClearRadialLines( void ); 103 104 void SetColour( CexmcSPType primitive, const G4Colour & colour ); 105 106 private: 107 void DrawRadialLine( G4VGraphicsScene & scene, 108 const CexmcRadialLine * rLine ); 109 110 void MarkTargetCenter( G4VGraphicsScene & scene ); 111 112 void HighlightInnerCrystals( G4VGraphicsScene & scene ); 113 114 private: 115 void UpdateScene( void ); 116 117 private: 118 CexmcSetup * setup; 119 120 G4bool markTargetCenter; 121 122 G4bool highlightInnerCrystals; 123 124 CexmcRadialLines radialLines; 125 126 CexmcSPColourMap spColours; 127 128 private: 129 CexmcScenePrimitivesMessenger * messenger; 130 }; 131 132 133 inline void CexmcScenePrimitives::SetColour( CexmcSPType primitive, 134 const G4Colour & colour ) 135 { 136 spColours[ primitive ] = colour; 137 } 138 139 140 inline void CexmcScenePrimitives::DrawRadialLine( const G4ThreeVector & line ) 141 { 142 radialLines.push_back( line ); 143 UpdateScene(); 144 } 145 146 147 inline void CexmcScenePrimitives::MarkTargetCenter( G4bool on ) 148 { 149 markTargetCenter = on; 150 UpdateScene(); 151 } 152 153 154 inline void CexmcScenePrimitives::HighlightInnerCrystals( G4bool on ) 155 { 156 highlightInnerCrystals = on; 157 UpdateScene(); 158 } 159 160 161 inline void CexmcScenePrimitives::ClearRadialLines( void ) 162 { 163 radialLines.clear(); 164 UpdateScene(); 165 } 166 167 168 inline void CexmcScenePrimitives::UpdateScene( void ) 169 { 170 G4VVisManager * visManager( G4VVisManager::GetConcreteInstance() ); 171 if ( visManager ) 172 visManager->NotifyHandlers(); 173 } 174 175 176 #endif 177 178