1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026734: Visualization, TKOpenGl - drop outdated UserDraw interfaces

Update ViewerTest and VoxelDemo to not use UserDraw callbacks.

OpenGl_View::blitBuffers() - set 0 GLSL program after blit
to avoid side effects on code that does not use shaders.

Drop interfaces Aspect_GraphicCallbackProc, Graphic3d_CUserDraw,
Graphic3d_Group::UserDraw(), OpenGl_GraphicDriver::UserDrawCallback().

V3d_View::SetWindow() - remove optional arguments initializing redraw callback.
OpenGl_View, declare following methods as virtual for inheritance:
redraw(), redrawImmediate(), render(), renderScene(), drawBackground(), renderStructs().

VocelClient_VisDrawer - do not include removed header
This commit is contained in:
kgv
2015-10-08 09:33:48 +03:00
committed by bugmaster
parent 4d4b43db21
commit a521d90d5a
24 changed files with 113 additions and 372 deletions

View File

@@ -1,53 +0,0 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Aspect_GraphicCallbackProc_HeaderFile
#define _Aspect_GraphicCallbackProc_HeaderFile
// To manage client post display
#include <Aspect_Display.hxx>
#include <Aspect_Drawable.hxx>
#include <Aspect_RenderingContext.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Transient.hxx>
// The flags below provide additional information to define the moment when
// callback was invoked in redraw procedure. These flags are bitwise OR'ed
// with the "reason" value of callback:
// 1) OCC_PRE_REDRAW - callback was invoked before redrawing underlayer
// ( at the beginning of redraw procedure );
// 2) OCC_PRE_OVERLAY - callback was invoked before redrawing overlayer;
// Otherwise, if no flags added to the "reason" value, the callback was
// invoked at the end of redraw ( after the overlayer is redrawn )
#define OCC_PRE_REDRAW 0x4000
#define OCC_PRE_OVERLAY 0x8000
// mask for all additional callbacks that invoked in process of redrawing
#define OCC_REDRAW_ADDITIONAL_CALLBACKS ( OCC_PRE_REDRAW | OCC_PRE_OVERLAY )
typedef struct
{
int reason;
int wsID;
int viewID;
bool IsCoreProfile;
Handle(Standard_Transient) glContext;
} Aspect_GraphicCallbackStruct;
// Prototype for callback function to perform custom drawing within the same window and GL context.
typedef int (*Aspect_GraphicCallbackProc) (Aspect_Drawable theWindowID,
void* theUserData,
Aspect_GraphicCallbackStruct* theCallData);
#endif /* _Aspect_GraphicCallbackProc_HeaderFile */

View File

@@ -26,7 +26,6 @@ Aspect_GenId.hxx
Aspect_GradientBackground.cxx
Aspect_GradientBackground.hxx
Aspect_GradientFillMethod.hxx
Aspect_GraphicCallbackProc.hxx
Aspect_GraphicDeviceDefinitionError.hxx
Aspect_Grid.cxx
Aspect_Grid.hxx

View File

@@ -55,7 +55,6 @@ Graphic3d_CStructure.cxx
Graphic3d_CStructure.hxx
Graphic3d_CStructurePtr.hxx
Graphic3d_CTexture.hxx
Graphic3d_CUserDraw.hxx
Graphic3d_CView.cxx
Graphic3d_CView.hxx
Graphic3d_CycleError.hxx

View File

@@ -1,27 +0,0 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
/*============================================================================*/
/*==== Titre: Graphic3d_CUserDraw.hxx */
/*==== Role : The header file of primitive type "CUserDraw" from Graphic3d */
/*==== */
/*==== Implementation: This is a primitive type implemented with typedef */
/*============================================================================*/
#ifndef _Graphic3d_CUserDraw_HeaderFile
#define _Graphic3d_CUserDraw_HeaderFile
#include <InterfaceGraphic_Graphic3d.hxx>
typedef CALL_DEF_USERDRAW Graphic3d_CUserDraw;
#endif /*Graphic3d_CUserDraw_HeaderFile*/

View File

