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

#include <G4OpenGLStoredViewer.hh>

Inheritance diagram for G4OpenGLStoredViewer:
G4OpenGLViewer G4VViewer G4OpenGLStoredQtViewer G4OpenGLStoredWin32Viewer G4OpenGLStoredXViewer G4OpenGLStoredXmViewer

Public Member Functions

void ClearView ()
 
void ClearViewWithoutFlush ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
virtual void DrawView ()=0
 
virtual bool exportImage (std::string name="", int width=-1, int height=-1)
 
virtual void FinishView ()
 
 G4OpenGLStoredViewer (G4OpenGLStoredSceneHandler &scene)
 
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 ()
 
void NeedKernelVisit ()
 
void ProcessView ()
 
void RefreshView ()
 
void SetDefaultViewParameters (const G4ViewParameters &vp)
 
bool setExportImageFormat (std::string format, bool quiet=false)
 
void SetName (const G4String &)
 
void SetNeedKernelVisit (G4bool need)
 
void SetViewParameters (const G4ViewParameters &vp)
 
virtual void ShowView ()
 
virtual ~G4OpenGLStoredViewer ()
 

Protected Member Functions

void addExportImageFormat (std::string format)
 
void AddPrimitiveForASingleFrame (const G4Circle &circle)
 
void AddPrimitiveForASingleFrame (const G4Text &text)
 
void ChangeLineWidth (G4double width)
 
void ChangePointSize (G4double size)
 
virtual G4bool CompareForKernelVisit (G4ViewParameters &)
 
virtual void CreateFontLists ()
 
virtual void DisplayTimePOColourModification (G4Colour &, size_t)
 
void DrawDisplayLists ()
 
virtual void DrawText (const G4Text &)
 
void g4GlFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
 
void g4GlOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
 
void g4GluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
 
void g4GluPickMatrix (GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4])
 
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails (GLdouble x, GLdouble y)
 
std::string getRealPrintFilename ()
 
GLdouble getSceneDepth ()
 
GLdouble getSceneFarWidth ()
 
GLdouble getSceneNearWidth ()
 
unsigned int getWinHeight () const
 
unsigned int getWinWidth () const
 
void HaloingFirstPass ()
 
void HaloingSecondPass ()
 
void HLRFirstPass ()
 
void HLRSecondPass ()
 
void HLRThirdPass ()
 
void InitializeGLView ()
 
G4bool isFramebufferReady ()
 
G4bool isGl2psWriting ()
 
void KernelVisitDecision ()
 
virtual G4String Pick (GLdouble x, GLdouble y)
 
virtual G4bool POSelected (size_t)
 
void ResetView ()
 
void ResizeGLView ()
 
void ResizeWindow (unsigned int, unsigned int)
 
void rotateScene (G4double dx, G4double dy)
 
void rotateSceneToggle (G4double dx, G4double dy)
 
bool setExportFilename (G4String name, G4bool inc=true)
 
void setExportSize (G4int, G4int)
 
