BLCMDshowmaterial Class Reference

Inheritance diagram for BLCMDshowmaterial:

BLCommand BLCallback

List of all members.


Detailed Description

class BLCMDshowmaterial - command to display a set of materials

Each argument name must be a material name, and name=1,1,0 assigns a color to that material, overriding any color assigned by the object. hideOthers=1 causes all other materials to be made invisible.

Applies to ALL logical volumes with each material.

Useful to display Vacuum regions, which are usually invisible and enclosed in pipes.

Public Member Functions

 BLCMDshowmaterial ()
 Constructor.
 ~BLCMDshowmaterial ()
 Destructor.
G4String commandName ()
 commandName() returns "showmaterial"
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
 command() executes the command associated with this element.
const G4VisAttributes * getVisAttributes (const G4Material *pm) const
 getVisAttributes() will return the G4VisAttributes for a material.
void callback (int type)
 callback() from BLCallback.
void handlePV (G4VPhysicalVolume *phys)
 handlePV() recursively handles physical volume-s.

Private Attributes

int hideOthers

Static Private Attributes

static std::map< const
G4Material *, const
G4VisAttributes * > 
mat2va


Constructor & Destructor Documentation

BLCMDshowmaterial::BLCMDshowmaterial (  ) 

Constructor.

References BLCMDTYPE_CONTROL, hideOthers, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().

00075                                      : BLCommand()
00076 {
00077         registerCommand(BLCMDTYPE_CONTROL);
00078         setSynopsis("Set the colors for selected materials.");
00079         setDescription("Arguments are of the form 'name=1,1,0', where name is\n"
00080                         "the name of a material, and 1,1,0 is the\n"
00081                         "R,G,B value desired for its color ('' for invisible)\n"
00082                         "Set hideOthers=1 to make all other materials invisible.\n"
00083                         "BEWARE: 'Vacuum' and 'vacuum' are different materials,\n"
00084                         "as are 'Iron' and 'Fe'.");
00085         hideOthers = 0;
00086 }

BLCMDshowmaterial::~BLCMDshowmaterial (  )  [inline]

Destructor.

00053 { }


Member Function Documentation

G4String BLCMDshowmaterial::commandName (  )  [inline, virtual]

commandName() returns "showmaterial"

Implements BLCommand.

00056 { return "showmaterial"; }

int BLCMDshowmaterial::command ( BLArgumentVector argv,
BLArgumentMap namedArgs 
) [virtual]

command() executes the command associated with this element.

Implements BLCommand.

References BLCommand::getMaterial(), BLManager::getObject(), BLCommand::getVisAttrib(), hideOthers, mat2va, BLCommand::print(), BLCommand::printError(), and BLManager::registerCallback().

00089 {
00090         int retval = 0;
00091 
00092         if(argv.size() > 0) {
00093                 printError("showmaterial: unnamed arguments are invalid.");
00094                 retval = 1;
00095         }
00096 
00097         BLArgumentMap::iterator i;
00098         for(i=namedArgs.begin(); i!=namedArgs.end(); ++i) {
00099                 G4String name = i->first;
00100                 G4String value = i->second;
00101                 if(name == "hideOthers") {
00102                         hideOthers = atoi(value.c_str());
00103                         continue;
00104                 }
00105                 const G4VisAttributes *va = getVisAttrib(value);
00106                 G4Material *pm = getMaterial(name,false);
00107                 if(!pm) {
00108                         printError("showmaterial: material '%s' not found",
00109                                                                 name.c_str());
00110                         retval = 1;
00111                         continue;
00112                 }
00113                 mat2va[pm] = va;
00114         }
00115 
00116         BLManager::getObject()->registerCallback(this, 0);
00117 
00118         print("",namedArgs);
00119 
00120         return retval;
00121 }

const G4VisAttributes * BLCMDshowmaterial::getVisAttributes ( const G4Material *  pm  )  const

getVisAttributes() will return the G4VisAttributes for a material.

References mat2va.

Referenced by handlePV().

00124 {
00125         if(mat2va.count(pm) > 0)
00126                 return mat2va[pm];
00127         return 0;
00128 }

void BLCMDshowmaterial::callback ( int  type  )  [virtual]

callback() from BLCallback.

Reimplemented from BLCallback.

References BLManager::getObject(), BLManager::getWorldPhysicalVolume(), and handlePV().

00131 {
00132         G4VPhysicalVolume *phys = 
00133                         BLManager::getObject()->getWorldPhysicalVolume();
00134         handlePV(phys);
00135 }

void BLCMDshowmaterial::handlePV ( G4VPhysicalVolume *  phys  ) 

handlePV() recursively handles physical volume-s.

References getVisAttributes(), and hideOthers.

Referenced by callback().

00138 {
00139         G4LogicalVolume *log = phys->GetLogicalVolume();
00140         const G4VisAttributes *va = getVisAttributes(log->GetMaterial());
00141         if(!va && hideOthers) va = &G4VisAttributes::GetInvisible();
00142         log->SetVisAttributes(va);
00143 
00144         int n = log->GetNoDaughters();
00145         for(int i=0; i<n; ++i) {
00146                 G4VPhysicalVolume *p = log->GetDaughter(i);
00147                 if(p)
00148                         handlePV(p);
00149         }
00150 }


Member Data Documentation

std::map< const G4Material *, const G4VisAttributes * > BLCMDshowmaterial::mat2va [static, private]

Referenced by command(), and getVisAttributes().


The documentation for this class was generated from the following file:
g4beamline