Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:54

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * =============================================================================
0028  *
0029  *       Filename:  CexmcScenePrimitivesMessenger.cc
0030  *
0031  *    Description:  draw auxiliary scene primitives
0032  *
0033  *        Version:  1.0
0034  *        Created:  03.01.2011 12:42:03
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * =============================================================================
0042  */
0043 
0044 #include <sstream>
0045 #include <cctype>
0046 #include <G4UIparameter.hh>
0047 #include <G4UIcommand.hh>
0048 #include <G4UIcmdWith3Vector.hh>
0049 #include <G4UIcmdWithABool.hh>
0050 #include <G4UIcmdWithoutParameter.hh>
0051 #include <G4Colour.hh>
0052 #include "CexmcScenePrimitives.hh"
0053 #include "CexmcScenePrimitivesMessenger.hh"
0054 #include "CexmcMessenger.hh"
0055 
0056 
0057 CexmcScenePrimitivesMessenger::CexmcScenePrimitivesMessenger(
0058                                     CexmcScenePrimitives *  scenePrimitives_ ) :
0059     scenePrimitives( scenePrimitives_ ), drawRadialLine( NULL ),
0060     clearRadialLines( NULL ), markTargetCenter( NULL ),
0061     highlightInnerCrystals( NULL ), setColour( NULL )
0062 {
0063     drawRadialLine = new G4UIcmdWith3Vector(
0064         ( CexmcMessenger::visDirName + "drawRadialLine" ).c_str(), this );
0065     drawRadialLine->SetGuidance( "Draw radial line with specified theta, phi "
0066                                  "(both in deg!)\n    and length (in cm!)" );
0067     drawRadialLine->SetParameterName( "RadialLineTheta", "RadialLinePhi",
0068                                       "RadialLineLength", true );
0069     drawRadialLine->SetRange( "RadialLineLength >= 0." );
0070     drawRadialLine->SetDefaultValue( G4ThreeVector( 0., 0., 100. ) );
0071     drawRadialLine->AvailableForStates( G4State_PreInit, G4State_Idle );
0072 
0073     clearRadialLines = new G4UIcmdWithoutParameter(
0074         ( CexmcMessenger::visDirName + "clearRadialLines" ).c_str(), this );
0075     clearRadialLines->SetGuidance( "Clear all existing radial lines" );
0076     clearRadialLines->AvailableForStates( G4State_PreInit, G4State_Idle );
0077 
0078     markTargetCenter = new G4UIcmdWithABool(
0079         ( CexmcMessenger::visDirName + "markTargetCenter" ).c_str(), this );
0080     markTargetCenter->SetGuidance( "Mark/unmark target center" );
0081     markTargetCenter->SetParameterName( "MarkTargetCenter", true );
0082     markTargetCenter->SetDefaultValue( true );
0083     markTargetCenter->AvailableForStates( G4State_PreInit, G4State_Idle );
0084 
0085     highlightInnerCrystals = new G4UIcmdWithABool(
0086         ( CexmcMessenger::visDirName + "hlIC" ).c_str(), this );
0087     highlightInnerCrystals->SetGuidance( "Highlight inner crystals in "
0088                                          "calorimeters on/off" );
0089     highlightInnerCrystals->SetParameterName( "HighlightInnerCrystals", true );
0090     highlightInnerCrystals->SetDefaultValue( true );
0091     highlightInnerCrystals->AvailableForStates( G4State_PreInit, G4State_Idle );
0092 
0093     setColour = new G4UIcommand(
0094         ( CexmcMessenger::visDirName + "setColour" ).c_str(), this );
0095     setColour->SetGuidance( "Set colour of specified scene primitive" );
0096     G4UIparameter *  parameter( new G4UIparameter( "ScenePrimitive", 's',
0097                                                    false ) );
0098     parameter->SetGuidance( "Scene primitive, possible values:\n"
0099         "    tc - target center mark,\n"
0100         "    rl - radial lines,\n"
0101         "    ic - inner crystal highlights" );
0102     parameter->SetParameterCandidates( "tc rl ic" );
0103     setColour->SetParameter( parameter );
0104     parameter = new G4UIparameter( "red", 's', true );
0105     parameter->SetGuidance( "Red component or string, e.g. \"blue\", in which "
0106         "case succeeding colour\n    components are ignored" );
0107     parameter->SetDefaultValue( "1.0" );
0108     setColour->SetParameter( parameter );
0109     parameter = new G4UIparameter( "green", 'd', true );
0110     parameter->SetGuidance( "Green component" );
0111     parameter->SetDefaultValue( 1.0 );
0112     setColour->SetParameter( parameter );
0113     parameter = new G4UIparameter( "blue", 'd', true );
0114     parameter->SetGuidance( "Blue component" );
0115     parameter->SetDefaultValue( 1.0 );
0116     setColour->SetParameter( parameter );
0117     parameter = new G4UIparameter( "opacity", 'd', true );
0118     parameter->SetGuidance( "Opacity" );
0119     parameter->SetDefaultValue( 1.0 );
0120     setColour->SetParameter( parameter );
0121     setColour->AvailableForStates( G4State_PreInit, G4State_Idle );
0122 }
0123 
0124 
0125 CexmcScenePrimitivesMessenger::~CexmcScenePrimitivesMessenger()
0126 {
0127     delete drawRadialLine;
0128     delete clearRadialLines;
0129     delete markTargetCenter;
0130     delete highlightInnerCrystals;
0131     delete setColour;
0132 }
0133 
0134 
0135 void  CexmcScenePrimitivesMessenger::SetNewValue( G4UIcommand *  cmd,
0136                                                   G4String  value )
0137 {
0138     do
0139     {
0140         if ( cmd == drawRadialLine )
0141         {
0142             G4ThreeVector  line( G4UIcmdWith3Vector::GetNew3VectorValue(
0143                                                                     value ) );
0144             scenePrimitives->DrawRadialLine( line );
0145             break;
0146         }
0147         if ( cmd == clearRadialLines )
0148         {
0149             scenePrimitives->ClearRadialLines();
0150             break;
0151         }
0152         if ( cmd == markTargetCenter )
0153         {
0154             scenePrimitives->MarkTargetCenter(
0155                                 G4UIcmdWithABool::GetNewBoolValue( value ) );
0156             break;
0157         }
0158         if ( cmd == highlightInnerCrystals )
0159         {
0160             scenePrimitives->HighlightInnerCrystals(
0161                                 G4UIcmdWithABool::GetNewBoolValue( value ) );
0162             break;
0163         }
0164         if ( cmd == setColour )
0165         {
0166             G4String            name;
0167             G4String            redOrString;
0168             G4double            green( 1 );
0169             G4double            blue( 1 );
0170             G4double            opacity( 1 );
0171             G4Colour            colour( 1, green, blue, opacity );
0172             std::istringstream  iss( value );
0173 
0174             iss >> name >> redOrString >> green >> blue >> opacity;
0175 
0176             if ( std::isalpha( redOrString[ size_t( 0 ) ] ) )
0177             {
0178                 G4Colour::GetColour( redOrString, colour );
0179             }
0180             else
0181             {
0182                 colour = G4Colour( G4UIcommand::ConvertToDouble( redOrString ),
0183                                    green, blue );
0184             }
0185             colour = G4Colour( colour.GetRed(), colour.GetGreen(),
0186                                colour.GetBlue(), opacity );
0187 
0188             CexmcSPType  primitive( CexmcTargetCenterMark_SP );
0189             do
0190             {
0191                 if ( name == "tc" )
0192                 {
0193                     primitive = CexmcTargetCenterMark_SP;
0194                     break;
0195                 }
0196                 if ( name == "rl" )
0197                 {
0198                     primitive = CexmcRadialLine_SP;
0199                     break;
0200                 }
0201                 if ( name == "ic" )
0202                 {
0203                     primitive = CexmcInnerCrystalsHl_SP;
0204                     break;
0205                 }
0206                 return;
0207             } while ( false );
0208 
0209             scenePrimitives->SetColour( primitive, colour );
0210             break;
0211         }
0212     } while ( false );
0213 }
0214