void SetTouchable (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
 
void SetView ()
 
G4bool sizeHasChanged ()
 
virtual G4bool TOSelected (size_t)
 
void TouchableSetColour (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
 
void TouchableSetVisibility (const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
 

Protected Attributes

G4bool antialiasing_enabled
 
G4Colour background
 
std::string fDefaultExportImageFormat
 
G4ViewParameters fDefaultVP
 
G4bool fDepthTestEnable
 
int fExportFilenameIndex
 
std::string fExportImageFormat
 
std::vector< std::string > fExportImageFormatVector
 
G4OpenGLStoredSceneHandlerfG4OpenGLStoredSceneHandler
 
G4OpenGL2PSActionfGL2PSAction
 
G4ViewParameters fLastVP
 
G4String fName
 
G4bool fNeedKernelVisit
 
G4Colour fOldDisplayListColor
 
G4OpenGLSceneHandlerfOpenGLSceneHandler
 
G4double fPan_sens
 
G4bool fPrintColour
 
G4int fPrintSizeX
 
G4int fPrintSizeY
 
G4double fRot_sens
 
G4VSceneHandlerfSceneHandler
 
G4String fShortName
 
G4bool fVectoredPs
 
G4int fViewId
 
G4ViewParameters fVP
 
unsigned int fWinSize_x
 
unsigned int fWinSize_y
 
G4bool haloing_enabled
 
G4bool transparency_enabled
 

Private Member Functions

G4int getRealExportHeight ()
 
G4int getRealExportWidth ()
 
GLubyte * grabPixels (int inColor, unsigned int width, unsigned int height)
 
bool printGl2PS ()
 
bool printNonVectoredEPS ()
 
bool printVectoredEPS ()
 
void rotateSceneInViewDirection (G4double dx, G4double dy)
 
void rotateSceneThetaPhi (G4double dx, G4double dy)
 

Private Attributes

G4String fDefaultExportFilename
 
G4String fExportFilename
 
int fGl2psDefaultLineWith
 
int fGl2psDefaultPointSize
 
bool fGlViewInitialized
 
bool fIsGettingPickInfos
 
G4float fPointSize
 
G4bool fSizeHasChanged
 

Detailed Description

Definition at line 44 of file G4OpenGLStoredViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenGLStoredViewer()

G4OpenGLStoredViewer::G4OpenGLStoredViewer ( G4OpenGLStoredSceneHandler scene)

Definition at line 44 of file G4OpenGLStoredViewer.cc.

45 :
46G4VViewer (sceneHandler, -1),
47G4OpenGLViewer (sceneHandler),
48fG4OpenGLStoredSceneHandler (sceneHandler),
50{
51 fLastVP = fDefaultVP; // Update in sub-class after KernelVisitDecision
52}
G4OpenGLStoredSceneHandler & fG4OpenGLStoredSceneHandler
G4OpenGLViewer(G4OpenGLSceneHandler &scene)
G4ViewParameters fDefaultVP
Definition: G4VViewer.hh:220
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
Definition: G4VViewer.cc:46

References G4VViewer::fDefaultVP, and fLastVP.

◆ ~G4OpenGLStoredViewer()

G4OpenGLStoredViewer::~G4OpenGLStoredViewer ( )
virtual

Definition at line 54 of file G4OpenGLStoredViewer.cc.

54{}

Member Function Documentation

◆ addExportImageFormat()

void G4OpenGLViewer::addExportImageFormat ( std::string  format)
protectedinherited

Definition at line 1288 of file G4OpenGLViewer.cc.

1288 {
1289 fExportImageFormatVector.push_back(format);
1290}
std::vector< std::string > fExportImageFormatVector

References G4OpenGLViewer::fExportImageFormatVector.

Referenced by G4OpenGLQtViewer::G4OpenGLQtViewer(), and G4OpenGLViewer::G4OpenGLViewer().

◆ AddPrimitiveForASingleFrame() [1/2]

void G4OpenGLStoredViewer::AddPrimitiveForASingleFrame ( const G4Circle circle)
protected

Definition at line 485 of file G4OpenGLStoredViewer.cc.

486{
487 // We don't want this to get into a display list or a TODL or a PODL so
488 // use the fMemoryForDisplayLists flag.
491 fG4OpenGLStoredSceneHandler.G4OpenGLStoredSceneHandler::AddPrimitive(circle);
492 fG4OpenGLStoredSceneHandler.fMemoryForDisplayLists = memoryForDisplayListsKeep;
493}
bool G4bool
Definition: G4Types.hh:86

References fG4OpenGLStoredSceneHandler, and G4OpenGLStoredSceneHandler::fMemoryForDisplayLists.

◆ AddPrimitiveForASingleFrame() [2/2]

void G4OpenGLStoredViewer::AddPrimitiveForASingleFrame ( const G4Text text)
protected

Definition at line 475 of file G4OpenGLStoredViewer.cc.

476{
477 // We don't want this to get into a display list or a TODL or a PODL so
478 // use the fMemoryForDisplayLists flag.
481 fG4OpenGLStoredSceneHandler.G4OpenGLStoredSceneHandler::AddPrimitive(text);
482 fG4OpenGLStoredSceneHandler.fMemoryForDisplayLists = memoryForDisplayListsKeep;
483}

References fG4OpenGLStoredSceneHandler, and G4OpenGLStoredSceneHandler::fMemoryForDisplayLists.

Referenced by DrawDisplayLists().

◆ ChangeLineWidth()

void G4OpenGLViewer::ChangeLineWidth ( G4double  width)
protectedinherited

Change LineSize on gl2ps if needed

Definition at line 810 of file G4OpenGLViewer.cc.

810 {
811
812 if (isGl2psWriting()) {
813 fGL2PSAction->setLineWidth(int(width));
814 } else {
815 glLineWidth (width);
816 }
817}
void setLineWidth(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
G4OpenGL2PSAction * fGL2PSAction
G4bool isGl2psWriting()

References G4OpenGLViewer::fGL2PSAction, G4OpenGLViewer::isGl2psWriting(), and G4OpenGL2PSAction::setLineWidth().

Referenced by G4OpenGLSceneHandler::AddPrimitive(), G4OpenGLViewer::HaloingFirstPass(), and G4OpenGLViewer::HaloingSecondPass().

◆ ChangePointSize()

void G4OpenGLViewer::ChangePointSize ( G4double  size)
protectedinherited

Change PointSize on gl2ps if needed

Definition at line 798 of file G4OpenGLViewer.cc.

798 {
799
800 if (isGl2psWriting()) {
801 fGL2PSAction->setPointSize(int(size));
802 } else {
803 glPointSize (size);
804 }
805}
void setPointSize(int)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

References G4OpenGLViewer::fGL2PSAction, G4OpenGLViewer::isGl2psWriting(), and G4OpenGL2PSAction::setPointSize().

Referenced by G4OpenGLSceneHandler::AddPrimitive().

◆ ClearView()

void G4OpenGLViewer::ClearView ( void  )
virtualinherited

◆ ClearViewWithoutFlush()

void G4OpenGLViewer::ClearViewWithoutFlush ( )
inherited

Definition at line 214 of file G4OpenGLViewer.cc.

214 {
215 // Ready for clear ?
216 // See : http://lists.apple.com/archives/mac-opengl/2012/Jul/msg00038.html
217 if(!isFramebufferReady()) {
218 return;
219 }
220
221 glClearColor (background.GetRed(),
224 1.);
225 glClearDepth (1.0);
226 //Below line does not compile with Mesa includes.
227 //glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
228 glClear (GL_COLOR_BUFFER_BIT);
229 glClear (GL_DEPTH_BUFFER_BIT);
230 glClear (GL_STENCIL_BUFFER_BIT);
231}
G4double GetBlue() const
Definition: G4Colour.hh:154
G4double GetRed() const
Definition: G4Colour.hh:152
G4double GetGreen() const
Definition: G4Colour.hh:153

References G4OpenGLViewer::background, G4Colour::GetBlue(), G4Colour::GetGreen(), G4Colour::GetRed(), and G4OpenGLViewer::isFramebufferReady().

Referenced by G4OpenGLViewer::ClearView().

◆ CompareForKernelVisit()

G4bool G4OpenGLStoredViewer::CompareForKernelVisit ( G4ViewParameters lastVP)
protectedvirtual

Reimplemented in G4OpenGLStoredQtViewer.

Definition at line 67 of file G4OpenGLStoredViewer.cc.

67 {
68
69 if (
70 (lastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
72 (lastVP.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) ||
73 (lastVP.IsCulling () != fVP.IsCulling ()) ||
74 (lastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
75 (lastVP.IsDensityCulling () != fVP.IsDensityCulling ()) ||
76 (lastVP.IsCullingCovered () != fVP.IsCullingCovered ()) ||
77 (lastVP.GetCBDAlgorithmNumber() !=
79 // Note: Section and Cutaway can reveal back-facing faces. If
80 // backface culling is implemented, the image can look strange because
81 // the back-facing faces are not there. For the moment, we have disabled
82 // (commented out) backface culling (it seems not to affect performance -
83 // in fact, performance seems to improve), so there is no problem.
84 (lastVP.IsSection () != fVP.IsSection ()) ||
85 // Section (DCUT) is NOT implemented locally so we need to visit the kernel.
86 // (lastVP.IsCutaway () != fVP.IsCutaway ()) ||
87 // Cutaways are implemented locally so we do not need to visit the kernel.
88 (lastVP.IsExplode () != fVP.IsExplode ()) ||
89 (lastVP.GetNoOfSides () != fVP.GetNoOfSides ()) ||
92 (lastVP.IsMarkerNotHidden () != fVP.IsMarkerNotHidden ()) ||
98 (lastVP.IsPicking () != fVP.IsPicking ()) ||
99 (lastVP.GetVisAttributesModifiers() !=
101 (lastVP.IsSpecialMeshRendering() !=
103 )
104 return true;
105
106 if (lastVP.IsDensityCulling () &&
107 (lastVP.GetVisibleDensity () != fVP.GetVisibleDensity ()))
108 return true;
109
110// /**************************************************************
111// If section (DCUT) is implemented locally, comment this out.
112 if (lastVP.IsSection () &&
113 (lastVP.GetSectionPlane () != fVP.GetSectionPlane ()))
114 return true;
115// ***************************************************************/
116
117 /**************************************************************
118 If cutaways are implemented locally, comment this out.
119 if (lastVP.IsCutaway ()) {
120 if (lastVP.GetCutawayPlanes ().size () !=
121 fVP.GetCutawayPlanes ().size ()) return true;
122 for (size_t i = 0; i < lastVP.GetCutawayPlanes().size(); ++i)
123 if (lastVP.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i])
124 return true;
125 }
126 ***************************************************************/
127
128 if (lastVP.GetCBDAlgorithmNumber() > 0) {
129 if (lastVP.GetCBDParameters().size() != fVP.GetCBDParameters().size()) return true;
130 else if (lastVP.GetCBDParameters() != fVP.GetCBDParameters()) return true;
131 }
132
133 if (lastVP.IsExplode () &&
134 (lastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
135 return true;
136
137 if (lastVP.IsSpecialMeshRendering() &&
139 return true;
140
141 // Time window parameters operate on the existing database so no need
142 // to rebuild even if they change.
143
144 return false;
145}
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
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
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::GetDefaultTextVisAttributes(), G4ViewParameters::GetDefaultVisAttributes(), G4ViewParameters::GetDrawingStyle(), G4ViewParameters::GetExplodeFactor(), G4ViewParameters::GetGlobalLineWidthScale(), G4ViewParameters::GetGlobalMarkerScale(), G4ViewParameters::GetNoOfSides(), G4ViewParameters::GetNumberOfCloudPoints(), G4ViewParameters::GetSectionPlane(), G4ViewParameters::GetSpecialMeshVolumes(), G4ViewParameters::GetVisAttributesModifiers(), G4ViewParameters::GetVisibleDensity(), G4ViewParameters::IsAuxEdgeVisible(), G4ViewParameters::IsCulling(), G4ViewParameters::IsCullingCovered(), G4ViewParameters::IsCullingInvisible(), 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().

◆ CreateFontLists()

virtual void G4OpenGLViewer::CreateFontLists ( )
inlineprotectedvirtualinherited

◆ DisplayTimePOColourModification()

virtual void G4OpenGLStoredViewer::DisplayTimePOColourModification ( G4Colour ,
size_t   
)
inlineprotectedvirtual

Reimplemented in G4OpenGLStoredQtViewer.

Definition at line 56 of file G4OpenGLStoredViewer.hh.

57{}

Referenced by DrawDisplayLists().

◆ DrawDisplayLists()

void G4OpenGLStoredViewer::DrawDisplayLists ( )
protected

Definition at line 147 of file G4OpenGLStoredViewer.cc.

147 {
148
149 // We moved these from G4OpenGLViewer to G4ViewParamaters. To avoid
150 // editing many lines below we introduce these convenient aliases.
151#define CONVENIENT_DOUBLE_ALIAS(q) const G4double& f##q = fVP.Get##q();
152#define CONVENIENT_BOOL_ALIAS(q) const G4bool& f##q = fVP.Is##q();
153 CONVENIENT_DOUBLE_ALIAS(StartTime)
155 CONVENIENT_DOUBLE_ALIAS(FadeFactor)
156 CONVENIENT_BOOL_ALIAS(DisplayHeadTime)
157 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeX)
158 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeY)
159 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeSize)
160 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeRed)
161 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeGreen)
162 CONVENIENT_DOUBLE_ALIAS(DisplayHeadTimeBlue)
163 CONVENIENT_BOOL_ALIAS(DisplayLightFront)
164 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontX)
165 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontY)
166 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontZ)
167 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontT)
168 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontRed)
169 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontGreen)
170 CONVENIENT_DOUBLE_ALIAS(DisplayLightFrontBlue)
171
172 const G4Planes& cutaways = fVP.GetCutawayPlanes();
173 G4bool cutawayUnion = fVP.IsCutaway() &&
175 const size_t nCutaways = cutawayUnion? cutaways.size(): 1;
176 G4int iPass = 1;
177 G4bool secondPassForTransparencyRequested = false;
178 G4bool thirdPassForNonHiddenMarkersRequested = false;
179 fDepthTestEnable = true;
180 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);
181 do {
182 for (size_t iCutaway = 0; iCutaway < nCutaways; ++iCutaway) {
183
184 if (cutawayUnion) {
185 double a[4];
186 a[0] = cutaways[iCutaway].a();
187 a[1] = cutaways[iCutaway].b();
188 a[2] = cutaways[iCutaway].c();
189 a[3] = cutaways[iCutaway].d();
190 glClipPlane (GL_CLIP_PLANE2, a);
191 glEnable (GL_CLIP_PLANE2);
192 }
193
194 G4bool isPicking = fVP.IsPicking();
195
196 for (size_t iPO = 0;
197 iPO < fG4OpenGLStoredSceneHandler.fPOList.size(); ++iPO) {
198 if (POSelected(iPO)) {
201 G4Colour c = po.fColour;
203 const G4bool isTransparent = c.GetAlpha() < 1.;
204 if ( iPass == 1) {
205 if (isTransparent && transparency_enabled) {
206 secondPassForTransparencyRequested = true;
207 continue;
208 }
210 thirdPassForNonHiddenMarkersRequested = true;
211 continue;
212 }
213 } else if (iPass == 2) { // Second pass for transparency.
214 if (!isTransparent) {
215 continue;
216 }
217 } else { // Third pass for non-hidden markers
218 if (!po.fMarkerOrPolyline) {
219 continue;
220 }
221 }
222 if (isPicking) glLoadName(po.fPickName);
224 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
225 } else {
226 glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
227 }
229 if (fDepthTestEnable !=false) {
230 glDisable (GL_DEPTH_TEST);
231 fDepthTestEnable = false;
232 }
233 } else {
234 if (fDepthTestEnable !=true) {
235 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);
236 fDepthTestEnable = true;
237 }
238 }
239 if (po.fpG4TextPlus) {
240 if (po.fpG4TextPlus->fProcessing2D) {
241 glMatrixMode (GL_PROJECTION);
242 glPushMatrix();
243 glLoadIdentity();
244 g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
245 glMatrixMode (GL_MODELVIEW);
246 glPushMatrix();
247 glLoadIdentity();
249 glMultMatrixd (oglt.GetGLMatrix ());
250 // This text is from a PODL. We don't want to create a new PODL.
252 } else {
253 glPushMatrix();
255 glMultMatrixd (oglt.GetGLMatrix ());
256 // This text is from a PODL. We don't want to create a new PODL.
258 glPopMatrix();
259 }
260
261 if (po.fpG4TextPlus->fProcessing2D) {
262 glMatrixMode (GL_PROJECTION);
263 glPopMatrix();
264 glMatrixMode (GL_MODELVIEW);
265 glPopMatrix();
266 }
267 } else {
268 glPushMatrix();
270 glMultMatrixd (oglt.GetGLMatrix ());
271 glCallList (po.fDisplayListId);
272 glPopMatrix();
273 }
274 }
275 }
276
277 G4Transform3D lastMatrixTransform;
278 G4bool first = true;
279
280 for (size_t iTO = 0;
281 iTO < fG4OpenGLStoredSceneHandler.fTOList.size(); ++iTO) {
282 if (TOSelected(iTO)) {
285 const G4Colour& c = to.fColour;
286 const G4bool isTransparent = c.GetAlpha() < 1.;
287 if ( iPass == 1) {
288 if (isTransparent && transparency_enabled) {
289 secondPassForTransparencyRequested = true;
290 continue;
291 }
293 thirdPassForNonHiddenMarkersRequested = true;
294 continue;
295 }
296 } else if (iPass == 2) { // Second pass for transparency.
297 if (!isTransparent) {
298 continue;
299 }
300 } else { // Third pass for non-hidden markers
301 if (!to.fMarkerOrPolyline) {
302 continue;
303 }
304 }
306 if (fDepthTestEnable !=false) {
307 glDisable (GL_DEPTH_TEST);
308 fDepthTestEnable = false;
309 }
310 } else {
311 if (fDepthTestEnable !=true) {
312 glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);
313 fDepthTestEnable = true;
314 }
315 }
316 if (to.fEndTime >= fStartTime && to.fStartTime <= fEndTime) {
317 if (fVP.IsPicking()) glLoadName(to.fPickName);
318 if (to.fpG4TextPlus) {
319 if (to.fpG4TextPlus->fProcessing2D) {
320 glMatrixMode (GL_PROJECTION);
321 glPushMatrix();
322 glLoadIdentity();
323 g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
324 glMatrixMode (GL_MODELVIEW);
325 glPushMatrix();
326 glLoadIdentity();
327 }
329 glMultMatrixd (oglt.GetGLMatrix ());
330 // This text is from a TODL. We don't want to create a new TODL.
332 if (to.fpG4TextPlus->fProcessing2D) {
333 glMatrixMode (GL_PROJECTION);
334 glPopMatrix();
335 glMatrixMode (GL_MODELVIEW);
336 glPopMatrix();
337 }
338 } else {
339 if (to.fTransform != lastMatrixTransform) {
340 if (! first) {
341 glPopMatrix();
342 }
343 first = false;
344 glPushMatrix();
346 glMultMatrixd (oglt.GetGLMatrix ());
347 }
348 const G4Colour& cc = to.fColour;
349 if (fFadeFactor > 0. && to.fEndTime < fEndTime) {
350 // Brightness scaling factor
351 G4double bsf = 1. - fFadeFactor *
352 ((fEndTime - to.fEndTime) / (fEndTime - fStartTime));
353 const G4Colour& bg = fVP.GetBackgroundColour();
355 glColor4d
356 (bsf * cc.GetRed() + (1. - bsf) * bg.GetRed(),
357 bsf * cc.GetGreen() + (1. - bsf) * bg.GetGreen(),
358 bsf * cc.GetBlue() + (1. - bsf) * bg.GetBlue(),
359 bsf * cc.GetAlpha() + (1. - bsf) * bg.GetAlpha());
360 } else {
361 glColor3d
362 (bsf * cc.GetRed() + (1. - bsf) * bg.GetRed(),
363 bsf * cc.GetGreen() + (1. - bsf) * bg.GetGreen(),
364 bsf * cc.GetBlue() + (1. - bsf) * bg.GetBlue());
365 }
366 } else {
368 glColor4d(cc.GetRed(),cc.GetGreen(),cc.GetBlue(),cc.GetAlpha());
369 } else {
370 glColor3d(cc.GetRed(),cc.GetGreen(),cc.GetBlue());
371 }
372 }
373 glCallList (to.fDisplayListId);
374 }
375 if (to.fTransform != lastMatrixTransform) {
376 lastMatrixTransform = to.fTransform;
377 }
378 }
379 }
380 }
381 if (! first) {
382 glPopMatrix();
383 }
384
385 if (cutawayUnion) glDisable (GL_CLIP_PLANE2);
386 } // iCutaway
387
388 if (iPass == 2) secondPassForTransparencyRequested = false; // Done.
389 if (iPass == 3) thirdPassForNonHiddenMarkersRequested = false; // Done.
390
391 if (secondPassForTransparencyRequested) iPass = 2;
392 else if (thirdPassForNonHiddenMarkersRequested) iPass = 3;
393 else break;
394
395 } while (true);
396
397 // Display time at "head" of time range, which is fEndTime...
398 if (fDisplayHeadTime && fEndTime < G4VisAttributes::fVeryLongTime) {
399 glMatrixMode (GL_PROJECTION);
400 glPushMatrix();
401 glLoadIdentity();
402 g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
403 glMatrixMode (GL_MODELVIEW);
404 glPushMatrix();
405 glLoadIdentity();
406 G4Text headTimeText(G4BestUnit(fEndTime,"Time"),
407 G4Point3D(fDisplayHeadTimeX, fDisplayHeadTimeY, 0.));
408 headTimeText.SetScreenSize(fDisplayHeadTimeSize);
410 (fDisplayHeadTimeRed,
411 fDisplayHeadTimeGreen,
412 fDisplayHeadTimeBlue));
413 headTimeText.SetVisAttributes(&visAtts);
414 AddPrimitiveForASingleFrame(headTimeText);
415 glMatrixMode (GL_PROJECTION);
416 glPopMatrix();
417 glMatrixMode (GL_MODELVIEW);
418 glPopMatrix();
419 }
420
421 // Display light front...
422 if (fDisplayLightFront && fEndTime < G4VisAttributes::fVeryLongTime) {
423 G4double lightFrontRadius = (fEndTime - fDisplayLightFrontT) * c_light;
424 if (lightFrontRadius > 0.) {
425 G4Point3D lightFrontCentre(fDisplayLightFrontX, fDisplayLightFrontY, fDisplayLightFrontZ);
426 G4Point3D circleCentre = lightFrontCentre;
427 G4double circleRadius = lightFrontRadius;
428 if (fVP.GetFieldHalfAngle() > 0.) {
429 // Perspective view. Find horizon centre and radius...
433 if(sceneRadius <= 0.) sceneRadius = 1.;
434 G4double cameraDistance = fVP.GetCameraDistance(sceneRadius);
435 G4Point3D cameraPosition = targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
436 G4Vector3D lightFrontToCameraDirection = cameraPosition - lightFrontCentre;
437 G4double lightFrontCentreDistance = lightFrontToCameraDirection.mag();
438 /*
439 G4cout << "cameraPosition: " << cameraPosition
440 << ", lightFrontCentre: " << lightFrontCentre
441 << ", lightFrontRadius: " << lightFrontRadius
442 << ", lightFrontCentreDistance: " << lightFrontCentreDistance
443 << ", dot: " << lightFrontToCameraDirection * fVP.GetViewpointDirection()
444 << G4endl;
445 */
446 if (lightFrontToCameraDirection * fVP.GetViewpointDirection() > 0. && lightFrontRadius < lightFrontCentreDistance) {
447 // Light front in front of camera...
448 G4double sineHorizonAngle = lightFrontRadius / lightFrontCentreDistance;
449 circleCentre = lightFrontCentre + (lightFrontRadius * sineHorizonAngle) * lightFrontToCameraDirection.unit();
450 circleRadius = lightFrontRadius * std::sqrt(1. - std::pow(sineHorizonAngle, 2));
451 /*
452 G4cout << "sineHorizonAngle: " << sineHorizonAngle
453 << ", circleCentre: " << circleCentre
454 << ", circleRadius: " << circleRadius
455 << G4endl;
456 */
457 } else {
458 circleRadius = -1.;
459 }
460 }
461 if (circleRadius > 0.) {
462 G4Circle lightFront(circleCentre);
463 lightFront.SetWorldRadius(circleRadius);
465 (fDisplayLightFrontRed,
466 fDisplayLightFrontGreen,
467 fDisplayLightFrontBlue));
468 lightFront.SetVisAttributes(visAtts);
469 AddPrimitiveForASingleFrame(lightFront);
470 }
471 }
472 }
473}
#define CONVENIENT_BOOL_ALIAS(q)
#define CONVENIENT_DOUBLE_ALIAS(q)
#define G4OPENGL_FLT_BIG
Definition: G4OpenGL.hh:89
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:34
#define G4BestUnit(a, b)
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
std::vector< G4Plane3D > G4Planes
G4double GetAlpha() const
Definition: G4Colour.hh:155
virtual G4bool TOSelected(size_t)
virtual G4bool POSelected(size_t)
virtual void DisplayTimePOColourModification(G4Colour &, size_t)
void AddPrimitiveForASingleFrame(const G4Text &text)
G4bool transparency_enabled
void g4GlOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
Definition: G4Text.hh:72
G4Scene * GetScene() const
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:215
CutawayMode GetCutawayMode() const
G4double GetCameraDistance(G4double radius) const
G4bool IsCutaway() const
const G4Vector3D & GetViewpointDirection() const
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFieldHalfAngle() const
const G4Planes & GetCutawayPlanes() const
static constexpr G4double fVeryLongTime
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
BasicVector3D< T > unit() const
float c_light
Definition: hepunit.py:256

References AddPrimitiveForASingleFrame(), source.hepunit::c_light, CONVENIENT_BOOL_ALIAS, CONVENIENT_DOUBLE_ALIAS, G4ViewParameters::cutawayUnion, DisplayTimePOColourModification(), G4OpenGLStoredSceneHandler::PO::fColour, G4OpenGLStoredSceneHandler::TO::fColour, fDepthTestEnable, G4OpenGLStoredSceneHandler::PO::fDisplayListId, G4OpenGLStoredSceneHandler::TO::fDisplayListId, G4OpenGLStoredSceneHandler::TO::fEndTime, fG4OpenGLStoredSceneHandler, G4OpenGLStoredSceneHandler::G4TextPlus::fG4Text, G4OpenGLStoredSceneHandler::PO::fMarkerOrPolyline, G4OpenGLStoredSceneHandler::TO::fMarkerOrPolyline, G4OpenGLStoredSceneHandler::PO::fpG4TextPlus, G4OpenGLStoredSceneHandler::TO::fpG4TextPlus, G4OpenGLStoredSceneHandler::PO::fPickName, G4OpenGLStoredSceneHandler::TO::fPickName, G4OpenGLStoredSceneHandler::fPOList, G4OpenGLStoredSceneHandler::G4TextPlus::fProcessing2D, G4VViewer::fSceneHandler, G4OpenGLStoredSceneHandler::TO::fStartTime, G4OpenGLStoredSceneHandler::fTOList, G4OpenGLStoredSceneHandler::PO::fTransform, G4OpenGLStoredSceneHandler::TO::fTransform, G4VisAttributes::fVeryLongTime, G4VViewer::fVP, G4BestUnit, G4OpenGLViewer::g4GlOrtho(), G4OPENGL_FLT_BIG, G4Colour::GetAlpha(), G4ViewParameters::GetBackgroundColour(), G4Colour::GetBlue(), G4ViewParameters::GetCameraDistance(), G4ViewParameters::GetCurrentTargetPoint(), G4ViewParameters::GetCutawayMode(), G4ViewParameters::GetCutawayPlanes(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetFieldHalfAngle(), G4OpenGLTransform3D::GetGLMatrix(), G4Colour::GetGreen(), G4Colour::GetRed(), G4VSceneHandler::GetScene(), G4Scene::GetStandardTargetPoint(), G4ViewParameters::GetViewpointDirection(), G4ViewParameters::IsCutaway(), G4ViewParameters::IsMarkerNotHidden(), G4ViewParameters::IsPicking(), HepGeom::BasicVector3D< T >::mag(), POSelected(), G4VMarker::SetScreenSize(), G4Visible::SetVisAttributes(), G4VMarker::SetWorldRadius(), TOSelected(), G4OpenGLViewer::transparency_enabled, and HepGeom::BasicVector3D< T >::unit().

Referenced by G4OpenGLStoredQtViewer::ComputeView(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), and G4OpenGLStoredXViewer::DrawView().

◆ DrawText()

void G4OpenGLViewer::DrawText ( const G4Text g4text)
protectedvirtualinherited

Reimplemented in G4OpenGLQtViewer, and G4OpenGLXViewer.

Definition at line 758 of file G4OpenGLViewer.cc.

759{
760 // gl2ps or GL window ?
761 if (isGl2psWriting()) {
762
764 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
765 G4Point3D position = g4text.GetPosition();
766
767 G4String textString = g4text.GetText();
768
769 glRasterPos3d(position.x(),position.y(),position.z());
770 GLint align = GL2PS_TEXT_B;
771
772 switch (g4text.GetLayout()) {
773 case G4Text::left: align = GL2PS_TEXT_BL; break;
774 case G4Text::centre: align = GL2PS_TEXT_B; break;
775 case G4Text::right: align = GL2PS_TEXT_BR;
776 }
777
778 gl2psTextOpt(textString.c_str(),"Times-Roman",GLshort(size),align,0);
779
780 } else {
781
782 static G4int callCount = 0;
783 ++callCount;
784 //if (callCount <= 10 || callCount%100 == 0) {
785 if (callCount <= 1) {
786 G4cout <<
787 "G4OpenGLViewer::DrawText: Not implemented for \""
788 << fName <<
789 "\"\n Called with "
790 << g4text
791 << G4endl;
792 }
793 }
794}
#define gl2psTextOpt
Definition: Geant4_gl2ps.h:44
Layout GetLayout() const
G4String GetText() const
@ centre
Definition: G4Text.hh:76
@ right
Definition: G4Text.hh:76
@ left
Definition: G4Text.hh:76
G4Point3D GetPosition() const
G4double GetMarkerSize(const G4VMarker &, MarkerSizeType &)
G4String fName
Definition: G4VViewer.hh:217
#define GL2PS_TEXT_BL
Definition: gl2ps.h:198
#define GL2PS_TEXT_BR
Definition: gl2ps.h:199
#define GL2PS_TEXT_B
Definition: gl2ps.h:197

References G4Text::centre, G4VViewer::fName, G4VViewer::fSceneHandler, G4cout, G4endl, G4Text::GetLayout(), G4VSceneHandler::GetMarkerSize(), G4VMarker::GetPosition(), G4Text::GetText(), GL2PS_TEXT_B, GL2PS_TEXT_BL, GL2PS_TEXT_BR, gl2psTextOpt, G4OpenGLViewer::isGl2psWriting(), G4Text::left, and G4Text::right.

Referenced by G4OpenGLSceneHandler::AddPrimitive(), G4OpenGLQtViewer::DrawText(), and G4OpenGLXViewer::DrawText().

◆ DrawView()

virtual void G4VViewer::DrawView ( )
pure virtualinherited

◆ exportImage()

bool G4OpenGLViewer::exportImage ( std::string  name = "",
int  width = -1,
int  height = -1 
)
virtualinherited

Export image with the given name with width and height Several cases : If name is "", filename will have the default value If name is "toto.png", set the name to "toto" and the format to "png". No incremented suffix is added. If name is "toto", set the name to "toto" and the format to default (or current format if specify). Will also add an incremented suffix at the end of the file

Reimplemented in G4OpenGLQtViewer.

Definition at line 827 of file G4OpenGLViewer.cc.

827 {
828
829 if (! setExportFilename(name)) {
830 return false;
831 }
832
833 if ((width != -1) && (height != -1)) {
834 setExportSize(width, height);
835 }
836
837 if (fExportImageFormat == "eps") {
839 } else if (fExportImageFormat == "ps") {
841 } else if (fExportImageFormat == "svg") {
843 } else if (fExportImageFormat == "pdf") {
845 } else {
846 setExportImageFormat(fExportImageFormat,true); // will display a message if this format is not correct for the current viewer
847 return false;
848 }
849
850 bool res;
851
852 // Change the LC_NUMERIC value in order to have "." separtor and not ","
853 // This case is only useful for French, Canadien...
854 size_t len = strlen(setlocale(LC_NUMERIC,NULL));
855 char* oldLocale = (char*)(malloc(len+1));
856 if(oldLocale!=NULL) strncpy(oldLocale,setlocale(LC_NUMERIC,NULL),len);
857 setlocale(LC_NUMERIC,"C");
858
859 if (((fExportImageFormat == "eps") || (fExportImageFormat == "ps")) && (!fVectoredPs)) {
860 res = printNonVectoredEPS();
861 } else {
862 res = printVectoredEPS();
863 }
864
865 // restore the local
866 if (oldLocale) {
867 setlocale(LC_NUMERIC,oldLocale);
868 free(oldLocale);
869 }
870
871 if (res == false) {
872 G4cerr << "Error saving file... " << getRealPrintFilename().c_str() << G4endl;
873 } else {
874 G4cout << "File " << getRealPrintFilename().c_str() << " size: " << getRealExportWidth() << "x" << getRealExportHeight() << " has been saved " << G4endl;
875
876 // increment index if necessary
877 if ( fExportFilenameIndex != -1) {
879 }
880 }
881
882 return res;
883}
G4GLOB_DLL std::ostream G4cerr
void setExportImageFormat(unsigned int)
G4int getRealExportHeight()
bool setExportImageFormat(std::string format, bool quiet=false)
std::string fExportImageFormat
bool setExportFilename(G4String name, G4bool inc=true)
bool printNonVectoredEPS()
void setExportSize(G4int, G4int)
G4int getRealExportWidth()
std::string getRealPrintFilename()
#define GL2PS_SVG
Definition: gl2ps.h:133
#define GL2PS_EPS
Definition: gl2ps.h:130
#define GL2PS_PDF
Definition: gl2ps.h:132
#define GL2PS_PS
Definition: gl2ps.h:129
const char * name(G4int ptype)

References G4OpenGLViewer::fExportFilenameIndex, G4OpenGLViewer::fExportImageFormat, G4OpenGLViewer::fGL2PSAction, free, G4OpenGLViewer::fVectoredPs, G4cerr, G4cout, G4endl, G4OpenGLViewer::getRealExportHeight(), G4OpenGLViewer::getRealExportWidth(), G4OpenGLViewer::getRealPrintFilename(), GL2PS_EPS, GL2PS_PDF, GL2PS_PS, GL2PS_SVG, G4InuclParticleNames::name(), G4OpenGLViewer::printNonVectoredEPS(), G4OpenGLViewer::printVectoredEPS(), G4OpenGLViewer::setExportFilename(), G4OpenGLViewer::setExportImageFormat(), G4OpenGL2PSAction::setExportImageFormat(), and G4OpenGLViewer::setExportSize().

Referenced by G4OpenGLQtViewer::exportImage(), G4OpenGLXmViewer::print_callback(), and G4OpenGLViewerMessenger::SetNewValue().

◆ FinishView()

void G4VViewer::FinishView ( void  )
virtualinherited

◆ g4GlFrustum()

void G4OpenGLViewer::g4GlFrustum ( GLdouble  left,
GLdouble  right,
GLdouble  bottom,
GLdouble  top,
GLdouble  near,
GLdouble  far 
)
protectedinherited

Definition at line 1467 of file G4OpenGLViewer.cc.

1467 {
1468 // glFrustum (left, right, bottom, top, near, far);
1469
1470 GLdouble deltaX = right - left;
1471 GLdouble deltaY = top - bottom;
1472 GLdouble deltaZ = zFar - zNear;
1473
1474 GLdouble a = 2.0f * zNear / deltaX;
1475 GLdouble b = 2.0f * zNear / deltaY;
1476 GLdouble c = (right + left) / deltaX;
1477 GLdouble d = (top + bottom) / deltaY;
1478 GLdouble e = -(zFar + zNear) / (zFar - zNear);
1479 GLdouble f = -2.0f * zFar * zNear / deltaZ;
1480
1481 GLdouble proj[16] = {
1482 a, 0, 0, 0,
1483 0, b, 0, 0,
1484 c, d, e, -1.0f,
1485 0, 0, f, 0
1486 };
1487
1488 glMultMatrixd(proj);
1489
1490}

Referenced by G4OpenGLViewer::SetView().

◆ g4GlOrtho()

void G4OpenGLViewer::g4GlOrtho ( GLdouble  left,
GLdouble  right,
GLdouble  bottom,
GLdouble  top,
GLdouble  near,
GLdouble  far 
)
protectedinherited

Definition at line 1445 of file G4OpenGLViewer.cc.

1445 {
1446 // glOrtho (left, right, bottom, top, near, far);
1447
1448 GLdouble a = 2.0 / (right - left);
1449 GLdouble b = 2.0 / (top - bottom);
1450 GLdouble c = -2.0 / (zFar - zNear);
1451
1452 GLdouble tx = - (right + left)/(right - left);
1453 GLdouble ty = - (top + bottom)/(top - bottom);
1454 GLdouble tz = - (zFar + zNear)/(zFar - zNear);
1455
1456 GLdouble ortho[16] = {
1457 a, 0, 0, 0,
1458 0, b, 0, 0,
1459 0, 0, c, 0,
1460 tx, ty, tz, 1
1461 };
1462 glMultMatrixd(ortho);
1463
1464}

Referenced by G4OpenGLStoredSceneHandler::AddPrimitivePreambleInternal(), G4OpenGLImmediateSceneHandler::BeginPrimitives2D(), DrawDisplayLists(), and G4OpenGLViewer::SetView().

◆ g4GluLookAt()

void G4OpenGLViewer::g4GluLookAt ( GLdouble  eyex,
GLdouble  eyey,
GLdouble  eyez,
GLdouble  centerx,
GLdouble  centery,
GLdouble  centerz,
GLdouble  upx,
GLdouble  upy,
GLdouble  upz 
)
protectedinherited

Definition at line 1365 of file G4OpenGLViewer.cc.

1369{
1370 GLdouble mat[16];
1371 GLdouble x[3], y[3], z[3];
1372 GLdouble mag;
1373
1374 /* Make rotation matrix */
1375
1376 /* Z vector */
1377 z[0] = eyex - centerx;
1378 z[1] = eyey - centery;
1379 z[2] = eyez - centerz;
1380 mag = std::sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
1381 if (mag) { /* mpichler, 19950515 */
1382 z[0] /= mag;
1383 z[1] /= mag;
1384 z[2] /= mag;
1385 }
1386
1387 /* Y vector */
1388 y[0] = upx;
1389 y[1] = upy;
1390 y[2] = upz;
1391
1392 /* X vector = Y cross Z */
1393 x[0] = y[1] * z[2] - y[2] * z[1];
1394 x[1] = -y[0] * z[2] + y[2] * z[0];
1395 x[2] = y[0] * z[1] - y[1] * z[0];
1396
1397 /* Recompute Y = Z cross X */
1398 y[0] = z[1] * x[2] - z[2] * x[1];
1399 y[1] = -z[0] * x[2] + z[2] * x[0];
1400 y[2] = z[0] * x[1] - z[1] * x[0];
1401
1402 /* mpichler, 19950515 */
1403 /* cross product gives area of parallelogram, which is < 1.0 for
1404 * non-perpendicular unit-length vectors; so normalize x, y here
1405 */
1406
1407 mag = std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
1408 if (mag) {
1409 x[0] /= mag;
1410 x[1] /= mag;
1411 x[2] /= mag;
1412 }
1413
1414 mag = std::sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
1415 if (mag) {
1416 y[0] /= mag;
1417 y[1] /= mag;
1418 y[2] /= mag;
1419 }
1420
1421#define M(row,col) mat[col*4+row]
1422 M(0, 0) = x[0];
1423 M(0, 1) = x[1];
1424 M(0, 2) = x[2];
1425 M(0, 3) = 0.0;
1426 M(1, 0) = y[0];
1427 M(1, 1) = y[1];
1428 M(1, 2) = y[2];
1429 M(1, 3) = 0.0;
1430 M(2, 0) = z[0];
1431 M(2, 1) = z[1];
1432 M(2, 2) = z[2];
1433 M(2, 3) = 0.0;
1434 M(3, 0) = 0.0;
1435 M(3, 1) = 0.0;
1436 M(3, 2) = 0.0;
1437 M(3, 3) = 1.0;
1438#undef M
1439 glMultMatrixd(mat);
1440
1441 /* Translate Eye to Origin */
1442 glTranslated(-eyex, -eyey, -eyez);
1443}
#define M(row, col)

References M.

Referenced by G4OpenGLViewer::SetView().

◆ g4GluPickMatrix()

void G4OpenGLViewer::g4GluPickMatrix ( GLdouble  x,
GLdouble  y,
GLdouble  width,
GLdouble  height,
GLint  viewport[4] 
)
protectedinherited

Definition at line 1323 of file G4OpenGLViewer.cc.

1325 {
1326 GLdouble mat[16];
1327 GLdouble sx, sy;
1328 GLdouble tx, ty;
1329
1330 sx = viewport[2] / width;
1331 sy = viewport[3] / height;
1332 tx = (viewport[2] + 2.0 * (viewport[0] - x)) / width;
1333 ty = (viewport[3] + 2.0 * (viewport[1] - y)) / height;
1334
1335#define M(row, col) mat[col*4+row]
1336 M(0, 0) = sx;
1337 M(0, 1) = 0.0;
1338 M(0, 2) = 0.0;
1339 M(0, 3) = tx;
1340 M(1, 0) = 0.0;
1341 M(1, 1) = sy;
1342 M(1, 2) = 0.0;
1343 M(1, 3) = ty;
1344 M(2, 0) = 0.0;
1345 M(2, 1) = 0.0;
1346 M(2, 2) = 1.0;
1347 M(2, 3) = 0.0;
1348 M(3, 0) = 0.0;
1349 M(3, 1) = 0.0;
1350 M(3, 2) = 0.0;
1351 M(3, 3) = 1.0;
1352#undef M
1353
1354 glMultMatrixd(mat);
1355}

References M.

Referenced by G4OpenGLViewer::GetPickDetails().

◆ GetApplicableVisAttributes()

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

◆ GetDefaultViewParameters()

const G4ViewParameters & G4VViewer::GetDefaultViewParameters ( ) const
inherited

◆ GetName()

const G4String & G4VViewer::GetName ( ) const
inherited

◆ GetPickDetails()

const std::vector< G4OpenGLViewerPickMap * > & G4OpenGLViewer::GetPickDetails ( GLdouble  x,
GLdouble  y 
)
protectedinherited

Definition at line 488 of file G4OpenGLViewer.cc.

489{
490 static std::vector < G4OpenGLViewerPickMap* > pickMapVector;
491 for (auto pickMap: pickMapVector) {
492 delete pickMap;
493 }
494 pickMapVector.clear();
495
496 const G4int BUFSIZE = 512;
497 GLuint selectBuffer[BUFSIZE];
498 glSelectBuffer(BUFSIZE, selectBuffer);
499 glRenderMode(GL_SELECT);
500 glInitNames();
501 glPushName(0);
502 glMatrixMode(GL_PROJECTION);
503 G4double currentProjectionMatrix[16];
504 glGetDoublev(GL_PROJECTION_MATRIX, currentProjectionMatrix);
505 glPushMatrix();
506 glLoadIdentity();
507 GLint viewport[4];
508 glGetIntegerv(GL_VIEWPORT, viewport);
509/* G4cout
510 << "viewport, x,y: "
511 << viewport[0] << ',' << viewport[1] << ',' << viewport[2] << ',' << viewport[3]
512 << ", " << x << ',' << y
513 << G4endl;
514*/
515 fIsGettingPickInfos = true;
516 // Define 5x5 pixel pick area
517 g4GluPickMatrix(x, viewport[3] - y, 5., 5., viewport);
518 glMultMatrixd(currentProjectionMatrix);
519 glMatrixMode(GL_MODELVIEW);
520 DrawView();
521 GLint hits = glRenderMode(GL_RENDER);
522 fIsGettingPickInfos = false;
523 if (hits < 0) {
524 G4cout << "Too many hits. Zoom in to reduce overlaps." << G4endl;
525 goto restoreMatrices;
526 }
527 if (hits > 0) {
528 GLuint* p = selectBuffer;
529 for (GLint i = 0; i < hits; ++i) {
530 GLuint nnames = *p++;
531 // This bit of debug code or...
532 //GLuint zmin = *p++;
533 //GLuint zmax = *p++;
534 //G4cout << "Hit " << i << ": " << nnames << " names"
535 // << "\nzmin: " << zmin << ", zmax: " << zmax << G4endl;
536 // ...just increment the pointer
537 p++;
538 p++;
539 for (GLuint j = 0; j < nnames; ++j) {
540 GLuint name = *p++;
541 std::map<GLuint, G4AttHolder*>::iterator iter =
543 if (iter != fOpenGLSceneHandler.fPickMap.end()) {
544 G4AttHolder* attHolder = iter->second;
545 if(attHolder && attHolder->GetAttDefs().size()) {
546 for (size_t iAtt = 0;
547 iAtt < attHolder->GetAttDefs().size(); ++iAtt) {
548 std::ostringstream oss;
549 oss << G4AttCheck(attHolder->GetAttValues()[iAtt],
550 attHolder->GetAttDefs()[iAtt]);
552// G4cout
553// << "i,j, attHolder->GetAttDefs().size(): "
554// << i << ',' << j
555// << ", " << attHolder->GetAttDefs().size()
556// << G4endl;
557// G4cout << "G4OpenGLViewer::GetPickDetails: " << oss.str() << G4endl;
558 pickMap->addAttributes(oss.str());
559 pickMap->setHitNumber(i);
560 pickMap->setSubHitNumber(j);
561 pickMap->setPickName(name);
562 pickMapVector.push_back(pickMap);
563 }
564 }
565 }
566 }
567 }
568 }
569
570restoreMatrices:
571 glMatrixMode(GL_PROJECTION);
572 glPopMatrix();
573 glMatrixMode(GL_MODELVIEW);
574
575 return pickMapVector;
576}
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
std::map< GLuint, G4AttHolder * > fPickMap
void setSubHitNumber(G4int n)
void setHitNumber(G4int n)
void addAttributes(G4String att)
void setPickName(G4int n)
void g4GluPickMatrix(GLdouble x, GLdouble y, GLdouble width, GLdouble height, GLint viewport[4])
G4OpenGLSceneHandler & fOpenGLSceneHandler
virtual void DrawView()=0
#define BUFSIZE
Definition: liblist.c:40

References G4OpenGLViewerPickMap::addAttributes(), BUFSIZE, G4VViewer::DrawView(), G4OpenGLViewer::fIsGettingPickInfos, G4OpenGLViewer::fOpenGLSceneHandler, G4OpenGLSceneHandler::fPickMap, G4cout, G4endl, G4OpenGLViewer::g4GluPickMatrix(), G4AttHolder::GetAttDefs(), G4AttHolder::GetAttValues(), G4InuclParticleNames::name(), G4OpenGLViewerPickMap::setHitNumber(), G4OpenGLViewerPickMap::setPickName(), and G4OpenGLViewerPickMap::setSubHitNumber().

Referenced by G4OpenGLViewer::Pick(), and G4OpenGLQtViewer::updatePickInfosWidget().

◆ GetPrivateVisAttributesModifiers()

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

◆ getRealExportHeight()

G4int G4OpenGLViewer::getRealExportHeight ( )
privateinherited

Definition at line 1004 of file G4OpenGLViewer.cc.

1004 {
1005 if (fPrintSizeY == -1) {
1006 return fWinSize_y;
1007 }
1008 GLint dims[2];
1009 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
1010
1011 // L.Garnier 01-2010: Some problems with mac 10.6
1012 if ((dims[0] !=0 ) && (dims[1] !=0)) {
1013 if (fPrintSizeY > dims[1]){
1014 return dims[1];
1015 }
1016 }
1017 if (fPrintSizeY < -1){
1018 return 0;
1019 }
1020 return fPrintSizeY;
1021}
unsigned int fWinSize_y

References G4OpenGLViewer::fPrintSizeY, and G4OpenGLViewer::fWinSize_y.

Referenced by G4OpenGLViewer::exportImage(), G4OpenGLViewer::printGl2PS(), and G4OpenGLViewer::printNonVectoredEPS().

◆ getRealExportWidth()

G4int G4OpenGLViewer::getRealExportWidth ( )
privateinherited

Definition at line 985 of file G4OpenGLViewer.cc.

985 {
986 if (fPrintSizeX == -1) {
987 return fWinSize_x;
988 }
989 GLint dims[2];
990 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
991
992 // L.Garnier 01-2010: Some problems with mac 10.6
993 if ((dims[0] !=0 ) && (dims[1] !=0)) {
994 if (fPrintSizeX > dims[0]){
995 return dims[0];
996 }
997 }
998 if (fPrintSizeX < -1){
999 return 0;
1000 }
1001 return fPrintSizeX;
1002}
unsigned int fWinSize_x

References G4OpenGLViewer::fPrintSizeX, and G4OpenGLViewer::fWinSize_x.

Referenced by G4OpenGLViewer::exportImage(), G4OpenGLViewer::printGl2PS(), and G4OpenGLViewer::printNonVectoredEPS().

◆ getRealPrintFilename()

std::string G4OpenGLViewer::getRealPrintFilename ( )
protectedinherited

Definition at line 1066 of file G4OpenGLViewer.cc.

1066 {
1067 std::string temp = fExportFilename;
1068 if (fExportFilenameIndex != -1) {
1069 temp += std::string("_");
1070 std::ostringstream os;
1071 os << std::setw(4) << std::setfill('0') << fExportFilenameIndex;
1072 std::string nb_str = os.str();
1073 temp += nb_str;
1074 }
1075 temp += "."+fExportImageFormat;
1076 return temp;
1077}
G4String fExportFilename

References G4OpenGLViewer::fExportFilename, G4OpenGLViewer::fExportFilenameIndex, and G4OpenGLViewer::fExportImageFormat.

Referenced by G4OpenGLQtViewer::exportImage(), G4OpenGLViewer::exportImage(), G4OpenGLXmViewer::misc_callback(), G4OpenGLViewer::printGl2PS(), G4OpenGLViewer::printNonVectoredEPS(), and G4OpenGLViewer::setExportFilename().

◆ getSceneDepth()

GLdouble G4OpenGLViewer::getSceneDepth ( )
protectedinherited

Definition at line 1111 of file G4OpenGLViewer.cc.

1112{
1113 if (!fSceneHandler.GetScene()) {
1114 return 0;
1115 }
1116 const G4Point3D targetPoint
1120 if(radius<=0.) radius = 1.;
1121 const G4double cameraDistance = fVP.GetCameraDistance (radius);
1122 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
1123 return fVP.GetFarDistance (cameraDistance, pnear, radius)- pnear;
1124}
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const

References G4VViewer::fSceneHandler, G4VViewer::fVP, G4ViewParameters::GetCameraDistance(), G4ViewParameters::GetCurrentTargetPoint(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetFarDistance(), G4ViewParameters::GetNearDistance(), G4VSceneHandler::GetScene(), and G4Scene::GetStandardTargetPoint().

Referenced by G4OpenGLQtViewer::moveScene().

◆ getSceneFarWidth()

GLdouble G4OpenGLViewer::getSceneFarWidth ( )
protectedinherited

Definition at line 1094 of file G4OpenGLViewer.cc.

1095{
1096 if (!fSceneHandler.GetScene()) {
1097 return 0;
1098 }
1099 const G4Point3D targetPoint
1103 if(radius<=0.) radius = 1.;
1104 const G4double cameraDistance = fVP.GetCameraDistance (radius);
1105 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
1106 const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
1107 return 2 * fVP.GetFrontHalfHeight (pfar, radius);
1108}
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const

References G4VViewer::fSceneHandler, G4VViewer::fVP, G4ViewParameters::GetCameraDistance(), G4ViewParameters::GetCurrentTargetPoint(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetFarDistance(), G4ViewParameters::GetFrontHalfHeight(), G4ViewParameters::GetNearDistance(), G4VSceneHandler::GetScene(), and G4Scene::GetStandardTargetPoint().

◆ GetSceneHandler()

G4VSceneHandler * G4VViewer::GetSceneHandler ( ) const
inherited

◆ getSceneNearWidth()

GLdouble G4OpenGLViewer::getSceneNearWidth ( )
protectedinherited

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

◆ getWinHeight()

unsigned int G4OpenGLViewer::getWinHeight ( ) const
protectedinherited

◆ getWinWidth()

unsigned int G4OpenGLViewer::getWinWidth ( ) const
protectedinherited

◆ grabPixels()

GLubyte * G4OpenGLViewer::grabPixels ( int  inColor,
unsigned int  width,
unsigned int  height 
)
privateinherited

Definition at line 578 of file G4OpenGLViewer.cc.

579 {
580
581 GLubyte* buffer;
582 GLint swapbytes, lsbfirst, rowlength;
583 GLint skiprows, skippixels, alignment;
584 GLenum format;
585 int size;
586
587 if (inColor) {
588 format = GL_RGB;
589 size = width*height*3;
590 } else {
591 format = GL_LUMINANCE;
592 size = width*height*1;
593 }
594
595 buffer = new GLubyte[size];
596 if (buffer == NULL)
597 return NULL;
598
599 glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
600 glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
601 glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
602
603 glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
604 glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
605 glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
606
607 glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
608 glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
609 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
610
611 glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
612 glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
613 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
614
615 glReadBuffer(GL_FRONT);
616 glReadPixels (0, 0, (GLsizei)width, (GLsizei)height, format, GL_UNSIGNED_BYTE, (GLvoid*) buffer);
617
618 glPixelStorei (GL_UNPACK_SWAP_BYTES, swapbytes);
619 glPixelStorei (GL_UNPACK_LSB_FIRST, lsbfirst);
620 glPixelStorei (GL_UNPACK_ROW_LENGTH, rowlength);
621
622 glPixelStorei (GL_UNPACK_SKIP_ROWS, skiprows);
623 glPixelStorei (GL_UNPACK_SKIP_PIXELS, skippixels);
624 glPixelStorei (GL_UNPACK_ALIGNMENT, alignment);
625
626 return buffer;
627}
#define buffer
Definition: xmlparse.cc:628

References buffer.

Referenced by G4OpenGLViewer::printNonVectoredEPS().

◆ HaloingFirstPass()

void G4OpenGLViewer::HaloingFirstPass ( )
protectedinherited

Definition at line 441 of file G4OpenGLViewer.cc.

441 {
442
443 //To perform haloing, first Draw all information to the depth buffer
444 //alone, using a chunky line width, and then Draw all info again, to
445 //the colour buffer, setting a thinner line width an the depth testing
446 //function to less than or equal, so if two lines cross, the one
447 //passing behind the other will not pass the depth test, and so not
448 //get rendered either side of the infront line for a short distance.
449
450 //First, disable writing to the colo(u)r buffer...
451 glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
452
453 //Now enable writing to the depth buffer...
454 glDepthMask (GL_TRUE);
455 glDepthFunc (GL_LESS);
456 glClearDepth (1.0);
457
458 //Finally, set the line width to something wide...
459 ChangeLineWidth(3.0);
460
461}
void ChangeLineWidth(G4double width)

References G4OpenGLViewer::ChangeLineWidth().

Referenced by G4OpenGLImmediateQtViewer::ComputeView(), G4OpenGLStoredQtViewer::ComputeView(), G4OpenGLImmediateWin32Viewer::DrawView(), G4OpenGLImmediateXmViewer::DrawView(), G4OpenGLImmediateXViewer::DrawView(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), and G4OpenGLStoredXViewer::DrawView().

◆ HaloingSecondPass()

void G4OpenGLViewer::HaloingSecondPass ( )
protectedinherited

Definition at line 463 of file G4OpenGLViewer.cc.

463 {
464
465 //And finally, turn the colour buffer back on with a sesible line width...
466 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
467 glDepthFunc (GL_LEQUAL);
468 ChangeLineWidth(1.0);
469
470}

References G4OpenGLViewer::ChangeLineWidth().

Referenced by G4OpenGLImmediateQtViewer::ComputeView(), G4OpenGLStoredQtViewer::ComputeView(), G4OpenGLImmediateWin32Viewer::DrawView(), G4OpenGLImmediateXmViewer::DrawView(), G4OpenGLImmediateXViewer::DrawView(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), and G4OpenGLStoredXViewer::DrawView().

◆ HLRFirstPass()

void G4OpenGLViewer::HLRFirstPass ( )
protectedinherited

◆ HLRSecondPass()

void G4OpenGLViewer::HLRSecondPass ( )
protectedinherited

◆ HLRThirdPass()

void G4OpenGLViewer::HLRThirdPass ( )
protectedinherited

◆ Initialise()

virtual void G4VViewer::Initialise ( )
virtualinherited

◆ InitializeGLView()

void G4OpenGLViewer::InitializeGLView ( )
protectedinherited

Definition at line 127 of file G4OpenGLViewer.cc.

128{
129#ifdef G4OPENGL_VERSION_2
130 if (fVboDrawer) {
131
132 // First, load a simple shader
133 fShaderProgram = glCreateProgram();
134 Shader vertexShader = glCreateShader(GL_VERTEX_SHADER);
135 const char * vSrc = fVboDrawer->getVertexShaderSrc();
136 glShaderSource(vertexShader, 1, &vSrc, NULL);
137 glCompileShader(vertexShader);
138 glAttachShader(fShaderProgram, vertexShader);
139
140 Shader fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
141 const char * fSrc = fVboDrawer->getFragmentShaderSrc();
142 glShaderSource(fragmentShader, 1, &fSrc, NULL);
143 glCompileShader(fragmentShader);
144
145 glAttachShader(fShaderProgram, fragmentShader);
146 glLinkProgram(fShaderProgram);
147 glUseProgram(fShaderProgram);
148
149 // UniformLocation uColor = getUniformLocation(fShaderProgram, "uColor");
150 // uniform4fv(uColor, [0.0, 0.3, 0.0, 1.0]);
151
152 // Extract the references to the attributes from the shader.
153
154 fVertexPositionAttribute =
155 glGetAttribLocation(fShaderProgram, "aVertexPosition");
156
157
158 glEnableVertexAttribArray(fVertexPositionAttribute);
159
160 // Extract the references the uniforms from the shader
161 fpMatrixUniform = glGetUniformLocation(fShaderProgram, "uPMatrix");
162 fcMatrixUniform = glGetUniformLocation(fShaderProgram, "uCMatrix");
163 fmvMatrixUniform = glGetUniformLocation(fShaderProgram, "uMVMatrix");
164 fnMatrixUniform = glGetUniformLocation(fShaderProgram, "uNMatrix");
165 ftMatrixUniform = glGetUniformLocation(fShaderProgram, "uTMatrix");
166
167 /* glUniformMatrix4fv(fcMatrixUniform, 1, 0, identity);
168 glUniformMatrix4fv(fpMatrixUniform, 1, 0, identity);
169 glUniformMatrix4fv(ftMatrixUniform, 1, 0, identity);
170 glUniformMatrix4fv(fmvMatrixUniform, 1, 0, identity);
171 */
172 // We have to set that in order to avoid calls on opengl commands before all is ready
173 fGlViewInitialized = true;
174 }
175#endif
176
177 if (fWinSize_x == 0) {
179 }
180 if (fWinSize_y == 0) {
182 }
183
184 glClearColor (0.0, 0.0, 0.0, 0.0);
185 glClearDepth (1.0);
186#ifndef G4OPENGL_VERSION_2
187 glDisable (GL_LINE_SMOOTH);
188 glDisable (GL_POLYGON_SMOOTH);
189#endif
190
191// clear the buffers and window?
192 ClearView ();
193 FinishView ();
194
195 glDepthFunc (GL_LEQUAL);
196 glDepthMask (GL_TRUE);
197
198 glEnable (GL_BLEND);
199 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
200
201}
virtual void FinishView()
Definition: G4VViewer.cc:101
unsigned int GetWindowSizeHintX() const
unsigned int GetWindowSizeHintY() const

References G4OpenGLViewer::ClearView(), G4OpenGLViewer::fGlViewInitialized, G4VViewer::FinishView(), G4VViewer::fVP, G4OpenGLViewer::fWinSize_x, G4OpenGLViewer::fWinSize_y, G4ViewParameters::GetWindowSizeHintX(), and G4ViewParameters::GetWindowSizeHintY().

Referenced by G4OpenGLImmediateXmViewer::Initialise(), G4OpenGLImmediateXViewer::Initialise(), G4OpenGLStoredXmViewer::Initialise(), G4OpenGLStoredXViewer::Initialise(), G4OpenGLImmediateQtViewer::initializeGL(), and G4OpenGLStoredQtViewer::initializeGL().

◆ isFramebufferReady()

G4bool G4OpenGLViewer::isFramebufferReady ( )
protectedinherited

Definition at line 730 of file G4OpenGLViewer.cc.

730 {
731 bool check = false;
732#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
733 check = true;
734#endif
735#ifdef G4VIS_BUILD_OPENGLX_DRIVER
736 check = false;
737#endif
738#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
739 check = false;
740#endif
741#ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
742 check = false;
743#endif
744
745#if GL_ARB_framebuffer_object
746 if (check) {
747// if ( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNDEFINED) {
748// return false;
749// }
750 }
751#endif
752 return true;
753}

Referenced by G4OpenGLViewer::ClearView(), G4OpenGLViewer::ClearViewWithoutFlush(), G4OpenGLImmediateQtViewer::paintEvent(), and G4OpenGLStoredQtViewer::paintEvent().

◆ isGl2psWriting()

bool G4OpenGLViewer::isGl2psWriting ( )
protectedinherited

Return if gl2ps is currently writing

Definition at line 720 of file G4OpenGLViewer.cc.

720 {
721
722 if (!fGL2PSAction) return false;
724 return true;
725 }
726 return false;
727}
bool fileWritingEnabled() const
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//

References G4OpenGLViewer::fGL2PSAction, and G4OpenGL2PSAction::fileWritingEnabled().

Referenced by G4OpenGLViewer::ChangeLineWidth(), G4OpenGLViewer::ChangePointSize(), G4OpenGLQtViewer::DrawText(), G4OpenGLViewer::DrawText(), and G4OpenGLXViewer::DrawText().

◆ KernelVisitDecision()

void G4OpenGLStoredViewer::KernelVisitDecision ( )
protected

Definition at line 56 of file G4OpenGLStoredViewer.cc.

56 {
57
58 // If there's a significant difference with the last view parameters
59 // of either the scene handler or this viewer, trigger a rebuild.
60
64 }
65}
virtual G4bool CompareForKernelVisit(G4ViewParameters &)
void NeedKernelVisit()
Definition: G4VViewer.cc:78

References CompareForKernelVisit(), fG4OpenGLStoredSceneHandler, fLastVP, G4OpenGLStoredSceneHandler::fTopPODL, and G4VViewer::NeedKernelVisit().

Referenced by G4OpenGLStoredQtViewer::ComputeView(), G4OpenGLStoredWin32Viewer::DrawView(), G4OpenGLStoredXmViewer::DrawView(), and G4OpenGLStoredXViewer::DrawView().

◆ 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}
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:224

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(), 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().

◆ Pick()

G4String G4OpenGLViewer::Pick ( GLdouble  x,
GLdouble  y 
)
protectedvirtualinherited

Definition at line 472 of file G4OpenGLViewer.cc.

473{
474 const std::vector < G4OpenGLViewerPickMap* > & pickMap = GetPickDetails(x,y);
475 G4String txt = "";
476 if (pickMap.size() == 0) {
477// txt += "No hits recorded.";;
478 } else {
479 for (unsigned int a=0; a < pickMap.size(); a++) {
480 if (pickMap[a]->getAttributes().size() > 0) {
481 txt += pickMap[a]->print();
482 }
483 }
484 }
485 return txt;
486}
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails(GLdouble x, GLdouble y)

References G4OpenGLViewer::GetPickDetails().

Referenced by G4OpenGLXViewer::ShowView().

◆ POSelected()

virtual G4bool G4OpenGLStoredViewer::POSelected ( size_t  )
inlineprotectedvirtual

Reimplemented in G4OpenGLStoredQtViewer.

Definition at line 67 of file G4OpenGLStoredViewer.hh.

67{return true;}

Referenced by DrawDisplayLists().

◆ printGl2PS()

bool G4OpenGLViewer::printGl2PS ( )
privateinherited

Definition at line 886 of file G4OpenGLViewer.cc.