@@ -14,7 +14,6 @@
#ifndef _Graphic3d_CView_HeaderFile
#define _Graphic3d_CView_HeaderFile
#include <Aspect_GraphicCallbackProc.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Aspect_RenderingContext.hxx>
@@ -252,16 +251,10 @@ public:
virtual Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) = 0;
//! Creates and maps rendering window to the view.
//! @param theView [in] the view to associate with the window.
//! @param theWindow [in] the window.
//! @param theContext [in] the rendering context. If NULL the context will be created internally.
//! @param theDisplayCB [in] the display callback function. If is not a NULL value, then the callback will be
//! invoked at the end of the OCC graphic traversal and just before the swap of buffers.
//! @param theClientData [in] the client data for the callback.
virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext = NULL,
const Aspect_GraphicCallbackProc& theDisplayCB = NULL,
const Standard_Address theClientData = NULL) = 0;
const Aspect_RenderingContext theContext = NULL) = 0;
//! Returns the window associated to the view.
virtual Handle(Aspect_Window) Window() const = 0;

View File

@@ -1074,30 +1074,6 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
AddPrimitiveArray (aPoints, theToEvalMinMax);
}
// =======================================================================
// function : UserDraw
// purpose :
// =======================================================================
void Graphic3d_Group::UserDraw (const Standard_Address /*theObject*/,
const Standard_Boolean /*theToEvalMinMax*/,
const Standard_Boolean theContainsFacet)
{
if (IsDeleted())
{
return;
}
// Without this modification, the group assumes the primitive contains
// no polygons and does not require the Z-buffer for display.
if (!MyContainsFacet && theContainsFacet)
{
myStructure->GroupsWithFacet (1);
MyContainsFacet = Standard_True;
}
Update();
}
// =======================================================================
// function : Text
// purpose :

View File

@@ -248,9 +248,6 @@ public:
//! Creates a primitive array with single marker using AddPrimitiveArray().
Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
//! Creates a UserDraw primitive using obsolete API.
Standard_EXPORT virtual void UserDraw (const Standard_Address theObject, const Standard_Boolean theToEvalMinMax = Standard_True, const Standard_Boolean theContainsFacet = Standard_False);
//! sets the stencil test to theIsEnabled state;
Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;

View File

@@ -84,13 +84,4 @@ typedef struct
CALL_DEF_POINT Point;
} CALL_DEF_TRANSFORM_PERSISTENCE;
/* USERDRAW DATA */
typedef struct {
void* Data;
Graphic3d_BndBox4f* Bounds;
} CALL_DEF_USERDRAW;
#endif /* InterfaceGraphic_Graphic3dHeader */

View File

@@ -66,8 +66,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
#endif
myCaps (new OpenGl_Caps()),
myMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator()),
myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator()),
myUserDrawCallback (NULL)
myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator())
{
#if !defined(_WIN32) && !defined(__ANDROID__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
if (myDisplayConnection.IsNull())
@@ -388,15 +387,6 @@ Standard_Integer OpenGl_GraphicDriver::InquirePlaneLimit()
return aCtx.IsNull() ? 0 : Max (aCtx->MaxClipPlanes() - 2, 0);
}
// =======================================================================
// function : UserDrawCallback
// purpose :
// =======================================================================
OpenGl_GraphicDriver::OpenGl_UserDrawCallback_t& OpenGl_GraphicDriver::UserDrawCallback()
{
return myUserDrawCallback;
}
// =======================================================================
// function : DefaultTextHeight
// purpose :

View File

@@ -33,7 +33,6 @@
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Graphic3d_CUserDraw.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_TypeOfComposition.hxx>
#include <Graphic3d_ExportFormat.hxx>
@@ -194,12 +193,6 @@ public:
Standard_EXPORT Standard_Boolean MemoryInfo (Standard_Size& theFreeBytes,
TCollection_AsciiString& theInfo) const;
//! UserDraw function prototype
typedef OpenGl_Element* (*OpenGl_UserDrawCallback_t )(const CALL_DEF_USERDRAW* );
//! Method to setup UserDraw callback
Standard_EXPORT OpenGl_UserDrawCallback_t& UserDrawCallback();
public:
//! Method to retrieve valid GL context.
@@ -228,7 +221,6 @@ protected:
Handle(OpenGl_Caps) myCaps;
NCollection_Map<Handle(OpenGl_View)> myMapOfView;
NCollection_DataMap<Standard_Integer, OpenGl_Structure*> myMapOfStructure;
OpenGl_UserDrawCallback_t myUserDrawCallback;
public:

View File

@@ -25,7 +25,6 @@
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_CUserDraw.hxx>
#include <Graphic3d_GroupDefinitionError.hxx>
@@ -271,36 +270,6 @@ void OpenGl_Group::Text (const Standard_CString theTextUtf,
}
// =======================================================================
// function : UserDraw
// purpose :
// =======================================================================
void OpenGl_Group::UserDraw (const Standard_Address theObject,
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theContainsFacet)
{
if (IsDeleted())
{
return;
}
OpenGl_Structure* aStruct = GlStruct();
if (aStruct->GlDriver()->UserDrawCallback() == NULL)
{
return;
}
Graphic3d_CUserDraw aUserDraw;
aUserDraw.Data = theObject;
aUserDraw.Bounds = theToEvalMinMax ? &myBounds : NULL;
OpenGl_Element* aUserDrawElem = aStruct->GlDriver()->UserDrawCallback()(&aUserDraw);
if (aUserDrawElem != NULL)
{
AddElement (aUserDrawElem);
}
Graphic3d_Group::UserDraw (theObject, theToEvalMinMax, theContainsFacet);
}
// =======================================================================
// function : SetFlippingOptions
// purpose :

View File

@@ -87,11 +87,6 @@ public:
const Graphic3d_VerticalTextAlignment theVTA,
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
//! Add UserDraw element using obsolete API
Standard_EXPORT virtual void UserDraw (const Standard_Address theObject,
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theContainsFacet);
//! Add flipping element
Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
const gp_Ax2& theRefPlane);

View File

