83 using namespace HEPREP;
 
   84 using namespace cheprep;
 
   87 G4int G4HepRepSceneHandler::sceneIdCount = 0;
 
   96           geometryLayer         (
"Geometry"),
 
   98           calHitLayer           (
"CalHit"),
 
   99           trajectoryLayer       (
"Trajectory"),
 
  101           rootVolumeName        (
"Geometry"),
 
  103           eventNumberPrefix     (
""),
 
  104           eventNumberSuffix     (
""),
 
  106           eventNumberWidth      (-1),
 
  111           writeMultipleFiles    (false),
 
  115           _heprepGeometry       (NULL)
 
  119     cout << 
"G4HepRepSceneHandler::G4HepRepSceneHandler: " << system << endl;
 
  137     cout << 
"G4HepRepSceneHandler::~G4HepRepSceneHandler() " << endl;
 
  150     if (writer != NULL) 
return;
 
  152     if (name == 
"stdout") {
 
  154         cout << 
"G4HepRepSceneHandler::Open() stdout" << endl;
 
  159         eventNumberPrefix = 
"";
 
  160         eventNumberSuffix = 
"";
 
  165         writeMultipleFiles = 
false;
 
  167         eventNumberWidth = 0;        
 
  168     } 
else if (name == 
"stderr") {
 
  170         cout << 
"G4HepRepSceneHandler::Open() stderr" << endl;
 
  175         eventNumberPrefix = 
"";
 
  176         eventNumberSuffix = 
"";
 
  181         writeMultipleFiles = 
false;
 
  183         eventNumberWidth = 0;        
 
  186         cout << 
"G4HepRepSceneHandler::Open() " << name << endl;
 
  188         if (eventNumberWidth < 0) {
 
  191             const unsigned int numberOfExtensions = 8;
 
  192             string ext[numberOfExtensions] = {
".heprep", 
".heprep.xml", 
".heprep.zip", 
".heprep.gz",
 
  193                                               ".bheprep", 
".bheprep.xml", 
".bheprep.zip", 
".bheprep.gz"};
 
  195             while (i < numberOfExtensions) {
 
  196                 int dot = name.size() - ext[i].size();
 
  198                     (name.substr(dot, ext[i].size()) == ext[i])) 
break;
 
  202             if (i != numberOfExtensions) {
 
  204                 writeBinary = i >= (numberOfExtensions/2);
 
  205                 writeZip = (i == 2) || (i == 6);
 
  206                 writeGZ = (i == 3) || (i == 7);
 
  208                 int dot = name.length() - extension.length();
 
  209                 baseName = (dot >= 0) ? name.substr(0, dot) : 
"";
 
  213                 extension = 
".heprep.zip";
 
  220             writeMultipleFiles = 
false;
 
  221             int startDigit = -1; 
int endDigit = -1;
 
  228                 endDigit = suffix.length()-1; 
 
  229                 while (endDigit >= 0) {
 
  230                     if (isdigit(suffix.at(endDigit))) 
break;
 
  234                     cerr << 
"/vis/heprep/appendEventNumberSuffix contains no digits" << endl;
 
  236                     writeMultipleFiles = 
true;
 
  237                     startDigit = endDigit;
 
  238                     while (startDigit >= 0) {
 
  239                         if (!isdigit(suffix.at(startDigit))) 
break;
 
  246             if (writeMultipleFiles) {
 
  247                 eventNumberPrefix = suffix.substr(0, startDigit);
 
  248                 eventNumber = atoi(suffix.substr(startDigit, endDigit).c_str());
 
  249                 eventNumberWidth = endDigit +1 - startDigit;
 
  250                 eventNumberSuffix = suffix.substr(endDigit+1);
 
  256                 eventNumberWidth = 10;
 
  257                 eventNumberPrefix = 
"";
 
  258                 eventNumberSuffix = 
"";
 
  267     cout << 
"G4HepRepSceneHandler::OpenHepRep() " << endl;
 
  270     if (_heprep != NULL) 
return;
 
  273     _heprepGeometry       = NULL;
 
  274     _geometryInstanceTree = NULL;
 
  275     _geometryRootInstance = NULL;
 
  276     _geometryInstance.clear();
 
  277     _geometryTypeTree     = NULL;
 
  278     _geometryRootType     = NULL;
 
  279     _geometryTypeName.clear();
 
  280     _geometryType.clear();
 
  281     _eventInstanceTree    = NULL;
 
  282     _eventInstance        = NULL;
 
  283     _eventTypeTree        = NULL;
 
  285     _trajectoryType       = NULL;
 
  288     _calHitFaceType       = NULL;     
 
  296     if (_heprep == NULL) 
return true;
 
  299     cout << 
"G4HepRepSceneHandler::CloseHepRep() start" << endl;
 
  304         if (_eventInstanceTree != NULL) {
 
  305             cerr << 
"WARNING: you probably used '/vis/viewer/endOfEventAction accumulate' and " 
  306                  << 
"forgot to call /vis/viewer/update before exit. No event written." << endl;
 
  314         if (_eventInstanceTree != NULL) {
 
  321                 if ((_geometryInstanceTree != NULL)) {
 
  326                 if (writeMultipleFiles) {
 
  327                     sprintf(name, 
"%s%s%s#%s", baseName.c_str(), 
"-geometry", extension.c_str(), 
"G4GeometryData");
 
  329                     sprintf(name, 
"%s%s#%s", 
"geometry", (writeBinary ? 
".bheprep" : 
".heprep"), 
"G4GeometryData");
 
  336         if (_eventInstanceTree != NULL) {
 
  346         writeLayers(_heprepGeometry);
 
  347         writeLayers(_heprep);
 
  350         if (writer == NULL) {
 
  356             if (writeMultipleFiles) {
 
  358                 sprintf(fileName, 
"%s%s%s", baseName.c_str(), 
"-geometry", extension.c_str());
 
  363             sprintf(name, 
"%s%s", 
"geometry", (writeBinary ? 
".bheprep" : 
".heprep"));
 
  364             if (!writeMultipleFiles) {
 
  370             delete _heprepGeometry;
 
  371             _heprepGeometry = NULL;
 
  376         if (writeMultipleFiles) {
 
  383             char fileFormat[128];
 
  384             sprintf(fileFormat, 
"%s%d%s", 
"%s%s%0", eventNumberWidth, 
"d%s%s");
 
  385             sprintf(fileName, fileFormat, baseName.c_str(), eventNumberPrefix.c_str(), eventNumber, eventNumberSuffix.c_str(), extension.c_str());
 
  396         char eventFormat[128];
 
  397         sprintf(eventFormat, 
"%s%d%s%s", 
"event-%0", eventNumberWidth, 
"d", (writeBinary ? 
".bheprep" : 
".heprep"));
 
  398         sprintf(eventName, eventFormat, eventNumber);
 
  413 void G4HepRepSceneHandler::close() {
 
  416     cout << 
"G4HepRepSceneHandler::Close() " << endl;
 
  419     if (writer == NULL) 
return;
 
  421     if (!writeMultipleFiles) {
 
  431     out = 
new ofstream(name.c_str(), std::ios::out | std::ios::binary );
 
  444 void G4HepRepSceneHandler::writeLayers(
HepRep* heprep) {
 
  445     if (heprep == NULL) 
return;
 
  455     cout << 
"G4HepRepSceneHandler::BeginModeling() " << endl;
 
  463     cout << 
"G4HepRepSceneHandler::EndModeling() " << endl;
 
  470     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Box& box)" << endl;
 
  473     if (dontWrite()) 
return;
 
  495     vertex1 = (transform) * vertex1;
 
  496     vertex2 = (transform) * vertex2;
 
  497     vertex3 = (transform) * vertex3;
 
  498     vertex4 = (transform) * vertex4;
 
  499     vertex5 = (transform) * vertex5;
 
  500     vertex6 = (transform) * vertex6;
 
  501     vertex7 = (transform) * vertex7;
 
  502     vertex8 = (transform) * vertex8;
 
  504     HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
 
  505     addAttributes(instance, getCalHitType());
 
  507     setAttribute(instance, 
"DrawAs", 
G4String(
"Prism"));
 
  509     setVisibility(instance, box);
 
  510     setLine(instance, box);
 
  511     setColor(instance, getColorFor(box));
 
  526     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Cons& cons)" << endl;
 
  529     if (dontWrite()) 
return;
 
  552     vertex1 = (transform) * vertex1;
 
  553     vertex2 = (transform) * vertex2;
 
  555     HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
 
  556     setAttribute(instance, 
"DrawAs", 
G4String(
"Cylinder"));
 
  558     setVisibility(instance, cons);
 
  559     setLine(instance, cons);
 
  560     setColor(instance, getColorFor(cons));
 
  567     outer->addAttValue(
"showParentAttributes",
true);
 
  590     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Tubs& tubs)" << endl;
 
  593     if (dontWrite()) 
return;
 
  616     vertex1 = (transform) * vertex1;
 
  617     vertex2 = (transform) * vertex2;
 
  619     HepRepInstance* instance = getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
 
  620     setAttribute(instance, 
"DrawAs", 
G4String(
"Cylinder"));
 
  622     setVisibility(instance, tubs);
 
  623     setLine(instance, tubs);
 
  624     setColor(instance, getColorFor(tubs));
 
  631     outer->addAttValue(
"pickParent",
true);
 
  632     outer->addAttValue(
"showParentAttributes",
true);
 
  650     cout << 
"G4HepRepSceneHandler::AddSolid(const G4Trd& trd)" << endl;
 
  652     if (dontWrite()) 
return;
 
  676     vertex1 = (transform) * vertex1;
 
  677     vertex2 = (transform) * vertex2;
 
  678     vertex3 = (transform) * vertex3;
 
  679     vertex4 = (transform) * vertex4;
 
  680     vertex5 = (transform) * vertex5;
 
  681     vertex6 = (transform) * vertex6;
 
  682     vertex7 = (transform) * vertex7;
 
  683     vertex8 = (transform) * vertex8;
 
  685     HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
 
  687     addAttributes(instance, getCalHitType());
 
  689     setAttribute(instance, 
"DrawAs", 
G4String(
"Prism"));
 
  691     setVisibility(instance, trd);
 
  692     setLine(instance, trd);
 
  693     setColor(instance, getColorFor(trd));
 
  706     if (dontWrite()) 
return;
 
  711     if (dontWrite()) 
return;
 
  716     if (dontWrite()) 
return;
 
  721     if (dontWrite()) 
return;
 
  726     if (dontWrite()) 
return;
 
  731     if (dontWrite()) 
return;
 
  736     if (dontWrite()) 
return;
 
  744     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Polyline&) " << line.size() << endl;
 
  746     if (dontWrite()) 
return;
 
  749       static G4bool warned = 
false;
 
  753       (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyline&)",
 
  755        "2D polylines not implemented.  Ignored.");
 
  762     addAttributes(instance, getTrajectoryType());
 
  766     setVisibility(instance, line);
 
  768     setLine(instance, line);
 
  770     for (
size_t i=0; i < line.size(); i++) {
 
  780     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Polymarker&) " << line.size() << endl;
 
  782     if (dontWrite()) 
return;
 
  785       static G4bool warned = 
false;
 
  789       (
"G4HepRepSceneHandler::AddPrimitive (const G4Polymarker&)",
 
  791        "2D polymarkers not implemented.  Ignored.");
 
  798     addAttributes(instance, getHitType());
 
  802     setVisibility(instance, line);
 
  804     setMarker(instance, line);
 
  810     if (mtype == line.
dots) {
 
  811         setAttribute(instance, 
"Fill", 
true);
 
  813     } 
else if (mtype == line.
circles) {
 
  815         setAttribute(instance, 
"MarkName", 
G4String(
"Box"));
 
  818         setAttribute(instance, 
"MarkName", 
G4String(
"Plus"));
 
  821     for (
size_t i=0; i < line.size(); i++) {
 
  830     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Circle&) " << endl;
 
  832     if (dontWrite()) 
return;
 
  835       static G4bool warned = 
false;
 
  839       (
"G4HepRepSceneHandler::AddPrimitive (const G4Circle&)",
 
  841        "2D circles not implemented.  Ignored.");
 
  848     addAttributes(instance, getHitType());
 
  852     setColor (instance, 
GetColor(circle));
 
  854     setVisibility(instance, circle);
 
  856     setMarker(instance, circle);
 
  865     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Polyhedron&) " << endl;
 
  867     if (dontWrite()) 
return;
 
  870       static G4bool warned = 
false;
 
  874       (
"G4HepRepSceneHandler::AddPrimitive (const G4Polyhedron&)",
 
  876        "2D polyhedra not implemented.  Ignored.");
 
  886     HepRepInstance* instance = getGeometryOrEventInstance(getCalHitType());
 
  888     addAttributes(instance, getCalHitType());
 
  890     setVisibility(instance, polyhedron);
 
  892     G4int currentDepth = 0;
 
  903             face = getGeometryInstance(
"*Face", currentDepth+1);
 
  904             setAttribute(face, 
"PickParent", 
true);
 
  905             setAttribute(face, 
"DrawAs", 
G4String(
"Polygon"));
 
  908         setLine(face, polyhedron);
 
  909         setColor(face, 
GetColor(polyhedron));
 
  910         if (isEventData()) setColor(face, 
GetColor(polyhedron), 
G4String(
"FillColor"));
 
  918             vertex = transform * vertex;
 
  920         } 
while (notLastEdge);
 
  921     } 
while (notLastFace);
 
  927     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Text&) " << endl;
 
  929     if (dontWrite()) 
return;
 
  945     cout << 
"G4HepRepSceneHandler::AddPrimitive G4Text : not yet implemented. " << endl;
 
  951     cout << 
"G4HepRepSceneHandler::AddPrimitive(G4Square&) " << endl;
 
  953     if (dontWrite()) 
return;
 
  956       static G4bool warned = 
false;
 
  960       (
"G4HepRepSceneHandler::AddPrimitive (const G4Square&)",
 
  962        "2D squares not implemented.  Ignored.");
 
  969     addAttributes(instance, getHitType());
 
  973     setColor (instance, getColorFor(square));
 
  975     setVisibility(instance, square);
 
  977     setMarker(instance, square);
 
  983     if (dontWrite()) 
return;
 
  989     cout << 
"G4HepRepSceneHandler::AddCompound(G4VTrajectory&) " << endl;
 
  991     if (dontWrite()) 
return;
 
  993     currentTrack = &trajectory;
 
 1001     cout << 
"G4HepRepSceneHandler::AddCompound(G4VHit&) " << endl;
 
 1003     if (dontWrite()) 
return;
 
 1015     transform = objectTransformation;
 
 1017     cout << 
"G4HepRepSceneHandler::PreAddSolid(G4Transform3D&, G4VisAttributes&)" << endl;
 
 1024     cout << 
"G4HepRepSceneHandler::PostAddSolid()" << endl;
 
 1032     cout << 
"G4HepRepSceneHandler::BeginPrimitives(G4Transform3D&)" << endl;
 
 1036     transform = objectTransformation;
 
 1042     cout << 
"G4HepRepSceneHandler::EndPrimitives" << endl;
 
 1048 G4bool G4HepRepSceneHandler::dontWrite() {  
 
 1057     cout << 
"G4HepRepSceneHandler::setColor : red : " << color.
GetRed ()   <<
 
 1058                                   " green : " << color.
GetGreen () <<
 
 1059                                   " blue : " << color.
GetBlue ()   << endl;
 
 1080     setAttribute(attribute, 
"Visibility", (atts && (atts->
IsVisible()==0)) ? 
false : 
true);
 
 1084     setAttribute(attribute, 
"LineWidth", 1.0);
 
 1090     setAttribute(attribute, 
"LineWidth", (atts != NULL) ? atts->
GetLineWidth() : 1.0);
 
 1095                 setAttribute(attribute, 
"LineStyle", 
G4String(
"Dotted"));
 
 1098                 setAttribute(attribute, 
"LineStyle", 
G4String(
"Dashed"));
 
 1111     setAttribute(attribute, 
"MarkSize", size);
 
 1113     if (markerType == 
screen) setAttribute(attribute, 
"MarkType", 
G4String(
"Symbol"));
 
 1115         setAttribute(attribute, 
"Fill", 
false);
 
 1124         const map<G4String,G4AttDef>* hitAttDefs = currentHit->
GetAttDefs();
 
 1126         addAttDefs(getHitType(), hitAttDefs);
 
 1137         addAttVals(instance, hitAttDefs, hitAttValues);
 
 1139         delete hitAttValues;
 
 1141     } 
else if (currentTrack) {
 
 1142         vector<G4AttValue>* trajectoryAttValues = currentTrack->
CreateAttValues();
 
 1143         const map<G4String,G4AttDef>* trajectoryAttDefs = currentTrack->
GetAttDefs();
 
 1145         addAttDefs(type, trajectoryAttDefs);
 
 1157         addAttVals(instance, trajectoryAttDefs, trajectoryAttValues);
 
 1159         delete trajectoryAttValues;
 
 1168         if (point != NULL) {
 
 1175         if (instance != NULL) {
 
 1178                 attribute = instance->
getType();
 
 1190         if (point != NULL) {
 
 1197         if (instance != NULL) {
 
 1200                 attribute = instance->
getType();
 
 1212         if (point != NULL) {
 
 1219         if (instance != NULL) {
 
 1222                 attribute = instance->
getType();
 
 1234         if (point != NULL) {
 
 1241         if (instance != NULL) {
 
 1244                 attribute = instance->
getType();
 
 1254     vector<double> color;
 
 1255     if (attValue != NULL) color = attValue->
getColor();
 
 1256     if ((color.size() == 0) ||
 
 1257         (color[0] != red) ||
 
 1258         (color[1] != green) ||
 
 1259         (color[2] != blue) ||
 
 1260         ((color.size() > 3) && (color[3] != alpha))) {
 
 1263         if (point != NULL) {
 
 1270         if (instance != NULL) {
 
 1273                 attribute = instance->
getType();
 
 1277         attribute->
addAttValue(name, red, green, blue, alpha);
 
 1281 void G4HepRepSceneHandler::addAttDefs(
HepRepDefinition* definition, 
const map<G4String,G4AttDef>* attDefs) {
 
 1282     if (attDefs == NULL) 
return;
 
 1285     map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->begin();
 
 1286     while (attDefIterator != attDefs->end()) {
 
 1287         definition->
addAttDef(attDefIterator->first, attDefIterator->second.GetDesc(),
 
 1288                         attDefIterator->second.GetCategory(), attDefIterator->second.GetExtra());
 
 1293 void G4HepRepSceneHandler::addAttVals(
HepRepAttribute* attribute, 
const map<G4String,G4AttDef>* attDefs, vector<G4AttValue>* attValues) {
 
 1294     if (attValues == NULL) 
return;
 
 1297     for (vector<G4AttValue>::iterator attValIterator = attValues->begin(); attValIterator != attValues->end(); attValIterator++) {        
 
 1298         G4String name = attValIterator->GetName();
 
 1301         if ((name == 
"Pos") && (point != NULL)) {
 
 1308             for (
unsigned int i=0; i<pos.length(); i++) {
 
 1309                 if (pos[i] == 
' ') {
 
 1312                         double factor = atof(pos.substr(is, i-is).c_str())/point->
getX();
 
 1313                         im = (
int)(std::log10(factor)+((factor < 1) ? -0.5 : 0.5));
 
 1315                     } 
else if (in == 3) {
 
 1317                         unit = pos.substr(is, i-is);
 
 1320                         } 
else if (unit == 
G4String(
"mm")) {
 
 1322                         } 
else if (unit == 
G4String(
"cm")) {
 
 1324                         } 
else if (unit == 
G4String(
"m")) {
 
 1326                         } 
else if (unit == 
G4String(
"km")) {
 
 1329                             cerr << 
"HepRepSceneHandler: Unrecognized Unit: '" << unit << 
"'" << endl;
 
 1353                     cerr << 
"HepRepSceneHandler: No valid unit found for im: " << im << endl;
 
 1358             setAttribute(attribute, 
G4String(
"PointUnit"), unit);
 
 1363         if (name == 
"NTP") 
continue;
 
 1366         const map<G4String,G4AttDef>::const_iterator attDefIterator = attDefs->find(name);
 
 1367         G4String type = attDefIterator->second.GetValueType();
 
 1370         if ((type == 
"G4double") || (type == 
"double")) {   
 
 1371             setAttribute(attribute, attValIterator->GetName(), atof(attValIterator->GetValue()));           
 
 1372         } 
else if ((type == 
"G4int") || (type == 
"int")) {  
 
 1373             setAttribute(attribute, attValIterator->GetName(), atoi(attValIterator->GetValue()));           
 
 1375             setAttribute(attribute, attValIterator->GetName(), attValIterator->GetValue());
 
 1381 bool G4HepRepSceneHandler::isEventData () {
 
 1387 void G4HepRepSceneHandler::addTopLevelAttributes(
HepRepType* type) {
 
 1390     type->
addAttDef(  
"Generator", 
"Generator of the file", 
"General", 
"");
 
 1393     type->
addAttDef(  
"GeneratorVersion", 
"Version of the Generator", 
"General", 
"");
 
 1394     G4String versionString = G4Version;
 
 1395     versionString = versionString.substr(1,versionString.size()-2);
 
 1396     versionString = 
" Geant4 version " + versionString + 
"   " + G4Date;
 
 1397     type->
addAttValue(
"GeneratorVersion", versionString);
 
 1401     type->
addAttDef(  
"ViewTheta", 
"Theta of initial suggested viewpoint", 
"Draw", 
"rad");
 
 1404     type->
addAttDef(  
"ViewPhi", 
"Phi of initial suggested viewpoint", 
"Draw", 
"rad");
 
 1407     type->
addAttDef(  
"ViewScale", 
"Scale of initial suggested viewpoint", 
"Draw", 
"");
 
 1411     type->
addAttDef(  
"ViewTranslateX", 
"Translate in X of initial suggested viewpoint", 
"Draw", 
"");
 
 1414     type->
addAttDef(  
"ViewTranslateY", 
"Translate in Y of initial suggested viewpoint", 
"Draw", 
"");
 
 1417     type->
addAttDef(  
"ViewTranslateZ", 
"Translate in Z of initial suggested viewpoint", 
"Draw", 
"");
 
 1420     type->
addAttDef(  
"PointUnit", 
"Length", 
"Physics", 
"");
 
 1425     type->
addAttDef(  
"UseSolids", 
"Use HepRep Solids rather than Geant4 Primitives", 
"Draw", 
"");
 
 1428     type->
addAttDef(  
"WriteInvisibles", 
"Write Invisible Objects", 
"Draw", 
"");
 
 1434     if (isEventData()) {
 
 1443       return getGeometryInstance(pCurrentLV, pCurrentMaterial, currentDepth);
 
 1447 HepRep* G4HepRepSceneHandler::getHepRep() {
 
 1448     if (_heprep == NULL) {
 
 1455 HepRep* G4HepRepSceneHandler::getHepRepGeometry() {
 
 1456     if (_heprepGeometry == NULL) {
 
 1460     return _heprepGeometry;
 
 1464     if (_geometryInstanceTree == NULL) {
 
 1475     return _geometryInstanceTree;
 
 1478 HepRepInstance* G4HepRepSceneHandler::getGeometryRootInstance() {
 
 1479     if (_geometryRootInstance == NULL) {
 
 1481         _geometryRootInstance = factory->
createHepRepInstance(getGeometryInstanceTree(), getGeometryRootType());
 
 1483     return _geometryRootInstance;
 
 1489     setAttribute(instance, 
"LVol",       volume->
GetName());
 
 1492     setAttribute(instance, 
"Region",     regionName);
 
 1493     setAttribute(instance, 
"RootRegion", volume->
IsRootRegion());
 
 1497     setAttribute(instance, 
"Material",   matName );
 
 1499     setAttribute(instance, 
"Density",    matDensity);
 
 1501     setAttribute(instance, 
"Radlen",     matRadlen);
 
 1504     G4String state = materialState[matState];
 
 1505     setAttribute(instance, 
"State", state);
 
 1514     while ((
int)_geometryInstance.size() > depth) {
 
 1515         _geometryInstance.pop_back();
 
 1519     HepRepInstance* parent = (_geometryInstance.empty()) ? getGeometryRootInstance() : _geometryInstance.back();
 
 1522     HepRepType* type = getGeometryType(volumeName, depth);
 
 1526     _geometryInstance.push_back(instance);
 
 1532     if (_geometryTypeTree == NULL) {
 
 1541             getHepRepGeometry()->
addTypeTree(_geometryTypeTree);
 
 1544     return _geometryTypeTree;
 
 1547 HepRepType* G4HepRepSceneHandler::getGeometryRootType() {
 
 1548     if (_geometryRootType == NULL) {
 
 1550         _geometryRootType = factory->
createHepRepType(getGeometryTypeTree(), rootVolumeName);
 
 1551         _geometryRootType->
addAttValue(
"Layer", geometryLayer);
 
 1554         _geometryRootType->
addAttDef  (
"LVol", 
"Logical Volume", 
"Physics",
"");
 
 1556         _geometryRootType->
addAttDef  (
"Region", 
"Cuts Region", 
"Physics",
"");
 
 1558         _geometryRootType->
addAttDef  (
"RootRegion", 
"Root Region", 
"Physics",
"");
 
 1559         _geometryRootType->
addAttValue(
"RootRegion", 
false);
 
 1560         _geometryRootType->
addAttDef  (
"Solid", 
"Solid Name", 
"Physics",
"");
 
 1562         _geometryRootType->
addAttDef  (
"EType", 
"Entity Type", 
"Physics",
"");
 
 1564         _geometryRootType->
addAttDef  (
"Material", 
"Material Name", 
"Physics",
"");
 
 1566         _geometryRootType->
addAttDef  (
"Density", 
"Material Density", 
"Physics",
"");
 
 1568         _geometryRootType->
addAttDef  (
"State", 
"Material State", 
"Physics",
"");
 
 1570         _geometryRootType->
addAttDef  (
"Radlen", 
"Material Radiation Length", 
"Physics",
"");
 
 1574         _geometryRootType->
addAttValue(
"Color", 0.8, 0.8, 0.8, 1.0);
 
 1575         _geometryRootType->
addAttValue(
"Visibility", 
true);
 
 1576         _geometryRootType->
addAttValue(
"FillColor", 0.8, 0.8, 0.8, 1.0);
 
 1579         _geometryRootType->
addAttValue(
"PickParent", 
false);
 
 1580         _geometryRootType->
addAttValue(
"ShowParentAttributes", 
true);
 
 1582         _geometryRootType->
addAttValue(
"MarkSizeMultiplier", 4.0);
 
 1583         _geometryRootType->
addAttValue(
"LineWidthMultiplier", 1.0);
 
 1585         addTopLevelAttributes(_geometryRootType);       
 
 1587         _geometryType[
"/"+_geometryRootType->
getName()] = _geometryRootType;
 
 1589     return _geometryRootType;
 
 1594     getGeometryRootType();   
 
 1597     G4String name = getFullTypeName(volumeName, depth);
 
 1602         G4String parentName = getParentTypeName(depth);
 
 1603         HepRepType* parentType = _geometryType[parentName];
 
 1606         _geometryType[
name] = type;
 
 1611 G4String G4HepRepSceneHandler::getFullTypeName(
G4String volumeName, 
int depth) {
 
 1613     if (depth > (
int)_geometryTypeName.size()) {
 
 1615         G4String problem = 
"HierarchyProblem";
 
 1616         if (_geometryType[
"/"+problem] == NULL) {
 
 1619             _geometryType[
"/"+problem] = type;
 
 1621         return "/" + problem + 
"/" + volumeName;
 
 1625     while ((
int)_geometryTypeName.size() > depth) {
 
 1626         _geometryTypeName.pop_back();
 
 1630     G4String name = (_geometryTypeName.empty()) ? 
G4String(
"/"+rootVolumeName) : _geometryTypeName.back();
 
 1631     name = name + 
"/" + volumeName;
 
 1632     _geometryTypeName.push_back(name);
 
 1636 G4String G4HepRepSceneHandler::getParentTypeName(
int depth) {
 
 1637     return (depth >= 1) ? _geometryTypeName[depth-1] : 
G4String(
"/"+rootVolumeName);
 
 1641     if (_eventInstanceTree == NULL) {
 
 1646     return _eventInstanceTree;
 
 1650     if (_eventInstance == NULL) {
 
 1654     return _eventInstance;
 
 1658     if (_eventTypeTree == NULL) {
 
 1665     return _eventTypeTree;
 
 1668 HepRepType* G4HepRepSceneHandler::getEventType() {
 
 1669     if (_eventType == NULL) {
 
 1676         _eventType->
addAttValue(
"Color", 1.0, 1.0, 1.0, 1.0);
 
 1677         _eventType->
addAttValue(
"FillColor", 1.0, 1.0, 1.0, 1.0);
 
 1681         _eventType->
addAttValue(
"ShowParentAttributes", 
false);
 
 1683         _eventType->
addAttValue(
"MarkSizeMultiplier", 4.0);
 
 1684         _eventType->
addAttValue(
"LineWidthMultiplier", 1.0);
 
 1686         addTopLevelAttributes(_eventType);
 
 1692 HepRepType* G4HepRepSceneHandler::getTrajectoryType() {
 
 1693     if (_trajectoryType == NULL) {
 
 1696         _trajectoryType->
addAttValue(
"Layer", trajectoryLayer);
 
 1699         _trajectoryType->
addAttValue(
"LineWidthMultiplier", 2.0);
 
 1707     return _trajectoryType;
 
 1710 HepRepType* G4HepRepSceneHandler::getHitType() {
 
 1711     if (_hitType == NULL) {
 
 1723 HepRepType* G4HepRepSceneHandler::getCalHitType() {
 
 1724     if (_calHitType == NULL) {
 
 1733 HepRepType* G4HepRepSceneHandler::getCalHitFaceType() {
 
 1734     if (_calHitFaceType == NULL) {
 
 1735         _calHitFaceType = factory->
createHepRepType(getCalHitType(), 
"CalHitFace");
 
 1738     return _calHitFaceType;
 
const G4Colour & GetColor(const G4Visible &)
 
void removeSceneHandler()
 
G4double GetZoomFactor() const 
 
virtual bool write(HepRep *heprep, std::string name)=0
 
G4double GetXHalfLength() const 
 
void AddSolid(const G4Box &box)
 
virtual void AddSolid(const G4Box &)
 
virtual HepRepWriter * createHepRepWriter(std::ostream *out, bool randomAccess, bool compress)=0
 
G4double GetAlpha() const 
 
MarkerType GetMarkerType() const 
 
virtual G4bool writeInvisibles()
 
G4double GetYHalfLength1() const 
 
virtual void BeginModeling()
 
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
 
void BeginPrimitives(const G4Transform3D &objectTransformation)
 
G4bool GetNextNormal(G4Normal3D &normal) const 
 
bool closeHepRep(bool final=false)
 
virtual void addTypeTree(HepRepTypeTree *typeTree)=0
 
G4double GetLineWidth() const 
 
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
 
void openFile(G4String name)
 
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)
 
virtual bool addProperty(std::string key, std::string value)=0
 
const G4String & GetName() const 
 
virtual HepRepTreeID * createHepRepTreeID(std::string name, std::string version, std::string qualifier="top-level")=0
 
G4VViewer * GetCurrentViewer() const 
 
G4Material * GetCurrentMaterial() const 
 
virtual void PostAddSolid()
 
virtual HepRepInstance * getInstance()=0
 
const G4ViewParameters & GetViewParameters() const 
 
G4double GetDensity() const 
 
virtual std::string getString()=0
 
const G4String & GetName() const 
 
HepGeom::Point3D< G4double > G4Point3D
 
G4double GetOuterRadiusMinusZ() const 
 
G4Point3D GetPosition() const 
 
const G4VisAttributes * GetVisAttributes() const 
 
virtual std::vector< double > getColor()=0
 
G4Region * GetRegion() const 
 
virtual G4GeometryType GetEntityType() const =0
 
virtual void addAttDef(std::string name, std::string desc, std::string category, std::string extra)=0
 
G4double GetZHalfLength() const 
 
G4int GetCurrentDepth() const 
 
virtual void AddPrimitive(const G4Polyline &)=0
 
G4double GetZHalfLength() const 
 
const XML_Char const XML_Char ** atts
 
LineStyle GetLineStyle() const 
 
virtual G4String getEventNumberSuffix()
 
virtual void addInstanceTree(HepRepTreeID *instanceTree)=0
 
virtual double getDouble()=0
 
virtual HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)=0
 
virtual HepRepInstance * createHepRepInstance(HepRepInstance *parent, HepRepType *type)=0
 
virtual HepRepPoint * createHepRepPoint(HepRepInstance *instance, double x, double y, double z)=0
 
G4double GetXHalfLength2() const 
 
virtual HepRep * createHepRep()=0
 
virtual int getInteger()=0
 
virtual HepRepType * getType()=0
 
const G4Vector3D & GetViewpointDirection() const 
 
G4double GetDeltaPhiAngle() const 
 
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const 
 
virtual std::string getName()=0
 
G4double GetGreen() const 
 
G4bool IsRootRegion() const 
 
G4double GetMarkerRadius(const G4VMarker &, MarkerSizeType &)
 
virtual void EndModeling()
 
static G4HepRepMessenger * GetInstance()
 
G4VGraphicsSystem * GetGraphicsSystem() const 
 
virtual void EndPrimitives()
 
G4double GetYHalfLength() const 
 
virtual void addAttValue(HepRepAttValue *attValue)=0
 
G4double GetYHalfLength2() const 
 
G4double GetInnerRadiusPlusZ() const 
 
G4double GetInnerRadius() const 
 
virtual G4bool appendGeometry()
 
G4double GetRadlen() const 
 
virtual ~G4HepRepSceneHandler()
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
const G4Color & GetColor() const 
 
virtual HepRepType * createHepRepType(HepRepTypeTree *parent, std::string name)=0
 
virtual bool getBoolean()=0
 
const G4VisAttributes * fpVisAttribs
 
G4Scene * GetScene() const 
 
virtual void AddCompound(const G4VTrajectory &)
 
virtual std::vector< G4AttValue > * CreateAttValues() const 
 
virtual HepRepAttValue * getAttValue(std::string name)=0
 
virtual HepRepTypeTree * createHepRepTypeTree(HepRepTreeID *treeID)=0
 
virtual HepRepInstanceTree * createHepRepInstanceTree(std::string name, std::string version, HepRepTreeID *typeTree)=0
 
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const 
 
virtual void addLayer(std::string layer)=0
 
void AddCompound(const G4VTrajectory &)
 
system("rm -rf dna.root")
 
G4HepRepSceneHandler(G4VGraphicsSystem &system, const G4String &name="")
 
G4double GetZHalfLength() const 
 
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
 
virtual std::vector< G4AttValue > * CreateAttValues() const 
 
const XML_Char int const XML_Char * value
 
FillStyle GetFillStyle() const 
 
G4double GetXHalfLength1() const 
 
void AddPrimitive(const G4Polyline &)
 
G4bool fReadyForTransients
 
G4double GetInnerRadiusMinusZ() const 
 
G4bool GetNextVertex(G4Point3D &vertex, G4int &edgeFlag) const 
 
G4LogicalVolume * GetCurrentLV() const 
 
G4int GetNoFacets() const 
 
virtual void addInstanceTree(HepRepInstanceTree *instanceTree)=0
 
G4double GetOuterRadiusPlusZ() const 
 
G4double GetZHalfLength() const 
 
virtual G4bool useSolids()
 
G4VSolid * GetSolid() const 
 
G4double GetOuterRadius() const 
 
virtual void DrawView()=0
 
G4double GetDeltaPhiAngle() const