886 {
887
888 int width = getRealExportWidth();
889 int height = getRealExportHeight();
890 bool res = true;
891
892 // no need to redraw at each new primitive for printgl2PS
893 G4OpenGLSceneHandler& oglSceneHandler = dynamic_cast<G4OpenGLSceneHandler&>(fSceneHandler);
894 G4OpenGLSceneHandler::FlushAction originalFlushAction = oglSceneHandler.GetFlushAction();
896
897 if (!fGL2PSAction) return false;
898
900 // try to resize
901 int X = fWinSize_x;
902 int Y = fWinSize_y;
903
904 fWinSize_x = width;
905 fWinSize_y = height;
906 // Laurent G. 16/03/10 : Not the good way to do.
907 // We should draw in a new offscreen context instead of
908 // resizing and drawing in current window...
909 // This should be solve when we will do an offscreen method
910 // to render OpenGL
911 // See :
912 // http://developer.apple.com/Mac/library/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_offscreen/opengl_offscreen.html
913 // http://www.songho.ca/opengl/gl_fbo.html
914
915 ResizeGLView();
916 bool extendBuffer = true;
917 bool endWriteAction = false;
918 bool beginWriteAction = true;
919 bool filePointerOk = true;
920 while ((extendBuffer) && (! endWriteAction) && (filePointerOk)) {
921
922 beginWriteAction = fGL2PSAction->enableFileWriting();
923 // 3 cases :
924 // - true
925 // - false && ! fGL2PSAction->fileWritingEnabled() => bad file name
926 // - false && fGL2PSAction->fileWritingEnabled() => buffer size problem ?
927
928 filePointerOk = fGL2PSAction->fileWritingEnabled();
929
930 if (beginWriteAction) {
931
932 // Set the viewport
933 // By default, we choose the line width (trajectories...)
935 // By default, we choose the point size (markers...)
937
938 DrawView ();
939 endWriteAction = fGL2PSAction->disableFileWriting();
940 }
941 if (filePointerOk) {
942 if ((! endWriteAction) || (! beginWriteAction)) {
943 extendBuffer = fGL2PSAction->extendBufferSize();
944 }
945 }
946 }
948
949 if (!extendBuffer ) {
950 G4cerr << "ERROR: gl2ps buffer size is not big enough to print this geometry. Try to extend it. No output produced"<< G4endl;
951 res = false;
952 }
953 if (!beginWriteAction ) {
954 G4cerr << "ERROR: saving file "<<getRealPrintFilename().c_str()<<". Check read/write access. No output produced" << G4endl;
955 res = false;
956 }
957 if (!endWriteAction ) {
958 G4cerr << "gl2ps error. No output produced" << G4endl;
959 res = false;
960 }
961 fWinSize_x = X;
962 fWinSize_y = Y;
963
964 oglSceneHandler.SetFlushAction(originalFlushAction);
965
966 // Reset for next time (useful is size change)
967 // fPrintSizeX = 0;
968 // fPrintSizeY = 0;
969
970 return res;
971}
G4double Y(G4double density)
bool enableFileWriting()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
bool disableFileWriting()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void setFileName(const char *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
bool extendBufferSize()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
void resetBufferSizeParameters()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
static void SetFlushAction(FlushAction action)
static FlushAction GetFlushAction()

References G4OpenGL2PSAction::disableFileWriting(), G4VViewer::DrawView(), G4OpenGL2PSAction::enableFileWriting(), G4OpenGL2PSAction::extendBufferSize(), G4OpenGLViewer::fGL2PSAction, G4OpenGLViewer::fGl2psDefaultLineWith, G4OpenGLViewer::fGl2psDefaultPointSize, G4OpenGL2PSAction::fileWritingEnabled(), G4VViewer::fSceneHandler, G4OpenGLViewer::fWinSize_x, G4OpenGLViewer::fWinSize_y, G4cerr, G4endl, G4OpenGLSceneHandler::GetFlushAction(), G4OpenGLViewer::getRealExportHeight(), G4OpenGLViewer::getRealExportWidth(), G4OpenGLViewer::getRealPrintFilename(), G4OpenGLSceneHandler::never, G4OpenGL2PSAction::resetBufferSizeParameters(), G4OpenGLViewer::ResizeGLView(), G4OpenGL2PSAction::setFileName(), G4OpenGLSceneHandler::SetFlushAction(), G4OpenGL2PSAction::setLineWidth(), G4OpenGL2PSAction::setPointSize(), and Y().

Referenced by G4OpenGLViewer::printVectoredEPS().

◆ printNonVectoredEPS()

bool G4OpenGLViewer::printNonVectoredEPS ( )
privateinherited

Definition at line 633 of file G4OpenGLViewer.cc.

633 {
634
635 int width = getRealExportWidth();
636 int height = getRealExportHeight();
637
638 FILE* fp;
639 GLubyte* pixels;
640 GLubyte* curpix;
641 int components, pos, i;
642
643 pixels = grabPixels (fPrintColour, width, height);
644
645 if (pixels == NULL) {
646 G4cerr << "Failed to get pixels from OpenGl viewport" << G4endl;
647 return false;
648 }
649 if (fPrintColour) {
650 components = 3;
651 } else {
652 components = 1;
653 }
654 std::string name = getRealPrintFilename();
655 fp = fopen (name.c_str(), "w");
656 if (fp == NULL) {
657 G4cerr << "Can't open filename " << name.c_str() << G4endl;
658 return false;
659 }
660
661 fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n");
662 fprintf (fp, "%%%%Title: %s\n", name.c_str());
663 fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n");
664 fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", width, height);
665 fprintf (fp, "%%%%EndComments\n");
666 fprintf (fp, "gsave\n");
667 fprintf (fp, "/bwproc {\n");
668 fprintf (fp, " rgbproc\n");
669 fprintf (fp, " dup length 3 idiv string 0 3 0 \n");
670 fprintf (fp, " 5 -1 roll {\n");
671 fprintf (fp, " add 2 1 roll 1 sub dup 0 eq\n");
672 fprintf (fp, " { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
673 fprintf (fp, " 3 1 roll 5 -1 roll } put 1 add 3 0 \n");
674 fprintf (fp, " { 2 1 roll } ifelse\n");
675 fprintf (fp, " }forall\n");
676 fprintf (fp, " pop pop pop\n");
677 fprintf (fp, "} def\n");
678 fprintf (fp, "systemdict /colorimage known not {\n");
679 fprintf (fp, " /colorimage {\n");
680 fprintf (fp, " pop\n");
681 fprintf (fp, " pop\n");
682 fprintf (fp, " /rgbproc exch def\n");
683 fprintf (fp, " { bwproc } image\n");
684 fprintf (fp, " } def\n");
685 fprintf (fp, "} if\n");
686 fprintf (fp, "/picstr %d string def\n", width * components);
687 fprintf (fp, "%d %d scale\n", width, height);
688 fprintf (fp, "%d %d %d\n", width, height, 8);
689 fprintf (fp, "[%d 0 0 %d 0 0]\n", width, height);
690 fprintf (fp, "{currentfile picstr readhexstring pop}\n");
691 fprintf (fp, "false %d\n", components);
692 fprintf (fp, "colorimage\n");
693
694 curpix = (GLubyte*) pixels;
695 pos = 0;
696 for (i = width*height*components; i>0; i--) {
697 fprintf (fp, "%02hx ", (unsigned short)(*(curpix++)));
698 if (++pos >= 32) {
699 fprintf (fp, "\n");
700 pos = 0;
701 }
702 }
703 if (pos)
704 fprintf (fp, "\n");
705
706 fprintf (fp, "grestore\n");
707 fprintf (fp, "showpage\n");
708 delete [] pixels;
709 fclose (fp);
710
711 // Reset for next time (useful is size change)
712 // fPrintSizeX = -1;
713 // fPrintSizeY = -1;
714
715 return true;
716}
static const G4double pos
GLubyte * grabPixels(int inColor, unsigned int width, unsigned int height)

References G4OpenGLViewer::fPrintColour, G4cerr, G4endl, G4OpenGLViewer::getRealExportHeight(), G4OpenGLViewer::getRealExportWidth(), G4OpenGLViewer::getRealPrintFilename(), G4OpenGLViewer::grabPixels(), G4InuclParticleNames::name(), and pos.

Referenced by G4OpenGLViewer::exportImage().

◆ printVectoredEPS()

bool G4OpenGLViewer::printVectoredEPS ( )
privateinherited

Definition at line 629 of file G4OpenGLViewer.cc.

629 {
630 return printGl2PS();
631}

References G4OpenGLViewer::printGl2PS().

Referenced by G4OpenGLViewer::exportImage().

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

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

void G4OpenGLViewer::ResetView ( )
protectedvirtualinherited

Reimplemented from G4VViewer.

Reimplemented in G4OpenGLXmViewer.

Definition at line 434 of file G4OpenGLViewer.cc.

434 {
436 fRot_sens = 1;
437 fPan_sens = 0.01;
438}
virtual void ResetView()

References G4OpenGLViewer::fPan_sens, G4OpenGLViewer::fRot_sens, and G4VViewer::ResetView().

Referenced by G4OpenGLQtViewer::ResetView(), and G4OpenGLXmViewer::ResetView().

◆ ResizeGLView()

void G4OpenGLViewer::ResizeGLView ( )
protectedinherited

Set the viewport of the scene MAXIMUM SIZE is : GLint dims[2]; glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);

Definition at line 250 of file G4OpenGLViewer.cc.

251{
252 // Check size
253 GLint dims[2];
254 dims[0] = 0;
255 dims[1] = 0;
256
257 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
258
259 if ((dims[0] !=0 ) && (dims[1] !=0)) {
260
261 if (fWinSize_x > (unsigned)dims[0]) {
262 G4cerr << "Try to resize view greater than max X viewport dimension. Desired size "<<fWinSize_x <<" is resize to "<< dims[0] << G4endl;
263 fWinSize_x = dims[0];
264 }
265 if (fWinSize_y > (unsigned)dims[1]) {
266 G4cerr << "Try to resize view greater than max Y viewport dimension. Desired size "<<fWinSize_y <<" is resize to "<< dims[1] << G4endl;
267 fWinSize_y = dims[1];
268 }
269 }
270
271 glViewport(0, 0, fWinSize_x,fWinSize_y);
272
273
274}

References G4OpenGLViewer::fWinSize_x, G4OpenGLViewer::fWinSize_y, G4cerr, and G4endl.

Referenced by G4OpenGLViewer::printGl2PS(), and G4OpenGLViewer::SetView().

◆ ResizeWindow()

void G4OpenGLViewer::ResizeWindow ( unsigned int  aWidth,
unsigned int  aHeight 
)
protectedinherited

◆ rotateScene()

void G4OpenGLViewer::rotateScene ( G4double  dx,
G4double  dy 
)
protectedinherited

Definition at line 1128 of file G4OpenGLViewer.cc.

1129{
1132 } else {
1133 if( dx != 0) {
1134 rotateSceneThetaPhi(dx,0);
1135 }
1136 if( dy != 0) {
1137 rotateSceneThetaPhi(0,dy);
1138 }
1139 }
1140}
void rotateSceneInViewDirection(G4double dx, G4double dy)
void rotateSceneThetaPhi(G4double dx, G4double dy)
RotationStyle GetRotationStyle() const

