Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLViewer Class Reference

#include <G4OpenGLViewer.hh>

+ Inheritance diagram for G4OpenGLViewer:

Public Member Functions

void ClearView ()
 
void ClearViewWithoutFlush ()
 
virtual bool exportImage (std::string name="", int width=-1, int height=-1)
 
bool setExportImageFormat (std::string format, bool quiet=false)
 
- Public Member Functions inherited from G4VViewer
 G4VViewer (G4VSceneHandler &, G4int id, const G4String &name="")
 
virtual ~G4VViewer ()
 
virtual void Initialise ()
 
virtual void DrawView ()=0
 
void RefreshView ()
 
virtual void ShowView ()
 
virtual void FinishView ()
 
std::vector< G4ThreeVectorComputeFlyThrough (G4Vector3D *)
 
SceneTreeSceneAccessSceneTreeScene ()
 
G4SceneTreeItemAccessSceneTree ()
 
void UpdateGUISceneTree ()
 
const G4StringGetName () const
 
const G4StringGetShortName () const
 
void SetName (const G4String &)
 
G4int GetViewId () const
 
G4VSceneHandlerGetSceneHandler () const
 
const G4ViewParametersGetViewParameters () const
 
const G4ViewParametersGetDefaultViewParameters () const
 
G4double GetKernelVisitElapsedTimeSeconds () const
 
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers () const
 
void SetViewParameters (const G4ViewParameters &vp)
 
void SetDefaultViewParameters (const G4ViewParameters &vp)
 
const G4VisAttributesGetApplicableVisAttributes (const G4VisAttributes *) const
 
void SetNeedKernelVisit (G4bool need)
 
void NeedKernelVisit ()
 
void ProcessView ()
 

Protected Member Functions

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

Protected Attributes

G4bool fPrintColour
 
G4bool fVectoredPs
 
G4OpenGLSceneHandlerfOpenGLSceneHandler
 
G4Colour background
 
G4bool transparency_enabled
 
G4bool antialiasing_enabled
 
G4bool haloing_enabled
 
G4gl2psfGL2PSAction
 
G4double fRot_sens
 
G4double fPan_sens
 
unsigned int fWinSize_x
 
unsigned int fWinSize_y
 
std::vector< std::string > fExportImageFormatVector
 
std::string fDefaultExportImageFormat
 
std::string fExportImageFormat
 
int fExportFilenameIndex
 
G4int fPrintSizeX
 
G4int fPrintSizeY
 
- Protected Attributes inherited from G4VViewer
G4VSceneHandlerfSceneHandler
 
G4int fViewId
 
G4String fName
 
G4String fShortName
 
G4ViewParameters fVP
 
G4ViewParameters fDefaultVP
 
G4double fKernelVisitElapsedTimeSeconds = 999.
 
SceneTreeScene fSceneTreeScene
 
G4SceneTreeItem fSceneTree
 
G4bool fNeedKernelVisit
 

Friends

class G4OpenGLSceneHandler
 
class G4OpenGLImmediateSceneHandler
 
class G4OpenGLStoredSceneHandler
 
class G4OpenGLFileSceneHandler
 
class G4OpenGLViewerMessenger
 

Detailed Description

Definition at line 95 of file G4OpenGLViewer.hh.

Constructor & Destructor Documentation

◆ G4OpenGLViewer()

G4OpenGLViewer::G4OpenGLViewer ( G4OpenGLSceneHandler & scene)
protected

Definition at line 58 of file G4OpenGLViewer.cc.

58 :
59G4VViewer (scene, -1),
60fPrintColour (true),
61fVectoredPs (true),
63background (G4Colour(0.,0.,0.)),
66haloing_enabled (false),
67fRot_sens(1.),
68fPan_sens(0.01),
69fWinSize_x(0),
70fWinSize_y(0),
74fPrintSizeX(-1),
75fPrintSizeY(-1),
76fPointSize (0),
77fDefaultExportFilename("G4OpenGL"),
78fSizeHasChanged(0),
79fGl2psDefaultLineWith(1),
80fGl2psDefaultPointSize(2),
81fGlViewInitialized(false),
82fIsGettingPickInfos(false)
83{
84 // Make changes to view parameters for OpenGL...
85 fVP.SetAutoRefresh(true);
87 fGL2PSAction = new G4gl2ps();
88 tools_gl2ps_gl_funcs_t _funcs = {
89 (tools_glIsEnabled_func)glIsEnabled,
90 (tools_glBegin_func)glBegin,
91 (tools_glEnd_func)glEnd,
92 (tools_glGetFloatv_func)glGetFloatv,
93 (tools_glVertex3f_func)glVertex3f,
94 (tools_glGetBooleanv_func)glGetBooleanv,
95 (tools_glGetIntegerv_func)glGetIntegerv,
96 (tools_glRenderMode_func)glRenderMode,
97 (tools_glFeedbackBuffer_func)glFeedbackBuffer,
98 (tools_glPassThrough_func)glPassThrough
99 };
101
102 // add supported export image format
107
108 // Change the default name
109 fExportFilename += fDefaultExportFilename + "_" + GetShortName().data();
110
111 // glClearColor (0.0, 0.0, 0.0, 0.0);
112 // glClearDepth (1.0);
113 // glDisable (GL_BLEND);
114 // glDisable (GL_LINE_SMOOTH);
115 // glDisable (GL_POLYGON_SMOOTH);
116
117}
unsigned int fWinSize_y
std::string fExportImageFormat
std::string fDefaultExportImageFormat
void addExportImageFormat(std::string format)
G4bool antialiasing_enabled
G4bool transparency_enabled
G4gl2ps * fGL2PSAction
G4OpenGLSceneHandler & fOpenGLSceneHandler
unsigned int fWinSize_x
G4ViewParameters fDefaultVP
Definition G4VViewer.hh:258
const G4String & GetShortName() const
G4ViewParameters fVP
Definition G4VViewer.hh:257
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
Definition G4VViewer.cc:49
void SetAutoRefresh(G4bool)
void setOpenGLFunctions(tools_gl2ps_gl_funcs_t *)
Definition G4gl2ps.cc:73
tools_GLint(* tools_glRenderMode_func)(tools_GLenum)
Definition gl2ps_def.h:195
void(* tools_glVertex3f_func)(tools_GLfloat, tools_GLfloat, tools_GLfloat)
Definition gl2ps_def.h:192
void(* tools_glGetFloatv_func)(tools_GLenum, tools_GLfloat *)
Definition gl2ps_def.h:191
void(* tools_glBegin_func)(tools_GLenum)
Definition gl2ps_def.h:189
void(* tools_glFeedbackBuffer_func)(tools_GLsizei, tools_GLenum, tools_GLfloat *)
Definition gl2ps_def.h:196
void(* tools_glPassThrough_func)(tools_GLfloat)
Definition gl2ps_def.h:197
void(* tools_glGetBooleanv_func)(tools_GLenum, tools_GLboolean *)
Definition gl2ps_def.h:193
void(* tools_glEnd_func)()
Definition gl2ps_def.h:190
void(* tools_glGetIntegerv_func)(tools_GLenum, tools_GLint *)
Definition gl2ps_def.h:194
tools_GLboolean(* tools_glIsEnabled_func)(tools_GLenum)
Definition gl2ps_def.h:188

