35#include <Inventor/SoPath.h>
36#include <Inventor/SoNodeKitPath.h>
37#include <Inventor/nodes/SoCoordinate3.h>
38#include <Inventor/nodes/SoCoordinate4.h>
39#include <Inventor/nodes/SoSeparator.h>
40#include <Inventor/nodes/SoDrawStyle.h>
41#include <Inventor/nodes/SoLightModel.h>
42#include <Inventor/nodes/SoMaterial.h>
43#include <Inventor/nodes/SoLineSet.h>
44#include <Inventor/nodes/SoCube.h>
45#include <Inventor/nodes/SoFont.h>
46#include <Inventor/nodes/SoText2.h>
47#include <Inventor/nodes/SoFaceSet.h>
48#include <Inventor/nodes/SoNormal.h>
49#include <Inventor/nodes/SoNormalBinding.h>
50#include <Inventor/nodes/SoComplexity.h>
51#include <Inventor/nodes/SoTranslation.h>
52#include <Inventor/nodes/SoTransform.h>
53#include <Inventor/nodes/SoResetTransform.h>
54#include <Inventor/nodes/SoMatrixTransform.h>
56#define USE_SOPOLYHEDRON
58#ifndef USE_SOPOLYHEDRON
107,fModelingSolid(false)
108,fReducedWireFrame(true)
110,fPreviewAndFull(true)
115 fRoot =
new SoSeparator;
117 fRoot->setName(
"Root");
183 static G4bool warned =
false;
187 (
"G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline&)",
189 "2D polylines not implemented. Ignored.");
201 G4int nPoints = line.size();
202 SbVec3f* pCoords =
new SbVec3f[nPoints];
204 for (
G4int iPoint = 0; iPoint < nPoints ; iPoint++) {
205 pCoords[iPoint].setValue((
float)line[iPoint].x(),
206 (
float)line[iPoint].y(),
207 (
float)line[iPoint].z());
213 SoCoordinate3 *polyCoords =
new SoCoordinate3;
214 polyCoords->point.setValues(0,nPoints,pCoords);
220 SoDrawStyle* drawStyle =
fStyleCache->getLineStyle();
229 pLine->numVertices.setValues(0,1,(
const long *)&nPoints);
231 pLine->numVertices.setValues(0,1,&nPoints);
242 static G4bool warned =
false;
246 (
"G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker&)",
248 "2D polymarkers not implemented. Ignored.");
260 G4int pointn = polymarker.size();
261 if(pointn<=0)
return;
263 SbVec3f* points =
new SbVec3f[pointn];
264 for (
G4int iPoint = 0; iPoint < pointn ; iPoint++) {
265 points[iPoint].setValue((
float)polymarker[iPoint].x(),
266 (
float)polymarker[iPoint].y(),
267 (
float)polymarker[iPoint].z());
270 SoCoordinate3* coordinate3 =
new SoCoordinate3;
271 coordinate3->point.setValues(0,pointn,points);
288 markerSet->numPoints = pointn;
299 if (screenSize <= 5.) {
301 }
else if (screenSize <= 7.) {
308 if (screenSize <= 5.) {
314 }
else if (screenSize <= 7.) {
329 if (screenSize <= 5.) {
335 }
else if (screenSize <= 7.) {
359 static G4bool warned =
false;
363 (
"G4OpenInventorSceneHandler::AddPrimitive (const G4Text&)",
365 "2D text not implemented. Ignored.");
401 SoFont *g4Font =
new SoFont();
408 SoText2 *g4String =
new SoText2();
409 g4String->string.setValue(text.
GetText());
410 g4String->spacing = 2.0;
414 g4String->justification = SoText2::LEFT;
break;
416 g4String->justification = SoText2::CENTER;
break;
418 g4String->justification = SoText2::RIGHT;
break;
441 static G4bool warned =
false;
445 (
"G4OpenInventorSceneHandler::AddCircleSquare",
447 "2D circles and squares not implemented. Ignored.");
475 SbVec3f* points =
new SbVec3f[1];
476 points[0].setValue((
float)centre.
x(),
479 SoCoordinate3* coordinate3 =
new SoCoordinate3;
480 coordinate3->point.setValues(0,1,points);
484 markerSet->numPoints = 1;
490 switch (markerType) {
492 if (screenSize <= 5.) {
498 }
else if (screenSize <= 7.) {
513 if (screenSize <= 5.) {
519 }
else if (screenSize <= 7.) {
547 static G4bool warned =
false;
551 (
"G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron&)",
553 "2D polyhedra not implemented. Ignored.");
571 SbString
name =
"Non-geometry";
578 soPolyhedron->setName(sbName);
615 typedef std::vector<PVNodeID> PVPath;
633 PVPath::const_reverse_iterator ri;
635 ri = ++drawnPVPath.rbegin();
636 if (ri != drawnPVPath.rend()) {
638 MotherVolume = ri->GetPhysicalVolume()->GetLogicalVolume();
648 SoSeparator* previewSeparator =
649 (SoSeparator*) detectorTreeKit->getPart(
"previewSeparator",
TRUE);
650 previewSeparator->renderCaching = SoSeparator::OFF;
652 SoSeparator* fullSeparator =
653 (SoSeparator*) detectorTreeKit->getPart(
"fullSeparator",
TRUE);
654 fullSeparator->renderCaching = SoSeparator::OFF;
667 const double red = g4Col.
GetRed ();
668 const double green = g4Col.
GetGreen ();
669 const double blue = g4Col.
GetBlue ();
670 double transparency = 1 - g4Col.
GetAlpha();
675 switch (drawing_style) {
693 (
float)transparency);
694 detectorTreeKit->setPart(
"appearance.material",
material);
696 SoLightModel* lightModel =
699 detectorTreeKit->setPart(
"appearance.lightModel",lightModel);
718 "ERROR: G4OpenInventorSceneHandler::GeneratePrerequisites: Mother "
719 << ri->GetPhysicalVolume()->GetName()
720 <<
':' << ri->GetCopyNo()
721 <<
" not previously encountered."
722 "\nShouldn't happen! Please report to visualization coordinator."
747 G4cout <<
"ERROR: G4OpenInventorSceneHandler::PreAddSolid: Mother "
748 << ri->GetPhysicalVolume()->GetName()
749 <<
':' << ri->GetCopyNo()
750 <<
" not previously encountered."
751 "\nShouldn't happen! Please report to visualization coordinator."
780 const double red = g4Col.
GetRed ();
781 const double green = g4Col.
GetGreen ();
782 const double blue = g4Col.
GetBlue ();
783 double transparency = 1 - g4Col.
GetAlpha();
788 switch (drawing_style) {
810 (
float)transparency);
813 SoLightModel* lightModel =
825 SoMatrixTransform* matrixTransform =
new SoMatrixTransform;
833 (SbVec3f((
float)scale.
x(),(
float)scale.
y(),(
float)scale.
z()));
834 sbMatrix->multRight(sbScale);
836 matrixTransform->matrix.setValue(*sbMatrix);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
HEPVis_SoMarkerSet SoMarkerSet
G4GLOB_DLL std::ostream G4cout
#define SoDetectorTreeKit
G4double GetAlpha() const
G4double GetGreen() const
size_t GetNoDaughters() const
const G4String & GetName() const
void AddPrimitive(const G4Polyline &line)
virtual ~G4OpenInventorSceneHandler()
void AddCircleSquare(G4OIMarker markerType, const G4VMarker &)
std::map< G4LogicalVolume *, SoSeparator *, std::less< G4LogicalVolume * > > fSeparatorMap
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)
void AddTransform(const G4Point3D &translation=G4Point3D())
SoSeparator * fTransientRoot
void GeneratePrerequisites()
Geant4_SoStyleCache * fStyleCache
SoSeparator * fDetectorRoot
G4OpenInventorSceneHandler(G4OpenInventor &system, const G4String &name="")
SoSeparator * fCurrentSeparator
void ClearTransientStore()
void BeginPrimitives(const G4Transform3D &objectTransformation)
void AddProperties(const G4VisAttributes *)
static G4int fSceneIdCount
const std::vector< G4PhysicalVolumeNodeID > & GetDrawnPVPath() const
G4VPhysicalVolume * GetCurrentPV() const
G4LogicalVolume * GetCurrentLV() const
MarkerType GetMarkerType() const
FillStyle GetFillStyle() const
G4Point3D GetPosition() const
virtual G4bool IsReplicated() const =0
void LoadAtts(const G4Visible &, G4AttHolder *)
const G4Colour & GetTextColour(const G4Text &)
G4Transform3D fObjectTransformation
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
const G4VisAttributes * fpVisAttribs
G4bool fReadyForTransients
G4ViewParameters::DrawingStyle GetDrawingStyle(const G4VisAttributes *)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())
G4bool GetAuxEdgeVisible(const G4VisAttributes *)
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
const G4ViewParameters & GetViewParameters() const
const G4Vector3D & GetScaleFactor() const
const G4Colour & GetColour() const
const G4VisAttributes * GetVisAttributes() const
SoSFBool reducedWireFrame
G4int GetNoFacets() const
virtual void setPreview(SbBool Flag)
const char * name(G4int ptype)