Import Geant4 8.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:36:02 +02:00
parent d93e1e39a9
commit 8a51e0bc40
5471 changed files with 99628 additions and 55248 deletions
+90 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.46 2005/05/29 23:18:56 allison Exp $
$Id: History,v 1.59 2005/11/24 10:24:12 allison Exp $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,95 @@ committal in the CVS repository !
History file for visualization/OpenGL
-------------------------------------
24th November 2005 John Allison (opengl-V07-01-09)
- Protected G4OpenGLXmViewerMessenger with #ifdef G4VIS_BUILD_OPENGLXM_DRIVER.
22nd November 2005 John Allison (opengl-V07-01-08)
- Added G4OpenGLXmViewerMessenger.
- Corrected text position.
- Made depth test for polyhedron GL_LEQUAL (slightly dominant).
17th November 2005 Gabriele Cosmo
- Fixed settings of background style for WIN32 viewers.
13th November 2005 John Allison (opengl-V07-01-07)
- Implemented X-Window-style geometry hints in G4OpenGLXViewer.
13th October 2005 John Allison (opengl-V07-01-06)
- Allowed any colour background.
- Implemented non-uniform scaling.
- Migration to <sstream>.
29th September 2005 John Allison (opengl-V07-01-05)
- Added G4OpenGLViewerDataStore to facilitate access of viewer data by
scene handler.
- Re-implemented transparency button in OpenGLXm.
13th September 2005 John Allison (opengl-V07-01-04 - needs visman-V07-01-02)
- Implemented white background for all OGL viewers.
- G4OpenGLSceneHandler.cc:
o Fixed hidden line removal (bug introduced in opengl-V07-01-02).
o Fixed treatment of triangular polygons for drawing of auxiliary/soft lines.
o Corrected GetTextColour(text).
o Corrected GetColour(polyhedron).
5th September 2005 John Allison (opengl-V07-01-03)
- Bug fix: stored transparent objects were being lost.
2nd September 2005 John Allison (opengl-V07-01-02 - needs visman-V07-01-01)
- Bug fix: edgeflags problem introduced with smooth shading in
opengl-V07-01-00.
- Implementation of a "better algorithm" for the rendering of
transparent polyhedron objects. It renders all opaque objects
first, then renders the transparent objects with the depth buffer in
read-only mode (see OpenGL Programming Guide). It uses the new
facility in G4VSceneHandler::ProcessScene for an optional second pass
of the run-duration models in the scene. Note this algorithm is
still only an approximation. It will still give the wrong blended
colour if two transparent objects are rendered front first. For
nested transparent objects, this is unfortunate, because
G4PhysicalVolumeModel traverses Geant4's mother-daughter hierarchy
in such a way that mothers come first. Also, there is no guaranteed
relationship between the order of rendering and the depth of two
transparent objects if they are at the same level or in different
branches of the hierarchy. Still, the only error will be an
incorrect colour - the objects will still give the appearance of
transparency, so it's a pretty good algorithm. (An even better
algorithm would be to attempt to render the facets in depth order,
deepest first. But how do you calculate the depth - centre of area,
deepest corner? One can still imagine pathalogical cases that would
sometimes give the wrong colour. Also, for stored mode, the order
is fixed in a display list so when the user rotates the view, one
would lose the depth ordering. I think we have to accept that
blending in OpenGL is only ever an approximation. For accurate
blending, use RayTracer.)
28th August 2005 John Allison (opengl-V07-01-01)
- Half-way implementation of rendering of transparent polyhedron
objects. In this implementation, no account is taken of the order
of rendering. Transparent objects are rendered with depth testing
off so that objects behind can still be seen. But this means that
opaque objects in front do not obscure them - and they jolly well
should! A better algorithm is to render all opaque objects first,
then render the transparent objects with the depth buffer in
read-only mode (see OpenGL Programming Guide). This is going to
take a little more thought - see opengl-V07-01-02.
20th July 2005 John Allison (opengl-V07-01-00)
- Introduced smooth shading, taking advantage of hitherto un-noticed
feature of HepPolyhedron::GetNextFacet that calculates the normals
at each vertex so that curved surfaces are rendered more
realistically (Gouraud shading).
- G4OpenGLImmediateSceneHandler.cc: Removed unnecessary #include's.
- G4OpenGLXmViewer.cc: Fixed to use window size hints. This changes
the default window size. It used to be 400x400, hardcoded in
G4OpenGLXmViewer.cc, but now it picks up the
G4ViewParameters::GetWindowSizeHintX/Y, which defaults to 600x600.
The user may change it on the command line, e.g:
/vis/open OGLSXm 500
or
/vis/viewer/create ! ! 500
30th May 2005 John Allison (opengl-V07-00-03)
- Fixed compilation problem in OpenGL on SUN. (Replaced multimap by
map of vectors in G4OpenGLFontBaseStore.)
@@ -21,7 +21,7 @@
// ********************************************************************
//
// $Id: G4OpenGL.hh,v 1.3 2005/04/17 16:08:43 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// G.Barrand.
@@ -21,7 +21,7 @@
// ********************************************************************
//
// $Id: G4OpenGLFontBaseStore.hh,v 1.2 2005/05/27 10:56:06 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// J.Allison Apr 2005.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateSceneHandler.hh,v 1.7 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLImmediateSceneHandler.hh,v 1.8 2005/09/05 11:02:38 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -54,6 +54,7 @@ public:
void ClearTransientStore ();
private:
void RequestPrimitives (const G4VSolid& solid);
static G4int fSceneIdCount; // static counter for OpenGLImmediate scenes.
};
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateViewer.hh,v 1.7 2002/10/16 10:44:13 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateWin32.hh,v 1.6 2002/10/16 10:44:14 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// OpenGLImmediateWin32 graphics system factory.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateWin32Viewer.hh,v 1.7 2002/10/16 10:44:14 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Class G4OpenGLImmediateWin32Viewer : a class derived from
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateX.hh,v 1.6 2001/07/11 10:08:48 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateXViewer.hh,v 1.7 2001/07/14 21:47:42 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateXm.hh,v 1.6 2001/07/11 10:08:49 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateXmViewer.hh,v 1.7 2001/07/14 21:47:43 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLSceneHandler.hh,v 1.18 2005/01/27 20:04:52 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLSceneHandler.icc,v 1.6 2005/01/27 20:04:55 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 20th January 1998
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredSceneHandler.hh,v 1.16 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredViewer.hh,v 1.8 2001/08/14 18:03:15 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredWin32.hh,v 1.6 2002/10/16 10:44:14 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// OpenGLStoredWin32 graphics system factory.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredWin32Viewer.hh,v 1.5 2002/10/16 10:44:14 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Class G4OpenGLStoredWin32Viewer : a class derived from
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredX.hh,v 1.6 2001/07/11 10:08:50 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredXViewer.hh,v 1.5 2001/07/14 21:47:46 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredXm.hh,v 1.5 2001/07/11 10:08:50 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredXmViewer.hh,v 1.5 2001/07/14 21:47:47 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLTransform3D.hh,v 1.6 2004/04/07 15:17:12 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 24th October 1996
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLViewer.hh,v 1.10 2005/04/22 12:02:47 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLViewer.hh,v 1.11 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -34,7 +34,6 @@
#define G4OPENGLVIEWER_HH
#include "G4VViewer.hh"
#include "globals.hh"
class G4OpenGLSceneHandler;
@@ -55,8 +54,8 @@ protected:
void HLRThirdPass ();
void InitializeGLView ();
virtual void CreateFontLists () {}
G4bool white_background, //the OpenGL clear colour
doublebuffer, //are we using a double buffered visual?
G4Colour background; //the OpenGL clear colour
G4bool doublebuffer, //are we using a double buffered visual?
transparency_enabled, //is alpha blending enabled?
antialiasing_enabled, //is antialiasing enabled?
haloing_enabled; //is haloing enabled for wireframe?
@@ -0,0 +1,48 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4OpenGLViewerDataStore.hh,v 1.1 2005/09/29 14:26:17 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// J.Allison Apr 2005.
// Class Description:
// Facilitates sharing of fontdat between scene handler and viewers.
#ifndef G4OPENGLVIEWERDATASTORE_HH
#define G4OPENGLVIEWERDATASTORE_HH
#include "globals.hh"
#include <map>
#include <vector>
class G4VViewer;
class G4OpenGLViewerDataStore {
public:
static void SetTransparencyEnabled(G4VViewer*, G4bool transparency_enabled);
static G4bool GetTransparencyEnabled(G4VViewer*);
private:
static std::map<G4VViewer*,G4bool> fTransparencyEnabledMap;
};
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLWin32Viewer.hh,v 1.11 2003/06/25 09:01:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// G4OpenGLWin32Viewer : Class to provide WindowsNT specific
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXViewer.hh,v 1.21 2005/04/22 12:02:47 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLXViewer.hh,v 1.22 2005/11/13 15:46:54 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -112,7 +112,7 @@ protected:
XClassHint *class_hints;
Pixmap icon_pixmap;
XSizeHints *size_hints;
G4int WinSize_x,
unsigned int WinSize_x,
WinSize_y;
Atom Xatom;
XTextProperty windowName,
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmBox.hh,v 1.6 2001/07/11 10:08:51 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Box container class
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmFourArrowButtons.hh,v 1.5 2001/07/11 10:08:51 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Four arrow buttons class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmFramedBox.hh,v 1.6 2001/07/11 10:08:51 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Framed box container class
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmPushButton.hh,v 1.6 2001/07/11 10:08:51 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Push button class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmRadioButton.hh,v 1.6 2001/07/11 10:08:51 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Radio button class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmResources.hh,v 1.4 2001/07/11 10:08:51 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Default resources file for GEANT4 OpenGL Motif windows.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmSeparator.hh,v 1.5 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Separator class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmSliderBar.hh,v 1.6 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Slider bar class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmTextField.hh,v 1.6 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Text field class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmTopLevelShell.hh,v 1.5 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Top level shell class
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetComponent.hh,v 1.5 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Base class for all Motif component widgets
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetContainer.hh,v 1.5 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Base class for all Motif container widgets
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetObject.hh,v 1.5 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Virtual base class for all Motif widgets.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetShell.hh,v 1.5 2001/07/11 10:08:52 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
//Base class for all Motif window widgets (shells)
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXmViewer.hh,v 1.7 2004/07/23 15:23:50 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLXmViewer.hh,v 1.8 2005/11/22 16:03:23 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -67,9 +67,10 @@ class G4OpenGLXmTextField;
class G4OpenGLXmFramedBox;
class G4OpenGLXmFourArrowButtons;
class G4OpenGLXmSeparator;
class G4OpenGLXmViewerMessenger;
class G4OpenGLXmViewer: public G4OpenGLXViewer {
public:
G4OpenGLXmViewer (G4OpenGLSceneHandler& scene);
virtual ~G4OpenGLXmViewer ();
@@ -206,6 +207,7 @@ protected:
G4OpenGLXmRadioButton* fpprint_col_radio2;
G4OpenGLXmRadioButton* fpprint_style_radio1;
G4OpenGLXmRadioButton* fpprint_style_radio2;
G4OpenGLXmViewerMessenger* fpMessenger;
public:
@@ -382,8 +384,9 @@ public:
static G4int get_int_userData (Widget w);
friend class G4OpenGLXmVWidgetObject;
friend class G4OpenGLXmVWidgetObject;
friend class G4OpenGLXmViewerMessenger;
private:
G4OpenGLXmViewer (const G4OpenGLXmViewer&);
G4OpenGLXmViewer& operator = (const G4OpenGLXmViewer&);
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4OpenGLXmViewerMessenger.hh,v 1.2 2005/11/24 10:23:43 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#ifndef G4OPENGLXMVIEWERMESSENGER_HH
#define G4OPENGLXMVIEWERMESSENGER_HH
#include "G4UImessenger.hh"
#include "G4String.hh"
class G4OpenGLXmViewer;
class G4UIdirectory;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithADouble;
class G4OpenGLXmViewerMessenger: public G4UImessenger {
public:
G4OpenGLXmViewerMessenger
(G4OpenGLXmViewer* viewer, const G4String& viewerShortName);
~G4OpenGLXmViewerMessenger();
void SetNewValue (G4UIcommand*, G4String);
private:
G4OpenGLXmViewer* fpViewer;
G4String fViewerShortName;
G4UIdirectory* fpDirectory;
G4UIdirectory* fpDirectorySet;
G4UIcmdWithADoubleAndUnit* fpCommandSetDollyHigh;
G4UIcmdWithADoubleAndUnit* fpCommandSetDollyLow;
G4UIcmdWithADoubleAndUnit* fpCommandSetPanHigh;
G4UIcmdWithADoubleAndUnit* fpCommandSetRotationHigh;
G4UIcmdWithADouble* fpCommandSetZoomHigh;
G4UIcmdWithADouble* fpCommandSetZoomLow;
};
#endif
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLFontBaseStore.cc,v 1.2 2005/05/27 10:56:06 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
#include "G4OpenGLFontBaseStore.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateSceneHandler.cc,v 1.13 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLImmediateSceneHandler.cc,v 1.17 2005/09/29 14:27:03 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -41,19 +41,13 @@
#include "G4OpenGLSceneHandler.hh"
#include "G4OpenGLViewer.hh"
#include "G4OpenGLViewerDataStore.hh"
#include "G4OpenGLTransform3D.hh"
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
#include "G4Transform3D.hh"
#include "G4Polyline.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4Polyhedron.hh"
#include "G4VisAttributes.hh"
#include "G4OpenGLImmediateSceneHandler.hh"
#include "G4LogicalVolume.hh"
G4OpenGLImmediateSceneHandler::G4OpenGLImmediateSceneHandler (G4VGraphicsSystem& system,
const G4String& name):
G4OpenGLSceneHandler (system, fSceneIdCount++, name)
@@ -111,6 +105,40 @@ void G4OpenGLImmediateSceneHandler::ClearTransientStore () {
}
}
void G4OpenGLImmediateSceneHandler::RequestPrimitives (const G4VSolid& solid) {
if (fReadyForTransients) {
// Always draw transient solids, e.g., hits represented as solids.
// (As we have no control over the order of drawing of transient
// objects, we cannot do anything about transparent ones, as
// below, so always draw them.)
G4VSceneHandler::RequestPrimitives (solid);
}
else {
// For non-transient (run-duration) objects, ensure transparent
// objects are drawn last. The problem of
// blending/transparency/alpha is quite a tricky one - see History
// of opengl-V07-01-01/2/3.
// Get vis attributes - pick up defaults if none.
const G4VisAttributes* pVA =
fpViewer -> GetApplicableVisAttributes(fpVisAttribs);
const G4Colour& c = pVA -> GetColour ();
G4double opacity = c.GetAlpha ();
if (!fSecondPass) {
G4bool transparency_enabled =
G4OpenGLViewerDataStore::GetTransparencyEnabled(fpViewer);
if (transparency_enabled && opacity < 1.) {
// On first pass, transparent objects are not drawn, but flag is set...
fSecondPassRequested = true;
return;
}
}
// On second pass, opaque objects are not drwan...
if (fSecondPass && opacity >= 1.) return;
// Else invoke base class method...
G4VSceneHandler::RequestPrimitives (solid);
}
}
G4int G4OpenGLImmediateSceneHandler::fSceneIdCount = 0;
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateViewer.cc,v 1.6 2002/10/16 10:44:15 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateWin32.cc,v 1.9 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// OpenGLImmediateWin32 graphics system factory.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateWin32Viewer.cc,v 1.9 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLImmediateWin32Viewer.cc,v 1.10 2005/11/17 07:36:04 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Class G4OpenGLImmediateWin32Viewer : a class derived from G4OpenGLWin32Viewer and
@@ -77,11 +77,10 @@ void G4OpenGLImmediateWin32Viewer::DrawView () {
glDrawBuffer (GL_FRONT);
}
if (white_background == true) {
glClearColor (1., 1., 1., 1.);
} else {
glClearColor (0., 0., 0., 1.);
}
glClearColor (background.GetRed(),
background.GetGreen(),
background.GetBlue(),
1.);
glClearDepth (1.0);
G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateX.cc,v 1.9 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateXViewer.cc,v 1.11 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLImmediateXViewer.cc,v 1.12 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -92,11 +92,11 @@ void G4OpenGLImmediateXViewer::Initialise () {
void G4OpenGLImmediateXViewer::DrawView () {
if (white_background == true) {
glClearColor (1., 1., 1., 1.);
} else {
glClearColor (0., 0., 0., 1.);
}
glClearColor (background.GetRed(),
background.GetGreen(),
background.GetBlue(),
1.);
glClearDepth (1.0);
G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLImmediateXm.cc,v 1.10 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateXmViewer.cc,v 1.11 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLImmediateXmViewer.cc,v 1.13 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -76,7 +76,6 @@ void G4OpenGLImmediateXmViewer::Initialise () {
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel (GL_FLAT);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//The following code was in the constructor and found not to work for
@@ -99,11 +98,11 @@ void G4OpenGLImmediateXmViewer::Initialise () {
void G4OpenGLImmediateXmViewer::DrawView () {
if (white_background == true) {
glClearColor (1., 1., 1., 1.);
} else {
glClearColor (0., 0., 0., 1.);
}
glClearColor (background.GetRed(),
background.GetGreen(),
background.GetBlue(),
1.);
glClearDepth (1.0);
G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLSceneHandler.cc,v 1.32 2005/04/17 16:08:43 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLSceneHandler.cc,v 1.39 2005/11/22 16:11:06 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -43,6 +43,7 @@
#include "G4OpenGLSceneHandler.hh"
#include "G4OpenGLViewer.hh"
#include "G4OpenGLFontBaseStore.hh"
#include "G4OpenGLViewerDataStore.hh"
#include "G4OpenGLTransform3D.hh"
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
@@ -61,7 +62,7 @@
G4OpenGLSceneHandler::G4OpenGLSceneHandler (G4VGraphicsSystem& system,
G4int id,
const G4String& name):
G4VSceneHandler (system, id, name)
G4VSceneHandler (system, id, name)
{}
G4OpenGLSceneHandler::~G4OpenGLSceneHandler ()
@@ -99,7 +100,7 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyline& line)
if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ())
glDisable (GL_DEPTH_TEST);
else glEnable (GL_DEPTH_TEST);
else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);}
glDisable (GL_LIGHTING);
glBegin (GL_LINE_STRIP);
@@ -116,10 +117,10 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyline& line)
void G4OpenGLSceneHandler::AddPrimitive (const G4Text& text) {
const G4Colour& c = GetColour (text); // Picks up default if none.
const G4Colour& c = GetTextColour (text); // Picks up default if none.
MarkerSizeType sizeType;
G4double size = GetMarkerSize (text, sizeType);
G4ThreeVector position (*fpObjectTransformation * text.GetPosition ());
G4ThreeVector position (text.GetPosition ());
G4String textString = text.GetText();
G4int font_base = G4OpenGLFontBaseStore::GetFontBase(fpViewer,size);
@@ -174,7 +175,7 @@ void G4OpenGLSceneHandler::AddCircleSquare
if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ())
glDisable (GL_DEPTH_TEST);
else glEnable (GL_DEPTH_TEST);
else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);}
glDisable (GL_LIGHTING);
@@ -368,8 +369,8 @@ void G4OpenGLSceneHandler::DrawXYPolygon
//Method for handling G4Polyhedron objects for drawing solids.
void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
//Assume all facets are convex quadrilaterals.
//Draw each G4Facet individually
// Assume all facets are planar convex quadrilaterals.
// Draw each facet individually
if (polyhedron.GetNoFacets() == 0) return;
@@ -380,21 +381,29 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
// Get view parameters that the user can force through the vis
// attributes, thereby over-riding the current view parameter.
G4ViewParameters::DrawingStyle drawing_style = GetDrawingStyle (pVA);
G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
//Get colour, etc..
const G4Colour& c = pVA -> GetColour ();
G4bool transparency_enabled =
G4OpenGLViewerDataStore::GetTransparencyEnabled(fpViewer);
const G4Colour& c = GetColour (polyhedron);
GLfloat materialColour [4];
materialColour [0] = c.GetRed ();
materialColour [1] = c.GetGreen ();
materialColour [2] = c.GetBlue ();
materialColour [3] = 1.0;
GLdouble clear_colour[4];
glGetDoublev (GL_COLOR_CLEAR_VALUE, clear_colour);
if (transparency_enabled) {
materialColour [3] = c.GetAlpha ();
} else {
materialColour [3] = 1.;
}
GLfloat clear_colour[4];
glGetFloatv (GL_COLOR_CLEAR_VALUE, clear_colour);
G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
switch (drawing_style) {
case (G4ViewParameters::hlhsr):
// Set up as for hidden line removal but paint polygons...
// Set up as for hidden line removal but paint polygon faces later...
case (G4ViewParameters::hlr):
glEnable (GL_STENCIL_TEST);
// The stencil buffer is cleared in G4OpenGLViewer::ClearView.
@@ -402,27 +411,43 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
glStencilFunc (GL_ALWAYS, 0, 1);
glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LESS);
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
glPolygonMode (GL_FRONT, GL_LINE);
glDepthFunc (GL_LEQUAL);
if (materialColour[3] < 1.) {
// Transparent...
glDisable (GL_CULL_FACE);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
} else {
// Opaque...
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
glPolygonMode (GL_FRONT, GL_LINE);
}
glDisable (GL_LIGHTING);
glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
break;
case (G4ViewParameters::hsr):
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LESS);
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
glDepthFunc (GL_LEQUAL);
if (materialColour[3] < 1.) {
// Transparent...
glDepthMask (0); // Make depth buffer read-only.
glDisable (GL_CULL_FACE);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, materialColour);
} else {
// Opaque...
glDepthMask (1); // Make depth buffer writable (default).
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
glPolygonMode (GL_FRONT, GL_FILL);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColour);
}
glEnable (GL_LIGHTING);
glPolygonMode (GL_FRONT, GL_FILL);
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColour);
break;
case (G4ViewParameters::wireframe):
default:
//glDisable (GL_DEPTH_TEST);
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_ALWAYS);
glDepthFunc (GL_LEQUAL); //??? was GL_ALWAYS
glDisable (GL_CULL_FACE);
glDisable (GL_LIGHTING);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
@@ -435,50 +460,49 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
G4bool notLastFace;
do {
//First, find surface normal and note "not last facet"...
G4Normal3D SurfaceUnitNormal;
notLastFace = polyhedron.GetNextUnitNormal (SurfaceUnitNormal);
//Loop through the four edges of each G4Facet...
G4bool notLastEdge;
//First, find vertices, edgeflags and normals and note "not last facet"...
G4Point3D vertex[4];
G4int edgeFlag[4];
G4Normal3D normals[4];
G4int n;
notLastFace = polyhedron.GetNextFacet(n, vertex, edgeFlag, normals);
//Loop through the four edges of each G4Facet...
G4int edgeCount = 0;
glNormal3d(SurfaceUnitNormal.x(), SurfaceUnitNormal.y(),
SurfaceUnitNormal.z());
do {
notLastEdge = polyhedron.GetNextVertex (vertex[edgeCount],
edgeFlag[edgeCount]);
for(edgeCount = 0; edgeCount < n; ++edgeCount) {
// Check to see if edge is visible or not...
if (isAuxEdgeVisible) {
edgeFlag[edgeCount] = G4int (true);
edgeFlag[edgeCount] = 1;
}
if (edgeFlag[edgeCount]) {
if (edgeFlag[edgeCount] > 0) {
glEdgeFlag (GL_TRUE);
} else {
glEdgeFlag (GL_FALSE);
}
glNormal3d (normals[edgeCount].x(),
normals[edgeCount].y(),
normals[edgeCount].z());
glVertex3d (vertex[edgeCount].x(),
vertex[edgeCount].y(),
vertex[edgeCount].z());
edgeCount++;
} while (notLastEdge && edgeCount < 4);
// HEPPolyhedron produces triangles too; in that case add an extra vertex..
while (edgeCount < 4) {
vertex[edgeCount] = vertex[edgeCount-1];
edgeFlag[edgeCount] = G4int (false);
}
// HepPolyhedron produces triangles too; in that case add an extra
// vertex identical to first...
if (n == 3) {
edgeCount = 3;
normals[edgeCount] = normals[0];
vertex[edgeCount] = vertex[0];
edgeFlag[edgeCount] = -1;
glEdgeFlag (GL_FALSE);
glNormal3d (normals[edgeCount].x(),
normals[edgeCount].y(),
normals[edgeCount].z());
glVertex3d (vertex[edgeCount].x(),
vertex[edgeCount].y(),
vertex[edgeCount].z());
edgeCount++;
}
// Trap situation where number of edges is > 4...
while (notLastEdge) {
notLastFace = polyhedron.GetNextUnitNormal (SurfaceUnitNormal);
edgeCount++;
}
if (edgeCount > 4) {
if (n > 4) {
G4cerr <<
"G4OpenGLSceneHandler::AddPrimitive(G4Polyhedron): WARNING";
if (fpCurrentPV) {
@@ -488,7 +512,7 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
" (" << fpCurrentLV->GetSolid()->GetEntityType();
}
G4cerr<<
"\n G4Polyhedron facet with " << edgeCount << " edges" << G4endl;
"\n G4Polyhedron facet with " << n << " edges" << G4endl;
}
// Do it all over again (twice) for hlr...
@@ -503,49 +527,91 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
// Draw through stencil...
glStencilFunc (GL_EQUAL, 0, 1);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
glPolygonMode (GL_FRONT, GL_FILL);
if (drawing_style == G4ViewParameters::hlhsr) glEnable (GL_LIGHTING);
glBegin (GL_QUADS);
if (drawing_style == G4ViewParameters::hlr) {
glColor4dv (clear_colour);
} else { // drawing_style == G4ViewParameters::hlhsr
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColour);
if (drawing_style == G4ViewParameters::hlhsr) {
glEnable (GL_LIGHTING);
}
glNormal3d(SurfaceUnitNormal.x(), SurfaceUnitNormal.y(),
SurfaceUnitNormal.z());
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LEQUAL);
if (materialColour[3] < 1.) {
// Transparent...
glDepthMask (0); // Make depth buffer read-only.
glDisable (GL_CULL_FACE);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
} else {
// Opaque...
glDepthMask (1); // Make depth buffer writable (default).
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
glPolygonMode (GL_FRONT, GL_FILL);
}
GLfloat* painting_colour;
if (drawing_style == G4ViewParameters::hlr) {
if (materialColour[3] < 1.) {
// Transparent - don't paint...
goto end_of_drawing_through_stencil;
}
painting_colour = clear_colour;
} else { // drawing_style == G4ViewParameters::hlhsr
painting_colour = materialColour;
}
if (materialColour[3] < 1.) {
// Transparent...
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, painting_colour);
} else {
// Opaque...
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, painting_colour);
}
glColor4fv (painting_colour);
glBegin (GL_QUADS);
for (int edgeCount = 0; edgeCount < 4; ++edgeCount) {
if (edgeFlag[edgeCount]) {
if (edgeFlag[edgeCount] > 0) {
glEdgeFlag (GL_TRUE);
} else {
glEdgeFlag (GL_FALSE);
}
glNormal3d (normals[edgeCount].x(),
normals[edgeCount].y(),
normals[edgeCount].z());
glVertex3d (vertex[edgeCount].x(),
vertex[edgeCount].y(),
vertex[edgeCount].z());
}
glEnd ();
glDisable (GL_LIGHTING);
end_of_drawing_through_stencil:
// and once more to reset the stencil bits...
glStencilFunc (GL_ALWAYS, 0, 1);
glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
glDepthFunc (GL_LEQUAL); // to make sure line gets drawn.
glPolygonMode (GL_FRONT, GL_LINE);
if (materialColour[3] < 1.) {
// Transparent...
glDisable (GL_CULL_FACE);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
} else {
// Opaque...
glEnable (GL_CULL_FACE);
glCullFace (GL_BACK);
glPolygonMode (GL_FRONT, GL_LINE);
}
glDisable (GL_LIGHTING);
glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
glBegin (GL_QUADS);
for (int edgeCount = 0; edgeCount < 4; ++edgeCount) {
if (edgeFlag[edgeCount]) {
if (edgeFlag[edgeCount] > 0) {
glEdgeFlag (GL_TRUE);
} else {
glEdgeFlag (GL_FALSE);
}
glNormal3d (normals[edgeCount].x(),
normals[edgeCount].y(),
normals[edgeCount].z());
glVertex3d (vertex[edgeCount].x(),
vertex[edgeCount].y(),
vertex[edgeCount].z());
}
glEnd ();
glDepthFunc (GL_LESS); // Revert for next quadrilateral.
glBegin (GL_QUADS); // Ready for next quadrilateral. GL
glDepthFunc (GL_LEQUAL); // Revert for next facet.
glBegin (GL_QUADS); // Ready for next facet. GL
// says it ignores incomplete
// quadrilaterals, so final empty
// glBegin/End sequence should be OK.
@@ -553,7 +619,8 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
} while (notLastFace);
glEnd ();
glDisable (GL_STENCIL_TEST);
glDisable (GL_STENCIL_TEST); // Revert to default for next primitive.
glDepthMask (1); // Revert to default for next primitive.
}
//Method for handling G4NURBS objects for drawing solids.
@@ -608,7 +675,9 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4NURBS& nurb) {
materialColour [0] = c.GetRed ();
materialColour [1] = c.GetGreen ();
materialColour [2] = c.GetBlue ();
materialColour [3] = 1.0;
materialColour [3] = 1.0; // = c.GetAlpha () for transparency -
// but see complication in
// AddPrimitive(const G4Polyhedron&).
glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColour);
break;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredSceneHandler.cc,v 1.20 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLStoredSceneHandler.cc,v 1.23 2005/09/29 14:27:03 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -40,7 +40,9 @@
#include "G4OpenGLStoredSceneHandler.hh"
#include "G4OpenGLViewerDataStore.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
G4OpenGLStoredSceneHandler::G4OpenGLStoredSceneHandler (G4VGraphicsSystem& system,
const G4String& name):
@@ -196,13 +198,45 @@ void G4OpenGLStoredSceneHandler::ClearTransientStore () {
void G4OpenGLStoredSceneHandler::RequestPrimitives (const G4VSolid& solid) {
if (fReadyForTransients) {
// Always draw transient solids, e.g., hits represented as solids.
// (As we have no control over the order of drawing of transient
// objects, we cannot do anything about transparent ones, as
// below, so always draw them.)
G4VSceneHandler::RequestPrimitives (solid);
}
else {
// Stop-gap solution for display List re-use. A proper
// implementation would use geometry hierarchy.
// For non-transient (run-duration) objects, ensure transparent
// objects are drawn last. The problem of
// blending/transparency/alpha is quite a tricky one - see History
// of opengl-V07-01-01/2/3.
// Get vis attributes - pick up defaults if none.
const G4VisAttributes* pVA =
fpViewer -> GetApplicableVisAttributes(fpVisAttribs);
const G4Colour& c = pVA -> GetColour ();
G4double opacity = c.GetAlpha ();
if (!fSecondPass) {
G4bool transparency_enabled =
G4OpenGLViewerDataStore::GetTransparencyEnabled(fpViewer);
if (transparency_enabled && opacity < 1.) {
// On first pass, transparent objects are not drawn, but flag is set...
fSecondPassRequested = true;
return;
}
}
// On second pass, opaque objects are not drwan...
if (fSecondPass && opacity >= 1.) return;
// If a display list already exists for this solid, re-use it if
// possible. We could be smarter, and recognise repeated branches
// of the geometry hierarchy, for example. But this a;gorithm
// should be secure, I think...
const G4VSolid* pSolid = &solid;
if (fpCurrentPV && !(fpCurrentPV -> IsReplicated ()) &&
if (fpCurrentPV &&
// Provided it is not replicated (because if so, the solid's
// parameters might have been changed)...
!(fpCurrentPV -> IsReplicated ()) &&
// ...and if the solid has already been rendered...
(fSolidMap.find (pSolid) != fSolidMap.end ())) {
fDisplayListId = fSolidMap [pSolid];
fPODLList.push_back (fDisplayListId);
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredViewer.cc,v 1.11 2004/11/18 15:19:40 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLStoredViewer.cc,v 1.13 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -78,7 +78,8 @@ G4bool G4OpenGLStoredViewer::CompareForKernelVisit(G4ViewParameters& lastVP) {
fVP.GetCutawayPlanes ().size ()) ||
// No need to visit kernel if cutaway planes change.
(lastVP.IsExplode () != fVP.IsExplode ()) ||
(lastVP.GetNoOfSides () != fVP.GetNoOfSides ())
(lastVP.GetNoOfSides () != fVP.GetNoOfSides ()) ||
(lastVP.GetBackgroundColour ()!= fVP.GetBackgroundColour ())
) {
return true;
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredWin32.cc,v 1.12 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// OpenGLStoredWin32 graphics system factory.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredWin32Viewer.cc,v 1.9 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLStoredWin32Viewer.cc,v 1.10 2005/11/17 07:36:04 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Class G4OpenGLStoredWin32Viewer : a class derived from G4OpenGLWin32Viewer and
@@ -63,11 +63,10 @@ void G4OpenGLStoredWin32Viewer::Initialise () {
void G4OpenGLStoredWin32Viewer::DrawView () {
if (white_background == true) {
glClearColor (1., 1., 1., 1.);
} else {
glClearColor (0., 0., 0., 1.);
}
glClearColor (background.GetRed(),
background.GetGreen(),
background.GetBlue(),
1.);
//Make sure current viewer is attached and clean...
//Win32 version needed
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredX.cc,v 1.10 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredXViewer.cc,v 1.12 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLStoredXViewer.cc,v 1.13 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -77,11 +77,10 @@ void G4OpenGLStoredXViewer::DrawView () {
glXMakeCurrent (dpy, win, cx);
glViewport (0, 0, WinSize_x, WinSize_y);
if (white_background == true) {
glClearColor (1., 1., 1., 1.);
} else {
glClearColor (0., 0., 0., 1.);
}
glClearColor (background.GetRed(),
background.GetGreen(),
background.GetBlue(),
1.);
ClearView ();
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLStoredXm.cc,v 1.8 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredXmViewer.cc,v 1.11 2005/06/02 17:43:46 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLStoredXmViewer.cc,v 1.13 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -73,16 +73,14 @@ void G4OpenGLStoredXmViewer::Initialise () {
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel (GL_FLAT);
}
void G4OpenGLStoredXmViewer::DrawView () {
if (white_background == true) {
glClearColor (1., 1., 1., 1.);
} else {
glClearColor (0., 0., 0., 1.);
}
glClearColor (background.GetRed(),
background.GetGreen(),
background.GetBlue(),
1.);
//Make sure current viewer is attached and clean...
glXMakeCurrent (dpy, win, cx);
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLTransform3D.cc,v 1.7 2004/09/13 12:12:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 24th October 1996
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLViewer.cc,v 1.19 2004/07/09 15:44:26 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLViewer.cc,v 1.22 2005/10/13 17:31:47 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 27th March 1996
@@ -32,6 +32,7 @@
#include "G4ios.hh"
#include "G4OpenGLViewer.hh"
#include "G4OpenGLViewerDataStore.hh"
#include "G4OpenGLSceneHandler.hh"
#include "G4OpenGLTransform3D.hh"
@@ -45,8 +46,8 @@
G4OpenGLViewer::G4OpenGLViewer (G4OpenGLSceneHandler& scene):
G4VViewer (scene, -1),
white_background (false),
transparency_enabled (false),
background (G4Colour(0.,0.,0.)),
transparency_enabled (true),
antialiasing_enabled (false),
haloing_enabled (false)
{
@@ -54,6 +55,8 @@ haloing_enabled (false)
fVP.SetAutoRefresh(true);
fDefaultVP.SetAutoRefresh(true);
G4OpenGLViewerDataStore::SetTransparencyEnabled(this, transparency_enabled);
// glClearColor (0.0, 0.0, 0.0, 0.0);
// glClearDepth (1.0);
// glDisable (GL_BLEND);
@@ -120,6 +123,9 @@ void G4OpenGLViewer::SetView () {
glMatrixMode (GL_PROJECTION); // set up Frustum.
glLoadIdentity();
const G4Vector3D scale = fVP.GetScaleFactor();
glScaled(scale.x(),scale.y(),scale.z());
if (fVP.GetFieldHalfAngle() == 0.) {
glOrtho (left, right, bottom, top, pnear, pfar);
@@ -169,7 +175,10 @@ void G4OpenGLViewer::SetView () {
glDisable (GL_CLIP_PLANE0);
glDisable (GL_CLIP_PLANE1);
}
// Background.
background = fVP.GetBackgroundColour ();
}
void G4OpenGLViewer::HaloingFirstPass () {
@@ -0,0 +1,45 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4OpenGLViewerDataStore.cc,v 1.1 2005/09/29 14:26:18 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
#include "G4OpenGLViewerDataStore.hh"
std::map<G4VViewer*,G4bool> G4OpenGLViewerDataStore::fTransparencyEnabledMap;
void G4OpenGLViewerDataStore::SetTransparencyEnabled
(G4VViewer* viewer, G4bool transparency_enabled) {
fTransparencyEnabledMap[viewer] = transparency_enabled;
}
G4bool G4OpenGLViewerDataStore::GetTransparencyEnabled(G4VViewer* viewer) {
std::map<G4VViewer*,G4bool>::const_iterator i;
i = fTransparencyEnabledMap.find(viewer);
if (i != fTransparencyEnabledMap.end()) {
return i->second;
} else {
return true; // Default.
}
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLWin32Viewer.cc,v 1.14 2004/11/15 12:13:08 gbarrand Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// G4OpenGLWin32Viewer : Class to provide WindowsNT specific
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXViewer.cc,v 1.25 2005/04/22 12:02:47 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLXViewer.cc,v 1.28 2005/11/22 16:10:12 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 7th February 1997
@@ -223,35 +223,58 @@ void G4OpenGLXViewer::CreateMainWindow () {
swa.event_mask = ExposureMask | ButtonPressMask | StructureNotifyMask;
swa.backing_store = WhenMapped;
// Window size and position...
unsigned int width, height;
x_origin = 0;
y_origin = 0;
size_hints = XAllocSizeHints();
const G4String& XGeometryString = fVP.GetXGeometryString();
int screen_num = DefaultScreen(dpy);
if (!XGeometryString.empty()) {
G4int geometryResultMask = XParseGeometry
((char*)XGeometryString.c_str(),
&x_origin, &y_origin, &width, &height);
if (geometryResultMask & (WidthValue | HeightValue)) {
if (geometryResultMask & XValue) {
if (geometryResultMask & XNegative) {
x_origin = DisplayWidth(dpy, screen_num) + x_origin - width;
}
size_hints->flags |= PPosition;
size_hints->x = x_origin;
}
if (geometryResultMask & YValue) {
if (geometryResultMask & YNegative) {
y_origin = DisplayHeight(dpy, screen_num) + y_origin - height;
}
size_hints->flags |= PPosition;
size_hints->y = y_origin;
}
} else {
G4cout << "ERROR: Geometry string \""
<< XGeometryString
<< "\" invalid. Using \"600x600\"."
<< G4endl;
width = 600;
height = 600;
}
}
size_hints->width = width;
size_hints->height = height;
size_hints->flags |= PSize;
// G4int WinSize_x;
// G4int WinSize_y;
if (xwa.width > xwa.height) {
WinSize_x = (xwa.height)/2;
WinSize_y = (xwa.height)/2;
}
else {
WinSize_x = (xwa.width)/2;
WinSize_y = (xwa.width)/2;
}
if (WinSize_x < fVP.GetWindowSizeHintX ())
WinSize_x = fVP.GetWindowSizeHintX ();
if (WinSize_y < fVP.GetWindowSizeHintY ())
WinSize_y = fVP.GetWindowSizeHintY ();
x_origin = xwa.x;
y_origin = xwa.y;
WinSize_x = width;
WinSize_y = height;
G4cout << "Window name: " << fName << G4endl;
strncpy (charViewName, fName, 100);
char *window_name = charViewName;
char *icon_name = charViewName;
//char tmpatom[] = "XA_WM_NORMAL_HINTS";
size_hints = XAllocSizeHints();
wm_hints = XAllocWMHints();
class_hints = XAllocClassHint();
size_hints -> flags = PPosition | PSize | PMinSize;
size_hints -> min_width = 300;
size_hints -> min_height = 200;
XStringListToTextProperty (&window_name, 1, &windowName);
XStringListToTextProperty (&icon_name, 1, &iconName);
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmBox.cc,v 1.5 2001/07/11 10:08:56 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Box container class
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmConvenienceRoutines.cc,v 1.10 2004/12/07 23:40:59 perl Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 16th April 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmFourArrowButtons.cc,v 1.4 2001/07/11 10:08:57 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Four arrow buttons class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmFramedBox.cc,v 1.5 2001/07/11 10:08:57 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Framed box container class
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXmMainMenubarCallbacks.cc,v 1.11 2004/07/01 15:29:15 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLXmMainMenubarCallbacks.cc,v 1.12 2005/10/13 17:33:24 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 16th April 1997
@@ -52,7 +52,7 @@
#include "G4OpenGLXmTopLevelShell.hh"
#include "G4OpenGLXmSeparator.hh"
#include <strstream>
#include <sstream>
void G4OpenGLXmViewer::actions_callback (Widget w,
XtPointer clientData,
@@ -74,14 +74,11 @@ void G4OpenGLXmViewer::actions_callback (Widget w,
{
if (!pView->fprotation_top) {
const int rot_len = 50;
char* frot_Name = new char [rot_len];
std::ostrstream rot_ost (frot_Name, rot_len);
rot_ost.seekp (std::ios::beg);
rot_ost << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId << std::ends;
std::ostringstream rot_Name;
rot_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId;
pView->fprotation_top = new G4OpenGLXmTopLevelShell (pView,
frot_Name);
pView->fprotation_top = new G4OpenGLXmTopLevelShell (pView,
(char*)rot_Name.str().c_str());
pView->fprotation_button_box = new G4OpenGLXmBox ("Rotation button box", True);
pView->fprotation_top->AddChild (pView->fprotation_button_box);
@@ -161,14 +158,11 @@ void G4OpenGLXmViewer::actions_callback (Widget w,
{
if (!pView->fppanning_top) {
const int pan_len = 50;
char* fpan_Name = new char [pan_len];
std::ostrstream pan_ost (fpan_Name, pan_len);
pan_ost.seekp (std::ios::beg);
pan_ost << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId << std::ends;
std::ostringstream pan_Name;
pan_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId;
pView->fppanning_top = new G4OpenGLXmTopLevelShell (pView,
fpan_Name);
(char*)pan_Name.str().c_str());
pView->fppanning_box = new G4OpenGLXmFramedBox ("Pan up-down-left-right",
False);
@@ -261,14 +255,11 @@ void G4OpenGLXmViewer::actions_callback (Widget w,
{
if (!pView->fpsetting_top) {
const int set_len = 50;
char* fset_Name = new char [set_len];
std::ostrstream set_ost (fset_Name, set_len);
set_ost.seekp (std::ios::beg);
set_ost << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId << std::ends;
std::ostringstream set_Name;
set_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId;
pView->fpsetting_top = new G4OpenGLXmTopLevelShell(pView,
fset_Name);
(char*)set_Name.str().c_str());
pView->fpsetting_box = new G4OpenGLXmFramedBox ("Set values for control panels",
False);
@@ -342,14 +333,11 @@ void G4OpenGLXmViewer::misc_callback (Widget w,
if (!pView->fpmiscellany_top) {
const int misc_len = 50;
char* fmisc_Name = new char [misc_len];
std::ostrstream misc_ost (fmisc_Name, misc_len);
misc_ost.seekp (std::ios::beg);
misc_ost << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId << std::ends;
std::ostringstream misc_Name;
misc_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId;
pView->fpmiscellany_top = new G4OpenGLXmTopLevelShell (pView,
fmisc_Name);
(char*)misc_Name.str().c_str());
pView->fpwobble_box = new G4OpenGLXmFramedBox ("Wobble view",
True);
pView->fpmiscellany_top->AddChild (pView->fpwobble_box);
@@ -437,14 +425,11 @@ void G4OpenGLXmViewer::misc_callback (Widget w,
{
if (!pView->fpprint_top) {
const int print_len = 50;
char* fprint_Name = new char [print_len];
std::ostrstream print_ost (fprint_Name, print_len);
print_ost.seekp (std::ios::beg);
print_ost << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId << std::ends;
std::ostringstream print_Name;
print_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId;
pView->fpprint_top = new G4OpenGLXmTopLevelShell (pView,
fprint_Name);
(char*)print_Name.str().c_str());
pView->fpprint_box = new G4OpenGLXmFramedBox ("Create EPS file of current view",
False);
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmPanningCallbacks.cc,v 1.7 2004/07/01 15:28:09 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 16th April 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmPushButton.cc,v 1.5 2001/07/11 10:08:57 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Push button class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmRadioButton.cc,v 1.5 2001/07/11 10:08:57 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Radio button class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmRotationCallbacks.cc,v 1.13 2004/12/10 18:16:00 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 16th April 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmSeparator.cc,v 1.4 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Separator class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmSliderBar.cc,v 1.6 2004/12/07 23:40:59 perl Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Slider bar class. Inherits from G4OpenGLXmVWidgetComponent
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXmStyleCallbacks.cc,v 1.8 2005/02/23 11:24:52 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLXmStyleCallbacks.cc,v 1.12 2005/10/13 17:30:08 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 16th April 1997
@@ -35,6 +35,8 @@
#include "G4OpenGLXmViewer.hh"
#include "G4OpenGLViewerDataStore.hh"
void G4OpenGLXmViewer::drawing_style_callback (Widget w,
XtPointer clientData,
XtPointer)
@@ -120,27 +122,21 @@ void G4OpenGLXmViewer::background_color_callback (Widget w,
NULL);
//I need to revisit the kernel if the background colour changes and hidden
//line removal is enabled, because hlr drawing utilises the background
//colour in its drawing...
//I need to revisit the kernel if the background colour changes and
//hidden line removal is enabled, because hlr drawing utilises the
//background colour in its drawing...
// (Note added by JA 13/9/2005) Background now handled in view
// parameters. A kernel visit is triggered on change of background.
switch (choice) {
case 0:
if (!pView->white_background) {
pView->white_background = true;
if (pView->GetViewParameters().GetDrawingStyle() == G4ViewParameters::hlr) {
pView->SetNeedKernelVisit (true);
}
}
((G4ViewParameters&)pView->GetViewParameters()).
SetBackgroundColour(G4Colour(1.,1.,1.)); // White
break;
case 1:
if (pView->white_background) {
pView->white_background = false;
if (pView->GetViewParameters().GetDrawingStyle() == G4ViewParameters::hlr) {
pView->SetNeedKernelVisit (true);
}
}
((G4ViewParameters&)pView->GetViewParameters()).
SetBackgroundColour(G4Colour(0.,0.,0.)); // Black
break;
default:
@@ -166,20 +162,19 @@ void G4OpenGLXmViewer::transparency_callback (Widget w,
case 0:
pView->transparency_enabled = false;
glDisable (GL_BLEND);
G4OpenGLViewerDataStore::SetTransparencyEnabled(pView, false);
break;
case 1:
pView->transparency_enabled = true;
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel (GL_FLAT);
G4OpenGLViewerDataStore::SetTransparencyEnabled(pView, true);
break;
default:
G4Exception("Unrecognised case in transparency_callback.");
}
pView->SetNeedKernelVisit (true);
pView->SetView ();
pView->ClearView ();
pView->DrawView ();
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmTextField.cc,v 1.6 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Text field class. Inherits from G4OpenGLXmVWidgetComponent
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmTopLevelShell.cc,v 1.4 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Top level shell class
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetComponent.cc,v 1.4 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Base class for all Motif component widgets
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetContainer.cc,v 1.4 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Base class for all Motif container widgets
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetObject.cc,v 1.4 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Virtual base class for all Motif widgets.
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmVWidgetShell.cc,v 1.4 2001/07/11 10:08:58 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//Base class for all Motif shell widgets
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXmViewer.cc,v 1.16 2005/04/22 12:02:47 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4OpenGLXmViewer.cc,v 1.21 2005/11/22 16:03:23 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 10th February 1997
@@ -34,8 +34,7 @@
#include "globals.hh"
#include "G4OpenGLXmViewer.hh"
#include "G4ios.hh"
#include "G4OpenGLXmViewerMessenger.hh"
#include "G4VisExtent.hh"
#include "G4LogicalVolume.hh"
@@ -48,6 +47,8 @@
#include "G4Xt.hh"
#include <X11/Shell.h>
#include <sstream>
void G4OpenGLXmViewer::ShowView () {
G4Xt::getInstance () -> SecondaryLoop ();
@@ -68,26 +69,33 @@ void G4OpenGLXmViewer::GetXmConnection () {
}
// Better to put this in an X11 resource file !!!
interactorManager->PutStringInResourceDatabase ((char*)"\
*glxarea*width: 500\n\
*glxarea*height: 500\n\
*frame*x: 10\n\
*frame*y: 10\n\
*frame*topOffset: 10\n\
*frame*bottomOffset: 10\n\
*frame*rightOffset: 10\n\
*frame*leftOffset: 10\n\
*frame*shadowType: SHADOW_IN\n\
*frame*useColorObj: False\n\
*frame*primaryColorSetId: 3\n\
*frame*secondaryColorSetId: 3\n\
*menubar*useColorObj: False\n\
*menubar*primaryColorSetId: 3\n\
*menubar*secondaryColorSetId: 3\n\
*toplevel*useColorObj: False\n\
*toplevel*primaryColorSetId: 3\n\
*toplevel*secondaryColorSetId: 3\n\
");
std::ostringstream oss;
oss <<
"*glxarea*width: " << fVP.GetWindowSizeHintX() << "\n"
"*glxarea*height: " << fVP.GetWindowSizeHintY() << "\n"
/*
// Tried this as a replacement for the above two lines, but
// sub-windows (rotation, etc.) came same size!!
"*geometry: " << fVP.GetXGeometryString() << "\n"
*/
"*frame*x: 10\n"
"*frame*y: 10\n"
"*frame*topOffset: 10\n"
"*frame*bottomOffset: 10\n"
"*frame*rightOffset: 10\n"
"*frame*leftOffset: 10\n"
"*frame*shadowType: SHADOW_IN\n"
"*frame*useColorObj: False\n"
"*frame*primaryColorSetId: 3\n"
"*frame*secondaryColorSetId: 3\n"
"*menubar*useColorObj: False\n"
"*menubar*primaryColorSetId: 3\n"
"*menubar*secondaryColorSetId: 3\n"
"*toplevel*useColorObj: False\n"
"*toplevel*primaryColorSetId: 3\n"
"*toplevel*secondaryColorSetId: 3\n";
interactorManager->PutStringInResourceDatabase ((char*)oss.str().c_str());
// interactorManager->AddSecondaryLoopPostAction ((G4SecondaryLoopAction)G4OpenGLXmViewerSecondaryLoopPostAction);
shell = XtAppCreateShell ((String)fName.data(),(String)fName.data(),topLevelShellWidgetClass,XtDisplay(toplevel),NULL,0);
@@ -311,18 +319,18 @@ void G4OpenGLXmViewer::CreateMainWindow () {
XtNbackground, bgnd,
NULL);
if (white_background == true) {
if (background.GetRed() == 1. &&
background.GetGreen() == 1. &&
background.GetBlue() == 1.) {
special_widget = XtNameToWidget(background_color_pullright, "button_0");
if(special_widget) {
XtVaSetValues (special_widget, XmNset, True, NULL);
}
} else if (white_background == false) {
} else {
special_widget = XtNameToWidget(background_color_pullright, "button_1");
if(special_widget) {
XtVaSetValues (special_widget, XmNset, True, NULL);
}
} else {
G4Exception("white_background in G4OpenGLXmViewer is neither true nor false!!");
}
XmStringFree (white_str);
@@ -609,17 +617,20 @@ rot_sens (4.),
wob_sens (20.),
original_vp(fVP.GetViewpointDirection()),
frameNo (0),
fprotation_top (NULL),
fprotation_slider (NULL),
fppanning_top (NULL),
fppanning_slider (NULL),
fpzoom_slider (NULL),
fpdolly_slider (NULL),
fpsetting_top (NULL),
fpmiscellany_top (NULL),
fpprint_top (NULL)
fprotation_top (0),
fprotation_slider (0),
fppanning_top (0),
fppanning_slider (0),
fpzoom_slider (0),
fpdolly_slider (0),
fpsetting_top (0),
fpmiscellany_top (0),
fpprint_top (0),
fpMessenger (0)
{
fpMessenger = new G4OpenGLXmViewerMessenger(this, fShortName);
WinSize_x = 100;
WinSize_y = 100;
@@ -652,6 +663,8 @@ G4OpenGLXmViewer::~G4OpenGLXmViewer ()
delete fpmiscellany_top;
}
******************************/
delete fpMessenger;
}
#endif
@@ -0,0 +1,261 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4OpenGLXmViewerMessenger.cc,v 1.2 2005/11/24 10:23:43 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#include "G4OpenGLXmViewerMessenger.hh"
#include "G4OpenGLXmViewer.hh"
#include "G4OpenGLXmSliderBar.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithADouble.hh"
G4OpenGLXmViewerMessenger::G4OpenGLXmViewerMessenger
(G4OpenGLXmViewer* viewer, const G4String& viewerShortName):
fpViewer(viewer),
fViewerShortName(viewerShortName)
{
G4String directoryName;
G4String guidance;
G4String commandName;
G4bool omitable;
directoryName = "/vis/oglxm-" + fViewerShortName + '/';
fpDirectory = new G4UIdirectory(directoryName);
guidance = "G4OpenGLXmViewer \"" + fViewerShortName + "\" commands.";
fpDirectory -> SetGuidance(guidance);
directoryName = directoryName + "set/";
fpDirectorySet = new G4UIdirectory (directoryName);
guidance = "G4OpenGLXmViewer \"" + fViewerShortName + "\" set commands.";
fpDirectorySet -> SetGuidance(guidance);
commandName = directoryName + "dolly-high";
fpCommandSetDollyHigh = new G4UIcmdWithADoubleAndUnit
(commandName, this);
fpCommandSetDollyHigh -> SetGuidance("Higher limit of dolly slider.");
fpCommandSetDollyHigh -> SetParameterName("dolly-high", omitable = false);
commandName = directoryName + "dolly-low";
fpCommandSetDollyLow = new G4UIcmdWithADoubleAndUnit
(commandName, this);
fpCommandSetDollyLow -> SetGuidance("Lower limit of dolly slider.");
fpCommandSetDollyLow -> SetParameterName("dolly-low", omitable = false);
commandName = directoryName + "pan-high";
fpCommandSetPanHigh = new G4UIcmdWithADoubleAndUnit
(commandName, this);
fpCommandSetPanHigh -> SetGuidance("Higher limit of pan slider.");
fpCommandSetPanHigh -> SetParameterName("pan-high", omitable = false);
commandName = directoryName + "rotation-high";
fpCommandSetRotationHigh = new G4UIcmdWithADoubleAndUnit
(commandName, this);
fpCommandSetRotationHigh -> SetGuidance("Higher limit of rotation slider.");
fpCommandSetRotationHigh -> SetParameterName("rotation-high", omitable = false);
commandName = directoryName + "zoom-high";
fpCommandSetZoomHigh = new G4UIcmdWithADouble
(commandName, this);
fpCommandSetZoomHigh -> SetGuidance("Higher limit of zoom slider.");
fpCommandSetZoomHigh -> SetParameterName("zoom-high", omitable = false);
commandName = directoryName + "zoom-low";
fpCommandSetZoomLow = new G4UIcmdWithADouble
(commandName, this);
fpCommandSetZoomLow -> SetGuidance("Lower limit of zoom slider.");
fpCommandSetZoomLow -> SetParameterName("zoom-low", omitable = false);
}
G4OpenGLXmViewerMessenger::~G4OpenGLXmViewerMessenger ()
{
delete fpCommandSetZoomLow;
delete fpCommandSetZoomHigh;
delete fpCommandSetRotationHigh;
delete fpCommandSetPanHigh;
delete fpCommandSetDollyLow;
delete fpCommandSetDollyHigh;
delete fpDirectorySet;
delete fpDirectory;
}
void G4OpenGLXmViewerMessenger::SetNewValue
(G4UIcommand* command, G4String newValue)
{
G4bool panningControlPanel = true;
G4bool rotationControlPanel = true;
if (command == fpCommandSetDollyHigh)
{
if (fpViewer->fpdolly_slider)
{
fpViewer->dolly_high =
fpCommandSetDollyHigh->GetNewDoubleValue(newValue);
fpViewer->fpdolly_slider->SetMaxValue (fpViewer->dolly_high);
if (fpViewer->fVP.GetDolly() > fpViewer->dolly_high)
{
fpViewer->fpdolly_slider->SetInitialValue (fpViewer->dolly_high);
fpViewer->fVP.SetDolly(fpViewer->dolly_high);
}
else
{
fpViewer->fpdolly_slider->SetInitialValue (fpViewer->fVP.GetDolly());
}
}
else
{
panningControlPanel = false;
}
}
else if (command == fpCommandSetDollyLow)
{
if (fpViewer->fpdolly_slider)
{
fpViewer->dolly_low =
fpCommandSetDollyLow->GetNewDoubleValue(newValue);
fpViewer->fpdolly_slider->SetMinValue (fpViewer->dolly_low);
if (fpViewer->fVP.GetDolly() < fpViewer->dolly_low)
{
fpViewer->fpdolly_slider->SetInitialValue (fpViewer->dolly_low);
fpViewer->fVP.SetDolly(fpViewer->dolly_low);
}
else
{
fpViewer->fpdolly_slider->SetInitialValue (fpViewer->fVP.GetDolly());
}
}
else
{
panningControlPanel = false;
}
}
else if (command == fpCommandSetPanHigh)
{
if (fpViewer->fppanning_slider)
{
fpViewer->pan_sens_limit =
fpCommandSetPanHigh->GetNewDoubleValue(newValue);
fpViewer->fppanning_slider->SetMaxValue (fpViewer->pan_sens_limit);
fpViewer->fppanning_slider->SetInitialValue (fpViewer->pan_sens_limit / 2.);
}
else
{
panningControlPanel = false;
}
}
else if (command == fpCommandSetRotationHigh)
{
if (fpViewer->fprotation_slider)
{
// Internally in OpenGLXm, it's in degrees...
fpViewer->rot_sens_limit =
fpCommandSetRotationHigh->GetNewDoubleValue(newValue) / deg;
fpViewer->fprotation_slider->SetMaxValue (fpViewer->rot_sens_limit);
fpViewer->fprotation_slider->SetInitialValue (fpViewer->rot_sens_limit / 2.);
}
else
{
rotationControlPanel = false;
}
}
else if (command == fpCommandSetZoomHigh)
{
if (fpViewer->fpzoom_slider)
{
fpViewer->zoom_high =
fpCommandSetZoomHigh->GetNewDoubleValue(newValue);
fpViewer->fpzoom_slider->SetMaxValue (fpViewer->zoom_high);
fpViewer->fpzoom_slider->SetInitialValue (fpViewer->fVP.GetZoomFactor());
if (fpViewer->fVP.GetZoomFactor() > fpViewer->zoom_high)
{
fpViewer->fpzoom_slider->SetInitialValue (fpViewer->zoom_high);
fpViewer->fVP.SetZoomFactor(fpViewer->zoom_high);
}
else
{
fpViewer->fpzoom_slider->SetInitialValue (fpViewer->fVP.GetZoomFactor());
}
}
else
{
panningControlPanel = false;
}
}
else if (command == fpCommandSetZoomLow)
{
if (fpViewer->fpzoom_slider)
{
fpViewer->zoom_low =
fpCommandSetZoomLow->GetNewDoubleValue(newValue);
fpViewer->fpzoom_slider->SetMinValue (fpViewer->zoom_low);
fpViewer->fpzoom_slider->SetInitialValue (fpViewer->fVP.GetZoomFactor());
if (fpViewer->fVP.GetZoomFactor() < fpViewer->zoom_low)
{
fpViewer->fpzoom_slider->SetInitialValue (fpViewer->zoom_low);
fpViewer->fVP.SetZoomFactor(fpViewer->zoom_low);
}
else
{
fpViewer->fpzoom_slider->SetInitialValue (fpViewer->fVP.GetZoomFactor());
}
}
else
{
panningControlPanel = false;
}
}
if (!panningControlPanel)
{
G4cout <<
"*** G4OpenGLXmViewerMessenger::SetNewValue: pull down panning"
"\n*** control panel and re-issue command."
<< G4endl;
return;
}
if (!rotationControlPanel)
{
G4cout <<
"*** G4OpenGLXmViewerMessenger::SetNewValue: pull down rotation"
"\n*** control panel and re-issue command."
<< G4endl;
return;
}
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
}
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: G4OpenGLXmWindowHandlingCallbacks.cc,v 1.5 2001/07/11 10:08:59 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// Andrew Walkden 16th June 1997