References G4ViewParameters::freeRotation, G4VViewer::fVP, G4ViewParameters::GetRotationStyle(), G4OpenGLViewer::rotateSceneInViewDirection(), and G4OpenGLViewer::rotateSceneThetaPhi().

Referenced by G4OpenGLXmViewer::rotate_in_phi(), G4OpenGLXmViewer::rotate_in_theta(), and G4OpenGLQtViewer::rotateQtScene().

◆ rotateSceneInViewDirection()

void G4OpenGLViewer::rotateSceneInViewDirection ( G4double  dx,
G4double  dy 
)
privateinherited

Definition at line 1241 of file G4OpenGLViewer.cc.

1242{
1243 if (!fSceneHandler.GetScene()) {
1244 return;
1245 }
1246
1247 G4Vector3D vp;
1248 G4Vector3D up;
1249
1250 G4Vector3D xprime;
1251 G4Vector3D yprime;
1252 G4Vector3D zprime;
1253
1254 G4Vector3D new_vp;
1255 G4Vector3D new_up;
1256
1257 G4Vector3D a1;
1258 G4Vector3D a2;
1259 G4Vector3D delta;
1260 G4Vector3D viewPoint;
1261
1262 dx = dx/100;
1263 dy = dy/100;
1264
1265 //phi spin stuff here
1266
1267 vp = fVP.GetViewpointDirection ().unit();
1268 up = fVP.GetUpVector ().unit();
1269
1270 G4Vector3D zPrimeVector = G4Vector3D(up.y()*vp.z()-up.z()*vp.y(),
1271 up.z()*vp.x()-up.x()*vp.z(),
1272 up.x()*vp.y()-up.y()*vp.x());
1273
1274 viewPoint = vp/fRot_sens + (zPrimeVector*dx - up*dy) ;
1275 new_up = G4Vector3D(viewPoint.y()*zPrimeVector.z()-viewPoint.z()*zPrimeVector.y(),
1276 viewPoint.z()*zPrimeVector.x()-viewPoint.x()*zPrimeVector.z(),
1277 viewPoint.x()*zPrimeVector.y()-viewPoint.y()*zPrimeVector.x());
1278
1279 G4Vector3D new_upUnit = new_up.unit();
1280
1281
1282
1283 fVP.SetUpVector(new_upUnit);
1284 fVP.SetViewAndLights (viewPoint);
1285}
void SetViewAndLights(const G4Vector3D &viewpointDirection)
const G4Vector3D & GetUpVector() const
void SetUpVector(const G4Vector3D &upVector)