@@ -15,7 +15,6 @@
#include <OpenGl_View.hxx>
#include <Aspect_GraphicCallbackProc.hxx>
#include <Aspect_RenderingContext.hxx>
#include <Aspect_Window.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
@@ -107,9 +106,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
myMainSceneFbos[1] = new OpenGl_FrameBuffer();
myImmediateSceneFbos[0] = new OpenGl_FrameBuffer();
myImmediateSceneFbos[1] = new OpenGl_FrameBuffer();
myDisplayCallback.Func = NULL;
myDisplayCallback.Data = NULL;
}
// =======================================================================
@@ -234,18 +230,13 @@ Standard_Boolean OpenGl_View::SetImmediateModeDrawToFront (const Standard_Boolea
// purpose :
// =======================================================================
void OpenGl_View::SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext,
const Aspect_GraphicCallbackProc& theDisplayCB,
const Standard_Address theClientData)
const Aspect_RenderingContext theContext)
{
myWindow = myDriver->CreateRenderWindow (theWindow, theContext);
Standard_ASSERT_RAISE (!myWindow.IsNull(),
"OpenGl_View::SetWindow, "
"Failed to create OpenGl window.");
myDisplayCallback.Func = theDisplayCB;
myDisplayCallback.Data = theClientData;
myWorkspace = new OpenGl_Workspace (this, myWindow);
myWorldViewProjState.Reset();
myToUpdateEnvironmentMap = Standard_True;

View File

@@ -123,16 +123,10 @@ public:
Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) Standard_OVERRIDE;
//! Creates and maps rendering window to the view.
//! @param theView [in] the view to associate with the window.
//! @param theWindow [in] the window.
//! @param theContext [in] the rendering context. If NULL the context will be created internally.
//! @param theDisplayCB [in] the display callback function. If is not a NULL value, then the callback will be
//! invoked at the end of the OCC graphic traversal and just before the swap of buffers.
//! @param theClientData [in] the client data for the callback.
Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext,
const Aspect_GraphicCallbackProc& theDisplayCB,
const Standard_Address theClientData) Standard_OVERRIDE;
Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext) Standard_OVERRIDE;
//! Returns window associated with the view.
virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE { return myWindow->PlatformWindow(); }
@@ -442,8 +436,6 @@ public:
void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
void DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
//! Returns list of OpenGL Z-layers.
const OpenGl_LayerList& LayerList() const { return myZLayers; }
@@ -471,10 +463,11 @@ protected: //! @name Internal methods for managing GL resources
//! Initializes OpenGl resource for environment texture.
void initTextureEnv (const Handle(OpenGl_Context)& theContext);
protected: //! @name Internal redrawing sub-routines
protected: //! @name low-level redrawing sub-routines
//! Redraws view for the given monographic camera projection, or left/right eye.
void redraw (const Graphic3d_Camera::Projection theProjection, OpenGl_FrameBuffer* theReadDrawFbo);
Standard_EXPORT virtual void redraw (const Graphic3d_Camera::Projection theProjection,
OpenGl_FrameBuffer* theReadDrawFbo);
//! Redraws view for the given monographic camera projection, or left/right eye.
//!
@@ -488,30 +481,18 @@ protected: //! @name Internal redrawing sub-routines
//!
//! @return false if immediate structures has been rendered directly into FrontBuffer
//! and Buffer Swap should not be called.
bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
OpenGl_FrameBuffer* theReadFbo,
OpenGl_FrameBuffer* theDrawFbo,
const Standard_Boolean theIsPartialUpdate = Standard_False);
//! Copy content of Back buffer to the Front buffer.
void copyBackToFront();
//! Initialize blit quad.
OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
Standard_EXPORT virtual bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
OpenGl_FrameBuffer* theReadFbo,
OpenGl_FrameBuffer* theDrawFbo,
const Standard_Boolean theIsPartialUpdate = Standard_False);
//! Blit image from/to specified buffers.
bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
OpenGl_FrameBuffer* theDrawFbo,
const Standard_Boolean theToFlip = Standard_False);
Standard_EXPORT bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
OpenGl_FrameBuffer* theDrawFbo,
const Standard_Boolean theToFlip = Standard_False);
//! Setup default FBO.
void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
//! Blend together views pair into stereo image.
void drawStereoPair();
//! Invokes display callback.
void displayCallback (const Standard_Integer theReason);
Standard_EXPORT void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
@@ -519,21 +500,24 @@ protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
//! @param theProjection [in] the projection that should be used for rendering.
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
void render (Graphic3d_Camera::Projection theProjection,
OpenGl_FrameBuffer* theReadDrawFbo,
const Standard_Boolean theToDrawImmediate);
Standard_EXPORT virtual void render (Graphic3d_Camera::Projection theProjection,
OpenGl_FrameBuffer* theReadDrawFbo,
const Standard_Boolean theToDrawImmediate);
//! Renders the graphical scene.
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
void renderScene (OpenGl_FrameBuffer* theReadDrawFbo,
const Standard_Boolean theToDrawImmediate);
Standard_EXPORT virtual void renderScene (OpenGl_FrameBuffer* theReadDrawFbo,
const Standard_Boolean theToDrawImmediate);
//! Draw background (gradient / image)
Standard_EXPORT virtual void drawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
//! Render set of structures presented in the view.
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
void renderStructs (OpenGl_FrameBuffer* theReadDrawFbo,
const Standard_Boolean theToDrawImmediate);
Standard_EXPORT virtual void renderStructs (OpenGl_FrameBuffer* theReadDrawFbo,
const Standard_Boolean theToDrawImmediate);
//! Renders trihedron.
void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
@@ -555,6 +539,17 @@ private:
Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
const Standard_Integer theNewPriority) Standard_OVERRIDE;
private:
//! Copy content of Back buffer to the Front buffer.
void copyBackToFront();
//! Initialize blit quad.
OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
//! Blend together views pair into stereo image.
void drawStereoPair();
protected:
OpenGl_GraphicDriver* myDriver;
@@ -603,12 +598,6 @@ protected:
Handle(OpenGl_Texture) myTextureEnv;
struct
{
Aspect_GraphicCallbackProc Func;
Standard_Address Data;
} myDisplayCallback;
protected: //! @name Rendering properties
//! Two framebuffers (left and right views) store cached main presentation

View File

@@ -149,10 +149,10 @@ static void bindLight (const OpenGl_Light& theLight,
#endif
//=======================================================================
//function : DrawBackground
//function : drawBackground
//purpose :
//=======================================================================
void OpenGl_View::DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
{
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
@@ -804,7 +804,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
// Render background
if (!theToDrawImmediate)
{
DrawBackground (myWorkspace);
drawBackground (myWorkspace);
}
#if !defined(GL_ES_VERSION_2_0)
@@ -924,7 +924,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
// Resetting GL parameters according to the default aspects
// in order to synchronize GL state with the graphic driver state
// before drawing auxiliary stuff (trihedrons, overlayer)
// and invoking optional callbacks
myWorkspace->ResetAppliedAspect();
aContext->ChangeClipping().RemoveAll();
@@ -958,12 +957,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
}
}
// ==============================================================
// Step 5: Invoke callback after redraw
// ==============================================================
displayCallback (0);
// ==============================================================
// Step 6: Keep shader manager informed about last View
// ==============================================================
@@ -1525,6 +1518,7 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
aVerts->UnbindVertexAttrib (aCtx, Graphic3d_TOA_POS);
theReadFbo->DepthStencilTexture()->Unbind (aCtx, GL_TEXTURE0 + 1);
theReadFbo->ColorTexture() ->Unbind (aCtx, GL_TEXTURE0 + 0);
aCtx->BindProgram (NULL);
}
else
{
@@ -1759,23 +1753,3 @@ void OpenGl_View::copyBackToFront()
#endif
myIsImmediateDrawn = Standard_False;
}
// =======================================================================
// function : displayCallback
// purpose :
// =======================================================================
void OpenGl_View::displayCallback (const Standard_Integer theReason)
{
if (myDisplayCallback.Func == NULL)
{
return;
}
Aspect_GraphicCallbackStruct aCallData;
aCallData.reason = theReason;
aCallData.glContext = myWorkspace->GetGlContext();
aCallData.wsID = -1;
aCallData.viewID = myId;
aCallData.IsCoreProfile = (myWorkspace->GetGlContext()->core11 == NULL);
myDisplayCallback.Func (myWindow->PlatformWindow()->NativeHandle(), myDisplayCallback.Data, &aCallData);
}

View File