◆ ~G4OpenGLViewer()

G4OpenGLViewer::~G4OpenGLViewer ( )
protectedvirtual

Definition at line 119 of file G4OpenGLViewer.cc.

120{
121 delete fGL2PSAction;
122}

Member Function Documentation

◆ addExportImageFormat()

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

Definition at line 1243 of file G4OpenGLViewer.cc.

1243 {
1244 fExportImageFormatVector.push_back(format);
1245}
std::vector< std::string > fExportImageFormatVector

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

◆ ChangeLineWidth()

void G4OpenGLViewer::ChangeLineWidth ( G4double width)
protected

Change LineSize on gl2ps if needed

Definition at line 756 of file G4OpenGLViewer.cc.

756 {
757
758 if (isGl2psWriting()) {
759 fGL2PSAction->setLineWidth(int(width));
760 } else {
761 glLineWidth (width);
762 }
763}
G4bool isGl2psWriting()
void setLineWidth(int)
Definition G4gl2ps.cc:90

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

◆ ChangePointSize()

void G4OpenGLViewer::ChangePointSize ( G4double size)
protected

Change PointSize on gl2ps if needed

Definition at line 744 of file G4OpenGLViewer.cc.

744 {
745
746 if (isGl2psWriting()) {
747 fGL2PSAction->setPointSize(int(size));
748 } else {
749 glPointSize (size);
750 }
751}
void setPointSize(int)
Definition G4gl2ps.cc:95

Referenced by G4OpenGLSceneHandler::AddPrimitive().

◆ ClearView()

◆ ClearViewWithoutFlush()

void G4OpenGLViewer::ClearViewWithoutFlush ( )

Definition at line 161 of file G4OpenGLViewer.cc.

161 {
162 // Ready for clear ?
163 // See : http://lists.apple.com/archives/mac-opengl/2012/Jul/msg00038.html
164 if(!isFramebufferReady()) {
165 return;
166 }
167
168 glClearColor (background.GetRed(),
171 1.);
172 glClearDepth (1.0);
173 //Below line does not compile with Mesa includes.
174 //glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
175 glClear (GL_COLOR_BUFFER_BIT);
176 glClear (GL_DEPTH_BUFFER_BIT);
177 glClear (GL_STENCIL_BUFFER_BIT);
178}
G4double GetBlue() const
Definition G4Colour.hh:154
G4double GetRed() const
Definition G4Colour.hh:152
G4double GetGreen() const
Definition G4Colour.hh:153

Referenced by ClearView().

◆ CreateFontLists()

virtual void G4OpenGLViewer::CreateFontLists ( )
inlineprotectedvirtual

◆ DrawText()

void G4OpenGLViewer::DrawText ( const G4Text & g4text)
protectedvirtual

Reimplemented in G4OpenGLQtViewer, and G4OpenGLXViewer.

Definition at line 704 of file G4OpenGLViewer.cc.

705{
706 // gl2ps or GL window ?
707 if (isGl2psWriting()) {
708
710 G4double size = fSceneHandler.GetMarkerSize(g4text,sizeType);
711 G4Point3D position = g4text.GetPosition();
712
713 G4String textString = g4text.GetText();
714
715 glRasterPos3d(position.x(),position.y(),position.z());
716 GLint align = GL2PS_TEXT_B;
717
718 switch (g4text.GetLayout()) {
719 case G4Text::left: align = GL2PS_TEXT_BL; break;
720 case G4Text::centre: align = GL2PS_TEXT_B; break;
721 case G4Text::right: align = GL2PS_TEXT_BR;
722 }
723
724 fGL2PSAction->addTextOpt(textString.c_str(),"Times-Roman",GLshort(size),align,0);
725
726 } else {
727
728 static G4int callCount = 0;
729 ++callCount;
730 //if (callCount <= 10 || callCount%100 == 0) {
731 if (callCount <= 1) {
732 G4cout <<
733 "G4OpenGLViewer::DrawText: Not implemented for \""
734 << fName <<
735 "\"\n Called with "
736 << g4text
737 << G4endl;
738 }
739 }
740}
#define GL2PS_TEXT_BL
#define GL2PS_TEXT_BR
#define GL2PS_TEXT_B
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
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 &)
G4VSceneHandler & fSceneHandler
Definition G4VViewer.hh:253
G4String fName
Definition G4VViewer.hh:255
void addTextOpt(const char *, const char *, tools_GLshort, tools_GLint, tools_GLfloat)
Definition G4gl2ps.cc:100

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

◆ exportImage()

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

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 773 of file G4OpenGLViewer.cc.

