Geant4-11
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
G4OpenInventorViewer Class Referenceabstract

#include <G4OpenInventorViewer.hh>

Inheritance diagram for G4OpenInventorViewer:
G4VViewer G4OpenInventorQtViewer G4OpenInventorWinViewer G4OpenInventorXtExtendedViewer G4OpenInventorXtViewer

Public Member Functions

virtual void ClearView ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
virtual void DrawView ()
 
virtual void FinishView ()
 
 G4OpenInventorViewer (G4OpenInventorSceneHandler &scene, const G4String &name="")
 
const G4VisAttributesGetApplicableVisAttributes (const G4VisAttributes *) const
 
const G4ViewParametersGetDefaultViewParameters () const
 
const G4StringGetName () const
 
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers () const
 
G4VSceneHandlerGetSceneHandler () const
 
const G4StringGetShortName () const
 
G4int GetViewId () const
 
const G4ViewParametersGetViewParameters () const
 
virtual void Initialise ()
 
virtual void KernelVisitDecision ()
 
void NeedKernelVisit ()
 
void ProcessView ()
 
void RefreshView ()
 
virtual void ResetView ()
 
void SetDefaultViewParameters (const G4ViewParameters &vp)
 
void SetName (const G4String &)
 
void SetNeedKernelVisit (G4bool need)
 
virtual void SetView ()
 
void SetViewParameters (const G4ViewParameters &vp)
 
virtual void ShowView ()
 
virtual ~G4OpenInventorViewer ()
 

Protected Member Functions

void EraseDetector ()
 
void EraseEvent ()
 
void Escape ()
 Menu items callbacks /////////////////////////////////////////////////////. More...
 
virtual SoCamera * GetCamera ()=0
 
G4String Help (const G4String &topic="controls")
 
void SceneGraphStatistics ()
 
void SetPreview ()
 
void SetPreviewAndFull ()
 
void SetReducedWireFrame (bool)
 
void SetSolid ()
 
