From 679ecdeeac9a41c8ed6e14501ca292707bbde932 Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 20 Mar 2014 13:54:12 +0400 Subject: [PATCH] 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 --- src/AIS/AIS_InteractiveContext.cdl | 65 +- src/AIS/AIS_InteractiveContext_1.cxx | 239 +++---- src/AIS/AIS_InteractiveContext_2.cxx | 75 +-- src/AIS/AIS_LengthDimension.hxx | 1 - src/AIS/AIS_LocalContext.cdl | 61 +- src/AIS/AIS_LocalContext.cxx | 95 +-- src/AIS/AIS_LocalContext_1.cxx | 597 +++++++---------- src/AIS/AIS_TexturedShape.hxx | 4 - src/Graphic3d/Graphic3d_CStructure.hxx | 3 + src/Graphic3d/Graphic3d_GraphicDriver.cdl | 87 +-- src/Graphic3d/Graphic3d_Structure.cdl | 22 +- src/Graphic3d/Graphic3d_Structure.cxx | 33 +- src/Graphic3d/Graphic3d_StructureManager.cdl | 5 +- src/MeshVS/MeshVS_Mesh.cxx | 6 +- src/OpenGl/FILES | 1 - src/OpenGl/OpenGl_Flipper.cxx | 2 +- src/OpenGl/OpenGl_GraphicDriver.cxx | 96 +-- src/OpenGl/OpenGl_GraphicDriver.hxx | 29 +- src/OpenGl/OpenGl_GraphicDriver_7.cxx | 27 +- src/OpenGl/OpenGl_NamedStatus.hxx | 15 +- src/OpenGl/OpenGl_Structure.cxx | 68 +- src/OpenGl/OpenGl_Structure.hxx | 5 +- src/OpenGl/OpenGl_View.hxx | 32 +- src/OpenGl/OpenGl_View_2.cxx | 37 ++ src/OpenGl/OpenGl_Window.cxx | 9 - src/OpenGl/OpenGl_Window.hxx | 3 - src/OpenGl/OpenGl_Workspace.cxx | 224 ++++++- src/OpenGl/OpenGl_Workspace.hxx | 41 +- src/OpenGl/OpenGl_Workspace_2.cxx | 132 +--- src/OpenGl/OpenGl_Workspace_3.cxx | 232 ------- src/Prs3d/FILES | 2 + src/Prs3d/Prs3d_Presentation.cdl | 30 +- src/Prs3d/Prs3d_Presentation.cxx | 72 +- src/Prs3d/Prs3d_PresentationShadow.cxx | 30 + src/Prs3d/Prs3d_PresentationShadow.hxx | 39 ++ src/PrsMgr/FILES | 1 + src/PrsMgr/PrsMgr.cdl | 9 +- src/PrsMgr/PrsMgr_ListOfPresentations.hxx | 28 + src/PrsMgr/PrsMgr_Presentation3d.cdl | 6 +- src/PrsMgr/PrsMgr_PresentationManager.cdl | 461 +++++++------ src/PrsMgr/PrsMgr_PresentationManager.cxx | 658 +++++++++++++------ src/PrsMgr/PrsMgr_PresentationManager.lxx | 9 +- src/PrsMgr/PrsMgr_PresentationManager3d.cdl | 191 ------ src/PrsMgr/PrsMgr_PresentationManager3d.cxx | 196 ------ src/PrsMgr/PrsMgr_PresentationManager3d.lxx | 19 - src/StdSelect/StdSelect_ViewerSelector3d.cxx | 78 +-- src/V3d/V3d_View.cdl | 54 +- src/V3d/V3d_View.cxx | 66 +- src/V3d/V3d_View_4.cxx | 40 -- src/V3d/V3d_Viewer.cdl | 20 +- src/V3d/V3d_Viewer.cxx | 51 +- src/V3d/V3d_Viewer_4.cxx | 441 ++++++++----- src/ViewerTest/ViewerTest_EventManager.cxx | 206 ++++-- src/Visual3d/Visual3d.cdl | 7 - src/Visual3d/Visual3d_TransientManager.cdl | 194 ------ src/Visual3d/Visual3d_TransientManager.cxx | 239 ------- src/Visual3d/Visual3d_View.cdl | 102 ++- src/Visual3d/Visual3d_View.cxx | 241 ++++--- src/Visual3d/Visual3d_ViewManager.cdl | 32 +- src/Visual3d/Visual3d_ViewManager.cxx | 107 +-- 60 files changed, 2716 insertions(+), 3159 deletions(-) delete mode 100644 src/OpenGl/OpenGl_Workspace_3.cxx create mode 100644 src/Prs3d/Prs3d_PresentationShadow.cxx create mode 100644 src/Prs3d/Prs3d_PresentationShadow.hxx create mode 100644 src/PrsMgr/FILES create mode 100644 src/PrsMgr/PrsMgr_ListOfPresentations.hxx delete mode 100644 src/PrsMgr/PrsMgr_PresentationManager3d.cdl delete mode 100644 src/PrsMgr/PrsMgr_PresentationManager3d.cxx delete mode 100644 src/PrsMgr/PrsMgr_PresentationManager3d.lxx delete mode 100644 src/Visual3d/Visual3d_TransientManager.cdl delete mode 100644 src/Visual3d/Visual3d_TransientManager.cxx diff --git a/src/AIS/AIS_InteractiveContext.cdl b/src/AIS/AIS_InteractiveContext.cdl index 0a1c72d66b..183c40a78d 100644 --- a/src/AIS/AIS_InteractiveContext.cdl +++ b/src/AIS/AIS_InteractiveContext.cdl @@ -25,7 +25,6 @@ -- GG : 25/05/00 BUC60688 Add SetSensitivity() methods -- VSV : 22/05/01 Add Selection by polygon -- SAV : Add DisplayFromCollector() method --- GG : IMP150501 CADPAK_V2 Add Drag() method -- ZSV : IMP160701 Add InitDetected(),MoreDetected(),NextDetected(), -- DetectedCurrentShape(),DetectedCurrentObject() -- methods @@ -1090,20 +1089,23 @@ is ---Category: GRAPHIC DETECTION / SELECTION - - MoveTo(me:mutable;XPix,YPix:Integer from Standard;aView:View from V3d) + MoveTo (me : mutable; + theXPix, theYPix : Integer from Standard; + theView : View from V3d; + theToRedrawOnUpdate : Boolean from Standard = Standard_True) returns StatusOfDetection from AIS; ----Purpose: Relays mouse position in pixels XPix and YPix to the --- interactive context selectors. This is done by the view --- aView passing this position to the main viewer and updating it. --- Functions in both Neutral Point and local contexts. - + ---Purpose: Relays mouse position in pixels theXPix and theYPix to the interactive context selectors. + -- This is done by the view theView passing this position to the main viewer and updating it. + -- Functions in both Neutral Point and local contexts. + -- If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object. HasNextDetected(me) returns Boolean from Standard; ---Purpose: returns True if other entities were detected in the -- last mouse detection - HilightNextDetected(me:mutable;aView:View from V3d) + HilightNextDetected (me : mutable; + theView : View from V3d; + theToRedrawImmediate : Boolean from Standard = Standard_True) returns Integer from Standard; ---Purpose: if more than 1 object is detected by the selector, -- only the "best" owner is hilighted at the mouse position. @@ -1116,7 +1118,9 @@ is -- have been hilighted , the next call will hilight -- the first one again - HilightPreviousDetected(me:mutable;aView:View from V3d) + HilightPreviousDetected (me : mutable; + theView : View from V3d; + theToRedrawImmediate : Boolean from Standard = Standard_True) returns Integer from Standard; ---Purpose: Same as previous methods in reverse direction... @@ -1633,52 +1637,31 @@ is -- 4.EndImmediateDraw() draws all the stored objects... -- - BeginImmediateDraw (me:mutable) returns Boolean from Standard; + BeginImmediateDraw (me : mutable) + returns Boolean from Standard; ---Purpose: initializes the list of presentations to be displayed -- returns False if No Local COnte - ImmediateAdd (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0) + ImmediateAdd (me : mutable; + theObj : InteractiveObject from AIS; + theMode : Integer from Standard = 0) returns Boolean from Standard; ---Purpose: returns True if has been stored in the list. - ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0) - returns Boolean from Standard; - ---Purpose: returns True if has been removed from the list. - - EndImmediateDraw(me:mutable;aView : View from V3d;DoubleBuf:Boolean from Standard=Standard_False) + EndImmediateDraw (me : mutable; + theView : View from V3d) returns Boolean from Standard; ---Purpose: returns True if the immediate display has been done. - EndImmediateDraw(me:mutable;DoubleBuf:Boolean from Standard=Standard_False) + + EndImmediateDraw (me : mutable) returns Boolean from Standard; - ---Purpose: Uses the First Active View of Main Viewer!!! + ---Purpose: Uses the First Active View of Main Viewer! -- returns True if the immediate display has been done. IsImmediateModeOn(me) returns Boolean from Standard; - Drag ( me : mutable; - aView: View from V3d; - anObject: InteractiveObject from AIS; - aTranformation: Transformation from Geom; - postConcatenate: Boolean from Standard = Standard_False; - update: Boolean from Standard = Standard_False; - zBuffer: Boolean from Standard = Standard_False) - is static; - ---Level: Public - ---Purpose: Transforms the current presentation of the object - -- using the transient graphic space of the view in - -- immediat mode graphics. - ---Warning: When is TRUE, then the view is redrawn with ALL - -- transformed presentations. - -- When is TRUE all transient graphic are drawn - -- using zbuffer activity. - -- Note that when is TRUE the view is cleared and redrawn - -- and soforth the Z buffer is always activated therefore the - -- parameter is ignored in this case. - - ---Category: Activation/Deactivation of Selection Modes. - SetAutomaticHilight(me:mutable;aStatus:Boolean); ---Purpose: -- Sets the highlighting status aStatus of detected and diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 85747ca9b1..21a03dc933 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -21,12 +21,6 @@ #define BUC60814 //GG_300101 Idem UKI60826 -#define IMP150501 //GG_150501 CADPAK_V2 Add Drag() method - -#define IMP160701 //ZSV Add InitDetected(),MoreDetected(),NextDetected(), -// DetectedCurrentShape(),DetectedCurrentObject() -// methods - #define OCC138 //VTN Avoding infinit loop in AddOrRemoveCurrentObject method. #define OCC9657 @@ -42,6 +36,8 @@ #include #include +#include + #include #include #include @@ -52,10 +48,7 @@ #include #include -#ifdef IMP150501 -#include #include -#endif #ifdef OCC9657 #include @@ -128,81 +121,66 @@ static void InfoOnLight(const Handle(V3d_View) aView) } #endif */ + //======================================================================= //function : MoveTo -//purpose : +//purpose : //======================================================================= - -AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V3d_View)& aView) +AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix, + const Standard_Integer theYPix, + const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawOnUpdate) { - if(HasOpenedContext()){ + if (HasOpenedContext()) + { myWasLastMain = Standard_True; - return myLocalContexts(myCurLocalIndex)->MoveTo(XPix,YPix,aView); + return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate); } -#ifdef IMP160701 - //Nullify class members storing information about detected AIS objects. myAISCurDetected = 0; myAISDetectedSeq.Clear(); -#endif - // OCC11904 - local variables made non-static - it looks and works better like this - Handle (PrsMgr_PresentationManager3d) pmgr ; - Handle (StdSelect_ViewerSelector3d) selector; - Standard_Boolean ismain = Standard_True,UpdVwr = Standard_False; - - // Preliminaires - if(aView->Viewer()== myMainVwr) { - pmgr = myMainPM; - selector=myMainSel; - myLastPicked = myLastinMain; - myWasLastMain = Standard_True; - } - else + if (theView->Viewer() != myMainVwr) + { return AIS_SOD_Error; - - AIS_StatusOfDetection TheStat(AIS_SOD_Nothing); - - + } + + // preliminaires + myLastPicked = myLastinMain; + myWasLastMain = Standard_True; + AIS_StatusOfDetection aStatus = AIS_SOD_Nothing; + Standard_Boolean toUpdateViewer = Standard_False; + // allonzy - selector->Pick(XPix, YPix, aView); - -#ifdef IMP160701 - //filling of myAISDetectedSeq sequence storing information about detected AIS objects - // (the objects must be AIS_Shapes). - Handle(SelectMgr_EntityOwner) anEntityOwner; - const Standard_Integer NbDetected = selector->NbPicked(); - for(Standard_Integer i_detect = 1;i_detect<=NbDetected;i_detect++) + myMainSel->Pick (theXPix, theYPix, theView); + + // filling of myAISDetectedSeq sequence storing information about detected AIS objects + // (the objects must be AIS_Shapes) + const Standard_Integer aDetectedNb = myMainSel->NbPicked(); + for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter) { - anEntityOwner = selector->Picked(i_detect); - if(!anEntityOwner.IsNull()) - if(myFilters->IsOk(anEntityOwner)) - { - Handle(AIS_InteractiveObject) anObj = - Handle(AIS_InteractiveObject)::DownCast(anEntityOwner->Selectable()); - if(!Handle(AIS_Shape)::DownCast(anObj).IsNull()) - myAISDetectedSeq.Append(anObj); - } + Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter); + if (anOwner.IsNull() + || !myFilters->IsOk (anOwner)) + { + continue; + } + + Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + if (!Handle(AIS_Shape)::DownCast (anObj).IsNull()) + { + myAISDetectedSeq.Append (anObj); + } } -#endif - selector->Init(); - if ( selector->More() ) + myMainSel->Init(); + if (myMainSel->More()) { - if ( HasOpenedContext() ) + // does nothing if previously detected object is equal to the current one + if (myMainSel->OnePicked()->Selectable() == myLastPicked) { - if ( !myFilters->IsOk( selector->OnePicked() ) ) - return AIS_SOD_AllBad; - else - if ( !myLocalContexts( myCurLocalIndex )->Filter()->IsOk( selector->OnePicked() ) ) - return AIS_SOD_AllBad; - } - - // Does nothing if previously detected object is equal to the current one - if ( selector->OnePicked()->Selectable() == myLastPicked ) return AIS_SOD_OnlyOneDetected; + } // Previously detected object is unhilighted if it is not selected or hilighted // with selection color if it is selected. Such highlighting with selection color @@ -211,69 +189,77 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix // method call. As result it is necessary to rehighligt it with mySelectionColor. if (!myLastPicked.IsNull()) { - Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; + const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; if (myLastPicked->State() != 1) { - pmgr->Unhighlight (myLastPicked, aHiMod); - UpdVwr = Standard_True; + myMainPM->Unhighlight (myLastPicked, aHiMod); + toUpdateViewer = Standard_True; } else if (myToHilightSelected) { - pmgr->Color (myLastPicked, mySelectionColor, aHiMod); - UpdVwr = Standard_True; + myMainPM->Color (myLastPicked, mySelectionColor, aHiMod); + toUpdateViewer = Standard_True; } } - // Initialize myLastPicked field with currently detected object - myLastPicked = Handle(AIS_InteractiveObject)::DownCast (selector->OnePicked()->Selectable()); + // initialize myLastPicked field with currently detected object + myLastPicked = Handle(AIS_InteractiveObject)::DownCast (myMainSel->OnePicked()->Selectable()); + myLastinMain = myLastPicked; - if ( ismain ) - myLastinMain = myLastPicked; - - // Highlight detected object if it is not selected or myToHilightSelected flag is true - if (!myLastPicked.IsNull() - && (myLastPicked->State()!= 1 || myToHilightSelected)) + // highlight detected object if it is not selected or myToHilightSelected flag is true + if (!myLastPicked.IsNull()) { - Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; - pmgr->Color (myLastPicked, myHilightColor, aHiMod); - UpdVwr = Standard_True; - } + if (myLastPicked->State() != 1 || myToHilightSelected) + { + const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; + myMainPM->Color (myLastPicked, myHilightColor, aHiMod); + toUpdateViewer = Standard_True; + } - if (!myLastPicked.IsNull() - && myLastPicked->State() == 1) - { - TheStat = AIS_SOD_Selected; + if (myLastPicked->State() == 1) + { + aStatus = AIS_SOD_Selected; + } } } else { - // Previously detected object is unhilighted if it is not selected or hilighted - // with selection color if it is selected. - TheStat = AIS_SOD_Nothing; + // previously detected object is unhilighted if it is not selected or hilighted + // with selection color if it is selected + aStatus = AIS_SOD_Nothing; if (!myLastPicked.IsNull()) { Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; if (myLastPicked->State() != 1) { - pmgr->Unhighlight (myLastPicked, aHiMod); - UpdVwr = Standard_True; + myMainPM->Unhighlight (myLastPicked, aHiMod); + toUpdateViewer = Standard_True; } else if (myToHilightSelected) { - pmgr->Color (myLastPicked, mySelectionColor, aHiMod); - UpdVwr = Standard_True; + myMainPM->Color (myLastPicked, mySelectionColor, aHiMod); + toUpdateViewer = Standard_True; } } - if ( ismain ) - myLastinMain.Nullify(); + myLastinMain.Nullify(); } - - if(UpdVwr) aView->Viewer()->Update(); + + if (toUpdateViewer) + { + if (theToRedrawOnUpdate) + { + theView->Viewer()->Update(); + } + else + { + theView->Viewer()->Invalidate(); + } + } + myLastPicked.Nullify(); - - mylastmoveview = aView; - return TheStat; + mylastmoveview = theView; + return aStatus; } //======================================================================= @@ -1310,56 +1296,30 @@ Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const //======================================================================= //function : HilightNextDetected -//purpose : +//purpose : //======================================================================= -Standard_Integer AIS_InteractiveContext::HilightNextDetected(const Handle(V3d_View)& V) +Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawImmediate) { - if(!HasOpenedContext()) - return 0; - return myLocalContexts(myCurLocalIndex)->HilightNextDetected(V); + return HasOpenedContext() + ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate) + : 0; } //======================================================================= //function : HilightNextDetected -//purpose : +//purpose : //======================================================================= -Standard_Integer AIS_InteractiveContext::HilightPreviousDetected(const Handle(V3d_View)& V) +Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawImmediate) { - if(!HasOpenedContext()) - return 0; - return myLocalContexts(myCurLocalIndex)->HilightPreviousDetected(V); + return HasOpenedContext() + ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate) + : 0; } -#ifdef IMP150501 -void AIS_InteractiveContext::Drag( - const Handle(V3d_View)& aView, - const Handle(AIS_InteractiveObject)& anObject, - const Handle(Geom_Transformation)& aTrsf, - const Standard_Boolean postConcatenate, - const Standard_Boolean update, - const Standard_Boolean zBuffer) { - - if( anObject.IsNull() || aView.IsNull() ) return; - - if( update ) { - anObject->SetTransformation(aTrsf,postConcatenate,Standard_True); - aView->Update(); - } else if( Visual3d_TransientManager::BeginDraw(aView->View(), - zBuffer,Standard_False) ) { - Handle(Prs3d_Presentation) P = anObject->Presentation(); - if( !P.IsNull() ) { - if( postConcatenate ) P->Multiply(aTrsf); - else P->Transform(aTrsf); - Visual3d_TransientManager::DrawStructure(P); - } - Visual3d_TransientManager::EndDraw(Standard_True); - } -} -#endif - -#ifdef IMP160701 //======================================================================= //function : InitDetected //purpose : @@ -1439,4 +1399,3 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() co else return aBad; } -#endif diff --git a/src/AIS/AIS_InteractiveContext_2.cxx b/src/AIS/AIS_InteractiveContext_2.cxx index 4c1bd8cb8f..aa8936950b 100644 --- a/src/AIS/AIS_InteractiveContext_2.cxx +++ b/src/AIS/AIS_InteractiveContext_2.cxx @@ -773,82 +773,71 @@ Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& V return NbCleared; } - //======================================================================= //function : IsImmediateModeOn -//purpose : +//purpose : //======================================================================= + Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const { if(!HasOpenedContext()) return Standard_False; return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn(); } -Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw() -{ - if(HasOpenedContext()) - return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw(); - return Standard_False; -} - //======================================================================= -//function : ImmediateAdd -//purpose : +//function : BeginImmediateDraw +//purpose : //======================================================================= -Standard_Boolean AIS_InteractiveContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, - const Standard_Integer AMode) -{ - if(HasOpenedContext()){ - return myLocalContexts(myCurLocalIndex)->ImmediateAdd(anIObj,AMode);} - return Standard_False; +Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw() +{ + return HasOpenedContext() + && myLocalContexts (myCurLocalIndex)->BeginImmediateDraw(); } //======================================================================= -//function : ImmediateRemove -//purpose : +//function : ImmediateAdd +//purpose : //======================================================================= -Standard_Boolean AIS_InteractiveContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, - const Standard_Integer aMode) +Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, + const Standard_Integer theMode) { - if(HasOpenedContext()) - return myLocalContexts(myCurLocalIndex)->ImmediateRemove(anIObj,aMode); - return Standard_False; + return HasOpenedContext() + && myLocalContexts (myCurLocalIndex)->ImmediateAdd (theObj, theMode); } //======================================================================= //function : EndImmediateDraw -//purpose : +//purpose : //======================================================================= -Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Handle(V3d_View)& aView, - const Standard_Boolean DoubleBuf) +Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView) { - if(HasOpenedContext()) - return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(aView,DoubleBuf); - return Standard_False; - + return HasOpenedContext() + && myLocalContexts (myCurLocalIndex)->EndImmediateDraw (theView); } //======================================================================= //function : EndImmediateDraw -//purpose : +//purpose : //======================================================================= -Standard_Boolean AIS_InteractiveContext::EndImmediateDraw(const Standard_Boolean DoubleBuf) +Standard_Boolean AIS_InteractiveContext::EndImmediateDraw() { - if(HasOpenedContext()){ - Handle(V3d_View) V ; - myMainVwr->InitActiveViews(); - if(myMainVwr->MoreActiveViews()){ - V = myMainVwr->ActiveView(); - - return myLocalContexts(myCurLocalIndex)->EndImmediateDraw(V,DoubleBuf); - } + if (!HasOpenedContext()) + { + return Standard_False; } - return Standard_False; - + + myMainVwr->InitActiveViews(); + if (!myMainVwr->MoreActiveViews()) + { + return Standard_False; + } + + Handle(V3d_View) aView = myMainVwr->ActiveView(); + return myLocalContexts (myCurLocalIndex)->EndImmediateDraw (aView); } diff --git a/src/AIS/AIS_LengthDimension.hxx b/src/AIS/AIS_LengthDimension.hxx index 0e5693332a..c4c87857a3 100755 --- a/src/AIS/AIS_LengthDimension.hxx +++ b/src/AIS/AIS_LengthDimension.hxx @@ -40,7 +40,6 @@ class gp_Pnt; class TopoDS_Edge; class TopoDS_Shape; class Geom_Plane; -class PrsMgr_PresentationManager3d; class Prs3d_Presentation; class Prs3d_Projector; class Geom_Transformation; diff --git a/src/AIS/AIS_LocalContext.cdl b/src/AIS/AIS_LocalContext.cdl index 6a5bdad1ab..337f1383b8 100644 --- a/src/AIS/AIS_LocalContext.cdl +++ b/src/AIS/AIS_LocalContext.cdl @@ -230,13 +230,12 @@ is AutomaticHilight(me) returns Boolean; ---C++: inline - - ---Category: THE SELECTION PROCESS - - MoveTo(me:mutable;Xpix,Ypix : Integer from Standard; - aview : View from V3d) + MoveTo (me : mutable; + theXpix, theYpix : Integer from Standard; + theView : View from V3d; + theToRedrawImmediate : Boolean from Standard) returns StatusOfDetection from AIS; @@ -245,15 +244,18 @@ is ---Purpose: returns True if more than one entity -- was detected at the last Mouse position. - HilightNextDetected(me:mutable;aView:View from V3d) + HilightNextDetected (me : mutable; + theView : View from V3d; + theToRedrawImmediate : Boolean from Standard) returns Integer from Standard; ---Purpose: returns True if last detected. the next detected will -- be first one (endless loop) - HilightPreviousDetected(me:mutable;aView:View from V3d) + HilightPreviousDetected (me : mutable; + theView : View from V3d; + theToRedrawImmediate : Boolean from Standard) returns Integer from Standard; - UnhilightLastDetected(me:mutable;aView:View from V3d) returns Boolean from Standard; ---Purpose: returns True if something was done... @@ -474,24 +476,29 @@ is ---Category: IMMEDIATE MODE - BeginImmediateDraw (me:mutable) returns Boolean from Standard; - ---Purpose: initializes the list of presentations to be displayed - -- returns False if No Local COnte - - ImmediateAdd (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0) + BeginImmediateDraw (me : mutable) returns Boolean from Standard; - ---Purpose: returns True if has been stored in the list. + ---Purpose: Resets the transient list of presentations previously displayed in immediate mode + -- and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls. + + ClearImmediateDraw (me : mutable) is virtual; + ---Purpose: Resets the transient list of presentations previously displayed in immediate mode. - ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0) + ImmediateAdd (me : mutable; + theObj : InteractiveObject from AIS; + theMode : Integer from Standard = 0) returns Boolean from Standard; - ---Purpose: returns True if has been removed from the list. + ---Purpose: Stores presentation theMode of object theObj in the transient list of presentations to be displayed in immediate mode. + -- Will be taken in account in EndImmediateDraw method. - EndImmediateDraw(me:mutable;aView : View from V3d;DoubleBuf:Boolean from Standard=Standard_False) + EndImmediateDraw (me : mutable; + theView : View from V3d) returns Boolean from Standard; - ---Purpose: returns True if the immediate display has been done. + ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background. + + IsImmediateModeOn (me) returns Boolean from Standard; + ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode. - IsImmediateModeOn(me) returns Boolean from Standard; - ---Category: INTERNAL METHODS; UpdateConversion(me:mutable); @@ -523,9 +530,10 @@ is ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr; WithProj: Boolean from Standard = Standard_True) is static private; - ManageDetected(me:mutable; - aPickOwner : EntityOwner from SelectMgr; - aview : View from V3d) is static private; + manageDetected (me : mutable; + thePickOwner : EntityOwner from SelectMgr; + theView : View from V3d; + theToRedrawImmediate : Boolean from Standard) is static private; DetectedIndex(me:mutable) returns Integer from Standard is static private; ---C++: inline @@ -568,17 +576,10 @@ is ClearSensitive(me:mutable;aView:View from V3d) is static; - - MainSelector(me) returns any ViewerSelector3d from StdSelect; ---C++: inline ---C++: return const& - - HilightTriangle(me:mutable;Rank:Integer from Standard;aViou:View from V3d) is static private; - ---Level: Internal - - FindSelectedOwnerFromIO(me;anIObj:InteractiveObject from AIS) returns EntityOwner from SelectMgr; diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 99aae2986a..78c0186ae4 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -50,7 +50,6 @@ #include #include #include -#include #include #ifdef ALE70590 @@ -693,10 +692,10 @@ Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projec //======================================================================= //function : Terminate -//purpose : +//purpose : //======================================================================= -void AIS_LocalContext::Terminate( const Standard_Boolean updateviewer ) +void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) { ClearDetected(); Clear(); @@ -720,23 +719,21 @@ void AIS_LocalContext::Terminate( const Standard_Boolean updateviewer ) AIS_Selection::Select(); AIS_Selection::Remove(mySelName.ToCString()); - // CLE - // const Handle(V3d_Viewer)& Vwr = myCTX->CurrentViewer(); - Handle(V3d_Viewer) Vwr = myCTX->CurrentViewer(); - // ENDCLE - Handle(V3d_View) curV; - for(Vwr->InitActiveViews();Vwr->MoreActiveViews();Vwr->NextActiveViews()){ - curV = Vwr->ActiveView(); - Visual3d_TransientManager::ClearDraw( curV->View(), updateviewer ); + Handle(V3d_Viewer) aViewer = myCTX->CurrentViewer(); + for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) + { + Handle(V3d_View) aView = aViewer->ActiveView(); + aView->View()->ClearImmediate(); } + Handle(V3d_View) aDummyView; + myMainVS->ClearAreas (aDummyView); + myMainVS->ClearSensitive (aDummyView); -#ifdef DEB - Handle(V3d_View) BidV; - myMainVS->ClearAreas(BidV); - myMainVS->ClearSensitive(BidV); - -#endif + if (theToUpdate) + { + myCTX->UpdateCurrentViewer(); + } } @@ -1172,50 +1169,68 @@ void AIS_LocalContext::UpdateSort() myMainVS->UpdateSort(); } - - //======================================================================= -//function : IMMEDIATE MODE -//purpose : +//function : BeginImmediateDraw +//purpose : //======================================================================= - -Standard_Boolean AIS_LocalContext::BeginImmediateDraw() +Standard_Boolean AIS_LocalContext::BeginImmediateDraw() { - if(myMainPM->IsImmediateModeOn()){ - myMainPM->BeginDraw(); + if (myMainPM->IsImmediateModeOn()) + { + myMainPM->BeginImmediateDraw(); return Standard_True; } return Standard_False; } - -Standard_Boolean AIS_LocalContext::ImmediateAdd(const Handle(AIS_InteractiveObject)& anIObj, - const Standard_Integer aMode) +//======================================================================= +//function : ImmediateAdd +//purpose : +//======================================================================= +Standard_Boolean AIS_LocalContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, + const Standard_Integer theMode) { - if(!myMainPM->IsImmediateModeOn()) + if (!myMainPM->IsImmediateModeOn()) + { return Standard_False; - myMainPM->Add(anIObj,aMode); + } + + myMainPM->AddToImmediateList (myMainPM->CastPresentation (theObj, theMode)->Presentation()); return Standard_True; } -Standard_Boolean AIS_LocalContext::ImmediateRemove(const Handle(AIS_InteractiveObject)& anIObj, - const Standard_Integer aMode) +//======================================================================= +//function : EndImmediateDraw +//purpose : +//======================================================================= +Standard_Boolean AIS_LocalContext::EndImmediateDraw (const Handle(V3d_View)& theView) { - if(!myMainPM->IsImmediateModeOn()) return Standard_False; - myMainPM->Remove(anIObj,aMode); + if (!myMainPM->IsImmediateModeOn()) + { + return Standard_False; + } + + myMainPM->EndImmediateDraw (theView); return Standard_True; } -Standard_Boolean AIS_LocalContext::EndImmediateDraw(const Handle(V3d_View)& aView, - const Standard_Boolean DoubleBuf) +// ======================================================================= +// function : ClearImmediateDraw +// purpose : +// ======================================================================= +void AIS_LocalContext::ClearImmediateDraw() { - if(!myMainPM->IsImmediateModeOn()) return Standard_False; - myMainPM->EndDraw(aView,DoubleBuf); - return Standard_True; + myMainPM->ClearImmediateDraw(); } +//======================================================================= +//function : IsImmediateModeOn +//purpose : +//======================================================================= Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const -{return myMainPM->IsImmediateModeOn();} +{ + return myMainPM->IsImmediateModeOn(); +} void AIS_LocalContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) { diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 9ba9b542b3..5ab1b8f306 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -47,9 +47,6 @@ #define IMP300101 //GG Enable to use polygon highlighting -#define BUC60863 //GG_270301 Clear hilight soon after selecting or -// unselecting something in Local Context mode. - #define BUC60876 //GG_050401 Clear selection always even // if the current highlight mode is not 0. @@ -71,12 +68,6 @@ #define USE_MAP //san : 18/04/03 USE_MAP - additional datamap is used to speed up access //to certain owners in AIS_Selection::myresult list -#define IMP120402 // GG : Add protection in manual detection methods -// after deselecting any item using ShiftSelect action. -// Thanks to Ivan FONTAINE of SAMTECH company - -#define IMP051001 //GG manage Z detection - #define OCC9026 //AEL Performance optimization of the FindSelectedOwnerFromShape() method. #include @@ -88,7 +79,6 @@ #include #include #include -#include #include #include #include @@ -103,6 +93,7 @@ #include #include +#include #ifdef IMP120701 #include #endif @@ -114,87 +105,78 @@ static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO) } //================================================== -// Function: +// Function: MoveTo // Purpose : //================================================== -AIS_StatusOfDetection AIS_LocalContext::MoveTo(const Standard_Integer Xpix, - const Standard_Integer Ypix, - const Handle(V3d_View)& aview) +AIS_StatusOfDetection AIS_LocalContext::MoveTo (const Standard_Integer theXpix, + const Standard_Integer theYpix, + const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawImmediate) { - // check that ViewerSelector gives - if(aview->Viewer()== myCTX->CurrentViewer()) { -#ifdef IMP160701 - //Nullify class members storing information about detected AIS objects. - myAISCurDetected = 0; - myAISDetectedSeq.Clear(); -#endif - myCurDetected = 0; - myDetectedSeq.Clear(); - myMainVS->Pick(Xpix,Ypix,aview); - Standard_Boolean had_nothing = myMainVS->NbPicked()==0; - Standard_Integer NbDetected = myMainVS->NbPicked(); - Handle(SelectMgr_EntityOwner) EO; - - for(Standard_Integer i_detect = 1;i_detect<=NbDetected;i_detect++){ - EO = myMainVS->Picked(i_detect); - if(!EO.IsNull()){ - if(myFilters->IsOk(EO)) { - myDetectedSeq.Append(i_detect); // normallly they are already arranged in correct order... -#ifdef IMP160701 - Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); - if(!Handle(AIS_Shape)::DownCast(anObj).IsNull()) - myAISDetectedSeq.Append(anObj); -#endif - } + // check that ViewerSelector gives + if (theView->Viewer() != myCTX->CurrentViewer()) + { + return AIS_SOD_Error; + } + + myAISCurDetected = 0; + myAISDetectedSeq.Clear(); + + myCurDetected = 0; + myDetectedSeq.Clear(); + myMainVS->Pick (theXpix, theYpix, theView); + + const Standard_Integer aDetectedNb = myMainVS->NbPicked(); + for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter) + { + Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (aDetIter); + if (anOwner.IsNull() + || !myFilters->IsOk (anOwner)) + { + continue; } + + myDetectedSeq.Append (aDetIter); // normallly they are already arranged in correct order... + Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + if (!Handle(AIS_Shape)::DownCast (anObj).IsNull()) + { + myAISDetectedSeq.Append (anObj); } - - //result of courses.. - if(had_nothing || myDetectedSeq.IsEmpty()){ - if(mylastindex !=0 && mylastindex <= myMapOfOwner.Extent()){ + } -#ifdef BUC60863 - Unhilight(myMapOfOwner(mylastindex),aview); -#else - if(!IsSelected(myMapOfOwner(mylastindex))) - Unhilight(myMapOfOwner(mylastindex),aview); -#endif + // result of courses.. + if (aDetectedNb == 0 || myDetectedSeq.IsEmpty()) + { + if (mylastindex != 0 && mylastindex <= myMapOfOwner.Extent()) + { + Unhilight (myMapOfOwner (mylastindex), theView); + if (theToRedrawImmediate) + { + theView->RedrawImmediate(); } - mylastindex=0; - return (had_nothing ? AIS_SOD_Nothing : AIS_SOD_AllBad); - } - - // all owners detected by the selector are passed to the - // filters and correct ones are preserved... - myCurDetected = 1; - EO = myMainVS->Picked(myDetectedSeq(myCurDetected)); - - static Standard_Boolean Normal_State(Standard_True); - static Standard_Boolean firsttime(Standard_True); - if(firsttime){ - OSD_Environment toto("HITRI"); - if(!toto.Value().IsEmpty()) - Normal_State = Standard_False; - firsttime = Standard_False; - } - - if(Normal_State) - ManageDetected(EO,aview); - else - HilightTriangle(1,aview); - - if(myDetectedSeq.Length() == 1){ - if(NbDetected==1) - return AIS_SOD_OnlyOneDetected; - else - return AIS_SOD_OnlyOneGood; } - else - return AIS_SOD_SeveralGood; - - + + mylastindex = 0; + return aDetectedNb == 0 + ? AIS_SOD_Nothing + : AIS_SOD_AllBad; + } + + // all owners detected by the selector are passed to the + // filters and correct ones are preserved... + myCurDetected = 1; + Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected)); + manageDetected (anOwner, theView, theToRedrawImmediate); + if (myDetectedSeq.Length() == 1) + { + return aDetectedNb == 1 + ? AIS_SOD_OnlyOneDetected + : AIS_SOD_OnlyOneGood; + } + else + { + return AIS_SOD_SeveralGood; } - return AIS_SOD_Error; } //================================================== @@ -229,24 +211,25 @@ AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Boolean updateviewer) AIS_Selection::ClearAndSelect(EO); #endif - if(myAutoHilight) { -#ifdef BUC60863 + if (myAutoHilight) + { const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); - for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) - Unhilight(EO, aViewer->ActiveView()); - - // san - advanced selection highlighting mechanism - if (!EO->IsAutoHilight() && EO->HasSelectable()){ - Handle(AIS_InteractiveObject) anIO = - Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); - UpdateSelected(anIO, Standard_False); + for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) + { + Unhilight (EO, aViewer->ActiveView()); } - if(updateviewer) - myCTX->CurrentViewer()->Update(); -#else - HilightPicked(updateviewer); -#endif + // advanced selection highlighting mechanism + if (!EO->IsAutoHilight() && EO->HasSelectable()) + { + Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); + UpdateSelected (anIO, Standard_False); + } + + if (updateviewer) + { + myCTX->CurrentViewer()->Update(); + } } return ( AIS_Selection::Extent() == 1)? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected ; } @@ -321,10 +304,6 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Boolean updateview { Standard_Integer I = DetectedIndex(); if(I>0){ -#ifndef BUC60863 - if(myAutoHilight) - UnhilightPicked(Standard_False); -#endif AIS_Selection::SetCurrentSelection(mySelName.ToCString()); #ifdef BUC60774 @@ -346,24 +325,25 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Boolean updateview AIS_Selection::Select(EO); #endif - if(myAutoHilight) { -#ifdef BUC60863 + if(myAutoHilight) + { const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); - for(aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) - Unhilight(EO, aViewer->ActiveView()); - - // san - advanced selection highlighting mechanism - if (!EO->IsAutoHilight() && EO->HasSelectable()){ - Handle(AIS_InteractiveObject) anIO = - Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); - UpdateSelected(anIO, Standard_False); + for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) + { + Unhilight (EO, aViewer->ActiveView()); } - if(updateviewer) + // advanced selection highlighting mechanism + if (!EO->IsAutoHilight() && EO->HasSelectable()) + { + Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (EO->Selectable()); + UpdateSelected (anIO, Standard_False); + } + + if (updateviewer) + { myCTX->CurrentViewer()->Update(); -#else - HilightPicked(updateviewer); -#endif + } } #ifdef BUC60774 Standard_Integer NS = AIS_Selection::Extent(); @@ -385,6 +365,8 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Integer XPMin, const Handle(V3d_View)& aView, const Standard_Boolean updateviewer) { + myMainPM->ClearImmediateDraw(); + if(aView->Viewer()== myCTX->CurrentViewer()) { myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView); #ifdef BUC60774 @@ -526,62 +508,48 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect( const TColgp_Array1OfPnt2d& aPol } //================================================== -// Function: +// Function: Hilight // Purpose : //================================================== -void AIS_LocalContext::Hilight(const Handle(SelectMgr_EntityOwner)& Ownr, - const Handle(V3d_View)& aview) +void AIS_LocalContext::Hilight (const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(V3d_View)& theView) { -#ifdef BUC60863 - if( aview.IsNull() ) return; - aview->TransientManagerClearDraw(); -#else - if(aview->TransientManagerBeginDraw()) - Visual3d_TransientManager::EndDraw(); -#endif - myMainPM->BeginDraw(); - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO)); - Ownr->HilightWithColor(myMainPM,myCTX->HilightColor(),HM); -#ifdef IMP051001 - myMainPM->EndDraw(aview,myCTX->ZDetection()); -#else - myMainPM->EndDraw(aview); -#endif + if (theView.IsNull()) + { + return; + } + const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable())); + myMainPM->BeginImmediateDraw(); + theOwner->HilightWithColor (myMainPM, myCTX->HilightColor(), aHilightMode); + myMainPM->EndImmediateDraw (theView); } //================================================== -// Function: +// Function: Unhilight // Purpose : //================================================== -void AIS_LocalContext::Unhilight(const Handle(SelectMgr_EntityOwner)& Ownr, - const Handle(V3d_View)& aview) +void AIS_LocalContext::Unhilight (const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(V3d_View)& theView) { + if (theView.IsNull()) + { + return; + } - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO)); -#ifdef BUC60863 - if( aview.IsNull() ) return; - if( IsSelected(Ownr) ) { - if ( Ownr->IsAutoHilight() ) - Ownr->HilightWithColor(myMainPM,myCTX->SelectionColor(),HM); - } - else + myMainPM->ClearImmediateDraw(); + const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable())); + if (IsSelected (theOwner)) { - myMainPM->BeginDraw(); - Ownr->Unhilight(myMainPM,HM); - myMainPM->EndDraw(aview); + if (theOwner->IsAutoHilight()) + { + theOwner->HilightWithColor (myMainPM, myCTX->SelectionColor(), aHilightMode); + } + } + else + { + theOwner->Unhilight (myMainPM, aHilightMode); } - aview->TransientManagerClearDraw(); -#else - if(aview->TransientManagerBeginDraw()) - Visual3d_TransientManager::EndDraw(); - myMainPM->BeginDraw(); - Ownr->Unhilight(myMainPM,HM); - myMainPM->EndDraw(aview); -#endif - } //======================================================================= @@ -647,12 +615,9 @@ void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer) aMapIter.More(); aMapIter.Next() ) aMapIter.Key()->HilightSelected ( myMainPM, aMapIter.Value() ); - if(updateviewer){ -#ifdef BUC60863 - myCTX->CurrentViewer()->Update(); -#else - if(updMain) myCTX->CurrentViewer()->Update(); -#endif + if (updateviewer) + { + myCTX->CurrentViewer()->Update(); } } @@ -660,9 +625,10 @@ void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer) // Function: // Purpose : //================================================== -void AIS_LocalContext:: -UnhilightPicked(const Standard_Boolean updateviewer) +void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer) { + myMainPM->ClearImmediateDraw(); + Standard_Boolean updMain(Standard_False); Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString()); @@ -1086,92 +1052,95 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& } //================================================== -// Function: +// Function: manageDetected // Purpose : //================================================== -void AIS_LocalContext::ManageDetected(const Handle(SelectMgr_EntityOwner)& aPickOwner, - const Handle(V3d_View)& aview) +void AIS_LocalContext::manageDetected (const Handle(SelectMgr_EntityOwner)& thePickOwner, + const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawImmediate) { -#ifdef BUC60818 - // Warning : aPickOwner may be null ! - if (aPickOwner.IsNull()) return; -#else - if(!myAutoHilight) return; -#endif -// const Handle(SelectMgr_SelectableObject)& SO = aPickOwner->Selectable(); - Standard_Boolean okStatus = myFilters->IsOk(aPickOwner); - // OK... - if(okStatus){ - //======================================================================================================= - // 2 cases : a- object is in the map of picks: - // 1. this is the same index as the last detected: -> Do nothing - // 2. otherwise : - // - if lastindex = 0 (no object was detected at the last step) - // the object presentation is highlighted and lastindex = index(objet) - // - othrwise : - // the presentation of the object corresponding to lastindex is "unhighlighted" - // it is removed if the object is not visualized but only active - // then the presentation of the detected object is highlighted and lastindex = index(objet) - // b- the object is not in the map of picked objects - // - if lastindex != 0 (object detected at the last step) it is unhighlighted ... - // if the object was decomposed, presentation is created for the detected shape and the couple - // (Proprietaire,Prs)is added in the map. - // otherwise the couple(proprietaire, NullPrs) is placed in the map and the interactive object - // itself is highlighted. - // - //======================================================================================================= - - - //szv: - Standard_Boolean wasContained = myMapOfOwner.Contains(aPickOwner); - Standard_Integer theNewIndex = 0; - if (wasContained) - theNewIndex = myMapOfOwner.FindIndex(aPickOwner); - else - theNewIndex = myMapOfOwner.Add(aPickOwner); + if (thePickOwner.IsNull()) + { + if (theToRedrawImmediate) + { + theView->RedrawImmediate(); + } + return; + } - // For the advanced mesh selection mode the owner indices comparison - // is not effective because in that case only one owner manage the - // selection in current selection mode. It is necessary to check the current detected - // entity and hilight it only if the detected entity is not the same as - // previous detected (IsForcedHilight call) - if (theNewIndex != mylastindex || aPickOwner->IsForcedHilight()) { + if (!myFilters->IsOk (thePickOwner)) + { + if (mylastindex != 0) + { + mylastgood = mylastindex; + } + if (theToRedrawImmediate) + { + theView->RedrawImmediate(); + } + return; + } - if (mylastindex && mylastindex <= myMapOfOwner.Extent()) { + //======================================================================================================= + // 2 cases : a- object is in the map of picks: + // 1. this is the same index as the last detected: -> Do nothing + // 2. otherwise : + // - if lastindex = 0 (no object was detected at the last step) + // the object presentation is highlighted and lastindex = index(objet) + // - othrwise : + // the presentation of the object corresponding to lastindex is "unhighlighted" + // it is removed if the object is not visualized but only active + // then the presentation of the detected object is highlighted and lastindex = index(objet) + // b- the object is not in the map of picked objects + // - if lastindex != 0 (object detected at the last step) it is unhighlighted ... + // if the object was decomposed, presentation is created for the detected shape and the couple + // (Proprietaire,Prs)is added in the map. + // otherwise the couple(proprietaire, NullPrs) is placed in the map and the interactive object + // itself is highlighted. + // + //======================================================================================================= + + const Standard_Integer aNewIndex = myMapOfOwner.Contains (thePickOwner) + ? myMapOfOwner.FindIndex (thePickOwner) + : myMapOfOwner.Add (thePickOwner); + + // For the advanced mesh selection mode the owner indices comparison + // is not effective because in that case only one owner manage the + // selection in current selection mode. It is necessary to check the current detected + // entity and hilight it only if the detected entity is not the same as + // previous detected (IsForcedHilight call) + if (aNewIndex != mylastindex + || thePickOwner->IsForcedHilight()) + { + if (mylastindex != 0 + && mylastindex <= myMapOfOwner.Extent()) + { + const Handle(SelectMgr_EntityOwner)& aLastOwner = myMapOfOwner (mylastindex); + Unhilight (aLastOwner, theView); + } - const Handle(SelectMgr_EntityOwner)& LastOwnr = myMapOfOwner(mylastindex); -#ifdef BUC60863 - Unhilight(LastOwnr,aview); -#else - if(!IsSelected(LastOwnr)) - Unhilight(LastOwnr,aview); -#endif + if (myAutoHilight) + { + if (thePickOwner->State() <= 0 + || myCTX->ToHilightSelected()) + { + Hilight (thePickOwner, theView); } - - if (myAutoHilight) { - // wasContained should not be checked because with this verification different - // behaviour of application may occer depending whether mouse is moved above - // owner first or second time - //if (wasContained) { -#ifdef BUC60569 - if (aPickOwner->State() <= 0 || myCTX->ToHilightSelected()) -#else - if(!IsSelected (aPickOwner) || myCTX->ToHilightSelected()) -#endif - Hilight(aPickOwner,aview); - /*} - else Hilight(aPickOwner,aview);*/ + if (theToRedrawImmediate) + { + theView->RedrawImmediate(); } - - mylastindex = theNewIndex; } + + mylastindex = aNewIndex; } - if (mylastindex) mylastgood = mylastindex; - + if (mylastindex) + { + mylastgood = mylastindex; + } } - //======================================================================= //function : HasDetectedShape //purpose : @@ -1314,138 +1283,78 @@ Standard_Boolean AIS_LocalContext::IsValidForSelection(const Handle(AIS_Interact //======================================================================= //function : HilightNextDetected -//purpose : +//purpose : //======================================================================= - -Standard_Integer AIS_LocalContext::HilightNextDetected(const Handle(V3d_View)& V) +Standard_Integer AIS_LocalContext::HilightNextDetected (const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawImmediate) { // go to the next owner + if (myDetectedSeq.IsEmpty()) + { + return 0; + } - if(myDetectedSeq.IsEmpty()) return Standard_False; - Standard_Integer L = myDetectedSeq.Length(); - myCurDetected++; - - if(myCurDetected>L) + const Standard_Integer aLen = myDetectedSeq.Length(); + if (++myCurDetected > aLen) + { myCurDetected = 1; - Handle(SelectMgr_EntityOwner) EO = myMainVS->Picked(myCurDetected); -#ifdef IMP120402 - if( EO.IsNull() ) return 0; -#endif - - static Standard_Boolean Normal_State(Standard_True); - static Standard_Boolean firsttime(Standard_True); - if(firsttime){ - OSD_Environment toto("HITRI"); - if(!toto.Value().IsEmpty()) - Normal_State = Standard_False; - firsttime = Standard_False; } - - - if(Normal_State) - ManageDetected(EO,V); - else - HilightTriangle(myCurDetected,V); + Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myCurDetected); + if (anOwner.IsNull()) + { + return 0; + } + manageDetected (anOwner, theView, theToRedrawImmediate); return myCurDetected; } //======================================================================= //function : HilightPreviousDetected -//purpose : +//purpose : //======================================================================= -Standard_Integer AIS_LocalContext::HilightPreviousDetected(const Handle(V3d_View)& V) +Standard_Integer AIS_LocalContext::HilightPreviousDetected (const Handle(V3d_View)& theView, + const Standard_Boolean theToRedrawImmediate) { - if(myDetectedSeq.IsEmpty()) return Standard_False; - - myCurDetected--; + if (myDetectedSeq.IsEmpty()) + { + return 0; + } - if(myCurDetected<1) + if (--myCurDetected < 1) + { myCurDetected = 1; - Handle(SelectMgr_EntityOwner) EO = myMainVS->Picked(myCurDetected); -#ifdef IMP120402 - if( EO.IsNull() ) return 0; -#endif - - static Standard_Boolean Normal_State(Standard_True); - static Standard_Boolean firsttime(Standard_True); - if(firsttime){ - OSD_Environment toto("HITRI"); - if(!toto.Value().IsEmpty()) - Normal_State = Standard_False; - firsttime = Standard_False; + } + Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myCurDetected); + if (anOwner.IsNull()) + { + return 0; } - - - if(Normal_State) - ManageDetected(EO,V); - else - HilightTriangle(myCurDetected,V); + manageDetected (anOwner, theView, theToRedrawImmediate); return myCurDetected; } //======================================================================= //function : UnhilightLastDetected -//purpose : +//purpose : //======================================================================= -Standard_Boolean AIS_LocalContext::UnhilightLastDetected(const Handle(V3d_View)& aview) +Standard_Boolean AIS_LocalContext::UnhilightLastDetected (const Handle(V3d_View)& theView) { - if(!IsValidIndex(mylastindex)) return Standard_False; - myMainPM->BeginDraw(); - const Handle(SelectMgr_EntityOwner)& Ownr = myMapOfOwner(mylastindex); - Standard_Integer HM(0); - if(Ownr->HasSelectable()){ - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&SO)); + if (!IsValidIndex (mylastindex)) + { + return Standard_False; } - myMapOfOwner(mylastindex)->Unhilight(myMainPM,HM); - myMainPM->EndDraw(aview); - mylastindex =0; - return Standard_True; -} - - - -//======================================================================= -//function : HilightTriangle -//purpose : -//======================================================================= -void AIS_LocalContext::HilightTriangle(const Standard_Integer Rank, - const Handle(V3d_View)& view) -{ - static Standard_Integer PrevRank(0); - if(Rank==PrevRank) return; - Handle(SelectBasics_SensitiveEntity) SE = myMainVS->Primitive(Rank); - if(SE->IsKind(STANDARD_TYPE(Select3D_SensitiveTriangulation))) - { - Handle(Select3D_SensitiveTriangulation) Tr = *((Handle(Select3D_SensitiveTriangulation)*)&SE); - gp_Pnt p1,p2,p3 ; Tr->DetectedTriangle(p1,p2,p3); - - Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles(3); - aTris->AddVertex(p1); - aTris->AddVertex(p2); - aTris->AddVertex(p3); - - static Handle(Prs3d_Presentation) TriPrs = - new Prs3d_Presentation(myMainPM->StructureManager()); - TriPrs->Clear(); -#ifdef IMP300101 - Handle(Prs3d_ShadingAspect) asp = myCTX->DefaultDrawer()->ShadingAspect(); - asp->SetColor(myCTX->HilightColor()); - TriPrs->SetShadingAspect(asp); -#endif - Prs3d_Root::CurrentGroup(TriPrs)->AddPrimitiveArray(aTris); + myMainPM->BeginImmediateDraw(); + const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (mylastindex); + const Standard_Integer aHilightMode = anOwner->HasSelectable() + ? GetHiMod (Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable())) + : 0; -#ifndef IMP300101 - if(view->TransientManagerBeginDraw()) - Visual3d_TransientManager::EndDraw(); -#endif - if(view->TransientManagerBeginDraw()) { - Visual3d_TransientManager::DrawStructure(TriPrs); - Visual3d_TransientManager::EndDraw(); - } - } + myMapOfOwner (mylastindex)->Unhilight (myMainPM, aHilightMode); + myMainPM->EndImmediateDraw (theView); + mylastindex = 0; + return Standard_True; } //======================================================================= diff --git a/src/AIS/AIS_TexturedShape.hxx b/src/AIS/AIS_TexturedShape.hxx index 8bec8f2a09..76ca3ab116 100644 --- a/src/AIS/AIS_TexturedShape.hxx +++ b/src/AIS/AIS_TexturedShape.hxx @@ -29,10 +29,6 @@ class Graphic3d_AspectFillArea3d; class Graphic3d_Texture2Dmanual; -class TopoDS_Shape; -class TCollection_AsciiString; -class PrsMgr_PresentationManager3d; -class Prs3d_Presentation; //! This class allows to map textures on shapes. //! Presentations modes AIS_WireFrame (0) and AIS_Shaded (1) behave in the same manner as in AIS_Shape, diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index 8cf6dd8841..844c4ca6f0 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -73,6 +73,9 @@ public: //! Highlight structure using boundary box virtual void HighlightWithBndBox (const Standard_Boolean theToCreate) = 0; + //! Create shadow link to this structure + virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0; + public: int Id; diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl index 0538f84f58..710d2d1c14 100644 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl @@ -275,16 +275,27 @@ is ---Purpose: call_togl_ratio_window Redraw ( me : mutable; - ACView : CView from Graphic3d; - ACUnderLayer : CLayer2d from Aspect; - ACOverLayer : CLayer2d from Aspect; - x : Integer = 0; - y : Integer = 0; - width : Integer = 0; - height : Integer = 0 ) - is deferred; - ---Purpose: call_togl_redraw - -- Warning: when the redraw area has a null size, the full view is redrawn + theCView : CView from Graphic3d; + theCUnderLayer : CLayer2d from Aspect; + theCOverLayer : CLayer2d from Aspect; + theX : Integer = 0; + theY : Integer = 0; + theWidth : Integer = 0; + theHeight : Integer = 0 ) + is deferred; + ---Purpose: Redraw content of the view + + RedrawImmediate ( me : mutable; + theCView : CView from Graphic3d; + theCUnderLayer : CLayer2d from Aspect; + theCOverLayer : CLayer2d from Aspect ) + is deferred; + ---Purpose: Redraw layer of immediate presentations + + Invalidate ( me : mutable; + theCView : CView from Graphic3d ) + is deferred; + ---Purpose: Invalidates content of the view but does not redraw it RemoveView ( me : mutable; ACView : CView from Graphic3d ) @@ -314,13 +325,6 @@ is is deferred; ---Purpose: call_togl_transparency - Update ( me : mutable; - ACView : CView from Graphic3d; - ACUnderLayer : CLayer2d from Aspect; - ACOverLayer : CLayer2d from Aspect ) - is deferred; - ---Purpose: call_togl_update - View ( me : mutable; ACView : in out CView from Graphic3d ) returns Boolean from Standard @@ -485,21 +489,7 @@ is is deferred; ---------------------------------- - -- Category: Ajout mode methods - ---------------------------------- - - BeginAddMode ( me : mutable; - ACView : CView from Graphic3d) - returns Boolean from Standard - is deferred; - ---Purpose: call_togl_begin_ajout_mode - - EndAddMode ( me : mutable) - is deferred; - ---Purpose: call_togl_end_ajout_mode - - ---------------------------------- - -- Category: Immediat mode methods + -- Category: Immediate mode methods ---------------------------------- SetImmediateModeDrawToFront (me : mutable; @@ -519,30 +509,17 @@ is -- But it works in any case and is especially useful for view dump because the dump image is read from the back buffer. -- @return previous mode. - BeginImmediatMode ( me : mutable; - ACView : CView from Graphic3d; - ACUnderLayer : CLayer2d from Aspect; - ACOverLayer : CLayer2d from Aspect; - DoubleBuffer : Boolean from Standard; - RetainMode : Boolean from Standard) - returns Boolean from Standard - is deferred; - ---Purpose: call_togl_begin_immediat_mode - - ClearImmediatMode ( me : mutable; ACView : CView from Graphic3d; - aFlush : Boolean from Standard = Standard_True) - is deferred; - ---Purpose: call_togl_clear_immediat_mode - - DrawStructure ( me : mutable; - ACStructure : CStructure from Graphic3d ) - is deferred; - ---Purpose: call_togl_draw_structure + DisplayImmediateStructure ( me : mutable; + theCView : CView from Graphic3d; + theCStructure : CStructure from Graphic3d ) + is deferred; + ---Purpose: Display structure in immediate mode on top of general presentation - EndImmediatMode ( me : mutable; - Synchronize : Integer from Standard ) - is deferred; - ---Purpose: call_togl_end_immediat_mode + EraseImmediateStructure ( me : mutable; + theCView : CView from Graphic3d; + theCStructure : CStructure from Graphic3d ) + is deferred; + ---Purpose: Erases immediate structure ------------------------------- -- Category: Layer mode methods diff --git a/src/Graphic3d/Graphic3d_Structure.cdl b/src/Graphic3d/Graphic3d_Structure.cdl index a756339991..49f230777d 100644 --- a/src/Graphic3d/Graphic3d_Structure.cdl +++ b/src/Graphic3d/Graphic3d_Structure.cdl @@ -87,15 +87,19 @@ is -- Category: Constructor ------------------------ - Create ( AManager : StructureManager from Graphic3d ) - returns mutable Structure from Graphic3d; - ---Level: Public - ---Purpose: Creates a graphic object in the manager . - -- It will appear in all the views of the visualiser. - -- Warning: The default values AspectLine, AspectFillArea, - -- AspectText and AspectMarker are NOT applied to the - -- structure. - -- The structure is not displayed when it is created. + Create (theManager : StructureManager from Graphic3d) + returns mutable Structure from Graphic3d; + ---Level: Public + ---Purpose: Creates a graphic object in the manager theManager. + -- It will appear in all the views of the visualiser. + -- Warning: The default values AspectLine, AspectFillArea, AspectText and AspectMarker are NOT applied to the structure. + -- The structure is not displayed when it is created. + + Create (theManager : StructureManager from Graphic3d; + thePrs : Structure from Graphic3d) + returns mutable Structure from Graphic3d; + ---Level: Public + ---Purpose: Creates a shadow link to existing graphic object. --------------------------------------------------- -- Category: Methods to modify the class definition diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index ce97024d0b..4f03321032 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -57,6 +57,34 @@ Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManage UpdateStructure (aAspectLine3d, aAspectText3d, aAspectMarker3d, aAspectFillArea3d); } +//============================================================================= +//function : Graphic3d_Structure +//purpose : +//============================================================================= +Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager, + const Handle(Graphic3d_Structure)& thePrs) +: myStructureManager (theManager.operator->()), + myFirstStructureManager (theManager.operator->()), + myComputeVisual (thePrs->myComputeVisual), + myHighlightColor (thePrs->myHighlightColor), + myHighlightMethod (thePrs->myHighlightMethod), + myOwner (thePrs->myOwner), + myVisual (thePrs->myVisual) +{ + myCStructure = thePrs->myCStructure->ShadowLink (theManager); + + // default aspects + Handle(Graphic3d_AspectLine3d) aAspectLine3d = new Graphic3d_AspectLine3d(); + Handle(Graphic3d_AspectText3d) aAspectText3d = new Graphic3d_AspectText3d(); + Handle(Graphic3d_AspectMarker3d) aAspectMarker3d = new Graphic3d_AspectMarker3d(); + Handle(Graphic3d_AspectFillArea3d) aAspectFillArea3d = new Graphic3d_AspectFillArea3d(); + theManager->PrimitivesAspect (aAspectLine3d, aAspectText3d, aAspectMarker3d, aAspectFillArea3d); + aAspectFillArea3d->SetPolygonOffsets (Aspect_POM_Fill, 1.0, 0.0); + + // update the associated CStructure + UpdateStructure (aAspectLine3d, aAspectText3d, aAspectMarker3d, aAspectFillArea3d); +} + //============================================================================= //function : Destroy //purpose : @@ -284,7 +312,10 @@ void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod theMetho SetDisplayPriority (Structure_MAX_PRIORITY - 1); GraphicHighlight (theMethod); - myStructureManager->Highlight (this, theMethod); + if (myCStructure->stick) + { + myStructureManager->Highlight (this, theMethod); + } Update(); } diff --git a/src/Graphic3d/Graphic3d_StructureManager.cdl b/src/Graphic3d/Graphic3d_StructureManager.cdl index 5493d343b6..b2a092b205 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cdl +++ b/src/Graphic3d/Graphic3d_StructureManager.cdl @@ -462,11 +462,10 @@ is -- resources after the last view has been closed without removing objects. RecomputeStructures (me: mutable; - theStructures : MapOfStructure from Graphic3d) - is private; + theStructures : MapOfStructure from Graphic3d); ---Purpose: Recomputes all structures from theStructures. --- +-- fields diff --git a/src/MeshVS/MeshVS_Mesh.cxx b/src/MeshVS/MeshVS_Mesh.cxx index 52a30e2389..2146f9ad50 100644 --- a/src/MeshVS/MeshVS_Mesh.cxx +++ b/src/MeshVS/MeshVS_Mesh.cxx @@ -1128,8 +1128,10 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage } } - if( PM->IsImmediateModeOn() ) - PM->AddToImmediateList( aHilightPrs ); + if (PM->IsImmediateModeOn()) + { + PM->AddToImmediateList (aHilightPrs); + } myHilighter->SetDrawer ( 0 ); } diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index 8494c66894..1db3d56f05 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -38,7 +38,6 @@ Handle_OpenGl_Workspace.hxx OpenGl_Workspace.hxx OpenGl_Workspace.cxx OpenGl_Workspace_2.cxx -OpenGl_Workspace_3.cxx OpenGl_Workspace_5.cxx Handle_OpenGl_View.hxx OpenGl_View.hxx diff --git a/src/OpenGl/OpenGl_Flipper.cxx b/src/OpenGl/OpenGl_Flipper.cxx index 5aa83b6592..70206c6a45 100755 --- a/src/OpenGl/OpenGl_Flipper.cxx +++ b/src/OpenGl/OpenGl_Flipper.cxx @@ -65,7 +65,7 @@ void OpenGl_Flipper::Release (const Handle(OpenGl_Context)& ) void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { // Check if rendering is to be in immediate mode - const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0; + const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0; const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext(); GLint aCurrMode = GL_MODELVIEW; glGetIntegerv (GL_MATRIX_MODE, &aCurrMode); diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 64637f3e19..8867f1582d 100755 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -200,104 +200,40 @@ Standard_Boolean OpenGl_GraphicDriver::GetOpenClDeviceInfo (const Graphic3d_CVie #endif // ======================================================================= -// function : BeginAddMode +// function : DisplayImmediateStructure // purpose : // ======================================================================= -Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& theCView) +void OpenGl_GraphicDriver::DisplayImmediateStructure (const Graphic3d_CView& theCView, + const Graphic3d_CStructure& theCStructure) { - if (theCView.ViewId == -1) - { - return Standard_False; - } - - const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; - if (aCView != NULL && aCView->WS->BeginAddMode()) - { - myImmediateWS = aCView->WS; - return Standard_True; - } - - return Standard_False; -} - -// ======================================================================= -// function : EndAddMode -// purpose : -// ======================================================================= -void OpenGl_GraphicDriver::EndAddMode() -{ - if (!myImmediateWS.IsNull()) - { - myImmediateWS->EndAddMode(); - myImmediateWS.Nullify(); - } -} - -// ======================================================================= -// function : BeginImmediatMode -// purpose : -// ======================================================================= -Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& theCView, - const Aspect_CLayer2d& /*theCUnderLayer*/, - const Aspect_CLayer2d& /*theCOverLayer*/, - const Standard_Boolean theDoubleBuffer, - const Standard_Boolean theRetainMode) -{ - if (theCView.ViewId == -1) - { - return Standard_False; - } - - const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; - if (aCView != NULL && aCView->WS->BeginImmediatMode (theCView, theDoubleBuffer, theRetainMode)) + OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; + OpenGl_Structure* aStructure = (OpenGl_Structure* )&theCStructure; + if (aCView == NULL) { - myImmediateWS = aCView->WS; - return Standard_True; + return; } - return Standard_False; + aCView->View->DisplayImmediateStructure (aStructure); } // ======================================================================= -// function : ClearImmediatMode +// function : EraseImmediateStructure // purpose : // ======================================================================= -void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& theCView, - const Standard_Boolean theToFlush) -{ - const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; - if (aCView != NULL) - { - aCView->WS->ClearImmediatMode (theCView, theToFlush); - } -} - -// ======================================================================= -// function : DrawStructure -// purpose : -// ======================================================================= -void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& theCStructure) +void OpenGl_GraphicDriver::EraseImmediateStructure (const Graphic3d_CView& theCView, + const Graphic3d_CStructure& theCStructure) { + OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView; OpenGl_Structure* aStructure = (OpenGl_Structure* )&theCStructure; - if (!myImmediateWS.IsNull()) + if (aCView == NULL) { - myImmediateWS->DrawStructure (aStructure); + return; } -} -// ======================================================================= -// function : EndImmediatMode -// purpose : -// ======================================================================= -void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer ) -{ - if (!myImmediateWS.IsNull()) - { - myImmediateWS->EndImmediatMode(); - myImmediateWS.Nullify(); - } + aCView->View->EraseImmediateStructure (aStructure); } + // ======================================================================= // function : Print // purpose : diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index a875278dbe..8f863c834d 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -132,6 +132,13 @@ public: // Methods for graphical structures Standard_EXPORT void RemoveStructure (Handle(Graphic3d_CStructure)& theCStructure); Standard_EXPORT Handle(Graphic3d_CStructure) Structure (const Handle(Graphic3d_StructureManager)& theManager); + Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Graphic3d_CView& theCView, + const Standard_Boolean theDrawToFrontBuffer); + Standard_EXPORT void DisplayImmediateStructure (const Graphic3d_CView& theCView, + const Graphic3d_CStructure& theCStructure); + Standard_EXPORT void EraseImmediateStructure (const Graphic3d_CView& theCView, + const Graphic3d_CStructure& theCStructure); + public: Standard_EXPORT void ActivateView (const Graphic3d_CView& ACView); @@ -145,14 +152,23 @@ public: Standard_EXPORT void DeactivateView (const Graphic3d_CView& ACView); Standard_EXPORT void DepthCueing (const Graphic3d_CView& ACView, const Standard_Boolean AFlag); Standard_EXPORT void RatioWindow (const Graphic3d_CView& ACView); - Standard_EXPORT void Redraw (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Integer x = 0, const Standard_Integer y = 0, const Standard_Integer width = 0, const Standard_Integer height = 0); + Standard_EXPORT void Redraw (const Graphic3d_CView& theCView, + const Aspect_CLayer2d& theCUnderLayer, + const Aspect_CLayer2d& theCOverLayer, + const Standard_Integer theX = 0, + const Standard_Integer theY = 0, + const Standard_Integer theWidth = 0, + const Standard_Integer theHeight = 0); + Standard_EXPORT void RedrawImmediate (const Graphic3d_CView& theCView, + const Aspect_CLayer2d& theCUnderLayer, + const Aspect_CLayer2d& theCOverLayer); + Standard_EXPORT void Invalidate (const Graphic3d_CView& theCView); Standard_EXPORT void RemoveView (const Graphic3d_CView& ACView); Standard_EXPORT void SetLight (const Graphic3d_CView& ACView); Standard_EXPORT void SetClipPlanes (const Graphic3d_CView& theCView); Standard_EXPORT void SetCamera (const Graphic3d_CView& theCView); Standard_EXPORT void SetVisualisation (const Graphic3d_CView& ACView); Standard_EXPORT void Transparency (const Graphic3d_CView& ACView, const Standard_Boolean AFlag); - Standard_EXPORT void Update (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer); Standard_EXPORT Standard_Boolean View (Graphic3d_CView& ACView); Standard_EXPORT void Environment (const Graphic3d_CView& ACView); Standard_EXPORT void SetStencilTestOptions (const Graphic3d_CGroup& theCGroup, const Standard_Boolean theIsEnabled); @@ -169,14 +185,6 @@ public: Standard_EXPORT void GraduatedTrihedronDisplay (const Graphic3d_CView& view, const Graphic3d_CGraduatedTrihedron& cubic); Standard_EXPORT void GraduatedTrihedronErase (const Graphic3d_CView& view); Standard_EXPORT void GraduatedTrihedronMinMaxValues (const Standard_ShortReal xmin, const Standard_ShortReal ymin, const Standard_ShortReal zmin, const Standard_ShortReal xmax, const Standard_ShortReal ymax, const Standard_ShortReal zmax); - Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Graphic3d_CView& theCView, - const Standard_Boolean theDrawToFrontBuffer); - Standard_EXPORT Standard_Boolean BeginAddMode (const Graphic3d_CView& ACView); - Standard_EXPORT void EndAddMode (); - Standard_EXPORT Standard_Boolean BeginImmediatMode(const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode); - Standard_EXPORT void ClearImmediatMode (const Graphic3d_CView& ACView,const Standard_Boolean aFlush = Standard_True); - Standard_EXPORT void DrawStructure (const Graphic3d_CStructure& ACStructure); - Standard_EXPORT void EndImmediatMode (const Standard_Integer Synchronize); Standard_EXPORT void Layer (Aspect_CLayer2d& ACLayer); Standard_EXPORT void RemoveLayer (const Aspect_CLayer2d& ACLayer); Standard_EXPORT void BeginLayer (const Aspect_CLayer2d& ACLayer); @@ -339,7 +347,6 @@ private: NCollection_DataMap myMapOfView; NCollection_DataMap myMapOfWS; NCollection_DataMap myMapOfStructure; - Handle(OpenGl_Workspace) myImmediateWS; mutable Handle(OpenGl_PrinterContext) myPrintContext; OpenGl_UserDrawCallback_t myUserDrawCallback; OpenGl_Text* myTempText; //!< variable for compatibility (drawing text in layers) diff --git a/src/OpenGl/OpenGl_GraphicDriver_7.cxx b/src/OpenGl/OpenGl_GraphicDriver_7.cxx index bdc565f579..dc5b191b1f 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_7.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_7.cxx @@ -126,6 +126,26 @@ void OpenGl_GraphicDriver::Redraw (const Graphic3d_CView& ACView, } } +void OpenGl_GraphicDriver::RedrawImmediate (const Graphic3d_CView& theCView, + const Aspect_CLayer2d& theCUnderLayer, + const Aspect_CLayer2d& theCOverLayer) +{ + const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; + if (aCView != NULL) + { + aCView->WS->RedrawImmediate (theCView, theCUnderLayer, theCOverLayer); + } +} + +void OpenGl_GraphicDriver::Invalidate (const Graphic3d_CView& theCView) +{ + const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; + if (aCView != NULL) + { + aCView->WS->Invalidate (theCView); + } +} + Graphic3d_PtrFrameBuffer OpenGl_GraphicDriver::FBOCreate (const Graphic3d_CView& ACView, const Standard_Integer theWidth, const Standard_Integer theHeight) { const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView; @@ -441,13 +461,6 @@ void OpenGl_GraphicDriver::Transparency (const Graphic3d_CView& ACView, const St aCView->WS->UseTransparency(AFlag); } -void OpenGl_GraphicDriver::Update (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer) -{ - const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView; - if (aCView) - aCView->WS->Update(ACView,ACUnderLayer,ACOverLayer); -} - Standard_Boolean OpenGl_GraphicDriver::View (Graphic3d_CView& theCView) { if (myGlDisplay.IsNull() diff --git a/src/OpenGl/OpenGl_NamedStatus.hxx b/src/OpenGl/OpenGl_NamedStatus.hxx index 28b2793fc3..c2d3ade486 100644 --- a/src/OpenGl/OpenGl_NamedStatus.hxx +++ b/src/OpenGl/OpenGl_NamedStatus.hxx @@ -20,13 +20,12 @@ #define OPENGL_NS_HIDE (1<<0) #define OPENGL_NS_HIGHLIGHT (1<<1) #define OPENGL_NS_RESMAT (1<<2) -#define OPENGL_NS_ADD (1<<3) -#define OPENGL_NS_IMMEDIATE (1<<4) -#define OPENGL_NS_TEXTURE (1<<5) -#define OPENGL_NS_ANTIALIASING (1<<6) -#define OPENGL_NS_2NDPASSNEED (1<<7) -#define OPENGL_NS_2NDPASSDO (1<<8) -#define OPENGL_NS_FORBIDSETTEX (1<<9) -#define OPENGL_NS_WHITEBACK (1<<10) +#define OPENGL_NS_IMMEDIATE (1<<3) +#define OPENGL_NS_TEXTURE (1<<4) +#define OPENGL_NS_ANTIALIASING (1<<5) +#define OPENGL_NS_2NDPASSNEED (1<<6) +#define OPENGL_NS_2NDPASSDO (1<<7) +#define OPENGL_NS_FORBIDSETTEX (1<<8) +#define OPENGL_NS_WHITEBACK (1<<9) #endif //_OpenGl_NamedStatus_Header diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index be362124f6..293b654f66 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -75,7 +75,7 @@ public: const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture(); glDisable (GL_LIGHTING); - if ((theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0) + if ((theWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0) { glDepthMask (GL_FALSE); } @@ -655,7 +655,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const AWorkspace->NamedStatus |= myNamedStatus; // Is rendering in ADD or IMMEDIATE mode? - const Standard_Boolean isImmediate = (AWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0; + const Standard_Boolean isImmediate = (AWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0; const Handle(OpenGl_Context)& aCtx = AWorkspace->GetGlContext(); @@ -775,7 +775,8 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const } // Render groups - OpenGl_ListOfGroup::Iterator itg(myGroups); + const OpenGl_ListOfGroup& aGroups = Groups(); + OpenGl_ListOfGroup::Iterator itg (aGroups); while (itg.More()) { itg.Value()->Render(AWorkspace); @@ -785,7 +786,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const // Render capping for structure groups if (!aContext->Clipping().Planes().IsEmpty()) { - OpenGl_CappingAlgo::RenderCapping (AWorkspace, myGroups); + OpenGl_CappingAlgo::RenderCapping (AWorkspace, aGroups); } // Revert structure clippings @@ -916,3 +917,62 @@ Standard_Integer OpenGl_Structure::GetZLayer () const { return myZLayer; } + +class OpenGl_StructureShadow : public OpenGl_Structure +{ + +public: + + //! Create empty structure + OpenGl_StructureShadow (const Handle(Graphic3d_StructureManager)& theManager, + const Handle(OpenGl_Structure)& theStructure); + + virtual const OpenGl_ListOfGroup& Groups() const { return myParent->Groups(); } + +private: + + Handle(OpenGl_Structure) myParent; + +public: + + DEFINE_STANDARD_RTTI(OpenGl_Structure) // Type definition + +}; + +DEFINE_STANDARD_HANDLE(OpenGl_StructureShadow, OpenGl_Structure) + +IMPLEMENT_STANDARD_HANDLE (OpenGl_StructureShadow, OpenGl_Structure) +IMPLEMENT_STANDARD_RTTIEXT(OpenGl_StructureShadow, OpenGl_Structure) + +OpenGl_StructureShadow::OpenGl_StructureShadow (const Handle(Graphic3d_StructureManager)& theManager, + const Handle(OpenGl_Structure)& theStructure) +: OpenGl_Structure (theManager) +{ + Handle(OpenGl_StructureShadow) aShadow = Handle(OpenGl_StructureShadow)::DownCast (theStructure); + myParent = aShadow.IsNull() ? theStructure : aShadow->myParent; + + + Composition = myParent->Composition; + ContainsFacet = myParent->ContainsFacet; + IsInfinite = myParent->IsInfinite; + for (Standard_Integer i = 0; i <= 3; ++i) + { + for (Standard_Integer j = 0; j <= 3; ++j) + { + Graphic3d_CStructure::Transformation[i][j] = myParent->Graphic3d_CStructure::Transformation[i][j]; + } + } + + TransformPersistence.IsSet = myParent->TransformPersistence.IsSet; + TransformPersistence.Flag = myParent->TransformPersistence.Flag; + TransformPersistence.Point = myParent->TransformPersistence.Point; +} + +//======================================================================= +//function : ShadowLink +//purpose : +//======================================================================= +Handle(Graphic3d_CStructure) OpenGl_Structure::ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const +{ + return new OpenGl_StructureShadow (theManager, this); +} diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 444a1c3d1b..2d720307ba 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -70,6 +70,9 @@ public: //! Highlight structure using boundary box virtual void HighlightWithBndBox (const Standard_Boolean theToCreate); + //! Create shadow link to this structure + virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const; + public: //! Access graphic driver @@ -120,7 +123,7 @@ public: void ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx); //! Returns list of OpenGL groups. - const OpenGl_ListOfGroup& Groups() const { return myGroups; } + virtual const OpenGl_ListOfGroup& Groups() const { return myGroups; } //! Returns list of connected OpenGL structures. const OpenGl_ListOfStructure& ConnectedStructures() const { return myConnected; } diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 982162ba11..a88fdaf4c0 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -135,11 +135,17 @@ class OpenGl_View : public MMgt_TShared //! The structure will be added to associated with it z layer. //! If the z layer is not presented in the view, the structure will //! be displayed in default bottom-level z layer. - void DisplayStructure (const OpenGl_Structure *theStructure, + void DisplayStructure (const OpenGl_Structure* theStructure, const Standard_Integer thePriority); //! Erase structure from display list. - void EraseStructure (const OpenGl_Structure *theStructure); + void EraseStructure (const OpenGl_Structure* theStructure); + + //! Add structure to the list of immediate structures. + void DisplayImmediateStructure (const OpenGl_Structure* theStructure); + + //! Erase structure from display list. + void EraseImmediateStructure (const OpenGl_Structure* theStructure); //! Insert a new top-level z layer with ID void AddZLayer (const Standard_Integer theLayerId); @@ -182,16 +188,18 @@ class OpenGl_View : public MMgt_TShared void GetMatrices (TColStd_Array2OfReal& theMatOrient, TColStd_Array2OfReal& theMatMapping) const; + //! Returns list of immediate structures rendered on top of main presentation + const OpenGl_SequenceOfStructure& ImmediateStructures() const + { + return myImmediateList; + } + #ifdef HAVE_OPENCL //! Returns modification state for ray-tracing. Standard_Size ModificationState() const { return myModificationState; } #endif -public: - - DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition - - protected: +protected: void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace); void RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintContext, @@ -242,7 +250,8 @@ public: //View_LABDepthCueing - fixed index used - OpenGl_LayerList myZLayers; + OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers + OpenGl_SequenceOfStructure myImmediateList; //!< list of immediate structures rendered on top of main presentation const TEL_TRANSFORM_PERSISTENCE *myTransPers; Standard_Boolean myIsTransPers; @@ -264,8 +273,11 @@ public: Standard_Size myModificationState; #endif - public: +public: + DEFINE_STANDARD_ALLOC + DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition + }; -#endif //_OpenGl_View_Header +#endif // _OpenGl_View_Header diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 9513ad817f..2292b91eae 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -947,6 +947,25 @@ void OpenGl_View::DisplayStructure (const OpenGl_Structure *theStructure, myZLayers.AddStructure (theStructure, aZLayer, thePriority); } +//======================================================================= +//function : DisplayImmediateStructure +//purpose : +//======================================================================= + +void OpenGl_View::DisplayImmediateStructure (const OpenGl_Structure* theStructure) +{ + for (OpenGl_SequenceOfStructure::Iterator anIter (myImmediateList); + anIter.More(); anIter.Next()) + { + if (anIter.Value() == theStructure) + { + return; + } + } + + myImmediateList.Append (theStructure); +} + //======================================================================= //function : EraseStructure //purpose : @@ -958,6 +977,24 @@ void OpenGl_View::EraseStructure (const OpenGl_Structure *theStructure) myZLayers.RemoveStructure (theStructure, aZLayer); } +//======================================================================= +//function : EraseImmediateStructure +//purpose : +//======================================================================= + +void OpenGl_View::EraseImmediateStructure (const OpenGl_Structure* theStructure) +{ + for (OpenGl_SequenceOfStructure::Iterator anIter (myImmediateList); + anIter.More(); anIter.Next()) + { + if (anIter.Value() == theStructure) + { + myImmediateList.Remove (anIter); + return; + } + } +} + //======================================================================= //function : ChangeZLayer //purpose : diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index f612d9dd0a..9f390636f2 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -861,15 +861,6 @@ void OpenGl_Window::MakeBackBufCurrent() const glDrawBuffer (GL_BACK); } -// ======================================================================= -// function : MakeFrontAndBackBufCurrent -// purpose : TelMakeFrontAndBackBufCurrent -// ======================================================================= -void OpenGl_Window::MakeFrontAndBackBufCurrent() const -{ - glDrawBuffer (GL_FRONT_AND_BACK); -} - // ======================================================================= // function : GetGContext // purpose : diff --git a/src/OpenGl/OpenGl_Window.hxx b/src/OpenGl/OpenGl_Window.hxx index e9393f6953..3266a1d2a2 100644 --- a/src/OpenGl/OpenGl_Window.hxx +++ b/src/OpenGl/OpenGl_Window.hxx @@ -87,9 +87,6 @@ protected: //! Draw to BACK buffer. Normal and default state. void MakeBackBufCurrent() const; - //! Draw simultaneously to BACK and FRONT buffers. Abnormal usage. - void MakeFrontAndBackBufCurrent() const; - protected: Handle(OpenGl_Display) myDisplay; diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index f6b19e4280..8f08b4b0d6 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -26,11 +26,12 @@ #include #include #include +#include #include +#include #include #include #include -#include #include @@ -145,14 +146,13 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, NamedStatus (0), HighlightColor (&THE_WHITE_COLOR), // - myIsTransientOpen (Standard_False), - myRetainMode (Standard_False), myTransientDrawToFront (Standard_True), + myBackBufferRestored (Standard_False), + myIsImmediateDrawn (Standard_False), myUseTransparency (Standard_False), myUseZBuffer (Standard_False), myUseDepthTest (Standard_True), myUseGLLight (Standard_True), - myBackBufferRestored (Standard_False), // AspectLine_set (&myDefaultAspectLine), AspectLine_applied (NULL), @@ -571,10 +571,11 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView, if (!theCView.IsRaytracing || myComputeInitStatus == OpenGl_CLIS_FAIL) { #endif - Redraw1 (theCView, theCUnderLayer, theCOverLayer, toSwap); - if (aFrameBuffer == NULL || !myTransientDrawToFront) + const Standard_Boolean isImmediate = !myView->ImmediateStructures().IsEmpty(); + redraw1 (theCView, theCUnderLayer, theCOverLayer, isImmediate ? 0 : toSwap); + if (isImmediate) { - RedrawImmediatMode(); + RedrawImmediate (theCView, theCUnderLayer, theCOverLayer, Standard_True); } theCView.WasRedrawnGL = Standard_True; @@ -598,7 +599,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView, glViewport (aViewPortBack[0], aViewPortBack[1], aViewPortBack[2], aViewPortBack[3]); } -#if (defined(_WIN32) || defined(__WIN32__)) && defined(HAVE_VIDEOCAPTURE) +#if defined(_WIN32) && defined(HAVE_VIDEOCAPTURE) if (OpenGl_AVIWriter_AllowWriting (theCView.DefWindow.XWindow)) { GLint params[4]; @@ -619,3 +620,210 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView, // reset render mode state aGlCtx->FetchState(); } + +// ======================================================================= +// function : redraw1 +// purpose : +// ======================================================================= +void OpenGl_Workspace::redraw1 (const Graphic3d_CView& theCView, + const Aspect_CLayer2d& theCUnderLayer, + const Aspect_CLayer2d& theCOverLayer, + const int theToSwap) +{ + if (myDisplay.IsNull() || myView.IsNull()) + { + return; + } + + // request reset of material + NamedStatus |= OPENGL_NS_RESMAT; + + // GL_DITHER on/off pour le background + if (myBackDither) + { + glEnable (GL_DITHER); + } + else + { + glDisable (GL_DITHER); + } + + GLbitfield toClear = GL_COLOR_BUFFER_BIT; + if (myUseZBuffer) + { + glDepthFunc (GL_LEQUAL); + glDepthMask (GL_TRUE); + if (myUseDepthTest) + { + glEnable (GL_DEPTH_TEST); + } + else + { + glDisable (GL_DEPTH_TEST); + } + + glClearDepth (1.0); + toClear |= GL_DEPTH_BUFFER_BIT; + } + else + { + glDisable (GL_DEPTH_TEST); + } + + if (NamedStatus & OPENGL_NS_WHITEBACK) + { + // set background to white + glClearColor (1.0f, 1.0f, 1.0f, 1.0f); + toClear |= GL_DEPTH_BUFFER_BIT; + } + else + { + glClearColor (myBgColor.rgb[0], myBgColor.rgb[1], myBgColor.rgb[2], 0.0f); + } + glClear (toClear); + + Handle(OpenGl_Workspace) aWS (this); + myView->Render (myPrintContext, aWS, theCView, theCUnderLayer, theCOverLayer); + + // swap the buffers + if (theToSwap) + { + GetGlContext()->SwapBuffers(); + myBackBufferRestored = Standard_False; + myIsImmediateDrawn = Standard_False; + } + else + { + glFlush(); + myBackBufferRestored = Standard_True; + myIsImmediateDrawn = Standard_False; + } +} + +// ======================================================================= +// function : copyBackToFront +// purpose : +// ======================================================================= +void OpenGl_Workspace::copyBackToFront() +{ + glMatrixMode (GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + gluOrtho2D (0.0, (GLdouble )myWidth, 0.0, (GLdouble )myHeight); + glMatrixMode (GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + DisableFeatures(); + + glDrawBuffer (GL_FRONT); + glReadBuffer (GL_BACK); + + glRasterPos2i (0, 0); + glCopyPixels (0, 0, myWidth + 1, myHeight + 1, GL_COLOR); + + EnableFeatures(); + + glMatrixMode (GL_PROJECTION); + glPopMatrix(); + glMatrixMode (GL_MODELVIEW); + glPopMatrix(); + + glDrawBuffer (GL_BACK); + + myIsImmediateDrawn = Standard_False; +} + +// ======================================================================= +// function : DisplayCallback +// purpose : +// ======================================================================= +void OpenGl_Workspace::DisplayCallback (const Graphic3d_CView& theCView, + Standard_Integer theReason) +{ + if (theCView.GDisplayCB == NULL) + { + return; + } + + Aspect_GraphicCallbackStruct aCallData; + aCallData.reason = theReason; + aCallData.glContext = GetGlContext(); + aCallData.wsID = theCView.WsId; + aCallData.viewID = theCView.ViewId; + theCView.GDisplayCB (theCView.DefWindow.XWindow, theCView.GClientData, &aCallData); +} + +// ======================================================================= +// function : RedrawImmediate +// purpose : +// ======================================================================= +void OpenGl_Workspace::RedrawImmediate (const Graphic3d_CView& theCView, + const Aspect_CLayer2d& theCUnderLayer, + const Aspect_CLayer2d& theCOverLayer, + const Standard_Boolean theToForce) +{ + if (!Activate()) + { + return; + } + + GLboolean isDoubleBuffer = GL_FALSE; + glGetBooleanv (GL_DOUBLEBUFFER, &isDoubleBuffer); + if (myView->ImmediateStructures().IsEmpty()) + { + if (theToForce + || !myIsImmediateDrawn) + { + myIsImmediateDrawn = Standard_False; + return; + } + + if (myBackBufferRestored + && isDoubleBuffer) + { + copyBackToFront(); + } + else + { + Redraw (theCView, theCUnderLayer, theCOverLayer); + } + return; + } + + if (isDoubleBuffer && myTransientDrawToFront) + { + if (!myBackBufferRestored) + { + Redraw (theCView, theCUnderLayer, theCOverLayer); + return; + } + copyBackToFront(); + MakeFrontBufCurrent(); + } + else + { + myBackBufferRestored = Standard_False; + } + myIsImmediateDrawn = Standard_True; + + NamedStatus |= OPENGL_NS_IMMEDIATE; + ///glDisable (GL_LIGHTING); + glDisable (GL_DEPTH_TEST); + + Handle(OpenGl_Workspace) aWS (this); + for (OpenGl_SequenceOfStructure::Iterator anIter (myView->ImmediateStructures()); + anIter.More(); anIter.Next()) + { + const OpenGl_Structure* aStructure = anIter.Value(); + aStructure->Render (aWS); + } + + NamedStatus &= ~OPENGL_NS_IMMEDIATE; + + if (isDoubleBuffer && myTransientDrawToFront) + { + glFlush(); + MakeBackBufCurrent(); + } +} diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index de0734bc0f..dac1880ea3 100755 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -116,12 +116,15 @@ public: const Aspect_CLayer2d& theCUnderLayer, const Aspect_CLayer2d& theCOverLayer); - //! Deprecated. Simply calls Redraw(). - void Update (const Graphic3d_CView& theCView, - const Aspect_CLayer2d& theCUnderLayer, - const Aspect_CLayer2d& theCOverLayer) + Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer); + void RedrawImmediate (const Graphic3d_CView& theCView, + const Aspect_CLayer2d& theCUnderLayer, + const Aspect_CLayer2d& theCOverLayer, + const Standard_Boolean theToForce = Standard_False); + + void Invalidate (const Graphic3d_CView& /*theCView*/) { - Redraw (theCView, theCUnderLayer, theCOverLayer); + myBackBufferRestored = Standard_False; } //! Special method to perform printing. @@ -143,18 +146,6 @@ public: void DisplayCallback (const Graphic3d_CView& theCView, int theReason); - Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer); - Standard_Boolean BeginAddMode(); - void EndAddMode(); - void ClearImmediatMode (const Graphic3d_CView& theCView, - const Standard_Boolean theToFlush); - void RedrawImmediatMode(); - Standard_Boolean BeginImmediatMode (const Graphic3d_CView& theCView, - const Standard_Boolean theUseDepthTest, - const Standard_Boolean theRetainMode); - void EndImmediatMode(); - void DrawStructure (const OpenGl_Structure* theStructure); - Graphic3d_PtrFrameBuffer FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight); void FBORelease (Graphic3d_PtrFrameBuffer theFBOPtr); Standard_Boolean BufferDump (OpenGl_FrameBuffer* theFBOPtr, @@ -227,15 +218,15 @@ public: protected: - void CopyBuffers (const Standard_Boolean theFrontToBack); + //! Copy content of Back buffer to the Front buffer + void copyBackToFront(); virtual Standard_Boolean Activate(); - // TEMPORARY!!! - void Redraw1 (const Graphic3d_CView& theCView, + void redraw1 (const Graphic3d_CView& theCView, const Aspect_CLayer2d& theCUnderLayer, const Aspect_CLayer2d& theCOverLayer, - const int theToSwap); + const int theToSwap); void updateMaterial (const int theFlag); @@ -423,17 +414,13 @@ protected: //! @name protected fields Handle(OpenGl_PrinterContext) myPrintContext; Handle(OpenGl_View) myView; // WSViews - now just one view is supported - Standard_Boolean myIsTransientOpen; // transientOpen - Standard_Boolean myRetainMode; Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer) - - NCollection_Sequence myTransientList; - + Standard_Boolean myBackBufferRestored; + Standard_Boolean myIsImmediateDrawn; //!< flag indicates that immediate mode buffer contains some data Standard_Boolean myUseTransparency; Standard_Boolean myUseZBuffer; Standard_Boolean myUseDepthTest; Standard_Boolean myUseGLLight; - Standard_Boolean myBackBufferRestored; protected: //! @name fields related to status diff --git a/src/OpenGl/OpenGl_Workspace_2.cxx b/src/OpenGl/OpenGl_Workspace_2.cxx index 0acfbd8d3d..6ab47d6ee7 100644 --- a/src/OpenGl/OpenGl_Workspace_2.cxx +++ b/src/OpenGl/OpenGl_Workspace_2.cxx @@ -38,8 +38,6 @@ #include #include -//10-05-96 : CAL ; Ajout d'un nouveau delta dans les copies de pixels (voir CALL_DEF_DELTA) -#define CALL_DEF_DELTA 10 #ifdef _WIN32 @@ -577,11 +575,11 @@ Standard_Boolean OpenGl_Workspace::Print myPrintContext->SetScale ((GLfloat )aFrameWidth /viewWidth, (GLfloat )aFrameHeight/viewHeight); aFrameBuffer->SetupViewport (GetGlContext()); - Redraw1(ACView, ACUnderLayer, ACOverLayer, 0); + redraw1 (ACView, ACUnderLayer, ACOverLayer, 0); if (!myTransientDrawToFront) { // render to FBO only if allowed to render to back buffer - RedrawImmediatMode(); + RedrawImmediate (ACView, ACUnderLayer, ACOverLayer, Standard_True); } glReadPixels (0, 0, aFrameWidth, aFrameHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, (GLvoid* )aViewBuffer); @@ -688,11 +686,11 @@ Standard_Boolean OpenGl_Workspace::Print // draw to the offscreen buffer and capture the result aFrameBuffer->SetupViewport (GetGlContext()); - Redraw1(ACView, ACUnderLayer, ACOverLayer, 0); + redraw1 (ACView, ACUnderLayer, ACOverLayer, 0); if (!myTransientDrawToFront) { // render to FBO only if forces to render to back buffer - RedrawImmediatMode(); + RedrawImmediate (ACView, ACUnderLayer, ACOverLayer, Standard_True); } glReadPixels (0, 0, aFrameWidth, aFrameHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, (GLvoid* )aViewBuffer); @@ -774,125 +772,3 @@ Standard_Boolean OpenGl_Workspace::Print return Standard_False; #endif } - -/*----------------------------------------------------------------------*/ - -//redrawView -void OpenGl_Workspace::Redraw1 (const Graphic3d_CView& ACView, - const Aspect_CLayer2d& ACUnderLayer, - const Aspect_CLayer2d& ACOverLayer, - const int aswap) -{ - if (myDisplay.IsNull() || myView.IsNull()) - return; - - // Request reset of material - NamedStatus |= OPENGL_NS_RESMAT; - - /* GL_DITHER on/off pour le background */ - if (myBackDither) - glEnable (GL_DITHER); - else - glDisable (GL_DITHER); - - GLbitfield toClear = GL_COLOR_BUFFER_BIT; - if ( myUseZBuffer ) - { - glDepthFunc(GL_LEQUAL); - glDepthMask(GL_TRUE); - - // SAV checking if depth test was deprecated somewhere outside - if ( myUseDepthTest ) - glEnable(GL_DEPTH_TEST); - else - glDisable(GL_DEPTH_TEST); - - glClearDepth(1.0); - toClear |= GL_DEPTH_BUFFER_BIT; - } - else - { - glDisable(GL_DEPTH_TEST); - } - - if ( NamedStatus & OPENGL_NS_WHITEBACK ) - { - // Set background to white - glClearColor (1.F, 1.F, 1.F, 1.F); - toClear |= GL_DEPTH_BUFFER_BIT; - } - else - { - glClearColor (myBgColor.rgb[0], myBgColor.rgb[1], myBgColor.rgb[2], 0.F); - } - glClear (toClear); - - Handle(OpenGl_Workspace) aWS(this); - myView->Render (myPrintContext, aWS, ACView, ACUnderLayer, ACOverLayer); - - // Swap the buffers - if ( aswap ) - { - GetGlContext()->SwapBuffers(); - myBackBufferRestored = Standard_False; - } - else - glFlush(); -} - -/*----------------------------------------------------------------------*/ - -//TelCopyBuffers -void OpenGl_Workspace::CopyBuffers (const Standard_Boolean theFrontToBack) -{ - if (theFrontToBack) - { - myBackBufferRestored = Standard_False; - } - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); - gluOrtho2D ((GLdouble) 0., (GLdouble) myWidth, 0., (GLdouble) myHeight); - glMatrixMode (GL_MODELVIEW); - glPushMatrix (); - glLoadIdentity (); - - DisableFeatures(); - - glDrawBuffer (theFrontToBack ? GL_BACK : GL_FRONT); - glReadBuffer (theFrontToBack ? GL_FRONT : GL_BACK); - - glRasterPos2i (0, 0); - glCopyPixels (0, 0, myWidth + 1, myHeight + 1, GL_COLOR); - - EnableFeatures(); - - glMatrixMode (GL_PROJECTION); - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - glPopMatrix (); - - glDrawBuffer (GL_BACK); -} - -/*----------------------------------------------------------------------*/ - -//call_subr_displayCB -void OpenGl_Workspace::DisplayCallback (const Graphic3d_CView& theCView, - int theReason) -{ - if (theCView.GDisplayCB == NULL) - { - return; - } - - Aspect_GraphicCallbackStruct aCallData; - aCallData.reason = theReason; - aCallData.glContext = GetGlContext(); - aCallData.wsID = theCView.WsId; - aCallData.viewID = theCView.ViewId; - theCView.GDisplayCB (theCView.DefWindow.XWindow, theCView.GClientData, &aCallData); -} - -/*----------------------------------------------------------------------*/ diff --git a/src/OpenGl/OpenGl_Workspace_3.cxx b/src/OpenGl/OpenGl_Workspace_3.cxx deleted file mode 100644 index ebf2e91b9d..0000000000 --- a/src/OpenGl/OpenGl_Workspace_3.cxx +++ /dev/null @@ -1,232 +0,0 @@ -// Created on: 2011-09-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-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. - -#include - -#include -#include -#include -#include - -/*----------------------------------------------------------------------*/ -/* Mode Ajout */ -/*----------------------------------------------------------------------*/ - -//call_togl_begin_ajout_mode -Standard_Boolean OpenGl_Workspace::BeginAddMode() -{ - if (!Activate()) - { - return Standard_False; - } - - NamedStatus |= OPENGL_NS_ADD; - - MakeFrontAndBackBufCurrent(); - - //TsmPushAttri(); - - return Standard_True; -} - -/*----------------------------------------------------------------------*/ - -//call_togl_end_ajout_mode -void OpenGl_Workspace::EndAddMode () -{ - if (NamedStatus & OPENGL_NS_ADD) - { - OpenGl_Workspace::MakeBackBufCurrent(); - - // Clear add mode flag - NamedStatus &= ~OPENGL_NS_ADD; - } - - // FMN necessaire pour l'affichage sur WNT - glFlush(); - - //TsmPopAttri(); -} - -/*----------------------------------------------------------------------*/ -/* Mode Transient */ -/*----------------------------------------------------------------------*/ - -//call_togl_clear_immediat_mode -void OpenGl_Workspace::ClearImmediatMode (const Graphic3d_CView& theCView, - const Standard_Boolean theToFlush) -{ - if (myIsTransientOpen) - { - EndImmediatMode(); - } - - if (!Activate()) - { - myTransientList.Clear(); // Clear current list contents - return; - } - - GLboolean isDoubleBuffer = GL_FALSE; - glGetBooleanv (GL_DOUBLEBUFFER, &isDoubleBuffer); - if (!myBackBufferRestored || !myTransientDrawToFront || !isDoubleBuffer) - { - Redraw1 (theCView, *((CALL_DEF_LAYER* )theCView.ptrUnderLayer), *((CALL_DEF_LAYER* )theCView.ptrOverLayer), theToFlush); - - // After a redraw, - // Made the back identical to the front buffer. - // Always perform full copy (partial update optimization is useless on mordern hardware)! - if (myRetainMode && myTransientDrawToFront && isDoubleBuffer) - { - const Standard_Boolean toCopyFrontToBack = Standard_True; - CopyBuffers (toCopyFrontToBack); - } - - myBackBufferRestored = Standard_True; - } - else if (!myTransientList.IsEmpty() && isDoubleBuffer) - { - // restore pixels from the back buffer - const Standard_Boolean toCopyFrontToBack = Standard_False; - CopyBuffers (toCopyFrontToBack); - } - - myTransientList.Clear(); // clear current list contents -} - -/*----------------------------------------------------------------------*/ - -//call_togl_redraw_immediat_mode -void OpenGl_Workspace::RedrawImmediatMode() -{ - if (!myRetainMode || myTransientList.IsEmpty()) - { - return; - } - - GLboolean isDoubleBuffer = GL_FALSE; - glGetBooleanv (GL_DOUBLEBUFFER, &isDoubleBuffer); - if (isDoubleBuffer && myTransientDrawToFront) - { - MakeFrontBufCurrent(); - } - else - { - myBackBufferRestored = Standard_False; - } - glDisable (GL_LIGHTING); - - Handle(OpenGl_Workspace) aWS (this); - for (Standard_Integer anIter = 1; anIter <= myTransientList.Size(); ++anIter) - { - const OpenGl_Structure* aStructure = myTransientList.Value (anIter); - aStructure->Render (aWS); - } - - if (isDoubleBuffer && myTransientDrawToFront) - { - glFlush(); // FMN necessaire pour l'affichage sur WNT - MakeBackBufCurrent(); - } -} - -/*----------------------------------------------------------------------*/ - -//call_togl_begin_immediat_mode -Standard_Boolean OpenGl_Workspace::BeginImmediatMode (const Graphic3d_CView& theCView, - const Standard_Boolean theToUseDepthTest, - const Standard_Boolean theRetainMode) -{ - if (!Activate()) - { - return Standard_False; - } - - OpenGl_Workspace::ClearImmediatMode (theCView, Standard_True); - - NamedStatus |= OPENGL_NS_IMMEDIATE; - myRetainMode = theRetainMode; - - if (myTransientDrawToFront) - { - MakeFrontBufCurrent(); - } - - //TsmPushAttri(); - - if (myRetainMode) - { - myIsTransientOpen = Standard_True; - } - - if (theToUseDepthTest) - { - glEnable (GL_DEPTH_TEST); - } - else - { - glDisable (GL_DEPTH_TEST); - } - - return Standard_True; -} - -/*----------------------------------------------------------------------*/ - -//call_togl_end_immediat_mode -void OpenGl_Workspace::EndImmediatMode() -{ - if (NamedStatus & OPENGL_NS_IMMEDIATE) - { - if (myIsTransientOpen) - { - myIsTransientOpen = Standard_False; - } - if (myTransientDrawToFront) - { - MakeBackBufCurrent(); - } - - // Clear immediate mode flag - NamedStatus &= ~OPENGL_NS_IMMEDIATE; - } - - if (myTransientDrawToFront) - { - // Ajout CAL : pour voir quelque chose avant le prochain begin_immediat_mode - glFinish(); - } - else - { - GetGlContext()->SwapBuffers(); - } - - //TsmPopAttri(); -} - -//call_togl_draw_structure -void OpenGl_Workspace::DrawStructure (const OpenGl_Structure* theStructure) -{ - if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) - { - Handle(OpenGl_Workspace) aWS (this); - theStructure->Render (aWS); - - if (myIsTransientOpen && myRetainMode) - { - myTransientList.Append (theStructure); - } - } -} diff --git a/src/Prs3d/FILES b/src/Prs3d/FILES index 823cf13642..c48cb5c169 100755 --- a/src/Prs3d/FILES +++ b/src/Prs3d/FILES @@ -5,3 +5,5 @@ Prs3d_WFShape.hxx Prs3d_WFShape.cxx Prs3d_DimensionUnits.hxx Prs3d_DimensionUnits.cxx +Prs3d_PresentationShadow.hxx +Prs3d_PresentationShadow.cxx diff --git a/src/Prs3d/Prs3d_Presentation.cdl b/src/Prs3d/Prs3d_Presentation.cdl index f07468a1ca..187a62cfea 100644 --- a/src/Prs3d/Prs3d_Presentation.cdl +++ b/src/Prs3d/Prs3d_Presentation.cdl @@ -40,12 +40,17 @@ uses ShadingAspect from Prs3d is - Create (aStructureManager: StructureManager from Graphic3d; - Init: Boolean from Standard = Standard_True) - ---Purpose: Constructs a presentation object - -- if is false, no color initialization is done. - returns mutable Presentation from Prs3d; + Create (theStructManager : StructureManager from Graphic3d; + theToInit : Boolean from Standard = Standard_True) + ---Purpose: Constructs a presentation object + -- if is false, no color initialization is done. + returns mutable Presentation from Prs3d; + + Create (theStructManager : StructureManager from Graphic3d; + thePrs : Presentation from Prs3d) + ---Purpose: Constructs a presentation object. + returns mutable Presentation from Prs3d; Compute(me : mutable; aProjector: DataStructureManager from Graphic3d) returns Structure from Graphic3d @@ -120,18 +125,11 @@ is NewGroup(me:mutable) returns mutable Group from Graphic3d is static private; fields - myStruct : Structure from Graphic3d; - myCurrentGroup: Group from Graphic3d; --- -friends - class Root from Prs3d - -end Presentation; - - - - + myCurrentGroup : Group from Graphic3d; +friends + class Root from Prs3d +end Presentation; diff --git a/src/Prs3d/Prs3d_Presentation.cxx b/src/Prs3d/Prs3d_Presentation.cxx index 17512a93e4..fdcb377e04 100644 --- a/src/Prs3d/Prs3d_Presentation.cxx +++ b/src/Prs3d/Prs3d_Presentation.cxx @@ -50,39 +50,53 @@ static void MakeGraphicTrsf (const Handle(Geom_Transformation)& aGeomTrsf, //======================================================================= //function : Prs3d_Presentation -//purpose : +//purpose : //======================================================================= -Prs3d_Presentation::Prs3d_Presentation - (const Handle(Graphic3d_StructureManager)& aViewer, - const Standard_Boolean Init): - Graphic3d_Structure(aViewer) +Prs3d_Presentation::Prs3d_Presentation (const Handle(Graphic3d_StructureManager)& theViewer, + const Standard_Boolean theToInit) +: Graphic3d_Structure (theViewer) { - if (Init) { - Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); - Quantity_Color Col; - // Ceci permet de recuperer la couleur associee - // au materiau defini par defaut. -//POP pour K4L - Col = aMat.AmbientColor (); -// Col = aMat.Color (); - - // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets - // It is necessary to set default polygon offsets for a new presentation - Handle(Graphic3d_AspectFillArea3d) aDefAspect = - new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, - Col, - Col, - Aspect_TOL_SOLID, - 1.0, - Graphic3d_NOM_BRASS, - Graphic3d_NOM_BRASS); - aDefAspect->SetPolygonOffsets( Aspect_POM_Fill, 1., 0. ); - SetPrimitivesAspect( aDefAspect ); - // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets + if (!theToInit) + { + return; } -// myStruct = Handle(Graphic3d_Structure)::DownCast(This ()); -// myCurrentGroup = new Graphic3d_Group(myStruct); + Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); + Quantity_Color aColor = aMat.AmbientColor(); + // It is necessary to set default polygon offsets for a new presentation + Handle(Graphic3d_AspectFillArea3d) aDefAspect = + new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, + aColor, + aColor, + Aspect_TOL_SOLID, + 1.0, + Graphic3d_NOM_BRASS, + Graphic3d_NOM_BRASS); + aDefAspect->SetPolygonOffsets (Aspect_POM_Fill, 1.0f, 0.0f); + SetPrimitivesAspect (aDefAspect); +} + +//======================================================================= +//function : Prs3d_Presentation +//purpose : +//======================================================================= +Prs3d_Presentation::Prs3d_Presentation (const Handle(Graphic3d_StructureManager)& theViewer, + const Handle(Prs3d_Presentation)& thePrs) +: Graphic3d_Structure (theViewer, thePrs) +{ + Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); + Quantity_Color aColor = aMat.AmbientColor(); + // It is necessary to set default polygon offsets for a new presentation + Handle(Graphic3d_AspectFillArea3d) aDefAspect = + new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, + aColor, + aColor, + Aspect_TOL_SOLID, + 1.0, + Graphic3d_NOM_BRASS, + Graphic3d_NOM_BRASS); + aDefAspect->SetPolygonOffsets (Aspect_POM_Fill, 1.0f, 0.0f); + SetPrimitivesAspect (aDefAspect); } //======================================================================= diff --git a/src/Prs3d/Prs3d_PresentationShadow.cxx b/src/Prs3d/Prs3d_PresentationShadow.cxx new file mode 100644 index 0000000000..c73bece695 --- /dev/null +++ b/src/Prs3d/Prs3d_PresentationShadow.cxx @@ -0,0 +1,30 @@ +// Created on: 2014-03-12 +// Created by: Kirill GAVRILOV +// Copyright (c) 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. + +#include + +IMPLEMENT_STANDARD_HANDLE (Prs3d_PresentationShadow, Prs3d_Presentation) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_PresentationShadow, Prs3d_Presentation) + +//======================================================================= +//function : Prs3d_PresentationShadow +//purpose : +//======================================================================= +Prs3d_PresentationShadow::Prs3d_PresentationShadow (const Handle(Graphic3d_StructureManager)& theViewer, + const Handle(Prs3d_Presentation)& thePrs) +: Prs3d_Presentation (theViewer, thePrs) +{ + // +} diff --git a/src/Prs3d/Prs3d_PresentationShadow.hxx b/src/Prs3d/Prs3d_PresentationShadow.hxx new file mode 100644 index 0000000000..cc8ae2cb48 --- /dev/null +++ b/src/Prs3d/Prs3d_PresentationShadow.hxx @@ -0,0 +1,39 @@ +// Created on: 2014-03-12 +// Created by: Kirill GAVRILOV +// Copyright (c) 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 _Prs3d_PresentationShadow_HeaderFile +#define _Prs3d_PresentationShadow_HeaderFile + +#include + +//! Defines a "shadow" of existing presentation object with custom aspects. +class Prs3d_PresentationShadow : public Prs3d_Presentation +{ + +public: + + //! Constructs a shadow of existing presentation object. + Standard_EXPORT Prs3d_PresentationShadow (const Handle(Graphic3d_StructureManager)& theViewer, + const Handle(Prs3d_Presentation)& thePrs); + +private: + + DEFINE_STANDARD_RTTI(Prs3d_PresentationShadow) + +}; + +DEFINE_STANDARD_HANDLE(Prs3d_PresentationShadow, Prs3d_Presentation) + +#endif // _Prs3d_PresentationShadow_HeaderFile diff --git a/src/PrsMgr/FILES b/src/PrsMgr/FILES new file mode 100644 index 0000000000..bc7af4c88d --- /dev/null +++ b/src/PrsMgr/FILES @@ -0,0 +1 @@ +PrsMgr_ListOfPresentations.hxx diff --git a/src/PrsMgr/PrsMgr.cdl b/src/PrsMgr/PrsMgr.cdl index e4ab009648..b42186f291 100644 --- a/src/PrsMgr/PrsMgr.cdl +++ b/src/PrsMgr/PrsMgr.cdl @@ -53,12 +53,13 @@ is -- removal mode, where every new point of view -- entails recalculation of the display. - deferred class PresentationManager; + class PresentationManager; + alias PresentationManager3d is PresentationManager; deferred class Presentation; deferred class PresentableObject; - - class PresentationManager3d; - + + imported ListOfPresentations; + class Prs; class Presentation3d; diff --git a/src/PrsMgr/PrsMgr_ListOfPresentations.hxx b/src/PrsMgr/PrsMgr_ListOfPresentations.hxx new file mode 100644 index 0000000000..206f637fec --- /dev/null +++ b/src/PrsMgr/PrsMgr_ListOfPresentations.hxx @@ -0,0 +1,28 @@ +// Created on: 2013-11-24 +// Created by: Kirill Gavrilov +// Copyright (c) 2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef _PrsMgr_ListOfPresentations_H__ +#define _PrsMgr_ListOfPresentations_H__ + +#include +#include + +typedef NCollection_List PrsMgr_ListOfPresentations; + +#endif // _PrsMgr_ListOfPresentations_H__ diff --git a/src/PrsMgr/PrsMgr_Presentation3d.cdl b/src/PrsMgr/PrsMgr_Presentation3d.cdl index 2e2f03cdc4..47af459ce0 100644 --- a/src/PrsMgr/PrsMgr_Presentation3d.cdl +++ b/src/PrsMgr/PrsMgr_Presentation3d.cdl @@ -21,7 +21,7 @@ class Presentation3d from PrsMgr inherits Presentation from PrsMgr uses - PresentationManager3d from PrsMgr, + PresentationManager from PrsMgr, Presentation from Prs3d, NameOfColor from Quantity, Transformation from Geom, @@ -35,7 +35,7 @@ uses Projector from Prs3d, KindOfPrs from PrsMgr is - Create(aPresentationManager: PresentationManager3d from PrsMgr; + Create(aPresentationManager: PresentationManager from PrsMgr; aPresentableObject: PresentableObject from PrsMgr) returns mutable Presentation3d from PrsMgr is private; @@ -167,7 +167,7 @@ fields myDisplayReason: Boolean from Standard; myPresentableObject: PresentableObjectPointer from PrsMgr; friends - class PresentationManager3d from PrsMgr, + class PresentationManager from PrsMgr, class PresentableObject from PrsMgr, class Prs from PrsMgr end Presentation3d from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cdl b/src/PrsMgr/PrsMgr_PresentationManager.cdl index 0bb8017eb6..74eb87be22 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cdl +++ b/src/PrsMgr/PrsMgr_PresentationManager.cdl @@ -14,200 +14,285 @@ -- Alternatively, this file may be used under the terms of Open CASCADE -- commercial license or contractual agreement. -deferred class PresentationManager from PrsMgr +class PresentationManager from PrsMgr inherits TShared from MMgt - ---Purpose: This class represents any kind of entity able to collect - -- representations of an object, to show or erase them. - -- Example: StructureManager from Graphic3d - -- View from Graphic2d + ---Purpose: A framework to manage 3D displays, graphic entities and their updates. + -- Used in the AIS package (Application Interactive Services), to enable the advanced user to define the + -- default display mode of a new interactive object which extends the list of signatures and types. + -- Definition of new display types is handled by calling the presentation algorithms provided by the StdPrs package. uses - Presentation from PrsMgr, - PresentableObject from PrsMgr, - View from V3d, - ListOfTransient from TColStd - - -raises - NoSuchObject from Standard + + StructureManager from Graphic3d, + PresentableObject from PrsMgr, + ListOfPresentations from PrsMgr, + Length,NameOfColor from Quantity, + Transformation from Geom, + NameOfMaterial from Graphic3d, + Presentation from PrsMgr, + Presentation3d from PrsMgr, + View from V3d, + ShadingAspect from Prs3d, + Presentation from Prs3d + +raises + + NoSuchObject from Standard + is - Initialize; - - Is3D(me) returns Boolean from Standard is deferred; - - Display(me: mutable; aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Displays the presentation of the object in the given - -- Presentation manager with the given mode. - -- The mode should be enumerated by the object which - -- inherits PresentableObject. - is static; - - Erase(me:mutable; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Level: public - ---Purpose: erases the presentation of the object in the given - -- Presentation manager with the given mode. - is static; - - Clear(me:mutable; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - is virtual; - ---Purpose: - -- Clears the presentation of the presentable object - -- aPresentableObject in this framework with the - -- display mode aMode. - - SetVisibility (me: mutable; thePresentableObject: PresentableObject from PrsMgr; - theMode: Integer from Standard; - theValue: Boolean from Standard); - ---Purpose: Sets the visibility of presentable object. - - Highlight(me: mutable; aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Highlights the presentation of the presentable object - -- aPresentableObject in this framework with the display mode aMode. - is static; - - Unhighlight(me:mutable; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Removes highlighting from the presentation of the - -- presentable object aPresentableObject in this - -- framework with the display mode aMode. - is static; - - SetDisplayPriority(me;aPresentableObject: PresentableObject from PrsMgr; - amode:Integer from Standard; - aNewPrior:Integer from Standard); - ---Purpose: - -- Sets the display priority aNewPrior of the - -- presentable object aPresentableObject in this - -- framework with the display mode aMode. - - DisplayPriority(me;aPresentableObject: PresentableObject from PrsMgr; - amode:Integer from Standard) - returns Integer from Standard; - ---Purpose: - -- Returns the display priority of the presentable object - -- aPresentableObject in this framework with the - -- display mode aMode. - - SetZLayer ( me : mutable; - thePresentableObject : PresentableObject from PrsMgr; - theLayerId : Integer from Standard ) - is static; - ---Purpose: Set Z layer ID for all presentations of the object. - - GetZLayer ( me; - thePresentableObject : PresentableObject from PrsMgr ) - returns Integer from Standard is static; - ---Purpose: Get Z layer ID assigned to all presentations of the object. - -- Method returns -1 value if object has no presentations and is - -- impossible to get layer index. - - IsDisplayed(me;aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Returns true if the presentation of the presentable - -- object aPresentableObject in this framework with the - -- display mode aMode is displayed. - returns Boolean from Standard - is static; - - IsHighlighted(me;aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Returns true if the presentation of the presentable - -- object aPresentableObject in this framework with the - -- display mode aMode is highlighted. - returns Boolean from Standard - is static; - - - Update(me; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Updates the presentation of the presentable object - -- aPresentableObject in this framework with the display mode aMode. - is static; - - ---Category: Immediate display methods. - - BeginDraw(me: mutable) is virtual; - ---Purpose: initializes the list of Prs to be displayed in transient mode - - Add(me: mutable ; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0); - ---Purpose: Performs an iteration of the transient objects to look - -- for the presentable objects with the display mode aMode. - -- Appends the presentation of the presentable object - -- aPresentableObject with the mode aMode to the list - -- of objects in immediate mode. - - Remove(me: mutable ; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0); - ---Purpose: Performs an iteration of the transient objects to look - -- for the presentable objects with the display mode aMode. - -- Removes the presentation of the presentable object - -- aPresentableObject with the mode aMode from the - -- list of objects in immediate mode. - - EndDraw(me: mutable; aView: View from V3d; DoubleBuffer: Boolean from Standard = Standard_False) - ---Purpose: Allows rapid drawing of the view aView by avoiding - -- an update of the whole background. If DoubleBuffer - -- is true, the background is drawn. - is deferred; - - IsImmediateModeOn(me) returns Boolean from Standard; - ---C++: inline - ---Purpose: Returns true if immediate (transient) mode is on. - - - - ---Category: Private & deferred methods. - - HasPresentation (me; - aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - returns Boolean from Standard - is static; - ---Purpose: Returns true if there is a presentation of the - -- presentable object aPresentableObject in this - -- framework, aPresentableObject having the display mode aMode. - - Presentation (me; - aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - returns mutable Presentation from PrsMgr - raises NoSuchObject from Standard - is static; - ---Purpose: Returns the presentation Presentation of the - -- presentable object aPresentableObject in this - -- framework. aPresentableObject has the display mode aMode. - - AddPresentation(me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Adds a presentation of the presentable object - -- aPresentableObject to this framework. - -- aPresentableObject has the display mode aMode. - is protected; - - RemovePresentation(me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Removes a presentation of the presentable object - -- aPresentableObject to this framework. - -- aPresentableObject has the display mode aMode. - is protected; - - newPresentation(me: mutable; aPresentableObject: PresentableObject from PrsMgr) - returns mutable Presentation from PrsMgr - ---Level: Internal - ---Purpose: Creates a new presentation in the presentation manager. - is deferred private; + Create (theStructureManager : StructureManager from Graphic3d) + returns mutable PresentationManager from PrsMgr; + ---Purpose: + -- Creates a framework to manage displays and graphic entities with the 3D view theStructureManager. + + Display (me : mutable; + thePrsObject : mutable PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: Displays the presentation of the object in the given Presentation manager with the given mode. + -- The mode should be enumerated by the object which inherits PresentableObject. + is static; + + Erase (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Level: public + ---Purpose: erases the presentation of the object in the given + -- Presentation manager with the given mode. + is static; + + Clear (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + is virtual; + ---Purpose: + -- Clears the presentation of the presentable object thePrsObject in this framework with the display mode theMode. + + SetVisibility (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard; + theValue : Boolean from Standard); + ---Purpose: Sets the visibility of presentable object. + + Highlight (me : mutable; + thePrsObject : mutable PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: Highlights the presentation of the presentable object + -- thePrsObject in this framework with the display mode theMode. + is static; + + Unhighlight (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: Removes highlighting from the presentation of the + -- presentable object thePrsObject in this framework with the display mode theMode. + is static; + + SetDisplayPriority (me; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard; + theNewPrior : Integer from Standard); + ---Purpose: + -- Sets the display priority theNewPrior of the + -- presentable object thePrsObject in this framework with the display mode theMode. + + DisplayPriority (me; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard) + returns Integer from Standard; + ---Purpose: + -- Returns the display priority of the presentable object + -- thePrsObject in this framework with the display mode theMode. + + SetZLayer (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theLayerId : Integer from Standard) + is static; + ---Purpose: Set Z layer ID for all presentations of the object. + + GetZLayer (me; + thePrsObject : PresentableObject from PrsMgr) + returns Integer from Standard is static; + ---Purpose: Get Z layer ID assigned to all presentations of the object. + -- Method returns -1 value if object has no presentations and is + -- impossible to get layer index. + + IsDisplayed (me; + thePrsObject : PresentableObject from PrsMgr; + theMode: Integer from Standard = 0) + --Purpose: Returns true if the presentation of the presentable + -- object thePrsObject in this framework with the display mode theMode is displayed. + returns Boolean from Standard + is static; + + IsHighlighted (me; + thePrsObject : PresentableObject from PrsMgr; + theMode: Integer from Standard = 0) + ---Purpose: Returns true if the presentation of the presentable + -- object thePrsObject in this framework with the display mode theMode is highlighted. + returns Boolean from Standard + is static; + + Update (me; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: Updates the presentation of the presentable object + -- thePrsObject in this framework with the display mode theMode. + is static; + +---Category: Immediate display methods. + + BeginImmediateDraw (me : mutable); + ---Purpose: Resets the transient list of presentations previously displayed in immediate mode + -- and begins accumulation of new list by following AddToImmediateList()/Color()/Highlight() calls. + + ClearImmediateDraw (me : mutable); + ---Purpose: Resets the transient list of presentations previously displayed in immediate mode. + + AddToImmediateList (me : mutable; + thePrs : Presentation from Prs3d); + ---Purpose: Stores thePrs in the transient list of presentations to be displayed in immediate mode. + -- Will be taken in account in EndImmediateDraw method. + + EndImmediateDraw (me : mutable; + theView : View from V3d); + ---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background. + + IsImmediateModeOn (me) returns Boolean from Standard; + ---C++: inline + ---Purpose: Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode. + +---Category: Hilighting methods. + + Color (me : mutable; + thePrsObject : mutable PresentableObject from PrsMgr; + theColor : NameOfColor from Quantity = Quantity_NOC_YELLOW; + theMode : Integer from Standard = 0) + ---Purpose: Highlights the graphic object thePrsObject in the color theColor. + -- thePrsObject has the display mode theMode; + -- this has the default value of 0, that is, the wireframe display mode. + is static; + + BoundBox (me : mutable; + thePrsObject : mutable PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: highlights the boundbox of the presentation + is static; + +---Category: references to other presentation. + + Connect (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theOtherObject : mutable PresentableObject from PrsMgr; + theMode : Integer from Standard = 0; + theOtherMode : Integer from Standard = 0) + is static; + +---Category: Transformation methods. + + Transform (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theTransformation : Transformation from Geom; + theMode : Integer from Standard = 0) + ---Purpose: + -- Sets the transformation theTransformation for the presentable object thePrsObject. + -- thePrsObject has the display mode theMode; this has the default value of 0, that is, the wireframe display mode. + is static; + + Place (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + X, Y, Z : Length from Quantity; + theMode : Integer from Standard = 0) + ---Purpose: + -- Sets a position to move the presentable object + -- aPresentableObject to. This position is defined by the + -- lengths along the x, y and z axes: X, Y and Z respectively. + -- aPresentableObject has the display mode aMode; + -- this has the default value of 0, that is, the wireframe display mode. + is static; + + Multiply (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theTransformation : Transformation from Geom; + theMode : Integer from Standard = 0) + ---Purpose: + -- Defines the transformation theTransformation for the presentable object thePrsObject. + -- thePrsObject has the display mode aMode; this has the default value of 0, that is, the wireframe display mode. + is static; + + Move (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + X, Y, Z : Length from Quantity; + theMode : Integer from Standard = 0) + ---Purpose: + -- Sets a position to move the presentable object thePrsObject to. This position is defined by the lengths along the x, y and z axes: X, Y and Z respectively. + -- thePrsObject has the display mode aMode; this has the default value of 0, that is, the wireframe display mode. + is static; + + StructureManager (me) returns mutable StructureManager from Graphic3d + is static; + ---C++: inline + ---C++: return const& + ---Purpose: Returns the structure manager. + + SetShadingAspect (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theColor : NameOfColor from Quantity; + theMaterial : NameOfMaterial from Graphic3d; + theMode : Integer from Standard = 0) + ---Purpose: this method will change the color and the aspect of the presentations containing shaded structures. + is static; + + SetShadingAspect (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theShadingAspect : ShadingAspect from Prs3d; + theMode : Integer from Standard = 0) + ---Purpose: this method will change the color and the aspect of the presentations containing shaded structures. + is static; + + CastPresentation (me; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + returns mutable Presentation3d from PrsMgr + is static; + +---Category: Private & deferred methods. + + HasPresentation (me; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + returns Boolean from Standard + is static; + ---Purpose: Returns true if there is a presentation of the + -- presentable object thePrsObject in this framework, thePrsObject having the display mode theMode. + + Presentation (me; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + returns mutable Presentation from PrsMgr + raises NoSuchObject from Standard + is static; + ---Purpose: Returns the presentation Presentation of the presentable object thePrsObject in this framework. thePrsObject has the display mode theMode. + + AddPresentation (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: Adds a presentation of the presentable object thePrsObject to this framework. + -- thePrsObject has the display mode theMode. + is protected; + + RemovePresentation (me : mutable; + thePrsObject : PresentableObject from PrsMgr; + theMode : Integer from Standard = 0) + ---Purpose: Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject has the display mode theMode. + is protected; fields - myImmediateMode: Boolean from Standard is protected; - myImmediateList: ListOfTransient from TColStd is protected; - + + myStructureManager : StructureManager from Graphic3d is protected; + myImmediateModeOn : Integer from Standard is protected; + myImmediateList : ListOfPresentations from PrsMgr is protected; + myImmediateView : View from V3d is protected; + end PresentationManager from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 755a1127c6..7908f2302a 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -13,63 +13,88 @@ // commercial license or contractual agreement. #include + +#include +#include #include #include #include #include #include +#include +#include +#include + +// ======================================================================= +// function : PrsMgr_PresentationManager +// purpose : +// ======================================================================= +PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager) +: myStructureManager (theStructureManager), + myImmediateModeOn (0) +{ + // +} - -PrsMgr_PresentationManager::PrsMgr_PresentationManager (): -myImmediateMode(Standard_False){} - - -void PrsMgr_PresentationManager::Display( - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) +// ======================================================================= +// function : Display +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); + if (!HasPresentation (thePrsObj, theMode)) + { + AddPresentation (thePrsObj, theMode); } - else if(Presentation(aPresentableObject,aMode)->MustBeUpdated()){ - Update(aPresentableObject,aMode); + + Handle(PrsMgr_Presentation3d) aPrs = CastPresentation (thePrsObj, theMode); + if (aPrs->MustBeUpdated()) + { + Update (thePrsObj, theMode); + } + + if (myImmediateModeOn > 0) + { + AddToImmediateList (aPrs->Presentation()); } - - if(myImmediateMode) - Add(aPresentableObject,aMode); else - Presentation(aPresentableObject,aMode)->Display(); + { + aPrs->Display(); + } } -void PrsMgr_PresentationManager::Erase( - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) +// ======================================================================= +// function : Erase +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) { - if (HasPresentation(aPresentableObject,aMode)) + if (HasPresentation (thePrsObj, theMode)) { - if(myImmediateMode) - { - Remove(aPresentableObject,aMode); - } - else - { - Presentation(aPresentableObject,aMode)->Erase(); - } - - RemovePresentation (aPresentableObject,aMode); + Presentation (thePrsObj, theMode)->Erase(); + RemovePresentation (thePrsObj, theMode); } } -void PrsMgr_PresentationManager::Clear(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) +// ======================================================================= +// function : Clear +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) { - if (HasPresentation(aPresentableObject,aMode)){ - if(myImmediateMode) - Remove(aPresentableObject,aMode); - else - Presentation(aPresentableObject,aMode)->Clear();} + if (HasPresentation (thePrsObj, theMode)) + { + Presentation (thePrsObj, theMode)->Clear(); + } } +// ======================================================================= +// function : SetVisibility +// purpose : +// ======================================================================= void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableObject)& thePresentableObject, const Standard_Integer theMode, const Standard_Boolean theValue) @@ -77,218 +102,473 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO Presentation(thePresentableObject, theMode)->SetVisible (theValue); } -void PrsMgr_PresentationManager::Highlight( - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) +// ======================================================================= +// function : Highlight +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); + if (!HasPresentation (thePrsObj, theMode)) + { + AddPresentation (thePrsObj, theMode); } - else if(Presentation(aPresentableObject,aMode)->MustBeUpdated()){ - Update(aPresentableObject,aMode); + + Handle(PrsMgr_Presentation3d) aPrs = CastPresentation (thePrsObj, theMode); + if (aPrs->MustBeUpdated()) + { + Update (thePrsObj, theMode); } - Presentation(aPresentableObject,aMode)->Highlight(); - if(myImmediateMode) - Add(aPresentableObject,aMode); + if (myImmediateModeOn > 0) + { + Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); + aShadow->Highlight(); + AddToImmediateList (aShadow); + } + else + { + aPrs->Highlight(); + } } -void PrsMgr_PresentationManager::Unhighlight( - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) +// ======================================================================= +// function : Unhighlight +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) { - if (HasPresentation(aPresentableObject,aMode)){ - Presentation(aPresentableObject,aMode)->Unhighlight(); - if(myImmediateMode) - Remove(aPresentableObject,aMode); + if (HasPresentation (thePrsObj, theMode)) + { + Presentation (thePrsObj, theMode)->Unhighlight(); } } +// ======================================================================= +// function : SetDisplayPriority +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode, + const Standard_Integer theNewPrior) const +{ + if (HasPresentation (thePrsObj, theMode)) + { + Presentation (thePrsObj, theMode)->SetDisplayPriority (theNewPrior); + } +} -void PrsMgr_PresentationManager:: -SetDisplayPriority(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode, - const Standard_Integer theNewPrior) const +// ======================================================================= +// function : DisplayPriority +// purpose : +// ======================================================================= +Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) const { - if (HasPresentation(aPresentableObject,aMode)) - Presentation(aPresentableObject,aMode)->SetDisplayPriority(theNewPrior); + return HasPresentation (thePrsObj, theMode) + ? Presentation (thePrsObj, theMode)->DisplayPriority() + : 0; } -Standard_Integer PrsMgr_PresentationManager:: -DisplayPriority(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) const +// ======================================================================= +// function : IsDisplayed +// purpose : +// ======================================================================= +Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) const { - if (HasPresentation(aPresentableObject,aMode)) - return Presentation(aPresentableObject,aMode)->DisplayPriority(); - - return 0; + return HasPresentation (thePrsObj, theMode) + && Presentation (thePrsObj, theMode)->IsDisplayed(); } +// ======================================================================= +// function : IsHighlighted +// purpose : +// ======================================================================= +Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) const +{ + return HasPresentation (thePrsObj, theMode) + && Presentation (thePrsObj, theMode)->IsHighlighted(); +} -Standard_Boolean PrsMgr_PresentationManager::IsDisplayed ( - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) const { - if (HasPresentation(aPresentableObject,aMode)) - return Presentation(aPresentableObject,aMode)->IsDisplayed(); - return Standard_False; - } +// ======================================================================= +// function : Update +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) const +{ + if (!HasPresentation(thePrsObj, theMode)) + { + return; + } -Standard_Boolean PrsMgr_PresentationManager::IsHighlighted ( - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) const { - if (HasPresentation(aPresentableObject,aMode)) - return Presentation(aPresentableObject,aMode)->IsHighlighted(); - return Standard_False; - } + Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); + if (!aPrs.IsNull()) + { + aPrs->Clear(); + thePrsObj->Fill (this, aPrs, theMode); + aPrs->SetUpdateStatus (Standard_False); + } +} -void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& aPresentableObject,const Standard_Integer aMode ) const { - if(HasPresentation(aPresentableObject,aMode)) { - Handle(PrsMgr_Presentation) P = Presentation(aPresentableObject,aMode); - if (!P.IsNull()) { - P->Clear(); - aPresentableObject->Fill(this,P,aMode); - P->SetUpdateStatus(Standard_False); - } +// ======================================================================= +// function : BeginImmediateDraw +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::BeginImmediateDraw() +{ + if (++myImmediateModeOn > 1) + { + return; } + + ClearImmediateDraw(); } -void PrsMgr_PresentationManager::BeginDraw() { - myImmediateMode = Standard_True; + +// ======================================================================= +// function : ClearImmediateDraw +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::ClearImmediateDraw() +{ + if (myImmediateView.IsNull()) + { + myImmediateList.Clear(); + return; + } + + for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) + { + myImmediateView->View()->EraseImmediate (anIter.Value()); + } + myImmediateList.Clear(); + myImmediateView.Nullify(); } +// ======================================================================= +// function : EndImmediateDraw +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_View)& theView) +{ + if (--myImmediateModeOn > 0) + { + return; + } + + for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) + { + theView->View()->DisplayImmediate (anIter.Value(), Standard_True); + } + if (!myImmediateList.IsEmpty()) + { + myImmediateView = theView; + } +} -void PrsMgr_PresentationManager::Add(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) { - if (myImmediateMode ) { - Handle(PrsMgr_Presentation) P = Presentation(aPresentableObject,aMode); - for (TColStd_ListIteratorOfListOfTransient it(myImmediateList);it.More();it.Next()){ - if(it.Value()==P) return; +// ======================================================================= +// function : AddToImmediateList +// purpose : +//======================================================================= +void PrsMgr_PresentationManager::AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs) +{ + if (myImmediateModeOn < 1) + { + return; + } + + for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next()) + { + if (anIter.Value() == thePrs) + { + return; } - myImmediateList.Append(P); - } -} -void PrsMgr_PresentationManager::Remove(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) { - if (myImmediateMode ) { - Handle(PrsMgr_Presentation) P = Presentation(aPresentableObject,aMode); - for (TColStd_ListIteratorOfListOfTransient it(myImmediateList);it.More();it.Next()){ - if(it.Value()==P) { - myImmediateList.Remove(it); - return; - } + } + + myImmediateList.Append (thePrs); +} + +// ======================================================================= +// function : HasPresentation +// purpose : +// ======================================================================= +Standard_Boolean PrsMgr_PresentationManager::HasPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) const +{ + const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); + for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) + { + const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter); + const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager(); + if (theMode == aModedPrs.Mode() + && this == aPrsMgr) + { + return Standard_True; } } + return Standard_False; } +// ======================================================================= +// function : Presentation +// purpose : +// ======================================================================= +Handle(PrsMgr_Presentation) PrsMgr_PresentationManager::Presentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) const +{ + const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); + if (aPrsList.IsEmpty()) + { + return Handle(PrsMgr_Presentation)(); + } + for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) + { + const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter); + const Handle(PrsMgr_PresentationManager)& aPrsMgr = aModedPrs.Presentation()->PresentationManager(); + if (theMode == aModedPrs.Mode() + && this == aPrsMgr) + { + return aModedPrs.Presentation(); + } + } + // To be changed within dedicated patch + ///return Handle(PrsMgr_Presentation)(); + return aPrsList.Last().Presentation(); +} -Standard_Boolean PrsMgr_PresentationManager::HasPresentation - (const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) const { +// ======================================================================= +// function : AddPresentation +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::AddPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) +{ + Handle(PrsMgr_Presentation) aPrs = new PrsMgr_Presentation3d (this, thePrsObj); + thePrsObj->Presentations().Append (PrsMgr_ModedPresentation (aPrs, theMode)); + thePrsObj->Fill (this, aPrs, theMode); - const PrsMgr_Presentations& S = aPresentableObject->Presentations(); - Standard_Boolean found = Standard_False; - Standard_Integer i=1; Standard_Integer l= S.Length(); - while (i<= l && !found) { -// modif WOK++ : operator == is ambiguous -// found = aMode == S(i).Mode() -// && this == S(i).Presentation()->PresentationManager(); - const Handle (PrsMgr_Presentation)& popPrs = S(i).Presentation(); - const Handle (PrsMgr_PresentationManager)& popPrsMgr = popPrs->PresentationManager(); - if ( aMode == S(i).Mode() && this == popPrsMgr ) - found = Standard_True; - i++; - } - return found; - } + // set layer index accordingly to object's presentations + const Standard_Integer aZLayerId = GetZLayer (thePrsObj); + if (aZLayerId >= 0) + { + aPrs->SetZLayer (aZLayerId); + } + aPrs->SetUpdateStatus (Standard_False); +} -Handle (PrsMgr_Presentation) - PrsMgr_PresentationManager::Presentation(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) const +// ======================================================================= +// function : RemovePresentation +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theMode) { - Handle(PrsMgr_Presentation) P; - const PrsMgr_Presentations& S = aPresentableObject->Presentations(); - Standard_Boolean found = Standard_False; - Standard_Integer i=1; Standard_Integer l= S.Length(); - while (i<= l && !found) { - P = S(i).Presentation(); - const Handle (PrsMgr_PresentationManager)& popPrsMgr = P->PresentationManager(); - if (aMode == S(i).Mode() && this == popPrsMgr) { - found = Standard_True; + PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); + for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) + { + if (theMode == aPrsList (aPrsIter).Mode()) + // && this == aPrsMgr) ?? + { + aPrsList.Remove (aPrsIter); + break; + } + } +} +// ======================================================================= +// function : SetZLayer +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Standard_Integer theLayerId) +{ + PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); + for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) + { + Handle(PrsMgr_Presentation) aPrs = aPrsList.ChangeValue (aPrsIter).Presentation(); + if (aPrs->PresentationManager() == this) + { + aPrs->SetZLayer (theLayerId); + } + } +} +// ======================================================================= +// function : GetZLayer +// purpose : +// ======================================================================= +Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const +{ + const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); + for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) + { + Handle(PrsMgr_Presentation) aPrs = aPrsList.Value (aPrsIter).Presentation(); + if (aPrs->PresentationManager() == this) + { + return aPrs->GetZLayer(); } - i++; } + return -1; +} - return P; +// ======================================================================= +// function : Connect +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Connect (const Handle(PrsMgr_PresentableObject)& thePrsObject, + const Handle(PrsMgr_PresentableObject)& theOtherObject, + const Standard_Integer theMode, + const Standard_Integer theOtherMode) +{ + if (!HasPresentation (thePrsObject, theMode)) + { + AddPresentation (thePrsObject, theMode); + } + if (!HasPresentation (theOtherObject, theOtherMode)) + { + AddPresentation (theOtherObject, theOtherMode); + } + CastPresentation (thePrsObject, theMode)->Connect (CastPresentation (theOtherObject, theMode)); } -void PrsMgr_PresentationManager::AddPresentation - (const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) { +// ======================================================================= +// function : Transform +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Handle(Geom_Transformation)& theTransformation, + const Standard_Integer theMode) +{ + CastPresentation (thePrsObj, theMode)->Transform (theTransformation); +} - Handle(PrsMgr_Presentation) P = newPresentation(aPresentableObject); - aPresentableObject->Presentations().Append(PrsMgr_ModedPresentation(P,aMode)); - aPresentableObject->Fill(this,P,aMode); +// ======================================================================= +// function : Place +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Place (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Quantity_Length theX, + const Quantity_Length theY, + const Quantity_Length theZ, + const Standard_Integer theMode) +{ + CastPresentation (thePrsObj, theMode)->Place (theX, theY, theZ); +} - // set layer index accordingly to object's presentations - Standard_Integer aZLayerId = GetZLayer (aPresentableObject); - if (aZLayerId >= 0) - P->SetZLayer (aZLayerId); +// ======================================================================= +// function : Multiply +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Multiply (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Handle(Geom_Transformation)& theTransformation, + const Standard_Integer theMode) +{ + CastPresentation (thePrsObj, theMode)->Multiply (theTransformation); +} - P->SetUpdateStatus(Standard_False); +// ======================================================================= +// function : Move +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Move (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Quantity_Length theX, + const Quantity_Length theY, + const Quantity_Length theZ, + const Standard_Integer theMode) +{ + CastPresentation (thePrsObj, theMode)->Move (theX, theY, theZ); } -void PrsMgr_PresentationManager::RemovePresentation(const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) +// ======================================================================= +// function : Color +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, + const Quantity_NameOfColor theColor, + const Standard_Integer theMode) { - PrsMgr_Presentations& S = aPresentableObject->Presentations(); - Standard_Integer i = 1; - Standard_Integer n = S.Length(); - while (i<= n) { - if (aMode == S(i).Mode()) { - S.Remove(i); - break; - } - i++; + if (!HasPresentation (thePrsObj, theMode)) + { + AddPresentation (thePrsObj, theMode); } -} -//======================================================================= -//function : SetZLayer -//purpose : -//======================================================================= + Handle(PrsMgr_Presentation3d) aPrs = CastPresentation (thePrsObj, theMode); + if (aPrs->MustBeUpdated()) + { + Update (thePrsObj, theMode); + } -void PrsMgr_PresentationManager::SetZLayer - (const Handle(PrsMgr_PresentableObject)& thePresentableObject, - const Standard_Integer theLayerId) + if (myImmediateModeOn > 0) + { + Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); + aShadow->Color (theColor); + AddToImmediateList (aShadow); + } + else + { + aPrs->Color (theColor); + } +} + +// ======================================================================= +// function : BoundBox +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObject, + const Standard_Integer theMode) { - PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations(); - for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++) + if (!HasPresentation (thePrsObject, theMode)) { - Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation (); - if (aPrs->PresentationManager () == this) - aPrs->SetZLayer (theLayerId); + AddPresentation (thePrsObject, theMode); + } + else if (Presentation (thePrsObject, theMode)->MustBeUpdated()) + { + Update (thePrsObject, theMode); } + CastPresentation (thePrsObject, theMode)->BoundBox(); } -//======================================================================= -//function : GetZLayer -//purpose : -//======================================================================= +// ======================================================================= +// function : SetShadingAspect +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject, + const Quantity_NameOfColor theColor, + const Graphic3d_NameOfMaterial theMaterial, + const Standard_Integer theMode) +{ + Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect(); + anAspect->SetColor (theColor); + anAspect->SetMaterial (theMaterial); + SetShadingAspect (thePrsObject, anAspect, theMode); +} -Standard_Integer PrsMgr_PresentationManager::GetZLayer - (const Handle(PrsMgr_PresentableObject)& thePresentableObject) const +// ======================================================================= +// function : SetShadingAspect +// purpose : +// ======================================================================= +void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject, + const Handle(Prs3d_ShadingAspect)& theShadingAspect, + const Standard_Integer theMode) { - PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations(); - for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++) + if (HasPresentation (thePrsObject, theMode)) { - Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation (); - if (aPrs->PresentationManager () == this) - return aPrs->GetZLayer (); + CastPresentation (thePrsObject, theMode)->SetShadingAspect (theShadingAspect); } - - return -1; +} + +// ======================================================================= +// function : CastPresentation +// purpose : +// ======================================================================= +Handle(PrsMgr_Presentation3d) PrsMgr_PresentationManager::CastPresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, + const Standard_Integer theMode) const +{ + return Handle(PrsMgr_Presentation3d)::DownCast (Presentation (thePrsObject, theMode)); } diff --git a/src/PrsMgr/PrsMgr_PresentationManager.lxx b/src/PrsMgr/PrsMgr_PresentationManager.lxx index 3425670123..9724f0c77f 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.lxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.lxx @@ -15,4 +15,11 @@ // commercial license or contractual agreement. inline Standard_Boolean PrsMgr_PresentationManager::IsImmediateModeOn() const -{return myImmediateMode;} +{ + return myImmediateModeOn > 0; +} + +inline const Handle(Graphic3d_StructureManager)& PrsMgr_PresentationManager::StructureManager() const +{ + return myStructureManager; +} diff --git a/src/PrsMgr/PrsMgr_PresentationManager3d.cdl b/src/PrsMgr/PrsMgr_PresentationManager3d.cdl deleted file mode 100644 index 91aa3a3257..0000000000 --- a/src/PrsMgr/PrsMgr_PresentationManager3d.cdl +++ /dev/null @@ -1,191 +0,0 @@ --- Created on: 1993-10-21 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- 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. - --- Modified by rob Aug 20 98 : --- new Methods : Is3D() , AddToImmediateList (Prs) --- BeginDraw redefined --- new field : myStrList --- => allows users to store independant Graphic Structures --- which will be displayed in immediate mode when EndDraw --- is applied - - -class PresentationManager3d from PrsMgr inherits PresentationManager from PrsMgr - - ---Purpose: A framework to manage 3D displays, graphic entities - -- and their updates. - -- Used in the AIS package (Application Interactive - -- Services), to enable the advanced user to define the - -- default display mode of a new interactive object which - -- extends the list of signatures and types. - -- Definition of new display types is handled by calling - -- the presentation algorithms provided by the StdPrs package. - -uses - ListOfTransient from TColStd, - StructureManager from Graphic3d, - PresentableObject from PrsMgr, - Length,NameOfColor from Quantity, - Transformation from Geom, - NameOfMaterial from Graphic3d, - --NameOfMaterialPhysic from Graphic3d, - --NameOfPhysicalMaterial from Graphic3d, - Presentation from PrsMgr, - Presentation3d from PrsMgr, - View from V3d, - ShadingAspect from Prs3d, - Presentation from Prs3d -is - - Create(aStructureManager: StructureManager from Graphic3d) - returns mutable PresentationManager3d from PrsMgr; - ---Purpose: - -- Creates a framework to manage displays and graphic - -- entities with the 3D view aStructureManager. - - Is3D(me) returns Boolean from Standard is redefined; - - Color(me: mutable; - aPresentableObject: mutable PresentableObject from PrsMgr; - aColor: NameOfColor from Quantity = Quantity_NOC_YELLOW; - aMode: Integer from Standard = 0) - ---Purpose: Highlights the graphic object aPresentableObject in - -- the color aColor. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe display mode. - is static; - - - BoundBox(me: mutable; aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: highlights the boundbox of the presentation - - is static; - ----Category: Immediate display methods. --- - - BeginDraw(me:mutable) is redefined static; - - AddToImmediateList(me:mutable;aPrs:Presentation from Prs3d); - ---Purpose: stores in a list of structure to be displayed - -- in immediate mode. will be taken in account in EndDraw Method. - - EndDraw(me: mutable; theView: View from V3d; DoubleBuffer: Boolean from Standard = Standard_False) - is redefined static; - - ----Category: references to other presentation. - - Connect(me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - anOtherObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0; - anOtherMode: Integer from Standard = 0) - is static; - ----Category: Transformation methods. - - Transform (me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - aTransformation: Transformation from Geom; - aMode: Integer from Standard = 0) - ---Purpose: - -- Sets the transformation aTransformation for the - -- presentable object aPresentableObject. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe - -- display mode. - is static; - - Place (me: mutable; aPresentableObject: PresentableObject from PrsMgr; - X,Y,Z: Length from Quantity; - aMode: Integer from Standard = 0) - ---Purpose: - -- Sets a position to move the presentable object - -- aPresentableObject to. This position is defined by the - -- lengths along the x, y and z axes: X, Y and Z respectively. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe display mode. - is static; - - Multiply (me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - aTransformation: Transformation from Geom; - aMode: Integer from Standard = 0) - ---Purpose: - -- Defines the transformation aTransformation for the - -- presentable object aPresentableObject. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe - -- display mode. - is static; - - Move (me: mutable; aPresentableObject: PresentableObject from PrsMgr; - X,Y,Z: Length from Quantity; - aMode: Integer from Standard = 0) - ---Purpose: - -- Sets a position to move the presentable object - -- aPresentableObject to. This position is defined by the - -- lengths along the x, y and z axes: X, Y and Z respectively. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe - -- display mode. - is static; - - StructureManager(me) returns mutable StructureManager from Graphic3d - is static; - ---C++: inline - ---C++: return const& - ---Purpose: Returns the structure manager. - - SetShadingAspect(me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - aColor: NameOfColor from Quantity; - aMaterial: NameOfMaterial from Graphic3d; - --aMaterial: NameOfPhysicalMaterial from Graphic3d; - aMode: Integer from Standard = 0) - ---Purpose: this method will change the color and the aspect - -- of the presentations containg shaded structures. - is static; - - - SetShadingAspect(me: mutable; - aPresentableObject: PresentableObject from PrsMgr; - aShadingAspect: ShadingAspect from Prs3d; - aMode: Integer from Standard = 0) - ---Purpose: this method will change the color and the aspect - -- of the presentations containg shaded structures. - is static; - - - CastPresentation(me; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - returns mutable Presentation3d from PrsMgr - is static ; - - newPresentation(me: mutable; aPresentableObject: PresentableObject from PrsMgr) - returns mutable Presentation from PrsMgr - ---Level: Internal - ---Purpose: Creates a new presentation in the presentation manager. - is redefined static private; - -fields - - myStructureManager : StructureManager from Graphic3d; - myStrList : ListOfTransient from TColStd; - -end PresentationManager3d from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentationManager3d.cxx b/src/PrsMgr/PrsMgr_PresentationManager3d.cxx deleted file mode 100644 index a98a7bfe46..0000000000 --- a/src/PrsMgr/PrsMgr_PresentationManager3d.cxx +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// 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. - -#include -#include -#include -#include -#include -#include - -PrsMgr_PresentationManager3d::PrsMgr_PresentationManager3d (const Handle(Graphic3d_StructureManager)& aStructureManager):myStructureManager(aStructureManager) {} - -Standard_Boolean PrsMgr_PresentationManager3d::Is3D() const -{return Standard_True;} - -Handle(PrsMgr_Presentation) PrsMgr_PresentationManager3d::newPresentation (const Handle(PrsMgr_PresentableObject) & aPresentableObject) { - - return new PrsMgr_Presentation3d(this,aPresentableObject); -} - -void PrsMgr_PresentationManager3d::Connect(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Handle(PrsMgr_PresentableObject)& anOtherObject, const Standard_Integer aMode, const Standard_Integer anOtherMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); - } - if (!HasPresentation(anOtherObject,anOtherMode)){ - AddPresentation(anOtherObject,anOtherMode); - } - CastPresentation(aPresentableObject,aMode)->Connect(CastPresentation(anOtherObject,aMode)); -} - -//======================================================================= -//function : Transform -//purpose : -//======================================================================= -void PrsMgr_PresentationManager3d::Transform(const Handle(PrsMgr_PresentableObject)& aPresentableObject,const Handle(Geom_Transformation)& aTransformation, const Standard_Integer aMode) { -CastPresentation(aPresentableObject,aMode)->Transform(aTransformation); -} - -//======================================================================= -//function : Place -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::Place(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Quantity_Length X,const Quantity_Length Y,const Quantity_Length Z,const Standard_Integer aMode) { - CastPresentation(aPresentableObject,aMode)->Place(X,Y,Z); -} - -//======================================================================= -//function : Multiply -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::Multiply(const Handle(PrsMgr_PresentableObject)& aPresentableObject,const Handle(Geom_Transformation)& aTransformation, const Standard_Integer aMode) { - CastPresentation(aPresentableObject,aMode)->Multiply(aTransformation); -} - -//======================================================================= -//function : Move -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::Move(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Quantity_Length X,const Quantity_Length Y,const Quantity_Length Z,const Standard_Integer aMode) { - CastPresentation(aPresentableObject,aMode)->Move(X,Y,Z); -} - -//======================================================================= -//function : Color -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::Color(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Quantity_NameOfColor aColor, const Standard_Integer aMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); - } - else if(Presentation(aPresentableObject,aMode)->MustBeUpdated()){ - Update(aPresentableObject,aMode); - } - CastPresentation(aPresentableObject,aMode)->Color(aColor); - - if(myImmediateMode) - Add(aPresentableObject,aMode); - -} - -//======================================================================= -//function : BoundBox -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::BoundBox(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); - } - else if(Presentation(aPresentableObject,aMode)->MustBeUpdated()){ - Update(aPresentableObject,aMode); - } - CastPresentation(aPresentableObject,aMode)->BoundBox(); -} -//======================================================================= -//function : SetShadingAspect -//purpose : -//======================================================================= - -//POP pour K4L -void PrsMgr_PresentationManager3d::SetShadingAspect(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Quantity_NameOfColor aColor, const Graphic3d_NameOfMaterial aMaterial, const Standard_Integer aMode) { -//void PrsMgr_PresentationManager3d::SetShadingAspect(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Quantity_NameOfColor aColor, const Graphic3d_NameOfPhysicalMaterial aMaterial, const Standard_Integer aMode) { - - Handle(Prs3d_ShadingAspect) sa = new Prs3d_ShadingAspect; - sa->SetColor(aColor); - sa->SetMaterial(aMaterial); - SetShadingAspect(aPresentableObject,sa,aMode); -} - -void PrsMgr_PresentationManager3d::SetShadingAspect(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Handle(Prs3d_ShadingAspect)& aShadingAspect, const Standard_Integer aMode) { - - if (HasPresentation(aPresentableObject,aMode)){ - CastPresentation(aPresentableObject,aMode)->SetShadingAspect(aShadingAspect); - } -} - - -//======================================================================= -//function : CastPresentation -//purpose : -//======================================================================= - -Handle(PrsMgr_Presentation3d) PrsMgr_PresentationManager3d::CastPresentation(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) const { - return Handle(PrsMgr_Presentation3d)::DownCast(Presentation(aPresentableObject,aMode)); -} - - - -//======================================================================= -//function : BeginDraw -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::BeginDraw() -{ - PrsMgr_PresentationManager::BeginDraw(); - myStrList.Clear(); -} - -//======================================================================= -//function : EndDraw -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager3d::EndDraw(const Handle(V3d_View)& theView, const Standard_Boolean DoubleBuffer) -{ - if (!theView->TransientManagerBeginDraw (DoubleBuffer, Standard_True)) - { - myImmediateMode = Standard_False; - return; - } - if(myImmediateList.IsEmpty() && myStrList.IsEmpty()) { - Visual3d_TransientManager::EndDraw(); - myImmediateMode = Standard_False; - return; - } - TColStd_ListIteratorOfListOfTransient it(myImmediateList); - Handle(PrsMgr_Presentation3d) P3d; - for (; it.More(); it.Next()) { - P3d = *((Handle(PrsMgr_Presentation3d)*)&(it.Value())); - Visual3d_TransientManager::DrawStructure(P3d->Presentation()); - } - - Handle(Standard_Transient) Tr; - for(it.Initialize(myStrList);it.More();it.Next()){ - Tr = it.Value(); - Visual3d_TransientManager::DrawStructure(*((Handle(Prs3d_Presentation)*)&Tr)); - } - - Visual3d_TransientManager::EndDraw(); - myImmediateMode = Standard_False; - -} - -//======================================================================= -//function : Add -//purpose : -//======================================================================= -void PrsMgr_PresentationManager3d::AddToImmediateList(const Handle(Prs3d_Presentation)& P){ - myStrList.Append(P); -} diff --git a/src/PrsMgr/PrsMgr_PresentationManager3d.lxx b/src/PrsMgr/PrsMgr_PresentationManager3d.lxx deleted file mode 100644 index ab274bef04..0000000000 --- a/src/PrsMgr/PrsMgr_PresentationManager3d.lxx +++ /dev/null @@ -1,19 +0,0 @@ -// Created on: 1998-08-20 -// Created by: Robert COUBLANC -// Copyright (c) 1998-1999 Matra Datavision -// 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. - -inline const Handle(Graphic3d_StructureManager)& PrsMgr_PresentationManager3d::StructureManager () const { - return myStructureManager; -} diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index 218783109b..9072875e5c 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,7 @@ #include #include +#include #include #include #include @@ -61,9 +61,9 @@ #include #include #include +#include #include - static Standard_Integer StdSel_NumberOfFreeEdges (const Handle(Poly_Triangulation)& Trg) { Standard_Integer nFree = 0; @@ -196,15 +196,14 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPix, { SetClipping (theView->GetClipPlanes()); UpdateProj (theView); + Standard_Real aPnt3d[3]; + theView->Convert (theXPix, theYPix, + aPnt3d[0], aPnt3d[1], aPnt3d[2]); - Standard_Real aXr3d = 0.0; - Standard_Real aYr3d = 0.0; - Standard_Real aZr3d = 0.0; - gp_Pnt2d aP2d; - theView->Convert (theXPix, theYPix, aXr3d, aYr3d, aZr3d); - myProjector->Project (gp_Pnt (aXr3d, aYr3d, aZr3d), aP2d); + gp_Pnt2d aPnt2d; + myProjector->Project (gp_Pnt (aPnt3d[0], aPnt3d[1], aPnt3d[2]), aPnt2d); - InitSelect (aP2d.X(), aP2d.Y()); + InitSelect (aPnt2d.X(), aPnt2d.Y()); } //======================================================================= @@ -373,15 +372,7 @@ void StdSelect_ViewerSelector3d::DisplayAreas (const Handle(V3d_View)& theView) myareagroup->Structure()->SetDisplayPriority (10); myareagroup->Structure()->Display(); - if (theView->TransientManagerBeginDraw()) - { - Visual3d_TransientManager::DrawStructure (mystruct); - Visual3d_TransientManager::EndDraw(); - } - else - { - theView->Update(); - } + theView->Update(); } //======================================================================= @@ -397,16 +388,7 @@ void StdSelect_ViewerSelector3d::ClearAreas (const Handle(V3d_View)& theView) myareagroup->Clear(); - if (theView.IsNull()) - { - return; - } - - if (theView->TransientManagerBeginDraw()) - { - Visual3d_TransientManager::EndDraw(); - } - else + if (!theView.IsNull()) { theView->Update(); } @@ -588,15 +570,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theVi mysensgroup->Structure()->SetDisplayPriority (10); mystruct->Display(); - if (theView->TransientManagerBeginDraw()) - { - Visual3d_TransientManager::DrawStructure (mystruct); - Visual3d_TransientManager::EndDraw(); - } - else if (!theView.IsNull()) - { - theView->Update(); - } + theView->Update(); } //======================================================================= @@ -617,14 +591,7 @@ void StdSelect_ViewerSelector3d::ClearSensitive (const Handle(V3d_View)& theView return; } - if (theView->TransientManagerBeginDraw()) - { - Visual3d_TransientManager::EndDraw(); - } - else - { - theView->Update(); - } + theView->Update(); } //======================================================================= @@ -661,15 +628,8 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(SelectMgr_Select mystruct->SetDisplayPriority (10); mystruct->Display(); - if (theView->TransientManagerBeginDraw()) - { - Visual3d_TransientManager::DrawStructure (mystruct); - Visual3d_TransientManager::EndDraw(); - } - else if(!theView.IsNull()) - { - theView->Update(); - } + + theView->Update(); } //======================================================================= @@ -702,15 +662,7 @@ void StdSelect_ViewerSelector3d::DisplayAreas (const Handle(SelectMgr_Selection) mystruct->SetDisplayPriority (10); mystruct->Display(); - if(theView->TransientManagerBeginDraw()) - { - Visual3d_TransientManager::DrawStructure (mystruct); - Visual3d_TransientManager::EndDraw(); - } - else - { - theView->Update(); - } + theView->Update(); } //======================================================================= diff --git a/src/V3d/V3d_View.cdl b/src/V3d/V3d_View.cdl index d989d5dd25..fab492e139 100644 --- a/src/V3d/V3d_View.cdl +++ b/src/V3d/V3d_View.cdl @@ -123,7 +123,6 @@ uses Coordinate from V3d, Array2OfReal from TColStd, ViewerPointer from V3d, - TransientManager from Visual3d, TypeOfTriedronEcho from Aspect, TypeOfTriedronPosition from Aspect, RenderingContext from Aspect, @@ -205,6 +204,14 @@ is -- Must be called if the view is shown. -- (Ex: DeIconification ) . + RedrawImmediate ( me ); + ---Level: Public + ---Purpose: Updates layer of immediate presentations. + + Invalidate ( me ); + ---Level: Public + ---Purpose: Invalidates view content but does not redraw it. + Redraw ( me ;x,y,width,height: Integer from Standard); ---Level: Public ---Purpose: Redisplays the view area after esxposure. @@ -1030,18 +1037,19 @@ is -- in the reference frame of the view corresponding -- to the intersection with the projection plane -- of the eye/view point vector and display the grid marker. - -- Warning: When the grid is not active the result is identical - -- to the above Convert() method. - -- How to use : + -- Warning: When the grid is not active the result is identical to the above Convert() method. + -- How to use: -- 1) Enable the grid echo display -- myViewer->SetGridEcho(Standard_True); - -- 2) When application receive a move event : + -- 2) When application receive a move event: -- 2.1) Check if any object is detected -- if( myInteractiveContext->MoveTo(x,y) == AIS_SOD_Nothing ) { -- 2.2) Check if the grid is active -- if( myViewer->Grid()->IsActive() ) { -- 2.3) Display the grid echo and gets the grid point -- myView->ConvertToGrid(x,y,X,Y,Z); + -- myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (X,Y,Z)); + -- myView->RedrawImmediate(); -- 2.4) Else this is the standard case -- } else myView->Convert(x,y,X,Y,Z); raises UnMapped from V3d; @@ -1343,42 +1351,6 @@ is ImmediateUpdate (me) is static protected; ---Purpose: - ----------------------------------------- - ---Category: TransientManager methods - ----------------------------------------- - - TransientManagerBeginDraw(me; DoubleBuffer: Boolean = Standard_False; - RetainMode : Boolean = Standard_False) - ---Level: Public - ---Purpose: Begins any graphics in the view - -- Redraw any structured graphics in the back buffer before - -- if is TRUE. - -- Restore the front buffer from the back before - -- if is FALSE. - -- if is TRUE. - -- the graphic managed itself exposure,resizing ... - -- if is FALSE. - -- the application must managed itself exposure,resizing ... - -- - returns Boolean from Standard; - - TransientManagerClearDraw(me); - ---Level: Public - ---Purpose: Clear all transient graphics in the view - - - TransientManagerBeginAddDraw(me) - ---Level: Public - ---Purpose: Begins any add graphics in the view - -- Redraw any structured graphics in the back buffer before - -- the application must managed itself exposure,resizing ... - -- Warning: Returns TRUE if transient drawing is enabled in - -- the associated view. - -- Returns FALSE ,if nothing works because something - -- is wrong for the transient principle : - -- - returns Boolean from Standard; - SetComputedMode ( me : mutable; aMode : Boolean from Standard ) is static; ---Level: Advanced diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index 9215239869..51bd7aec27 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -116,7 +116,6 @@ To solve the problem (for lack of a better solution) I make 2 passes. #include #include -#include #include #include #include @@ -415,6 +414,30 @@ void V3d_View::Redraw() const if( MyView->IsDefined() ) MyView->Redraw() ; } +//============================================================================= +//function : RedrawImmediate +//purpose : +//============================================================================= +void V3d_View::RedrawImmediate() const +{ + if (MyView->IsDefined()) + { + MyView->RedrawImmediate(); + } +} + +//============================================================================= +//function : Invalidate +//purpose : +//============================================================================= +void V3d_View::Invalidate() const +{ + if (MyView->IsDefined()) + { + MyView->Invalidate(); + } +} + //============================================================================= //function : Redraw //purpose : @@ -2974,37 +2997,6 @@ V3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const return V3d_TypeOfBackfacingModel(MyView -> BackFacingModel ()); } -//============================================================================= -//function : TransientManagerBeginDraw -//purpose : -//============================================================================= -Standard_Boolean V3d_View::TransientManagerBeginDraw(const Standard_Boolean DoubleBuffer,const Standard_Boolean RetainMode) const -{ - return Visual3d_TransientManager::BeginDraw(MyView,DoubleBuffer,RetainMode); -} - -//============================================================================= -//function : TransientManagerClearDraw -//purpose : -//============================================================================= -void V3d_View::TransientManagerClearDraw() const -{ - Visual3d_TransientManager::ClearDraw(MyView); -} - -//============================================================================= -//function : TransientManagerBeginAddDraw -//purpose : -//============================================================================= -Standard_Boolean V3d_View::TransientManagerBeginAddDraw() const -{ - return Visual3d_TransientManager::BeginAddDraw(MyView); -} - -//============================================================================= -//function : Init -//purpose : -//============================================================================= void V3d_View::Init() { myComputedMode = MyViewer->ComputedMode(); @@ -3131,7 +3123,14 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage, } } + // render immediate structures into back buffer rather than front + Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver()); + const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False); + + const Standard_Boolean toAutoUpdate = myImmediateUpdate; + myImmediateUpdate = Standard_False; AutoZFit(); + myImmediateUpdate = toAutoUpdate; if (theToKeepAspect) { @@ -3144,9 +3143,6 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage, MyLayerMgr->Compute(); } - // render immediate structures into back buffer rather than front - Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver()); - const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False); Redraw(); if (!aDriver.IsNull()) diff --git a/src/V3d/V3d_View_4.cxx b/src/V3d/V3d_View_4.cxx index b770e553a7..5062485d4c 100644 --- a/src/V3d/V3d_View_4.cxx +++ b/src/V3d/V3d_View_4.cxx @@ -11,32 +11,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -/*********************************************************************** - - FONCTION : - ---------- - Classe V3d_View : - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - 16-08-98 : CAL ; S3892. Ajout grilles 3d. - 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1) - 21-09-98 : CAL ; Activation de l'echo que si CSF_GraphicEcho est definie. - 22-09-98 : BGN ; S3989 (anciennement S3819) - TypeOfTriedron* from Aspect (pas V3d) - 02.15.100 : JR : Clutter - 28/05/02 : VSV: ZBUFFER mode of Trihedron - -************************************************************************/ - -#define IMP240100 //GG -// -> In Compute() method call MyViewer->ShowGridEcho() - - -/*----------------------------------------------------------------------*/ -/* - * Includes - */ #include #include @@ -48,14 +22,6 @@ #include #include -// For the echo of the chosen point -#include - -/*----------------------------------------------------------------------*/ -/* - * Constant - */ - #define MYEPSILON1 0.0001 // Comparison with 0.0 #define MYEPSILON2 M_PI / 180. // Delta between 2 angles @@ -176,9 +142,6 @@ Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const // are perpendicular to MYEPSILON2 close radians if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) { NewPoint.SetCoord (X1, Y1, Z1); -#ifdef IMP240100 - MyViewer->ShowGridEcho(this,NewPoint); -#endif //IMP240100 return NewPoint; } @@ -279,9 +242,6 @@ Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const NewPoint.SetCoord (aResult.X(), aResult.Y(), aResult.Z()); } -#ifdef IMP240100 - MyViewer->ShowGridEcho(this,NewPoint); -#endif //IMP240100 return NewPoint; } diff --git a/src/V3d/V3d_Viewer.cdl b/src/V3d/V3d_Viewer.cdl index 673966e96d..86f759bfb8 100644 --- a/src/V3d/V3d_Viewer.cdl +++ b/src/V3d/V3d_Viewer.cdl @@ -151,6 +151,14 @@ is -- all the views of the Viewer are exposed, as for -- example in a global DeIconification. + RedrawImmediate ( me ); + ---Level: Public + ---Purpose: Updates layer of immediate presentations. + + Invalidate ( me ); + ---Level: Public + ---Purpose: Invalidates viewer content but does not redraw it. + Remove (me:mutable); ---Level: Public ---Purpose: Suppresses the Viewer. @@ -624,12 +632,17 @@ is IsActive(me; aView: View from V3d) returns Boolean from Standard is private; - ShowGridEcho(me : mutable; - aView: View from V3d; - aPoint: Vertex from Graphic3d) is private; + ShowGridEcho (me : mutable; + theView : View from V3d; + thePoint : Vertex from Graphic3d); ---Purpose: -- Display grid echo at requested point in the view. + HideGridEcho (me : mutable; + theView : View from V3d); + ---Purpose: + -- Temporarly hide grid echo. + AddZLayer ( me : mutable; theLayerId : in out Integer from Standard ) returns Boolean from Standard is static; @@ -708,6 +721,7 @@ fields myGridEchoStructure: Structure from Graphic3d; myGridEchoGroup: Group from Graphic3d; myGridEchoAspect : AspectMarker3d from Graphic3d; + myGridEchoLastVert : Vertex from Graphic3d; friends class View from V3d, diff --git a/src/V3d/V3d_Viewer.cxx b/src/V3d/V3d_Viewer.cxx index e8d182a187..6b43f0892e 100644 --- a/src/V3d/V3d_Viewer.cxx +++ b/src/V3d/V3d_Viewer.cxx @@ -11,32 +11,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -/*********************************************************************** - - FONCTION : - ---------- - Classe V3d_Viewer : - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - 00-09-92 : GG ; Creation. - 15-11-97 : FMN ; Ajout texture mapping - 02-02-98 : FMN ; Mise a niveau WNT - 23-02-98 : FMN ; Remplacement PI par Standard_PI - 16-07-98 : CAL ; S3892. Ajout grilles 3d. - -************************************************************************/ - -//GER61351 //GG_15/12/99 Adds SetDefaultBackgroundColor() and DefaultBackgroundColor() methods - -#define IMP240100 //GG -// Initalize grid echo fields - -/*----------------------------------------------------------------------*/ -/* - * Includes - */ - #include #include #include @@ -75,10 +49,9 @@ myComputedMode (theComputedMode), myDefaultComputedMode (theDefaultComputedMode), myPrivilegedPlane (gp_Ax3 (gp_Pnt (0.,0.,0), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.))), myDisplayPlane (Standard_False), -myDisplayPlaneLength (theViewSize) -#ifdef IMP240100 -,myGridEcho (Standard_True), myGridEchoStructure(), myGridEchoGroup() -#endif +myDisplayPlaneLength (theViewSize), +myGridEcho (Standard_True), +myGridEchoLastVert (ShortRealLast(), ShortRealLast(), ShortRealLast()) { MyViewer = new Visual3d_ViewManager (theDriver); // san (16/09/2010): It has been decided to turn depth test ON @@ -156,16 +129,26 @@ Standard_Boolean V3d_Viewer::DefaultComputedMode() const { return myDefaultComputedMode; } -void V3d_Viewer::Update() { - +void V3d_Viewer::Update() +{ MyViewer->Update(); } -void V3d_Viewer::Redraw()const { - +void V3d_Viewer::Redraw()const +{ MyViewer->Redraw(); } +void V3d_Viewer::RedrawImmediate() const +{ + MyViewer->RedrawImmediate(); +} + +void V3d_Viewer::Invalidate() const +{ + MyViewer->Invalidate(); +} + void V3d_Viewer::Remove() { MyViewer->Remove(); diff --git a/src/V3d/V3d_Viewer_4.cxx b/src/V3d/V3d_Viewer_4.cxx index 38591f2cac..4d1a1a1587 100644 --- a/src/V3d/V3d_Viewer_4.cxx +++ b/src/V3d/V3d_Viewer_4.cxx @@ -11,218 +11,317 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -/*********************************************************************** - - FONCTION : - ---------- - Classe V3d_Viewer : - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - 16-07-98 : CAL ; S3892. Ajout grilles 3d. - 22-09-98 : CAL ; Erreur de compilation sur WNT dans V3d_Viewer_4.cxx. - -************************************************************************/ - -#define IMP200100 //GG -// -> Add GridDrawMode() method. -// -> Compute the case Aspect_TDM_None -// in ActivateGrid(..) - -#define IMP240100 //GG -// -> Add SetGridEcho() & GridEcho() methods -// -> Add ShowGridEcho() private method. - -#define OCC281 //SAV added new field to store grid echo aspect - -/*----------------------------------------------------------------------*/ -/* - * Includes - */ #include -/*----------------------------------------------------------------------*/ - -Handle(Aspect_Grid) V3d_Viewer::Grid () const { - - if (myGridType == Aspect_GT_Circular) - return myCGrid; - else if (myGridType == Aspect_GT_Rectangular) - return myRGrid; - else - return myRGrid; +#include +#include + +// ======================================================================= +// function : Grid +// purpose : +// ======================================================================= +Handle(Aspect_Grid) V3d_Viewer::Grid() const +{ + switch (myGridType) + { + case Aspect_GT_Circular: return myCGrid; + case Aspect_GT_Rectangular: return myRGrid; + } + return myRGrid; } -Aspect_GridType V3d_Viewer::GridType () const { - - return myGridType; +// ======================================================================= +// function : GridType +// purpose : +// ======================================================================= +Aspect_GridType V3d_Viewer::GridType() const +{ + return myGridType; } -#ifdef IMP200100 -Aspect_GridDrawMode V3d_Viewer::GridDrawMode () const { - - return Grid()->DrawMode(); +// ======================================================================= +// function : GridDrawMode +// purpose : +// ======================================================================= +Aspect_GridDrawMode V3d_Viewer::GridDrawMode() const +{ + return Grid()->DrawMode(); } -#endif -void V3d_Viewer::ActivateGrid (const Aspect_GridType aType, const Aspect_GridDrawMode aMode) { - - Grid ()->Erase (); - myGridType = aType; - Grid ()->SetDrawMode (aMode); -#ifdef IMP200100 - if( aMode != Aspect_GDM_None ) Grid ()->Display (); -#else - Grid ()->Display (); -#endif - Grid ()->Activate (); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) { - ActiveView ()->SetGrid (myPrivilegedPlane, Grid ()); -#ifndef IMP200100 //Do nothing more than the previous Grid()->Activate() - ActiveView ()->SetGridActivity (Standard_True); -#endif - } - Update (); +// ======================================================================= +// function : ActivateGrid +// purpose : +// ======================================================================= +void V3d_Viewer::ActivateGrid (const Aspect_GridType theType, + const Aspect_GridDrawMode theMode) +{ + Grid()->Erase(); + myGridType = theType; + Grid()->SetDrawMode (theMode); + if (theMode != Aspect_GDM_None) + { + Grid()->Display(); + } + Grid()->Activate(); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->SetGrid (myPrivilegedPlane, Grid()); + } + Update(); } -void V3d_Viewer::DeactivateGrid () { - - Grid ()->Erase (); - myGridType = Aspect_GT_Rectangular; - Grid ()->Deactivate (); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) { - ActiveView ()->SetGridActivity (Standard_False); - } - Update (); +// ======================================================================= +// function : DeactivateGrid +// purpose : +// ======================================================================= +void V3d_Viewer::DeactivateGrid() +{ + Grid()->Erase(); + myGridType = Aspect_GT_Rectangular; + Grid()->Deactivate(); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->SetGridActivity (Standard_False); + if (myGridEcho + && !myGridEchoStructure.IsNull()) + { + ActiveView()->View()->EraseImmediate (myGridEchoStructure); + } + } + Update(); } -Standard_Boolean V3d_Viewer::IsActive () const { - - return Grid ()->IsActive (); +// ======================================================================= +// function : IsActive +// purpose : +// ======================================================================= +Standard_Boolean V3d_Viewer::IsActive() const +{ + return Grid()->IsActive(); } -void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theXStep, Quantity_Length& theYStep, Quantity_PlaneAngle& theRotationAngle) const { +// ======================================================================= +// function : RectangularGridValues +// purpose : +// ======================================================================= +void V3d_Viewer::RectangularGridValues (Quantity_Length& theXOrigin, + Quantity_Length& theYOrigin, + Quantity_Length& theXStep, + Quantity_Length& theYStep, + Quantity_PlaneAngle& theRotationAngle) const +{ + theXOrigin = myRGrid->XOrigin(); + theYOrigin = myRGrid->YOrigin(); + theXStep = myRGrid->XStep(); + theYStep = myRGrid->YStep(); + theRotationAngle = myRGrid->RotationAngle(); +} - theXOrigin = myRGrid->XOrigin (); - theYOrigin = myRGrid->YOrigin (); - theXStep = myRGrid->XStep (); - theYStep = myRGrid->YStep (); - theRotationAngle = myRGrid->RotationAngle (); +// ======================================================================= +// function : SetRectangularGridValues +// purpose : +// ======================================================================= +void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, + const Quantity_Length theYOrigin, + const Quantity_Length theXStep, + const Quantity_Length theYStep, + const Quantity_PlaneAngle theRotationAngle) +{ + myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->SetGrid (myPrivilegedPlane, myRGrid); + } + Update(); } -void V3d_Viewer::SetRectangularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theXStep, const Quantity_Length theYStep, const Quantity_PlaneAngle theRotationAngle) { +// ======================================================================= +// function : CircularGridValues +// purpose : +// ======================================================================= +void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, + Quantity_Length& theYOrigin, + Quantity_Length& theRadiusStep, + Standard_Integer& theDivisionNumber, + Quantity_PlaneAngle& theRotationAngle) const +{ + theXOrigin = myCGrid->XOrigin(); + theYOrigin = myCGrid->YOrigin(); + theRadiusStep = myCGrid->RadiusStep(); + theDivisionNumber = myCGrid->DivisionNumber(); + theRotationAngle = myCGrid->RotationAngle(); +} - myRGrid->SetGridValues - (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) - ActiveView ()->SetGrid (myPrivilegedPlane, myRGrid); - Update (); +// ======================================================================= +// function : SetCircularGridValues +// purpose : +// ======================================================================= +void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, + const Quantity_Length theYOrigin, + const Quantity_Length theRadiusStep, + const Standard_Integer theDivisionNumber, + const Quantity_PlaneAngle theRotationAngle) +{ + myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep, + theDivisionNumber, theRotationAngle); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->SetGrid (myPrivilegedPlane, myCGrid); + } + Update(); } -void V3d_Viewer::CircularGridValues (Quantity_Length& theXOrigin, Quantity_Length& theYOrigin, Quantity_Length& theRadiusStep, Standard_Integer& theDivisionNumber, Quantity_PlaneAngle& theRotationAngle) const { +// ======================================================================= +// function : RectangularGridGraphicValues +// purpose : +// ======================================================================= +void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, + Quantity_Length& theYSize, + Quantity_Length& theOffSet) const +{ + myRGrid->GraphicValues (theXSize, theYSize, theOffSet); +} - theXOrigin = myCGrid->XOrigin (); - theYOrigin = myCGrid->YOrigin (); - theRadiusStep = myCGrid->RadiusStep (); - theDivisionNumber = myCGrid->DivisionNumber (); - theRotationAngle = myCGrid->RotationAngle (); +// ======================================================================= +// function : SetRectangularGridGraphicValues +// purpose : +// ======================================================================= +void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, + const Quantity_Length theYSize, + const Quantity_Length theOffSet) +{ + myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->SetGridGraphicValues (myRGrid); + } + Update(); } -void V3d_Viewer::SetCircularGridValues (const Quantity_Length theXOrigin, const Quantity_Length theYOrigin, const Quantity_Length theRadiusStep, const Standard_Integer theDivisionNumber, const Quantity_PlaneAngle theRotationAngle) { +// ======================================================================= +// function : CircularGridGraphicValues +// purpose : +// ======================================================================= +void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, + Quantity_Length& theOffSet) const +{ + myCGrid->GraphicValues (theRadius, theOffSet); +} - myCGrid->SetGridValues - (theXOrigin, theYOrigin, theRadiusStep, - theDivisionNumber, theRotationAngle); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) - ActiveView ()->SetGrid (myPrivilegedPlane, myCGrid); - Update (); +// ======================================================================= +// function : SetCircularGridGraphicValues +// purpose : +// ======================================================================= +void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, + const Quantity_Length theOffSet) +{ + myCGrid->SetGraphicValues (theRadius, theOffSet); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->SetGridGraphicValues (myCGrid); + } + Update(); } -void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const { +// ======================================================================= +// function : SetGridEcho +// purpose : +// ======================================================================= +void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid) +{ + if (myGridEcho == theToShowGrid) + { + return; + } + + myGridEcho = theToShowGrid; + if (theToShowGrid + || myGridEchoStructure.IsNull()) + { + return; + } - myRGrid->GraphicValues (theXSize, theYSize, theOffSet); + for (InitActiveViews(); MoreActiveViews(); NextActiveViews()) + { + ActiveView()->View()->EraseImmediate (myGridEchoStructure); + } } -void V3d_Viewer::SetRectangularGridGraphicValues (const Quantity_Length theXSize, const Quantity_Length theYSize, const Quantity_Length theOffSet) { +// ======================================================================= +// function : SetGridEcho +// purpose : +// ======================================================================= +void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker) +{ + if (myGridEchoStructure.IsNull()) + { + myGridEchoStructure = new Graphic3d_Structure (Viewer()); + myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure); + } - myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) - ActiveView ()->SetGridGraphicValues (myRGrid); - Update (); + myGridEchoAspect = theMarker; + myGridEchoGroup->SetPrimitivesAspect (theMarker); } -void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const { - - myCGrid->GraphicValues (theRadius, theOffSet); +// ======================================================================= +// function : GridEcho +// purpose : +// ======================================================================= +Standard_Boolean V3d_Viewer::GridEcho() const +{ + return myGridEcho; } -void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) { +// ======================================================================= +// function : ShowGridEcho +// purpose : +// ======================================================================= +void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView, + const Graphic3d_Vertex& theVertex) +{ + if (!myGridEcho) + { + return; + } - myCGrid->SetGraphicValues (theRadius, theOffSet); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) - ActiveView ()->SetGridGraphicValues (myCGrid); - Update (); -} + if (myGridEchoStructure.IsNull()) + { + myGridEchoStructure = new Graphic3d_Structure (Viewer()); + myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure); -#ifdef IMP240100 -void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) { + myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0); + myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect); + } - myGridEcho = showGrid; -} + if (theVertex.X() == myGridEchoLastVert.X() + && theVertex.Y() == myGridEchoLastVert.Y() + && theVertex.Z() == myGridEchoLastVert.Z()) + { + return; + } -void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) { - if( myGridEchoStructure.IsNull() ) { - myGridEchoStructure = new Graphic3d_Structure(Viewer()); - myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure); - } -#ifdef OCC281 - myGridEchoAspect = aMarker; -#endif - myGridEchoGroup->SetPrimitivesAspect (aMarker); -} + myGridEchoLastVert = theVertex; + myGridEchoGroup->Clear(); + myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect); -Standard_Boolean V3d_Viewer::GridEcho() const { + Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); + anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z()); + myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints); - return myGridEcho; + theView->View()->DisplayImmediate (myGridEchoStructure, Standard_True); } -#include -#include -void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView, - const Graphic3d_Vertex& aVertex ) { - if( myGridEcho ) { - if( myGridEchoStructure.IsNull() ) { - myGridEchoStructure = new Graphic3d_Structure(Viewer()); - myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure); -#ifdef OCC281 - myGridEchoAspect = new Graphic3d_AspectMarker3d( Aspect_TOM_STAR, - Quantity_Color( Quantity_NOC_GRAY90 ), - 3.0 ); - myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect ); -#else - Handle(Graphic3d_AspectMarker3d) markerAttrib = - new Graphic3d_AspectMarker3d(Aspect_TOM_STAR, - Quantity_Color(Quantity_NOC_GRAY90),3.0); - myGridEchoGroup->SetPrimitivesAspect (markerAttrib); -#endif - } - - static Graphic3d_Vertex lastVertex; - if( aVertex.Distance(lastVertex) != 0.0 ) { - lastVertex = aVertex; - myGridEchoGroup->Clear(); -#ifdef OCC281 - myGridEchoGroup->SetPrimitivesAspect( myGridEchoAspect ); -#endif - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints->AddVertex (aVertex.X(), aVertex.Y(), aVertex.Z()); - myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints); - - Visual3d_TransientManager::BeginDraw( - aView->View(), Standard_False, Standard_False); - Visual3d_TransientManager::DrawStructure (myGridEchoStructure); - Visual3d_TransientManager::EndDraw (Standard_True); - } +// ======================================================================= +// function : HideGridEcho +// purpose : +// ======================================================================= +void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView) +{ + if (myGridEchoStructure.IsNull()) + { + return; } + + myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast()); + theView->View()->EraseImmediate (myGridEchoStructure); } -#endif diff --git a/src/ViewerTest/ViewerTest_EventManager.cxx b/src/ViewerTest/ViewerTest_EventManager.cxx index 1760960093..d9543e88b2 100644 --- a/src/ViewerTest/ViewerTest_EventManager.cxx +++ b/src/ViewerTest/ViewerTest_EventManager.cxx @@ -16,101 +16,169 @@ #include #include +#include #include //======================================================================= //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 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 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(); } diff --git a/src/Visual3d/Visual3d.cdl b/src/Visual3d/Visual3d.cdl index 50d988ba69..fff61bfbb0 100644 --- a/src/Visual3d/Visual3d.cdl +++ b/src/Visual3d/Visual3d.cdl @@ -95,9 +95,6 @@ is exception ZClippingDefinitionError inherits OutOfRange; ---Category: The exceptions - exception TransientDefinitionError inherits OutOfRange; - ---Category: The exceptions - exception LayerDefinitionError inherits OutOfRange; ---Category: The exceptions @@ -259,10 +256,6 @@ is ---Purpose: 3D Visualiser ---Category: The classes - class TransientManager; - ---Purpose: 3D Transient Visualiser - ---Category: The classes - class Layer; ---Purpose: 2D Layer ---Category: The classes diff --git a/src/Visual3d/Visual3d_TransientManager.cdl b/src/Visual3d/Visual3d_TransientManager.cdl deleted file mode 100644 index 39d414ce14..0000000000 --- a/src/Visual3d/Visual3d_TransientManager.cdl +++ /dev/null @@ -1,194 +0,0 @@ --- Created on: 1995-10-10 --- Created by: GG --- Copyright (c) 1995-1999 Matra Datavision --- 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. - -class TransientManager from Visual3d inherits TShared - - ---Version: - - ---Purpose: This class allows to manage transient graphics - -- above one View. - -- A simple way to drawn something very quicly above - -- a complex scene (Hilighting,Sketching,...) - -- All transient graphics will be erased at the next - -- View::BeginDraw(). - -- If RetainMode is active, - -- All transient graphics will be kept at the - -- next View::Update(),Redraw(). The transient graphics - -- is stored by this object and graphic library, the - -- graphic managed itself exposure,resizing,... - -- The method View::ClearDraw() is necessary to erase - -- all transient graphics. - -- If RetainMode is deactivate, - -- All transient graphics will be erased at the - -- next View::Update(),Redraw(). - -- Remember that nothing is stored by this object and - -- graphic library,the application must managed itself - -- exposure,resizing,... - -- If double_buffering is activate, - -- all graphics are drawn in the back buffer and flushed - -- in the front buffer at the end of drawing but nothing - -- is done for to separate transient from structured - -- graphics,the only way to regenerate the structured - -- view is to Redraw() the view. - -- If double_buffering is deactivate, - -- the back buffer is preserved and used for restoring - -- the front buffer at begin drawing time.I recommend - -- to use the second way (without DB) if you want - -- to preserve the graphics and the performances! - - -uses - - Array2OfReal from TColStd, - - ExtendedString from TCollection, - - PlaneAngle from Quantity, - - Structure from Graphic3d, - AspectLine3d from Graphic3d, - AspectFillArea3d from Graphic3d, - AspectText3d from Graphic3d, - AspectMarker3d from Graphic3d, - TypeOfComposition from Graphic3d, - TextPath from Graphic3d, - HorizontalTextAlignment from Graphic3d, - VerticalTextAlignment from Graphic3d, - - View from Visual3d - -raises - TransientDefinitionError from Visual3d, - TransformError from Graphic3d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create returns mutable TransientManager from Visual3d; - ---Purpose: Creates a TransientManager . - ---Category: Constructors - - ------------------------ - -- Category: Destructors - ------------------------ - - Destroy (me : mutable); - ---Level: Public - ---Purpose: Suppress the TransientManager . - ---Category: Destructors - ---C++: alias ~ - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - BeginDraw (myclass; - aView : View from Visual3d; - DoubleBuffer: Boolean = Standard_False; - RetainMode: Boolean = Standard_False) - returns Boolean from Standard - ---Level: Public - ---Purpose: Begins any graphics in the view - -- Redraw any structured graphics in the back buffer before - -- if is TRUE. - -- Restore the front buffer from the back before - -- if is FALSE. - -- if is TRUE. - -- the graphic managed itself exposure,resizing ... - -- if is FALSE. - -- the application must managed itself exposure,resizing ... - -- - -- Warning: Returns TRUE if transient drawing is enabled in - -- the associated view. - -- Returns FALSE ,if nothing works because something - -- is wrong for the transient principle : - -- Immediat mode is not implemented depending of the - -- graphic library used. - -- MBX,PIXMAP double buffering don't works depending of - -- the graphic board and the visual of the window supporting - -- the view. - -- Warning: No default attributes - -- Raises TransientDefinitionError from Visual3d; - -- if Drawing is already opened. - -- or the associated view is not mapped on a window. - raises TransientDefinitionError from Visual3d; - - EndDraw (myclass; - Synchronize: Boolean = Standard_False) - ---Level: Public - ---Purpose: Flush all graphics to the front buffer. - -- Synchronize graphics to the screen if is - -- TRUE (make becarefull to the performances!). - -- Raises TransientDefinitionError from Visual3d; - -- if Drawing is not opened. - raises TransientDefinitionError from Visual3d; - - ClearDraw (myclass; aView : View from Visual3d; - aFlush : Boolean from Standard = Standard_True) - ---Level: Public - ---Purpose: Clear all transient graphics in the view - --- updates a scene if = true - -- Raises TransientDefinitionError from Visual3d; - -- if Drawing is already opened. - -- or the associated view is not mapped on a window. - raises TransientDefinitionError from Visual3d; - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - BeginAddDraw (myclass; - aView : View from Visual3d) - returns Boolean from Standard - ---Level: Public - ---Purpose: Begins any add graphics in the view - -- the application must managed itself exposure,resizing ... - -- - -- Warning: Returns TRUE if transient drawing is enabled in - -- the associated view. - -- Returns FALSE ,if nothing works because something - -- is wrong for the transient principle : - -- Immediat mode is not implemented depending of the - -- graphic library used. - -- MBX,PIXMAP double buffering don't works depending of - -- the graphic board and the visual of the window supporting - -- the view. - -- Warning: No default attributes - -- Raises TransientDefinitionError from Visual3d; - -- if Drawing is already opened. - -- or the associated view is not mapped on a window. - raises TransientDefinitionError from Visual3d; - - EndAddDraw (myclass) - ---Purpose: Flush all add graphics to the front buffer. - -- Raises TransientDefinitionError from Visual3d; - -- if Drawing is not opened. - raises TransientDefinitionError from Visual3d; - - --------------------------------------- - -- Category: Graphic definition methods - --------------------------------------- - - DrawStructure (myclass; - AStructure : Structure from Graphic3d) - ---Purpose: Drawn the structure . - -- Raises TransientDefinitionError from Visual3d; - -- if Drawing is not opened. - raises TransientDefinitionError from Visual3d; - -end TransientManager from Visual3d; diff --git a/src/Visual3d/Visual3d_TransientManager.cxx b/src/Visual3d/Visual3d_TransientManager.cxx deleted file mode 100644 index cbb0a974c7..0000000000 --- a/src/Visual3d/Visual3d_TransientManager.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// 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. - -/*********************************************************************** - - FONCTION : - ---------- - Classe Visual3d_TransientManager : - - - Declaration des variables specifiques au mode transient. - - Une vue est definie par : - - un ViewManager - - un ContextView - - un ViewMapping - - une ViewOrientation - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - October 1995 : GG : Creation. - 20-11-97 : CAL ; Disparition de la dependance avec math - 01-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED. - 18-12-97 : FMN ; Ajout mode AJOUT. - 27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM) - 10-06-98 : CAL ; Modification de la signature de DrawStructure. - 25-09-98 : CAL ; Mise a jour de theCView = *(CALL_DEF_VIEW *)AView->CView (); - 10-11-98 : CAL ; PRO16361. theCView dans ClearImmediatMode. - 30-11-98 : FMN ; S4069 : Textes toujours visibles. - 01-12-98 : CAL ; S4062. Ajout des layers. - -************************************************************************/ - -// for the class -#include -#include -#include - -#include -#include -#include -#include -#include - -enum TypeOfImmediat { - Immediat_None, - Immediat_Transient, - Immediat_Ajout -}; - -//-Global data definitions -static Standard_Integer theDrawingState = 0; -static TypeOfImmediat theImmediatState = Immediat_None; - -static Handle(Graphic3d_GraphicDriver)& _theGraphicDriver() { - static Handle(Graphic3d_GraphicDriver) theGraphicDriver; -return theGraphicDriver; -} -#define theGraphicDriver _theGraphicDriver() - -static Graphic3d_CView& _theCView() { - static Graphic3d_CView theCView; -return theCView; -} -#define theCView _theCView() - -static Aspect_CLayer2d UnderCLayer; -static Aspect_CLayer2d OverCLayer; - -// -//-Constructors -// - -Visual3d_TransientManager::Visual3d_TransientManager () { -} - -// -//-Destructors -// - -void Visual3d_TransientManager::Destroy () { -} - -//-Methods, in order - -Standard_Boolean Visual3d_TransientManager::BeginDraw (const Handle(Visual3d_View)& AView, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode) { - - if (theDrawingState > 0) { - Graphic3d_CView* pview = (Graphic3d_CView*) AView->CView(); - if( theImmediatState == Immediat_Transient && - pview->ViewId == theCView.ViewId ) { - theDrawingState++; - return theDrawingState; - } else - Visual3d_TransientDefinitionError::Raise - ("Drawing in progress !"); - } - -Handle(Visual3d_Layer) OverLayer = AView->OverLayer (); -Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer (); - OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; - theCView = *(Graphic3d_CView* )AView->CView (); - - if (! UnderLayer.IsNull ()){ - UnderCLayer = UnderLayer->CLayer(); - theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer; - } - if (! OverLayer.IsNull ()){ - OverCLayer = OverLayer->CLayer(); - theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer; - } - - // Begin rendering - theGraphicDriver = AView->GraphicDriver(); - - if (theGraphicDriver->BeginImmediatMode - (theCView, UnderCLayer, OverCLayer, DoubleBuffer, RetainMode)) - { - theDrawingState++; - theImmediatState = Immediat_Transient; - } - - return theDrawingState; -} - -void Visual3d_TransientManager::EndDraw (const Standard_Boolean Synchronize) { - - if( theDrawingState <= 0 ) - Visual3d_TransientDefinitionError::Raise ("Drawing not started !"); - - theDrawingState--; - if( theDrawingState > 0 ) return; - theImmediatState = Immediat_None; - - // Flush all graphics - theGraphicDriver->EndImmediatMode(Synchronize); -} - -void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView, - const Standard_Boolean aFlush) -{ - if (theDrawingState > 0) - Visual3d_TransientDefinitionError::Raise - ("Drawing in progress !"); - - // Begin rendering - theCView = *(Graphic3d_CView* )AView->CView (); - if (!AView->UnderLayer().IsNull()) { - UnderCLayer = AView->UnderLayer()->CLayer(); - theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer; - } - if (!AView->OverLayer().IsNull()) { - OverCLayer = AView->OverLayer()->CLayer(); - theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer; - } - - theGraphicDriver = AView->GraphicDriver(); - theGraphicDriver->ClearImmediatMode (theCView, aFlush); -} - -// -//-Mode Ajout -// - -Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_View)& AView) -{ - if (theDrawingState > 0) - { - Graphic3d_CView* pview = (Graphic3d_CView* )AView->CView(); - if( theImmediatState == Immediat_Ajout && - pview->ViewId == theCView.ViewId ) { - theDrawingState++; - return theDrawingState; - } else - Visual3d_TransientDefinitionError::Raise - ("Drawing in progress !"); - } - - // Begin rendering - theCView = *(Graphic3d_CView* )AView->CView (); - if (!AView->UnderLayer().IsNull()) { - UnderCLayer = AView->UnderLayer()->CLayer(); - theCView.ptrUnderLayer = (CALL_DEF_LAYER *) &UnderCLayer; - } - if (!AView->OverLayer().IsNull()) { - OverCLayer = AView->OverLayer()->CLayer(); - theCView.ptrOverLayer = (CALL_DEF_LAYER *) &OverCLayer; - } - - theGraphicDriver = AView->GraphicDriver (); - - if (theGraphicDriver->BeginAddMode (theCView)) - { - theDrawingState++; - theImmediatState = Immediat_Ajout; - } - - return theDrawingState; -} - -void Visual3d_TransientManager::EndAddDraw () { - - if( theDrawingState <= 0 ) - Visual3d_TransientDefinitionError::Raise ("Drawing not started !"); - - theDrawingState--; - if( theDrawingState > 0 ) return; - theImmediatState = Immediat_None; - // Flush all graphics - theGraphicDriver->EndAddMode(); -} - - -// -//-Graphic definition methods -// - -void Visual3d_TransientManager::DrawStructure (const Handle(Graphic3d_Structure)& theStructure) -{ - if (!theDrawingState) - { - Visual3d_TransientDefinitionError::Raise ("Drawing is not open !"); - } - else if (!theStructure->IsEmpty()) - { - theGraphicDriver->DrawStructure (*theStructure->CStructure()); - } -} diff --git a/src/Visual3d/Visual3d_View.cdl b/src/Visual3d/Visual3d_View.cdl index 60085e8058..63f9192cee 100644 --- a/src/Visual3d/Visual3d_View.cdl +++ b/src/Visual3d/Visual3d_View.cdl @@ -172,6 +172,11 @@ is ---Purpose: Updates screen in all cases. ---Category: Methods to modify the class definition + RedrawImmediate ( me : mutable ) + is static; + ---Level: Public + ---Purpose: Updates layer of immediate presentations. + Redraw ( me : mutable; x,y,width,height: Integer from Standard ) is static; ---Level: Public @@ -187,6 +192,18 @@ is ---Purpose: Updates screen in all cases. ---Category: Methods to modify the class definition + RedrawImmediate ( me : mutable; + theUnderLayer : Layer from Visual3d; + theOverLayer : Layer from Visual3d ) + is static; + ---Level: Public + ---Purpose: Updates layer of immediate presentations. + + Invalidate ( me : mutable ) + is static; + ---Level: Public + ---Purpose: Invalidates view content but does not redraw it. + Redraw ( me : mutable; AnUnderLayer : Layer from Visual3d; AnOverLayer : Layer from Visual3d; @@ -839,6 +856,30 @@ is ---Purpose: Display the structure to the view . ---Category: Private methods + DisplayImmediate ( me : mutable; + theStructure : Structure from Graphic3d; + theIsSingleView : Boolean from Standard = Standard_True) + returns Boolean from Standard + is static; + ---Level: Internal + ---Purpose: Add structure to the list of immediate presentations. + -- @return true if structure has not been registered in this view + + EraseImmediate ( me : mutable; + theStructure : Structure from Graphic3d ) + returns Boolean from Standard + is static; + ---Level: Internal + ---Purpose: Removes the structure from the list of immediate presentations. + -- @return true if structure has been registered in view + + ClearImmediate ( me : mutable ) + returns Boolean from Standard + is static; + ---Level: Internal + ---Purpose: Clears list of immediate presentations. + -- @return true if list was not empty + Erase ( me : mutable; AStructure : Structure from Graphic3d ) is static private; @@ -1138,52 +1179,53 @@ is fields -- --- Classe : Visual3d_View +-- Classe: Visual3d_View -- --- Purpose : Declaration of the variables specific to views. +-- Purpose: Declaration of the variables specific to views. -- --- Reminder : A view is defined by: --- - a ViewManager --- - a ContextView +-- Reminder: A view is defined by: +-- - a ViewManager +-- - a ContextView + + -- the associated C structure + MyCView : CView from Graphic3d; - -- the associated C structure - MyCView : CView from Graphic3d; + -- the context of the view : Aliasing, Depth-Cueing, Lights ... + MyContext : ContextView from Visual3d; - -- the context of the view : Aliasing, Depth-Cueing, Lights ... - MyContext : ContextView from Visual3d; + -- the associated window + MyWindow : Window from Aspect; - -- the associated window - MyWindow : Window from Aspect; + -- association Structure_COMPUTE and Structure_Computed + MyTOCOMPUTESequence : SequenceOfStructure from Graphic3d; + MyCOMPUTEDSequence : SequenceOfStructure from Graphic3d; - -- association Structure_COMPUTE and Structure_Computed - MyTOCOMPUTESequence : SequenceOfStructure from Graphic3d; - MyCOMPUTEDSequence : SequenceOfStructure from Graphic3d; + -- the graphic driver used + MyGraphicDriver : GraphicDriver from Graphic3d; - -- the graphic driver used - MyGraphicDriver : GraphicDriver from Graphic3d; + -- the background of the associated window + MyBackground : Background from Aspect; - -- the background of the associated window - MyBackground : Background from Aspect; + -- the gradient background of the associated window + MyGradientBackground : GradientBackground from Aspect; - -- the gradient background of the associated window - MyGradientBackground : GradientBackground from Aspect; + -- the displayed structures in the view + MyDisplayedStructure : MapOfStructure from Graphic3d; - -- the displayed structures in the view - MyDisplayedStructure : MapOfStructure from Graphic3d; + myImmediateStructures : MapOfStructure from Graphic3d; - -- the ViewManager associated with the view --- MyPtrViewManager : Address from Standard; - MyPtrViewManager : ViewManagerPtr from Visual3d; + -- the ViewManager associated with the view + MyPtrViewManager : ViewManagerPtr from Visual3d; - -- Booleans - MyCBitFields : CBitFields8 from Graphic3d; + -- Booleans + MyCBitFields : CBitFields8 from Graphic3d; - MyGTrihedron : CGraduatedTrihedron from Graphic3d; + MyGTrihedron : CGraduatedTrihedron from Graphic3d; - myDefaultCamera : Camera_Handle from Graphic3d; + myDefaultCamera : Camera_Handle from Graphic3d; friends - class ViewManager from Visual3d + class ViewManager from Visual3d end View; diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index 305b948824..658997b3ce 100644 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -136,8 +136,8 @@ #include #include #include +#include #include - #include #include @@ -1021,130 +1021,115 @@ void Visual3d_View::Deactivate () { } -void Visual3d_View::Redraw () { - - Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ()); - +void Visual3d_View::Redraw() +{ + Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0); } -void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) { - - Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height); +void Visual3d_View::Redraw (const Standard_Integer theX, + const Standard_Integer theY, + const Standard_Integer theWidth, + const Standard_Integer theHeight) +{ + Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), + theX, theY, theWidth, theHeight); } -void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) { - - if (IsDeleted ()) return; - - if ((! IsDefined ()) || (! IsActive ())) return; +void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer, + const Handle(Visual3d_Layer)& theOverLayer) +{ + Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0); +} - if (! MyWindow->IsMapped ()) return; +void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer, + const Handle(Visual3d_Layer)& theOverLayer, + const Standard_Integer theX, + const Standard_Integer theY, + const Standard_Integer theWidth, + const Standard_Integer theHeight) +{ + if (IsDeleted() + || !IsDefined() + || !IsActive() + || !MyWindow->IsMapped()) + { + return; + } - // san - 14/04/2004 - set up Z buffer state before redrawing - // If the activation/desactivation of ZBuffer should be automatic - // depending on the presence or absence of facets. - if (MyViewManager->ZBufferAuto ()) { - Standard_Boolean BContainsFacet = ContainsFacet (); - Standard_Boolean BZBuffer = ZBufferIsActivated (); - // If the view contains facets - // and if ZBuffer is not active - if (BContainsFacet && ! BZBuffer) - SetZBufferActivity (1); - // If the view contains only facets - // and if ZBuffer is active - if (! BContainsFacet && BZBuffer) - SetZBufferActivity (0); - } + if (MyGraphicDriver->IsDeviceLost()) + { + MyViewManager->RecomputeStructures(); + MyViewManager->RecomputeStructures (myImmediateStructures); + MyGraphicDriver->ResetDeviceLostFlag(); + } - Aspect_CLayer2d OverCLayer; - Aspect_CLayer2d UnderCLayer; - OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; - if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer (); - if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer (); - MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer); + // set up Z buffer state before redrawing + if (MyViewManager->ZBufferAuto()) + { + const Standard_Boolean hasFacet = ContainsFacet(); + const Standard_Boolean hasZBuffer = ZBufferIsActivated(); + // if the view contains facets and if ZBuffer is not active + if (hasFacet && !hasZBuffer) + { + SetZBufferActivity (1); + } + // if the view contains only facets and if ZBuffer is active + if (!hasFacet && hasZBuffer) + { + SetZBufferActivity (0); + } + } + Aspect_CLayer2d anOverCLayer, anUnderCLayer; + anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL; + if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer(); + if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer(); + MyGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight); } -void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) { - - if (IsDeleted ()) return; - - if ((! IsDefined ()) || (! IsActive ())) return; - - if (! MyWindow->IsMapped ()) return; +void Visual3d_View::RedrawImmediate() +{ + RedrawImmediate (MyViewManager->UnderLayer(), MyViewManager->OverLayer()); +} - // san - 14/04/2004 - set up Z buffer state before redrawing - // If activation/desactivation of ZBuffer should be automatic - // depending on the presence or absence of facets. - if (MyViewManager->ZBufferAuto ()) { - Standard_Boolean BContainsFacet = ContainsFacet (); - Standard_Boolean BZBuffer = ZBufferIsActivated (); - // If the view contains facets - // and if ZBuffer is not active - if (BContainsFacet && ! BZBuffer) - SetZBufferActivity (1); - // If the view contains only facets - // and if ZBuffer is active - if (! BContainsFacet && BZBuffer) - SetZBufferActivity (0); - } +void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer, + const Handle(Visual3d_Layer)& theOverLayer) +{ + if (IsDeleted() + || !IsDefined() + || !IsActive() + || !MyWindow->IsMapped()) + { + return; + } - Aspect_CLayer2d OverCLayer; - Aspect_CLayer2d UnderCLayer; - OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; - if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer (); - if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer (); - MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height); + Aspect_CLayer2d anOverCLayer, anUnderCLayer; + anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL; + if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer(); + if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer(); + MyGraphicDriver->RedrawImmediate (MyCView, anUnderCLayer, anOverCLayer); +} +void Visual3d_View::Invalidate() +{ + MyGraphicDriver->Invalidate (MyCView); } -void Visual3d_View::Update () +void Visual3d_View::Update() { IsInitialized = Standard_True; - Compute (); - Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ()); + Redraw (MyViewManager->UnderLayer(), MyViewManager->OverLayer(), 0, 0, 0, 0); } -void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) { - - if (IsDeleted ()) return; - - if ((! IsDefined ()) || (! IsActive ())) return; - - if (! MyWindow->IsMapped ()) return; - - if (MyGraphicDriver->IsDeviceLost()) - { - MyViewManager->RecomputeStructures(); - MyGraphicDriver->ResetDeviceLostFlag(); - } - - // If activation/desactivation of ZBuffer should be automatic - // depending on the presence or absence of facets. - if (MyViewManager->ZBufferAuto ()) { -Standard_Boolean BContainsFacet = ContainsFacet (); -Standard_Boolean BZBuffer = ZBufferIsActivated (); - // If the view contains facets - // and if ZBuffer is not active - if (BContainsFacet && ! BZBuffer) - SetZBufferActivity (1); - // If the view does not contain facets - // and if ZBuffer is active - if (! BContainsFacet && BZBuffer) - SetZBufferActivity (0); - } - -Aspect_CLayer2d OverCLayer; -Aspect_CLayer2d UnderCLayer; - OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL; - if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer (); - if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer (); - //OSD::SetSignal (Standard_False); - MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer); - //OSD::SetSignal (Standard_True); +void Visual3d_View::Update (const Handle(Visual3d_Layer)& theUnderLayer, + const Handle(Visual3d_Layer)& theOverLayer) +{ + IsInitialized = Standard_True; + Compute (); + Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0); } Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const { @@ -1311,6 +1296,56 @@ Standard_Integer IndexD = IsComputed (ADaughter); } +Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure, + const Standard_Boolean theIsSingleView) +{ + if (!myImmediateStructures.Add (theStructure)) + { + return Standard_False; + } + + if (theIsSingleView) + { + Handle_Visual3d_HSetOfView aViews = MyViewManager->DefinedView(); + for (Visual3d_SetIteratorOfSetOfView aViewIter (aViews->Set()); aViewIter.More(); aViewIter.Next()) + { + if (aViewIter.Value().Access() != this) + { + aViewIter.Value()->EraseImmediate (theStructure); + } + } + } + + MyGraphicDriver->DisplayImmediateStructure (MyCView, *theStructure->CStructure()); + return Standard_True; +} + +Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure) +{ + const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure); + if (isErased) + { + MyGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure()); + } + + return isErased; +} + +Standard_Boolean Visual3d_View::ClearImmediate() +{ + if (myImmediateStructures.IsEmpty()) + { + return Standard_False; + } + + for (Graphic3d_MapIteratorOfMapOfStructure anIter (myImmediateStructures); anIter.More(); anIter.Next()) + { + MyGraphicDriver->EraseImmediateStructure (MyCView, *anIter.Key()->CStructure()); + } + myImmediateStructures.Clear(); + return Standard_True; +} + void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) { Display (AStructure, MyViewManager->UpdateMode ()); diff --git a/src/Visual3d/Visual3d_ViewManager.cdl b/src/Visual3d/Visual3d_ViewManager.cdl index 5520739f19..3f8829253c 100644 --- a/src/Visual3d/Visual3d_ViewManager.cdl +++ b/src/Visual3d/Visual3d_ViewManager.cdl @@ -88,11 +88,21 @@ is -- visualiser . ---Category: Methods to modify the class definition - Redraw ( me ) - is static; - ---Level: Public - ---Purpose: Redraws all the displayed structures. - ---Category: Methods to modify the class definition + Redraw ( me ) + is static; + ---Level: Public + ---Purpose: Redraws all the displayed structures. + ---Category: Methods to modify the class definition + + RedrawImmediate ( me ) + is static; + ---Level: Public + ---Purpose: Updates layer of immediate presentations. + + Invalidate ( me ) + is static; + ---Level: Public + ---Purpose: Invalidates viewer content but does not redraw it. Remove ( me : mutable ) is static; @@ -100,13 +110,11 @@ is ---Purpose: Deletes and erases the 3D visualiser . ---Category: Methods to modify the class definition - Update ( me ) - is redefined static; - ---Level: Public - ---Purpose: Updates screen in function of modifications of - -- the structures. - -- Category: Methods to modify the class definition - -- Warning: Not necessary if the update mode is TOU_ASAP. + Update ( me ) + is redefined static; + ---Level: Public + ---Purpose: Updates screen in function of modifications of the structures. + -- Category: Methods to modify the class definition ---------------------------- -- Category: Inquire methods diff --git a/src/Visual3d/Visual3d_ViewManager.cxx b/src/Visual3d/Visual3d_ViewManager.cxx index 4a9a3a1a23..0c797036e2 100644 --- a/src/Visual3d/Visual3d_ViewManager.cxx +++ b/src/Visual3d/Visual3d_ViewManager.cxx @@ -388,61 +388,76 @@ void Visual3d_ViewManager::UnHighlight (const Handle(Graphic3d_Structure)& AStru } -void Visual3d_ViewManager::Redraw () const { - -Standard_Integer MaxDx, MaxDy; -Standard_Integer Dx, Dy; - MaxDx = MaxDy = IntegerFirst (); - - // - // Redraw all activated views - // - Standard_Integer j = MyDefinedView.Extent (); - if (j == 0) return; - Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView); - - if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ()) { - while (MyIterator.More ()) { - (MyIterator.Value ())->Window ()->Size (Dx, Dy); - if (Dx > MaxDx) MaxDx = Dx; - if (Dy > MaxDy) MaxDy = Dy; - - // MyIterator.Next () is located on the next view - MyIterator.Next (); - } - if (! MyUnderLayer.IsNull ()) - MyUnderLayer->SetViewport (MaxDx, MaxDy); - if (! MyOverLayer.IsNull ()) - MyOverLayer->SetViewport (MaxDx, MaxDy); - } +void Visual3d_ViewManager::Redraw() const +{ + // redraw all activated views + if (MyDefinedView.Extent() == 0) + { + return; + } - if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ()) - MyIterator.Initialize (MyDefinedView); - while (MyIterator.More ()) { - (MyIterator.Value ())->Redraw (MyUnderLayer, MyOverLayer); + if (!MyUnderLayer.IsNull() || !MyOverLayer.IsNull()) + { + Standard_Integer aWidth = 0, aHeight = 0; + Standard_Integer aWidthMax = 0; + Standard_Integer aHeightMax = 0; + for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView); + anIter.More(); anIter.Next()) + { + anIter.Value()->Window()->Size (aWidth, aHeight); + aWidthMax = Max (aWidthMax, aWidth); + aHeightMax = Max (aHeightMax, aWidth); + } + if (!MyUnderLayer.IsNull()) + { + MyUnderLayer->SetViewport (aWidthMax, aHeightMax); + } + if (!MyOverLayer.IsNull()) + { + MyOverLayer->SetViewport (aWidthMax, aHeightMax); + } + } - // MyIterator.Next () is located on the next view - MyIterator.Next (); + for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView); + anIter.More(); anIter.Next()) + { + anIter.Value()->Redraw (MyUnderLayer, MyOverLayer); } - } -void Visual3d_ViewManager::Update () const { +void Visual3d_ViewManager::Update() const +{ + Redraw(); +} - // - // Update all activated views - // - Standard_Integer j = MyDefinedView.Extent (); - if (j == 0) return; - Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView); +void Visual3d_ViewManager::RedrawImmediate() const +{ + if (MyDefinedView.Extent() == 0) + { + return; + } - while (MyIterator.More ()) { - (MyIterator.Value ())->Update (MyUnderLayer, MyOverLayer); + // update all activated views + for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView); + anIter.More(); anIter.Next()) + { + anIter.Value()->RedrawImmediate (MyUnderLayer, MyOverLayer); + } +} - // MyIterator.Next () is located on the next view - MyIterator.Next (); - } +void Visual3d_ViewManager::Invalidate() const +{ + if (MyDefinedView.Extent() == 0) + { + return; + } + // update all activated views + for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView); + anIter.More(); anIter.Next()) + { + anIter.Value()->Invalidate(); + } } Handle(Visual3d_HSetOfView) Visual3d_ViewManager::ActivatedView () const { -- 2.20.1