773 {
774
775 if (! setExportFilename(name)) {
776 return false;
777 }
778
779 if ((width != -1) && (height != -1)) {
780 setExportSize(width, height);
781 }
782
783 if (fExportImageFormat == "eps") {
785 } else if (fExportImageFormat == "ps") {
787 } else if (fExportImageFormat == "svg") {
789 } else if (fExportImageFormat == "pdf") {
791 } else {
792 setExportImageFormat(fExportImageFormat,true); // will display a message if this format is not correct for the current viewer
793 return false;
794 }
795
796 bool res;
797
798 // Change the LC_NUMERIC value in order to have "." separtor and not ","
799 // This case is only useful for French, Canadien...
800 size_t len = strlen(setlocale(LC_NUMERIC,NULL));
801 char* oldLocale = (char*)(malloc(len+1));
802 if(oldLocale!=NULL) strncpy(oldLocale,setlocale(LC_NUMERIC,NULL),len);
803 setlocale(LC_NUMERIC,"C");
804
805 if (((fExportImageFormat == "eps") || (fExportImageFormat == "ps")) && (!fVectoredPs)) {
806 res = printNonVectoredEPS();
807 } else {
808 res = printVectoredEPS();
809 }
810
811 // restore the local
812 if (oldLocale) {
813 setlocale(LC_NUMERIC,oldLocale);
814 free(oldLocale);
815 }
816
817 if (res == false) {
818 G4cerr << "Error saving file... " << getRealPrintFilename().c_str() << G4endl;
819 } else {
820 G4cout << "File " << getRealPrintFilename().c_str() << " size: " << getRealExportWidth() << "x" << getRealExportHeight() << " has been saved " << G4endl;
821
822 // increment index if necessary
823 if ( fExportFilenameIndex != -1) {
825 }
826 }
827
828 return res;
829}
G4GLOB_DLL std::ostream G4cerr
bool setExportImageFormat(std::string format, bool quiet=false)
bool setExportFilename(G4String name, G4bool inc=true)
void setExportSize(G4int, G4int)
std::string getRealPrintFilename()
void setExportImageFormat_SVG()
Definition G4gl2ps.hh:49
void setExportImageFormat_PDF()
Definition G4gl2ps.hh:48
void setExportImageFormat_PS()
Definition G4gl2ps.hh:45
void setExportImageFormat_EPS()
Definition G4gl2ps.hh:46

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

◆ g4GlFrustum()

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

Definition at line 1422 of file G4OpenGLViewer.cc.

1422 {
1423 // glFrustum (left, right, bottom, top, near, far);
1424
1425 GLdouble deltaX = right - left;
1426 GLdouble deltaY = top - bottom;
1427 GLdouble deltaZ = zFar - zNear;
1428
1429 GLdouble a = 2.0f * zNear / deltaX;
1430 GLdouble b = 2.0f * zNear / deltaY;
1431 GLdouble c = (right + left) / deltaX;
1432 GLdouble d = (top + bottom) / deltaY;
1433 GLdouble e = -(zFar + zNear) / (zFar - zNear);
1434 GLdouble f = -2.0f * zFar * zNear / deltaZ;
1435
1436 GLdouble proj[16] = {
1437 a, 0, 0, 0,
1438 0, b, 0, 0,
1439 c, d, e, -1.0f,
1440 0, 0, f, 0
1441 };
1442
1443 glMultMatrixd(proj);
1444
1445}

Referenced by SetView().

◆ g4GlOrtho()

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

Definition at line 1400 of file G4OpenGLViewer.cc.

1400 {
1401 // glOrtho (left, right, bottom, top, near, far);
1402
1403 GLdouble a = 2.0 / (right - left);
1404 GLdouble b = 2.0 / (top - bottom);
1405 GLdouble c = -2.0 / (zFar - zNear);
1406
1407 GLdouble tx = - (right + left)/(right - left);
1408 GLdouble ty = - (top + bottom)/(top - bottom);
1409 GLdouble tz = - (zFar + zNear)/(zFar - zNear);
1410
1411 GLdouble ortho[16] = {
1412 a, 0, 0, 0,
1413 0, b, 0, 0,
1414 0, 0, c, 0,
1415 tx, ty, tz, 1
1416 };
1417 glMultMatrixd(ortho);
1418
1419}

Referenced by G4OpenGLImmediateSceneHandler::BeginPrimitives2D(), G4OpenGLStoredViewer::DrawDisplayLists(), and SetView().

◆ g4GluLookAt()

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

Definition at line 1320 of file G4OpenGLViewer.cc.

1324{
1325 GLdouble mat[16];
1326 GLdouble x[3], y[3], z[3];
1327 GLdouble mag;
1328
1329 /* Make rotation matrix */
1330
1331 /* Z vector */
1332 z[0] = eyex - centerx;
1333 z[1] = eyey - centery;
1334 z[2] = eyez - centerz;
1335 mag = std::sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
1336 if (mag) { /* mpichler, 19950515 */
1337 z[0] /= mag;
1338 z[1] /= mag;
1339 z[2] /= mag;
1340 }
1341
1342 /* Y vector */
1343 y[0] = upx;
1344 y[1] = upy;
1345 y[2] = upz;
1346
1347 /* X vector = Y cross Z */
1348 x[0] = y[1] * z[2] - y[2] * z[1];
1349 x[1] = -y[0] * z[2] + y[2] * z[0];
1350 x[2] = y[0] * z[1] - y[1] * z[0];
1351
1352 /* Recompute Y = Z cross X */
1353 y[0] = z[1] * x[2] - z[2] * x[1];
1354 y[1] = -z[0] * x[2] + z[2] * x[0];
1355 y[2] = z[0] * x[1] - z[1] * x[0];
1356
1357 /* mpichler, 19950515 */
1358 /* cross product gives area of parallelogram, which is < 1.0 for
1359 * non-perpendicular unit-length vectors; so normalize x, y here
1360 */
1361
1362 mag = std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
1363 if (mag) {
1364 x[0] /= mag;
1365 x[1] /= mag;
1366 x[2] /= mag;
1367 }
1368
1369 mag = std::sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
1370 if (mag) {
1371 y[0] /= mag;
1372 y[1] /= mag;
1373 y[2] /= mag;
1374 }
1375
1376#define M(row,col) mat[col*4+row]
1377 M(0, 0) = x[0];
1378 M(0, 1) = x[1];
1379 M(0, 2) = x[2];
1380 M(0, 3) = 0.0;
1381 M(1, 0) = y[0];
1382 M(1, 1) = y[1];
1383 M(1, 2) = y[2];
1384 M(1, 3) = 0.0;
1385 M(2, 0) = z[0];
1386 M(2, 1) = z[1];
1387 M(2, 2) = z[2];
1388 M(2, 3) = 0.0;
1389 M(3, 0) = 0.0;
1390 M(3, 1) = 0.0;
1391 M(3, 2) = 0.0;
1392 M(3, 3) = 1.0;
1393#undef M
1394 glMultMatrixd(mat);
1395
1396 /* Translate Eye to Origin */
1397 glTranslated(-eyex, -eyey, -eyez);
1398}
#define M(row, col)