void SetTouchable (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
 
void SetWireFrame ()
 
void TouchableSetColour (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
 
void TouchableSetVisibility (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
 
void UpdateScene ()
 
virtual void ViewerRender ()=0
 
void WriteInventor (const G4String &file="g4out.iv")
 
void WritePDF (const G4String &file="g4out.pdf")
 
void WritePixmapPostScript (const G4String &file="g4out.ps")
 
void WritePostScript (const G4String &file="g4out.ps")
 

Static Protected Member Functions

static void SelectionCB (void *, SoPath *)
 

Protected Attributes

G4ViewParameters fDefaultVP
 
G4OpenInventorSceneHandlerfG4OpenInventorSceneHandler
 
Geant4_SoGL2PSAction * fGL2PSAction
 
SoNodeSensor * fGroupCameraSensor
 
G4VInteractorManagerfInteractorManager
 
G4String fName
 
G4bool fNeedKernelVisit
 
G4VSceneHandlerfSceneHandler
 
G4String fShortName
 
Geant4_SoImageWriter * fSoImageWriter
 
SoSelection * fSoSelection
 
G4int fViewId
 
G4ViewParameters fVP
 

Private Member Functions

G4bool CompareForKernelVisit (G4ViewParameters &)
 
void DrawDetector ()
 

Static Private Member Functions

static void GroupCameraSensorCB (void *, SoSensor *)
 
static void lookAt (SoCamera *, const SbVec3f &dir, const SbVec3f &up)
 
static void lookedAt (SoCamera *, SbVec3f &dir, SbVec3f &up)
 
static void pointAt (SoCamera *, const SbVec3f &targetpoint, const SbVec3f &upvector)
 

Private Attributes

G4ViewParameters fLastVP
 

Detailed Description

Definition at line 49 of file G4OpenInventorViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenInventorViewer()

G4OpenInventorViewer::G4OpenInventorViewer ( G4OpenInventorSceneHandler scene,
const G4String name = "" 
)

Definition at line 58 of file G4OpenInventorViewer.cc.

61:G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
62,fG4OpenInventorSceneHandler(sceneHandler)
66,fGL2PSAction(0) //To be set be suclass.
68 //,fCameraSensor(0)
69{
70 fVP.SetAutoRefresh(true);
72 fVP.SetPicking(true);
74
75 //FIXME : G.Barrand : not convinced that we have to rm culling.
76 // For viewing of all objects by default :
77 //fDefaultVP.SetCulling(false);
78 //fVP.SetCulling(false);
79
82 GetInteractorManager();
83
84 // Main user scene graph root sent to the viewers.
85 fSoSelection = new SoSelection;
86 fSoSelection->ref();
87 fSoSelection->addSelectionCallback(SelectionCB,this);
88 //fSoSelection->addDeselectionCallback(DeselectionCB,this);
89 fSoSelection->policy = SoSelection::SINGLE;
90
91 SoGroup* group = new SoGroup;
92 fSoSelection->addChild(group);
93
94 // Have a camera under fSoSelection in order
95 // that the below SceneGraphSensor be notifed
96 // when the viewer changes the camera type.
97 // But we put the camera under a SoGroup so that
98 // the SceneGraphSensor be not triggered at each change
99 // under the fG4OpenInventorSceneHandler.fRoot.
100 SoOrthographicCamera* camera = new SoOrthographicCamera;
101 camera->viewportMapping.setValue(SoCamera::ADJUST_CAMERA);
102 //camera->aspectRatio.setValue(10);
103 camera->position.setValue(0,0,10);
104 camera->orientation.setValue(SbRotation(SbVec3f(0,1,0),0));
105 camera->height.setValue(10);
106 camera->nearDistance.setValue(1);
107 camera->farDistance.setValue(100);
108 camera->focalDistance.setValue(10);
109 group->addChild(camera);
110
111 {SoInput soInput;
112 if(soInput.openFile("g4view.iv",TRUE)) {
113 SoSeparator* separator = SoDB::readAll(&soInput);
114 if(separator) fSoSelection->addChild(separator);
115 }}
116
118
119 // SoImageWriter should be the last.
121 fSoImageWriter->fileName.setValue("g4out.ps");
122 fSoSelection->addChild(fSoImageWriter);
123
124 // Sensors :
125 // To detect that the viewer had changed the camera type :
126 fGroupCameraSensor = new SoNodeSensor(GroupCameraSensorCB,this);
127 fGroupCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
128 fGroupCameraSensor->attach(group);
129 // FWJ Upgraded the group sensor so the camera sensor is not needed
130 // fCameraSensor = new SoNodeSensor(CameraSensorCB,this);
131 // fCameraSensor->setPriority(0);//Needed in order to do getTriggerNode()
132 // fCameraSensor->attach(camera);
133}
#define TRUE
Definition: Globals.hh:27
#define SoImageWriter
Definition: SoImageWriter.h:40
SoNodeSensor * fGroupCameraSensor
G4OpenInventorSceneHandler & fG4OpenInventorSceneHandler
G4VInteractorManager * fInteractorManager
static void SelectionCB(void *, SoPath *)
Geant4_SoImageWriter * fSoImageWriter
static void GroupCameraSensorCB(void *, SoSensor *)
Geant4_SoGL2PSAction * fGL2PSAction
G4VGraphicsSystem * GetGraphicsSystem() const
G4ViewParameters fDefaultVP
Definition: G4VViewer.hh:220
G4ViewParameters fVP
Definition: G4VViewer.hh:219
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
Definition: G4VViewer.cc:46
void SetAutoRefresh(G4bool)
void SetPicking(G4bool)
const char * name(G4int ptype)

References G4VViewer::fDefaultVP, fG4OpenInventorSceneHandler, fGroupCameraSensor, fInteractorManager, G4OpenInventorSceneHandler::fRoot, fSoImageWriter, fSoSelection, G4VViewer::fVP, G4VSceneHandler::GetGraphicsSystem(), GroupCameraSensorCB(), SelectionCB(), G4ViewParameters::SetAutoRefresh(), G4ViewParameters::SetPicking(), SoImageWriter, and TRUE.

◆ ~G4OpenInventorViewer()

G4OpenInventorViewer::~G4OpenInventorViewer ( )
virtual

Definition at line 135 of file G4OpenInventorViewer.cc.

135 {
136 // fCameraSensor->detach();
137 // delete fCameraSensor;
138 fGroupCameraSensor->detach();
139 delete fGroupCameraSensor;
140 fSoSelection->unref();
141}

References fGroupCameraSensor, and fSoSelection.

Member Function Documentation

◆ ClearView()

void G4OpenInventorViewer::ClearView ( void  )
virtual

Implements G4VViewer.

Definition at line 234 of file G4OpenInventorViewer.cc.

234 {
235}

◆ CompareForKernelVisit()

G4bool G4OpenInventorViewer::CompareForKernelVisit ( G4ViewParameters vp)
private

Definition at line 158 of file G4OpenInventorViewer.cc.

158 {
159
160 if (
161 (vp.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
163 (vp.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) ||
164 (vp.IsCulling () != fVP.IsCulling ()) ||
166 (vp.IsDensityCulling () != fVP.IsDensityCulling ()) ||
167 (vp.IsCullingCovered () != fVP.IsCullingCovered ()) ||
168 (vp.GetCBDAlgorithmNumber() !=
170 (vp.IsSection () != fVP.IsSection ()) ||
171 (vp.IsCutaway () != fVP.IsCutaway ()) ||
172 // This assumes use of generic clipping (sectioning, slicing,
173 // DCUT, cutaway). If a decision is made to implement locally,
174 // this will need changing. See G4OpenGLViewer::SetView,
175 // G4OpenGLStoredViewer.cc::CompareForKernelVisit and
176 // G4OpenGLStoredSceneHander::CreateSection/CutawayPolyhedron.
177 (vp.IsExplode () != fVP.IsExplode ()) ||
178 (vp.GetNoOfSides () != fVP.GetNoOfSides ()) ||
187 (vp.IsPicking () != fVP.IsPicking ()) ||
188 // Scaling for Open Inventor is done by the scene handler so it
189 // needs a kernel visit. (In this respect, it differs from the
190 // OpenGL drivers, where it's done in SetView.)
191 (vp.GetScaleFactor () != fVP.GetScaleFactor ()) ||
192 // If G4OpenInventor ever introduces VAMs, the following might need
193 // changing to a complete comparison, i.e., remove ".size()". See
194 // G4OpenGLStoredViewer::CompareForKernelVisit.
199 )
200 return true;
201
202 if (vp.IsDensityCulling () &&
204 return true;
205
206 if (vp.GetCBDAlgorithmNumber() > 0) {
207 if (vp.GetCBDParameters().size() != fVP.GetCBDParameters().size()) return true;
208 else if (vp.GetCBDParameters() != fVP.GetCBDParameters()) return true;
209 }
210
211 if (vp.IsSection () &&
212 (vp.GetSectionPlane () != fVP.GetSectionPlane ()))
213 return true;
214
215 if (vp.IsCutaway ()) {
216 if (vp.GetCutawayPlanes ().size () !=
217 fVP.GetCutawayPlanes ().size ()) return true;
218 for (size_t i = 0; i < vp.GetCutawayPlanes().size(); ++i)
219 if (vp.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i])
220 return true;
221 }
222
223 if (vp.IsExplode () &&
225 return true;
226
227 if (vp.IsSpecialMeshRendering() &&
229 return true;
230
231 return false;
232}
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Vector3D & GetScaleFactor() const
G4int GetNoOfSides() const
G4bool IsSpecialMeshRendering() const
G4double GetExplodeFactor() const
G4int GetNumberOfCloudPoints() const
G4bool IsMarkerNotHidden() const
G4double GetGlobalLineWidthScale() const
G4bool IsCutaway() const
const G4Colour & GetBackgroundColour() const
G4bool IsSection() const
G4bool IsPicking() const
G4bool IsCulling() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4bool IsExplode() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
const std::vector< G4ModelingParameters::PVNameCopyNo > & GetSpecialMeshVolumes() const
G4double GetGlobalMarkerScale() const
G4bool IsCullingInvisible() const
const G4VisAttributes * GetDefaultVisAttributes() const
const G4Planes & GetCutawayPlanes() const
G4bool IsDensityCulling() const
G4double GetVisibleDensity() const
G4bool IsCullingCovered() const
const G4Plane3D & GetSectionPlane() const
DrawingStyle GetDrawingStyle() const
G4bool IsAuxEdgeVisible() const
const G4Colour & GetColour() const

References G4VViewer::fVP, G4ViewParameters::GetBackgroundColour(), G4ViewParameters::GetCBDAlgorithmNumber(), G4ViewParameters::GetCBDParameters(), G4VisAttributes::GetColour(), G4ViewParameters::GetCutawayPlanes(), G4ViewParameters::GetDefaultTextVisAttributes(), G4ViewParameters::GetDefaultVisAttributes(), G4ViewParameters::GetDrawingStyle(), G4ViewParameters::GetExplodeFactor(), G4ViewParameters::GetGlobalLineWidthScale(), G4ViewParameters::GetGlobalMarkerScale(), G4ViewParameters::GetNoOfSides(), G4ViewParameters::GetNumberOfCloudPoints(), G4ViewParameters::GetScaleFactor(), G4ViewParameters::GetSectionPlane(), G4ViewParameters::GetSpecialMeshVolumes(), G4ViewParameters::GetVisAttributesModifiers(), G4ViewParameters::GetVisibleDensity(), G4ViewParameters::IsAuxEdgeVisible(), G4ViewParameters::IsCulling(), G4ViewParameters::IsCullingCovered(), G4ViewParameters::IsCullingInvisible(), G4ViewParameters::IsCutaway(), G4ViewParameters::IsDensityCulling(), G4ViewParameters::IsExplode(), G4ViewParameters::IsMarkerNotHidden(), G4ViewParameters::IsPicking(), G4ViewParameters::IsSection(), and G4ViewParameters::IsSpecialMeshRendering().

Referenced by KernelVisitDecision().

◆ ComputeFlyThrough()

std::vector< G4ThreeVector > G4VViewer::ComputeFlyThrough ( G4Vector3D )
inherited

Definition at line 215 of file G4VViewer.cc.

216{
217 enum CurveType {
218 Bezier,
219 G4SplineTest};
220
221 // Choose a curve type (for testing)
222// int myCurveType = Bezier;
223
224 // number if step points
225 int stepPoints = 500;
226
227
228 G4Spline spline;
229
230
231 // At the moment we don't use the aVect parameters, but build it here :
232 // Good step points for exampleB5
233 spline.AddSplinePoint(G4Vector3D(0,1000,-14000));
234 spline.AddSplinePoint(G4Vector3D(0,1000,0));
235 spline.AddSplinePoint(G4Vector3D(-4000,1000,4000));
236
237
238 std::vector <G4ThreeVector> viewVect;
239
240// if(myCurveType == Bezier) {
241
242
243 // Draw the spline
244
245 for (int i = 0; i < stepPoints; i++) {
246 float t = (float)i / (float)stepPoints;
247 G4Vector3D cameraPosition = spline.GetInterpolatedSplinePoint(t);
248 // G4Vector3D targetPoint = spline.GetInterpolatedSplinePoint(t);
249
250 // viewParam->SetViewAndLights(G4ThreeVector (cameraPosition.x(), cameraPosition.y(), cameraPosition.z()));
251 // viewParam->SetCurrentTargetPoint(targetPoint);
252 G4cout << "FLY CR("<< i << "):" << cameraPosition << G4endl;
253 viewVect.push_back(G4ThreeVector (cameraPosition.x(), cameraPosition.y(), cameraPosition.z()));
254 }
255
256// } else if (myCurveType == G4SplineTest) {
257 /*
258 This method is a inspire from a Bezier curve. The problem of the Bezier curve is that the path does not go straight between two waypoints.
259 This method add "stay straight" parameter which could be between 0 and 1 where the pass will follow exactly the line between the waypoints
260 Ex : stay straight = 50%
261 m1 = 3*(P1+P0)/2
262
263 Ex : stay straight = 0%
264 m1 = (P1+P0)/2
265
266 P1
267 / \
268 / \
269 a--x--b
270 / ° ° \
271 / ° ° \
272 m1 m2
273 / \
274 / \
275 / \
276 / \
277 P0 P2
278
279 */
280// G4Vector3D a;
281// G4Vector3D b;
282// G4Vector3D m1;
283// G4Vector3D m2;
284// G4Vector3D P0;
285// G4Vector3D P1;
286// G4Vector3D P2;
287// G4double stayStraight = 0;
288// G4double bezierSpeed = 0.4; // Spend 40% time in bezier curve (time between m1-m2 is 40% of time between P0-P1)
289//
290// G4Vector3D firstPoint;
291// G4Vector3D lastPoint;
292//
293// float nbBezierSteps = (stepPoints * bezierSpeed*(1-stayStraight)) * (2./spline.GetNumPoints());
294// float nbFirstSteps = ((stepPoints/2-nbBezierSteps/2) /(1+stayStraight)) * (2./spline.GetNumPoints());
295//
296// // First points
297// firstPoint = spline.GetPoint(0);
298// lastPoint = (firstPoint + spline.GetPoint(1))/2;
299//
300// for( float j=0; j<1; j+= 1/nbFirstSteps) {
301// G4ThreeVector pt = firstPoint + (lastPoint - firstPoint) * j;
302// viewVect.push_back(pt);
303// G4cout << "FLY Bezier A1("<< viewVect.size()<< "):" << pt << G4endl;
304// }
305//
306// for (int i = 0; i < spline.GetNumPoints()-2; i++) {
307// P0 = spline.GetPoint(i);
308// P1 = spline.GetPoint(i+1);
309// P2 = spline.GetPoint(i+2);
310//
311// m1 = P1 - (P1-P0)*(1-stayStraight)/2;
312// m2 = P1 + (P2-P1)*(1-stayStraight)/2;
313//
314// // We have to get straight path from (middile of P0-P1) to (middile of P0-P1 + (dist P0-P1) * stayStraight/2)
315// if (stayStraight >0) {
316//
317// firstPoint = (P0 + P1)/2;
318// lastPoint = (P0 + P1)/2 + (P1-P0)*stayStraight/2;
319//
320// for( float j=0; j<1; j+= 1/(nbFirstSteps*stayStraight)) {
321// G4ThreeVector pt = firstPoint + (lastPoint - firstPoint)* j;
322// viewVect.push_back(pt);
323// G4cout << "FLY Bezier A2("<< viewVect.size()<< "):" << pt << G4endl;
324// }
325// }
326// // Compute Bezier curve
327// for( float delta = 0 ; delta < 1 ; delta += 1/nbBezierSteps)
328// {
329// // The Green Line
330// a = m1 + ( (P1 - m1) * delta );
331// b = P1 + ( (m2 - P1) * delta );
332//
333// // Final point
334// G4ThreeVector pt = a + ((b-a) * delta );
335// viewVect.push_back(pt);
336// G4cout << "FLY Bezier("<< viewVect.size()<< "):" << pt << G4endl;
337// }
338//
339// // We have to get straight path
340// if (stayStraight >0) {
341// firstPoint = (P1 + P2)/2 - (P2-P1)*stayStraight/2;
342// lastPoint = (P1 + P2)/2;
343//
344// for( float j=0; j<1; j+= 1/(nbFirstSteps*stayStraight)) {
345// G4ThreeVector pt = firstPoint + (lastPoint - firstPoint)* j;
346// viewVect.push_back(pt);
347// G4cout << "FLY Bezier B1("<< viewVect.size()<< "):" << pt << G4endl;
348// }
349// }
350// }
351//
352// // last points
353// firstPoint = spline.GetPoint(spline.GetNumPoints()-2);
354// lastPoint = spline.GetPoint(spline.GetNumPoints()-1);
355// for( float j=1; j>0; j-= 1/nbFirstSteps) {
356// G4ThreeVector pt = lastPoint - ((lastPoint-firstPoint)*((1-stayStraight)/2) * j );
357// viewVect.push_back(pt);
358// G4cout << "FLY Bezier B2("<< viewVect.size()<< "):" << pt << G4endl;
359// }
360// }
361 return viewVect;
362}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:34
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References G4VViewer::G4Spline::AddSplinePoint(), G4cout, G4endl, G4VViewer::G4Spline::GetInterpolatedSplinePoint(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

◆ DrawDetector()

void G4OpenInventorViewer::DrawDetector ( )
private

Definition at line 502 of file G4OpenInventorViewer.cc.

502 {
503 /* Replace this... - JA
504 // DrawView does a ClearStore. Do not clear the transient store :
505 SoSeparator* tmp = fG4OpenInventorSceneHandler.fTransientRoot;
506 fG4OpenInventorSceneHandler.fTransientRoot = new SoSeparator;
507 if (!fNeedKernelVisit) KernelVisitDecision();
508 ProcessView();
509 fG4OpenInventorSceneHandler.fTransientRoot->unref();
510 fG4OpenInventorSceneHandler.fTransientRoot = tmp;
511 */
512 // ...by this... - JA
513 DrawView();
514}

References DrawView().

Referenced by SetPreview(), SetPreviewAndFull(), SetReducedWireFrame(), SetSolid(), and SetWireFrame().

◆ DrawView()

void G4OpenInventorViewer::DrawView ( )
virtual

Implements G4VViewer.

Definition at line 383 of file G4OpenInventorViewer.cc.

383 {
384 //G4cout << "debug Iv::DrawViewer " <<G4endl;
386 fLastVP= fVP;
387 ProcessView();
388 FinishView();
389}
virtual void KernelVisitDecision()
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:224
void ProcessView()
Definition: G4VViewer.cc:105
virtual void FinishView()
Definition: G4VViewer.cc:101

References G4VViewer::FinishView(), fLastVP, G4VViewer::fNeedKernelVisit, G4VViewer::fVP, KernelVisitDecision(), and G4VViewer::ProcessView().

Referenced by DrawDetector(), and UpdateScene().

◆ EraseDetector()

void G4OpenInventorViewer::EraseDetector ( )
protected

◆ EraseEvent()

void G4OpenInventorViewer::EraseEvent ( )
protected

◆ Escape()

void G4OpenInventorViewer::Escape ( )
protected

◆ FinishView()

void G4VViewer::FinishView ( void  )
virtualinherited

◆ GetApplicableVisAttributes()

const G4VisAttributes * G4VViewer::GetApplicableVisAttributes ( const G4VisAttributes ) const
inherited

◆ GetCamera()

virtual SoCamera * G4OpenInventorViewer::GetCamera ( )
protectedpure virtual

◆ GetDefaultViewParameters()

const G4ViewParameters & G4VViewer::GetDefaultViewParameters ( ) const
inherited

◆ GetName()

const G4String & G4VViewer::GetName ( ) const
inherited

◆ GetPrivateVisAttributesModifiers()

virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * G4VViewer::GetPrivateVisAttributesModifiers ( ) const
virtualinherited

◆ GetSceneHandler()

G4VSceneHandler * G4VViewer::GetSceneHandler ( ) const
inherited

◆ GetShortName()

const G4String & G4VViewer::GetShortName ( ) const
inherited

◆ GetViewId()

G4int G4VViewer::GetViewId ( ) const
inherited

◆ GetViewParameters()

const G4ViewParameters & G4VViewer::GetViewParameters ( ) const
inherited

Referenced by G4OpenGLXmViewer::actions_callback(), G4OpenInventorSceneHandler::AddCircleSquare(), G4Qt3DSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), G4OpenInventorSceneHandler::AddPrimitive(), G4OpenGLSceneHandler::AddPrimitive(), G4OpenGLImmediateSceneHandler::AddPrimitivePreambleInternal(), G4OpenGLStoredSceneHandler::AddPrimitivePreambleInternal(), G4OpenInventorSceneHandler::AddTransform(), G4OpenGLXmViewer::background_color_callback(), G4OpenGLImmediateQtViewer::ComputeView(), G4OpenGLStoredQtViewer::ComputeView(), G4VSceneHandler::CreateSectionSolid(), G4VisManager::CreateViewer(), G4OpenGLImmediateWin32Viewer::DrawView(), G4OpenGLImmediateXmViewer::DrawView(), G4OpenGLImmediateXViewer::DrawView(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), G4OpenGLStoredXViewer::DrawView(), G4OpenGLStoredSceneHandler::EndModeling(), G4VisManager::EndOfRun(), G4VSceneHandler::GetAuxEdgeVisible(), G4VSceneHandler::GetColour(), G4VSceneHandler::GetDrawingStyle(), G4VSceneHandler::GetNoOfSides(), G4VSceneHandler::GetNumberOfCloudPoints(), G4VSceneHandler::GetTextColour(), G4VVisCommand::RefreshIfRequired(), G4VSceneHandler::RequestPrimitives(), G4VisCommandDrawView::SetNewValue(), G4VisCommandDrawLogicalVolume::SetNewValue(), G4VisCommandGeometrySetDaughtersInvisible::SetNewValue(), G4VisCommandGeometrySetVisibility::SetNewValue(), G4VisCommandSceneNotifyHandlers::SetNewValue(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddScale::SetNewValue(), G4VisCommandSceneHandlerCreate::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), G4VisCommandsTouchableSet::SetNewValue(), G4VisCommandViewerAddCutawayPlane::SetNewValue(), G4VisCommandViewerCentreOn::SetNewValue(), G4VisCommandViewerChangeCutawayPlane::SetNewValue(), G4VisCommandViewerClearCutawayPlanes::SetNewValue(), G4VisCommandViewerClearVisAttributesModifiers::SetNewValue(), G4VisCommandViewerClone::SetNewValue(), G4VisCommandViewerColourByDensity::SetNewValue(), G4VisCommandViewerCopyViewFrom::SetNewValue(), G4VisCommandViewerCreate::SetNewValue(), G4VisCommandViewerDolly::SetNewValue(), G4VisCommandViewerInterpolate::SetNewValue(), G4VisCommandViewerPan::SetNewValue(), G4VisCommandViewerSave::SetNewValue(), G4VisCommandViewerScale::SetNewValue(), G4VisCommandViewerZoom::SetNewValue(), G4VisCommandsViewerSet::SetNewValue(), G4VisCommandGeometrySetVisibility::SetNewValueOnLV(), SetReducedWireFrame(), SetSolid(), and SetWireFrame().

◆ GroupCameraSensorCB()

void G4OpenInventorViewer::GroupCameraSensorCB ( void *  aThis,
SoSensor *  aSensor 
)
staticprivate

Definition at line 396 of file G4OpenInventorViewer.cc.

397{
399
400 SoNode* node = ((SoNodeSensor*)aSensor)->getTriggerNode();
401 // printf("debug : GroupCameraSensorCB %s\n",
402 // node->getTypeId().getName().getString());
403
404 if(node->isOfType(SoCamera::getClassTypeId())) {
405 SoCamera* camera = (SoCamera*)node;
406
407 // FWJ DEBUG
408 // G4cout << " UPDATING fVP FROM CAMERA " << camera << G4endl;
409 SbVec3f direction, up;
410 lookedAt(camera, direction, up);
412 (G4Vector3D(-direction[0], -direction[1], -direction[2]));
413 This->fVP.SetUpVector(G4Vector3D(up[0], up[1], up[2]));
414
415 SbVec3f pos = camera->position.getValue();
416 SbVec3f target = pos + direction * camera->focalDistance.getValue();
417
418 This->fVP.SetCurrentTargetPoint(G4Point3D(target[0], target[1], target[2]));
419
420 // FWJ camera sensor no longer needed
421 // Viewer had changed the camera type,
422 // attach the fCameraSensor to the new camera.
423 // FWJ DEBUG
424 // G4cout << " SWITCHING TO CAMERA " << camera << G4endl;
425 // This->fCameraSensor->detach();
426 // This->fCameraSensor->attach(camera);
427 }
428
429}
static const G4double pos
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:34
static void lookedAt(SoCamera *, SbVec3f &dir, SbVec3f &up)
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
void SetUpVector(const G4Vector3D &upVector)

References G4VViewer::fVP, lookedAt(), pos, G4ViewParameters::SetCurrentTargetPoint(), G4ViewParameters::SetUpVector(), and G4ViewParameters::SetViewpointDirection().

Referenced by G4OpenInventorViewer().

◆ Help()

G4String G4OpenInventorViewer::Help ( const G4String topic = "controls")
protected

Definition at line 774 of file G4OpenInventorViewer.cc.

774 {
775 if(aTopic=="controls") {
776 return G4String("\
777Controls on an Inventor examiner viewer are :\n\
778- in picking mode (cursor is the upper left arrow)\n\
779 Ctrl + pick a volume : see daughters.\n\
780 Shift + pick a volume : see mother.\n\
781- in viewing mode (cursor is the hand)\n\
782 Left-button + pointer move : rotate.\n\
783 Ctrl+Left-button + pointer move : pan.\n\
784 Ctrl+Shift+Left-button + pointer move : scale.\n\
785 Middle-button + pointer move : pan.\n\
786 Right-button : popup menu.\n");
787 } else {
788 return "";
789 }
790}

Referenced by G4OpenInventorXtExtendedViewer::HelpCbk(), G4OpenInventorXtViewer::HelpCbk(), and G4OpenInventorWinViewer::WindowProc().

◆ Initialise()

virtual void G4VViewer::Initialise ( )
virtualinherited

◆ KernelVisitDecision()

void G4OpenInventorViewer::KernelVisitDecision ( )
virtual

Definition at line 143 of file G4OpenInventorViewer.cc.

143 {
144
145 // If there's a significant difference with the last view parameters
146 // of either the scene handler or this viewer, trigger a rebuild.
147
148 if (
149 //??fG4OpenInventorSceneHandler.fPODLList.size() == 0 ||
150 // We need a test for empty scene graph, such as
151 // staticRoot.size() or something?????????? See temporary fix
152 // in contructor. (John Allison Aug 2001)
155 }
156}
G4bool CompareForKernelVisit(G4ViewParameters &)
void NeedKernelVisit()
Definition: G4VViewer.cc:78

References CompareForKernelVisit(), fLastVP, and G4VViewer::NeedKernelVisit().

Referenced by DrawView().

◆ lookAt()

void G4OpenInventorViewer::lookAt ( SoCamera *  camera,
const SbVec3f &  dir,
const SbVec3f &  up 
)
staticprivate

Definition at line 323 of file G4OpenInventorViewer.cc.

324{
325 SbVec3f z = -dir;
326 SbVec3f y = up;
327 SbVec3f x = y.cross(z);
328
329 // recompute y to create a valid coordinate system
330 y = z.cross(x);
331
332 // normalize x and y to create an orthonormal coord system
333 y.normalize();
334 x.normalize();
335
336 // create a rotation matrix
337 SbMatrix rot = SbMatrix::identity();
338 rot[0][0] = x[0];
339 rot[0][1] = x[1];
340 rot[0][2] = x[2];
341
342 rot[1][0] = y[0];
343 rot[1][1] = y[1];
344 rot[1][2] = y[2];
345
346 rot[2][0] = z[0];
347 rot[2][1] = z[1];
348 rot[2][2] = z[2];
349
350 camera->orientation.setValue(SbRotation(rot));
351}

Referenced by pointAt().

◆ lookedAt()

void G4OpenInventorViewer::lookedAt ( SoCamera *  camera,
SbVec3f &  dir,
SbVec3f &  up 
)
staticprivate

Definition at line 354 of file G4OpenInventorViewer.cc.

355{
356 SbRotation rot = camera->orientation.getValue();
357 SbMatrix mrot; rot.getValue(mrot);
358
359 SbVec3f x, y, z;
360
361 // create a rotation matrix
362 x[0] = mrot[0][0];
363 x[1] = mrot[0][1];
364 x[2] = mrot[0][2];
365
366 y[0] = mrot[1][0];
367 y[1] = mrot[1][1];
368 y[2] = mrot[1][2];
369
370 z[0] = mrot[2][0];
371 z[1] = mrot[2][1];
372 z[2] = mrot[2][2];
373
374 dir = -z;
375 dir.normalize();
376 up = SbVec3f(0.f,1.f,0.f); // Choose y-axis if possible.
377 if (std::abs(up.dot(z)) > 1.e-6) {
378 up = y;
379 up.normalize();
380 }
381}

Referenced by GroupCameraSensorCB().

◆ NeedKernelVisit()

void G4VViewer::NeedKernelVisit ( )
inherited

Definition at line 78 of file G4VViewer.cc.

78 {
79
80 fNeedKernelVisit = true;
81
82 // At one time I thought we'd better notify all viewers. But I guess
83 // each viewer can take care of itself, so the following code is
84 // redundant (but keep it commented out for now). (John Allison)
85 // Notify all viewers that a kernel visit is required.
86 // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
87 // G4ViewerListConstIterator i;
88 // for (i = viewerList.begin(); i != viewerList.end(); i++) {
89 // (*i) -> SetNeedKernelVisit ();
90 // }
91 // ??...but, there's a problem in OpenGL Stored which seems to
92 // require *all* viewers to revisit the kernel, so...
93 // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
94 // G4ViewerListConstIterator i;
95 // for (i = viewerList.begin(); i != viewerList.end(); i++) {
96 // (*i) -> SetNeedKernelVisit (true);
97 // }
98 // Feb 2005 - commented out. Let's fix OpenGL if necessary.
99}

References G4VViewer::fNeedKernelVisit.

Referenced by G4OpenGLImmediateQtViewer::ComputeView(), G4DAWNFILEViewer::DrawView(), G4GMocrenFileViewer::DrawView(), G4HepRepFileViewer::DrawView(), G4OpenGLImmediateWin32Viewer::DrawView(), G4OpenGLImmediateXmViewer::DrawView(), G4OpenGLImmediateXViewer::DrawView(), G4VTreeViewer::DrawView(), G4VRML2FileViewer::DrawView(), G4VtkViewer::DrawView(), G4VisManager::GeometryHasChanged(), G4OpenGLStoredViewer::KernelVisitDecision(), KernelVisitDecision(), G4Qt3DViewer::KernelVisitDecision(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::KernelVisitDecision(), G4VisManager::NotifyHandlers(), G4OpenGLImmediateViewer::ProcessView(), G4VisCommandViewerRebuild::SetNewValue(), SetPreview(), SetPreviewAndFull(), SetReducedWireFrame(), and UpdateScene().

◆ pointAt()

void G4OpenInventorViewer::pointAt ( SoCamera *  camera,
const SbVec3f &  targetpoint,
const SbVec3f &  upvector 
)
staticprivate

Definition at line 312 of file G4OpenInventorViewer.cc.

313{
314 SbVec3f dir = targetpoint - camera->position.getValue();
315 if (dir.normalize() == 0.0f) return;
316 lookAt(camera,dir, upvector);
317}
static void lookAt(SoCamera *, const SbVec3f &dir, const SbVec3f &up)

References lookAt().

Referenced by SetView().

◆ ProcessView()

void G4VViewer::ProcessView ( )
inherited

Definition at line 105 of file G4VViewer.cc.

106{
107 // If the scene has changed, or if the concrete viewer has decided
108 // that it necessary to visit the kernel, perhaps because the view
109 // parameters have changed significantly (this should be done in the
110 // concrete viewer's DrawView)...
111 if (fNeedKernelVisit) {
112 // Reset flag. This must be done before ProcessScene to prevent
113 // recursive calls when recomputing transients...
114 fNeedKernelVisit = false;
117 }
118}
virtual void ProcessScene()
virtual void ClearStore()
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:215

References G4VSceneHandler::ClearStore(), G4VViewer::fNeedKernelVisit, G4VViewer::fSceneHandler, and G4VSceneHandler::ProcessScene().

Referenced by G4OpenGLStoredQtViewer::ComputeView(), G4DAWNFILEViewer::DrawView(), G4GMocrenFileViewer::DrawView(), G4HepRepFileViewer::DrawView(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), G4OpenGLStoredXViewer::DrawView(), DrawView(), G4Qt3DViewer::DrawView(), G4RayTracerViewer::DrawView(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::DrawView(), G4VTreeViewer::DrawView(), G4VRML2FileViewer::DrawView(), G4VtkViewer::DrawView(), and G4OpenGLImmediateViewer::ProcessView().

◆ RefreshView()

void G4VViewer::RefreshView ( )
inherited

◆ ResetView()

virtual void G4VViewer::ResetView ( )
virtualinherited

◆ SceneGraphStatistics()

void G4OpenInventorViewer::SceneGraphStatistics ( )
protected

Definition at line 633 of file G4OpenInventorViewer.cc.

633 {
634 Counter counter;
635 counter.fTriangles = 0;
636 counter.fLineSegments = 0;
637 counter.fPoints = 0;
638
639 SoCallbackAction callbackAction;
640 callbackAction.addTriangleCallback
641 (SoShape::getClassTypeId(),CountTrianglesCB,(void*)&counter);
642 callbackAction.addLineSegmentCallback
643 (SoShape::getClassTypeId(),CountLineSegmentsCB,(void*)&counter);
644 callbackAction.addPointCallback
645 (SoShape::getClassTypeId(),CountPointsCB,(void*)&counter);
646 callbackAction.apply(fSoSelection);
647
648 SoCounterAction counterAction;
649 counterAction.apply(fSoSelection);
650 int nodes = counterAction.getCount();
651
652 counterAction.setLookFor(SoCounterAction::TYPE);
653 counterAction.setType(SoShape::getClassTypeId());
654 counterAction.apply(fSoSelection);
655 int shapes = counterAction.getCount();
656
657 G4cout << "Number of triangles : " << counter.fTriangles << G4endl;
658 G4cout << "Number of line segments : " << counter.fLineSegments << G4endl;
659 G4cout << "Number of points : " << counter.fPoints << G4endl;
660 G4cout << "Number of nodes : " << nodes << G4endl;
661 G4cout << "Number of shapes : " << shapes << G4endl;
662}
static void CountLineSegmentsCB(void *userData, SoCallbackAction *, const SoPrimitiveVertex *, const SoPrimitiveVertex *)
static void CountPointsCB(void *userData, SoCallbackAction *, const SoPrimitiveVertex *)
static void CountTrianglesCB(void *userData, SoCallbackAction *, const SoPrimitiveVertex *, const SoPrimitiveVertex *, const SoPrimitiveVertex *)
int getCount() const
void setLookFor(LookFor)
void setType(const SoType, SbBool=TRUE)

References CountLineSegmentsCB(), CountPointsCB(), CountTrianglesCB(), Counter::fLineSegments, Counter::fPoints, fSoSelection, Counter::fTriangles, G4cout, G4endl, SoCounterAction::getCount(), geant4_check_module_cycles::nodes, SoCounterAction::setLookFor(), SoCounterAction::setType(), and SoCounterAction::TYPE.

Referenced by G4OpenInventorQtViewer::EtcSceneGraphStatsCB(), G4OpenInventorXtExtendedViewer::SceneGraphStatisticsCbk(), G4OpenInventorXtViewer::SceneGraphStatisticsCbk(), and G4OpenInventorWinViewer::WindowProc().

◆ SelectionCB()

void G4OpenInventorViewer::SelectionCB ( void *  aThis,
SoPath *  aPath 
)
staticprotected

Definition at line 458 of file G4OpenInventorViewer.cc.

462{
464 SoNode* node = ((SoFullPath*)aPath)->getTail();
465 G4AttHolder* attHolder = dynamic_cast<G4AttHolder*>(node);
466 if(attHolder && attHolder->GetAttDefs().size()) {
467 for (size_t i = 0; i < attHolder->GetAttDefs().size(); ++i) {
468 G4cout << G4AttCheck(attHolder->GetAttValues()[i],
469 attHolder->GetAttDefs()[i]);
470 }
471 } else {
472 G4String name((char*)node->getName().getString());
473 G4String cls((char*)node->getTypeId().getName().getString());
474 G4cout << "SoNode : " << node
475 << " SoType : " << cls
476 << " name : " << name
477 << G4endl;
478 G4cout << "No attributes attached." << G4endl;
479 }
480 /*FIXME : to explore (need different button - this is used for picking.
481 if(node->isOfType(Geant4_SoPolyhedron::getClassTypeId())) {
482 Geant4_SoPolyhedron* polyhedron = (Geant4_SoPolyhedron*)node;
483 if(polyhedron->solid.getValue()==FALSE)
484 polyhedron->solid.setValue(TRUE);
485 else
486 polyhedron->solid.setValue(FALSE);
487 }*/
488 This->fSoSelection->deselectAll();
489}
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
Definition: G4AttHolder.hh:59
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
Definition: G4AttHolder.hh:61

References fSoSelection, G4cout, G4endl, G4AttHolder::GetAttDefs(), G4AttHolder::GetAttValues(), and G4InuclParticleNames::name().

Referenced by G4OpenInventorViewer(), and G4OpenInventorXtExtendedViewer::Initialise().

◆ SetDefaultViewParameters()

void G4VViewer::SetDefaultViewParameters ( const G4ViewParameters vp)
inherited

◆ SetName()

void G4VViewer::SetName ( const G4String name)
inherited

Definition at line 72 of file G4VViewer.cc.

72 {
73 fName = name;
74 fShortName = fName.substr(0, fName.find (' '));
76}
G4String fShortName
Definition: G4VViewer.hh:218
G4String fName
Definition: G4VViewer.hh:217
void strip(G4String &str, char c=' ')
Remove leading and trailing characters from string.

References G4VViewer::fName, G4VViewer::fShortName, G4InuclParticleNames::name(), and G4StrUtil::strip().

◆ SetNeedKernelVisit()

void G4VViewer::SetNeedKernelVisit ( G4bool  need)
inherited

◆ SetPreview()

void G4OpenInventorViewer::SetPreview ( )
protected

◆ SetPreviewAndFull()

void G4OpenInventorViewer::SetPreviewAndFull ( )
protected

◆ SetReducedWireFrame()

void G4OpenInventorViewer::SetReducedWireFrame ( bool  aValue)
protected

Definition at line 734 of file G4OpenInventorViewer.cc.

734 {
736
737 // Set the wire frame kind :
738 vp.SetAuxEdgeVisible(!aValue);
739
740 // Set wire frame :
742 switch (existingStyle) {
744 break;
746 break;
749 break;
752 break;
755 break;
756 }
758 NeedKernelVisit(); // Just in case it was alread in wire framw.
759 DrawDetector();
760}
const G4ViewParameters & GetViewParameters() const
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:120
void SetDrawingStyle(G4ViewParameters::DrawingStyle style)
void SetAuxEdgeVisible(G4bool)

References G4ViewParameters::cloud, DrawDetector(), G4ViewParameters::GetDrawingStyle(), G4VViewer::GetViewParameters(), G4ViewParameters::hlhsr, G4ViewParameters::hlr, G4ViewParameters::hsr, G4VViewer::NeedKernelVisit(), G4ViewParameters::SetAuxEdgeVisible(), G4ViewParameters::SetDrawingStyle(), G4VViewer::SetViewParameters(), and G4ViewParameters::wireframe.

Referenced by G4OpenInventorQtViewer::EtcSetFullWireframeCB(), G4OpenInventorQtViewer::EtcSetReducedWireframeCB(), G4OpenInventorXtExtendedViewer::SetFullWireFrameCbk(), G4OpenInventorXtViewer::SetFullWireFrameCbk(), G4OpenInventorXtExtendedViewer::SetReducedWireFrameCbk(), G4OpenInventorXtViewer::SetReducedWireFrameCbk(), and G4OpenInventorWinViewer::WindowProc().

◆ SetSolid()

void G4OpenInventorViewer::SetSolid ( )
protected

◆ SetTouchable()

void G4VViewer::SetTouchable ( const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &  fullPath)
protectedinherited

Definition at line 124 of file G4VViewer.cc.

126{
127 // Set the touchable for /vis/touchable/set/... commands.
128 std::ostringstream oss;
129 const auto& pvStore = G4PhysicalVolumeStore::GetInstance();
130 for (const auto& pvNodeId: fullPath) {
131 const auto& pv = pvNodeId.GetPhysicalVolume();
132 auto iterator = find(pvStore->begin(),pvStore->end(),pv);
133 if (iterator == pvStore->end()) {
135 ed << "Volume no longer in physical volume store.";
136 G4Exception("G4VViewer::SetTouchable", "visman0501", JustWarning, ed);
137 } else {
138 oss
139 << ' ' << pvNodeId.GetPhysicalVolume()->GetName()
140 << ' ' << pvNodeId.GetCopyNo();
141 }
142 }
143 G4UImanager::GetUIpointer()->ApplyCommand("/vis/set/touchable" + oss.str());
144}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
static G4PhysicalVolumeStore * GetInstance()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77

References G4UImanager::ApplyCommand(), G4Exception(), G4PhysicalVolumeStore::GetInstance(), G4UImanager::GetUIpointer(), and JustWarning.

Referenced by G4OpenGLQtViewer::changeColorAndTransparency(), and G4OpenGLQtViewer::setCheckComponent().

◆ SetView()

void G4OpenInventorViewer::SetView ( )
virtual

Implements G4VViewer.

Reimplemented in G4OpenInventorQtViewer, G4OpenInventorWinViewer, G4OpenInventorXtExtendedViewer, and G4OpenInventorXtViewer.

Definition at line 237 of file G4OpenInventorViewer.cc.

237 {
238
239 // Get G4 camera infos :
240 const G4Point3D target
244 if(radius<=0.) radius = 1.;
245 const G4double cameraDistance = fVP.GetCameraDistance (radius);
246 const G4Vector3D& direction = fVP.GetViewpointDirection().unit();
247 const G4Point3D cameraPosition = target + cameraDistance * direction;
248 //const G4double pnear = fVP.GetNearDistance (cameraDistance, radius);
249 //const G4double pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
250 const G4Normal3D& up = fVP.GetUpVector ();
251
252/*
253 printf("debug : target : %g %g %g\n",target.x(),
254 target.y(),
255 target.z());
256 printf("debug : dir : %g %g %g\n",direction.x(),
257 direction.y(),
258 direction.z());
259 printf("debug : pos : %g %g %g\n",cameraPosition.x(),
260 cameraPosition.y(),
261 cameraPosition.z());
262 //printf("debug : near %g far %g\n",pnear,pfar);
263*/
264
265 SoCamera* camera = GetCamera();
266 if(!camera) return;
267
268 // viewer camera setup :
269 camera->position.setValue((float)cameraPosition.x(),
270 (float)cameraPosition.y(),
271 (float)cameraPosition.z());
272
273 SbVec3f sbTarget((float)target.x(),
274 (float)target.y(),
275 (float)target.z());
276 SbVec3f sbUp((float)up.x(),
277 (float)up.y(),
278 (float)up.z());
279 sbUp.normalize();
280 // Need Coin's camera->pointAt(sbTarget,sbUp); not in the SGI API
281 // Stole Coin's code...
282 pointAt(camera,sbTarget,sbUp);
283
284 //camera->height.setValue(10);
285 //camera->nearDistance.setValue((float)pnear);
286 //camera->farDistance.setValue((float)pfar);
287 //camera->focalDistance.setValue((float)cameraDistance);
288
289 if(camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
290 if (fVP.GetFieldHalfAngle() == 0.) {
291 //FIXME : ((SoOrthographicCamera*)camera)->height.setValue();
292 //FIXME : (Don't think we have to do that.)
293 } else {
294 //FIXME : Have to set a perspective camera !
295 //FIXME : viewer->setCameraType(SoPerspectiveCamera::getClassTypeId())
296 //FIXME : ((SoPerspectiveCamera*)camera)->heightAngle.setValue
297 //FIXME : (2.*fVP.GetFieldHalfAngle());
298 }
299 } else if(camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
300 if (fVP.GetFieldHalfAngle() == 0.) {
301 //FIXME : Have to set an orthographic camera !
302 //FIXME : viewer->setCameraType(SoOrthographicCamera::getClassTypeId())
303 } else {
304 //FIXME : ((SoPerspectiveCamera*)camera)->heightAngle.setValue
305 //FIXME : (2.*fVP.GetFieldHalfAngle());
306 }
307 }
308}
double G4double
Definition: G4Types.hh:83
virtual SoCamera * GetCamera()=0
static void pointAt(SoCamera *, const SbVec3f &targetpoint, const SbVec3f &upvector)
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
G4Scene * GetScene() const
G4double GetCameraDistance(G4double radius) const
const G4Vector3D & GetViewpointDirection() const
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFieldHalfAngle() const
const G4Vector3D & GetUpVector() const
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
BasicVector3D< T > unit() const

References G4VViewer::fSceneHandler, G4VViewer::fVP, GetCamera(), G4ViewParameters::GetCameraDistance(), G4ViewParameters::GetCurrentTargetPoint(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetFieldHalfAngle(), G4VSceneHandler::GetScene(), G4Scene::GetStandardTargetPoint(), G4ViewParameters::GetUpVector(), G4ViewParameters::GetViewpointDirection(), pointAt(), HepGeom::BasicVector3D< T >::unit(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4OpenInventorQtViewer::SetView(), G4OpenInventorWinViewer::SetView(), G4OpenInventorXtExtendedViewer::SetView(), and G4OpenInventorXtViewer::SetView().

◆ SetViewParameters()

void G4VViewer::SetViewParameters ( const G4ViewParameters vp)
inherited

◆ SetWireFrame()

void G4OpenInventorViewer::SetWireFrame ( )
protected

◆ ShowView()

void G4OpenInventorViewer::ShowView ( void  )
virtual

Reimplemented from G4VViewer.

Definition at line 391 of file G4OpenInventorViewer.cc.

391 {
392 fInteractorManager -> SecondaryLoop ();
393}

References fInteractorManager.

◆ TouchableSetColour()

void G4VViewer::TouchableSetColour ( const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &  fullPath,
const G4Colour colour 
)
protectedinherited

Definition at line 180 of file G4VViewer.cc.

183{
184 // Changes the Vis Attribute Modifiers WITHOUT triggering a rebuild.
185
186 std::ostringstream oss;
187 oss << "/vis/touchable/set/colour "
188 << colour.GetRed() << ' ' << colour.GetGreen()
189 << ' ' << colour.GetBlue() << ' ' << colour.GetAlpha();
190
191 // The following is equivalent to
192 // G4UImanager::GetUIpointer()->ApplyCommand(oss.str());
193 // (assuming the touchable has already been set), but avoids view rebuild.
194
195 // Instantiate a working copy of a G4VisAttributes object...
196 G4VisAttributes workingVisAtts;
197 // and set the colour.
198 workingVisAtts.SetColour(colour);
199
202 (workingVisAtts,
205 // G4ModelingParameters::VASColour (VAS = Vis Attribute Signifier)
206 // signifies that it is the colour that should be picked out
207 // and merged with the touchable's normal vis attributes.
208
209 // Record on G4cout (with #) for information.
210 if (G4UImanager::GetUIpointer()->GetVerboseLevel() >= 2) {
211 G4cout << "# " << oss.str() << G4endl;
212 }
213}
G4double GetBlue() const
Definition: G4Colour.hh:154
G4double GetAlpha() const
Definition: G4Colour.hh:155
G4double GetRed() const
Definition: G4Colour.hh:152
G4double GetGreen() const
Definition: G4Colour.hh:153
static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath(const std::vector< G4PhysicalVolumeNodeID > &)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
void SetColour(const G4Colour &)

References G4ViewParameters::AddVisAttributesModifier(), G4VViewer::fVP, G4cout, G4endl, G4Colour::GetAlpha(), G4Colour::GetBlue(), G4Colour::GetGreen(), G4PhysicalVolumeModel::GetPVNameCopyNoPath(), G4Colour::GetRed(), G4UImanager::GetUIpointer(), G4VisAttributes::SetColour(), and G4ModelingParameters::VASColour.

Referenced by G4OpenGLQtViewer::changeColorAndTransparency().

◆ TouchableSetVisibility()

void G4VViewer::TouchableSetVisibility ( const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &  fullPath,
G4bool  visibility 
)
protectedinherited

Definition at line 146 of file G4VViewer.cc.

149{
150 // Changes the Vis Attribute Modifiers WITHOUT triggering a rebuild.
151
152 std::ostringstream oss;
153 oss << "/vis/touchable/set/visibility ";
154 if (visibiity) oss << "true"; else oss << "false";
155
156 // The following is equivalent to
157 // G4UImanager::GetUIpointer()->ApplyCommand(oss.str());
158 // (assuming the touchable has already been set), but avoids view rebuild.
159
160 // Instantiate a working copy of a G4VisAttributes object...
161 G4VisAttributes workingVisAtts;
162 // and set the visibility.
163 workingVisAtts.SetVisibility(visibiity);
164
167 (workingVisAtts,
170 // G4ModelingParameters::VASVisibility (VAS = Vis Attribute Signifier)
171 // signifies that it is the visibility that should be picked out
172 // and merged with the touchable's normal vis attributes.
173
174 // Record on G4cout (with #) for information.
175 if (G4UImanager::GetUIpointer()->GetVerboseLevel() >= 2) {
176 G4cout << "# " << oss.str() << G4endl;
177 }
178}
void SetVisibility(G4bool=true)

References G4ViewParameters::AddVisAttributesModifier(), G4VViewer::fVP, G4cout, G4endl, G4PhysicalVolumeModel::GetPVNameCopyNoPath(), G4UImanager::GetUIpointer(), G4VisAttributes::SetVisibility(), and G4ModelingParameters::VASVisibility.

Referenced by G4OpenGLQtViewer::setCheckComponent().

◆ UpdateScene()

void G4OpenInventorViewer::UpdateScene ( )
protected

Definition at line 762 of file G4OpenInventorViewer.cc.

762 {
763 /* Replace this... - JA
764 fG4OpenInventorSceneHandler.ClearStore();
765 ClearView();
766 if (!fNeedKernelVisit) KernelVisitDecision();
767 ProcessView();
768 ShowView();
769 */
770 // ...by this - JA
772 DrawView();
773}

References DrawView(), and G4VViewer::NeedKernelVisit().

Referenced by G4OpenInventorQtViewer::EtcUpdateSceneCB(), G4OpenInventorXtExtendedViewer::UpdateSceneCbk(), G4OpenInventorXtViewer::UpdateSceneCbk(), and G4OpenInventorWinViewer::WindowProc().

◆ ViewerRender()

virtual void G4OpenInventorViewer::ViewerRender ( )
protectedpure virtual

◆ WriteInventor()

void G4OpenInventorViewer::WriteInventor ( const G4String file = "g4out.iv")
protected

Definition at line 570 of file G4OpenInventorViewer.cc.

570 {
571 G4cout << "Produce " << aFile << "..." << G4endl;
572
573 SbBool genAlternateRep = TRUE;
574 //SbBool binary = FALSE;
575 SbBool binary = TRUE;
576 SoAlternateRepAction alternateRepAction;
577 if(genAlternateRep==TRUE) {
578 alternateRepAction.setGenerate(TRUE); //Clear alternate reps.
579 alternateRepAction.apply(fSoSelection);
580 }
581
582 SoWriteAction writeAction;
583 writeAction.getOutput()->openFile(aFile.c_str());
584 writeAction.getOutput()->setBinary(binary);
585 writeAction.apply(fSoSelection);
586 writeAction.getOutput()->closeFile();
587
588 if(genAlternateRep==TRUE) {
589 alternateRepAction.setGenerate(FALSE); //Clear alternate reps.
590 alternateRepAction.apply(fSoSelection);
591 }
592
593
594
595}
#define FALSE
Definition: Globals.hh:23
void setGenerate(SbBool)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

References FALSE, fSoSelection, G4cout, G4endl, SoAlternateRepAction::setGenerate(), and TRUE.

Referenced by G4OpenInventorQtViewer::FileWriteIVCB(), G4OpenInventorWinViewer::WindowProc(), G4OpenInventorXtExtendedViewer::WriteInventorCbk(), and G4OpenInventorXtViewer::WriteInventorCbk().

◆ WritePDF()

void G4OpenInventorViewer::WritePDF ( const G4String file = "g4out.pdf")
protected

Definition at line 539 of file G4OpenInventorViewer.cc.

539 {
540 if(!fGL2PSAction) return;
541 fGL2PSAction->setFileName(aFile.c_str());
542 fGL2PSAction->setExportImageFormat(GL2PS_PDF);
543 // Use gl2ps default buffer (2048*2048)
544 fGL2PSAction->setBufferSize(0);
545 G4cout << "Produce " << aFile << "..." << G4endl;
546 if (fGL2PSAction->enableFileWriting()) {
547 ViewerRender();
548 fGL2PSAction->disableFileWriting();
549 }
550 fGL2PSAction->resetBufferSizeParameters();
551}
virtual void ViewerRender()=0
#define GL2PS_PDF
Definition: gl2ps.h:132

References fGL2PSAction, G4cout, G4endl, GL2PS_PDF, and ViewerRender().

Referenced by G4OpenInventorQtViewer::FileWritePDFCB(), and G4OpenInventorXtExtendedViewer::PDFCbk().

◆ WritePixmapPostScript()

void G4OpenInventorViewer::WritePixmapPostScript ( const G4String file = "g4out.ps")
protected

Definition at line 553 of file G4OpenInventorViewer.cc.

553 {
554 fSoImageWriter->fileName.setValue(aFile.c_str());
555 //imageWriter->format.setValue(SoImageWriter::POST_SCRIPT);
556 fSoImageWriter->enable();
557 ViewerRender();
558 fSoImageWriter->disable();
559 if(fSoImageWriter->getStatus()) {
560 G4cout << G4String(fSoImageWriter->fileName.getValue().getString())
561 << " produced."
562 << G4endl;
563 } else {
564 G4cout << G4String(fSoImageWriter->fileName.getValue().getString())
565 << " not produced."
566 << G4endl;
567 }
568}

References fSoImageWriter, G4cout, G4endl, and ViewerRender().

Referenced by G4OpenInventorXtExtendedViewer::PixmapPostScriptCbk(), G4OpenInventorXtViewer::PixmapPostScriptCbk(), and G4OpenInventorWinViewer::WindowProc().

◆ WritePostScript()

void G4OpenInventorViewer::WritePostScript ( const G4String file = "g4out.ps")
protected

Definition at line 525 of file G4OpenInventorViewer.cc.

525 {
526 if(!fGL2PSAction) return;
527 fGL2PSAction->setFileName(aFile.c_str());
528 fGL2PSAction->setExportImageFormat(GL2PS_EPS);
529 // Use gl2ps default buffer (2048*2048)
530 fGL2PSAction->setBufferSize(0);
531 G4cout << "Produce " << aFile << "..." << G4endl;
532 if (fGL2PSAction->enableFileWriting()) {
533 ViewerRender();
534 fGL2PSAction->disableFileWriting();
535 }
536 fGL2PSAction->resetBufferSizeParameters();
537}
#define GL2PS_EPS
Definition: gl2ps.h:130

References fGL2PSAction, G4cout, G4endl, GL2PS_EPS, and ViewerRender().

Referenced by G4OpenInventorQtViewer::FileWritePSCB(), G4OpenInventorXtExtendedViewer::PostScriptCbk(), G4OpenInventorXtViewer::PostScriptCbk(), and G4OpenInventorWinViewer::WindowProc().

Field Documentation

◆ fDefaultVP

G4ViewParameters G4VViewer::fDefaultVP
protectedinherited

◆ fG4OpenInventorSceneHandler

G4OpenInventorSceneHandler& G4OpenInventorViewer::fG4OpenInventorSceneHandler
protected

◆ fGL2PSAction

Geant4_SoGL2PSAction* G4OpenInventorViewer::fGL2PSAction
protected

◆ fGroupCameraSensor

SoNodeSensor* G4OpenInventorViewer::fGroupCameraSensor
protected

Definition at line 99 of file G4OpenInventorViewer.hh.

Referenced by G4OpenInventorViewer(), and ~G4OpenInventorViewer().

◆ fInteractorManager

G4VInteractorManager* G4OpenInventorViewer::fInteractorManager
protected

◆ fLastVP

G4ViewParameters G4OpenInventorViewer::fLastVP
private

Definition at line 91 of file G4OpenInventorViewer.hh.

Referenced by DrawView(), and KernelVisitDecision().

◆ fName

G4String G4VViewer::fName
protectedinherited

◆ fNeedKernelVisit

G4bool G4VViewer::fNeedKernelVisit
protectedinherited

◆ fSceneHandler

G4VSceneHandler& G4VViewer::fSceneHandler
protectedinherited

◆ fShortName

G4String G4VViewer::fShortName
protectedinherited

◆ fSoImageWriter

Geant4_SoImageWriter* G4OpenInventorViewer::fSoImageWriter
protected

Definition at line 97 of file G4OpenInventorViewer.hh.

Referenced by G4OpenInventorViewer(), and WritePixmapPostScript().

◆ fSoSelection

SoSelection* G4OpenInventorViewer::fSoSelection
protected

◆ fViewId

G4int G4VViewer::fViewId
protectedinherited

◆ fVP

G4ViewParameters G4VViewer::fVP
protectedinherited

Definition at line 219 of file G4VViewer.hh.

Referenced by G4OpenGLQtViewer::actionChangeBackgroundColor(), G4OpenGLQtViewer::actionChangeDefaultColor(), G4OpenGLQtViewer::actionChangeTextColor(), G4OpenGLXmViewer::actions_callback(), G4OpenGLSceneHandler::AddPrimitive(), G4OpenGLImmediateSceneHandler::AddPrimitivePreambleInternal(), G4OpenGLStoredSceneHandler::AddPrimitivePreambleInternal(), G4OpenGLXmViewer::aux_edge_callback(), G4OpenGLQtViewer::changeDepthInSceneTree(), G4OpenGLStoredQtViewer::CompareForKernelVisit(), G4OpenGLStoredViewer::CompareForKernelVisit(), CompareForKernelVisit(), G4Qt3DViewer::CompareForKernelVisit(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::CompareForKernelVisit(), G4OpenGLStoredQtViewer::ComputeView(), G4OpenGLWin32Viewer::CreateMainWindow(), G4OpenGLXmViewer::CreateMainWindow(), G4OpenGLXViewer::CreateMainWindow(), G4OpenGLQtViewer::CreateMainWindow(), G4OpenGLQtViewer::createPopupMenu(), G4OpenGLXmViewer::dolly_callback(), G4OpenGLStoredViewer::DrawDisplayLists(), G4OpenGLXmViewer::drawing_style_callback(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), G4OpenGLStoredXViewer::DrawView(), DrawView(), G4Qt3DViewer::DrawView(), G4RayTracerViewer::DrawView(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::DrawView(), G4VtkViewer::DrawViewHUD(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::Export(), G4ASCIITreeViewer::G4ASCIITreeViewer(), G4HepRepFileViewer::G4HepRepFileViewer(), G4OpenGLQtViewer::G4keyPressEvent(), G4OpenGLQtViewer::G4MouseMoveEvent(), G4OpenGLQtViewer::G4MousePressEvent(), G4OpenGLQtViewer::G4MouseReleaseEvent(), G4OpenGLViewer::G4OpenGLViewer(), G4OpenInventorViewer(), G4VtkViewer::G4VtkViewer(), G4VViewer::G4VViewer(), G4OpenGLQtViewer::G4wheelEvent(), G4OpenGLViewer::getSceneDepth(), G4OpenGLViewer::getSceneFarWidth(), G4OpenGLViewer::getSceneNearWidth(), G4OpenGLXmViewer::GetXmConnection(), GroupCameraSensorCB(), G4OpenInventorQtViewer::Initialise(), G4OpenInventorWinViewer::Initialise(), G4OpenInventorXtExtendedViewer::Initialise(), G4OpenInventorXtViewer::Initialise(), G4Qt3DViewer::Initialise(), G4RayTracerViewer::Initialise(), G4RayTracerXViewer::Initialise(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::Initialise(), G4VtkQtViewer::Initialise(), G4VtkViewer::Initialise(), G4OpenGLViewer::InitializeGLView(), G4OpenGLXmViewer::left_right_pan_callback(), G4OpenGLXmViewer::misc_callback(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::mouse_move(), G4Qt3DViewer::mouseMoveEvent(), G4OpenGLQtViewer::moveScene(), G4OpenGLImmediateViewer::ProcessView(), G4OpenGLXmViewer::projection_callback(), G4OpenGLXmViewer::reset_callback(), G4OpenGLXmViewer::ResetView(), G4OpenGLViewer::rotateScene(), G4OpenGLViewer::rotateSceneInViewDirection(), G4OpenGLViewer::rotateSceneThetaPhi(), G4OpenGLViewer::rotateSceneToggle(), G4DAWNFILEViewer::SendDrawingStyleToDAWNGUI(), G4DAWNFILEViewer::SendViewParameters(), G4VRML2FileViewer::SendViewParameters(), G4OpenGLXmViewer::set_rot_subject_callback(), G4OpenGLViewerMessenger::SetNewValue(), G4OpenGLXmViewerMessenger::SetNewValue(), G4OpenGLWin32Viewer::SetRotation(), G4OpenGLWin32Viewer::SetShift(), G4OpenGLViewer::SetView(), G4OpenInventorQtViewer::SetView(), SetView(), G4OpenInventorWinViewer::SetView(), G4OpenInventorXtExtendedViewer::SetView(), G4OpenInventorXtViewer::SetView(), G4Qt3DViewer::SetView(), G4RayTracerViewer::SetView(), G4ToolsSGQtViewer::SetView(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::SetView(), G4VtkViewer::SetView(), G4VViewer::SetViewParameters(), G4OpenGLWin32Viewer::SetZoom(), G4OpenGLXViewer::ShowView(), G4VtkViewer::ShowView(), G4OpenGLQtViewer::toggleAux(), G4OpenGLQtViewer::toggleHiddenMarkers(), G4OpenGLQtViewer::togglePicking(), G4OpenGLQtViewer::toggleProjection(), G4OpenGLQtViewer::toggleSurfaceAction(), G4VViewer::TouchableSetColour(), G4VViewer::TouchableSetVisibility(), G4OpenGLXmViewer::up_down_pan_callback(), G4OpenGLXmViewer::update_panels_callback(), G4OpenGLXmViewer::UpdateControlPanel(), G4OpenGLQtViewer::updateToolbarAndMouseContextMenu(), G4OpenGLQtViewer::updateViewerPropertiesTableWidget(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::wheel_rotate(), G4Qt3DViewer::wheelEvent(), G4OpenGLXmViewer::wobble_callback(), G4OpenGLXmViewer::wobble_timer_callback(), and G4OpenGLXmViewer::zoom_callback().


The documentation for this class was generated from the following files: