34#ifdef G4VIS_BUILD_OPENGL_DRIVER
41#define CENTERLINE_CLPP
59G4OpenGLImmediateSceneHandler::G4OpenGLImmediateSceneHandler
61 G4OpenGLSceneHandler (system, fSceneIdCount++, name)
64G4OpenGLImmediateSceneHandler::~G4OpenGLImmediateSceneHandler ()
69G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreamble(
const G4Visible& visible)
71 const G4Colour& c = GetColour (visible);
74 G4bool transparency_enabled =
true;
75 G4bool isMarkerNotHidden =
true;
76 G4OpenGLViewer* pViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
78 transparency_enabled = pViewer->transparency_enabled;
79 isMarkerNotHidden = pViewer->fVP.IsMarkerNotHidden();
84 (void)
dynamic_cast<const G4VMarker&
>(visible);
87 catch (std::bad_cast) {}
91 (void)
dynamic_cast<const G4Polyline&
>(visible);
94 catch (std::bad_cast) {}
96 G4bool isMarkerOrPolyline = isMarker || isPolyline;
97 G4bool treatAsTransparent = transparency_enabled && opacity < 1.;
98 G4bool treatAsNotHidden = isMarkerNotHidden && (isMarker || isPolyline);
100 if (fProcessing2D) glDisable (GL_DEPTH_TEST);
102 if (isMarkerOrPolyline && isMarkerNotHidden)
103 glDisable (GL_DEPTH_TEST);
104 else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);}
107 if (fThreePassCapable) {
112 if (!(fSecondPassForTransparency || fThirdPassForNonHiddenMarkers)) {
114 if (treatAsTransparent) {
115 fSecondPassForTransparencyRequested =
true;
117 if (treatAsNotHidden) {
118 fThirdPassForNonHiddenMarkersRequested =
true;
121 if (treatAsTransparent || treatAsNotHidden) {
127 if (fSecondPassForTransparency) {
128 if (!treatAsTransparent) {
134 if (fThirdPassForNonHiddenMarkers) {
135 if (!treatAsNotHidden) {
142 if (fpViewer->GetViewParameters().IsPicking()) {
143 glLoadName(++fPickName);
145 LoadAtts(visible, holder);
146 fPickMap[fPickName] = holder;
149 if (transparency_enabled) {
158void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polyline& polyline)
160 G4bool furtherprocessing = AddPrimitivePreamble(polyline);
161 if (furtherprocessing) {
162 G4OpenGLSceneHandler::AddPrimitive(polyline);
166void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polymarker& polymarker)
168 G4bool furtherprocessing = AddPrimitivePreamble(polymarker);
169 if (furtherprocessing) {
170 G4OpenGLSceneHandler::AddPrimitive(polymarker);
174void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Text& text)
178 G4bool furtherprocessing = AddPrimitivePreamble(text);
179 if (furtherprocessing) {
180 G4OpenGLSceneHandler::AddPrimitive(text);
184void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Circle& circle)
186 G4bool furtherprocessing = AddPrimitivePreamble(circle);
187 if (furtherprocessing) {
188 G4OpenGLSceneHandler::AddPrimitive(circle);
192void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Square& square)
194 G4bool furtherprocessing = AddPrimitivePreamble(square);
195 if (furtherprocessing) {
196 G4OpenGLSceneHandler::AddPrimitive(square);
200void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Scale& scale)
202 G4bool furtherprocessing = AddPrimitivePreamble(scale);
203 if (furtherprocessing) {
204 G4OpenGLSceneHandler::AddPrimitive(scale);
208void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polyhedron& polyhedron)
212 G4bool furtherprocessing = AddPrimitivePreamble(polyhedron);
213 if (furtherprocessing) {
214 G4OpenGLSceneHandler::AddPrimitive(polyhedron);
218void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4NURBS& nurbs)
222 G4bool furtherprocessing = AddPrimitivePreamble(nurbs);
223 if (furtherprocessing) {
224 G4OpenGLSceneHandler::AddPrimitive(nurbs);
228void G4OpenGLImmediateSceneHandler::BeginPrimitives
231 G4OpenGLSceneHandler::BeginPrimitives (objectTransformation);
233 G4OpenGLTransform3D oglt (objectTransformation);
247 glMultMatrixd (oglt.GetGLMatrix ());
250void G4OpenGLImmediateSceneHandler::EndPrimitives ()
257 G4OpenGLSceneHandler::EndPrimitives ();
260void G4OpenGLImmediateSceneHandler::BeginPrimitives2D
263 G4OpenGLSceneHandler::BeginPrimitives2D(objectTransformation);
267 glMatrixMode (GL_PROJECTION);
270 glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
271 glMatrixMode (GL_MODELVIEW);
274 G4OpenGLTransform3D oglt (objectTransformation);
275 glMultMatrixd (oglt.GetGLMatrix ());
276 glDisable(GL_DEPTH_TEST);
277 glDisable (GL_LIGHTING);
280void G4OpenGLImmediateSceneHandler::EndPrimitives2D()
283 glMatrixMode (GL_PROJECTION);
285 glMatrixMode (GL_MODELVIEW);
291 G4OpenGLSceneHandler::EndPrimitives2D ();
294void G4OpenGLImmediateSceneHandler::BeginModeling () {
298void G4OpenGLImmediateSceneHandler::EndModeling () {
302void G4OpenGLImmediateSceneHandler::ClearTransientStore ()
306 fpViewer -> SetView ();
307 fpViewer -> ClearView ();
308 fpViewer -> DrawView ();
312G4int G4OpenGLImmediateSceneHandler::fSceneIdCount = 0;
G4double GetAlpha() const
G4double GetGreen() const
virtual void BeginModeling()
virtual void EndModeling()