Referenced by SetView().

◆ g4GluPickMatrix()

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

Definition at line 1278 of file G4OpenGLViewer.cc.

1280 {
1281 GLdouble mat[16];
1282 GLdouble sx, sy;
1283 GLdouble tx, ty;
1284
1285 sx = viewport[2] / width;
1286 sy = viewport[3] / height;
1287 tx = (viewport[2] + 2.0 * (viewport[0] - x)) / width;
1288 ty = (viewport[3] + 2.0 * (viewport[1] - y)) / height;
1289
1290#define M(row, col) mat[col*4+row]
1291 M(0, 0) = sx;
1292 M(0, 1) = 0.0;
1293 M(0, 2) = 0.0;
1294 M(0, 3) = tx;
1295 M(1, 0) = 0.0;
1296 M(1, 1) = sy;
1297 M(1, 2) = 0.0;
1298 M(1, 3) = ty;
1299 M(2, 0) = 0.0;
1300 M(2, 1) = 0.0;
1301 M(2, 2) = 1.0;
1302 M(2, 3) = 0.0;
1303 M(3, 0) = 0.0;
1304 M(3, 1) = 0.0;
1305 M(3, 2) = 0.0;
1306 M(3, 3) = 1.0;
1307#undef M
1308
1309 glMultMatrixd(mat);
1310}

Referenced by GetPickDetails().

◆ GetPickDetails()

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

Definition at line 434 of file G4OpenGLViewer.cc.

435{
436 static std::vector < G4OpenGLViewerPickMap* > pickMapVector;
437 for (auto pickMap: pickMapVector) {
438 delete pickMap;
439 }
440 pickMapVector.clear();
441
442 const G4int BUFSIZE = 512;
443 GLuint selectBuffer[BUFSIZE];
444 glSelectBuffer(BUFSIZE, selectBuffer);
445 glRenderMode(GL_SELECT);
446 glInitNames();
447 glPushName(0);
448 glMatrixMode(GL_PROJECTION);
449 G4double currentProjectionMatrix[16];
450 glGetDoublev(GL_PROJECTION_MATRIX, currentProjectionMatrix);
451 glPushMatrix();
452 glLoadIdentity();
453 GLint viewport[4];
454 glGetIntegerv(GL_VIEWPORT, viewport);
455/* G4cout
456 << "viewport, x,y: "
457 << viewport[0] << ',' << viewport[1] << ',' << viewport[2] << ',' << viewport[3]
458 << ", " << x << ',' << y
459 << G4endl;
460*/
461 fIsGettingPickInfos = true;
462 // Define 5x5 pixel pick area
463 g4GluPickMatrix(x, viewport[3] - y, 5., 5., viewport);
464 glMultMatrixd(currentProjectionMatrix);
465 glMatrixMode(GL_MODELVIEW);
466 DrawView();
467 GLint hits = glRenderMode(GL_RENDER);
468 fIsGettingPickInfos = false;
469 if (hits < 0) {
470 G4cout << "Too many hits. Zoom in to reduce overlaps." << G4endl;
471 goto restoreMatrices;
472 }
473 if (hits > 0) {
474 GLuint* p = selectBuffer;
475 for (GLint i = 0; i < hits; ++i) {
476 GLuint nnames = *p++;
477 // This bit of debug code or...
478 //GLuint zmin = *p++;
479 //GLuint zmax = *p++;
480 //G4cout << "Hit " << i << ": " << nnames << " names"
481 // << "\nzmin: " << zmin << ", zmax: " << zmax << G4endl;
482 // ...just increment the pointer
483 p++;
484 p++;
485 for (GLuint j = 0; j < nnames; ++j) {
486 GLuint name = *p++;
487 std::map<GLuint, G4AttHolder*>::iterator iter =
488 fOpenGLSceneHandler.fPickMap.find(name);
489 if (iter != fOpenGLSceneHandler.fPickMap.end()) {
490 G4AttHolder* attHolder = iter->second;
491 if(attHolder && attHolder->GetAttDefs().size()) {
492 for (size_t iAtt = 0;
493 iAtt < attHolder->GetAttDefs().size(); ++iAtt) {
494 std::ostringstream oss;
495 oss << G4AttCheck(attHolder->GetAttValues()[iAtt],
496 attHolder->GetAttDefs()[iAtt]);
498// G4cout
499// << "i,j, attHolder->GetAttDefs().size(): "
500// << i << ',' << j
501// << ", " << attHolder->GetAttDefs().size()
502// << G4endl;
503// G4cout << "G4OpenGLViewer::GetPickDetails: " << oss.str() << G4endl;
504 pickMap->addAttributes(oss.str());
505 pickMap->setHitNumber(i);
506 pickMap->setSubHitNumber(j);
507 pickMap->setPickName(name);
508 pickMapVector.push_back(pickMap);
509 }
510 }
511 }
512 }
513 }
514 }
515
516restoreMatrices:
517 glMatrixMode(GL_PROJECTION);
518 glPopMatrix();
519 glMatrixMode(GL_MODELVIEW);
520
521 return pickMapVector;
522}
const std::vector< const std::vector< G4AttValue > * > & GetAttValues() const
const std::vector< const std::map< G4String, G4AttDef > * > & GetAttDefs() const
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])
virtual void DrawView()=0
const char * name(G4int ptype)

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

◆ getRealPrintFilename()

std::string G4OpenGLViewer::getRealPrintFilename ( )
protected

Definition at line 1021 of file G4OpenGLViewer.cc.

1021 {
1022 std::string temp = fExportFilename;
1023 if (fExportFilenameIndex != -1) {
1024 temp += std::string("_");
1025 std::ostringstream os;
1026 os << std::setw(4) << std::setfill('0') << fExportFilenameIndex;
1027 std::string nb_str = os.str();
1028 temp += nb_str;
1029 }
1030 temp += "."+fExportImageFormat;
1031 return temp;
1032}

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

◆ getSceneDepth()

GLdouble G4OpenGLViewer::getSceneDepth ( )
protected

Definition at line 1066 of file G4OpenGLViewer.cc.

1067{
1068 if (!fSceneHandler.GetScene()) {
1069 return 0;
1070 }
1071 const G4Point3D targetPoint
1075 if(radius<=0.) radius = 1.;
1076 const G4double cameraDistance = fVP.GetCameraDistance (radius);
1077 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
1078 return fVP.GetFarDistance (cameraDistance, pnear, radius)- pnear;
1079}
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
G4Scene * GetScene() const
G4double GetCameraDistance(G4double radius) const
const G4Point3D & GetCurrentTargetPoint() const
G4double GetFarDistance(G4double cameraDistance, G4double nearDistance, G4double radius) const
G4double GetNearDistance(G4double cameraDistance, G4double radius) const
G4double GetExtentRadius() const

Referenced by G4OpenGLQtViewer::moveScene().

◆ getSceneFarWidth()

GLdouble G4OpenGLViewer::getSceneFarWidth ( )
protected

Definition at line 1049 of file G4OpenGLViewer.cc.

1050{
1051 if (!fSceneHandler.GetScene()) {
1052 return 0;
1053 }
1054 const G4Point3D targetPoint
1058 if(radius<=0.) radius = 1.;
1059 const G4double cameraDistance = fVP.GetCameraDistance (radius);
1060 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
1061 const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
1062 return 2 * fVP.GetFrontHalfHeight (pfar, radius);
1063}
G4double GetFrontHalfHeight(G4double nearDistance, G4double radius) const

◆ getSceneNearWidth()

GLdouble G4OpenGLViewer::getSceneNearWidth ( )
protected

Definition at line 1034 of file G4OpenGLViewer.cc.

1035{
1036 if (!fSceneHandler.GetScene()) {
1037 return 0;
1038 }
1039 const G4Point3D targetPoint
1043 if(radius<=0.) radius = 1.;
1044 const G4double cameraDistance = fVP.GetCameraDistance (radius);
1045 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
1046 return 2 * fVP.GetFrontHalfHeight (pnear, radius);
1047}

Referenced by G4OpenGLQtViewer::G4MousePressEvent(), and G4OpenGLQtViewer::moveScene().

◆ getWinHeight()

◆ getWinWidth()

◆ HaloingFirstPass()

void G4OpenGLViewer::HaloingFirstPass ( )
protected

Definition at line 387 of file G4OpenGLViewer.cc.

387 {
388
389 //To perform haloing, first Draw all information to the depth buffer
390 //alone, using a chunky line width, and then Draw all info again, to
391 //the colour buffer, setting a thinner line width an the depth testing
392 //function to less than or equal, so if two lines cross, the one
393 //passing behind the other will not pass the depth test, and so not
394 //get rendered either side of the infront line for a short distance.
395
396 //First, disable writing to the colo(u)r buffer...
397 glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
398
399 //Now enable writing to the depth buffer...
400 glDepthMask (GL_TRUE);
401 glDepthFunc (GL_LESS);
402 glClearDepth (1.0);
403
404 //Finally, set the line width to something wide...
405 ChangeLineWidth(3.0);
406
407}
void ChangeLineWidth(G4double width)

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

◆ HaloingSecondPass()

void G4OpenGLViewer::HaloingSecondPass ( )
protected

Definition at line 409 of file G4OpenGLViewer.cc.

409 {
410
411 //And finally, turn the colour buffer back on with a sesible line width...
412 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
413 glDepthFunc (GL_LEQUAL);
414 ChangeLineWidth(1.0);
415
416}

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

◆ HLRFirstPass()

void G4OpenGLViewer::HLRFirstPass ( )
protected

◆ HLRSecondPass()

void G4OpenGLViewer::HLRSecondPass ( )
protected

◆ HLRThirdPass()

void G4OpenGLViewer::HLRThirdPass ( )
protected

◆ InitializeGLView()

void G4OpenGLViewer::InitializeGLView ( )
protected

Definition at line 124 of file G4OpenGLViewer.cc.

125{
126 if (fWinSize_x == 0) {
128 }
129 if (fWinSize_y == 0) {
131 }
132
133 glClearColor (0.0, 0.0, 0.0, 0.0);
134 glClearDepth (1.0);
135 glDisable (GL_LINE_SMOOTH);
136 glDisable (GL_POLYGON_SMOOTH);
137
138// clear the buffers and window?
139 ClearView ();
140 FinishView ();
141
142 glDepthFunc (GL_LEQUAL);
143 glDepthMask (GL_TRUE);
144
145 glEnable (GL_BLEND);
146 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
147
148}
virtual void FinishView()
Definition G4VViewer.cc:104
unsigned int GetWindowSizeHintX() const
unsigned int GetWindowSizeHintY() const

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

◆ isFramebufferReady()

G4bool G4OpenGLViewer::isFramebufferReady ( )
protected

Definition at line 676 of file G4OpenGLViewer.cc.

676 {
677 bool check = false;
678#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
679 check = true;
680#endif
681#ifdef G4VIS_BUILD_OPENGLX_DRIVER
682 check = false;
683#endif
684#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
685 check = false;
686#endif
687#ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
688 check = false;
689#endif
690
691#if GL_ARB_framebuffer_object
692 if (check) {
693// if ( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_UNDEFINED) {
694// return false;
695// }
696 }
697#endif
698 return true;
699}

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

◆ isGl2psWriting()

bool G4OpenGLViewer::isGl2psWriting ( )
protected

Return if gl2ps is currently writing

Definition at line 666 of file G4OpenGLViewer.cc.

666 {
667
668 if (!fGL2PSAction) return false;
670 return true;
671 }
672 return false;
673}
bool fileWritingEnabled() const
Definition G4gl2ps.cc:157

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

◆ Pick()

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

Definition at line 418 of file G4OpenGLViewer.cc.

419{
420 const std::vector < G4OpenGLViewerPickMap* > & pickMap = GetPickDetails(x,y);
421 G4String txt = "";
422 if (pickMap.size() == 0) {
423// txt += "No hits recorded.";;
424 } else {
425 for (unsigned int a=0; a < pickMap.size(); a++) {
426 if (pickMap[a]->getAttributes().size() > 0) {
427 txt += pickMap[a]->print();
428 }
429 }
430 }
431 return txt;
432}
const std::vector< G4OpenGLViewerPickMap * > & GetPickDetails(GLdouble x, GLdouble y)

Referenced by G4OpenGLXViewer::ShowView().

◆ ResetView()

void G4OpenGLViewer::ResetView ( )
protectedvirtual

Reimplemented from G4VViewer.

Reimplemented in G4OpenGLXmViewer.

Definition at line 380 of file G4OpenGLViewer.cc.

380 {
382 fRot_sens = 1;
383 fPan_sens = 0.01;
384}
virtual void ResetView()

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

◆ ResizeGLView()

void G4OpenGLViewer::ResizeGLView ( )
protected

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

Definition at line 197 of file G4OpenGLViewer.cc.

198{
199 // Check size
200 GLint dims[2];
201 dims[0] = 0;
202 dims[1] = 0;
203
204 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
205
206 if ((dims[0] !=0 ) && (dims[1] !=0)) {
207
208 if (fWinSize_x > (unsigned)dims[0]) {
209 G4cerr << "Try to resize view greater than max X viewport dimension. Desired size "<<fWinSize_x <<" is resize to "<< dims[0] << G4endl;
210 fWinSize_x = dims[0];
211 }
212 if (fWinSize_y > (unsigned)dims[1]) {
213 G4cerr << "Try to resize view greater than max Y viewport dimension. Desired size "<<fWinSize_y <<" is resize to "<< dims[1] << G4endl;
214 fWinSize_y = dims[1];
215 }
216 }
217
218 glViewport(0, 0, fWinSize_x,fWinSize_y);
219
220
221}

Referenced by SetView().

◆ ResizeWindow()

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

Definition at line 181 of file G4OpenGLViewer.cc.

181 {
182 if ((fWinSize_x != aWidth) || (fWinSize_y != aHeight)) {
183 fWinSize_x = aWidth;
184 fWinSize_y = aHeight;
185 fSizeHasChanged = true;
186 } else {
187 fSizeHasChanged = false;
188 }
189}

Referenced by G4OpenGLQtViewer::CreateMainWindow(), G4OpenGLWin32Viewer::CreateMainWindow(), G4OpenGLXmViewer::CreateMainWindow(), G4OpenGLXViewer::CreateMainWindow(), G4OpenGLXmViewer::expose_callback(), G4OpenGLImmediateQtViewer::resizeGL(), and G4OpenGLStoredQtViewer::resizeGL().

◆ rotateScene()

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

Definition at line 1083 of file G4OpenGLViewer.cc.

1084{
1086 rotateSceneInViewDirection(dx,dy);
1087 } else {
1088 if( dx != 0) {
1089 rotateSceneThetaPhi(dx,0);
1090 }
1091 if( dy != 0) {
1092 rotateSceneThetaPhi(0,dy);
1093 }
1094 }
1095}
RotationStyle GetRotationStyle() const

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

◆ rotateSceneToggle()

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

Definition at line 1098 of file G4OpenGLViewer.cc.

1099{
1101 rotateSceneInViewDirection(dx,dy);
1102 } else {
1103 if( dx != 0) {
1104 rotateSceneThetaPhi(dx,0);
1105 }
1106 if( dy != 0) {
1107 rotateSceneThetaPhi(0,dy);
1108 }
1109 }
1110}

Referenced by G4OpenGLQtViewer::rotateQtSceneToggle().

◆ setExportFilename()

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

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 989 of file G4OpenGLViewer.cc.

989 {
990 if (name == "!") {
991 name = "";
992 }
993
994 if (inc) {
995 if ((name != "") && (fExportFilename != name)) {
997 }
998 } else {
1000 }
1001
1002 if (name.size() == 0) {
1003 name = getRealPrintFilename().c_str();
1004 } else {
1005 // guess format by extention
1006 std::string extension = name.substr(name.find_last_of(".") + 1);
1007 // If there is a dot in the name the above might find rubbish, so...
1008 if (extension.size() >= 3 && extension.size() <= 4) { // Possible extension
1009 if (setExportImageFormat(extension, false)) { // Extension found
1010 fExportFilename = name.substr(0,name.find_last_of("."));
1011 } else { // No viable extension found
1012 return false;
1013 }
1014 } else { // Assume name is already the required without-extension part
1015 fExportFilename = name;
1016 }
1017 }
1018 return true;
1019}

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

◆ setExportImageFormat()

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

Definition at line 1247 of file G4OpenGLViewer.cc.

1247 {
1248 bool found = false;
1249 std::string list;
1250 for (unsigned int a=0; a<fExportImageFormatVector.size(); a++) {
1251 list +=fExportImageFormatVector.at(a) + " ";
1252
1253 if (fExportImageFormatVector.at(a) == format) {
1254 if (! quiet) {
1255 G4cout << " Changing export format to \"" << format << "\"" << G4endl;
1256 }
1257 if (format != fExportImageFormat) {
1259 fExportImageFormat = format;
1260 }
1261 return true;
1262 }
1263 }
1264 if (! found) {
1265 if (format.size() == 0) {
1266 G4cout << " Current formats availables are : " << list << G4endl;
1267 } else {
1268 G4cerr << " Format \"" << format << "\" is not available for the selected viewer. Current formats availables are : " << list << G4endl;
1269 }
1270 }
1271 return false;
1272}

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

◆ setExportSize()

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

Definition at line 978 of file G4OpenGLViewer.cc.

978 {
979 fPrintSizeX = X;
980 fPrintSizeY = Y;
981}
G4double Y(G4double density)

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

◆ SetView()

void G4OpenGLViewer::SetView ( )
protectedvirtual

Implements G4VViewer.

Reimplemented in G4OpenGLWin32Viewer, and G4OpenGLXViewer.

Definition at line 224 of file G4OpenGLViewer.cc.

224 {
225 // if getting pick infos, should not resize the view.
226 if (fIsGettingPickInfos) return;
227
228 if (!fSceneHandler.GetScene()) {
229 return;
230 }
231 // Calculates view representation based on extent of object being
232 // viewed and (initial) viewpoint. (Note: it can change later due
233 // to user interaction via visualization system's GUI.)
234
235 // Lighting.
236 GLfloat lightPosition [4];
237 lightPosition [0] = fVP.GetActualLightpointDirection().x();
238 lightPosition [1] = fVP.GetActualLightpointDirection().y();
239 lightPosition [2] = fVP.GetActualLightpointDirection().z();
240 lightPosition [3] = 0.;
241 // Light position is "true" light direction, so must come after gluLookAt.
242 GLfloat ambient [] = { 0.2f, 0.2f, 0.2f, 1.f};
243 GLfloat diffuse [] = { 0.8f, 0.8f, 0.8f, 1.f};
244 glEnable (GL_LIGHT0);
245 glLightfv (GL_LIGHT0, GL_AMBIENT, ambient);
246 glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
247
248 G4double ratioX = 1;
249 G4double ratioY = 1;
250 if (fWinSize_y > fWinSize_x) {
251 ratioX = ((G4double)fWinSize_y) / ((G4double)fWinSize_x);
252 }
253 if (fWinSize_x > fWinSize_y) {
254 ratioY = ((G4double)fWinSize_x) / ((G4double)fWinSize_y);
255 }
256
257 // Get radius of scene, etc.
258 // Note that this procedure properly takes into account zoom, dolly and pan.
259 const G4Point3D targetPoint
263 if(radius<=0.) radius = 1.;
264 const G4double cameraDistance = fVP.GetCameraDistance (radius);
265 const G4Point3D cameraPosition =
266 targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
267 const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
268 const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
269 const GLdouble right = fVP.GetFrontHalfHeight (pnear, radius) * ratioY;
270 const GLdouble left = -right;
271 const GLdouble top = fVP.GetFrontHalfHeight (pnear, radius) * ratioX;
272 const GLdouble bottom = -top;
273
274 // FIXME
275 ResizeGLView();
276 //SHOULD SetWindowsSizeHint()...
277
278 glMatrixMode (GL_PROJECTION); // set up Frustum.
279 glLoadIdentity();
280
281 const G4Vector3D scaleFactor = fVP.GetScaleFactor();
282 glScaled(scaleFactor.x(),scaleFactor.y(),scaleFactor.z());
283
284 if (fVP.GetFieldHalfAngle() == 0.) {
285 g4GlOrtho (left, right, bottom, top, pnear, pfar);
286 }
287 else {
288 g4GlFrustum (left, right, bottom, top, pnear, pfar);
289 }
290
291 glMatrixMode (GL_MODELVIEW); // apply further transformations to scene.
292 glLoadIdentity();
293
294 const G4Normal3D& upVector = fVP.GetUpVector ();
295 G4Point3D gltarget;
296 if (cameraDistance > 1.e-6 * radius) {
297 gltarget = targetPoint;
298 }
299 else {
300 gltarget = targetPoint - radius * fVP.GetViewpointDirection().unit();
301 }
302
303 const G4Point3D& pCamera = cameraPosition; // An alias for brevity.
304
305 g4GluLookAt (pCamera.x(), pCamera.y(), pCamera.z(), // Viewpoint.
306 gltarget.x(), gltarget.y(), gltarget.z(), // Target point.
307 upVector.x(), upVector.y(), upVector.z()); // Up vector.
308 // Light position is "true" light direction, so must come after gluLookAt.
309 glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
310
311 // The idea is to use back-to-back clipping planes. This can cut an object
312 // down to just a few pixels, which can make it difficult to see. So, for
313 // now, comment this out and use the generic (Boolean) method, via
314 // G4VSolid* G4OpenGLSceneHandler::CreateSectionSolid ()
315 // { return G4VSceneHandler::CreateSectionSolid(); }
316// if (fVP.IsSection () ) { // pair of back to back clip planes.
317// const G4Plane3D& sp = fVP.GetSectionPlane ();
318// double sArray[4];
319// sArray[0] = sp.a();
320// sArray[1] = sp.b();
321// sArray[2] = sp.c();
322// sArray[3] = sp.d() + radius * 1.e-05;
323// glClipPlane (GL_CLIP_PLANE0, sArray);
324// glEnable (GL_CLIP_PLANE0);
325// sArray[0] = -sp.a();
326// sArray[1] = -sp.b();
327// sArray[2] = -sp.c();
328// sArray[3] = -sp.d() + radius * 1.e-05;
329// glClipPlane (GL_CLIP_PLANE1, sArray);
330// glEnable (GL_CLIP_PLANE1);
331// } else {
332// glDisable (GL_CLIP_PLANE0);
333// glDisable (GL_CLIP_PLANE1);
334// }
335
336 // What we call intersection of cutaways is easy in OpenGL. You
337 // just keep cutting. Unions are more tricky - you have to have
338 // multiple passes and this is handled in
339 // G4OpenGLImmediate/StoredViewer::ProcessView.
340 const G4Planes& cutaways = fVP.GetCutawayPlanes();
341 size_t nPlanes = cutaways.size();
342 if (fVP.IsCutaway() &&
344 double a[4];
345 a[0] = cutaways[0].a();
346 a[1] = cutaways[0].b();
347 a[2] = cutaways[0].c();
348 a[3] = cutaways[0].d();
349 glClipPlane (GL_CLIP_PLANE2, a);
350 glEnable (GL_CLIP_PLANE2);
351 if (nPlanes > 1) {
352 a[0] = cutaways[1].a();
353 a[1] = cutaways[1].b();
354 a[2] = cutaways[1].c();
355 a[3] = cutaways[1].d();
356 glClipPlane (GL_CLIP_PLANE3, a);
357 glEnable (GL_CLIP_PLANE3);
358 }
359 if (nPlanes > 2) {
360 a[0] = cutaways[2].a();
361 a[1] = cutaways[2].b();
362 a[2] = cutaways[2].c();
363 a[3] = cutaways[2].d();
364 glClipPlane (GL_CLIP_PLANE4, a);
365 glEnable (GL_CLIP_PLANE4);
366 }
367 } else {
368 glDisable (GL_CLIP_PLANE2);
369 glDisable (GL_CLIP_PLANE3);
370 glDisable (GL_CLIP_PLANE4);
371 }
372
373 // Background.
375
376}
std::vector< G4Plane3D > G4Planes
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)
void g4GlOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far)
const G4Vector3D & GetScaleFactor() const
CutawayMode GetCutawayMode() const
G4bool IsCutaway() const
G4Vector3D & GetActualLightpointDirection()
const G4Colour & GetBackgroundColour() const
const G4Vector3D & GetViewpointDirection() const
G4double GetFieldHalfAngle() const
const G4Vector3D & GetUpVector() const
const G4Planes & GetCutawayPlanes() const
BasicVector3D< T > unit() const

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

