mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024637: Visualization - clean up implementation of rendering in immediate mode
Remove unused flag "DoubleBuf". Remove Visual3d_TransientManager "class" (functionality moved to PrsMgr_PresentationManager). Remove unused "Add" immediate mode. V3d_View class - remove methods ::TransientManagerBeginDraw(), ::TransientManagerClearDraw(), ::TransientManagerBeginAddDraw(). Add method ::RedrawImmediate() to redraw only immediate presentations. OpenGl_GraphicDriver - add methods ::DisplayImmediateStructure(), ::EraseImmediateStructure(), ::RedrawImmediate(). OpenGl_View - manage list of immediate structures. OpenGl_Workspace - automate rendering workflow of immediate + persistent layers. Merge PrsMgr_PresentationManager3d class into PrsMgr_PresentationManager. Mark PrsMgr_PresentationManager3d as alias to PrsMgr_PresentationManager to simplify porting. Prs3d_Presentation - remove unused field myStruct. Prs3d_PresentationShadow - shadow link to existing presentation with custom attributes. Graphic3d_Structure::Highlight() - do not register undisplayed structure in structure manager. AIS_InteractiveContext, AIS_LocalContext add flag to prevent view update into methods ::MoveTo(), ::HilightNextDetected(), ::HilightPreviousDetected() to allow update of customized immediate structures before redraw but after ::MoveTo(). Remove unused method AIS_InteractiveContext::Drag(). StdSelect_ViewerSelector3d do not user immediate mode in methods ::DisplayAreas(), ::ClearAreas(), ::ClearSensitive(), ::DisplaySensitive(), GridEcho - update value in StdSelect_ViewerSelector3d::Pick() instead of V3d_View::Compute(). Do not use global variable for GridEcho vertex. Redraw immediate mode not within GridEcho but at AIS_InteractiveContext, AIS_LocalContext layer. V3d_View::ToPixMap() - disable autoupdate during FitAll. Avoid Redraw() into FBO without ImmediateModeDrawToFront flag. PrsMgr_PresentationManager stores list of temporary immediate presentations, automatically cleared within BeginImmediateMode() call. Methods with ambiguous names have been renamed (new names now consistent with pre-existed method names in AIS_LocalContext class): - BeginDraw -> BeginImmediateDraw - EndDraw -> EndImmediateDraw Remove now useless Remove() method (and ImmediateRemove() in AIS). Visual3d_View now stores map of displayed immediate presentations. ViewerTest_EventManager - eliminate double redraw in selection methods. Fix warning
This commit is contained in:
@@ -16,101 +16,169 @@
|
||||
|
||||
#include <ViewerTest_EventManager.ixx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Aspect_Grid.hxx>
|
||||
#include <NIS_View.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewerTest_EventManager
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
ViewerTest_EventManager::ViewerTest_EventManager
|
||||
(const Handle(V3d_View)& aView,
|
||||
const Handle(AIS_InteractiveContext)& Ctx)
|
||||
: myCtx (Ctx),
|
||||
myView (aView),
|
||||
myX (-1),
|
||||
myY (-1)
|
||||
ViewerTest_EventManager::ViewerTest_EventManager (const Handle(V3d_View)& theView,
|
||||
const Handle(AIS_InteractiveContext)& theCtx)
|
||||
: myCtx (theCtx),
|
||||
myView (theView),
|
||||
myX (-1),
|
||||
myY (-1)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : MoveTo
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::MoveTo(const Standard_Integer XPix,
|
||||
const Standard_Integer YPix)
|
||||
void ViewerTest_EventManager::MoveTo (const Standard_Integer theXPix,
|
||||
const Standard_Integer theYPix)
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->MoveTo(XPix,YPix,myView);
|
||||
myX = XPix;
|
||||
myY = YPix;
|
||||
Standard_Real aPnt3d[3] = {0.0, 0.0, 0.0};
|
||||
if (!myCtx.IsNull()
|
||||
&& !myView.IsNull())
|
||||
{
|
||||
const Standard_Boolean toEchoGrid = myView->Viewer()->Grid()->IsActive()
|
||||
&& myView->Viewer()->GridEcho();
|
||||
switch (myCtx->MoveTo (theXPix, theYPix, myView, !toEchoGrid))
|
||||
{
|
||||
case AIS_SOD_Nothing:
|
||||
{
|
||||
if (toEchoGrid)
|
||||
{
|
||||
myView->ConvertToGrid (theXPix, theYPix, aPnt3d[0], aPnt3d[1], aPnt3d[2]);
|
||||
myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (aPnt3d[0], aPnt3d[1], aPnt3d[2]));
|
||||
myView->RedrawImmediate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (toEchoGrid)
|
||||
{
|
||||
myView->Viewer()->HideGridEcho (myView);
|
||||
myView->RedrawImmediate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myX = theXPix;
|
||||
myY = theYPix;
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
aView->DynamicHilight (XPix, YPix);
|
||||
{
|
||||
aView->DynamicHilight (theXPix, theYPix);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::Select(const Standard_Integer XPMin,
|
||||
const Standard_Integer YPMin,
|
||||
const Standard_Integer XPMax,
|
||||
const Standard_Integer YPMax)
|
||||
void ViewerTest_EventManager::Select (const Standard_Integer theXPMin,
|
||||
const Standard_Integer theYPMin,
|
||||
const Standard_Integer theXPMax,
|
||||
const Standard_Integer theYPMax)
|
||||
{
|
||||
#define IS_FULL_INCLUSION Standard_True
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->Select(XPMin,YPMin,XPMax,YPMax,myView);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
#define IS_FULL_INCLUSION Standard_True
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!myCtx.IsNull())
|
||||
{
|
||||
myCtx->Select (theXPMin, theYPMin, theXPMax, theYPMax, myView, Standard_False);
|
||||
}
|
||||
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_False, IS_FULL_INCLUSION);
|
||||
{
|
||||
aView->Select (theXPMin, theYPMin, theXPMax, theYPMax, Standard_False, IS_FULL_INCLUSION, Standard_False);
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShiftSelect
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::ShiftSelect(const Standard_Integer XPMin,
|
||||
const Standard_Integer YPMin,
|
||||
const Standard_Integer XPMax,
|
||||
const Standard_Integer YPMax)
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->AIS_InteractiveContext::ShiftSelect(XPMin,YPMin,XPMax,YPMax,myView,
|
||||
Standard_True);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
void ViewerTest_EventManager::ShiftSelect (const Standard_Integer theXPMin,
|
||||
const Standard_Integer theYPMin,
|
||||
const Standard_Integer theXPMax,
|
||||
const Standard_Integer theYPMax)
|
||||
{
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!myCtx.IsNull())
|
||||
{
|
||||
myCtx->AIS_InteractiveContext::ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax, myView, Standard_False);
|
||||
}
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_True, IS_FULL_INCLUSION);
|
||||
{
|
||||
aView->Select (theXPMin, theYPMin, theXPMax, theYPMax, Standard_True, IS_FULL_INCLUSION, Standard_False);
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::Select()
|
||||
{
|
||||
if (!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->Select();
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!myCtx.IsNull())
|
||||
{
|
||||
myCtx->Select (Standard_False);
|
||||
}
|
||||
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(myX, myY);
|
||||
{
|
||||
aView->Select (myX, myY, Standard_False);
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShiftSelect
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::ShiftSelect()
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->ShiftSelect(Standard_True);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!myCtx.IsNull())
|
||||
{
|
||||
myCtx->ShiftSelect (Standard_False);
|
||||
}
|
||||
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
|
||||
if (!aView.IsNull())
|
||||
aView->Select(myX, myY, Standard_True);
|
||||
{
|
||||
aView->Select (myX, myY, Standard_False);
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -118,21 +186,28 @@ void ViewerTest_EventManager::ShiftSelect()
|
||||
//purpose : Selection with polyline
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::Select(const TColgp_Array1OfPnt2d& thePolyline)
|
||||
void ViewerTest_EventManager::Select (const TColgp_Array1OfPnt2d& thePolyline)
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->Select(thePolyline,myView);
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!myCtx.IsNull())
|
||||
{
|
||||
myCtx->Select (thePolyline, myView, Standard_False);
|
||||
}
|
||||
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (!aView.IsNull())
|
||||
{
|
||||
NCollection_List<gp_XY> aPolylist;
|
||||
for(Standard_Integer anIter = thePolyline.Lower();anIter <= thePolyline.Upper();++anIter)
|
||||
for(Standard_Integer anIter = thePolyline.Lower(); anIter <= thePolyline.Upper(); ++anIter)
|
||||
{
|
||||
aPolylist.Append(gp_XY(thePolyline.Value(anIter).X(),
|
||||
thePolyline.Value(anIter).Y()));
|
||||
aPolylist.Append (gp_XY (thePolyline.Value (anIter).X(), thePolyline.Value (anIter).Y()));
|
||||
}
|
||||
aView->Select(aPolylist);
|
||||
aView->Select (aPolylist, Standard_False, Standard_False, Standard_False);
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -140,19 +215,26 @@ void ViewerTest_EventManager::Select(const TColgp_Array1OfPnt2d& thePolyline)
|
||||
//purpose : Selection with polyline without erasing of current selection
|
||||
//=======================================================================
|
||||
|
||||
void ViewerTest_EventManager::ShiftSelect(const TColgp_Array1OfPnt2d& thePolyline)
|
||||
void ViewerTest_EventManager::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline)
|
||||
{
|
||||
if(!myCtx.IsNull() && !myView.IsNull())
|
||||
myCtx->ShiftSelect(thePolyline,myView);
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (!myCtx.IsNull())
|
||||
{
|
||||
myCtx->ShiftSelect (thePolyline, myView, Standard_False);
|
||||
}
|
||||
|
||||
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
|
||||
if (!aView.IsNull())
|
||||
{
|
||||
NCollection_List<gp_XY> aPolylist;
|
||||
for(Standard_Integer anIter = thePolyline.Lower();anIter <= thePolyline.Upper();++anIter)
|
||||
for (Standard_Integer anIter = thePolyline.Lower(); anIter <= thePolyline.Upper(); ++anIter)
|
||||
{
|
||||
aPolylist.Append(gp_XY(thePolyline.Value(anIter).X(),
|
||||
thePolyline.Value(anIter).Y()));
|
||||
aPolylist.Append (gp_XY (thePolyline.Value (anIter).X(), thePolyline.Value (anIter).Y()));
|
||||
}
|
||||
aView->Select(aPolylist, Standard_True);
|
||||
aView->Select (aPolylist, Standard_True, Standard_False, Standard_False);
|
||||
}
|
||||
myView->Redraw();
|
||||
}
|
||||
|
Reference in New Issue
Block a user