References G4OpenGLViewer::fRot_sens, G4VViewer::fSceneHandler, G4VViewer::fVP, G4VSceneHandler::GetScene(), G4ViewParameters::GetUpVector(), G4ViewParameters::GetViewpointDirection(), G4ViewParameters::SetUpVector(), G4ViewParameters::SetViewAndLights(), HepGeom::BasicVector3D< T >::unit(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4OpenGLViewer::rotateScene(), and G4OpenGLViewer::rotateSceneToggle().

◆ rotateSceneThetaPhi()

void G4OpenGLViewer::rotateSceneThetaPhi ( G4double  dx,
G4double  dy 
)
privateinherited

Definition at line 1157 of file G4OpenGLViewer.cc.

1158{
1159 if (!fSceneHandler.GetScene()) {
1160 return;
1161 }
1162
1163 G4Vector3D vp;
1164 G4Vector3D up;
1165
1166 G4Vector3D xprime;
1167 G4Vector3D yprime;
1168 G4Vector3D zprime;
1169
1170 G4double delta_alpha;
1171 G4double delta_theta;
1172
1173 G4Vector3D new_vp;
1174 G4Vector3D new_up;
1175
1176 G4double cosalpha;
1177 G4double sinalpha;
1178
1179 G4Vector3D a1;
1180 G4Vector3D a2;
1181 G4Vector3D delta;
1182 G4Vector3D viewPoint;
1183
1184
1185 //phi spin stuff here
1186
1187 vp = fVP.GetViewpointDirection ().unit ();
1188 up = fVP.GetUpVector ().unit ();
1189
1190 yprime = (up.cross(vp)).unit();
1191 zprime = (vp.cross(yprime)).unit();
1192
1194 delta_alpha = dy * fRot_sens;
1195 delta_theta = -dx * fRot_sens;
1196 } else {
1197 delta_alpha = -dy * fRot_sens;
1198 delta_theta = dx * fRot_sens;
1199 }
1200
1201 delta_alpha *= CLHEP::deg;
1202 delta_theta *= CLHEP::deg;
1203
1204 new_vp = std::cos(delta_alpha) * vp + std::sin(delta_alpha) * zprime;
1205
1206 // to avoid z rotation flipping
1207 // to allow more than 360∞ rotation
1208
1210 new_up = (new_vp.cross(yprime)).unit();
1211 if (new_vp.z()*vp.z() <0) {
1212 new_up.set(new_up.x(),-new_up.y(),new_up.z());
1213 }
1214 } else {
1215 new_up = up;
1216 if (new_vp.z()*vp.z() <0) {
1217 new_up.set(new_up.x(),-new_up.y(),new_up.z());
1218 }
1219 }
1220 fVP.SetUpVector(new_up);
1222 // Rotates by fixed azimuthal angle delta_theta.
1223
1224 cosalpha = new_up.dot (new_vp.unit());
1225 sinalpha = std::sqrt (1. - std::pow (cosalpha, 2));
1226 yprime = (new_up.cross (new_vp.unit())).unit ();
1227 xprime = yprime.cross (new_up);
1228 // Projection of vp on plane perpendicular to up...
1229 a1 = sinalpha * xprime;
1230 // Required new projection...
1231 a2 = sinalpha * (std::cos (delta_theta) * xprime + std::sin (delta_theta) * yprime);
1232 // Required Increment vector...
1233 delta = a2 - a1;
1234 // So new viewpoint is...
1235 viewPoint = new_vp.unit() + delta;
1236
1237 fVP.SetViewAndLights (viewPoint);
1238}
G4bool GetLightsMoveWithCamera() const
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
void set(T x1, T y1, T z1)
T dot(const BasicVector3D< T > &v) const
static constexpr double deg

References HepGeom::BasicVector3D< T >::cross(), CLHEP::deg, HepGeom::BasicVector3D< T >::dot(), G4OpenGLViewer::fRot_sens, G4VViewer::fSceneHandler, G4VViewer::fVP, G4ViewParameters::GetLightsMoveWithCamera(), G4VSceneHandler::GetScene(), G4ViewParameters::GetUpVector(), G4ViewParameters::GetViewpointDirection(), HepGeom::BasicVector3D< T >::set(), G4ViewParameters::SetUpVector(), G4ViewParameters::SetViewAndLights(), HepGeom::BasicVector3D< T >::unit(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4OpenGLViewer::rotateScene(), and G4OpenGLViewer::rotateSceneToggle().

◆ rotateSceneToggle()

void G4OpenGLViewer::rotateSceneToggle ( G4double  dx,
G4double  dy 
)
protectedinherited

◆ SetDefaultViewParameters()

void G4VViewer::SetDefaultViewParameters ( const G4ViewParameters vp)
inherited

◆ setExportFilename()

bool G4OpenGLViewer::setExportFilename ( G4String  name,
G4bool  inc = true 
)
protectedinherited

If name is "" or "!", filename and extension will have the default value. If name is "toto.png", set the name to "toto" and the format to "png". No incremented suffix is added. If name is "toto", set the name to "toto" and the format to default (or current format if specify). If name is the same as previous, do not reset incremented suffix.

Definition at line 1034 of file G4OpenGLViewer.cc.

1034 {
1035 if (name == "!") {
1036 name = "";
1037 }
1038
1039 if (inc) {
1040 if ((name != "") && (fExportFilename != name)) {
1042 }
1043 } else {
1045 }
1046
1047 if (name.size() == 0) {
1048 name = getRealPrintFilename().c_str();
1049 } else {
1050 // guess format by extention
1051 std::string extension = name.substr(name.find_last_of(".") + 1);
1052 // If there is a dot in the name the above might find rubbish, so...
1053 if (extension.size() >= 3 && extension.size() <= 4) { // Possible extension
1054 if (setExportImageFormat(extension, false)) { // Extension found
1055 fExportFilename = name.substr(0,name.find_last_of("."));
1056 } else { // No viable extension found
1057 return false;
1058 }
1059 } else { // Assume name is already the required without-extension part
1061 }
1062 }
1063 return true;
1064}

References G4OpenGLViewer::fExportFilename, G4OpenGLViewer::fExportFilenameIndex, G4OpenGLViewer::getRealPrintFilename(), G4InuclParticleNames::name(), and G4OpenGLViewer::setExportImageFormat().

Referenced by G4OpenGLQtViewer::actionSaveImage(), G4OpenGLQtViewer::exportImage(), G4OpenGLViewer::exportImage(), and G4OpenGLViewerMessenger::SetNewValue().

◆ setExportImageFormat()

bool G4OpenGLViewer::setExportImageFormat ( std::string  format,
bool  quiet = false 
)
inherited

Definition at line 1292 of file G4OpenGLViewer.cc.

1292 {
1293 bool found = false;
1294 std::string list;
1295 for (unsigned int a=0; a<fExportImageFormatVector.size(); a++) {
1296 list +=fExportImageFormatVector.at(a) + " ";
1297
1298 if (fExportImageFormatVector.at(a) == format) {
1299 if (! quiet) {
1300 G4cout << " Changing export format to \"" << format << "\"" << G4endl;
1301 }
1302 if (format != fExportImageFormat) {
1304 fExportImageFormat = format;
1305 }
1306 return true;
1307 }
1308 }
1309 if (! found) {
1310 if (format.size() == 0) {
1311 G4cout << " Current formats availables are : " << list << G4endl;
1312 } else {
1313 G4cerr << " Format \"" << format << "\" is not available for the selected viewer. Current formats availables are : " << list << G4endl;
1314 }
1315 }
1316 return false;
1317}

References G4OpenGLViewer::fExportFilenameIndex, G4OpenGLViewer::fExportImageFormat, G4OpenGLViewer::fExportImageFormatVector, G4cerr, G4cout, and G4endl.

Referenced by G4OpenGLViewer::exportImage(), G4OpenGLImmediateQtViewer::initializeGL(), G4OpenGLStoredQtViewer::initializeGL(), G4OpenGLViewer::setExportFilename(), and G4OpenGLViewerMessenger::SetNewValue().

◆ setExportSize()

void G4OpenGLViewer::setExportSize ( G4int  X,
G4int  Y 
)
protectedinherited

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

void G4OpenGLViewer::SetView ( )
protectedvirtualinherited

Implements G4VViewer.

Reimplemented in G4OpenGLWin32Viewer, and G4OpenGLXViewer.

Definition at line 277 of file G4OpenGLViewer.cc.

277 {
278 // if getting pick infos, should not resize the view.
279 if (fIsGettingPickInfos) return;
280
281 if (!fSceneHandler.GetScene()) {
282 return;
283 }
284 // Calculates view representation based on extent of object being
285 // viewed and (initial) viewpoint. (Note: it can change later due
286 // to user interaction via visualization system's GUI.)
287
288 // Lighting.
289 GLfloat lightPosition [4];
290 lightPosition [0] = fVP.GetActualLightpointDirection().x();
291 lightPosition [1] = fVP.GetActualLightpointDirection().y();
292 lightPosition [2] = fVP.GetActualLightpointDirection().z();
293 lightPosition [3] = 0.;
294 // Light position is "true" light direction, so must come after gluLookAt.
295 GLfloat ambient [] = { 0.2f, 0.2f, 0.2f, 1.f};
296 GLfloat diffuse [] = { 0.8f, 0.8f, 0.8f, 1.f};
297 glEnable (GL_LIGHT0);
298 glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
299 glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
300
301 G4double ratioX = 1;
302 G4double ratioY = 1;
303 if (fWinSize_y > fWinSize_x) {
304 ratioX = ((G4double)fWinSize_y) / ((G4double)fWinSize_x);
305 }
306 if (fWinSize_x > fWinSize_y) {
307 ratioY = ((G4double)fWinSize_x) / ((G4double)fWinSize_y);
308 }
309
310 // Get radius of scene, etc.
311 // Note that this procedure properly takes into account zoom, dolly and pan.
312 const G4Point3D targetPoint
316 if(radius<=0.) radius = 1.;
317 const G4double cameraDistance = fVP.GetCameraDistance (radius);
318 const G4Point3D cameraPosition =
319 targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
320 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
321 const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
322 const GLdouble right = fVP.GetFrontHalfHeight (pnear, radius) * ratioY;
323 const GLdouble left = -right;
324 const GLdouble top = fVP.GetFrontHalfHeight (pnear, radius) * ratioX;
325 const GLdouble bottom = -top;
326
327 // FIXME
328 ResizeGLView();
329 //SHOULD SetWindowsSizeHint()...
330
331 glMatrixMode (GL_PROJECTION); // set up Frustum.
332 glLoadIdentity();
333
334 const G4Vector3D scaleFactor = fVP.GetScaleFactor();
335 glScaled(scaleFactor.x(),scaleFactor.y(),scaleFactor.z());
336
337 if (fVP.GetFieldHalfAngle() == 0.) {
338 g4GlOrtho (left, right, bottom, top, pnear, pfar);
339 }
340 else {
341 g4GlFrustum (left, right, bottom, top, pnear, pfar);
342 }
343
344 glMatrixMode (GL_MODELVIEW); // apply further transformations to scene.
345 glLoadIdentity();
346
347 const G4Normal3D& upVector = fVP.GetUpVector ();
348 G4Point3D gltarget;
349 if (cameraDistance > 1.e-6 * radius) {
350 gltarget = targetPoint;
351 }
352 else {
353 gltarget = targetPoint - radius * fVP.GetViewpointDirection().unit();
354 }
355
356 const G4Point3D& pCamera = cameraPosition; // An alias for brevity.
357
358 g4GluLookAt (pCamera.x(), pCamera.y(), pCamera.z(), // Viewpoint.
359 gltarget.x(), gltarget.y(), gltarget.z(), // Target point.
360 upVector.x(), upVector.y(), upVector.z()); // Up vector.
361 // Light position is "true" light direction, so must come after gluLookAt.
362 glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
363
364 // The idea is to use back-to-back clipping planes. This can cut an object
365 // down to just a few pixels, which can make it difficult to see. So, for
366 // now, comment this out and use the generic (Boolean) method, via
367 // G4VSolid* G4OpenGLSceneHandler::CreateSectionSolid ()
368 // { return G4VSceneHandler::CreateSectionSolid(); }
369// if (fVP.IsSection () ) { // pair of back to back clip planes.
370// const G4Plane3D& sp = fVP.GetSectionPlane ();
371// double sArray[4];
372// sArray[0] = sp.a();
373// sArray[1] = sp.b();
374// sArray[2] = sp.c();
375// sArray[3] = sp.d() + radius * 1.e-05;
376// glClipPlane (GL_CLIP_PLANE0, sArray);
377// glEnable (GL_CLIP_PLANE0);
378// sArray[0] = -sp.a();
379// sArray[1] = -sp.b();
380// sArray[2] = -sp.c();
381// sArray[3] = -sp.d() + radius * 1.e-05;
382// glClipPlane (GL_CLIP_PLANE1, sArray);
383// glEnable (GL_CLIP_PLANE1);
384// } else {
385// glDisable (GL_CLIP_PLANE0);
386// glDisable (GL_CLIP_PLANE1);
387// }
388
389 // What we call intersection of cutaways is easy in OpenGL. You
390 // just keep cutting. Unions are more tricky - you have to have
391 // multiple passes and this is handled in
392 // G4OpenGLImmediate/StoredViewer::ProcessView.
393 const G4Planes& cutaways = fVP.GetCutawayPlanes();
394 size_t nPlanes = cutaways.size();
395 if (fVP.IsCutaway() &&
397 nPlanes > 0) {
398 double a[4];
399 a[0] = cutaways[0].a();
400 a[1] = cutaways[0].b();
401 a[2] = cutaways[0].c();
402 a[3] = cutaways[0].d();
403 glClipPlane (GL_CLIP_PLANE2, a);
404 glEnable (GL_CLIP_PLANE2);
405 if (nPlanes > 1) {
406 a[0] = cutaways[1].a();
407 a[1] = cutaways[1].b();
408 a[2] = cutaways[1].c();
409 a[3] = cutaways[1].d();
410 glClipPlane (GL_CLIP_PLANE3, a);
411 glEnable (GL_CLIP_PLANE3);
412 }
413 if (nPlanes > 2) {
414 a[0] = cutaways[2].a();
415 a[1] = cutaways[2].b();
416 a[2] = cutaways[2].c();
417 a[3] = cutaways[2].d();
418 glClipPlane (GL_CLIP_PLANE4, a);
419 glEnable (GL_CLIP_PLANE4);
420 }
421 } else {
422 glDisable (GL_CLIP_PLANE2);
423 glDisable (GL_CLIP_PLANE3);
424 glDisable (GL_CLIP_PLANE4);
425 }
426
427 // Background.
429
430}
void g4GlFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
void g4GluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
const G4Vector3D & GetScaleFactor() const
G4Vector3D & GetActualLightpointDirection()

References G4OpenGLViewer::background, G4ViewParameters::cutawayIntersection, G4OpenGLViewer::fIsGettingPickInfos, G4VViewer::fSceneHandler, G4VViewer::fVP, G4OpenGLViewer::fWinSize_x, G4OpenGLViewer::fWinSize_y, G4OpenGLViewer::g4GlFrustum(), G4OpenGLViewer::g4GlOrtho(), G4OpenGLViewer::g4GluLookAt(), G4ViewParameters::GetActualLightpointDirection(), G4ViewParameters::GetBackgroundColour(), G4ViewParameters::GetCameraDistance(), G4ViewParameters::GetCurrentTargetPoint(), G4ViewParameters::GetCutawayMode(), G4ViewParameters::GetCutawayPlanes(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4ViewParameters::GetFarDistance(), G4ViewParameters::GetFieldHalfAngle(), G4ViewParameters::GetFrontHalfHeight(), G4ViewParameters::GetNearDistance(), G4ViewParameters::GetScaleFactor(), G4VSceneHandler::GetScene(), G4Scene::GetStandardTargetPoint(), G4ViewParameters::GetUpVector(), G4ViewParameters::GetViewpointDirection(), G4ViewParameters::IsCutaway(), G4OpenGLViewer::ResizeGLView(), HepGeom::BasicVector3D< T >::unit(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4OpenGLImmediateQtViewer::paintGL(), G4OpenGLStoredQtViewer::paintGL(), G4OpenGLWin32Viewer::SetView(), and G4OpenGLXViewer::SetView().

◆ SetViewParameters()

void G4VViewer::SetViewParameters ( const G4ViewParameters vp)
inherited

◆ ShowView()

void G4VViewer::ShowView ( void  )
virtualinherited

◆ sizeHasChanged()

G4bool G4OpenGLViewer::sizeHasChanged ( )
protectedinherited

◆ TOSelected()

virtual G4bool G4OpenGLStoredViewer::TOSelected ( size_t  )
inlineprotectedvirtual

Reimplemented in G4OpenGLStoredQtViewer.

Definition at line 68 of file G4OpenGLStoredViewer.hh.

68{return true;}

Referenced by DrawDisplayLists().

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

Field Documentation

◆ antialiasing_enabled

G4bool G4OpenGLViewer::antialiasing_enabled
protectedinherited

◆ background

G4Colour G4OpenGLViewer::background
protectedinherited

◆ fDefaultExportFilename

G4String G4OpenGLViewer::fDefaultExportFilename
privateinherited

Definition at line 220 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLViewer::G4OpenGLViewer().

◆ fDefaultExportImageFormat

std::string G4OpenGLViewer::fDefaultExportImageFormat
protectedinherited

Definition at line 210 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLQtViewer::actionSaveImage().

◆ fDefaultVP

G4ViewParameters G4VViewer::fDefaultVP
protectedinherited

◆ fDepthTestEnable

G4bool G4OpenGLStoredViewer::fDepthTestEnable
protected

Definition at line 70 of file G4OpenGLStoredViewer.hh.

Referenced by DrawDisplayLists().

◆ fExportFilename

G4String G4OpenGLViewer::fExportFilename
privateinherited

◆ fExportFilenameIndex

int G4OpenGLViewer::fExportFilenameIndex
protectedinherited

◆ fExportImageFormat

std::string G4OpenGLViewer::fExportImageFormat
protectedinherited

◆ fExportImageFormatVector

std::vector< std::string > G4OpenGLViewer::fExportImageFormatVector
protectedinherited

◆ fG4OpenGLStoredSceneHandler

G4OpenGLStoredSceneHandler& G4OpenGLStoredViewer::fG4OpenGLStoredSceneHandler
protected

◆ fGL2PSAction

G4OpenGL2PSAction* G4OpenGLViewer::fGL2PSAction
protectedinherited

◆ fGl2psDefaultLineWith

int G4OpenGLViewer::fGl2psDefaultLineWith
privateinherited

Definition at line 222 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLViewer::printGl2PS().

◆ fGl2psDefaultPointSize

int G4OpenGLViewer::fGl2psDefaultPointSize
privateinherited

Definition at line 223 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLViewer::printGl2PS().

◆ fGlViewInitialized

bool G4OpenGLViewer::fGlViewInitialized
privateinherited

Definition at line 224 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLViewer::InitializeGLView().

◆ fIsGettingPickInfos

bool G4OpenGLViewer::fIsGettingPickInfos
privateinherited

Definition at line 241 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLViewer::GetPickDetails(), and G4OpenGLViewer::SetView().

◆ fLastVP

G4ViewParameters G4OpenGLStoredViewer::fLastVP
protected

◆ fName

G4String G4VViewer::fName
protectedinherited

◆ fNeedKernelVisit

G4bool G4VViewer::fNeedKernelVisit
protectedinherited

◆ fOldDisplayListColor

G4Colour G4OpenGLStoredViewer::fOldDisplayListColor
protected

Definition at line 71 of file G4OpenGLStoredViewer.hh.

◆ fOpenGLSceneHandler

G4OpenGLSceneHandler& G4OpenGLViewer::fOpenGLSceneHandler
protectedinherited

Definition at line 197 of file G4OpenGLViewer.hh.

Referenced by G4OpenGLViewer::GetPickDetails().

◆ fPan_sens

G4double G4OpenGLViewer::fPan_sens
protectedinherited

◆ fPointSize

G4float G4OpenGLViewer::fPointSize
privateinherited

Definition at line 218 of file G4OpenGLViewer.hh.

◆ fPrintColour

G4bool G4OpenGLViewer::fPrintColour
protectedinherited

◆ fPrintSizeX

G4int G4OpenGLViewer::fPrintSizeX
protectedinherited

◆ fPrintSizeY

G4int G4OpenGLViewer::fPrintSizeY
protectedinherited

◆ fRot_sens

G4double G4OpenGLViewer::fRot_sens
protectedinherited

◆ fSceneHandler

G4VSceneHandler& G4VViewer::fSceneHandler
protectedinherited

◆ fShortName

G4String G4VViewer::fShortName
protectedinherited

◆ fSizeHasChanged

G4bool G4OpenGLViewer::fSizeHasChanged
privateinherited

◆ fVectoredPs

G4bool G4OpenGLViewer::fVectoredPs
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(), 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(), 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().

◆ fWinSize_x

unsigned int G4OpenGLViewer::fWinSize_x
protectedinherited

◆ fWinSize_y

unsigned int G4OpenGLViewer::fWinSize_y
protectedinherited

◆ haloing_enabled

G4bool G4OpenGLViewer::haloing_enabled
protectedinherited

◆ transparency_enabled

G4bool G4OpenGLViewer::transparency_enabled
protectedinherited

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