◆ sizeHasChanged()

G4bool G4OpenGLViewer::sizeHasChanged ( )
protected

Definition at line 936 of file G4OpenGLViewer.cc.

936 {
937 return fSizeHasChanged;
938}

Referenced by G4OpenGLImmediateQtViewer::resizeGL(), and G4OpenGLStoredQtViewer::resizeGL().

Friends And Related Symbol Documentation

◆ G4OpenGLFileSceneHandler

friend class G4OpenGLFileSceneHandler
friend

Definition at line 100 of file G4OpenGLViewer.hh.

◆ G4OpenGLImmediateSceneHandler

friend class G4OpenGLImmediateSceneHandler
friend

Definition at line 98 of file G4OpenGLViewer.hh.

◆ G4OpenGLSceneHandler

friend class G4OpenGLSceneHandler
friend

Definition at line 97 of file G4OpenGLViewer.hh.

◆ G4OpenGLStoredSceneHandler

friend class G4OpenGLStoredSceneHandler
friend

Definition at line 99 of file G4OpenGLViewer.hh.

◆ G4OpenGLViewerMessenger

friend class G4OpenGLViewerMessenger
friend

Definition at line 101 of file G4OpenGLViewer.hh.

Member Data Documentation

◆ antialiasing_enabled

G4bool G4OpenGLViewer::antialiasing_enabled
protected

◆ background

G4Colour G4OpenGLViewer::background
protected

◆ fDefaultExportImageFormat

std::string G4OpenGLViewer::fDefaultExportImageFormat
protected

Definition at line 197 of file G4OpenGLViewer.hh.

◆ fExportFilenameIndex

int G4OpenGLViewer::fExportFilenameIndex
protected

◆ fExportImageFormat

std::string G4OpenGLViewer::fExportImageFormat
protected

Definition at line 198 of file G4OpenGLViewer.hh.

Referenced by exportImage(), getRealPrintFilename(), and setExportImageFormat().

◆ fExportImageFormatVector

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

Definition at line 196 of file G4OpenGLViewer.hh.

Referenced by addExportImageFormat(), and setExportImageFormat().

◆ fGL2PSAction

G4gl2ps* G4OpenGLViewer::fGL2PSAction
protected

◆ fOpenGLSceneHandler

G4OpenGLSceneHandler& G4OpenGLViewer::fOpenGLSceneHandler
protected

Definition at line 184 of file G4OpenGLViewer.hh.

Referenced by GetPickDetails().

◆ fPan_sens

◆ fPrintColour

◆ fPrintSizeX

G4int G4OpenGLViewer::fPrintSizeX
protected

Definition at line 200 of file G4OpenGLViewer.hh.

Referenced by setExportSize().

◆ fPrintSizeY

G4int G4OpenGLViewer::fPrintSizeY
protected

Definition at line 201 of file G4OpenGLViewer.hh.

Referenced by setExportSize().

◆ fRot_sens

◆ fVectoredPs

◆ fWinSize_x

unsigned int G4OpenGLViewer::fWinSize_x
protected

◆ fWinSize_y

unsigned int G4OpenGLViewer::fWinSize_y
protected

◆ haloing_enabled

◆ transparency_enabled


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