@@ -245,10 +245,8 @@ void V3d_View::SetMagnify (const Handle(Aspect_Window)& theWindow,
//function : SetWindow
//purpose :
//=============================================================================
void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext,
const Aspect_GraphicCallbackProc& theDisplayCB,
const Standard_Address theClientData)
void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext)
{
if (myView->IsRemoved())
{
@@ -257,7 +255,7 @@ void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
// method V3d_View::SetWindow() should assign the field MyWindow before calling Redraw()
MyWindow = theWindow;
myView->SetWindow (theWindow, theContext, theDisplayCB, theClientData);
myView->SetWindow (theWindow, theContext);
MyViewer->SetViewOn (this);
SetRatio();
Redraw();

View File

@@ -21,7 +21,6 @@
#include <Aspect_FillMethod.hxx>
#include <Aspect_GradientBackground.hxx>
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_GraphicCallbackProc.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Aspect_RenderingContext.hxx>
@@ -135,18 +134,10 @@ public:
//! If <aContext> is not NULL the graphic context is used
//! to draw something in this view.
//! Otherwise an internal graphic context is created.
//! If <aDisplayCB> is not NULL then a user display CB is
//! call at the end of the OCC graphic traversal and just
//! before the swap of buffers. The <aClientData> is pass
//! to this call back.
//! Warning! raises MultiplyDefined from Standard
//! if the view is already activated in a window.
//! Warning: The view is centered and resized to preserve
//! the height/width ratio of the window.
Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& theWindow,
const Aspect_RenderingContext theContext = NULL,
const Aspect_GraphicCallbackProc& theDisplayCB = NULL,
const Standard_Address theClientData = NULL);
const Aspect_RenderingContext theContext = NULL);
Standard_EXPORT void SetMagnify (const Handle(Aspect_Window)& theWindow,
const Handle(V3d_View)& thePreviousView,

View File

@@ -81,17 +81,9 @@ public:
Handle(VUserDrawObj) myIObj;
public:
Element (const Handle(VUserDrawObj)& theIObj,
Graphic3d_BndBox4f* theBounds)
: myIObj( theIObj )
{
if (!myIObj.IsNull())
myIObj->GetBounds(theBounds);
}
Element (const Handle(VUserDrawObj)& theIObj) : myIObj (theIObj) {}
virtual ~Element ()
{
}
virtual ~Element() {}
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
@@ -119,21 +111,28 @@ private:
// Called by VUserDrawElement
void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
void GetBounds(Graphic3d_BndBox4f* theBounds);
private:
GLfloat myCoords[6];
friend class Element;
};
void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
const Handle(Prs3d_Presentation)& thePresentation,
void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer /*theMode*/)
{
thePresentation->Clear();
thePrs->Clear();
Handle(Graphic3d_Group) aGrp = Prs3d_Root::CurrentGroup(thePresentation);
aGrp->UserDraw(this, Standard_True, Standard_True);
Graphic3d_Vec4 aBndMin (myCoords[0], myCoords[1], myCoords[2], 1.0f);
Graphic3d_Vec4 aBndMax (myCoords[3], myCoords[4], myCoords[5], 1.0f);
Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (thePrs->NewGroup());
aGroup->SetMinMaxValues (aBndMin.x(), aBndMin.y(), aBndMin.z(),
aBndMax.x(), aBndMax.y(), aBndMax.z());
VUserDrawObj::Element* anElem = new VUserDrawObj::Element (this);
aGroup->AddElement(anElem);
// invalidate bounding box of the scene
thePrsMgr->StructureManager()->Update (thePrsMgr->StructureManager()->UpdateMode());
}
void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
@@ -150,26 +149,12 @@ void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelec
theSelection->Add(aSensitive);
}
void VUserDrawObj::GetBounds(Graphic3d_BndBox4f* theBounds)
{
if (theBounds)
{
Graphic3d_Vec4 aMinPt (myCoords[0], myCoords[1], myCoords[2], 1.0f);
Graphic3d_Vec4 aMaxPt (myCoords[3], myCoords[4], myCoords[5], 1.0f);
if (!theBounds->IsValid())
{
theBounds->Combine (Graphic3d_BndBox4f (aMinPt, aMaxPt));
}
else
{
theBounds->CornerMin() = aMinPt;
theBounds->CornerMax() = aMaxPt;
}
}
}
void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
{
// this sample does not use GLSL programs - make sure it is disabled
Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext();
aCtx->BindProgram (NULL);
// To test linking against OpenGl_Workspace and all aspect classes
const OpenGl_AspectLine* aLA = theWorkspace->AspectLine(0);
const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker(0);
@@ -179,9 +164,6 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
TEL_COLOUR aColor = theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT ?
*(theWorkspace->HighlightColor) : aLA->Color();
// To test OpenGl_Window
//Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext();
// Finally draw something to make sure UserDraw really works
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
@@ -197,17 +179,6 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
} // end of anonymous namespace
OpenGl_Element* VUserDrawCallback(const CALL_DEF_USERDRAW * theUserDraw)
{
Handle(VUserDrawObj) anIObj = (VUserDrawObj*)theUserDraw->Data;
if (anIObj.IsNull())
{
std::cout << "VUserDrawCallback error: null object passed, the custom scene element will not be rendered" << std::endl;
}
return new VUserDrawObj::Element(anIObj, theUserDraw->Bounds);
}
static Standard_Integer VUserDraw (Draw_Interpretor& di,
Standard_Integer argc,
const char ** argv)
@@ -235,9 +206,6 @@ static Standard_Integer VUserDraw (Draw_Interpretor& di,
TCollection_AsciiString aName (argv[1]);
VDisplayAISObject(aName, Handle(AIS_InteractiveObject)());
// register the custom element factory function
aDriver->UserDrawCallback() = VUserDrawCallback;
Handle(VUserDrawObj) anIObj = new VUserDrawObj();
VDisplayAISObject(aName, anIObj);

View File

@@ -154,7 +154,8 @@ void Voxel_Prs::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresent
}
}
G->UserDraw(myVisData);
///Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (G);
///aGroup->AddElement (myVisData);
}
void Voxel_Prs::ComputeSelection(const Handle(SelectMgr_Selection)& /*theSelection*/,

View File

@@ -127,7 +127,7 @@ protected:
private:
protected:
Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);