Geant4-11
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types
G4ToolsSGViewer< SG_SESSION, SG_VIEWER > Class Template Reference

#include <G4ToolsSGViewer.hh>

Inheritance diagram for G4ToolsSGViewer< SG_SESSION, SG_VIEWER >:
G4VViewer

Data Structures

class  Messenger
 

Public Member Functions

virtual void ClearView ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
virtual void DrawView ()
 
virtual void FinishView ()
 
 G4ToolsSGViewer (SG_SESSION &a_session, G4ToolsSGSceneHandler &a_scene_handler, const G4String &a_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 key_press (const tools::sg::key_down_event &a_event)
 
virtual void key_release (const tools::sg::key_up_event &)
 
virtual void mouse_move (const tools::sg::mouse_move_event &a_event)
 
virtual void mouse_press (const tools::sg::mouse_down_event &a_event)
 
virtual void mouse_release (const tools::sg::mouse_up_event &)
 
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 void wheel_rotate (const tools::sg::wheel_rotate_event &a_event)
 
virtual ~G4ToolsSGViewer ()
 

Protected Member Functions

G4bool CompareForKernelVisit (G4ViewParameters &lastVP)
 
void CreateSG (tools::sg::base_camera *a_camera, const G4Vector3D &a_light_dir)
 
void Export (const G4String &a_format, const G4String &a_file)
 
 G4ToolsSGViewer (const G4ToolsSGViewer &a_from)
 
void KernelVisitDecision ()
 
G4ToolsSGVieweroperator= (const G4ToolsSGViewer &)
 
void SetTouchable (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
 
void TouchableSetColour (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
 
void TouchableSetVisibility (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
 

Protected Attributes

tools::sg::gl2ps_manager f_gl2ps_mgr
 
tools::sg::zb_manager f_zb_mgr
 
G4ViewParameters fDefaultVP
 
G4bool fKeyPressed
 
G4bool fKeyShift
 
G4ViewParameters fLastVP
 
G4bool fMousePressed
 
G4double fMousePressedX
 
G4double fMousePressedY
 
G4String fName
 
G4bool fNeedKernelVisit
 
G4VSceneHandlerfSceneHandler
 
G4ToolsSGSceneHandlerfSGSceneHandler
 
SG_SESSION & fSGSession
 
SG_VIEWER * fSGViewer
 
G4String fShortName
 
G4int fViewId
 
G4ViewParameters fVP
 

Private Types

typedef G4VViewer parent
 
typedef tools::sg::device_interactor parent_interactor
 

Detailed Description

template<class SG_SESSION, class SG_VIEWER>
class G4ToolsSGViewer< SG_SESSION, SG_VIEWER >

Definition at line 50 of file G4ToolsSGViewer.hh.

Member Typedef Documentation

◆ parent

template<class SG_SESSION , class SG_VIEWER >
typedef G4VViewer G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::parent
private

Definition at line 51 of file G4ToolsSGViewer.hh.

◆ parent_interactor

template<class SG_SESSION , class SG_VIEWER >
typedef tools::sg::device_interactor G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::parent_interactor
private

Definition at line 52 of file G4ToolsSGViewer.hh.

Constructor & Destructor Documentation

◆ G4ToolsSGViewer() [1/2]

template<class SG_SESSION , class SG_VIEWER >
G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::G4ToolsSGViewer ( SG_SESSION &  a_session,
G4ToolsSGSceneHandler a_scene_handler,
const G4String a_name 
)
inline

Definition at line 119 of file G4ToolsSGViewer.hh.

120 :parent(a_scene_handler,a_scene_handler.IncrementViewCount(),a_name)
121 ,fSGSession(a_session)
122 ,fSGSceneHandler(a_scene_handler)
123 ,fSGViewer(nullptr)
124 ,fKeyPressed(false)
125 ,fKeyShift(false)
126 ,fMousePressed(false)
129 {
130 //::printf("debug : G4ToolsSGViewer::G4ToolsSGViewer: %lu, %s\n",this,a_name.c_str());
132 }
SG_SESSION & fSGSession
G4ToolsSGSceneHandler & fSGSceneHandler
SG_VIEWER * fSGViewer
G4int IncrementViewCount()

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::Messenger::Create().

◆ ~G4ToolsSGViewer()

template<class SG_SESSION , class SG_VIEWER >
virtual G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::~G4ToolsSGViewer ( )
inlinevirtual

Definition at line 134 of file G4ToolsSGViewer.hh.

134 {
135 //::printf("debug : G4ToolsSGViewer::~G4ToolsSGViewer: %lu\n",this);
136 //WARNING : nodes may refer f_gl2ps_mgr, f_zb_mgr (to handle gstos (for GPU) or textures), then
137 // we have to delete them first.
138 fSGViewer->sg().clear();
139 delete fSGViewer;
140 }

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGViewer.

◆ G4ToolsSGViewer() [2/2]

template<class SG_SESSION , class SG_VIEWER >
G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::G4ToolsSGViewer ( const G4ToolsSGViewer< SG_SESSION, SG_VIEWER > &  a_from)
inlineprotected

Definition at line 142 of file G4ToolsSGViewer.hh.

143 :parent(a_from)
144 ,parent_interactor(a_from)
145 ,fSGSession(a_from.fSGSession)
147 ,fSGViewer(nullptr)
148 ,fKeyPressed(false)
149 ,fKeyShift(false)
150 ,fMousePressed(false)
153 {}
tools::sg::device_interactor parent_interactor

Member Function Documentation

◆ ClearView()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::ClearView ( void  )
inlinevirtual

Implements G4VViewer.

Definition at line 271 of file G4ToolsSGViewer.hh.

271{}

◆ CompareForKernelVisit()

template<class SG_SESSION , class SG_VIEWER >
G4bool G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::CompareForKernelVisit ( G4ViewParameters lastVP)
inlineprotected

Definition at line 326 of file G4ToolsSGViewer.hh.

326 {
327 // Typical comparison. Taken from OpenGL.
328 if (
329 (lastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
331 (lastVP.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) ||
332 (lastVP.IsCulling () != fVP.IsCulling ()) ||
333 (lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
334 (lastVP.IsDensityCulling () != fVP.IsDensityCulling ()) ||
335 (lastVP.IsCullingCovered () != fVP.IsCullingCovered ()) ||
336 (lastVP.GetCBDAlgorithmNumber() !=
338 (lastVP.IsSection () != fVP.IsSection ()) ||
339 (lastVP.IsCutaway () != fVP.IsCutaway ()) ||
340 (lastVP.IsExplode () != fVP.IsExplode ()) ||
341 (lastVP.GetNoOfSides () != fVP.GetNoOfSides ()) ||
344 (lastVP.IsMarkerNotHidden () != fVP.IsMarkerNotHidden ()) ||
345 (lastVP.GetDefaultVisAttributes()->GetColour() !=
350 (lastVP.IsPicking () != fVP.IsPicking ()) ||
351 (lastVP.GetVisAttributesModifiers() !=
353 (lastVP.IsSpecialMeshRendering() !=
355 ) {
356 return true;
357 }
358
359 if (lastVP.IsDensityCulling () &&
360 (lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ())) return true;
361
362 if (lastVP.GetCBDAlgorithmNumber() > 0) {
363 if (lastVP.GetCBDParameters().size() != fVP.GetCBDParameters().size()) return true;
364 else if (lastVP.GetCBDParameters() != fVP.GetCBDParameters()) return true;
365 }
366
367 if (lastVP.IsExplode () &&
368 (lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
369 return true;
370
371 if (lastVP.IsSpecialMeshRendering() &&
373 return true;
374
375 return false;
376 }
G4ViewParameters fVP
Definition: G4VViewer.hh:219
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() 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
G4bool IsDensityCulling() const
G4double GetVisibleDensity() const
G4bool IsCullingCovered() const
DrawingStyle GetDrawingStyle() const
G4bool IsAuxEdgeVisible() const
const G4Colour & GetColour() const

References G4VViewer::fVP, G4ViewParameters::GetBackgroundColour(), G4ViewParameters::GetCBDAlgorithmNumber(), G4ViewParameters::GetCBDParameters(), G4VisAttributes::GetColour(), G4ViewParameters::GetDefaultTextVisAttributes(), G4ViewParameters::GetDefaultVisAttributes(), G4ViewParameters::GetDrawingStyle(), G4ViewParameters::GetExplodeFactor(), G4ViewParameters::GetGlobalLineWidthScale(), G4ViewParameters::GetGlobalMarkerScale(), G4ViewParameters::GetNoOfSides(), G4ViewParameters::GetNumberOfCloudPoints(), 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 G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::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().

◆ CreateSG()

template<class SG_SESSION , class SG_VIEWER >
void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::CreateSG ( tools::sg::base_camera *  a_camera,
const G4Vector3D a_light_dir 
)
inlineprotected

2D scene graph: ///////////////////////////////

3D scene graph: ///////////////////////////////

Definition at line 387 of file G4ToolsSGViewer.hh.

387 {
388 tools::sg::group& _parent = fSGViewer->sg();
389 _parent.clear();
390
394 tools::sg::separator* scene_2D = new tools::sg::separator;
395 _parent.add(scene_2D);
396 scene_2D->add(new tools::sg::noderef(fSGSceneHandler.GetTransient2DObjects()));
397 scene_2D->add(new tools::sg::noderef(fSGSceneHandler.GetPersistent2DObjects()));
398
402 tools::sg::separator* scene_3D = new tools::sg::separator;
403 _parent.add(scene_3D);
404
405 scene_3D->add(a_camera);
406
407 {tools::sg::torche* light = new tools::sg::torche;
408 light->on = true;
409 light->direction = tools::vec3f(-a_light_dir.x(),-a_light_dir.y(),-a_light_dir.z());
410 scene_3D->add(light);}
411
412 {tools::sg::blend* blend = new tools::sg::blend;
413 blend->on = true; //to handle transparency.
414 scene_3D->add(blend);}
415
416 scene_3D->add(new tools::sg::noderef(fSGSceneHandler.GetTransient3DObjects()));
417 scene_3D->add(new tools::sg::noderef(fSGSceneHandler.GetPersistent3DObjects()));
418 }
tools::sg::separator & GetTransient3DObjects()
tools::sg::separator & GetTransient2DObjects()
tools::sg::separator & GetPersistent3DObjects()
tools::sg::separator & GetPersistent2DObjects()

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGSceneHandler, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGViewer, G4ToolsSGSceneHandler::GetPersistent2DObjects(), G4ToolsSGSceneHandler::GetPersistent3DObjects(), G4ToolsSGSceneHandler::GetTransient2DObjects(), G4ToolsSGSceneHandler::GetTransient3DObjects(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::SetView().

◆ DrawView()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::DrawView ( )
inlinevirtual

Implements G4VViewer.

Definition at line 273 of file G4ToolsSGViewer.hh.

273 {
275 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
276 fLastVP = fVP;
277 ProcessView(); // Clears store and processes scene only if necessary.
278 if (kernelVisitWasNeeded) {
279 // We might need to do something if the kernel was visited.
280 } else {
281 }
282 FinishView (); // Flush streams and/or swap buffers.
283 }
bool G4bool
Definition: G4Types.hh:86
virtual void FinishView()
G4ViewParameters fLastVP
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:224
void ProcessView()
Definition: G4VViewer.cc:105

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::FinishView(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fLastVP, G4VViewer::fNeedKernelVisit, G4VViewer::fVP, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::KernelVisitDecision(), and G4VViewer::ProcessView().

Referenced by G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::mouse_move(), and G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::wheel_rotate().

◆ Export()

template<class SG_SESSION , class SG_VIEWER >
void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::Export ( const G4String a_format,
const G4String a_file 
)
inlineprotected

Definition at line 420 of file G4ToolsSGViewer.hh.

420 {
421 if(!fSGViewer) return;
422 const G4Colour& back_color = fVP.GetBackgroundColour();
423 if(!write_paper(G4cout,f_gl2ps_mgr,f_zb_mgr,0,0,
424 float(back_color.GetRed()),float(back_color.GetGreen()),float(back_color.GetBlue()),float(back_color.GetAlpha()),
425 fSGViewer->sg(),
426 fSGViewer->width(),fSGViewer->height(),a_file,a_format)) {
427 G4cout << "G4ToolsSGViewer::Export: write_paper() failed." << G4endl;
428 return;
429 }
430 }
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
tools::sg::gl2ps_manager f_gl2ps_mgr
tools::sg::zb_manager f_zb_mgr

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::f_gl2ps_mgr, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::f_zb_mgr, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGViewer, G4VViewer::fVP, G4cout, G4endl, G4Colour::GetAlpha(), G4ViewParameters::GetBackgroundColour(), G4Colour::GetBlue(), G4Colour::GetGreen(), and G4Colour::GetRed().

Referenced by G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::Messenger::SetNewValue().

◆ FinishView()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::FinishView ( void  )
inlinevirtual

◆ GetApplicableVisAttributes()

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

◆ 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(), G4OpenInventorViewer::SetReducedWireFrame(), G4OpenInventorViewer::SetSolid(), and G4OpenInventorViewer::SetWireFrame().

◆ Initialise()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::Initialise ( )
inlinevirtual

create the viewer, set the scene graph ///////////////

Reimplemented from G4VViewer.

Reimplemented in G4ToolsSGQtViewer.

Definition at line 156 of file G4ToolsSGViewer.hh.

156 {
157 if(fSGViewer) return; //done.
158 fVP.SetAutoRefresh(true);
160 //::printf("debug : G4ToolsSGViewer::Initialise\n");
164 fSGViewer = new SG_VIEWER(fSGSession
169 ,fName);
170 if(!fSGViewer->has_window()) {
171 fViewId = -1; // This flags an error.
172 G4cerr << "G4ToolsSGViewer::Initialise : SG_VIEWER::has_window() failed." << G4endl;
173 return;
174 }
175 fSGViewer->set_device_interactor(this);
176 }
G4GLOB_DLL std::ostream G4cerr
G4String fName
Definition: G4VViewer.hh:217
G4ViewParameters fDefaultVP
Definition: G4VViewer.hh:220
G4int fViewId
Definition: G4VViewer.hh:216
void SetAutoRefresh(G4bool)
G4int GetWindowAbsoluteLocationHintY(G4int) const
unsigned int GetWindowSizeHintX() const
G4int GetWindowAbsoluteLocationHintX(G4int) const
unsigned int GetWindowSizeHintY() const

References G4VViewer::fDefaultVP, G4VViewer::fName, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGSession, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGViewer, G4VViewer::fViewId, G4VViewer::fVP, G4cerr, G4endl, G4ViewParameters::GetWindowAbsoluteLocationHintX(), G4ViewParameters::GetWindowAbsoluteLocationHintY(), G4ViewParameters::GetWindowSizeHintX(), G4ViewParameters::GetWindowSizeHintY(), and G4ViewParameters::SetAutoRefresh().

◆ KernelVisitDecision()

template<class SG_SESSION , class SG_VIEWER >
void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::KernelVisitDecision ( )
inlineprotected

◆ key_press()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::key_press ( const tools::sg::key_down_event &  a_event)
inlinevirtual

Definition at line 54 of file G4ToolsSGViewer.hh.

54 {
55 fKeyPressed = true;
56 fKeyShift = a_event.key() == tools::sg::key_shift()?true:false;
57 }

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyPressed, and G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyShift.

◆ key_release()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::key_release ( const tools::sg::key_up_event &  )
inlinevirtual

Definition at line 58 of file G4ToolsSGViewer.hh.

58{fKeyPressed = false;}

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyPressed.

◆ mouse_move()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::mouse_move ( const tools::sg::mouse_move_event &  a_event)
inlinevirtual

Definition at line 65 of file G4ToolsSGViewer.hh.

65 {
66 G4double x = a_event.x();
67 G4double y = a_event.y();
72
73 if (fMousePressed) {
74
75 if (fKeyPressed && fKeyShift) { // Translation (pan)
76
78 const G4double scale = 300; // Roughly pixels per window, empirically chosen
79 const G4double dxScene = dx*sceneRadius/scale;
80 const G4double dyScene = dy*sceneRadius/scale;
81 fVP.IncrementPan(-dxScene,dyScene);
82
83 } else { // Rotation
84
85 // Simple ad-hoc algorithms
87 const G4Vector3D& y_prime = x_prime.cross(fVP.GetViewpointDirection());
88 const G4double scale = 200; // Roughly pixels per window, empirically chosen
89 G4Vector3D newViewpointDirection = fVP.GetViewpointDirection();
90 newViewpointDirection += dx*x_prime/scale;
91 newViewpointDirection += dy*y_prime/scale;
92 fVP.SetViewpointDirection(newViewpointDirection.unit());
93
95 G4Vector3D newUpVector = fVP.GetUpVector();
96 newUpVector += dx*x_prime/scale;
97 newUpVector += dy*y_prime/scale;
98 fVP.SetUpVector(newUpVector.unit());
99 }
100 }
101 }
102
103 SetView();
104 DrawView();
105 }
double G4double
Definition: G4Types.hh:83
const G4VisExtent & GetExtent() const
virtual void SetView()
virtual void DrawView()
G4Scene * GetScene() const
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
const G4Vector3D & GetViewpointDirection() const
void IncrementPan(G4double right, G4double up)
const G4Vector3D & GetUpVector() const
void SetUpVector(const G4Vector3D &upVector)
RotationStyle GetRotationStyle() const
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< T > unit() const

References HepGeom::BasicVector3D< T >::cross(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::DrawView(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyPressed, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyShift, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fMousePressed, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fMousePressedX, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fMousePressedY, G4ViewParameters::freeRotation, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGSceneHandler, G4VViewer::fVP, G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetRotationStyle(), G4VSceneHandler::GetScene(), G4ViewParameters::GetUpVector(), G4ViewParameters::GetViewpointDirection(), G4ViewParameters::IncrementPan(), G4ViewParameters::SetUpVector(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::SetView(), G4ViewParameters::SetViewpointDirection(), and HepGeom::BasicVector3D< T >::unit().

◆ mouse_press()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::mouse_press ( const tools::sg::mouse_down_event &  a_event)
inlinevirtual

◆ mouse_release()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::mouse_release ( const tools::sg::mouse_up_event &  )
inlinevirtual

◆ 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(), G4OpenInventorViewer::KernelVisitDecision(), G4Qt3DViewer::KernelVisitDecision(), G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::KernelVisitDecision(), G4VisManager::NotifyHandlers(), G4OpenGLImmediateViewer::ProcessView(), G4VisCommandViewerRebuild::SetNewValue(), G4OpenInventorViewer::SetPreview(), G4OpenInventorViewer::SetPreviewAndFull(), G4OpenInventorViewer::SetReducedWireFrame(), and G4OpenInventorViewer::UpdateScene().

◆ operator=()

template<class SG_SESSION , class SG_VIEWER >
G4ToolsSGViewer & G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::operator= ( const G4ToolsSGViewer< SG_SESSION, SG_VIEWER > &  )
inlineprotected

Definition at line 154 of file G4ToolsSGViewer.hh.

154{return *this;}

◆ 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(), G4OpenInventorViewer::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

◆ 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
const char * name(G4int ptype)
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

◆ 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()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::SetView ( )
inlinevirtual

create scene graph ///////////////////////////////////

Implements G4VViewer.

Reimplemented in G4ToolsSGQtViewer.

Definition at line 178 of file G4ToolsSGViewer.hh.

178 {
179 //::printf("debug : G4ToolsSGViewer::SetView\n");
180 if(!fSceneHandler.GetScene()) {
181 fSGViewer->set_clear_color(0.3,0.3,0.3,1); //some grey color to signal the user that something is wrong.
182 G4cerr << "G4ToolsSGViewer::SetView : no G4Scene.." << G4endl;
183 return;
184 }
185
189 // Get radius of scene, etc.
190 // Note that this procedure properly takes into account zoom, dolly and pan.
191 const G4Point3D targetPoint
194 if(radius<=0.) radius = 1.;
195 const G4double cameraDistance = fVP.GetCameraDistance (radius);
196 const G4Point3D cameraPosition = targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
197 const G4Normal3D& up = fVP.GetUpVector ();
198 const G4double pnear = fVP.GetNearDistance (cameraDistance, radius);
199 const G4double pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
200 //const G4double right = fVP.GetFrontHalfHeight (pnear, radius);
201 //const G4double left = -right;
202 const G4double top = fVP.GetFrontHalfHeight (pnear, radius);
203 const G4double bottom = -top;
204 // sanity check :
205 tools::vec3f dir(float(targetPoint.x()-cameraPosition.x()),
206 float(targetPoint.y()-cameraPosition.y()),
207 float(targetPoint.z()-cameraPosition.z()));
208 if(!dir.length()) {
209 fSGViewer->set_clear_color(0.3,0.3,0.3,1);
210 G4cerr << "G4ToolsSGViewer::SetView : null size viewer area." << G4endl;
211 return;
212 }
213
217 /*
218 G4cout << "debug : 0002 : radius " << radius << std::endl;
219 G4cout << "debug : cameraDistance : " << cameraDistance << std::endl;
220 G4cout << "debug : fieldHalfAngle : " << fVP.GetFieldHalfAngle() << std::endl;
221 G4cout << "debug : zoomFactor : " << fVP.GetZoomFactor() << std::endl;
222 G4cout << "debug : up : " << up.x() << " " << up.y() << " " << up.z() << std::endl;
223 G4cout << "debug : targetPoint : " << targetPoint.x() << " " << targetPoint.y() << " " << targetPoint.z() << std::endl;
224 G4cout << "debug : cameraPosition : " << cameraPosition.x() << " " << cameraPosition.y() << " " << cameraPosition.z() << std::endl;
225 G4cout << "debug : camera : znear " << pnear << ", zfar " << pfar << std::endl;
226 */
230 // Set projection, then create the tools::sg camera node :
231 tools::sg::base_camera* _camera = nullptr;
232 if (fVP.GetFieldHalfAngle() <= 0.) {
233 //G4cout << "debug : camera : ortho : top " << top << " bottom " << bottom << " top-bottom " << top-bottom << std::endl;
234 if((top-bottom)<=0) {
235 fSGViewer->set_clear_color(0.3,0.3,0.3,1);
236 G4cerr << "G4ToolsSGViewer::SetView : for ortho camera, (top-bottom)<=0." << G4endl;
237 return;
238 }
239 tools::sg::ortho* ortho_camera = new tools::sg::ortho;
240 ortho_camera->height.value(float(top-bottom));
241 _camera = ortho_camera;
242 } else {
243 //G4cout << "debug : camera : perspec : heightAngle " << float(2*fVP.GetFieldHalfAngle()) << std::endl;
244 tools::sg::perspective* perspective_camera = new tools::sg::perspective;
245 perspective_camera->height_angle.value(float(2*fVP.GetFieldHalfAngle()));
246 _camera = perspective_camera;
247 }
248
249 _camera->position.value
250 (tools::vec3f(float(cameraPosition.x()),
251 float(cameraPosition.y()),
252 float(cameraPosition.z())));
253 _camera->znear.value(float(pnear));
254 _camera->zfar.value(float(pfar));
255
256 _camera->look_at(dir,tools::vec3f(up.x(),up.y(),up.z())); //same logic as in G4OpenInventorViewer.
257
258 /*
259 const G4Vector3D& lightDirection = fVP.GetLightpointDirection();
260 G4cout << "debug : lightDirection : " << lightDirection.x() << " " << lightDirection.y() << " " << lightDirection.z() << std::endl;
261 const G4Vector3D& actualLightDirection = fVP.GetActualLightpointDirection();
262 G4cout << "debug : actualLightDirection : " << actualLightDirection.x() << " " << actualLightDirection.y() << " " << actualLightDirection.z() << std::endl;
263 */
264
266
267 {G4Color background = fVP.GetBackgroundColour ();
268 fSGViewer->set_clear_color(float(background.GetRed()),float(background.GetBlue()),float(background.GetBlue()),1);}
269 }
const G4Point3D & GetStandardTargetPoint() const
void CreateSG(tools::sg::base_camera *a_camera, const G4Vector3D &a_light_dir)
G4double GetCameraDistance(G4double radius) const
G4Vector3D & GetActualLightpointDirection()
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
G4double GetFieldHalfAngle() const
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::CreateSG(), G4VViewer::fSceneHandler, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGViewer, G4VViewer::fVP, G4cerr, G4endl, G4ViewParameters::GetActualLightpointDirection(), G4ViewParameters::GetBackgroundColour(), G4Colour::GetBlue(), G4ViewParameters::GetCameraDistance(), G4ViewParameters::GetCurrentTargetPoint(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetFarDistance(), G4ViewParameters::GetFieldHalfAngle(), G4ViewParameters::GetFrontHalfHeight(), G4ViewParameters::GetNearDistance(), G4Colour::GetRed(), G4VSceneHandler::GetScene(), G4Scene::GetStandardTargetPoint(), G4ViewParameters::GetUpVector(), G4ViewParameters::GetViewpointDirection(), HepGeom::BasicVector3D< T >::unit(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::mouse_move(), and G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::wheel_rotate().

◆ SetViewParameters()

void G4VViewer::SetViewParameters ( const G4ViewParameters vp)
inherited

◆ ShowView()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::ShowView ( void  )
inlinevirtual

Reimplemented from G4VViewer.

Definition at line 285 of file G4ToolsSGViewer.hh.

285{FinishView();}

References G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::FinishView().

◆ 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}
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().

◆ wheel_rotate()

template<class SG_SESSION , class SG_VIEWER >
virtual void G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::wheel_rotate ( const tools::sg::wheel_rotate_event &  a_event)
inlinevirtual

Definition at line 106 of file G4ToolsSGViewer.hh.

106 {
107 const G4double angleY = a_event.angle();
108 if (fVP.GetFieldHalfAngle() == 0.) { // Orthographic projection
109 const G4double scale = 500; // Empirically chosen
110 fVP.MultiplyZoomFactor(1.+angleY/scale);
111 } else { // Perspective projection
112 const G4double scale = fVP.GetFieldHalfAngle()/(10.*CLHEP::deg); // Empirical
113 fVP.SetDolly(fVP.GetDolly()+angleY/scale);
114 }
115 SetView();
116 DrawView();
117 }
void SetDolly(G4double dolly)
void MultiplyZoomFactor(G4double zoomFactorMultiplier)
G4double GetDolly() const
static constexpr double deg

References CLHEP::deg, G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::DrawView(), G4VViewer::fVP, G4ViewParameters::GetDolly(), G4ViewParameters::GetFieldHalfAngle(), G4ViewParameters::MultiplyZoomFactor(), G4ViewParameters::SetDolly(), and G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::SetView().

Field Documentation

◆ f_gl2ps_mgr

template<class SG_SESSION , class SG_VIEWER >
tools::sg::gl2ps_manager G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::f_gl2ps_mgr
protected

◆ f_zb_mgr

template<class SG_SESSION , class SG_VIEWER >
tools::sg::zb_manager G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::f_zb_mgr
protected

◆ fDefaultVP

G4ViewParameters G4VViewer::fDefaultVP
protectedinherited

◆ fKeyPressed

template<class SG_SESSION , class SG_VIEWER >
G4bool G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyPressed
protected

◆ fKeyShift

template<class SG_SESSION , class SG_VIEWER >
G4bool G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fKeyShift
protected

◆ fLastVP

template<class SG_SESSION , class SG_VIEWER >
G4ViewParameters G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fLastVP
protected

◆ fMousePressed

template<class SG_SESSION , class SG_VIEWER >
G4bool G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fMousePressed
protected

◆ fMousePressedX

template<class SG_SESSION , class SG_VIEWER >
G4double G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fMousePressedX
protected

◆ fMousePressedY

template<class SG_SESSION , class SG_VIEWER >
G4double G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fMousePressedY
protected

◆ fName

G4String G4VViewer::fName
protectedinherited

◆ fNeedKernelVisit

G4bool G4VViewer::fNeedKernelVisit
protectedinherited

◆ fSceneHandler

G4VSceneHandler& G4VViewer::fSceneHandler
protectedinherited

◆ fSGSceneHandler

template<class SG_SESSION , class SG_VIEWER >
G4ToolsSGSceneHandler& G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGSceneHandler
protected

◆ fSGSession

template<class SG_SESSION , class SG_VIEWER >
SG_SESSION& G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGSession
protected

◆ fSGViewer

template<class SG_SESSION , class SG_VIEWER >
SG_VIEWER* G4ToolsSGViewer< SG_SESSION, SG_VIEWER >::fSGViewer
protected

◆ fShortName

G4String G4VViewer::fShortName
protectedinherited

◆ 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(), G4OpenInventorViewer::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(), G4OpenInventorViewer::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::G4OpenInventorViewer(), G4VtkViewer::G4VtkViewer(), G4VViewer::G4VViewer(), G4OpenGLQtViewer::G4wheelEvent(), G4OpenGLViewer::getSceneDepth(), G4OpenGLViewer::getSceneFarWidth(), G4OpenGLViewer::getSceneNearWidth(), G4OpenGLXmViewer::GetXmConnection(), G4OpenInventorViewer::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(), G4OpenInventorViewer::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 file: