1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-08 18:40:55 +03:00

0024637: Visualization - clean up implementation of rendering in immediate mode

Remove unused flag "DoubleBuf".
Remove Visual3d_TransientManager "class" (functionality moved to PrsMgr_PresentationManager).
Remove unused "Add" immediate mode.

V3d_View class - remove methods ::TransientManagerBeginDraw(), ::TransientManagerClearDraw(), ::TransientManagerBeginAddDraw().
Add method ::RedrawImmediate() to redraw only immediate presentations.

OpenGl_GraphicDriver - add methods ::DisplayImmediateStructure(), ::EraseImmediateStructure(), ::RedrawImmediate().
OpenGl_View - manage list of immediate structures.
OpenGl_Workspace - automate rendering workflow of immediate + persistent layers.

Merge PrsMgr_PresentationManager3d class into PrsMgr_PresentationManager.
Mark PrsMgr_PresentationManager3d as alias to PrsMgr_PresentationManager to simplify porting.

Prs3d_Presentation - remove unused field myStruct.
Prs3d_PresentationShadow - shadow link to existing presentation with custom attributes.
Graphic3d_Structure::Highlight() - do not register undisplayed structure in structure manager.

AIS_InteractiveContext, AIS_LocalContext add flag to prevent view update into methods
::MoveTo(), ::HilightNextDetected(), ::HilightPreviousDetected()
to allow update of customized immediate structures before redraw but after ::MoveTo().

Remove unused method AIS_InteractiveContext::Drag().

StdSelect_ViewerSelector3d do not user immediate mode in methods
::DisplayAreas(), ::ClearAreas(), ::ClearSensitive(), ::DisplaySensitive(),

GridEcho - update value in StdSelect_ViewerSelector3d::Pick() instead of V3d_View::Compute().
Do not use global variable for GridEcho vertex.
Redraw immediate mode not within GridEcho but at AIS_InteractiveContext, AIS_LocalContext layer.

V3d_View::ToPixMap() - disable autoupdate during FitAll.
Avoid Redraw() into FBO without ImmediateModeDrawToFront flag.

PrsMgr_PresentationManager stores list of temporary immediate presentations,
automatically cleared within BeginImmediateMode() call.
Methods with ambiguous names have been renamed
(new names now consistent with pre-existed method names in AIS_LocalContext class):
- BeginDraw -> BeginImmediateDraw
- EndDraw -> EndImmediateDraw
Remove now useless Remove() method (and ImmediateRemove() in AIS).

Visual3d_View now stores map of displayed immediate presentations.

ViewerTest_EventManager - eliminate double redraw in selection methods.

Fix warning
This commit is contained in:
kgv 2014-03-20 13:54:12 +04:00 committed by bugmaster
parent 01ca42b2c1
commit 679ecdeeac
60 changed files with 2773 additions and 3216 deletions

View File

@ -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 <anIObj> 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 <anIObj> 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 <anObject>
-- using the transient graphic space of the view <aView> in
-- immediat mode graphics.
---Warning: When <update> is TRUE, then the view is redrawn with ALL
-- transformed presentations.
-- When <zBuffer> is TRUE all transient graphic are drawn
-- using zbuffer activity.
-- Note that when <update> is TRUE the view is cleared and redrawn
-- and soforth the Z buffer is always activated therefore the <zBuffer>
-- 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

View File

@ -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 <AIS_GlobalStatus.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_Grid.hxx>
#include <V3d_Light.hxx>
#include <V3d_PositionalLight.hxx>
#include <V3d_SpotLight.hxx>
@ -52,10 +48,7 @@
#include <SelectMgr_Selection.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
#ifdef IMP150501
#include <Visual3d_TransientManager.hxx>
#include <Prs3d_Presentation.hxx>
#endif
#ifdef OCC9657
#include <AIS_MapOfInteractive.hxx>
@ -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);
// 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++)
{
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);
}
}
#endif
selector->Init();
if ( selector->More() )
// preliminaires
myLastPicked = myLastinMain;
myWasLastMain = Standard_True;
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
Standard_Boolean toUpdateViewer = Standard_False;
// allonzy
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)
{
if ( HasOpenedContext() )
Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
if (anOwner.IsNull()
|| !myFilters->IsOk (anOwner))
{
if ( !myFilters->IsOk( selector->OnePicked() ) )
return AIS_SOD_AllBad;
else
if ( !myLocalContexts( myCurLocalIndex )->Filter()->IsOk( selector->OnePicked() ) )
return AIS_SOD_AllBad;
continue;
}
// Does nothing if previously detected object is equal to the current one
if ( selector->OnePicked()->Selectable() == myLastPicked )
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
if (!Handle(AIS_Shape)::DownCast (anObj).IsNull())
{
myAISDetectedSeq.Append (anObj);
}
}
myMainSel->Init();
if (myMainSel->More())
{
// does nothing if previously detected object is equal to the current one
if (myMainSel->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

View File

@ -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()
//=======================================================================
//function : BeginImmediateDraw
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
{
if(HasOpenedContext())
return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw();
return Standard_False;
return HasOpenedContext()
&& myLocalContexts (myCurLocalIndex)->BeginImmediateDraw();
}
//=======================================================================
//function : ImmediateAdd
//purpose :
//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;
}
//=======================================================================
//function : ImmediateRemove
//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);
}

View File

@ -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;

View File

@ -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 <anIObj> 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.
ImmediateRemove (me:mutable;anIObj:InteractiveObject from AIS;aMode:Integer from Standard=0)
ClearImmediateDraw (me : mutable) is virtual;
---Purpose: Resets the transient list of presentations previously displayed in immediate mode.
ImmediateAdd (me : mutable;
theObj : InteractiveObject from AIS;
theMode : Integer from Standard = 0)
returns Boolean from Standard;
---Purpose: returns True if <anIObj> 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;

View File

@ -50,7 +50,6 @@
#include <AIS_Selection.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <Visual3d_TransientManager.hxx>
#include <Visual3d_View.hxx>
#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) {

View File

@ -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 <AIS_LocalContext.jxx>
@ -88,7 +79,6 @@
#include <Prs3d_ShadingAspect.hxx>
#include <AIS_LocalStatus.hxx>
#include <StdPrs_WFShape.hxx>
#include <Visual3d_TransientManager.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Group.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
@ -103,6 +93,7 @@
#include <Geom_Transformation.hxx>
#include <AIS_Selection.hxx>
#include <Aspect_Grid.hxx>
#ifdef IMP120701
#include <AIS_Shape.hxx>
#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
}
}
}
//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
}
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;
// 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 (aDetectedNb == 0 || myDetectedSeq.IsEmpty())
{
if (mylastindex != 0 && mylastindex <= myMapOfOwner.Extent())
{
Unhilight (myMapOfOwner (mylastindex), theView);
if (theToRedrawImmediate)
{
theView->RedrawImmediate();
}
}
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)
{
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
if (theView.IsNull())
{
myMainPM->BeginDraw();
Ownr->Unhilight(myMainPM,HM);
myMainPM->EndDraw(aview);
return;
}
myMainPM->ClearImmediateDraw();
const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
if (IsSelected (theOwner))
{
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,91 +1052,94 @@ 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);
// 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 (mylastindex && mylastindex <= myMapOfOwner.Extent()) {
const Handle(SelectMgr_EntityOwner)& LastOwnr = myMapOfOwner(mylastindex);
#ifdef BUC60863
Unhilight(LastOwnr,aview);
#else
if(!IsSelected(LastOwnr))
Unhilight(LastOwnr,aview);
#endif
}
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);*/
}
mylastindex = theNewIndex;
if (thePickOwner.IsNull())
{
if (theToRedrawImmediate)
{
theView->RedrawImmediate();
}
return;
}
if (mylastindex) mylastgood = mylastindex;
}
if (!myFilters->IsOk (thePickOwner))
{
if (mylastindex != 0)
{
mylastgood = mylastindex;
}
if (theToRedrawImmediate)
{
theView->RedrawImmediate();
}
return;
}
//=======================================================================================================
// 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);
}
if (myAutoHilight)
{
if (thePickOwner->State() <= 0
|| myCTX->ToHilightSelected())
{
Hilight (thePickOwner, theView);
}
if (theToRedrawImmediate)
{
theView->RedrawImmediate();
}
}
mylastindex = aNewIndex;
}
if (mylastindex)
{
mylastgood = mylastindex;
}
}
//=======================================================================
//function : HasDetectedShape
@ -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 Standard_False;
Standard_Integer L = myDetectedSeq.Length();
myCurDetected++;
if(myCurDetected>L)
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 (myDetectedSeq.IsEmpty())
{
return 0;
}
if(Normal_State)
ManageDetected(EO,V);
else
HilightTriangle(myCurDetected,V);
const Standard_Integer aLen = myDetectedSeq.Length();
if (++myCurDetected > aLen)
{
myCurDetected = 1;
}
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(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;
if (myDetectedSeq.IsEmpty())
{
return 0;
}
if (--myCurDetected < 1)
{
myCurDetected = 1;
}
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));
}
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)))
if (!IsValidIndex (mylastindex))
{
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);
#ifndef IMP300101
if(view->TransientManagerBeginDraw())
Visual3d_TransientManager::EndDraw();
#endif
if(view->TransientManagerBeginDraw()) {
Visual3d_TransientManager::DrawStructure(TriPrs);
Visual3d_TransientManager::EndDraw();
}
return Standard_False;
}
myMainPM->BeginImmediateDraw();
const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (mylastindex);
const Standard_Integer aHilightMode = anOwner->HasSelectable()
? GetHiMod (Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()))
: 0;
myMapOfOwner (mylastindex)->Unhilight (myMainPM, aHilightMode);
myMainPM->EndImmediateDraw (theView);
mylastindex = 0;
return Standard_True;
}
//=======================================================================

View File

@ -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,

View File

@ -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;

View File

@ -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
DisplayImmediateStructure ( me : mutable;
theCView : CView from Graphic3d;
theCStructure : CStructure from Graphic3d )
is deferred;
---Purpose: Display structure in immediate mode on top of general presentation
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
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

View File

@ -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 <AManager>.
-- 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

View File

@ -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();
}

View File

@ -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

View File

@ -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 );
}

View File

@ -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

View File

@ -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);

View File

@ -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)
{
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))
{
myImmediateWS = aCView->WS;
return Standard_True;
}
return Standard_False;
}
// =======================================================================
// function : ClearImmediatMode
// 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::DisplayImmediateStructure (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;
}
aCView->View->DisplayImmediateStructure (aStructure);
}
// =======================================================================
// function : EndImmediatMode
// function : EraseImmediateStructure
// purpose :
// =======================================================================
void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer )
void OpenGl_GraphicDriver::EraseImmediateStructure (const Graphic3d_CView& theCView,
const Graphic3d_CStructure& theCStructure)
{
if (!myImmediateWS.IsNull())
OpenGl_CView* aCView = (OpenGl_CView* )theCView.ptrView;
OpenGl_Structure* aStructure = (OpenGl_Structure* )&theCStructure;
if (aCView == NULL)
{
myImmediateWS->EndImmediatMode();
myImmediateWS.Nullify();
return;
}
aCView->View->EraseImmediateStructure (aStructure);
}
// =======================================================================
// function : Print
// purpose :

View File

@ -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<Standard_Integer, Handle(OpenGl_View)> myMapOfView;
NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)> myMapOfWS;
NCollection_DataMap<Standard_Integer, OpenGl_Structure*> myMapOfStructure;
Handle(OpenGl_Workspace) myImmediateWS;
mutable Handle(OpenGl_PrinterContext) myPrintContext;
OpenGl_UserDrawCallback_t myUserDrawCallback;
OpenGl_Text* myTempText; //!< variable for compatibility (drawing text in layers)

View File

@ -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()

View File

@ -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

View File

@ -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);
}

View File

@ -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; }

View File

@ -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 <theLayerId>
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

View File

@ -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 :

View File

@ -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 :

View File

@ -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;

View File

@ -26,11 +26,12 @@
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_Element.hxx>
#include <Graphic3d_TextureParams.hxx>
@ -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();
}
}

View File

@ -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<const OpenGl_Structure*> 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

View File

@ -38,8 +38,6 @@
#include <OpenGl_View.hxx>
#include <OpenGl_Display.hxx>
//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);
}
/*----------------------------------------------------------------------*/

View File

@ -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 <stdio.h>
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Structure.hxx>
#include <OpenGl_Workspace.hxx>
/*----------------------------------------------------------------------*/
/* 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);
}
}
}

View File

@ -5,3 +5,5 @@ Prs3d_WFShape.hxx
Prs3d_WFShape.cxx
Prs3d_DimensionUnits.hxx
Prs3d_DimensionUnits.cxx
Prs3d_PresentationShadow.hxx
Prs3d_PresentationShadow.cxx

View File

@ -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 <Init> 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 <Init> 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
myCurrentGroup : Group from Graphic3d;
friends
class Root from Prs3d
end Presentation;

View File

@ -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);
}
//=======================================================================

View File

@ -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 <Prs3d_PresentationShadow.hxx>
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)
{
//
}

View File

@ -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 <Prs3d_Presentation.hxx>
//! 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

1
src/PrsMgr/FILES Normal file
View File

@ -0,0 +1 @@
PrsMgr_ListOfPresentations.hxx

View File

@ -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;

View File

@ -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 <NCollection_List.hxx>
#include <Prs3d_Presentation.hxx>
typedef NCollection_List<Handle(Prs3d_Presentation)> PrsMgr_ListOfPresentations;
#endif // _PrsMgr_ListOfPresentations_H__

View File

@ -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;

View File

@ -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;
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.
Is3D(me) returns Boolean from Standard is deferred;
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;
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;
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; 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.
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; thePresentableObject: PresentableObject from PrsMgr;
theMode: Integer from Standard;
theValue: Boolean from Standard);
---Purpose: Sets the visibility of presentable object.
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; 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;
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;
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.
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;
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;
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.
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;
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.
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.
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.
BeginDraw(me: mutable) is virtual;
---Purpose: initializes the list of Prs to be displayed in transient mode
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;
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.
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;
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.
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;
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;
---Category: Immediate display methods.
IsImmediateModeOn(me) returns Boolean from Standard;
---C++: inline
---Purpose: Returns true if immediate (transient) mode is on.
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.
---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;
EndImmediateDraw (me : mutable;
theView : View from V3d);
---Purpose: Allows rapid drawing of the view theView by avoiding an update of the whole background.
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;
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.
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;
---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;

View File

@ -13,63 +13,88 @@
// commercial license or contractual agreement.
#include <PrsMgr_PresentationManager.ixx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Prs3d_PresentationShadow.hxx>
#include <PrsMgr_PresentableObject.hxx>
#include <PrsMgr_Presentation.hxx>
#include <PrsMgr_Presentations.hxx>
#include <PrsMgr_ModedPresentation.hxx>
#include <TColStd_ListIteratorOfListOfTransient.hxx>
#include <V3d_View.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_Layer.hxx>
PrsMgr_PresentationManager::PrsMgr_PresentationManager ():
myImmediateMode(Standard_False){}
void PrsMgr_PresentationManager::Display(
const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode)
// =======================================================================
// function : PrsMgr_PresentationManager
// purpose :
// =======================================================================
PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager)
: myStructureManager (theStructureManager),
myImmediateModeOn (0)
{
if (!HasPresentation(aPresentableObject,aMode)){
AddPresentation(aPresentableObject,aMode);
}
else if(Presentation(aPresentableObject,aMode)->MustBeUpdated()){
Update(aPresentableObject,aMode);
}
if(myImmediateMode)
Add(aPresentableObject,aMode);
else
Presentation(aPresentableObject,aMode)->Display();
//
}
void PrsMgr_PresentationManager::Erase(
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))
if (!HasPresentation (thePrsObj, theMode))
{
if(myImmediateMode)
{
Remove(aPresentableObject,aMode);
}
else
{
Presentation(aPresentableObject,aMode)->Erase();
}
AddPresentation (thePrsObj, theMode);
}
RemovePresentation (aPresentableObject,aMode);
Handle(PrsMgr_Presentation3d) aPrs = CastPresentation (thePrsObj, theMode);
if (aPrs->MustBeUpdated())
{
Update (thePrsObj, theMode);
}
if (myImmediateModeOn > 0)
{
AddToImmediateList (aPrs->Presentation());
}
else
{
aPrs->Display();
}
}
void PrsMgr_PresentationManager::Clear(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(myImmediateMode)
Remove(aPresentableObject,aMode);
else
Presentation(aPresentableObject,aMode)->Clear();}
if (HasPresentation (thePrsObj, theMode))
{
Presentation (thePrsObj, theMode)->Erase();
RemovePresentation (thePrsObj, theMode);
}
}
// =======================================================================
// function : Clear
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
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);
}
void PrsMgr_PresentationManager::Unhighlight(
const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode)
{
if (HasPresentation(aPresentableObject,aMode)){
Presentation(aPresentableObject,aMode)->Unhighlight();
if(myImmediateMode)
Remove(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::
SetDisplayPriority(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode,
const Standard_Integer theNewPrior) const
// =======================================================================
// function : Unhighlight
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
if (HasPresentation(aPresentableObject,aMode))
Presentation(aPresentableObject,aMode)->SetDisplayPriority(theNewPrior);
}
Standard_Integer PrsMgr_PresentationManager::
DisplayPriority(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode) const
{
if (HasPresentation(aPresentableObject,aMode))
return Presentation(aPresentableObject,aMode)->DisplayPriority();
return 0;
}
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;
}
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;
}
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);
}
if (HasPresentation (thePrsObj, theMode))
{
Presentation (thePrsObj, theMode)->Unhighlight();
}
}
void PrsMgr_PresentationManager::BeginDraw() {
myImmediateMode = Standard_True;
// =======================================================================
// 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);
}
}
// =======================================================================
// function : DisplayPriority
// purpose :
// =======================================================================
Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
return HasPresentation (thePrsObj, theMode)
? Presentation (thePrsObj, theMode)->DisplayPriority()
: 0;
}
// =======================================================================
// function : IsDisplayed
// purpose :
// =======================================================================
Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
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();
}
// =======================================================================
// function : Update
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Update (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (!HasPresentation(thePrsObj, theMode))
{
return;
}
Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
if (!aPrs.IsNull())
{
aPrs->Clear();
thePrsObj->Fill (this, aPrs, theMode);
aPrs->SetUpdateStatus (Standard_False);
}
}
// =======================================================================
// function : BeginImmediateDraw
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::BeginImmediateDraw()
{
if (++myImmediateModeOn > 1)
{
return;
}
ClearImmediateDraw();
}
// =======================================================================
// 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();
}
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;
}
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;
}
}
}
}
Standard_Boolean PrsMgr_PresentationManager::HasPresentation
(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode) const {
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;
}
Handle (PrsMgr_Presentation)
PrsMgr_PresentationManager::Presentation(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode) const
// =======================================================================
// function : EndImmediateDraw
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::EndImmediateDraw (const Handle(V3d_View)& theView)
{
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;
}
i++;
if (--myImmediateModeOn > 0)
{
return;
}
return P;
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::AddPresentation
(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode) {
Handle(PrsMgr_Presentation) P = newPresentation(aPresentableObject);
aPresentableObject->Presentations().Append(PrsMgr_ModedPresentation(P,aMode));
aPresentableObject->Fill(this,P,aMode);
// set layer index accordingly to object's presentations
Standard_Integer aZLayerId = GetZLayer (aPresentableObject);
if (aZLayerId >= 0)
P->SetZLayer (aZLayerId);
P->SetUpdateStatus(Standard_False);
}
void PrsMgr_PresentationManager::RemovePresentation(const Handle(PrsMgr_PresentableObject)& aPresentableObject,
const Standard_Integer aMode)
// =======================================================================
// function : AddToImmediateList
// purpose :
//=======================================================================
void PrsMgr_PresentationManager::AddToImmediateList (const Handle(Prs3d_Presentation)& thePrs)
{
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);
if (myImmediateModeOn < 1)
{
return;
}
for (PrsMgr_ListOfPresentations::Iterator anIter (myImmediateList); anIter.More(); anIter.Next())
{
if (anIter.Value() == thePrs)
{
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();
}
// =======================================================================
// 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);
// set layer index accordingly to object's presentations
const Standard_Integer aZLayerId = GetZLayer (thePrsObj);
if (aZLayerId >= 0)
{
aPrs->SetZLayer (aZLayerId);
}
aPrs->SetUpdateStatus (Standard_False);
}
// =======================================================================
// function : RemovePresentation
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
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;
}
i++;
}
}
//=======================================================================
//function : SetZLayer
//purpose :
//=======================================================================
void PrsMgr_PresentationManager::SetZLayer
(const Handle(PrsMgr_PresentableObject)& thePresentableObject,
const Standard_Integer theLayerId)
// =======================================================================
// function : SetZLayer
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theLayerId)
{
PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{
Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
if (aPrs->PresentationManager () == this)
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)& thePresentableObject) const
// =======================================================================
// function : GetZLayer
// purpose :
// =======================================================================
Standard_Integer PrsMgr_PresentationManager::GetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj) const
{
PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter)
{
Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
if (aPrs->PresentationManager () == this)
return aPrs->GetZLayer ();
Handle(PrsMgr_Presentation) aPrs = aPrsList.Value (aPrsIter).Presentation();
if (aPrs->PresentationManager() == this)
{
return aPrs->GetZLayer();
}
}
return -1;
}
// =======================================================================
// 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));
}
// =======================================================================
// 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);
}
// =======================================================================
// 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);
}
// =======================================================================
// 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);
}
// =======================================================================
// 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);
}
// =======================================================================
// function : Color
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Quantity_NameOfColor theColor,
const Standard_Integer theMode)
{
if (!HasPresentation (thePrsObj, theMode))
{
AddPresentation (thePrsObj, theMode);
}
Handle(PrsMgr_Presentation3d) aPrs = CastPresentation (thePrsObj, theMode);
if (aPrs->MustBeUpdated())
{
Update (thePrsObj, theMode);
}
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)
{
if (!HasPresentation (thePrsObject, theMode))
{
AddPresentation (thePrsObject, theMode);
}
else if (Presentation (thePrsObject, theMode)->MustBeUpdated())
{
Update (thePrsObject, theMode);
}
CastPresentation (thePrsObject, theMode)->BoundBox();
}
// =======================================================================
// 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);
}
// =======================================================================
// function : SetShadingAspect
// purpose :
// =======================================================================
void PrsMgr_PresentationManager::SetShadingAspect (const Handle(PrsMgr_PresentableObject)& thePrsObject,
const Handle(Prs3d_ShadingAspect)& theShadingAspect,
const Standard_Integer theMode)
{
if (HasPresentation (thePrsObject, theMode))
{
CastPresentation (thePrsObject, theMode)->SetShadingAspect (theShadingAspect);
}
}
// =======================================================================
// 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));
}

View File

@ -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;
}

View File

@ -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 <aPrs> 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;

View File

@ -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 <PrsMgr_PresentationManager3d.ixx>
#include <PrsMgr_Presentation3d.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Visual3d_TransientManager.hxx>
#include <V3d_View.hxx>
#include <TColStd_ListIteratorOfListOfTransient.hxx>
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);
}

View File

@ -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;
}

View File

@ -31,7 +31,6 @@
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <Visual3d_TransientManager.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
@ -49,6 +48,7 @@
#include <Select3D_ListIteratorOfListOfSensitiveTriangle.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation.hxx>
#include <Aspect_Grid.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
@ -61,9 +61,9 @@
#include <OSD_Environment.hxx>
#include <V3d.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
#include <TColgp_SequenceOfPnt.hxx>
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();
}
//=======================================================================

View File

@ -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 <aView>
-- Redraw any structured graphics in the back buffer before
-- if <DoubleBuffer> is TRUE.
-- Restore the front buffer from the back before
-- if <DoubleBuffer> is FALSE.
-- if <RetainMode> is TRUE.
-- the graphic managed itself exposure,resizing ...
-- if <RetainMode> 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 <aView>
TransientManagerBeginAddDraw(me)
---Level: Public
---Purpose: Begins any add graphics in the view <aView>
-- 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

View File

@ -116,7 +116,6 @@ To solve the problem (for lack of a better solution) I make 2 passes.
#include <Standard_ErrorHandler.hxx>
#include <Standard_DivideByZero.hxx>
#include <Visual3d_TransientManager.hxx>
#include <Visual3d_ViewManager.hxx>
#include <Visual3d_Light.hxx>
#include <Visual3d_Layer.hxx>
@ -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())

View File

@ -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 <V3d_View.jxx>
#include <TColStd_Array2OfReal.hxx>
@ -48,14 +22,6 @@
#include <V3d_RectangularGrid.hxx>
#include <V3d_CircularGrid.hxx>
// For the echo of the chosen point
#include <Visual3d_TransientManager.hxx>
/*----------------------------------------------------------------------*/
/*
* 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;
}

View File

@ -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,

View File

@ -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 <V3d.hxx>
#include <Visual3d_View.hxx>
#include <Visual3d_Light.hxx>
@ -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();

View File

@ -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 <V3d_Viewer.jxx>
/*----------------------------------------------------------------------*/
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Visual3d_View.hxx>
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;
// =======================================================================
// 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();
}
#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 : GridDrawMode
// purpose :
// =======================================================================
Aspect_GridDrawMode V3d_Viewer::GridDrawMode() const
{
return Grid()->DrawMode();
}
void V3d_Viewer::DeactivateGrid () {
Grid ()->Erase ();
myGridType = Aspect_GT_Rectangular;
Grid ()->Deactivate ();
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
ActiveView ()->SetGridActivity (Standard_False);
}
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();
}
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 {
theXOrigin = myRGrid->XOrigin ();
theYOrigin = myRGrid->YOrigin ();
theXStep = myRGrid->XStep ();
theYStep = myRGrid->YStep ();
theRotationAngle = myRGrid->RotationAngle ();
}
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::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 ();
}
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::RectangularGridGraphicValues (Quantity_Length& theXSize, Quantity_Length& theYSize, Quantity_Length& theOffSet) const {
myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}
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::CircularGridGraphicValues (Quantity_Length& theRadius, Quantity_Length& theOffSet) const {
myCGrid->GraphicValues (theRadius, theOffSet);
}
void V3d_Viewer::SetCircularGridGraphicValues (const Quantity_Length theRadius, const Quantity_Length theOffSet) {
myCGrid->SetGraphicValues (theRadius, theOffSet);
for (InitActiveViews (); MoreActiveViews (); NextActiveViews ())
ActiveView ()->SetGridGraphicValues (myCGrid);
Update ();
}
#ifdef IMP240100
void V3d_Viewer::SetGridEcho( const Standard_Boolean showGrid ) {
myGridEcho = showGrid;
}
void V3d_Viewer::SetGridEcho( const Handle(Graphic3d_AspectMarker3d)& aMarker ) {
if( myGridEchoStructure.IsNull() ) {
myGridEchoStructure = new Graphic3d_Structure(Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
// =======================================================================
// 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);
}
#ifdef OCC281
myGridEchoAspect = aMarker;
#endif
myGridEchoGroup->SetPrimitivesAspect (aMarker);
}
Update();
}
Standard_Boolean V3d_Viewer::GridEcho() const {
// =======================================================================
// function : IsActive
// purpose :
// =======================================================================
Standard_Boolean V3d_Viewer::IsActive() const
{
return Grid()->IsActive();
}
// =======================================================================
// 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();
}
// =======================================================================
// 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();
}
// =======================================================================
// 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();
}
// =======================================================================
// 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();
}
// =======================================================================
// function : RectangularGridGraphicValues
// purpose :
// =======================================================================
void V3d_Viewer::RectangularGridGraphicValues (Quantity_Length& theXSize,
Quantity_Length& theYSize,
Quantity_Length& theOffSet) const
{
myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
}
// =======================================================================
// 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();
}
// =======================================================================
// function : CircularGridGraphicValues
// purpose :
// =======================================================================
void V3d_Viewer::CircularGridGraphicValues (Quantity_Length& theRadius,
Quantity_Length& theOffSet) const
{
myCGrid->GraphicValues (theRadius, theOffSet);
}
// =======================================================================
// 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();
}
// =======================================================================
// function : SetGridEcho
// purpose :
// =======================================================================
void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid)
{
if (myGridEcho == theToShowGrid)
{
return;
}
myGridEcho = theToShowGrid;
if (theToShowGrid
|| myGridEchoStructure.IsNull())
{
return;
}
for (InitActiveViews(); MoreActiveViews(); NextActiveViews())
{
ActiveView()->View()->EraseImmediate (myGridEchoStructure);
}
}
// =======================================================================
// 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);
}
myGridEchoAspect = theMarker;
myGridEchoGroup->SetPrimitivesAspect (theMarker);
}
// =======================================================================
// function : GridEcho
// purpose :
// =======================================================================
Standard_Boolean V3d_Viewer::GridEcho() const
{
return myGridEcho;
}
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Visual3d_TransientManager.hxx>
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 : ShowGridEcho
// purpose :
// =======================================================================
void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView,
const Graphic3d_Vertex& theVertex)
{
if (!myGridEcho)
{
return;
}
if (myGridEchoStructure.IsNull())
{
myGridEchoStructure = new Graphic3d_Structure (Viewer());
myGridEchoGroup = new Graphic3d_Group (myGridEchoStructure);
myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0);
myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
}
if (theVertex.X() == myGridEchoLastVert.X()
&& theVertex.Y() == myGridEchoLastVert.Y()
&& theVertex.Z() == myGridEchoLastVert.Z())
{
return;
}
myGridEchoLastVert = theVertex;
myGridEchoGroup->Clear();
myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
theView->View()->DisplayImmediate (myGridEchoStructure, 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

View File

@ -16,101 +16,169 @@
#include <ViewerTest_EventManager.ixx>
#include <AIS_InteractiveContext.hxx>
#include <Aspect_Grid.hxx>
#include <NIS_View.hxx>
//=======================================================================
//function : ViewerTest_EventManager
//purpose :
//purpose :
//=======================================================================
ViewerTest_EventManager::ViewerTest_EventManager
(const Handle(V3d_View)& aView,
const Handle(AIS_InteractiveContext)& Ctx)
: myCtx (Ctx),
myView (aView),
myX (-1),
myY (-1)
ViewerTest_EventManager::ViewerTest_EventManager (const Handle(V3d_View)& theView,
const Handle(AIS_InteractiveContext)& theCtx)
: myCtx (theCtx),
myView (theView),
myX (-1),
myY (-1)
{}
//=======================================================================
//function : MoveTo
//purpose :
//purpose :
//=======================================================================
void ViewerTest_EventManager::MoveTo(const Standard_Integer XPix,
const Standard_Integer YPix)
void ViewerTest_EventManager::MoveTo (const Standard_Integer theXPix,
const Standard_Integer theYPix)
{
if(!myCtx.IsNull() && !myView.IsNull())
myCtx->MoveTo(XPix,YPix,myView);
myX = XPix;
myY = YPix;
Standard_Real aPnt3d[3] = {0.0, 0.0, 0.0};
if (!myCtx.IsNull()
&& !myView.IsNull())
{
const Standard_Boolean toEchoGrid = myView->Viewer()->Grid()->IsActive()
&& myView->Viewer()->GridEcho();
switch (myCtx->MoveTo (theXPix, theYPix, myView, !toEchoGrid))
{
case AIS_SOD_Nothing:
{
if (toEchoGrid)
{
myView->ConvertToGrid (theXPix, theYPix, aPnt3d[0], aPnt3d[1], aPnt3d[2]);
myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (aPnt3d[0], aPnt3d[1], aPnt3d[2]));
myView->RedrawImmediate();
}
break;
}
default:
{
if (toEchoGrid)
{
myView->Viewer()->HideGridEcho (myView);
myView->RedrawImmediate();
}
break;
}
}
}
myX = theXPix;
myY = theYPix;
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
if (!aView.IsNull())
aView->DynamicHilight (XPix, YPix);
{
aView->DynamicHilight (theXPix, theYPix);
}
}
//=======================================================================
//function : Select
//purpose :
//purpose :
//=======================================================================
void ViewerTest_EventManager::Select(const Standard_Integer XPMin,
const Standard_Integer YPMin,
const Standard_Integer XPMax,
const Standard_Integer YPMax)
void ViewerTest_EventManager::Select (const Standard_Integer theXPMin,
const Standard_Integer theYPMin,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax)
{
#define IS_FULL_INCLUSION Standard_True
if(!myCtx.IsNull() && !myView.IsNull())
myCtx->Select(XPMin,YPMin,XPMax,YPMax,myView);
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
#define IS_FULL_INCLUSION Standard_True
if (myView.IsNull())
{
return;
}
else if (!myCtx.IsNull())
{
myCtx->Select (theXPMin, theYPMin, theXPMax, theYPMax, myView, Standard_False);
}
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
if (!aView.IsNull())
aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_False, IS_FULL_INCLUSION);
{
aView->Select (theXPMin, theYPMin, theXPMax, theYPMax, Standard_False, IS_FULL_INCLUSION, Standard_False);
}
myView->Redraw();
}
//=======================================================================
//function : ShiftSelect
//purpose :
//purpose :
//=======================================================================
void ViewerTest_EventManager::ShiftSelect(const Standard_Integer XPMin,
const Standard_Integer YPMin,
const Standard_Integer XPMax,
const Standard_Integer YPMax)
{
if(!myCtx.IsNull() && !myView.IsNull())
myCtx->AIS_InteractiveContext::ShiftSelect(XPMin,YPMin,XPMax,YPMax,myView,
Standard_True);
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
void ViewerTest_EventManager::ShiftSelect (const Standard_Integer theXPMin,
const Standard_Integer theYPMin,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax)
{
if (myView.IsNull())
{
return;
}
else if (!myCtx.IsNull())
{
myCtx->AIS_InteractiveContext::ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax, myView, Standard_False);
}
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
if (!aView.IsNull())
aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_True, IS_FULL_INCLUSION);
{
aView->Select (theXPMin, theYPMin, theXPMax, theYPMax, Standard_True, IS_FULL_INCLUSION, Standard_False);
}
myView->Redraw();
}
//=======================================================================
//function : Select
//purpose :
//purpose :
//=======================================================================
void ViewerTest_EventManager::Select()
{
if (!myCtx.IsNull() && !myView.IsNull())
myCtx->Select();
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
if (myView.IsNull())
{
return;
}
else if (!myCtx.IsNull())
{
myCtx->Select (Standard_False);
}
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
if (!aView.IsNull())
aView->Select(myX, myY);
{
aView->Select (myX, myY, Standard_False);
}
myView->Redraw();
}
//=======================================================================
//function : ShiftSelect
//purpose :
//purpose :
//=======================================================================
void ViewerTest_EventManager::ShiftSelect()
{
if(!myCtx.IsNull() && !myView.IsNull())
myCtx->ShiftSelect(Standard_True);
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
if (myView.IsNull())
{
return;
}
else if (!myCtx.IsNull())
{
myCtx->ShiftSelect (Standard_False);
}
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
if (!aView.IsNull())
aView->Select(myX, myY, Standard_True);
{
aView->Select (myX, myY, Standard_False);
}
myView->Redraw();
}
//=======================================================================
@ -118,21 +186,28 @@ void ViewerTest_EventManager::ShiftSelect()
//purpose : Selection with polyline
//=======================================================================
void ViewerTest_EventManager::Select(const TColgp_Array1OfPnt2d& thePolyline)
void ViewerTest_EventManager::Select (const TColgp_Array1OfPnt2d& thePolyline)
{
if(!myCtx.IsNull() && !myView.IsNull())
myCtx->Select(thePolyline,myView);
if (myView.IsNull())
{
return;
}
else if (!myCtx.IsNull())
{
myCtx->Select (thePolyline, myView, Standard_False);
}
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
if (!aView.IsNull())
{
NCollection_List<gp_XY> aPolylist;
for(Standard_Integer anIter = thePolyline.Lower();anIter <= thePolyline.Upper();++anIter)
for(Standard_Integer anIter = thePolyline.Lower(); anIter <= thePolyline.Upper(); ++anIter)
{
aPolylist.Append(gp_XY(thePolyline.Value(anIter).X(),
thePolyline.Value(anIter).Y()));
aPolylist.Append (gp_XY (thePolyline.Value (anIter).X(), thePolyline.Value (anIter).Y()));
}
aView->Select(aPolylist);
aView->Select (aPolylist, Standard_False, Standard_False, Standard_False);
}
myView->Redraw();
}
//=======================================================================
@ -140,19 +215,26 @@ void ViewerTest_EventManager::Select(const TColgp_Array1OfPnt2d& thePolyline)
//purpose : Selection with polyline without erasing of current selection
//=======================================================================
void ViewerTest_EventManager::ShiftSelect(const TColgp_Array1OfPnt2d& thePolyline)
void ViewerTest_EventManager::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline)
{
if(!myCtx.IsNull() && !myView.IsNull())
myCtx->ShiftSelect(thePolyline,myView);
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
if (myView.IsNull())
{
return;
}
else if (!myCtx.IsNull())
{
myCtx->ShiftSelect (thePolyline, myView, Standard_False);
}
const Handle(NIS_View) aView = Handle(NIS_View)::DownCast (myView);
if (!aView.IsNull())
{
NCollection_List<gp_XY> aPolylist;
for(Standard_Integer anIter = thePolyline.Lower();anIter <= thePolyline.Upper();++anIter)
for (Standard_Integer anIter = thePolyline.Lower(); anIter <= thePolyline.Upper(); ++anIter)
{
aPolylist.Append(gp_XY(thePolyline.Value(anIter).X(),
thePolyline.Value(anIter).Y()));
aPolylist.Append (gp_XY (thePolyline.Value (anIter).X(), thePolyline.Value (anIter).Y()));
}
aView->Select(aPolylist, Standard_True);
aView->Select (aPolylist, Standard_True, Standard_False, Standard_False);
}
myView->Redraw();
}

View File

@ -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

View File

@ -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 <aView>.
---Category: Constructors
------------------------
-- Category: Destructors
------------------------
Destroy (me : mutable);
---Level: Public
---Purpose: Suppress the TransientManager <me>.
---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 <aView>
-- Redraw any structured graphics in the back buffer before
-- if <DoubleBuffer> is TRUE.
-- Restore the front buffer from the back before
-- if <DoubleBuffer> is FALSE.
-- if <RetainMode> is TRUE.
-- the graphic managed itself exposure,resizing ...
-- if <RetainMode> 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 <Synchronize> 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 <aView>
--- updates a scene if <aFlush> = 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 <aView>
-- 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 <AStructure>.
-- Raises TransientDefinitionError from Visual3d;
-- if Drawing is not opened.
raises TransientDefinitionError from Visual3d;
end TransientManager from Visual3d;

View File

@ -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 <Visual3d_TransientManager.ixx>
#include <Visual3d_ViewPtr.hxx>
#include <Visual3d_View.pxx>
#include <Aspect_CLayer2d.hxx>
#include <Graphic3d_CView.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_TypeOfPrimitive.hxx>
#include <Visual3d_Layer.hxx>
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());
}
}

View File

@ -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 <AStructure> to the view <me>.
---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;
-- the ViewManager associated with the view
-- MyPtrViewManager : Address from Standard;
MyPtrViewManager : ViewManagerPtr from Visual3d;
myImmediateStructures : MapOfStructure from Graphic3d;
-- Booleans
MyCBitFields : CBitFields8 from Graphic3d;
-- the ViewManager associated with the view
MyPtrViewManager : ViewManagerPtr from Visual3d;
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
-- Booleans
MyCBitFields : CBitFields8 from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d;
MyGTrihedron : CGraduatedTrihedron from Graphic3d;
myDefaultCamera : Camera_Handle from Graphic3d;
friends
class ViewManager from Visual3d
class ViewManager from Visual3d
end View;

View File

@ -136,8 +136,8 @@
#include <Visual3d_Light.hxx>
#include <Visual3d_SetOfLight.hxx>
#include <Visual3d_HSetOfLight.hxx>
#include <Visual3d_HSetOfView.hxx>
#include <Visual3d_SetIteratorOfSetOfLight.hxx>
#include <Visual3d_SetIteratorOfSetOfView.hxx>
#include <Graphic3d_TextureEnv.hxx>
@ -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;
if (! 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);
}
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);
void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
const Handle(Visual3d_Layer)& theOverLayer)
{
Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
}
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) {
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;
}
if (IsDeleted ()) return;
if (MyGraphicDriver->IsDeviceLost())
{
MyViewManager->RecomputeStructures();
MyViewManager->RecomputeStructures (myImmediateStructures);
MyGraphicDriver->ResetDeviceLostFlag();
}
if ((! IsDefined ()) || (! IsActive ())) return;
if (! MyWindow->IsMapped ()) return;
// 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);
}
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);
// 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::Update ()
void Visual3d_View::RedrawImmediate()
{
RedrawImmediate (MyViewManager->UnderLayer(), MyViewManager->OverLayer());
}
void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer,
const Handle(Visual3d_Layer)& theOverLayer)
{
if (IsDeleted()
|| !IsDefined()
|| !IsActive()
|| !MyWindow->IsMapped())
{
return;
}
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()
{
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 ());

View File

@ -88,11 +88,21 @@ is
-- visualiser <me>.
---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 <me>.
---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

View File

@ -388,61 +388,76 @@ void Visual3d_ViewManager::UnHighlight (const Handle(Graphic3d_Structure)& AStru
}
void Visual3d_ViewManager::Redraw () const {
void Visual3d_ViewManager::Redraw() const
{
// redraw all activated views
if (MyDefinedView.Extent() == 0)
{
return;
}
Standard_Integer MaxDx, MaxDy;
Standard_Integer Dx, Dy;
MaxDx = MaxDy = IntegerFirst ();
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);
}
}
//
// 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);
for (Visual3d_SetIteratorOfSetOfView anIter (MyDefinedView);
anIter.More(); anIter.Next())
{
anIter.Value()->Redraw (MyUnderLayer, MyOverLayer);
}
if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ())
MyIterator.Initialize (MyDefinedView);
while (MyIterator.More ()) {
(MyIterator.Value ())->Redraw (MyUnderLayer, MyOverLayer);
// MyIterator.Next () is located on the next view
MyIterator.Next ();
}
}
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 {