From f838dac48b3342dd001f3ba81c5ba070762e42df Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 2 Nov 2016 17:36:18 +0300 Subject: [PATCH] 0025695: Visualization, AIS_InteractiveContext - define default HilightMode AIS_InteractiveContext - removed the following unused properties: - PreSelectionColor(), DefaultColor(), WasCurrentTouched(), ZDetection(). AIS_InteractiveObject - removed unused property SelectionPriority(). Prs3d_Drawer - removed properties HighlightStyle() and SelectionStyle(). Graphic3d_HighlightStyle has been superseded by Prs3d_Drawer inheriting from new class Graphic3d_PresentationAttributes. Graphic3d_PresentationAttributes (as Graphic3d_HighlightStyle replacement) has been extended with new properties: - ZLayer() defining Z-Layer for highlighting presentation. - DisplayMode() defining display mode for highlighting. StdSelect_BRepSelectionTool methods have been corrected to take SelectMgr_EntityOwner instead of StdSelect_BRepOwner. StdSelect_Shape - duplicated field myDrawer has been dropped. AIS_InteractiveObject - myDrawer->Color() is now used instead of myOwnColor, myDrawer->Transparency() instead of myTransparency and myDrawer->ZLayer() instead of myZLayer. PrsMgr_PresentationManager::Unhighlight() now unhighlight all modes. The method taking Mode as argument has been marked deprecated. New enumeration Prs3d_TypeOfHighlight has been introduced defining different highlight types. AIS_InteractiveObject::HighlightStyle() now takes enumeration argument and defines different styles for Global and Local selection. ComesFromDecomposition() property has been moved from StdSelect_BRepOwner to SelectMgr_EntityOwner. --- dox/dev_guides/upgrade/upgrade.md | 37 +++ .../Common/ISession/ISession_Curve.cpp | 2 +- .../04_Viewer3d/src/ISession_Curve.cpp | 2 +- .../07_Triangulation/src/ISession_Curve.cpp | 2 +- .../src/ISession/ISession_Curve.cpp | 2 +- .../Common/Primitive/Sample2D_Face.cpp | 2 +- .../standard/Common/Primitive/Sample2D_Face.h | 2 +- src/AIS/AIS_Axis.cxx | 2 +- src/AIS/AIS_Circle.cxx | 8 +- src/AIS/AIS_ColorScale.cxx | 2 +- src/AIS/AIS_ColoredShape.cxx | 4 +- src/AIS/AIS_ConnectedInteractive.cxx | 2 +- src/AIS/AIS_DimensionOwner.cxx | 7 +- src/AIS/AIS_DimensionOwner.hxx | 27 +- src/AIS/AIS_GlobalStatus.cxx | 4 +- src/AIS/AIS_GlobalStatus.hxx | 89 ++--- src/AIS/AIS_GlobalStatus.lxx | 74 ----- src/AIS/AIS_InteractiveContext.cxx | 167 +++++++--- src/AIS/AIS_InteractiveContext.hxx | 173 +++++----- src/AIS/AIS_InteractiveContext.lxx | 85 ----- src/AIS/AIS_InteractiveContext_1.cxx | 202 ++++++------ src/AIS/AIS_InteractiveContext_2.cxx | 37 +-- src/AIS/AIS_InteractiveObject.cxx | 82 +++-- src/AIS/AIS_InteractiveObject.hxx | 151 ++++----- src/AIS/AIS_InteractiveObject.lxx | 100 ------ src/AIS/AIS_Line.cxx | 8 +- src/AIS/AIS_LocalContext.cxx | 55 ++-- src/AIS/AIS_LocalContext.hxx | 23 +- src/AIS/AIS_LocalContext_1.cxx | 56 +--- src/AIS/AIS_LocalStatus.cxx | 7 +- src/AIS/AIS_LocalStatus.hxx | 32 +- src/AIS/AIS_Manipulator.cxx | 2 +- src/AIS/AIS_Manipulator.hxx | 2 +- src/AIS/AIS_ManipulatorOwner.cxx | 4 +- src/AIS/AIS_ManipulatorOwner.hxx | 2 +- src/AIS/AIS_MultipleConnectedInteractive.cxx | 33 +- src/AIS/AIS_Plane.cxx | 5 +- src/AIS/AIS_PlaneTrihedron.cxx | 2 +- src/AIS/AIS_Point.cxx | 29 +- src/AIS/AIS_PointCloud.cxx | 8 +- src/AIS/AIS_Relation.cxx | 4 +- src/AIS/AIS_Shape.cxx | 11 +- src/AIS/AIS_TextLabel.cxx | 2 +- src/AIS/AIS_Triangulation.cxx | 4 +- src/AIS/AIS_Trihedron.cxx | 14 +- src/AIS/FILES | 3 - src/Graphic3d/FILES | 3 +- src/Graphic3d/Graphic3d_CStructure.hxx | 10 +- src/Graphic3d/Graphic3d_HighlightStyle.hxx | 99 +----- ...x => Graphic3d_PresentationAttributes.cxx} | 4 +- .../Graphic3d_PresentationAttributes.hxx | 105 ++++++ src/Graphic3d/Graphic3d_Structure.cxx | 6 +- src/Graphic3d/Graphic3d_Structure.hxx | 4 +- src/Graphic3d/Graphic3d_ZLayerId.hxx | 2 + src/MeshVS/MeshVS_Mesh.cxx | 8 +- src/MeshVS/MeshVS_Mesh.hxx | 2 +- src/MeshVS/MeshVS_MeshEntityOwner.cxx | 2 +- src/MeshVS/MeshVS_MeshEntityOwner.hxx | 2 +- src/MeshVS/MeshVS_MeshOwner.cxx | 7 +- src/MeshVS/MeshVS_MeshOwner.hxx | 2 +- src/OpenGl/OpenGl_Context.cxx | 26 +- src/OpenGl/OpenGl_Context.hxx | 4 +- src/OpenGl/OpenGl_PrimitiveArray.cxx | 2 +- src/OpenGl/OpenGl_Structure.cxx | 17 +- src/OpenGl/OpenGl_Structure.hxx | 4 +- src/OpenGl/OpenGl_Workspace.cxx | 12 +- src/OpenGl/OpenGl_Workspace.hxx | 49 +-- src/Prs3d/FILES | 1 + src/Prs3d/Prs3d_Drawer.cxx | 31 +- src/Prs3d/Prs3d_Drawer.hxx | 59 +--- src/Prs3d/Prs3d_TypeOfHighlight.hxx | 29 ++ src/PrsMgr/FILES | 2 - src/PrsMgr/PrsMgr_PresentableObject.cxx | 38 ++- src/PrsMgr/PrsMgr_PresentableObject.hxx | 49 ++- src/PrsMgr/PrsMgr_Presentation.cxx | 6 +- src/PrsMgr/PrsMgr_Presentation.hxx | 56 +--- src/PrsMgr/PrsMgr_Presentation.lxx | 37 --- src/PrsMgr/PrsMgr_PresentationManager.cxx | 26 +- src/PrsMgr/PrsMgr_PresentationManager.hxx | 49 ++- src/PrsMgr/PrsMgr_PresentationManager.lxx | 25 -- src/QABugs/QABugs_16.cxx | 2 +- src/QABugs/QABugs_19.cxx | 19 +- src/QABugs/QABugs_9.cxx | 16 - src/SelectBasics/SelectBasics_EntityOwner.cxx | 18 +- src/SelectBasics/SelectBasics_EntityOwner.hxx | 52 +-- src/SelectMgr/FILES | 1 - src/SelectMgr/SelectMgr_EntityOwner.cxx | 116 ++++--- src/SelectMgr/SelectMgr_EntityOwner.hxx | 100 +++--- src/SelectMgr/SelectMgr_EntityOwner.lxx | 27 -- src/SelectMgr/SelectMgr_SelectableObject.cxx | 127 +------ src/SelectMgr/SelectMgr_SelectableObject.hxx | 40 +-- src/StdSelect/FILES | 1 - src/StdSelect/StdSelect_BRepOwner.cxx | 163 +++++---- src/StdSelect/StdSelect_BRepOwner.hxx | 52 +-- src/StdSelect/StdSelect_BRepSelectionTool.cxx | 129 +++----- src/StdSelect/StdSelect_BRepSelectionTool.hxx | 122 ++++--- src/StdSelect/StdSelect_Shape.cxx | 15 +- src/StdSelect/StdSelect_Shape.hxx | 36 +- src/StdSelect/StdSelect_Shape.lxx | 13 - src/ViewerTest/ViewerTest.cxx | 12 +- src/ViewerTest/ViewerTest_ObjectCommands.cxx | 14 +- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 309 ++++++++++++------ tests/bugs/vis/bug137_4 | 53 --- tests/bugs/vis/bug137_5 | 53 --- tests/bugs/vis/bug25695 | 22 ++ tests/v3d/materials/bug27818_1 | 6 +- 106 files changed, 1609 insertions(+), 2258 deletions(-) delete mode 100644 src/AIS/AIS_GlobalStatus.lxx delete mode 100644 src/AIS/AIS_InteractiveContext.lxx delete mode 100644 src/AIS/AIS_InteractiveObject.lxx rename src/Graphic3d/{Graphic3d_HighlightStyle.cxx => Graphic3d_PresentationAttributes.cxx} (84%) create mode 100644 src/Graphic3d/Graphic3d_PresentationAttributes.hxx create mode 100644 src/Prs3d/Prs3d_TypeOfHighlight.hxx delete mode 100644 src/PrsMgr/PrsMgr_Presentation.lxx delete mode 100644 src/PrsMgr/PrsMgr_PresentationManager.lxx delete mode 100644 src/SelectMgr/SelectMgr_EntityOwner.lxx delete mode 100644 src/StdSelect/StdSelect_Shape.lxx delete mode 100755 tests/bugs/vis/bug137_4 delete mode 100755 tests/bugs/vis/bug137_5 create mode 100644 tests/bugs/vis/bug25695 diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 0e7d69399e..e3486df8bd 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1117,6 +1117,14 @@ The following classes have been changed: @section upgrade_occt720 Upgrade to OCCT 7.2.0 +@subsection upgrade_720_removed Removed features + +The following obsolete features have been removed: +* *AIS_InteractiveContext::PreSelectionColor()*, *::DefaultColor()*, *::WasCurrentTouched()*, *::ZDetection()*. + These properties were unused, and therefore application should remove occurrences of these methods. +* *AIS_InteractiveObject::SelectionPriority()*. + These property was not implemented. + @subsection upgrade_occt720_correction_of_Offset_API Corrections in BRepOffset API Class *BRepOffsetAPI_MakeOffsetShape*: @@ -1140,3 +1148,32 @@ The code below shows new calling procedure: BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3); myBody = BodyMaker.Shape(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +@subsection upgrade_720_highlight Highlight style + +Management of highlight attributes has been revised and might require modifications from application side: +* New class *Graphic3d_PresentationAttributes* defining basic presentation attributes has been introduced. + It's definition includes properties previously defined by class Graphic3d_HighlightStyle (*Color*, *Transparency*), + and new properties (*Display mode*, *ZLayer*, optional *FillArea aspect*). +* Class *Prs3d_Drawer* now inherits class *Graphic3d_PresentationAttributes*. + So that overall presentation attributes are now split into two parts - Basic attributes and Detailed attributes. +* Class *Graphic3d_HighlightStyle* has been dropped. + It is now defined as a typedef to *Prs3d_Drawer*. + Therefore, highlight style now also includes not only Basic presentation attributes, but also Detailed attributes + which can be used by custom presentation builders. +* Highlighting style defined by class *Graphic3d_PresentationAttributes* now provides more options: + - *Graphic3d_PresentationAttributes::BasicFillAreaAspect()* property providing complete Material definition. + This option, when defined, can be used instead of the pair Object Material + Highlight Color. + - *Graphic3d_PresentationAttributes::ZLayer()* property specifying the Layer where highlighted presentation should be shown. + This property can be set to Graphic3d_ZLayerId_UNKNOWN, which means that ZLayer of main presentation should be used instead. + - *Graphic3d_PresentationAttributes::DisplayMode()* property specifying Display Mode for highlight presentation. +* Since Highlight and Selection styles within *AIS_InteractiveContext* are now defined by *Prs3d_Drawer* inheriting from *Graphic3d_PresentationAttributes*, + it is now possible to customize default highlight attributes like *Display Mode* and *ZLayer*, which previously could be defined only on Object level. +* Properties *Prs3d_Drawer::HighlightStyle()* and *Prs3d_Drawer::SelectionStyle()* have been removed. + Instead, *AIS_InteractiveObject* now defines *::DynamicHilightAttributes()* for dynamic highlighting in addition to *::HilightAttributes()* used for highlighting in selected state. +* The following protected fields have been removed from class *AIS_InteractiveObject*: + - *myOwnColor*, replaced by *myDrawer->Color()* + - *myTransparency*, replaced by *myDrawer->Transparency()* + - *myZLayer*, replaced by *myDrawer->ZLayer()* +* The method *PrsMgr_PresentationManager::Unhighlight()* taking Display Mode as an argument has been marked deprecated. + Implementation now performs unhighlighting of all highlighted presentation mode. diff --git a/samples/mfc/occtdemo/Common/ISession/ISession_Curve.cpp b/samples/mfc/occtdemo/Common/ISession/ISession_Curve.cpp index 52e9ea23dd..24f597b483 100755 --- a/samples/mfc/occtdemo/Common/ISession/ISession_Curve.cpp +++ b/samples/mfc/occtdemo/Common/ISession/ISession_Curve.cpp @@ -56,7 +56,7 @@ void ISession_Curve::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresen { GeomAdaptor_Curve anAdaptorCurve(myCurve); if (hasOwnColor) - myDrawer->LineAspect()->SetColor(myOwnColor); + myDrawer->LineAspect()->SetColor (myDrawer->Color()); myDrawer->Link()->SetDiscretisation(100); myDrawer->Link()->SetMaximalParameterValue(500); diff --git a/samples/mfc/standard/04_Viewer3d/src/ISession_Curve.cpp b/samples/mfc/standard/04_Viewer3d/src/ISession_Curve.cpp index 839a7a7aee..5b8b6a6f1b 100755 --- a/samples/mfc/standard/04_Viewer3d/src/ISession_Curve.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/ISession_Curve.cpp @@ -37,7 +37,7 @@ void ISession_Curve::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPres { GeomAdaptor_Curve anAdaptorCurve(myCurve); if (hasOwnColor) - myDrawer->LineAspect()->SetColor(myOwnColor); + myDrawer->LineAspect()->SetColor (myDrawer->Color()); myDrawer->Link()->SetDiscretisation(100); myDrawer->Link()->SetMaximalParameterValue(500); diff --git a/samples/mfc/standard/07_Triangulation/src/ISession_Curve.cpp b/samples/mfc/standard/07_Triangulation/src/ISession_Curve.cpp index 839a7a7aee..5b8b6a6f1b 100755 --- a/samples/mfc/standard/07_Triangulation/src/ISession_Curve.cpp +++ b/samples/mfc/standard/07_Triangulation/src/ISession_Curve.cpp @@ -37,7 +37,7 @@ void ISession_Curve::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPres { GeomAdaptor_Curve anAdaptorCurve(myCurve); if (hasOwnColor) - myDrawer->LineAspect()->SetColor(myOwnColor); + myDrawer->LineAspect()->SetColor (myDrawer->Color()); myDrawer->Link()->SetDiscretisation(100); myDrawer->Link()->SetMaximalParameterValue(500); diff --git a/samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.cpp b/samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.cpp index 839a7a7aee..5b8b6a6f1b 100755 --- a/samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.cpp +++ b/samples/mfc/standard/10_Convert/src/ISession/ISession_Curve.cpp @@ -37,7 +37,7 @@ void ISession_Curve::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPres { GeomAdaptor_Curve anAdaptorCurve(myCurve); if (hasOwnColor) - myDrawer->LineAspect()->SetColor(myOwnColor); + myDrawer->LineAspect()->SetColor (myDrawer->Color()); myDrawer->Link()->SetDiscretisation(100); myDrawer->Link()->SetMaximalParameterValue(500); diff --git a/samples/mfc/standard/Common/Primitive/Sample2D_Face.cpp b/samples/mfc/standard/Common/Primitive/Sample2D_Face.cpp index 1c9f44ac7d..a6d774f338 100755 --- a/samples/mfc/standard/Common/Primitive/Sample2D_Face.cpp +++ b/samples/mfc/standard/Common/Primitive/Sample2D_Face.cpp @@ -331,7 +331,7 @@ void Sample2D_Face::ClearSelected () //Method for advanced customizable highlighting of picked object void Sample2D_Face::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner) { Handle( Prs3d_Presentation ) aHighlightPrs; diff --git a/samples/mfc/standard/Common/Primitive/Sample2D_Face.h b/samples/mfc/standard/Common/Primitive/Sample2D_Face.h index 860dc04005..f1eab36e27 100755 --- a/samples/mfc/standard/Common/Primitive/Sample2D_Face.h +++ b/samples/mfc/standard/Common/Primitive/Sample2D_Face.h @@ -53,7 +53,7 @@ private: const SelectMgr_SequenceOfOwner& theOwners); void HilightOwnerWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner); void Compute ( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, diff --git a/src/AIS/AIS_Axis.cxx b/src/AIS/AIS_Axis.cxx index d04e55eb87..31eaf41d09 100644 --- a/src/AIS/AIS_Axis.cxx +++ b/src/AIS/AIS_Axis.cxx @@ -221,7 +221,7 @@ void AIS_Axis::SetColor(const Quantity_NameOfColor aCol) void AIS_Axis::SetColor(const Quantity_Color &aCol) { hasOwnColor=Standard_True; - myOwnColor=aCol; + myDrawer->SetColor (aCol); myDrawer->LineAspect()->SetColor(aCol); const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect(); diff --git a/src/AIS/AIS_Circle.cxx b/src/AIS/AIS_Circle.cxx index 82254ca47d..14d653c8dc 100644 --- a/src/AIS/AIS_Circle.cxx +++ b/src/AIS/AIS_Circle.cxx @@ -131,7 +131,7 @@ void AIS_Circle::SetColor(const Quantity_NameOfColor aCol) void AIS_Circle::SetColor(const Quantity_Color &aCol) { hasOwnColor=Standard_True; - myOwnColor=aCol; + myDrawer->SetColor (aCol); Standard_Real WW = HasWidth() ? myOwnWidth : myDrawer->HasLink() ? @@ -156,7 +156,7 @@ void AIS_Circle::SetWidth(const Standard_Real aValue) if (!myDrawer->HasOwnLineAspect ()) { Quantity_Color CC = Quantity_NOC_YELLOW; - if( HasColor() ) CC = myOwnColor; + if( HasColor() ) CC = myDrawer->Color(); else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue)); } else @@ -177,10 +177,10 @@ void AIS_Circle::UnsetColor() if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); else{ Quantity_Color CC = Quantity_NOC_YELLOW;; - if( HasColor() ) CC = myOwnColor; + if( HasColor() ) CC = myDrawer->Color(); else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); myDrawer->LineAspect()->SetColor(CC); - myOwnColor = CC; + myDrawer->SetColor (CC); } } diff --git a/src/AIS/AIS_ColorScale.cxx b/src/AIS/AIS_ColorScale.cxx index c0c8b8a9fe..9db164a9a0 100644 --- a/src/AIS/AIS_ColorScale.cxx +++ b/src/AIS/AIS_ColorScale.cxx @@ -576,7 +576,7 @@ void AIS_ColorScale::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePr Standard_Boolean toDrawLabel = GetLabelPosition() != Aspect_TOCSP_NONE; TCollection_ExtendedString aTitle = GetTitle(); Standard_Integer aTitleHeight = aSpacer; - Quantity_Color aFgColor (hasOwnColor ? myOwnColor : Quantity_NOC_WHITE); + Quantity_Color aFgColor (hasOwnColor ? myDrawer->Color() : Quantity_NOC_WHITE); // Draw title if (aTitle.Length()) diff --git a/src/AIS/AIS_ColoredShape.cxx b/src/AIS/AIS_ColoredShape.cxx index 370a032fb0..627db72633 100644 --- a/src/AIS/AIS_ColoredShape.cxx +++ b/src/AIS/AIS_ColoredShape.cxx @@ -208,7 +208,7 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape, void AIS_ColoredShape::SetColor (const Quantity_Color& theColor) { setColor (myDrawer, theColor); - myOwnColor = theColor; + myDrawer->SetColor (theColor); hasOwnColor = Standard_True; LoadRecomputable (AIS_WireFrame); LoadRecomputable (AIS_Shaded); @@ -273,7 +273,7 @@ void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth) void AIS_ColoredShape::SetTransparency (const Standard_Real theValue) { setTransparency (myDrawer, theValue); - myTransparency = theValue; + myDrawer->SetTransparency ((Standard_ShortReal )theValue); LoadRecomputable (AIS_WireFrame); LoadRecomputable (AIS_Shaded); for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next()) diff --git a/src/AIS/AIS_ConnectedInteractive.cxx b/src/AIS/AIS_ConnectedInteractive.cxx index d65c174872..237e320ecb 100644 --- a/src/AIS/AIS_ConnectedInteractive.cxx +++ b/src/AIS/AIS_ConnectedInteractive.cxx @@ -48,7 +48,7 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject) AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): AIS_InteractiveObject(aTypeOfPresentation3d) { - SetHilightMode(0); + // } //======================================================================= diff --git a/src/AIS/AIS_DimensionOwner.cxx b/src/AIS/AIS_DimensionOwner.cxx index 76415545fc..d0ae5acc0c 100755 --- a/src/AIS/AIS_DimensionOwner.cxx +++ b/src/AIS/AIS_DimensionOwner.cxx @@ -14,13 +14,12 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include #include #include #include -#include #include #include @@ -92,7 +91,7 @@ void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& th return; } - thePM->Unhighlight (Selectable(), HighlightMode (mySelectionMode)); + thePM->Unhighlight (Selectable()); } //======================================================================= @@ -100,7 +99,7 @@ void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& th //purpose : //======================================================================= void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer /*theMode*/) { thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode)); diff --git a/src/AIS/AIS_DimensionOwner.hxx b/src/AIS/AIS_DimensionOwner.hxx index 339f298938..1049791c7f 100644 --- a/src/AIS/AIS_DimensionOwner.hxx +++ b/src/AIS/AIS_DimensionOwner.hxx @@ -26,11 +26,10 @@ #include #include #include + class SelectMgr_SelectableObject; class PrsMgr_PresentationManager; - -class AIS_DimensionOwner; DEFINE_STANDARD_HANDLE(AIS_DimensionOwner, SelectMgr_EntityOwner) //! The owner is the entity which makes it possible to link @@ -46,11 +45,9 @@ DEFINE_STANDARD_HANDLE(AIS_DimensionOwner, SelectMgr_EntityOwner) //! priority 4. The default priority is 5. class AIS_DimensionOwner : public SelectMgr_EntityOwner { - + DEFINE_STANDARD_RTTIEXT(AIS_DimensionOwner, SelectMgr_EntityOwner) public: - - //! Initializes the dimension owner, theSO, and attributes it //! the priority, thePriority. Standard_EXPORT AIS_DimensionOwner(const Handle(SelectMgr_SelectableObject)& theSelObject, const AIS_DimensionSelectionMode theSelMode, const Standard_Integer thePriority = 0); @@ -58,7 +55,7 @@ public: Standard_EXPORT AIS_DimensionSelectionMode SelectionMode() const; Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode = 0) Standard_OVERRIDE; //! Returns true if an object with the selection mode @@ -68,28 +65,10 @@ public: //! Removes highlighting from the selected part of dimension. Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode = 0) Standard_OVERRIDE; - - - - DEFINE_STANDARD_RTTIEXT(AIS_DimensionOwner,SelectMgr_EntityOwner) - -protected: - - - - private: - AIS_DimensionSelectionMode mySelectionMode; - }; - - - - - - #endif // _AIS_DimensionOwner_HeaderFile diff --git a/src/AIS/AIS_GlobalStatus.cxx b/src/AIS/AIS_GlobalStatus.cxx index 7625b4c0aa..28ae7bef15 100644 --- a/src/AIS/AIS_GlobalStatus.cxx +++ b/src/AIS/AIS_GlobalStatus.cxx @@ -14,13 +14,13 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include #include #include -IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient) AIS_GlobalStatus::AIS_GlobalStatus(): myStatus(AIS_DS_None), diff --git a/src/AIS/AIS_GlobalStatus.hxx b/src/AIS/AIS_GlobalStatus.hxx index 2e9079dc38..d5ca4bbb0f 100644 --- a/src/AIS/AIS_GlobalStatus.hxx +++ b/src/AIS/AIS_GlobalStatus.hxx @@ -21,15 +21,13 @@ #include #include -#include +#include #include #include #include -#include +#include - -class AIS_GlobalStatus; -DEFINE_STANDARD_HANDLE(AIS_GlobalStatus, MMgt_TShared) +DEFINE_STANDARD_HANDLE(AIS_GlobalStatus, Standard_Transient) //! Stores information about objects in graphic context: //! - Status Of Display : in the main viewer @@ -38,59 +36,52 @@ DEFINE_STANDARD_HANDLE(AIS_GlobalStatus, MMgt_TShared) //! - Active Selection Modes //! - is the Interactive Object Current ? //! - Layer Index -class AIS_GlobalStatus : public MMgt_TShared +class AIS_GlobalStatus : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient) public: - Standard_EXPORT AIS_GlobalStatus(); Standard_EXPORT AIS_GlobalStatus(const AIS_DisplayStatus aStat, const Standard_Integer aDispMode, const Standard_Integer aSelMode, const Standard_Boolean ishilighted = Standard_False, const Standard_Integer aLayerIndex = 0); - - void SetGraphicStatus (const AIS_DisplayStatus aStat); - - void AddSelectionMode (const Standard_Integer aMode); - //! Sets display mode. - void SetDisplayMode (const Standard_Integer theMode); + void SetGraphicStatus (const AIS_DisplayStatus theStatus) { myStatus = theStatus; } - //! Returns the display mode. - Standard_Integer DisplayMode() const; - - void SetLayerIndex (const Standard_Integer AnIndex); - - void SetHilightStatus (const Standard_Boolean aStat); + void AddSelectionMode (const Standard_Integer theMode) { if (!IsSModeIn (theMode)) mySelModes.Append (theMode); } - //! Changes applied highlight style for a particular object - void SetHilightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) - { - myHiStyle = theStyle; - } + //! Sets display mode. + void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; } - //! Returns applied highlight style for a particular object - const Handle(Graphic3d_HighlightStyle)& HilightStyle() const - { - return myHiStyle; - } + //! Returns the display mode. + Standard_Integer DisplayMode() const { return myDispMode; } - Standard_Boolean IsSubIntensityOn() const; - - void SubIntensityOn(); - - void SubIntensityOff(); + void SetLayerIndex (const Standard_Integer theIndex) { myLayerIndex = theIndex; } + + void SetHilightStatus (const Standard_Boolean theStatus) { myIsHilit = theStatus; } + + //! Changes applied highlight style for a particular object + void SetHilightStyle (const Handle(Prs3d_Drawer)& theStyle) { myHiStyle = theStyle; } + + //! Returns applied highlight style for a particular object + const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; } + + Standard_Boolean IsSubIntensityOn() const { return mySubInt; } + + void SubIntensityOn() { mySubInt = Standard_True; } + + void SubIntensityOff() { mySubInt = Standard_False; } Standard_EXPORT void RemoveSelectionMode (const Standard_Integer aMode); Standard_EXPORT void ClearSelectionModes(); - AIS_DisplayStatus GraphicStatus() const; + AIS_DisplayStatus GraphicStatus() const { return myStatus; } //! keeps the active selection modes of the object //! in the main viewer. - const TColStd_ListOfInteger& SelectionModes() const; + const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; } - Standard_Boolean IsHilighted() const; + Standard_Boolean IsHilighted() const { return myIsHilit; } Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const; @@ -100,34 +91,16 @@ public: return myLayerIndex; } - - - DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus,MMgt_TShared) - -protected: - - - - private: - + TColStd_ListOfInteger mySelModes; + Handle(Prs3d_Drawer) myHiStyle; AIS_DisplayStatus myStatus; Standard_Integer myDispMode; - TColStd_ListOfInteger mySelModes; Standard_Integer myLayerIndex; Standard_Boolean myIsHilit; - Handle(Graphic3d_HighlightStyle) myHiStyle; Standard_Boolean mySubInt; - }; - -#include - - - - - #endif // _AIS_GlobalStatus_HeaderFile diff --git a/src/AIS/AIS_GlobalStatus.lxx b/src/AIS/AIS_GlobalStatus.lxx deleted file mode 100644 index bd970dbb88..0000000000 --- a/src/AIS/AIS_GlobalStatus.lxx +++ /dev/null @@ -1,74 +0,0 @@ -// Created on: 1997-01-24 -// Created by: Robert COUBLANC -// Copyright (c) 1997-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 void AIS_GlobalStatus::SetGraphicStatus(const AIS_DisplayStatus aStat) -{ - myStatus = aStat; -} - -inline void AIS_GlobalStatus::SetDisplayMode (const Standard_Integer theMode) -{ - myDispMode = theMode; -} -inline void AIS_GlobalStatus::AddSelectionMode(const Standard_Integer aMode) -{ - if(!IsSModeIn(aMode)) mySelModes.Append(aMode); -} - -inline void AIS_GlobalStatus::SetLayerIndex(const Standard_Integer AnIndex) -{ - myLayerIndex=AnIndex; -} - -inline void AIS_GlobalStatus::SetHilightStatus(const Standard_Boolean aStat) -{ - myIsHilit = aStat; -} - -inline Standard_Boolean AIS_GlobalStatus::IsSubIntensityOn() const -{ - return mySubInt; -} -inline void AIS_GlobalStatus::SubIntensityOn() -{ - mySubInt = Standard_True; -} -inline void AIS_GlobalStatus::SubIntensityOff() -{ - mySubInt = Standard_False; -} - - - -inline AIS_DisplayStatus AIS_GlobalStatus::GraphicStatus() const -{ - return myStatus; -} - -inline Standard_Integer AIS_GlobalStatus::DisplayMode() const -{ - return myDispMode; -} - -inline const TColStd_ListOfInteger& AIS_GlobalStatus::SelectionModes() const -{ - return mySelModes; -} - -inline Standard_Boolean AIS_GlobalStatus::IsHilighted() const -{ - return myIsHilit; -} diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 13191a1940..1acdb9307c 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +67,38 @@ namespace { typedef NCollection_DataMap AIS_MapOfObjectOwners; typedef NCollection_DataMap::Iterator AIS_MapIteratorOfMapOfObjectOwners; + + //! Initialize default highlighting attributes. + static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) + { + theDrawer->SetMethod (Aspect_TOHM_COLOR); + theDrawer->SetDisplayMode (0); + + theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0)); + *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect(); + theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect(); + theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect(); + theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect()); + *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect(); + theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect(); + theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect(); + + theDrawer->WireAspect()->SetWidth (2.0); + theDrawer->LineAspect()->SetWidth (2.0); + theDrawer->PlaneAspect()->EdgesAspect()->SetWidth (2.0); + theDrawer->FreeBoundaryAspect() ->SetWidth (2.0); + theDrawer->UnFreeBoundaryAspect()->SetWidth (2.0); + theDrawer->PointAspect()->SetTypeOfMarker (Aspect_TOM_O_POINT); + theDrawer->PointAspect()->SetScale (2.0); + + // the triangulation should be computed using main presentation attributes, + // and should not be overridden by highlighting + theDrawer->SetAutoTriangulation (Standard_False); + } } //======================================================================= @@ -79,24 +112,59 @@ myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())), myMainVwr(MainViewer), myMainSel(new StdSelect_ViewerSelector3d()), myWasLastMain(Standard_False), -myCurrentTouched(Standard_False), -mySelectedTouched(Standard_False), myToHilightSelected(Standard_True), +mySelection(new AIS_Selection()), myFilters(new SelectMgr_OrFilter()), myDefaultDrawer(new Prs3d_Drawer()), -mySelection(new AIS_Selection()), -myDefaultColor(Quantity_NOC_GOLDENROD), -myHiStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_CYAN1)), -mySelStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_GRAY80)), -myPreselectionColor(Quantity_NOC_GREEN), -mySubintStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_GRAY40)), -myDisplayMode(0), myCurLocalIndex(0), myCurDetected(0), myCurHighlighted(0), -myZDetectionFlag(0), myIsAutoActivateSelMode(Standard_True) -{ +{ + myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer; + myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer(); + myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer(); + myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer(); + myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer(); + myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer(); + + myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default); + myDefaultDrawer->SetDisplayMode(0); + { + const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic]; + aStyle->Link (myDefaultDrawer); + initDefaultHilightAttributes (aStyle); + aStyle->SetZLayer(Graphic3d_ZLayerId_Top); + aStyle->SetColor (Quantity_NOC_CYAN1); + } + { + const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic]; + aStyle->Link (myDefaultDrawer); + initDefaultHilightAttributes (aStyle); + aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost); + aStyle->SetColor (Quantity_NOC_CYAN1); + } + { + const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected]; + aStyle->Link (myDefaultDrawer); + initDefaultHilightAttributes (aStyle); + aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); + aStyle->SetColor (Quantity_NOC_GRAY80); + } + { + const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected]; + aStyle->Link (myDefaultDrawer); + initDefaultHilightAttributes (aStyle); + aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); + aStyle->SetColor (Quantity_NOC_GRAY80); + } + { + const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity]; + aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); + aStyle->SetMethod(Aspect_TOHM_COLOR); + aStyle->SetColor (Quantity_NOC_GRAY40); + } + InitAttributes(); } @@ -443,7 +511,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO { if(myMainPM->IsHighlighted (theIObj, anOldMode)) { - unhighlightGlobal (theIObj, anOldMode); + unhighlightGlobal (theIObj); } myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); } @@ -454,8 +522,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO aStatus->SetGraphicStatus (AIS_DS_Displayed); if (aStatus->IsHilighted()) { - const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; - highlightGlobal (theIObj, aStatus->HilightStyle(), aHiMod); + highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode); } if (theSelectionMode != -1) { @@ -854,7 +921,7 @@ void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theI //purpose : //======================================================================= void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Boolean theIsToUpdate) { if (theObj.IsNull()) @@ -871,8 +938,7 @@ void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject if (aStatus->GraphicStatus() == AIS_DS_Displayed) { - const Standard_Integer aHilightMode = theObj->HasHilightMode() ? theObj->HilightMode() : 0; - highlightGlobal (theObj, theStyle, aHilightMode); + highlightGlobal (theObj, theStyle, aStatus->DisplayMode()); aStatus->SetHilightStyle (theStyle); } } @@ -899,12 +965,11 @@ void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIO const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj); aStatus->SetHilightStatus (Standard_False); - aStatus->SetHilightStyle (new Graphic3d_HighlightStyle()); + aStatus->SetHilightStyle (Handle(Prs3d_Drawer)()); if (aStatus->GraphicStatus() == AIS_DS_Displayed) { - Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; - unhighlightGlobal (anIObj, aHilightMode); + unhighlightGlobal (anIObj); } } else @@ -971,7 +1036,7 @@ Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_Ent //purpose : //======================================================================= Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, - Handle(Graphic3d_HighlightStyle)& theStyle) const + Handle(Prs3d_Drawer)& theStyle) const { if (HasOpenedContext()) myLocalContexts (myCurLocalIndex)->HighlightStyle (theObj, theStyle); @@ -993,7 +1058,7 @@ Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_Intera //purpose : //======================================================================= Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, - Handle(Graphic3d_HighlightStyle)& theStyle) const + Handle(Prs3d_Drawer)& theStyle) const { if (theOwner.IsNull() || !theOwner->HasSelectable()) return Standard_False; @@ -1012,7 +1077,7 @@ Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_ // check if the object has own selection style. If not, it can // only be highlighted with default selection style (because // sub-intensity does not modify any selection states) - theStyle = getSelStyle (anObj); + theStyle = getSelStyle (anObj, theOwner); } return Standard_True; } @@ -1099,8 +1164,8 @@ Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_Inter { Standard_Integer aDispMode = theIObj->HasDisplayMode() ? theIObj->DisplayMode() - : (theIObj->AcceptDisplayMode (myDisplayMode) - ? myDisplayMode + : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) + ? myDefaultDrawer->DisplayMode() : 0); return myMainPM->DisplayPriority (theIObj, aDispMode); } @@ -1128,8 +1193,8 @@ void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObj { Standard_Integer aDisplayMode = theIObj->HasDisplayMode() ? theIObj->DisplayMode() - : (theIObj->AcceptDisplayMode (myDisplayMode) - ? myDisplayMode + : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) + ? myDefaultDrawer->DisplayMode() : 0); myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority); } @@ -1470,7 +1535,7 @@ Standard_Real AIS_InteractiveContext::HLRAngle() const void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode, const Standard_Boolean theToUpdateViewer) { - if (theMode == myDisplayMode) + if (theMode == myDefaultDrawer->DisplayMode()) { return; } @@ -1498,18 +1563,18 @@ void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode, if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj)) { myMainPM->BeginImmediateDraw(); - unhighlightGlobal (anObj, myDisplayMode); + unhighlightGlobal (anObj); myMainPM->EndImmediateDraw (myMainVwr); } if (aStatus->IsSubIntensityOn()) { highlightWithSubintensity (anObj, theMode); } - myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False); + myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False); } } - myDisplayMode = theMode; + myDefaultDrawer->SetDisplayMode (theMode); if (theToUpdateViewer) { myMainVwr->Update(); @@ -1549,7 +1614,7 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject) { if (myMainPM->IsHighlighted (theIObj, anOldMode)) { - unhighlightGlobal (theIObj, anOldMode); + unhighlightGlobal (theIObj); } myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); } @@ -1557,11 +1622,9 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject) aStatus->SetDisplayMode (theMode); myMainPM->Display (theIObj, theMode); - Standard_Integer aDispMode, aHiMode, aSelMode; - GetDefModes (theIObj, aDispMode, aHiMode, aSelMode); if (aStatus->IsHilighted()) { - highlightGlobal (theIObj, getSelStyle (theIObj), aHiMode); + highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode); } if (aStatus->IsSubIntensityOn()) { @@ -1595,32 +1658,29 @@ void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObjec } const Standard_Integer anOldMode = theIObj->DisplayMode(); - if (myDisplayMode == anOldMode) + if (myDefaultDrawer->DisplayMode() == anOldMode) { return; } const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); - aStatus->SetDisplayMode (myDisplayMode); + aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode()); if (aStatus->GraphicStatus() == AIS_DS_Displayed) { if (myMainPM->IsHighlighted (theIObj, anOldMode)) { - unhighlightGlobal (theIObj, anOldMode); + unhighlightGlobal (theIObj); } myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); - myMainPM->Display (theIObj, myDisplayMode); - - Standard_Integer aDispMode, aHiMode, aSelMode; - GetDefModes (theIObj, aDispMode, aHiMode, aSelMode); + myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode()); if (aStatus->IsHilighted()) { highlightSelected (theIObj->GlobalSelOwner()); } if (aStatus->IsSubIntensityOn()) { - highlightWithSubintensity (theIObj, myDisplayMode); + highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode()); } if (theToUpdateViewer) @@ -2002,16 +2062,15 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI { if (myLastinMain->IsAutoHilight()) { - const Standard_Integer aHiMode = - theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; + const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; myLastinMain->HilightWithColor (myMainPM, - myLastinMain->IsSelected() ? getSelStyle (theIObj) : getHiStyle (theIObj), + myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain), aHiMode); } else { theIObj->HilightOwnerWithColor (myMainPM, - myLastinMain->IsSelected() ? getSelStyle (theIObj) : getHiStyle (theIObj), + myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain), myLastinMain); } } @@ -2081,12 +2140,12 @@ void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject setContextToObject (theIObj); if (!theIObj->IsTransparent() - && theValue <= 0.05) + && theValue <= 0.005) { return; } - if (theValue <= 0.05) + if (theValue <= 0.005) { UnsetTransparency (theIObj, theToUpdateViewer); return; @@ -2240,8 +2299,8 @@ void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& t theDispMode = theIObj->HasDisplayMode() ? theIObj->DisplayMode() - : (theIObj->AcceptDisplayMode (myDisplayMode) - ? myDisplayMode + : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) + ? myDefaultDrawer->DisplayMode() : 0); theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; theSelMode = theIObj->GlobalSelectionMode(); @@ -2278,7 +2337,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t } else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode())) { - unhighlightGlobal (theIObj, aStatus->DisplayMode()); + unhighlightGlobal (theIObj); } Standard_ENABLE_DEPRECATION_WARNINGS } @@ -2288,7 +2347,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t if (aStatus->IsHilighted() && theIObj->HasHilightMode()) { - unhighlightGlobal (theIObj, aDispMode); + unhighlightGlobal (theIObj); } if (!myLastPicked.IsNull() @@ -2420,7 +2479,7 @@ void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject) if (aDispMode == theMode && myMainPM->IsHighlighted (theIObj, theMode)) { - unhighlightGlobal (theIObj, theMode); + unhighlightGlobal (theIObj); } myMainPM->Erase (theIObj, theMode); diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 6481d43286..33327459e4 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,7 @@ #include #include #include +#include class SelectMgr_SelectionManager; class V3d_Viewer; class AIS_InteractiveObject; @@ -262,7 +262,6 @@ public: //! Removes all the objects from all opened Local Contexts //! and from the Neutral Point Standard_EXPORT void RemoveAll (const Standard_Boolean updateviewer = Standard_True); - //! Updates the display in the viewer to take dynamic //! detection into account. On dynamic detection by the @@ -276,7 +275,7 @@ public: Standard_DEPRECATED("Deprecated method Hilight()") void Hilight (const Handle(AIS_InteractiveObject)& theObj, const Standard_Boolean theIsToUpdateViewer = Standard_True) { - return HilightWithColor (theObj, mySelStyle, theIsToUpdateViewer); + return HilightWithColor (theObj, myStyles[Prs3d_TypeOfHighlight_Dynamic], theIsToUpdateViewer); } //! Changes the color of all the lines of the object in view, @@ -287,7 +286,7 @@ public: //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& theObj, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Boolean theIsToUpdate = Standard_True); @@ -573,12 +572,12 @@ public: //! Returns highlight style of the object if it is marked as highlighted via global status //! @param theObj [in] the object to check Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, - Handle(Graphic3d_HighlightStyle)& theStyle) const; + Handle(Prs3d_Drawer)& theStyle) const; //! Returns highlight style of the owner if it is selected //! @param theOwner [in] the owner to check Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, - Handle(Graphic3d_HighlightStyle)& theStyle) const; + Handle(Prs3d_Drawer)& theStyle) const; //! Returns the display priority of the entity anIobj. This //! will be display mode of anIobj if it is in the main @@ -625,44 +624,40 @@ public: //! Returns the display mode setting. //! Note that mode 3 is only used. - Standard_Integer DisplayMode() const; - + Standard_Integer DisplayMode() const { return myDefaultDrawer->DisplayMode(); } + + //! Returns highlight style settings. + const Handle(Prs3d_Drawer)& HighlightStyle (const Prs3d_TypeOfHighlight theStyleType) const { return myStyles[theStyleType]; } + + //! Setup highlight style settings. + void SetHighlightStyle (const Prs3d_TypeOfHighlight theStyleType, + const Handle(Prs3d_Drawer)& theStyle) { myStyles[theStyleType] = theStyle; } //! Returns current dynamic highlight style settings. //! By default: //! - the color of dynamic highlight is Quantity_NOC_CYAN1; //! - the presentation for dynamic highlight is completely opaque; //! - the type of highlight is Aspect_TOHM_COLOR. - const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const + const Handle(Prs3d_Drawer)& HighlightStyle() const { - return myHiStyle; + return myStyles[Prs3d_TypeOfHighlight_Dynamic]; } //! Setup the style of dynamic highlighting. - void SetHighlightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) { myHiStyle = theStyle; } + void SetHighlightStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle; } //! Returns current selection style settings. //! By default: //! - the color of selection is Quantity_NOC_GRAY80; //! - the presentation for selection is completely opaque; //! - the type of highlight is Aspect_TOHM_COLOR. - const Handle(Graphic3d_HighlightStyle)& SelectionStyle() const + const Handle(Prs3d_Drawer)& SelectionStyle() const { - return mySelStyle; + return myStyles[Prs3d_TypeOfHighlight_Selected]; } //! Setup the style of selection highlighting. - void SetSelectionStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) { mySelStyle = theStyle; } - - //! Returns the name of the color used to show preselection. - //! By default, this is Quantity_NOC_GREEN. - Quantity_NameOfColor PreSelectionColor() const; - - - //! Returns the name of the color used by default. - //! By default, this is Quantity_NOC_GOLDENROD. - Quantity_NameOfColor DefaultColor() const; - + void SetSelectionStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Selected] = theStyle; } //! Sub-intensity allows temporary highlighting of particular //! objects with specified color in a manner of selection highlight, @@ -672,7 +667,7 @@ public: //! By default, it is Quantity_NOC_GRAY40. const Quantity_Color& SubIntensityColor() const { - return mySubintStyle->Color(); + return myStyles[Prs3d_TypeOfHighlight_SubIntensity]->Color(); } //! Sub-intensity allows temporary highlighting of particular @@ -683,15 +678,9 @@ public: //! By default, this is Quantity_NOC_GRAY40. void SetSubIntensityColor (const Quantity_Color& theColor) { - mySubintStyle->SetColor (theColor); + myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetColor (theColor); } - //! Allows you to set the color used to show preselection. - //! By default, this is Quantity_NOC_GREEN. - //! A preselected entity is one which has been selected - //! as the domain of application of a function such as a fillet. - void SetPreselectionColor (const Quantity_NameOfColor aCol); - //! Sets the display mode of seen Interactive Objects. //! aMode provides the display mode index of the entity aniobj. //! If updateviewer equals Standard_True, the @@ -950,12 +939,11 @@ public: //! Specify whether selected object must be hilighted when mouse cursor //! is moved above it (in MoveTo method). By default this value is false and //! selected object is not hilighted in this case. - void SetToHilightSelected (const Standard_Boolean toHilight); - + void SetToHilightSelected (const Standard_Boolean toHilight) { myToHilightSelected = toHilight; } + //! Return value specified whether selected object must be hilighted //! when mouse cursor is moved above it - Standard_Boolean ToHilightSelected() const; - + Standard_Boolean ToHilightSelected() const { return myToHilightSelected; } //! @name OBSOLETE METHODS THAT ARE VALID FOR LOCAL CONTEXT ONLY @@ -986,18 +974,6 @@ public: //! local context, selected objects. Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT void UpdateCurrent(); - - - //! Returns the current selection touched by the cursor. - //! Objects selected when there is no open local context - //! are called current objects; those selected in open - //! local context, selected objects. - Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") - Standard_Boolean WasCurrentTouched() const; - - Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") - void SetOkCurrent(); - //! Returns true if there is a non-null interactive object in Neutral Point. //! Objects selected when there is no open local context are called current objects; @@ -1366,15 +1342,7 @@ public: //! Returns true if the automatic highlight mode is active //! in an open context. Standard_EXPORT Standard_Boolean AutomaticHilight() const; - - //! Enables/Disables the Z detection. - //! If TRUE the detection echo can be partially hidden by the - //! detected object. - Standard_EXPORT void SetZDetection (const Standard_Boolean aStatus = Standard_False); - - //! Retrieves the Z detection state. - Standard_EXPORT Standard_Boolean ZDetection() const; - + //! Activates the selection mode aMode whose index is //! given, for the given interactive entity anIobj. Standard_EXPORT void Activate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode = 0, const Standard_Boolean theIsForce = Standard_False); @@ -1502,17 +1470,16 @@ public: //! Returns the list of filters active in a local context. Standard_EXPORT const SelectMgr_ListOfFilter& Filters() const; - //! Returns the default attribute manager. //! This contains all the color and line attributes which //! can be used by interactive objects which do not have //! their own attributes. - const Handle(Prs3d_Drawer)& DefaultDrawer() const; - + const Handle(Prs3d_Drawer)& DefaultDrawer() const { return myDefaultDrawer; } + //! Returns the current viewer. - const Handle(V3d_Viewer)& CurrentViewer() const; - + const Handle(V3d_Viewer)& CurrentViewer() const { return myMainVwr; } + //! Returns the list of displayed objects of a particular //! Type WhichKind and Signature WhichSignature. By //! Default, WhichSignature equals -1. This means that @@ -1560,7 +1527,7 @@ public: Standard_EXPORT void ObjectsInside (AIS_ListOfInteractive& aListOfIO, const AIS_KindOfInteractive WhichKind = AIS_KOI_None, const Standard_Integer WhichSignature = -1) const; //! Returns true if there is an open context. - Standard_Boolean HasOpenedContext() const; + Standard_Boolean HasOpenedContext() const { return myCurLocalIndex != 0; } //! This method is only intended for advanced operation, particularly with //! the aim to improve performance when many objects have to be selected @@ -1568,14 +1535,14 @@ public: //! class AIS_InteractiveContext without trying to obtain an instance of //! AIS_LocalContext. Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") - Handle(AIS_LocalContext) LocalContext() const; - - const Handle(SelectMgr_SelectionManager)& SelectionManager() const; - - const Handle(PrsMgr_PresentationManager3d)& MainPrsMgr() const; - - const Handle(StdSelect_ViewerSelector3d)& MainSelector() const; + Handle(AIS_LocalContext) LocalContext() const { return myCurLocalIndex > 0 ? myLocalContexts (myCurLocalIndex) : Handle(AIS_LocalContext)(); } + + const Handle(SelectMgr_SelectionManager)& SelectionManager() const { return mgrSelector; } + const Handle(PrsMgr_PresentationManager3d)& MainPrsMgr() const { return myMainPM; } + + const Handle(StdSelect_ViewerSelector3d)& MainSelector() const { return myMainSel; } + Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") Standard_EXPORT Handle(StdSelect_ViewerSelector3d) LocalSelector() const; @@ -1656,8 +1623,8 @@ protected: //! for AutoHighlight, e.g. is used for selection. //! If global owner is null, it simply highlights the whole object Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj, - const Handle(Graphic3d_HighlightStyle)& theStyle, - const Standard_Integer theMode) const; + const Handle(Prs3d_Drawer)& theStyle, + const Standard_Integer theDispMode) const; //! Helper function that unhighlights all owners that are stored in current AIS_Selection. //! The function updates global status and selection state of owner and interactive object. @@ -1667,7 +1634,7 @@ protected: //! Helper function that unhighlights global selection owner of given interactive. //! The function does not perform any updates of global or owner status - Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode) const; + Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const; //! Helper function that turns on sub-intensity in global status and highlights //! given objects with sub-intensity color @@ -1697,22 +1664,32 @@ protected: //! if custom style is defined via object's highlight drawer, it will be used. Otherwise, //! dynamic highlight style of interactive context will be returned. //! @param theObj [in] the object to check - const Handle(Graphic3d_HighlightStyle)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj) const + const Handle(Prs3d_Drawer)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj, + const Handle(SelectMgr_EntityOwner)& theOwner) const { - const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes(); - return !aHiDrawer.IsNull() && aHiDrawer->HasOwnHighlightStyle() - ? aHiDrawer->HighlightStyle() : myHiStyle; + const Handle(Prs3d_Drawer)& aHiDrawer = theObj->DynamicHilightAttributes(); + if (!aHiDrawer.IsNull()) + { + return aHiDrawer; + } + + return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalDynamic : Prs3d_TypeOfHighlight_Dynamic]; } //! Helper function that returns correct selection style for the object: //! if custom style is defined via object's highlight drawer, it will be used. Otherwise, //! selection style of interactive context will be returned. //! @param theObj [in] the object to check - const Handle(Graphic3d_HighlightStyle)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj) const + const Handle(Prs3d_Drawer)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj, + const Handle(SelectMgr_EntityOwner)& theOwner) const { const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes(); - return !aHiDrawer.IsNull() && aHiDrawer->HasOwnSelectionStyle() - ? aHiDrawer->SelectionStyle() : mySelStyle; + if (!aHiDrawer.IsNull()) + { + return aHiDrawer; + } + + return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalSelected : Prs3d_TypeOfHighlight_Selected]; } //! Assign the context to the object or throw exception if object was already assigned to another context. @@ -1731,6 +1708,28 @@ protected: } } + //! Return display mode for highlighting. + Standard_Integer getHilightMode (const Handle(AIS_InteractiveObject)& theObj, + const Handle(Prs3d_Drawer)& theStyle, + const Standard_Integer theDispMode) const + { + if (!theStyle.IsNull() + && theStyle->DisplayMode() != -1 + && theObj->AcceptDisplayMode (theStyle->DisplayMode())) + { + return theStyle->DisplayMode(); + } + else if (theDispMode != -1) + { + return theDispMode; + } + else if (theObj->HasDisplayMode()) + { + return theObj->DisplayMode(); + } + return myDefaultDrawer->DisplayMode(); + } + protected: AIS_DataMapOfIOStatus myObjects; @@ -1741,31 +1740,21 @@ protected: Handle(SelectMgr_EntityOwner) myLastPicked; Handle(SelectMgr_EntityOwner) myLastinMain; Standard_Boolean myWasLastMain; - Standard_Boolean myCurrentTouched; - Standard_Boolean mySelectedTouched; Standard_Boolean myToHilightSelected; + Handle(AIS_Selection) mySelection; Handle(SelectMgr_OrFilter) myFilters; Handle(Prs3d_Drawer) myDefaultDrawer; - Handle(AIS_Selection) mySelection; - Quantity_NameOfColor myDefaultColor; - Handle(Graphic3d_HighlightStyle) myHiStyle; - Handle(Graphic3d_HighlightStyle) mySelStyle; - Quantity_NameOfColor myPreselectionColor; - Handle(Graphic3d_HighlightStyle) mySubintStyle; - Standard_Integer myDisplayMode; + Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB]; AIS_DataMapOfILC myLocalContexts; Standard_Integer myCurLocalIndex; Handle(V3d_View) mylastmoveview; TColStd_SequenceOfInteger myDetectedSeq; Standard_Integer myCurDetected; Standard_Integer myCurHighlighted; - Standard_Boolean myZDetectionFlag; Standard_Boolean myIsAutoActivateSelMode; }; DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient) -#include - #endif // _AIS_InteractiveContext_HeaderFile diff --git a/src/AIS/AIS_InteractiveContext.lxx b/src/AIS/AIS_InteractiveContext.lxx deleted file mode 100644 index 9f3b25bc0e..0000000000 --- a/src/AIS/AIS_InteractiveContext.lxx +++ /dev/null @@ -1,85 +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. - -inline const Handle(V3d_Viewer)& AIS_InteractiveContext::CurrentViewer() const -{ - return myMainVwr; -} - -inline Quantity_NameOfColor AIS_InteractiveContext::PreSelectionColor() const -{ - return myPreselectionColor; -} - -inline Quantity_NameOfColor AIS_InteractiveContext::DefaultColor() const -{ return myDefaultColor; -} - -inline void AIS_InteractiveContext::SetPreselectionColor(const Quantity_NameOfColor aCol) -{ - myPreselectionColor = aCol; -} - -inline Standard_Integer AIS_InteractiveContext::DisplayMode() const -{ - return myDisplayMode; -} - -inline const Handle(Prs3d_Drawer)& AIS_InteractiveContext::DefaultDrawer() const -{return myDefaultDrawer;} -inline const Handle(SelectMgr_SelectionManager)& AIS_InteractiveContext::SelectionManager() const -{return mgrSelector ;} - -inline const Handle(PrsMgr_PresentationManager3d)& AIS_InteractiveContext::MainPrsMgr() const -{return myMainPM ;} - -inline Standard_Boolean AIS_InteractiveContext::HasOpenedContext() const -{return myCurLocalIndex != 0;} - -inline Handle(AIS_LocalContext) AIS_InteractiveContext::LocalContext() const -{ return (myCurLocalIndex > 0) ? myLocalContexts(myCurLocalIndex) : NULL; } - -inline Standard_Boolean AIS_InteractiveContext::WasCurrentTouched() const -{return myCurrentTouched;} - -inline void AIS_InteractiveContext::SetOkCurrent() -{myCurrentTouched= Standard_False;} - - -inline const Handle(StdSelect_ViewerSelector3d)& AIS_InteractiveContext::MainSelector() const -{return myMainSel;} - -inline void AIS_InteractiveContext::SetToHilightSelected(const Standard_Boolean toHilight) -{ - myToHilightSelected = toHilight; -} - -inline Standard_Boolean AIS_InteractiveContext::ToHilightSelected() const -{ - return myToHilightSelected; -} - - - - - - - - - - - - - - diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index b869d7870c..5a3a042e01 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -66,14 +66,17 @@ namespace void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(V3d_Viewer)& theViewer) { - const Handle(AIS_InteractiveObject) anObj = - Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); if (anObj.IsNull()) + { return; - const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + } + + const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner); + const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1); myMainPM->BeginImmediateDraw(); - theOwner->HilightWithColor (myMainPM, getHiStyle (anObj), aHiMode); + theOwner->HilightWithColor (myMainPM, aStyle, aHiMode); myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer); } @@ -83,11 +86,11 @@ void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOw //======================================================================= void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner) { - const Handle(AIS_InteractiveObject) anObj = - Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); if (anObj.IsNull()) + { return; - const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + } if (!theOwner->IsAutoHilight()) { @@ -103,7 +106,9 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn } else { - theOwner->HilightWithColor (myMainPM, getSelStyle (anObj), aHiMode); + const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner); + const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1); + theOwner->HilightWithColor (myMainPM, aStyle, aHiMode); } } @@ -112,16 +117,20 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn //purpose : //======================================================================= void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj, - const Handle(Graphic3d_HighlightStyle)& theStyle, - const Standard_Integer theMode) const + const Handle(Prs3d_Drawer)& theStyle, + const Standard_Integer theDispMode) const { if (theObj.IsNull()) + { return; + } + + const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode); const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); if (aGlobOwner.IsNull()) { - myMainPM->Color (theObj, theStyle, theMode); + myMainPM->Color (theObj, theStyle, aHiMode); return; } @@ -139,7 +148,7 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject } else { - aGlobOwner->HilightWithColor (myMainPM, theStyle, theMode); + aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode); } } @@ -154,24 +163,29 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo { const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + Handle(AIS_GlobalStatus) aStatus; + if (!myObjects.Find (anInteractive, aStatus)) + { + continue; + } + if (anOwner->IsAutoHilight()) { - const Standard_Integer aHiMode = anInteractive->HasHilightMode() ? anInteractive->HilightMode() : 0; - anOwner->Unhilight (myMainPM, aHiMode); + anOwner->Unhilight (myMainPM); if (theIsToHilightSubIntensity) { - if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn()) + if (aStatus->IsSubIntensityOn()) { + const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode()); highlightWithSubintensity (anOwner, aHiMode); } } } else { - if (!anObjToClear.Contains (anInteractive)) - anObjToClear.Add (anInteractive); + anObjToClear.Add (anInteractive); } - anOwner->State (0); + anOwner->SetSelected (Standard_False); if (anOwner == anInteractive->GlobalSelOwner()) { myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False); @@ -180,8 +194,7 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo for (NCollection_IndexedMap::Iterator anIter (anObjToClear); anIter.More(); anIter.Next()) { const Handle(AIS_InteractiveObject)& anObj = anIter.Value(); - const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; - myMainPM->Unhighlight (anObj, aHiMode); + myMainPM->Unhighlight (anObj); anObj->ClearSelected(); } } @@ -190,26 +203,27 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo //function : unhighlightGlobal //purpose : //======================================================================= -void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj, - const Standard_Integer theMode) const +void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const { if (theObj.IsNull()) + { return; - const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); + } + const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); if (aGlobOwner.IsNull()) { - myMainPM->Unhighlight (theObj, theMode); + myMainPM->Unhighlight (theObj); return; } if (aGlobOwner->IsAutoHilight()) { - aGlobOwner->Unhilight (myMainPM, theMode); + aGlobOwner->Unhilight (myMainPM); } else { - myMainPM->Unhighlight (theObj, theMode); + myMainPM->Unhighlight (theObj); theObj->ClearSelected(); } } @@ -222,9 +236,9 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj const Standard_Integer theDispMode, const Standard_Boolean theIsDisplayedOnly) const { - // the only differ with selection highlight is color, so - // sync transparency values - mySubintStyle->SetTransparency (mySelStyle->Transparency()); + // the only differ with selection highlight is color, so sync transparency values + const Handle(Prs3d_Drawer)& aSubStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity]; + aSubStyle->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency()); if (theObject.IsNull()) { @@ -235,13 +249,7 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj continue; aStatus->SubIntensityOn(); - - if (theDispMode == -1) - { - myMainPM->Color (anObjsIter.Key(), mySubintStyle, aStatus->DisplayMode()); - } - else - myMainPM->Color (anObjsIter.Key(), mySubintStyle, theDispMode); + myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode()); } } else @@ -251,16 +259,10 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj return; if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly) - return; + return; aStatus->SubIntensityOn(); - - if (theDispMode == -1) - { - myMainPM->Color (theObject, mySubintStyle, aStatus->DisplayMode()); - } - else - myMainPM->Color (theObject, mySubintStyle, theDispMode); + myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode()); } } @@ -273,9 +275,9 @@ void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_Interac { // the only differ with selection highlight is color, so // sync transparency values - mySubintStyle->SetTransparency (mySelStyle->Transparency()); + myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency()); - myMainPM->Color (theObject, mySubintStyle, theMode); + myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode); } //======================================================================= @@ -287,9 +289,9 @@ void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_E { // the only differ with selection highlight is color, so // sync transparency values - mySubintStyle->SetTransparency (mySelStyle->Transparency()); + myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency()); - theOwner->HilightWithColor (myMainPM, mySubintStyle, theMode); + theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode); } //======================================================================= @@ -372,11 +374,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) { myMainPM->ClearImmediateDraw(); - const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); - const Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0; if (!myLastPicked->IsSelected()) { - myLastPicked->Unhilight (myMainPM, aHiMod); + myLastPicked->Unhilight (myMainPM); toUpdateViewer = Standard_True; } else if (myToHilightSelected) @@ -412,13 +412,11 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) { myMainPM->ClearImmediateDraw(); - const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); - Standard_Integer aHiMod = aLastPickedAIS->HasHilightMode() ? aLastPickedAIS->HilightMode() : 0; if (!myLastPicked->IsSelected()) { if (myLastPicked->IsAutoHilight()) { - myLastPicked->Unhilight (myMainPM, aHiMod); + myLastPicked->Unhilight (myMainPM); } toUpdateViewer = Standard_True; } @@ -500,7 +498,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi continue; mySelection->Select (aCurOwner); - aCurOwner->State (1); + aCurOwner->SetSelected (Standard_True); } HilightSelected (toUpdateViewer); @@ -547,7 +545,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the continue; mySelection->Select (anOwner); - anOwner->State (1); + anOwner->SetSelected (Standard_True); } HilightSelected (toUpdateViewer); @@ -683,8 +681,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the continue; AIS_SelectStatus aSelStatus = mySelection->Select (anOwner); - Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; - anOwner->State (aState); + anOwner->SetSelected (aSelStatus == AIS_SS_Added); } HilightSelected (toUpdateViewer); @@ -732,8 +729,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d continue; AIS_SelectStatus aSelStatus = mySelection->Select (anOwner); - Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; - anOwner->State (aState); + anOwner->SetSelected (aSelStatus == AIS_SS_Added); } HilightSelected (toUpdateViewer); @@ -906,14 +902,14 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate { const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); - const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = getSelStyle (anObj); + const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner); + Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj); if (anOwner == anObj->GlobalSelOwner()) { - Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj); aState->SetHilightStatus (Standard_True); aState->SetHilightStyle (anObjSelStyle); } - anOwner->State (1); + anOwner->SetSelected (Standard_True); if (!anOwner->IsAutoHilight()) { NCollection_Handle aSeq; @@ -930,7 +926,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate } else { - const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; + const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode()); anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); } } @@ -968,9 +964,8 @@ void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpda myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False); } - anOwner->State (0); - const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HasHilightMode() : 0; - anOwner->Unhilight (myMainPM, aHiMode); + anOwner->SetSelected (Standard_False); + anOwner->Unhilight (myMainPM); } if (theToUpdateViewer) @@ -1020,24 +1015,34 @@ void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateV void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject, const Standard_Boolean theToUpdateViewer) { - if(HasOpenedContext()) + if (HasOpenedContext()) { return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer); } if (theObject.IsNull()) + { return; - if(!myObjects.IsBound (theObject)) + } + + if (!myObjects.IsBound (theObject)) + { Display (theObject, Standard_False); + } if (!theObject->HasSelection (theObject->GlobalSelectionMode())) + { return; + } + Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); + if (anOwner.IsNull()) + { + return; + } - const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = - getSelStyle (theObject); - + const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner); if (NbSelected() == 1 && myObjects (theObject)->IsHilighted()) { - Handle(Graphic3d_HighlightStyle) aCustomStyle; + Handle(Prs3d_Drawer) aCustomStyle; if (HighlightStyle (theObject, aCustomStyle)) { if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) @@ -1050,29 +1055,25 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t for (mySelection->Init(); mySelection->More(); mySelection->Next()) { - const Handle(SelectMgr_EntityOwner) anOwner = mySelection->Value(); - if (!myFilters->IsOk (anOwner)) + const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value(); + if (!myFilters->IsOk (aSelOwner)) { continue; } - Handle(AIS_InteractiveObject) aSelectable = - Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); + Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable()); Unhilight (aSelectable, Standard_False); - anOwner->State (0); - if (anOwner == aSelectable->GlobalSelOwner()) + aSelOwner->SetSelected (Standard_False); + if (aSelOwner == aSelectable->GlobalSelOwner()) { myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False); } } // added to avoid untimely viewer update... - Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); - if (anOwner.IsNull()) - return; mySelection->ClearAndSelect (anOwner); - Handle(Graphic3d_HighlightStyle) aCustomStyle; + Handle(Prs3d_Drawer) aCustomStyle; if (HighlightStyle (theObject, aCustomStyle)) { if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) @@ -1084,7 +1085,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t { HilightWithColor (theObject, anObjSelStyle, Standard_False); } - anOwner->State (1); + anOwner->SetSelected (Standard_True); if (theToUpdateViewer) UpdateCurrentViewer(); @@ -1100,14 +1101,11 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner)) return; - const Handle(AIS_InteractiveObject) anObject = - Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); - const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = - getSelStyle (anObject); - + const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner); if (NbSelected() == 1 && theOwner->IsSelected()) { - Handle(Graphic3d_HighlightStyle) aCustomStyle; + Handle(Prs3d_Drawer) aCustomStyle; if (HighlightStyle (theOwner, aCustomStyle)) { if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) @@ -1125,14 +1123,15 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t unhighlightSelected(); mySelection->ClearAndSelect (theOwner); - Handle(Graphic3d_HighlightStyle) aCustomStyle; + Handle(Prs3d_Drawer) aCustomStyle; if (!HighlightStyle (theOwner, aCustomStyle) || (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle)) { + theOwner->SetSelected (Standard_True); highlightSelected (theOwner); } - theOwner->State (1); + theOwner->SetSelected (Standard_True); if (theOwner == anObject->GlobalSelOwner()) { Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject); @@ -1206,31 +1205,32 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO return; AIS_SelectStatus aSelStat = mySelection->Select (theOwner); - - Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0; - theOwner->State (aState); + theOwner->SetSelected (aSelStat == AIS_SS_Added); const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner; Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj); - const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; - if (aState == 1) + if (theOwner->IsSelected()) { highlightSelected (theOwner); if (isGlobal) { aStatus->SetHilightStatus (Standard_True); - aStatus->SetHilightStyle (getSelStyle (anObj)); + aStatus->SetHilightStyle (getSelStyle (anObj, theOwner)); } } else { if (theOwner->IsAutoHilight()) - theOwner->Unhilight (myMainPM, aHiMode); + { + theOwner->Unhilight (myMainPM); + } else + { anObj->ClearSelected(); + } aStatus->SetHilightStatus (Standard_False); - aStatus->SetHilightStyle (new Graphic3d_HighlightStyle()); + aStatus->SetHilightStyle (Handle(Prs3d_Drawer)()); } if (theToUpdateViewer) @@ -1264,7 +1264,7 @@ Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_Interactiv if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull()) return Standard_False; - return theObj->GlobalSelOwner()->State() == 1; + return theObj->GlobalSelOwner()->IsSelected(); } //======================================================================= diff --git a/src/AIS/AIS_InteractiveContext_2.cxx b/src/AIS/AIS_InteractiveContext_2.cxx index e05c201518..48334f47ed 100644 --- a/src/AIS/AIS_InteractiveContext_2.cxx +++ b/src/AIS/AIS_InteractiveContext_2.cxx @@ -57,10 +57,8 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects, // the entities eventually detected just before the context was opened are unhighlighted... if(!IsSelected(myLastPicked)){ if(!myLastPicked.IsNull()){ - const Handle(AIS_InteractiveObject) aLastPickedAIS = - Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); - Standard_Integer HiMod = aLastPickedAIS->HasHilightMode()?aLastPickedAIS->HilightMode():0; - unhighlightGlobal (aLastPickedAIS, HiMod); + const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); + unhighlightGlobal (aLastPickedAIS); }} if(!mylastmoveview.IsNull()){ @@ -441,12 +439,10 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, if(GB->GraphicStatus() == AIS_DS_Displayed) { - myMainPM->Unhighlight (anIObj, GB->DisplayMode()); + myMainPM->Unhighlight (anIObj); UpdMain = Standard_True; } - Standard_Integer DM,HM,SM; - GetDefModes(anIObj,DM,HM,SM); if(IsSelected(anIObj)) highlightSelected (anIObj->GlobalSelOwner()); @@ -456,12 +452,11 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, } } else { - const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = - getSelStyle (anIObj); + const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anIObj, anIObj->GlobalSelOwner()); if(myObjects.IsBound(anIObj)){ const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); STAT->SubIntensityOff(); - myMainPM->Unhighlight (anIObj, STAT->DisplayMode()); + myMainPM->Unhighlight (anIObj); if (STAT->IsHilighted()) HilightWithColor (anIObj, anObjSelStyle, Standard_False); } @@ -814,8 +809,8 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie myMainPM->Display (iobj, STAT->DisplayMode()); if(STAT->IsHilighted()) { - const Handle(Graphic3d_HighlightStyle)& aStyle = STAT->HilightStyle(); - if (!aStyle.IsNull() && getSelStyle (iobj) != aStyle) + const Handle(Prs3d_Drawer)& aStyle = STAT->HilightStyle(); + if (!aStyle.IsNull() && getSelStyle (iobj, iobj->GlobalSelOwner()) != aStyle) HilightWithColor(iobj,aStyle,Standard_False); } //part selection @@ -838,21 +833,3 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie myMainVwr->Update(); } } - -//======================================================================= -//function : SetZDetection -//purpose : -//======================================================================= -void AIS_InteractiveContext::SetZDetection(const Standard_Boolean aStatus) -{ - myZDetectionFlag = aStatus; -} - -//======================================================================= -//function : ZDetection -//purpose : -//======================================================================= -Standard_Boolean AIS_InteractiveContext::ZDetection() const -{ - return myZDetectionFlag; -} diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index 4e8e65348d..33408d64b2 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -14,11 +14,10 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// Modified : 22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets +#include #include #include -#include #include #include #include @@ -50,22 +49,16 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject) //function : AIS_InteractiveObject //purpose : //======================================================================= -AIS_InteractiveObject:: -AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): -SelectMgr_SelectableObject(aTypeOfPresentation3d), -myTransparency(0.), -myOwnColor(Quantity_NOC_WHITE), -myOwnMaterial(Graphic3d_NOM_DEFAULT), -myHilightMode(-1), -myOwnWidth(0.0), -myInfiniteState(Standard_False), -hasOwnColor(Standard_False), -hasOwnMaterial(Standard_False), -myCurrentFacingModel(Aspect_TOFM_BOTH_SIDE), -myRecomputeEveryPrs(Standard_True), -myCTXPtr(NULL), -mySelPriority(-1), -myDisplayMode (-1) +AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) +: SelectMgr_SelectableObject (aTypeOfPresentation3d), + myCTXPtr (NULL), + myOwnWidth (0.0), + myOwnMaterial (Graphic3d_NOM_DEFAULT), + myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE), + myInfiniteState (Standard_False), + hasOwnColor (Standard_False), + hasOwnMaterial (Standard_False), + myRecomputeEveryPrs (Standard_True) { SetCurrentFacingModel(); } @@ -154,13 +147,15 @@ void AIS_InteractiveObject::ClearOwner() } //======================================================================= -//function : -//purpose : +//function : SetDisplayMode +//purpose : //======================================================================= -void AIS_InteractiveObject::SetDisplayMode(const Standard_Integer aMode) +void AIS_InteractiveObject::SetDisplayMode (const Standard_Integer theMode) { - if( AcceptDisplayMode(aMode) ) - myDisplayMode = aMode; + if (AcceptDisplayMode (theMode)) + { + myDrawer->SetDisplayMode (theMode); + } } //======================================================================= @@ -195,9 +190,9 @@ void AIS_InteractiveObject::SetColor(const Quantity_NameOfColor aColor) //purpose : //======================================================================= -void AIS_InteractiveObject::SetColor(const Quantity_Color &aColor) +void AIS_InteractiveObject::SetColor(const Quantity_Color& theColor) { - myOwnColor = aColor; + myDrawer->SetColor (theColor); hasOwnColor = Standard_True; } @@ -286,12 +281,12 @@ void AIS_InteractiveObject::UnsetMaterial() if (HasColor()) { - SetColor (myOwnColor); + SetColor (myDrawer->Color()); } if (IsTransparent()) { - SetTransparency (myTransparency); + SetTransparency (myDrawer->Transparency()); } } else @@ -320,7 +315,7 @@ void AIS_InteractiveObject::SetTransparency(const Standard_Real aValue) FMat.SetTransparency(aValue); BMat.SetTransparency(aValue); myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat); - myTransparency = aValue; + myDrawer->SetTransparency ((Standard_ShortReal )aValue); } //======================================================================= @@ -341,7 +336,7 @@ void AIS_InteractiveObject::UnsetTransparency() Handle (Prs3d_ShadingAspect) SA; myDrawer->SetShadingAspect(SA); } - myTransparency =0.0; + myDrawer->SetTransparency (0.0f); } //======================================================================= //function : Transparency @@ -349,7 +344,7 @@ void AIS_InteractiveObject::UnsetTransparency() //======================================================================= Standard_Real AIS_InteractiveObject::Transparency() const { - return (myTransparency<=0.05 ? 0 : myTransparency); + return (myDrawer->Transparency() <= 0.005f ? 0.0 : myDrawer->Transparency()); // Graphic3d_MaterialAspect Mat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); // return Mat.Transparency(); } @@ -365,7 +360,7 @@ void AIS_InteractiveObject::UnsetAttributes() hasOwnColor = Standard_False; hasOwnMaterial = Standard_False; myOwnWidth = 0.0; - myTransparency = 0.0; + myDrawer->SetTransparency (0.0f); } //======================================================================= @@ -430,8 +425,8 @@ void AIS_InteractiveObject::SetInfiniteState(const Standard_Boolean aFlag) //======================================================================= Standard_Boolean AIS_InteractiveObject::HasPresentation() const { - return !GetContext().IsNull() - && GetContext()->MainPrsMgr()->HasPresentation (this, myDisplayMode); + return HasInteractiveContext() + && myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode()); } //======================================================================= @@ -440,8 +435,14 @@ Standard_Boolean AIS_InteractiveObject::HasPresentation() const //======================================================================= Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const { - return HasPresentation() - ? GetContext()->MainPrsMgr()->Presentation (this, myDisplayMode)->Presentation() + if (!HasInteractiveContext()) + { + return Handle(Prs3d_Presentation)(); + } + + Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false); + return !aPrs.IsNull() + ? aPrs->Presentation() : Handle(Prs3d_Presentation)(); } @@ -517,12 +518,7 @@ void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer aMode, continue; } - Handle(Graphic3d_AspectFillArea3d) aFaceAsp = new Graphic3d_AspectFillArea3d(); - Handle(Graphic3d_AspectLine3d) aLineAsp = new Graphic3d_AspectLine3d(); - Handle(Graphic3d_AspectMarker3d) aPntAsp = new Graphic3d_AspectMarker3d(); - Handle(Graphic3d_AspectText3d) aTextAsp = new Graphic3d_AspectText3d(); - // TODO: Add methods for retrieving individual aspects from Graphic3d_Group - aGrp->GroupPrimitivesAspect(aLineAsp, aTextAsp, aPntAsp, aFaceAsp); + Handle(Graphic3d_AspectFillArea3d) aFaceAsp = aGrp->FillAreaAspect(); aFaceAsp->SetPolygonOffsets(aMode, aFactor, aUnits); aGrp->SetGroupPrimitivesAspect(aFaceAsp); } @@ -561,7 +557,7 @@ void AIS_InteractiveObject::PolygonOffsets(Standard_Integer& aMode, //======================================================================= void AIS_InteractiveObject::BoundingBox (Bnd_Box& theBndBox) { - if (myDisplayMode == -1) + if (myDrawer->DisplayMode() == -1) { if (!myPresentations.IsEmpty()) { @@ -599,7 +595,7 @@ void AIS_InteractiveObject::BoundingBox (Bnd_Box& theBndBox) { for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) { - if (myPresentations (aPrsIter).Mode() == myDisplayMode) + if (myPresentations (aPrsIter).Mode() == myDrawer->DisplayMode()) { const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation(); const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation(); diff --git a/src/AIS/AIS_InteractiveObject.hxx b/src/AIS/AIS_InteractiveObject.hxx index a4b6a3699f..f561de9d21 100644 --- a/src/AIS/AIS_InteractiveObject.hxx +++ b/src/AIS/AIS_InteractiveObject.hxx @@ -127,7 +127,7 @@ public: //! wireaspect field of the drawer, but for a vertex, only //! the point aspect field is affected by the color) //! WARNING : Do not forget to set the corresponding fields - //! here (hasOwnColor and myOwnColor) + //! here (hasOwnColor and myDrawer->SetColor()) Standard_EXPORT virtual void SetColor (const Quantity_NameOfColor aColor); //! Removes color settings. Only the Interactive Object @@ -215,7 +215,7 @@ public: //! Returns true if the Interactive Object has a display //! mode setting. Otherwise, it is displayed in Neutral Point. - Standard_Boolean HasDisplayMode() const { return myDisplayMode != -1; } + Standard_Boolean HasDisplayMode() const { return myDrawer->DisplayMode() != -1; } //! Sets the display mode aMode for the interactive object. //! An object can have its own temporary display mode, @@ -227,7 +227,7 @@ public: Standard_EXPORT void SetDisplayMode (const Standard_Integer aMode); //! Removes display mode settings from the interactive object. - void UnsetDisplayMode() { myDisplayMode = -1; } + void UnsetDisplayMode() { myDrawer->SetDisplayMode (-1); } //! Returns the display mode setting of the Interactive Object. //! The range of possibilities is the following: @@ -235,88 +235,59 @@ public: //! - AIS_Shaded //! This range can, however, be extended through the //! creation of new display modes. - Standard_Integer DisplayMode() const { return myDisplayMode; } - - //! Returns the selection priority setting. -1 indicates that there is none. - //! You can modify the selection priority of an owner to - //! make one entity more selectionable than another one. - //! The default selection priority for an owner is 5, for - //! example. To increase selection priority, choose a - //! setting between 5 and 10. An entity with priority 7 will - //! take priority over one with a setting of 6 if both - //! objects are selected at the same time. - //! You could give vertices priority 8, edges priority 7, - //! faces priority 6, and shapes priority 5. If a vertex, an - //! edge and a face are simultaneously detected during - //! selection, only the vertex will then be highlighted. - //! For trihedra, for example, the default priorities are the following four: - //! - priority 1 - a trihedron - //! - priority 5 - its origin - //! - priority 3 - its axes - //! - priority 2 - its planes - Standard_Integer SelectionPriority() const { return mySelPriority; } - - //! Allows you to provide a setting thePriority for selection priority. - //! You can modify selection priority of an owner to make - //! one entity more selectionable than another one. The - //! default selection priority for an owner is 5, for - //! example. To increase selection priority, choose a - //! setting between 5 and 10. An entity with priority 7 will - //! take priority over one with a setting of 6. - void SetSelectionPriority (const Standard_Integer thePriority) { mySelPriority = thePriority; } - - //! Removes the setting for selection priority. SelectionPriority then returns -1. - void UnsetSelectionPriority() { mySelPriority = -1; } - - //! Returns true if there is a setting for selection priority. - //! You can modify selection priority of an owner to make - //! one entity more selectionable than another one. The - //! default selection priority for an owner is 5, for - //! example. To increase selection priority, choose a - //! setting between 5 and 10. An entity with priority 7 will - //! take priority over one with a setting of 6. - Standard_Boolean HasSelectionPriority() const { return mySelPriority != -1; } + Standard_Integer DisplayMode() const { return myDrawer->DisplayMode(); } //! Returns true if the Interactive Object is in highlight mode. - Standard_Boolean HasHilightMode() const { return myHilightMode != -1; } - - //! Returns the setting for highlight mode. - //! At dynamic detection, the presentation echoed by the - //! Interactive Context, is by default the presentation - //! already on the screen. You can specify a Highlight - //! presentation mode which is valid no matter what the - //! active representation of the object. It makes no - //! difference whether this choice is temporary or - //! definitive. To do this, we use the following functions: - //! - SetHilightMode - //! - UnSetHilightMode - //! In the case of a shape, whether it is visualized in - //! wireframe presentation or with shading, we want to - //! systematically highlight the wireframe presentation. - //! Consequently, we set the highlight mode to 0. - Standard_Integer HilightMode() const { return myHilightMode; } - - //! Sets the highlight mode theMode for the interactive object. - //! If, for example, you want to systematically highlight - //! the wireframe presentation of a shape - whether - //! visualized in wireframe presentation or with shading - - //! you set the highlight mode to 0. - void SetHilightMode (const Standard_Integer theMode) { myHilightMode = theMode; } - - //! Allows the user to take a given Prs for hilight - //! ex : for a shape which would be displayed in shading mode - //! the hilight Prs is the wireframe mode. - //! if No specific hilight mode is defined, the displayed Prs - //! will be the hilighted one. - void UnsetHilightMode() { myHilightMode = -1; } + Standard_Boolean HasHilightMode() const { return !myHilightDrawer.IsNull() && myHilightDrawer->DisplayMode() != -1; } + + //! Returns highlight display mode. + //! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead. + Standard_Integer HilightMode() const { return !myHilightDrawer.IsNull() ? myHilightDrawer->DisplayMode() : -1; } + + //! Sets highlight display mode. + //! This is obsolete method for backward compatibility - use ::HilightAttributes() and ::DynamicHilightAttributes() instead. + void SetHilightMode (const Standard_Integer theMode) + { + if (myHilightDrawer.IsNull()) + { + myHilightDrawer = new Prs3d_Drawer(); + myHilightDrawer->Link (myDrawer); + myHilightDrawer->SetAutoTriangulation (Standard_False); + myHilightDrawer->SetColor (Quantity_NOC_GRAY80); + myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); + } + if (myDynHilightDrawer.IsNull()) + { + myDynHilightDrawer = new Prs3d_Drawer(); + myDynHilightDrawer->Link (myDrawer); + myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1); + myDynHilightDrawer->SetAutoTriangulation (Standard_False); + myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top); + } + myHilightDrawer ->SetDisplayMode (theMode); + myDynHilightDrawer->SetDisplayMode (theMode); + } + + //! Unsets highlight display mode. + void UnsetHilightMode() + { + if (!myHilightDrawer.IsNull()) + { + myHilightDrawer->SetDisplayMode (-1); + } + if (!myDynHilightDrawer.IsNull()) + { + myDynHilightDrawer->SetDisplayMode (-1); + } + } //! Returns true if the Interactive Object has color. Standard_Boolean HasColor() const { return hasOwnColor; } //! Returns the color setting of the Interactive Object. - virtual Quantity_NameOfColor Color() const { return myOwnColor.Name(); } + virtual Quantity_NameOfColor Color() const { return myDrawer->Color().Name(); } - virtual void Color (Quantity_Color& theColor) const { theColor = myOwnColor; } + virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); } //! Returns true if the Interactive Object has width. Standard_Boolean HasWidth() const { return myOwnWidth != 0.0; } @@ -359,7 +330,7 @@ public: Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6); //! Returns true if there is a transparency setting. - Standard_Boolean IsTransparent() const { return myTransparency > 0.005; } + Standard_Boolean IsTransparent() const { return myDrawer->Transparency() > 0.005f; } //! Returns the transparency setting. //! This will be between 0.0 and 1.0. @@ -440,29 +411,25 @@ private: protected: - //! The TypeOfPresention3d means that the interactive object //! may have a presentation dependant of the view of Display. Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); - Standard_Real myTransparency; - Quantity_Color myOwnColor; - Graphic3d_NameOfMaterial myOwnMaterial; - Standard_Integer myHilightMode; +private: + + AIS_InteractiveContext* myCTXPtr; + Handle(Standard_Transient) myOwner; + +protected: + + TColStd_ListOfInteger myToRecomputeModes; Standard_Real myOwnWidth; + Graphic3d_NameOfMaterial myOwnMaterial; + Aspect_TypeOfFacingModel myCurrentFacingModel; Standard_Boolean myInfiniteState; Standard_Boolean hasOwnColor; Standard_Boolean hasOwnMaterial; - Aspect_TypeOfFacingModel myCurrentFacingModel; Standard_Boolean myRecomputeEveryPrs; - TColStd_ListOfInteger myToRecomputeModes; - -private: - - AIS_InteractiveContext* myCTXPtr; - Handle(Standard_Transient) myOwner; - Standard_Integer mySelPriority; - Standard_Integer myDisplayMode; }; diff --git a/src/AIS/AIS_InteractiveObject.lxx b/src/AIS/AIS_InteractiveObject.lxx deleted file mode 100644 index cadc41bc0c..0000000000 --- a/src/AIS/AIS_InteractiveObject.lxx +++ /dev/null @@ -1,100 +0,0 @@ -// Created on: 1997-01-08 -// Created by: Robert COUBLANC -// Copyright (c) 1997-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 Standard_Boolean AIS_InteractiveObject::AcceptShapeDecomposition() const -{return Standard_False;} - - -inline Standard_Boolean AIS_InteractiveObject::IsInfinite() const -{return myInfiniteState;} - -inline Standard_Boolean AIS_InteractiveObject::HasColor() const -{return hasOwnColor;} - -inline const Handle(Standard_Transient)& -AIS_InteractiveObject::GetOwner() const -{return myOwner;} - -inline void AIS_InteractiveObject::SetOwner(const Handle(Standard_Transient)& ApplicativeEntity) -{myOwner = ApplicativeEntity;} - -inline const TColStd_ListOfTransient& -AIS_InteractiveObject::Users() const -{return myUsers;} - -inline Standard_Boolean AIS_InteractiveObject::HasDisplayMode() const -{return myDisplayMode!=-1;} - -inline void AIS_InteractiveObject::UnsetDisplayMode() -{myDisplayMode =-1;} - -inline Standard_Integer AIS_InteractiveObject::DisplayMode() const -{return myDisplayMode;} - -inline Quantity_NameOfColor AIS_InteractiveObject::Color() const -{ - return myOwnColor.Name(); -} - -inline void AIS_InteractiveObject::Color(Quantity_Color& aColor) const -{ - aColor = myOwnColor; -} - -inline Standard_Boolean AIS_InteractiveObject::HasWidth() const -{return !(myOwnWidth == 0.);} - -inline Standard_Real AIS_InteractiveObject::Width() const -{return myOwnWidth;} -inline Standard_Boolean AIS_InteractiveObject::HasMaterial() const -{return hasOwnMaterial;} - -//POP pour K4L -inline Graphic3d_NameOfMaterial AIS_InteractiveObject::Material() const -//inline Graphic3d_NameOfPhysicalMaterial AIS_InteractiveObject::Material() const -{return myOwnMaterial;} - -inline Standard_Boolean AIS_InteractiveObject::HasHilightMode() const -{return myHilightMode!=-1;} - -inline Standard_Integer AIS_InteractiveObject::HilightMode() const -{return myHilightMode;} - -inline void AIS_InteractiveObject::SetHilightMode(const Standard_Integer aMode) -{myHilightMode = aMode;} - -inline void AIS_InteractiveObject::UnsetHilightMode() -{myHilightMode = -1;} - - -inline Standard_Boolean AIS_InteractiveObject::IsTransparent() const -{return myTransparency >0.005;} - -inline Standard_Boolean AIS_InteractiveObject::HasSelectionPriority() const -{return mySelPriority != -1;} -inline void AIS_InteractiveObject::SetSelectionPriority(const Standard_Integer P) -{mySelPriority = P;} -inline void AIS_InteractiveObject::UnsetSelectionPriority() -{mySelPriority = -1;} -inline Standard_Integer AIS_InteractiveObject::SelectionPriority() const -{return mySelPriority;} - -inline Standard_Integer AIS_InteractiveObject::State() const -{return mystate;} - -inline void AIS_InteractiveObject::State(const Standard_Integer TheState) -{mystate = TheState;} - diff --git a/src/AIS/AIS_Line.cxx b/src/AIS/AIS_Line.cxx index b9229cf3ef..bcce3f6b52 100644 --- a/src/AIS/AIS_Line.cxx +++ b/src/AIS/AIS_Line.cxx @@ -166,7 +166,7 @@ void AIS_Line::SetColor(const Quantity_NameOfColor aCol) void AIS_Line::SetColor(const Quantity_Color &aCol) { hasOwnColor=Standard_True; - myOwnColor=aCol; + myDrawer->SetColor (aCol); Standard_Real WW = HasWidth()? myOwnWidth: myDrawer->HasLink() ? @@ -192,10 +192,10 @@ void AIS_Line::UnsetColor() if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); else{ Quantity_Color CC = Quantity_NOC_YELLOW; - if( HasColor() ) CC = myOwnColor; + if( HasColor() ) CC = myDrawer->Color(); else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); myDrawer->LineAspect()->SetColor(CC); - myOwnColor = CC; + myDrawer->SetColor (CC); } } @@ -209,7 +209,7 @@ void AIS_Line::SetWidth(const Standard_Real aValue) if (!myDrawer->HasOwnLineAspect ()) { Quantity_Color CC = Quantity_NOC_YELLOW; - if( HasColor() ) CC = myOwnColor; + if( HasColor() ) CC = myDrawer->Color(); else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); myDrawer->SetLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); } else diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 910d391081..a3e8119b73 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -78,9 +78,13 @@ mylastindex(0), mylastgood(0), myCurDetected(0), myAISCurDetected(0), -mySubintStyle (new Graphic3d_HighlightStyle (aCtx->SelectionStyle())) - +mySubintStyle (new Prs3d_Drawer()) { + mySubintStyle->Link (aCtx->SelectionStyle()); + mySubintStyle->SetColor (aCtx->SelectionStyle()->Color()); + mySubintStyle->SetTransparency (aCtx->SelectionStyle()->Transparency()); + mySubintStyle->SetMethod (aCtx->SelectionStyle()->Method()); + // bind self to AIS_InteractiveContext::myLocalContexts. Further, the // constructor executes logic that implies that the context is already // created and mapped. @@ -262,7 +266,7 @@ ClearPrs(const Handle(AIS_InteractiveObject)& anInteractive, if(STAT->IsSubIntensityOn()) { STAT->SubIntensityOff(); if(STAT->HilightMode()==aMode) - myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); + myMainPM->Unhighlight(anInteractive); } myMainPM->Clear(anInteractive,aMode); // correction connexions 23/09/97 jobdone = Standard_True; @@ -285,7 +289,7 @@ Erase(const Handle(AIS_InteractiveObject)& anInteractive) //Display step if(STAT->IsSubIntensityOn()) { STAT->SubIntensityOff(); - myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); + myMainPM->Unhighlight (anInteractive); } Standard_Boolean status(Standard_False); @@ -294,7 +298,9 @@ Erase(const Handle(AIS_InteractiveObject)& anInteractive) if(IsSelected(anInteractive)) AddOrRemoveSelected(anInteractive); if(myMainPM->IsHighlighted(anInteractive,STAT->HilightMode())) - myMainPM->Unhighlight(anInteractive,STAT->HilightMode()); + { + myMainPM->Unhighlight (anInteractive); + } myMainPM->SetVisibility (anInteractive, STAT->DisplayMode(), Standard_False); STAT->SetDisplayMode(-1); status = Standard_True; @@ -450,7 +456,7 @@ Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& a { if (Att->IsSubIntensityOn()) { - myMainPM->Unhighlight (aSelectable, Att->HilightMode()); + myMainPM->Unhighlight (aSelectable); } myMainPM->Erase (aSelectable, Att->DisplayMode()); @@ -681,7 +687,7 @@ void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) } const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); - myMainPM->Color(anObject, getHiStyle (anObject), Att->HilightMode()); + myMainPM->Color(anObject, myCTX->getHiStyle (anObject, anObject->GlobalSelOwner()), Att->HilightMode()); Att->SubIntensityOn(); } //======================================================================= @@ -690,7 +696,7 @@ void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) //======================================================================= void AIS_LocalContext::Hilight (const Handle(AIS_InteractiveObject)& theObj, - const Handle(Graphic3d_HighlightStyle)& theStyle) + const Handle(Prs3d_Drawer)& theStyle) { if (!myActiveObjects.IsBound (theObj)) { @@ -721,13 +727,13 @@ void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) Standard_ENABLE_DEPRECATION_WARNINGS const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); - myMainPM->Unhighlight(anObject,Att->HilightMode()); + myMainPM->Unhighlight (anObject); if(Att->IsTemporary() && Att->DisplayMode()==-1) if(!IsSomeWhereElse) myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); Att->SubIntensityOff(); - Att->SetHilightStyle (new Graphic3d_HighlightStyle()); + Att->SetHilightStyle (Handle(Prs3d_Drawer)()); } @@ -754,7 +760,7 @@ Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObjec } Standard_Boolean AIS_LocalContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObject, - Handle(Graphic3d_HighlightStyle)& theStyle) const + Handle(Prs3d_Drawer)& theStyle) const { if (!myActiveObjects.IsBound (theObject)) return Standard_False; @@ -975,17 +981,22 @@ void AIS_LocalContext::ClearObjects() // if object is temporary the presentations managed by myMainPM are removed AIS_DisplayStatus TheDS = myCTX->DisplayStatus(SO); - if(TheDS != AIS_DS_Displayed){ - if(myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())){ - if(CurAtt->IsSubIntensityOn()&& - myMainPM->IsHighlighted(SO,CurAtt->HilightMode())) - myMainPM->Unhighlight(SO,CurAtt->HilightMode()); - myMainPM->Erase(SO,CurAtt->DisplayMode()); - } - - if(CurAtt->IsTemporary()){ - myMainPM->Erase(SO,CurAtt->DisplayMode());} -// myMainPM->Clear(SO,CurAtt->DisplayMode());} + if(TheDS != AIS_DS_Displayed) + { + if (myMainPM->IsDisplayed(SO,CurAtt->DisplayMode())) + { + if (CurAtt->IsSubIntensityOn() && myMainPM->IsHighlighted (SO, CurAtt->HilightMode())) + { + myMainPM->Unhighlight (SO); + } + myMainPM->Erase (SO, CurAtt->DisplayMode()); + } + + if (CurAtt->IsTemporary()) + { + myMainPM->Erase (SO, CurAtt->DisplayMode()); + //myMainPM->Clear(SO,CurAtt->DisplayMode()); + } } else { if (CurAtt->IsSubIntensityOn()) diff --git a/src/AIS/AIS_LocalContext.hxx b/src/AIS/AIS_LocalContext.hxx index 1bbd5f5b64..90e6ec6071 100644 --- a/src/AIS/AIS_LocalContext.hxx +++ b/src/AIS/AIS_LocalContext.hxx @@ -303,14 +303,14 @@ public: Standard_EXPORT void Hilight (const Handle(AIS_InteractiveObject)& anObject); Standard_EXPORT void Hilight (const Handle(AIS_InteractiveObject)& theObj, - const Handle(Graphic3d_HighlightStyle)& theStyle); + const Handle(Prs3d_Drawer)& theStyle); Standard_EXPORT void Unhilight (const Handle(AIS_InteractiveObject)& anObject); Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& anObject) const; Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObject, - Handle(Graphic3d_HighlightStyle)& theStyle) const; + Handle(Prs3d_Drawer)& theStyle) const; //! Define the current selection sensitivity for //! this local context according to the view size. @@ -365,25 +365,8 @@ public: //! stored in local status Standard_EXPORT void RestoreActivatedModes() const; - - - DEFINE_STANDARD_RTTIEXT(AIS_LocalContext,MMgt_TShared) -protected: - - //! Helper function that returns correct dynamic highlight style for the object: - //! if custom style is defined via object's highlight drawer, it will be used. Otherwise, - //! dynamic highlight style of interactive context will be returned. - //! @param theObj [in] the object to check - Standard_EXPORT const Handle(Graphic3d_HighlightStyle)& getHiStyle (const Handle(SelectMgr_SelectableObject)& theObj) const; - - //! Helper function that returns correct selection style for the object: - //! if custom style is defined via object's highlight drawer, it will be used. Otherwise, - //! selection style of interactive context will be returned. - //! @param theObj [in] the object to check - Standard_EXPORT const Handle(Graphic3d_HighlightStyle)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj) const; - private: @@ -440,7 +423,7 @@ private: Standard_Integer myCurDetected; AIS_SequenceOfInteractive myAISDetectedSeq; Standard_Integer myAISCurDetected; - Handle(Graphic3d_HighlightStyle) mySubintStyle; + Handle(Prs3d_Drawer) mySubintStyle; }; diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 6a2a0887c4..3739620f3a 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -57,33 +57,6 @@ namespace TopoDS_Shape AIS_myDummyShape; } -static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO) -{ - return IO->HasHilightMode() ? IO->HilightMode():0; -} - -//======================================================================= -//function : getHiStyle -//purpose : -//======================================================================= -const Handle(Graphic3d_HighlightStyle)& AIS_LocalContext::getHiStyle (const Handle(SelectMgr_SelectableObject)& theObj) const -{ - const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes(); - return !aHiDrawer.IsNull() && aHiDrawer->HasOwnHighlightStyle() - ? aHiDrawer->HighlightStyle() : myCTX->HighlightStyle(); -} - -//======================================================================= -//function : getSelStyle -//purpose : -//======================================================================= -const Handle(Graphic3d_HighlightStyle)& AIS_LocalContext::getSelStyle (const Handle(AIS_InteractiveObject)& theObj) const -{ - const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes(); - return !aHiDrawer.IsNull() && aHiDrawer->HasOwnSelectionStyle() - ? aHiDrawer->SelectionStyle() : myCTX->SelectionStyle(); -} - //================================================== // Function: MoveTo // Purpose : @@ -502,9 +475,11 @@ void AIS_LocalContext::Hilight (const Handle(SelectMgr_EntityOwner)& theOwner, return; } - const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable())); + const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); + const Handle(Prs3d_Drawer)& aHiStyle = myCTX->getHiStyle (anObj, theOwner); + const Standard_Integer aHiMode = myCTX->getHilightMode (anObj, aHiStyle, -1); myMainPM->BeginImmediateDraw(); - theOwner->HilightWithColor (myMainPM, getHiStyle (theOwner->Selectable()), aHilightMode); + theOwner->HilightWithColor (myMainPM, aHiStyle, aHiMode); myMainPM->EndImmediateDraw (theView->Viewer()); } @@ -520,18 +495,19 @@ void AIS_LocalContext::Unhilight (const Handle(SelectMgr_EntityOwner)& theOwner, return; } - const Handle(AIS_InteractiveObject)& anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); - const Standard_Integer aHilightMode = GetHiMod (anObj); + const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); if (IsSelected (theOwner)) { if (theOwner->IsAutoHilight()) { - theOwner->HilightWithColor (myMainPM, getSelStyle (anObj), aHilightMode); + const Handle(Prs3d_Drawer)& aSelStyle = myCTX->getSelStyle (anObj, theOwner); + const Standard_Integer aHiMode = myCTX->getHilightMode (anObj, aSelStyle, -1); + theOwner->HilightWithColor (myMainPM, aSelStyle, aHiMode); } } else { - theOwner->Unhilight (myMainPM, aHilightMode); + theOwner->Unhilight (myMainPM); } } @@ -558,8 +534,9 @@ void AIS_LocalContext::HilightPicked (const Standard_Boolean theToUpdateviewer) if (anOwner->IsAutoHilight()) { Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(aSelObj); - const Standard_Integer aHighMode = GetHiMod (anIO); - anOwner->HilightWithColor (myMainPM, getSelStyle (anIO), aHighMode); + const Handle(Prs3d_Drawer)& aSelStyle = myCTX->getSelStyle (anIO, anOwner); + const Standard_Integer aHiMode = myCTX->getHilightMode (anIO, aSelStyle, -1); + anOwner->HilightWithColor (myMainPM, aSelStyle, aHiMode); continue; } @@ -606,8 +583,7 @@ void AIS_LocalContext::UnhilightPicked (const Standard_Boolean theToUpdateViewer Handle(SelectMgr_SelectableObject) aSelObj = anOwner->Selectable(); Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aSelObj); anObjMap.Add (aSelObj); - Standard_Integer aHighMode = GetHiMod (anIO); - anOwner->Unhilight (myMainPM, aHighMode); + anOwner->Unhilight (myMainPM); } for (NCollection_Map::Iterator aMapIter (anObjMap); @@ -1394,11 +1370,7 @@ Standard_Boolean AIS_LocalContext::UnhilightLastDetected (const Handle(V3d_View) myMainPM->BeginImmediateDraw(); const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (mylastindex); - const Standard_Integer aHilightMode = anOwner->HasSelectable() - ? GetHiMod (Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable())) - : 0; - - myMapOfOwner->FindKey (mylastindex)->Unhilight (myMainPM, aHilightMode); + anOwner->Unhilight (myMainPM); myMainPM->EndImmediateDraw (theView->Viewer()); mylastindex = 0; return Standard_True; diff --git a/src/AIS/AIS_LocalStatus.cxx b/src/AIS/AIS_LocalStatus.cxx index faa8e7351c..cef3f9eb0b 100644 --- a/src/AIS/AIS_LocalStatus.cxx +++ b/src/AIS/AIS_LocalStatus.cxx @@ -12,13 +12,12 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include + #include #include -IMPLEMENT_STANDARD_RTTIEXT(AIS_LocalStatus,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(AIS_LocalStatus, Standard_Transient) AIS_LocalStatus::AIS_LocalStatus (const Standard_Boolean theIsTemporary, const Standard_Boolean theIsToDecompose, @@ -26,7 +25,7 @@ AIS_LocalStatus::AIS_LocalStatus (const Standard_Boolean theIsTemporary, const Standard_Integer theSelectionMode, const Standard_Integer theHilightMode, const Standard_Boolean theIsSubIntensity, - const Handle(Graphic3d_HighlightStyle)& theStyle) + const Handle(Prs3d_Drawer)& theStyle) : myDecomposition (theIsToDecompose), myIsTemporary (theIsTemporary), myDMode (theDisplayMode), diff --git a/src/AIS/AIS_LocalStatus.hxx b/src/AIS/AIS_LocalStatus.hxx index 9315e350fa..f650019c78 100644 --- a/src/AIS/AIS_LocalStatus.hxx +++ b/src/AIS/AIS_LocalStatus.hxx @@ -17,33 +17,29 @@ #ifndef _AIS_LocalStatus_HeaderFile #define _AIS_LocalStatus_HeaderFile -#include -#include +#include +#include #include #include #include #include #include -class Standard_Transient; - -class AIS_LocalStatus; -DEFINE_STANDARD_HANDLE(AIS_LocalStatus, MMgt_TShared) +DEFINE_STANDARD_HANDLE(AIS_LocalStatus, Standard_Transient) //! Stored Info about temporary objects. -class AIS_LocalStatus : public MMgt_TShared +class AIS_LocalStatus : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(AIS_LocalStatus, Standard_Transient) public: - Standard_EXPORT AIS_LocalStatus (const Standard_Boolean theIsTemporary = Standard_True, const Standard_Boolean theIsToDecompose = Standard_False, const Standard_Integer theDisplayMode = -1, const Standard_Integer theSelectionMode = -1, const Standard_Integer theHilightMode = 0, const Standard_Boolean theIsSubIntensity = 0, - const Handle(Graphic3d_HighlightStyle)& theStyle = NULL); + const Handle(Prs3d_Drawer)& theStyle = Handle(Prs3d_Drawer)()); Standard_Boolean Decomposed() const; @@ -59,7 +55,7 @@ public: Standard_Boolean IsSubIntensityOn() const; - const Handle(Graphic3d_HighlightStyle)& HilightStyle() const + const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; } @@ -84,7 +80,7 @@ public: void SetHilightMode (const Standard_Integer aMode); - void SetHilightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) + void SetHilightStyle (const Handle(Prs3d_Drawer)& theStyle) { myHiStyle = theStyle; } @@ -97,11 +93,6 @@ public: const Handle(Standard_Transient)& PreviousState() const; - - - - DEFINE_STANDARD_RTTIEXT(AIS_LocalStatus,MMgt_TShared) - private: Standard_Boolean myDecomposition; Standard_Boolean myIsTemporary; @@ -111,14 +102,9 @@ private: TColStd_ListOfInteger mySModes; Standard_Boolean mySubIntensity; Handle(Standard_Transient) myPreviousState; - Handle(Graphic3d_HighlightStyle) myHiStyle; + Handle(Prs3d_Drawer) myHiStyle; }; - #include - - - - #endif // _AIS_LocalStatus_HeaderFile diff --git a/src/AIS/AIS_Manipulator.cxx b/src/AIS/AIS_Manipulator.cxx index ff0746caf3..dde6ed1498 100644 --- a/src/AIS/AIS_Manipulator.cxx +++ b/src/AIS/AIS_Manipulator.cxx @@ -873,7 +873,7 @@ void AIS_Manipulator::ClearSelected() //purpose : //======================================================================= void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner) { Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theOwner); diff --git a/src/AIS/AIS_Manipulator.hxx b/src/AIS/AIS_Manipulator.hxx index 6700c401c6..1562bb64f5 100644 --- a/src/AIS/AIS_Manipulator.hxx +++ b/src/AIS/AIS_Manipulator.hxx @@ -324,7 +324,7 @@ public: //! @name Presentation computation //! Method which hilight an owner belonging to //! this selectable object ( for fast presentation draw ). Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; protected: diff --git a/src/AIS/AIS_ManipulatorOwner.cxx b/src/AIS/AIS_ManipulatorOwner.cxx index 8aaa83181e..d57dab3d52 100644 --- a/src/AIS/AIS_ManipulatorOwner.cxx +++ b/src/AIS/AIS_ManipulatorOwner.cxx @@ -36,7 +36,7 @@ AIS_ManipulatorOwner::AIS_ManipulatorOwner (const Handle(SelectMgr_SelectableObj //purpose : //======================================================================= void AIS_ManipulatorOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode) { if (theMode == 0) @@ -75,5 +75,5 @@ void AIS_ManipulatorOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& return; } - thePM->Unhighlight (Selectable(), myMode); + thePM->Unhighlight (Selectable()); } diff --git a/src/AIS/AIS_ManipulatorOwner.hxx b/src/AIS/AIS_ManipulatorOwner.hxx index ac087856cb..10ce576a5e 100644 --- a/src/AIS/AIS_ManipulatorOwner.hxx +++ b/src/AIS/AIS_ManipulatorOwner.hxx @@ -38,7 +38,7 @@ public: Standard_EXPORT virtual ~AIS_ManipulatorOwner() {} Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode) Standard_OVERRIDE; Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 47b4303c8d..83c4b437d1 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -48,15 +48,18 @@ namespace } //! Selectable() method modified to return myAssembly. - virtual Handle(SelectMgr_SelectableObject) Selectable() const; + virtual Handle(SelectMgr_SelectableObject) Selectable() const Standard_OVERRIDE + { + return myAssembly; + } - Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode) const; + virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode) const Standard_OVERRIDE; - void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, - const Standard_Integer theMode); + virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Prs3d_Drawer)& theStyle, + const Standard_Integer theMode) Standard_OVERRIDE; - void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer aMode); + virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer aMode) Standard_OVERRIDE; private: @@ -77,15 +80,6 @@ SelectMgr_AssemblyEntityOwner::SelectMgr_AssemblyEntityOwner (const Handle(Selec { } -//======================================================================= -//function : Selectable -//purpose : -//======================================================================= -Handle(SelectMgr_SelectableObject) SelectMgr_AssemblyEntityOwner::Selectable() const -{ - return myAssembly; -} - //======================================================================= //function : IsHilighted //purpose : @@ -106,7 +100,7 @@ Standard_Boolean SelectMgr_AssemblyEntityOwner::IsHilighted (const Handle(PrsMgr //purpose : //======================================================================= void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode) { if (HasSelectable()) @@ -126,12 +120,12 @@ void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_Presen //function : Unhilight //purpose : //======================================================================= -void SelectMgr_AssemblyEntityOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) +void SelectMgr_AssemblyEntityOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, + const Standard_Integer ) { if (HasSelectable()) { - PM->Unhighlight (myAssembly, aMode); + thePrsMgr->Unhighlight (myAssembly); } } @@ -146,7 +140,6 @@ AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive() { myHasOwnPresentations = Standard_False; myAssemblyOwner = NULL; - SetHilightMode (0); } //======================================================================= diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index 86088627b8..bff45ce08f 100644 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -111,7 +111,6 @@ myIsXYZPlane(Standard_False), myTypeOfSensitivity (Select3D_TOS_BOUNDARY) { InitDrawerAttributes(); - SetHilightMode(0); } //======================================================================= @@ -130,8 +129,6 @@ myTypeOfSensitivity (Select3D_TOS_BOUNDARY) { InitDrawerAttributes(); ComputeFields(); - SetHilightMode(0); - } @@ -482,7 +479,7 @@ void AIS_Plane::SetColor(const Quantity_Color &aCol) myDrawer->ShadingAspect()->SetColor(aCol); hasOwnColor=Standard_True; - myOwnColor = aCol; + myDrawer->SetColor (aCol); } //======================================================================= //function : SetColor diff --git a/src/AIS/AIS_PlaneTrihedron.cxx b/src/AIS/AIS_PlaneTrihedron.cxx index 728520d7e2..67ca778b8d 100644 --- a/src/AIS/AIS_PlaneTrihedron.cxx +++ b/src/AIS/AIS_PlaneTrihedron.cxx @@ -252,7 +252,7 @@ void AIS_PlaneTrihedron::SetColor(const Quantity_NameOfColor aCol) void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol) { hasOwnColor=Standard_True; - myOwnColor = aCol; + myDrawer->SetColor (aCol); myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(aCol); myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(aCol); } diff --git a/src/AIS/AIS_Point.cxx b/src/AIS/AIS_Point.cxx index 916be5d52c..e6eaae105b 100644 --- a/src/AIS/AIS_Point.cxx +++ b/src/AIS/AIS_Point.cxx @@ -48,7 +48,14 @@ myComponent(aComponent), myHasTOM(Standard_False), myTOM(Aspect_TOM_PLUS) { - myHilightMode=-99; + myHilightDrawer = new Prs3d_Drawer(); + myHilightDrawer->SetDisplayMode (-99); + myHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0)); + myHilightDrawer->SetColor (Quantity_NOC_GRAY80); + myDynHilightDrawer = new Prs3d_Drawer(); + myDynHilightDrawer->SetDisplayMode (-99); + myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0)); + myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1); } //======================================================================= @@ -85,11 +92,8 @@ void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat StdPrs_Point::Add(aPresentation,myComponent,myDrawer); else if (aMode== -99) { - Handle(Graphic3d_AspectMarker3d) PtA = new Graphic3d_AspectMarker3d (); - PtA->SetType(Aspect_TOM_PLUS); - PtA->SetScale(3.); Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); - TheGroup->SetPrimitivesAspect(PtA); + TheGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect()); Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1); aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z()); TheGroup->AddPrimitiveArray (aPoint); @@ -134,10 +138,10 @@ void AIS_Point::SetColor(const Quantity_NameOfColor aCol) SetColor(Quantity_Color(aCol)); } -void AIS_Point::SetColor(const Quantity_Color &aCol) +void AIS_Point::SetColor (const Quantity_Color& theCol) { hasOwnColor=Standard_True; - myOwnColor=aCol; + myDrawer->SetColor (theCol); UpdatePointValues(); } @@ -199,10 +203,11 @@ void AIS_Point::UnsetMarker() //purpose : //======================================================================= - Standard_Boolean AIS_Point:: -AcceptDisplayMode(const Standard_Integer aMode) const -{return aMode == 0;} - + Standard_Boolean AIS_Point::AcceptDisplayMode (const Standard_Integer theMode) const +{ + return theMode == 0 + || theMode == -99; +} //======================================================================= //function : UpdatePointValues @@ -227,7 +232,7 @@ void AIS_Point::UpdatePointValues() aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale(); } - if(hasOwnColor) aCol = myOwnColor; + if(hasOwnColor) aCol = myDrawer->Color(); if(myOwnWidth!=0.0) aScale = myOwnWidth; if(myHasTOM) aTOM = myTOM; diff --git a/src/AIS/AIS_PointCloud.cxx b/src/AIS/AIS_PointCloud.cxx index 67038d8fb8..94460aa1ed 100644 --- a/src/AIS/AIS_PointCloud.cxx +++ b/src/AIS/AIS_PointCloud.cxx @@ -320,9 +320,9 @@ void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat) myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel); if (HasColor()) { - myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel); + myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel); } - myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel); + myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel); // modify shading presentation without re-computation const PrsMgr_Presentations& aPrsList = Presentations(); @@ -368,8 +368,8 @@ void AIS_PointCloud::UnsetMaterial() myCurrentFacingModel); if (HasColor()) { - myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel); - myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel); + myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel); + myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel); } } else diff --git a/src/AIS/AIS_Relation.cxx b/src/AIS/AIS_Relation.cxx index a3b64ee789..04e15f38d0 100644 --- a/src/AIS/AIS_Relation.cxx +++ b/src/AIS/AIS_Relation.cxx @@ -216,11 +216,11 @@ void AIS_Relation::SetColor(const Quantity_NameOfColor aCol) void AIS_Relation::SetColor(const Quantity_Color &aCol) { - if(hasOwnColor && myOwnColor==aCol) return; + if(hasOwnColor && myDrawer->Color() == aCol) return; if (!myDrawer->HasOwnTextAspect()) myDrawer->SetTextAspect(new Prs3d_TextAspect()); hasOwnColor=Standard_True; - myOwnColor=aCol; + myDrawer->SetColor (aCol); myDrawer->TextAspect()->SetColor(aCol); Standard_Real WW = HasWidth()? Width(): myDrawer->HasLink() ? diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 602472874c..484a33c968 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -90,7 +90,6 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant), myInitAng(0.) { Set (shap); - SetHilightMode(0); } //======================================================================= @@ -523,7 +522,7 @@ void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer, void AIS_Shape::SetColor (const Quantity_Color& theColor) { setColor (myDrawer, theColor); - myOwnColor = theColor; + myDrawer->SetColor (theColor); hasOwnColor = Standard_True; // modify shading presentation without re-computation @@ -903,8 +902,8 @@ void AIS_Shape::UnsetMaterial() } if (HasColor()) { - myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel); - myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel); + myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel); + myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel); } } else @@ -968,7 +967,7 @@ void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer, void AIS_Shape::SetTransparency (const Standard_Real theValue) { setTransparency (myDrawer, theValue); - myTransparency = theValue; + myDrawer->SetTransparency ((Standard_ShortReal )theValue); // modify shading presentation without re-computation const PrsMgr_Presentations& aPrsList = Presentations(); @@ -1004,7 +1003,7 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue) void AIS_Shape::UnsetTransparency() { - myTransparency = 0.0; + myDrawer->SetTransparency (0.0f); if (!myDrawer->HasOwnShadingAspect()) { return; diff --git a/src/AIS/AIS_TextLabel.cxx b/src/AIS/AIS_TextLabel.cxx index 5ba7e3773e..170cf5ada3 100644 --- a/src/AIS/AIS_TextLabel.cxx +++ b/src/AIS/AIS_TextLabel.cxx @@ -56,7 +56,7 @@ AIS_TextLabel::AIS_TextLabel() void AIS_TextLabel::SetColor (const Quantity_Color& theColor) { hasOwnColor = Standard_True; - myOwnColor = theColor; + myDrawer->SetColor (theColor); myDrawer->TextAspect()->SetColor (theColor); } diff --git a/src/AIS/AIS_Triangulation.cxx b/src/AIS/AIS_Triangulation.cxx index 189518fcc0..f4df8e4c27 100644 --- a/src/AIS/AIS_Triangulation.cxx +++ b/src/AIS/AIS_Triangulation.cxx @@ -56,7 +56,7 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue) // override transparency myDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel); - myTransparency = theValue; + myDrawer->SetTransparency ((Standard_ShortReal )theValue); updatePresentation(); } @@ -67,7 +67,7 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue) //======================================================================= void AIS_Triangulation::UnsetTransparency() { - myTransparency = 0.0; + myDrawer->SetTransparency (0.0f); if (!myDrawer->HasOwnShadingAspect()) { return; diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index 2bdee5f579..f97f8ab1bb 100644 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -436,7 +436,7 @@ void AIS_Trihedron::SetColor(const Quantity_NameOfColor aCol) void AIS_Trihedron::SetColor(const Quantity_Color &aCol) { hasOwnColor=Standard_True; - myOwnColor = aCol; + myDrawer->SetColor (aCol); if(!myDrawer->HasOwnDatumAspect()){ Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); @@ -587,16 +587,16 @@ AcceptDisplayMode(const Standard_Integer aMode) const void AIS_Trihedron::UnsetColor() { hasOwnColor=Standard_False; - myOwnColor = Quantity_NOC_LIGHTSTEELBLUE4; - myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(myOwnColor); - myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(myOwnColor); - myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(myOwnColor); + myDrawer->SetColor (Quantity_NOC_LIGHTSTEELBLUE4); + myDrawer->DatumAspect()->FirstAxisAspect() ->SetColor (myDrawer->Color()); + myDrawer->DatumAspect()->SecondAxisAspect()->SetColor (myDrawer->Color()); + myDrawer->DatumAspect()->ThirdAxisAspect() ->SetColor (myDrawer->Color()); if( HasTextColor() ) { - SetTextColor(myOwnColor.Name()); + SetTextColor(myDrawer->Color().Name()); myHasOwnTextColor = Standard_False; } if( HasArrowColor() ) { - SetArrowColor(myOwnColor.Name()); + SetArrowColor(myDrawer->Color().Name()); myHasOwnArrowColor = Standard_False; } diff --git a/src/AIS/FILES b/src/AIS/FILES index 67ec0e6747..fe0d904914 100644 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -74,7 +74,6 @@ AIS_FixRelation.hxx AIS_FixRelation.lxx AIS_GlobalStatus.cxx AIS_GlobalStatus.hxx -AIS_GlobalStatus.lxx AIS_GraphicTool.cxx AIS_GraphicTool.hxx AIS_IdenticRelation.cxx @@ -83,13 +82,11 @@ AIS_IdenticRelation.lxx AIS_IndexedDataMapOfOwnerPrs.hxx AIS_InteractiveContext.cxx AIS_InteractiveContext.hxx -AIS_InteractiveContext.lxx AIS_InteractiveContext_1.cxx AIS_InteractiveContext_2.cxx AIS_InteractiveContext_3.cxx AIS_InteractiveObject.cxx AIS_InteractiveObject.hxx -AIS_InteractiveObject.lxx AIS_KindOfDimension.hxx AIS_KindOfInteractive.hxx AIS_KindOfRelation.hxx diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index c42a5ebd96..321015c759 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -62,7 +62,8 @@ Graphic3d_GroupDefinitionError.hxx Graphic3d_HatchStyle.hxx Graphic3d_HatchStyle.cxx Graphic3d_HighlightStyle.hxx -Graphic3d_HighlightStyle.cxx +Graphic3d_PresentationAttributes.hxx +Graphic3d_PresentationAttributes.cxx Graphic3d_HorizontalTextAlignment.hxx Graphic3d_IndexBuffer.hxx Graphic3d_IndexedMapOfAddress.hxx diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index e874fc22ea..b9425584ed 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -101,7 +101,7 @@ public: //! Returns valid handle to highlight style of the structure in case if //! highlight flag is set to true - const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const { return myHighlightStyle; } + const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; } public: @@ -118,8 +118,8 @@ public: virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0; //! Highlights structure with the given style - virtual void GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle, - const Handle(Graphic3d_Structure)& theStruct) = 0; + virtual void GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle, + const Handle(Graphic3d_Structure)& theStruct) = 0; //! Unhighlights the structure and invalidates pointer to structure's highlight //! style @@ -167,7 +167,7 @@ protected: Handle(Geom_Transformation) myTrsf; Handle(Graphic3d_TransformPers) myTrsfPers; Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; - Handle(Graphic3d_HighlightStyle) myHighlightStyle; //! Current highlight style; is set only if highlight flag is true + Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //! Current highlight style; is set only if highlight flag is true public: diff --git a/src/Graphic3d/Graphic3d_HighlightStyle.hxx b/src/Graphic3d/Graphic3d_HighlightStyle.hxx index f9d945c072..e3329a2d04 100644 --- a/src/Graphic3d/Graphic3d_HighlightStyle.hxx +++ b/src/Graphic3d/Graphic3d_HighlightStyle.hxx @@ -16,102 +16,7 @@ #ifndef _Graphic3d_HighlightStyle_HeaderFile #define _Graphic3d_HighlightStyle_HeaderFile -#include -#include -#include -#include -#include - -//! A class for setting up highlight properties, such as: -//! - highlight method (box or some of object's presentations); -//! - highlight color; -//! - transparency coefficient. -class Graphic3d_HighlightStyle : public Standard_Transient -{ -public: - - //! Creates the style. Default parameters are: - //! - method: color; - //! - color: white; - //! - transparency: 0.f. - Graphic3d_HighlightStyle (const Aspect_TypeOfHighlightMethod theMethod = Aspect_TOHM_COLOR, - const Quantity_Color& theColor = Quantity_NOC_WHITE, - const Standard_ShortReal theTransparency = 0.f) - : myMethod (theMethod) - { - myColor.ChangeRGB() = theColor; - myColor.SetAlpha (1.f - theTransparency); - myColorFltPtr = new Graphic3d_Vec4 (myColor.GetRGB(), myColor.Alpha()); - }; - - //! Creates a copy of the given style - Graphic3d_HighlightStyle (const Handle(Graphic3d_HighlightStyle)& theOther) - : myMethod (theOther->myMethod), - myColor (theOther->myColor) - { - myColorFltPtr = new Graphic3d_Vec4 (myColor.GetRGB(), myColor.Alpha()); - }; - - //! Deletes color pointer stored for consistency with TKOpenGl - virtual ~Graphic3d_HighlightStyle() - { - delete myColorFltPtr; - myColorFltPtr = NULL; - } - - //! Changes current highlight method to the given one - void SetMethod (const Aspect_TypeOfHighlightMethod theMethod) - { - myMethod = theMethod; - } - - //! Returns current highlight method - Aspect_TypeOfHighlightMethod Method() const - { - return myMethod; - } - - //! Changes highlight color to the given one - void SetColor (const Quantity_Color& theColor) - { - myColor.ChangeRGB() = theColor; - myColorFltPtr->xyz() = theColor; - } - - //! Returns current highlight color - const Quantity_Color& Color() const - { - return myColor.GetRGB(); - } - - //! Changes transparency of a highlight presentation to the given one - void SetTransparency (const Standard_ShortReal theTranspCoef) - { - myColor.SetAlpha (1.f - theTranspCoef); - myColorFltPtr->a() = myColor.Alpha(); - } - - //! Returns current transparency of a highlight presentation - Standard_ShortReal Transparency() const - { - return 1.f - myColor.Alpha(); - } - - //! Returns pointer to current highlight color in RGBA format - const Graphic3d_Vec4* ColorFltPtr() const - { - return myColorFltPtr; - } - - DEFINE_STANDARD_RTTIEXT (Graphic3d_HighlightStyle, Standard_Transient) - -private: - - Aspect_TypeOfHighlightMethod myMethod; //!< Box or color highlighting - Quantity_ColorRGBA myColor; //!< 3-component highlight color with opacity - Graphic3d_Vec4* myColorFltPtr; //!< For consistency with TKOpenGl -}; - -DEFINE_STANDARD_HANDLE (Graphic3d_HighlightStyle, Standard_Transient) +// header file for deprecated type Graphic3d_HighlightStyle +#include #endif // _Graphic3d_HighlightStyle_HeaderFile diff --git a/src/Graphic3d/Graphic3d_HighlightStyle.cxx b/src/Graphic3d/Graphic3d_PresentationAttributes.cxx similarity index 84% rename from src/Graphic3d/Graphic3d_HighlightStyle.cxx rename to src/Graphic3d/Graphic3d_PresentationAttributes.cxx index 41327015e1..69ce5ae07e 100644 --- a/src/Graphic3d/Graphic3d_HighlightStyle.cxx +++ b/src/Graphic3d/Graphic3d_PresentationAttributes.cxx @@ -13,6 +13,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include -IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_HighlightStyle, Standard_Transient) +IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_PresentationAttributes, Standard_Transient) diff --git a/src/Graphic3d/Graphic3d_PresentationAttributes.hxx b/src/Graphic3d/Graphic3d_PresentationAttributes.hxx new file mode 100644 index 0000000000..0e7a76913c --- /dev/null +++ b/src/Graphic3d/Graphic3d_PresentationAttributes.hxx @@ -0,0 +1,105 @@ +// Created on: 2016-08-24 +// Created by: Varvara POSKONINA +// Copyright (c) 2016 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 _Graphic3d_PresentationAttributes_HeaderFile +#define _Graphic3d_PresentationAttributes_HeaderFile + +#include +#include +#include +#include +#include +#include + +//! Class defines presentation properties. +class Graphic3d_PresentationAttributes : public Standard_Transient +{ + DEFINE_STANDARD_RTTIEXT(Graphic3d_PresentationAttributes, Standard_Transient) +public: + + //! Empty constructor. + Graphic3d_PresentationAttributes() + : myBasicColor (Quantity_NOC_WHITE), + myHiMethod (Aspect_TOHM_COLOR), + myZLayer (Graphic3d_ZLayerId_Default), + myDispMode (0) + { + // + } + + //! Destructor. + virtual ~Graphic3d_PresentationAttributes() {} + + //! Returns highlight method, Aspect_TOHM_COLOR by default. + Aspect_TypeOfHighlightMethod Method() const { return myHiMethod; } + + //! Changes highlight method to the given one. + virtual void SetMethod (const Aspect_TypeOfHighlightMethod theMethod) { myHiMethod = theMethod; } + + //! Returns basic presentation color (including alpha channel). + const Quantity_ColorRGBA& ColorRGBA() const { return myBasicColor; } + + //! Returns basic presentation color, Quantity_NOC_WHITE by default. + const Quantity_Color& Color() const { return myBasicColor.GetRGB(); } + + //! Sets basic presentation color (RGB components, does not modifies transparency). + virtual void SetColor (const Quantity_Color& theColor) + { + myBasicColor.ChangeRGB() = theColor; + } + + //! Returns basic presentation transparency (0 - opaque, 1 - fully transparent), 0 by default (opaque). + Standard_ShortReal Transparency() const { return 1.0f - myBasicColor.Alpha(); } + + //! Sets basic presentation transparency (0 - opaque, 1 - fully transparent). + virtual void SetTransparency (const Standard_ShortReal theTranspCoef) + { + myBasicColor.SetAlpha (1.0f - theTranspCoef); + } + + //! Returns presentation Zlayer, Graphic3d_ZLayerId_Default by default. + //! Graphic3d_ZLayerId_UNKNOWN means undefined (a layer of main presentation to be used). + Graphic3d_ZLayerId ZLayer() const { return myZLayer; } + + //! Sets presentation Zlayer. + virtual void SetZLayer (const Graphic3d_ZLayerId theLayer) { myZLayer = theLayer; } + + //! Returns display mode, 0 by default. + //! -1 means undefined (main display mode of presentation to be used). + Standard_Integer DisplayMode() const { return myDispMode; } + + //! Sets display mode. + virtual void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; } + + //! Return basic presentation fill area aspect, NULL by default. + //! When set, might be used instead of Color() property. + const Handle(Graphic3d_AspectFillArea3d)& BasicFillAreaAspect() const { return myBasicFillAreaAspect; } + + //! Sets basic presentation fill area aspect. + virtual void SetBasicFillAreaAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { myBasicFillAreaAspect = theAspect; } + +protected: + + Handle(Graphic3d_AspectFillArea3d) myBasicFillAreaAspect; //!< presentation fill area aspect + Quantity_ColorRGBA myBasicColor; //!< presentation color + Aspect_TypeOfHighlightMethod myHiMethod; //!< box or color highlighting + Graphic3d_ZLayerId myZLayer; //!< Z-layer + Standard_Integer myDispMode; //!< display mode + +}; + +DEFINE_STANDARD_HANDLE (Graphic3d_PresentationAttributes, Standard_Transient) + +#endif // _Graphic3d_PresentationAttributes_HeaderFile diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 113799334d..35ef3e7a50 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -254,8 +254,8 @@ void Graphic3d_Structure::Erase() //function : Highlight //purpose : //============================================================================= -void Graphic3d_Structure::Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle, - const Standard_Boolean theToUpdateMgr) +void Graphic3d_Structure::Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle, + const Standard_Boolean theToUpdateMgr) { if (IsDeleted()) { @@ -322,7 +322,7 @@ void Graphic3d_Structure::UnHighlight() //function : HighlightStyle //purpose : //============================================================================= -const Handle(Graphic3d_HighlightStyle)& Graphic3d_Structure::HighlightStyle() const +const Handle(Graphic3d_PresentationAttributes)& Graphic3d_Structure::HighlightStyle() const { return myCStructure->HighlightStyle(); } diff --git a/src/Graphic3d/Graphic3d_Structure.hxx b/src/Graphic3d/Graphic3d_Structure.hxx index 358dc5eead..7ba30432dc 100644 --- a/src/Graphic3d/Graphic3d_Structure.hxx +++ b/src/Graphic3d/Graphic3d_Structure.hxx @@ -106,7 +106,7 @@ public: //! @param theStyle [in] the style (type of highlighting: box/color, color and opacity) //! @param theToUpdateMgr [in] defines whether related computed structures will be //! highlighted via structure manager or not - Standard_EXPORT void Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Boolean theToUpdateMgr = Standard_True); + Standard_EXPORT void Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle, const Standard_Boolean theToUpdateMgr = Standard_True); //! Suppress the structure . //! It will be erased at the next screen update. @@ -232,7 +232,7 @@ public: //! Returns the highlight color for the Highlight method //! with the highlight method TOHM_COLOR or TOHM_BOUNDBOX. - Standard_EXPORT const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const; + Standard_EXPORT const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const; //! Returns Standard_True if the structure is deleted. //! is deleted after the call Remove (me). diff --git a/src/Graphic3d/Graphic3d_ZLayerId.hxx b/src/Graphic3d/Graphic3d_ZLayerId.hxx index c8aefe23ed..5551c0cdf0 100644 --- a/src/Graphic3d/Graphic3d_ZLayerId.hxx +++ b/src/Graphic3d/Graphic3d_ZLayerId.hxx @@ -16,6 +16,8 @@ #ifndef _Graphic3d_ZLayerId_HeaderFile #define _Graphic3d_ZLayerId_HeaderFile +#include + typedef Standard_Integer Graphic3d_ZLayerId; //! This enumeration defines the list of predefined layers, which can not be removed (but settings can be overridden). diff --git a/src/MeshVS/MeshVS_Mesh.cxx b/src/MeshVS/MeshVS_Mesh.cxx index eed2b17486..372c53d0db 100644 --- a/src/MeshVS/MeshVS_Mesh.cxx +++ b/src/MeshVS/MeshVS_Mesh.cxx @@ -135,9 +135,6 @@ MeshVS_Mesh::MeshVS_Mesh (const Standard_Boolean theIsAllowOverlapped ) myHilightDrawer->SetInteger ( MeshVS_DA_MarkerType, Aspect_TOM_STAR ); myHilightDrawer->SetColor ( MeshVS_DA_MarkerColor, Quantity_NOC_GRAY80 ); myHilightDrawer->SetDouble ( MeshVS_DA_MarkerScale, 2.0 ); - - HilightAttributes()->SetSelectionStyle - (new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_GRAY80, 0.0)); } //================================================================ @@ -954,8 +951,7 @@ void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)& if (theOwners.Value (i) == GlobalSelOwner()) { const Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0; - const Handle(Graphic3d_HighlightStyle)& aSelStyle = GetContext().IsNull() - ? HilightAttributes()->SelectionStyle() : GetContext()->SelectionStyle(); + const Handle(Prs3d_Drawer)& aSelStyle = !HilightAttributes().IsNull() ? HilightAttributes() : GetContext()->SelectionStyle(); thePM->Color (this, aSelStyle, aHiMode); continue; } @@ -1064,7 +1060,7 @@ void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)& // Purpose : //================================================================ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner) { if (theOwner.IsNull()) diff --git a/src/MeshVS/MeshVS_Mesh.hxx b/src/MeshVS/MeshVS_Mesh.hxx index 90ea105cb6..22e8780978 100644 --- a/src/MeshVS/MeshVS_Mesh.hxx +++ b/src/MeshVS/MeshVS_Mesh.hxx @@ -65,7 +65,7 @@ public: //! Draw hilighted owner presentation Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theColor, + const Handle(Prs3d_Drawer)& theColor, const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; //! Clears internal selection presentation diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.cxx b/src/MeshVS/MeshVS_MeshEntityOwner.cxx index 9604ced648..247d8cac24 100644 --- a/src/MeshVS/MeshVS_MeshEntityOwner.cxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.cxx @@ -94,7 +94,7 @@ Standard_Boolean MeshVS_MeshEntityOwner::IsHilighted ( const Handle(PrsMgr_Prese // Purpose : //================================================================ void MeshVS_MeshEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer /*theMode*/ ) { Handle( SelectMgr_SelectableObject ) aSelObj; diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.hxx b/src/MeshVS/MeshVS_MeshEntityOwner.hxx index a3eb78a221..43db8e1ed5 100644 --- a/src/MeshVS/MeshVS_MeshEntityOwner.hxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.hxx @@ -62,7 +62,7 @@ public: //! Hilights owner with the certain color Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode = 0) Standard_OVERRIDE; //! Strip hilight of owner diff --git a/src/MeshVS/MeshVS_MeshOwner.cxx b/src/MeshVS/MeshVS_MeshOwner.cxx index b9c56b84f6..700e90b792 100644 --- a/src/MeshVS/MeshVS_MeshOwner.cxx +++ b/src/MeshVS/MeshVS_MeshOwner.cxx @@ -136,7 +136,7 @@ void MeshVS_MeshOwner::SetDetectedEntities (const Handle(TColStd_HPackedMapOfInt // Purpose : //================================================================ void MeshVS_MeshOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer /*theMode*/) { Handle( SelectMgr_SelectableObject ) aSelObj; @@ -171,10 +171,9 @@ void MeshVS_MeshOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager } } -void MeshVS_MeshOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& thePM, - const Standard_Integer theMode) +void MeshVS_MeshOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer ) { - SelectMgr_EntityOwner::Unhilight( thePM, theMode ); + SelectMgr_EntityOwner::Unhilight (thePM); Handle(TColStd_HPackedMapOfInteger) aNodes = GetDetectedNodes(); Handle(TColStd_HPackedMapOfInteger) aElems = GetDetectedElements(); diff --git a/src/MeshVS/MeshVS_MeshOwner.hxx b/src/MeshVS/MeshVS_MeshOwner.hxx index 93a5aa5e80..c67f9ba1d2 100644 --- a/src/MeshVS/MeshVS_MeshOwner.hxx +++ b/src/MeshVS/MeshVS_MeshOwner.hxx @@ -68,7 +68,7 @@ public: Standard_EXPORT void SetDetectedEntities (const Handle(TColStd_HPackedMapOfInteger)& Nodes, const Handle(TColStd_HPackedMapOfInteger)& Elems); Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theColor, + const Handle(Prs3d_Drawer)& theColor, const Standard_Integer theMode = 0) Standard_OVERRIDE; Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer Mode = 0) Standard_OVERRIDE; diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index cd271774ee..23b6337790 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -2843,16 +2843,19 @@ Handle(OpenGl_FrameBuffer) OpenGl_Context::SetDefaultFrameBuffer (const Handle(O // purpose : // ======================================================================= void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect, - const OpenGl_Vec4* theHighlightColor) + const Handle(Graphic3d_PresentationAttributes)& theHighlight) { if (!myActiveProgram.IsNull()) { + const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull()) + ? theHighlight->BasicFillAreaAspect() + : theAspect->Aspect(); myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE), - theAspect->Aspect()->ToMapTexture() ? 1 : 0); + anAspect->ToMapTexture() ? 1 : 0); myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE), - theAspect->Aspect()->Distinguish() ? 1 : 0); + anAspect->Distinguish() ? 1 : 0); OpenGl_Material aParams; for (Standard_Integer anIndex = 0; anIndex < 2; ++anIndex) @@ -2865,24 +2868,25 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect, continue; } - if (anIndex == 0 || !theAspect->Aspect()->Distinguish()) + if (anIndex == 0 || !anAspect->Distinguish()) { - const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->FrontMaterial(); - const Quantity_Color& aSrcIntColor = theAspect->Aspect()->InteriorColor(); + const Graphic3d_MaterialAspect& aSrcMat = anAspect->FrontMaterial(); + const Quantity_Color& aSrcIntColor = anAspect->InteriorColor(); aParams.Init (aSrcMat, aSrcIntColor); aParams.Diffuse.a() = 1.0f - (float )aSrcMat.Transparency(); } else { - const Graphic3d_MaterialAspect& aSrcMat = theAspect->Aspect()->BackMaterial(); - const Quantity_Color& aSrcIntColor = theAspect->Aspect()->BackInteriorColor(); + const Graphic3d_MaterialAspect& aSrcMat = anAspect->BackMaterial(); + const Quantity_Color& aSrcIntColor = anAspect->BackInteriorColor(); aParams.Init (aSrcMat, aSrcIntColor); aParams.Diffuse.a() = 1.0f - (float )aSrcMat.Transparency(); } - if (theHighlightColor != NULL) + if (!theHighlight.IsNull() + && theHighlight->BasicFillAreaAspect().IsNull()) { - aParams.SetColor (*theHighlightColor); - aParams.Diffuse.a() = theHighlightColor->a(); + aParams.SetColor (theHighlight->ColorRGBA()); + aParams.Diffuse.a() = theHighlight->ColorRGBA().Alpha(); } myActiveProgram->SetUniform (this, aLoc, OpenGl_Material::NbOfVec4(), diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index ac5e23b7ae..d74c2fc7d1 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -132,8 +132,8 @@ class OpenGl_ShaderManager; class OpenGl_Sampler; class OpenGl_FrameBuffer; class OpenGl_AspectFace; +class Graphic3d_PresentationAttributes; -class OpenGl_Context; DEFINE_STANDARD_HANDLE(OpenGl_Context, Standard_Transient) //! This class generalize access to the GL context and available extensions. @@ -624,7 +624,7 @@ public: //! @name methods to alter or retrieve current state //! Setup current shading material. Standard_EXPORT void SetShadingMaterial (const OpenGl_AspectFace* theAspect, - const OpenGl_Vec4* theHighlightColor = NULL); + const Handle(Graphic3d_PresentationAttributes)& theHighlight = Handle(Graphic3d_PresentationAttributes)()); //! Setup current color. Standard_EXPORT void SetColor4fv (const OpenGl_Vec4& theColor); diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 3132f4f102..b19a62c04d 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -811,7 +811,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace // All primitives should gather material properties from the AspectFace in shading mode if (isLightOn) { - aCtx->SetShadingMaterial (anAspectFace, theWorkspace->ToHighlight() ? theWorkspace->HighlightColor : NULL); + aCtx->SetShadingMaterial (anAspectFace, theWorkspace->HighlightStyle()); } if (!theWorkspace->ActiveTexture().IsNull() diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 9e12749317..4c08752c40 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -242,8 +242,8 @@ void OpenGl_Structure::highlightWithBndBox (const Handle(Graphic3d_Structure)& t // function : GraphicHighlight // purpose : // ======================================================================= -void OpenGl_Structure::GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle, - const Handle(Graphic3d_Structure)& theStruct) +void OpenGl_Structure::GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle, + const Handle(Graphic3d_Structure)& theStruct) { if (!myHighlightStyle.IsNull() && myHighlightStyle->Method() == Aspect_TOHM_BOUNDBOX @@ -485,7 +485,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con // Render named status if (highlight && myHighlightBox.IsNull()) { - theWorkspace->SetHighlight (true); + theWorkspace->SetHighlightStyle (myHighlightStyle); } // Apply local transformation @@ -543,11 +543,6 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con aCtx->core11fwd->glFrontFace (GL_CW); } - // Apply highlight color - const OpenGl_Vec4* aHighlightColor = theWorkspace->HighlightColor; - if (!myHighlightStyle.IsNull()) - theWorkspace->HighlightColor = myHighlightStyle->ColorFltPtr(); - // Collect clipping planes of structure scope aCtx->ChangeClipping().SetLocalPlanes (aCtx, myClipPlanes); @@ -683,9 +678,6 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con aCtx->WorldViewState.Pop(); } - // Restore highlight color - theWorkspace->HighlightColor = aHighlightColor; - // Restore aspects theWorkspace->SetAspectLine (aPrevAspectLine); theWorkspace->SetAspectFace (aPrevAspectFace); @@ -695,11 +687,12 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con // Apply highlight box if (!myHighlightBox.IsNull()) { + theWorkspace->SetHighlightStyle (myHighlightStyle); myHighlightBox->Render (theWorkspace); } // Restore named status - theWorkspace->SetHighlight (false); + theWorkspace->SetHighlightStyle (Handle(Graphic3d_PresentationAttributes)()); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index c35d324217..11d38ac9b6 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -88,8 +88,8 @@ public: //! Highlights structure according to the given style and updates corresponding class fields //! (highlight status and style) - Standard_EXPORT virtual void GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle, - const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE; + Standard_EXPORT virtual void GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle, + const Handle(Graphic3d_Structure)& theStruct) Standard_OVERRIDE; //! Unighlights structure and updates corresponding class fields (highlight status and style) Standard_EXPORT virtual void GraphicUnhighlight() Standard_OVERRIDE; diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index ce8a751ed0..b195bde43a 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -130,7 +130,6 @@ void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat, // ======================================================================= OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow) : NamedStatus (0), - HighlightColor (&THE_WHITE_COLOR), myView (theView), myWindow (theWindow), myGlContext (!theWindow.IsNull() ? theWindow->GetGlContext() : NULL), @@ -146,7 +145,6 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi ViewMatrix_applied (&myDefaultMatrix), StructureMatrix_applied (&myDefaultMatrix), myToAllowFaceCulling (false), - myToHighlight (false), myModelViewMatrix (myDefaultMatrix) { if (!myGlContext.IsNull() && myGlContext->MakeCurrent()) @@ -207,7 +205,7 @@ void OpenGl_Workspace::ResetAppliedAspect() myGlContext->BindDefaultVao(); NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0; - HighlightColor = &THE_WHITE_COLOR; + myHighlightStyle.Nullify(); myToAllowFaceCulling = false; myAspectLineSet = &myDefaultAspectLine; myAspectFaceSet = &myDefaultAspectFace; @@ -599,9 +597,9 @@ void OpenGl_Workspace::updateMaterial (const int theFlag) } myMatTmp.Init (*aSrcMat, *aSrcIntColor); - if (myToHighlight) + if (!myHighlightStyle.IsNull()) { - myMatTmp.SetColor (*HighlightColor); + myMatTmp.SetColor (myHighlightStyle->ColorRGBA()); } // handling transparency @@ -798,11 +796,11 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace() } if (myAspectFaceSet->Aspect() == myAspectFaceApplied - && myToHighlight == myAspectFaceAppliedWithHL) + && !myHighlightStyle.IsNull() == myAspectFaceAppliedWithHL) { return myAspectFaceSet; } - myAspectFaceAppliedWithHL = myToHighlight; + myAspectFaceAppliedWithHL = !myHighlightStyle.IsNull(); #if !defined(GL_ES_VERSION_2_0) const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle(); diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 77780926a9..58ef05592c 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -162,8 +162,6 @@ public: //// RELATED TO STATUS //// - const OpenGl_Vec4* HighlightColor; - //! Return true if active group might activate face culling (e.g. primitives are closed). bool ToAllowFaceCulling() const { return myToAllowFaceCulling; } @@ -173,57 +171,60 @@ public: void SetAllowFaceCulling (bool theToAllow) { myToAllowFaceCulling = theToAllow; } //! Return true if following structures should apply highlight color. - bool ToHighlight() const { return myToHighlight; } + bool ToHighlight() const { return !myHighlightStyle.IsNull(); } + + //! Return highlight style. + const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; } - //! Set highlight. - void SetHighlight (bool theToHighlight) { myToHighlight = theToHighlight; } + //! Set highlight style. + void SetHighlightStyle (const Handle(Graphic3d_PresentationAttributes)& theStyle) { myHighlightStyle = theStyle; } //! Return line color taking into account highlight flag. const OpenGl_Vec4& LineColor() const { - return myToHighlight - ? *HighlightColor - : myAspectLineSet->Aspect()->ColorRGBA(); + return !myHighlightStyle.IsNull() + ? myHighlightStyle->ColorRGBA() + : myAspectLineSet->Aspect()->ColorRGBA(); } //! Return edge color taking into account highlight flag. const OpenGl_Vec4& EdgeColor() const { - return myToHighlight - ? *HighlightColor - : myAspectFaceSet->AspectEdge()->Aspect()->ColorRGBA(); + return !myHighlightStyle.IsNull() + ? myHighlightStyle->ColorRGBA() + : myAspectFaceSet->AspectEdge()->Aspect()->ColorRGBA(); } //! Return marker color taking into account highlight flag. const OpenGl_Vec4& MarkerColor() const { - return myToHighlight - ? *HighlightColor - : myAspectMarkerSet->Aspect()->ColorRGBA(); + return !myHighlightStyle.IsNull() + ? myHighlightStyle->ColorRGBA() + : myAspectMarkerSet->Aspect()->ColorRGBA(); } //! Return Interior color taking into account highlight flag. const OpenGl_Vec4& InteriorColor() const { - return myToHighlight - ? *HighlightColor - : myAspectFaceSet->Aspect()->InteriorColorRGBA(); + return !myHighlightStyle.IsNull() + ? myHighlightStyle->ColorRGBA() + : myAspectFaceSet->Aspect()->InteriorColorRGBA(); } //! Return text color taking into account highlight flag. const OpenGl_Vec4& TextColor() const { - return myToHighlight - ? *HighlightColor - : myAspectTextSet->Aspect()->ColorRGBA(); + return !myHighlightStyle.IsNull() + ? myHighlightStyle->ColorRGBA() + : myAspectTextSet->Aspect()->ColorRGBA(); } //! Return text Subtitle color taking into account highlight flag. const OpenGl_Vec4& TextSubtitleColor() const { - return myToHighlight - ? *HighlightColor - : myAspectTextSet->Aspect()->ColorSubTitleRGBA(); + return !myHighlightStyle.IsNull() + ? myHighlightStyle->ColorRGBA() + : myAspectTextSet->Aspect()->ColorSubTitleRGBA(); } //! Currently set line aspect (can differ from applied). @@ -375,7 +376,7 @@ protected: //! @name fields related to status OpenGl_Material myMatBack; //!< current back material state OpenGl_Material myMatTmp; //!< temporary variable bool myToAllowFaceCulling; //!< allow back face culling - bool myToHighlight; //!< flag indicating highlighting mode + Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //!< active highlight style OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations diff --git a/src/Prs3d/FILES b/src/Prs3d/FILES index a982836f3d..d534f2e5c6 100755 --- a/src/Prs3d/FILES +++ b/src/Prs3d/FILES @@ -54,6 +54,7 @@ Prs3d_ToolQuadric.hxx Prs3d_ToolQuadric.cxx Prs3d_ToolSphere.hxx Prs3d_ToolSphere.cxx +Prs3d_TypeOfHighlight.hxx Prs3d_TypeOfHLR.hxx Prs3d_TypeOfLinePicking.hxx Prs3d_VertexDrawMode.hxx diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index 723cb72876..ea8e7c45f7 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -27,7 +27,7 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes) // ======================================================================= // function : Prs3d_Drawer @@ -94,10 +94,7 @@ Prs3d_Drawer::Prs3d_Drawer() myHasOwnDimLengthModelUnits (Standard_False), myHasOwnDimAngleModelUnits (Standard_False), myHasOwnDimLengthDisplayUnits (Standard_False), - myHasOwnDimAngleDisplayUnits (Standard_False), - - myHasOwnHighlightStyle (Standard_False), - myHasOwnSelectionStyle (Standard_False) + myHasOwnDimAngleDisplayUnits (Standard_False) { myDimensionModelUnits.SetLengthUnits ("m"); myDimensionModelUnits.SetAngleUnits ("rad"); @@ -1016,8 +1013,6 @@ void Prs3d_Drawer::ClearLocalAttributes() myDatumAspect.Nullify(); myDimensionAspect.Nullify(); mySectionAspect.Nullify(); - myHighlightStyle.Nullify(); - mySelectionStyle.Nullify(); myHasOwnUIsoAspect = Standard_False; myHasOwnVIsoAspect = Standard_False; @@ -1059,8 +1054,6 @@ void Prs3d_Drawer::ClearLocalAttributes() myHasOwnDimLengthDisplayUnits = Standard_False; myHasOwnDimAngleModelUnits = Standard_False; myHasOwnDimAngleDisplayUnits = Standard_False; - myHasOwnHighlightStyle = Standard_False; - myHasOwnSelectionStyle = Standard_False; myVertexDrawMode = Prs3d_VDM_Inherited; myTypeOfHLR = Prs3d_TOH_NotSet; @@ -1247,23 +1240,3 @@ void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP } } } - -// ======================================================================= -// function : SetHighlightStyle -// purpose : -// ======================================================================= -void Prs3d_Drawer::SetHighlightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) -{ - myHighlightStyle = theStyle; - myHasOwnHighlightStyle = !myHighlightStyle.IsNull(); -} - -// ======================================================================= -// function : SetSelectionStyle -// purpose : -// ======================================================================= -void Prs3d_Drawer::SetSelectionStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) -{ - mySelectionStyle = theStyle; - myHasOwnSelectionStyle = !mySelectionStyle.IsNull(); -} diff --git a/src/Prs3d/Prs3d_Drawer.hxx b/src/Prs3d/Prs3d_Drawer.hxx index f8541dfa70..56acba3908 100644 --- a/src/Prs3d/Prs3d_Drawer.hxx +++ b/src/Prs3d/Prs3d_Drawer.hxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,15 +42,14 @@ class Prs3d_DatumAspect; class Prs3d_DimensionAspect; class TCollection_AsciiString; -class Prs3d_Drawer; -DEFINE_STANDARD_HANDLE(Prs3d_Drawer, MMgt_TShared) +DEFINE_STANDARD_HANDLE(Prs3d_Drawer, Graphic3d_PresentationAttributes) //! A graphic attribute manager which governs how //! objects such as color, width, line thickness and deflection are displayed. //! A drawer includes an instance of the Aspect classes with particular default values. -class Prs3d_Drawer : public MMgt_TShared +class Prs3d_Drawer : public Graphic3d_PresentationAttributes { - + DEFINE_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes) public: //! Default constructor. @@ -824,36 +823,6 @@ public: //! that overrides the one in the link. Standard_Boolean HasOwnDimAngleDisplayUnits() const { return myHasOwnDimAngleDisplayUnits; } - //! Returns true if the drawer has its own style of dynamic highlighting - //! that overrides the one in the link - Standard_Boolean HasOwnHighlightStyle() const { return myHasOwnHighlightStyle; } - - //! Returns own dynamic highlight style or corresponding style of the link. If no one of - //! them is defined, invalid handle will be returned. - const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const - { - return HasOwnHighlightStyle() || myLink.IsNull() - ? myHighlightStyle : myLink->HighlightStyle(); - } - - //! Allows to set own dynamic highlight style. - Standard_EXPORT void SetHighlightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle); - - //! Returns true if the drawer has its own style of selection highlighting - //! that overrides the one in the link - Standard_Boolean HasOwnSelectionStyle() const { return myHasOwnSelectionStyle; } - - //! Returns own selection highlight style or corresponding style of the link. If no one of - //! them is defined, invalid handle will be returned. - const Handle(Graphic3d_HighlightStyle)& SelectionStyle() const - { - return HasOwnSelectionStyle() || myLink.IsNull() - ? mySelectionStyle : myLink->SelectionStyle(); - } - - //! Allows to set own selection highlight style. - Standard_EXPORT void SetSelectionStyle (const Handle(Graphic3d_HighlightStyle)& theStyle); - //! Returns the drawer to which the current object references. const Handle(Prs3d_Drawer)& Link() { return myLink; } @@ -861,10 +830,10 @@ public: Standard_Boolean HasLink() const { return !myLink.IsNull(); } //! Sets theDrawer as a link to which the current object references. - void Link (const Handle(Prs3d_Drawer)& theDrawer) - { - myLink = theDrawer; - } + void Link (const Handle(Prs3d_Drawer)& theDrawer) { SetLink (theDrawer); } + + //! Sets theDrawer as a link to which the current object references. + void SetLink (const Handle(Prs3d_Drawer)& theDrawer) { myLink = theDrawer; } //! Removes local attributes. Standard_EXPORT void ClearLocalAttributes(); @@ -968,15 +937,9 @@ protected: Standard_Boolean myHasOwnDimLengthDisplayUnits; Standard_Boolean myHasOwnDimAngleDisplayUnits; - Handle(Graphic3d_HighlightStyle) myHighlightStyle; - Standard_Boolean myHasOwnHighlightStyle; - Handle(Graphic3d_HighlightStyle) mySelectionStyle; - Standard_Boolean myHasOwnSelectionStyle; - -public: - - DEFINE_STANDARD_RTTIEXT(Prs3d_Drawer,MMgt_TShared) - }; +Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead") +typedef Prs3d_Drawer Graphic3d_HighlightStyle; + #endif // _Prs3d_Drawer_HeaderFile diff --git a/src/Prs3d/Prs3d_TypeOfHighlight.hxx b/src/Prs3d/Prs3d_TypeOfHighlight.hxx new file mode 100644 index 0000000000..d118333d00 --- /dev/null +++ b/src/Prs3d/Prs3d_TypeOfHighlight.hxx @@ -0,0 +1,29 @@ +// Copyright (c) 2016 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_TypeOfHighlight_HeaderFile +#define _Prs3d_TypeOfHighlight_HeaderFile + +//! Type of highlighting to apply specific style. +enum Prs3d_TypeOfHighlight +{ + Prs3d_TypeOfHighlight_None = 0, //!< no highlighting + Prs3d_TypeOfHighlight_Selected, //!< entire object is selected + Prs3d_TypeOfHighlight_Dynamic, //!< entire object is dynamically highlighted + Prs3d_TypeOfHighlight_LocalSelected, //!< part of the object is selected + Prs3d_TypeOfHighlight_LocalDynamic, //!< part of the object is dynamically highlighted + Prs3d_TypeOfHighlight_SubIntensity, //!< sub-intensity style + Prs3d_TypeOfHighlight_NB +}; + +#endif // _Prs3d_TypeOfHighlight_HeaderFile diff --git a/src/PrsMgr/FILES b/src/PrsMgr/FILES index fa76169037..44922a483d 100644 --- a/src/PrsMgr/FILES +++ b/src/PrsMgr/FILES @@ -7,11 +7,9 @@ PrsMgr_PresentableObject.hxx PrsMgr_PresentableObjectPointer.hxx PrsMgr_Presentation.cxx PrsMgr_Presentation.hxx -PrsMgr_Presentation.lxx PrsMgr_Presentation3d.hxx PrsMgr_PresentationManager.cxx PrsMgr_PresentationManager.hxx -PrsMgr_PresentationManager.lxx PrsMgr_PresentationManager3d.hxx PrsMgr_PresentationPointer.hxx PrsMgr_Presentations.hxx diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index bb2ee098ee..3886f0af66 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -23,7 +24,7 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient) namespace { @@ -44,13 +45,13 @@ const gp_Trsf& PrsMgr_PresentableObject::getIdentityTrsf() //purpose : //======================================================================= PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentation3d theType) -: myTypeOfPresentation3d (theType), +: myDrawer (new Prs3d_Drawer()), + myTypeOfPresentation3d (theType), myIsMutable (Standard_False), - myZLayer (Graphic3d_ZLayerId_Default), myHasOwnPresentations (Standard_True), myParent (NULL) { - // + myDrawer->SetDisplayMode (-1); } //======================================================================= @@ -407,12 +408,12 @@ void PrsMgr_PresentableObject::RemoveChild (const Handle(PrsMgr_PresentableObjec //======================================================================= void PrsMgr_PresentableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId) { - if (myZLayer == theLayerId) + if (myDrawer->ZLayer() == theLayerId) { return; } - myZLayer = theLayerId; + myDrawer->SetZLayer (theLayerId); for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) { const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIter); @@ -432,7 +433,7 @@ void PrsMgr_PresentableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId) //======================================================================= Graphic3d_ZLayerId PrsMgr_PresentableObject::ZLayer() const { - return myZLayer; + return myDrawer->ZLayer(); } // ======================================================================= @@ -532,3 +533,26 @@ void PrsMgr_PresentableObject::SetMutable (const Standard_Boolean theIsMutable) aModedPrs.Presentation()->Presentation()->SetMutable (theIsMutable); } } + +// ======================================================================= +// function : SetAttributes +// purpose : +// ======================================================================= +void PrsMgr_PresentableObject::SetAttributes (const Handle(Prs3d_Drawer)& theDrawer) +{ + myDrawer = theDrawer; +} + +// ======================================================================= +// function : UnsetAttributes +// purpose : +// ======================================================================= +void PrsMgr_PresentableObject::UnsetAttributes() +{ + Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer(); + if (myDrawer->HasLink()) + { + aDrawer->Link(myDrawer->Link()); + } + myDrawer = aDrawer; +} diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index 71d3fad6e8..89134b82e2 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -46,9 +46,11 @@ //! the relevant daughter classes and their member //! functions in AIS. This is particularly true in the //! creation of new interactive objects. -class PrsMgr_PresentableObject : public MMgt_TShared +class PrsMgr_PresentableObject : public Standard_Transient { - DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, MMgt_TShared) + DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentableObject, Standard_Transient) + friend class PrsMgr_Presentation; + friend class PrsMgr_PresentationManager; public: PrsMgr_Presentations& Presentations() { return myPresentations; } @@ -208,17 +210,32 @@ public: //! Returns parent of current object in scene hierarchy. PrsMgr_PresentableObjectPointer Parent() const { return myParent; } + //! Initializes the drawing tool theDrawer. + Standard_EXPORT virtual void SetAttributes(const Handle(Prs3d_Drawer)& theDrawer); -friend class PrsMgr_Presentation; -friend class PrsMgr_PresentationManager; -friend - Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector); -friend - Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Graphic3d_Structure)& theGivenStruct); -friend - Standard_EXPORT Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf); -friend - Standard_EXPORT void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)& theProjector, const Handle(Geom_Transformation)& theTrsf, const Handle(Graphic3d_Structure)& theGivenStruct); + //! Returns the attributes settings. + const Handle(Prs3d_Drawer)& Attributes() const + { + return myDrawer; + } + + //! Clears settings provided by the drawing tool theDrawer. + Standard_EXPORT virtual void UnsetAttributes(); + + //! Returns the hilight attributes settings. + const Handle(Prs3d_Drawer)& HilightAttributes() const { return myHilightDrawer; } + + //! Initializes the hilight drawing tool theDrawer. + virtual void SetHilightAttributes(const Handle(Prs3d_Drawer)& theDrawer) { myHilightDrawer = theDrawer; } + + //! Returns the hilight attributes settings. + const Handle(Prs3d_Drawer)& DynamicHilightAttributes() const { return myDynHilightDrawer; } + + //! Initializes the dynamic hilight drawing tool. + virtual void SetDynamicHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) { myDynHilightDrawer = theDrawer; } + + //! Clears settings provided by the hilight drawing tool theDrawer. + virtual void UnsetHilightAttributes() { myHilightDrawer.Nullify(); } protected: @@ -290,10 +307,12 @@ private: protected: PrsMgr_Presentations myPresentations; - PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; + Handle(Prs3d_Drawer) myDrawer; + Handle(Prs3d_Drawer) myHilightDrawer; + Handle(Prs3d_Drawer) myDynHilightDrawer; + PrsMgr_TypeOfPresentation3d myTypeOfPresentation3d; Standard_Boolean myIsMutable; - Graphic3d_ZLayerId myZLayer; Standard_Boolean myHasOwnPresentations; private: @@ -308,6 +327,6 @@ private: }; -DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, MMgt_TShared) +DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient) #endif // _PrsMgr_PresentableObject_HeaderFile diff --git a/src/PrsMgr/PrsMgr_Presentation.cxx b/src/PrsMgr/PrsMgr_Presentation.cxx index 23a73f7d91..75e8bc49c8 100644 --- a/src/PrsMgr/PrsMgr_Presentation.cxx +++ b/src/PrsMgr/PrsMgr_Presentation.cxx @@ -15,10 +15,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -29,7 +29,7 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_Presentation,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_Presentation, Standard_Transient) namespace { @@ -126,7 +126,7 @@ void PrsMgr_Presentation::SetVisible (const Standard_Boolean theValue) //function : Highlight //purpose : //======================================================================= -void PrsMgr_Presentation::Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle) +void PrsMgr_Presentation::Highlight (const Handle(Prs3d_Drawer)& theStyle) { if (!IsHighlighted()) { diff --git a/src/PrsMgr/PrsMgr_Presentation.hxx b/src/PrsMgr/PrsMgr_Presentation.hxx index 768a20e7bc..02c3d9fe20 100644 --- a/src/PrsMgr/PrsMgr_Presentation.hxx +++ b/src/PrsMgr/PrsMgr_Presentation.hxx @@ -17,64 +17,50 @@ #ifndef _PrsMgr_Presentation_HeaderFile #define _PrsMgr_Presentation_HeaderFile -#include -#include - #include +#include #include #include -#include +#include +#include #include #include + class PrsMgr_PresentationManager; class PrsMgr_Prs; class PrsMgr_PresentableObject; class Quantity_Color; class Geom_Transformation; class Prs3d_Presentation; -class Graphic3d_HighlightStyle; +class Prs3d_Drawer; class Graphic3d_Structure; class Graphic3d_DataStructureManager; class Prs3d_Projector; +DEFINE_STANDARD_HANDLE(PrsMgr_Presentation, Standard_Transient) -class PrsMgr_Presentation; -DEFINE_STANDARD_HANDLE(PrsMgr_Presentation, MMgt_TShared) - - -class PrsMgr_Presentation : public MMgt_TShared +class PrsMgr_Presentation : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(PrsMgr_Presentation, Standard_Transient) + friend class PrsMgr_PresentationManager; + friend class PrsMgr_PresentableObject; + friend class PrsMgr_Prs; public: - //! Destructor Standard_EXPORT ~PrsMgr_Presentation(); - - const Handle(Prs3d_Presentation)& Presentation() const; - - //! returns the PresentationManager in which the presentation has been created. - const Handle(PrsMgr_PresentationManager)& PresentationManager() const; - - void SetUpdateStatus (const Standard_Boolean theStat); - - Standard_Boolean MustBeUpdated() const; - -friend class PrsMgr_PresentationManager; -friend class PrsMgr_PresentableObject; -friend class PrsMgr_Prs; + const Handle(Prs3d_Presentation)& Presentation() const { return myStructure; } - DEFINE_STANDARD_RTTIEXT(PrsMgr_Presentation,MMgt_TShared) - -protected: - + //! returns the PresentationManager in which the presentation has been created. + const Handle(PrsMgr_PresentationManager)& PresentationManager() const { return myPresentationManager; } + void SetUpdateStatus (const Standard_Boolean theUpdateStatus) { myMustBeUpdated = theUpdateStatus; } + Standard_Boolean MustBeUpdated() const { return myMustBeUpdated; } private: - Standard_EXPORT PrsMgr_Presentation(const Handle(PrsMgr_PresentationManager)& thePresentationManager, const Handle(PrsMgr_PresentableObject)& thePresentableObject); Standard_EXPORT void Display(); @@ -86,7 +72,7 @@ private: Standard_EXPORT void SetVisible (const Standard_Boolean theValue); - Standard_EXPORT void Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle); + Standard_EXPORT void Highlight (const Handle(Prs3d_Drawer)& theStyle); Standard_EXPORT void Unhighlight() const; @@ -132,14 +118,6 @@ protected: Standard_Boolean myMustBeUpdated; Standard_Integer myBeforeHighlightState; - }; - -#include - - - - - #endif // _PrsMgr_Presentation_HeaderFile diff --git a/src/PrsMgr/PrsMgr_Presentation.lxx b/src/PrsMgr/PrsMgr_Presentation.lxx deleted file mode 100644 index 9be5c66910..0000000000 --- a/src/PrsMgr/PrsMgr_Presentation.lxx +++ /dev/null @@ -1,37 +0,0 @@ -// Created on: 1997-02-20 -// Created by: Robert COUBLANC -// Copyright (c) 1997-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 - -inline void PrsMgr_Presentation::SetUpdateStatus (const Standard_Boolean theUpdateStatus) -{ - myMustBeUpdated = theUpdateStatus; -} - -inline Standard_Boolean PrsMgr_Presentation::MustBeUpdated() const -{ - return myMustBeUpdated; -} - -inline const Handle(PrsMgr_PresentationManager)& PrsMgr_Presentation::PresentationManager() const -{ - return myPresentationManager; -} - -inline const Handle(Prs3d_Presentation)& PrsMgr_Presentation::Presentation() const -{ - return myStructure; -} diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 8da2864560..9a0aee8cfc 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -12,22 +12,23 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include +#include #include #include #include #include #include -#include #include #include #include #include #include -IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentationManager,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient) // ======================================================================= // function : PrsMgr_PresentationManager @@ -164,18 +165,24 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO // function : Unhighlight // purpose : // ======================================================================= -void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Standard_Integer theMode) +void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj) { for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) { - Unhighlight (anIter.Value(), theMode); + Unhighlight (anIter.Value()); } - const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode); - if (!aPrs.IsNull()) + const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations(); + for (Standard_Integer aPrsIter = 1; aPrsIter <= aPrsList.Length(); ++aPrsIter) { - aPrs->Unhighlight(); + const PrsMgr_ModedPresentation& aModedPrs = aPrsList.Value (aPrsIter); + const Handle(PrsMgr_Presentation)& aPrs = aModedPrs.Presentation(); + const Handle(PrsMgr_PresentationManager)& aPrsMgr = aPrs->PresentationManager(); + if (this == aPrsMgr + && aPrs->IsHighlighted()) + { + aPrs->Unhighlight(); + } } } @@ -565,13 +572,12 @@ void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObjec Presentation (thePrsObj, theMode)->SetTransformation (theTransformation); } - // ======================================================================= // function : Color // purpose : // ======================================================================= void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode, const Handle(PrsMgr_PresentableObject)& theSelObj, const Standard_Integer theImmediateStructLayerId) diff --git a/src/PrsMgr/PrsMgr_PresentationManager.hxx b/src/PrsMgr/PrsMgr_PresentationManager.hxx index 0d1c4f9af5..2d0b3634d2 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.hxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.hxx @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,26 +30,24 @@ #include class Geom_Transformation; +class Prs3d_Drawer; class Prs3d_Presentation; class PrsMgr_PresentableObject; class PrsMgr_Presentation; class Standard_NoSuchObject; class V3d_Viewer; -class PrsMgr_PresentationManager; -DEFINE_STANDARD_HANDLE(PrsMgr_PresentationManager, MMgt_TShared) +DEFINE_STANDARD_HANDLE(PrsMgr_PresentationManager, Standard_Transient) //! 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. -class PrsMgr_PresentationManager : public MMgt_TShared +class PrsMgr_PresentationManager : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentationManager, Standard_Transient) public: - - //! Creates a framework to manage displays and graphic entities with the 3D view theStructureManager. Standard_EXPORT PrsMgr_PresentationManager(const Handle(Graphic3d_StructureManager)& theStructureManager); @@ -69,10 +67,11 @@ public: //! Sets the visibility of presentable object. Standard_EXPORT void SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Boolean theValue); - //! Removes highlighting from the presentation of the - //! presentable object thePrsObject in this framework with the display mode theMode. - Standard_EXPORT void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); - + //! Removes highlighting from the presentation of the presentable object. + Standard_EXPORT void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject); + + Standard_DEPRECATED("Deprecated method Unhighlight() - argument theMode will be ignored") + void Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode) { Unhighlight (thePrsObject); (void )theMode; } //! Sets the display priority theNewPrior of the //! presentable object thePrsObject in this framework with the display mode theMode. @@ -119,13 +118,13 @@ public: Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer); //! Returns true if Presentation Manager is accumulating transient list of presentations to be displayed in immediate mode. - Standard_Boolean IsImmediateModeOn() const; + Standard_Boolean IsImmediateModeOn() const { return myImmediateModeOn > 0; } //! 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. Standard_EXPORT void Color (const Handle(PrsMgr_PresentableObject)& thePrsObject, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode = 0, const Handle(PrsMgr_PresentableObject)& theSelObj = NULL, const Graphic3d_ZLayerId theImmediateStructLayerId = Graphic3d_ZLayerId_Topmost); @@ -138,7 +137,7 @@ public: Standard_EXPORT void Transform (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(Geom_Transformation)& theTransformation, const Standard_Integer theMode = 0); //! Returns the structure manager. - const Handle(Graphic3d_StructureManager)& StructureManager() const; + const Handle(Graphic3d_StructureManager)& StructureManager() const { return myStructureManager; } //! Returns true if there is a presentation of the //! presentable object thePrsObject in this framework, thePrsObject having the display mode theMode. @@ -158,34 +157,24 @@ public: const Standard_Integer theMode = 0, const Handle(PrsMgr_PresentableObject)& theSelObj = NULL); - - - DEFINE_STANDARD_RTTIEXT(PrsMgr_PresentationManager,MMgt_TShared) - protected: - //! Removes a presentation of the presentable object thePrsObject to this framework. thePrsObject has the display mode theMode. Standard_EXPORT Standard_Boolean RemovePresentation (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); - Handle(Graphic3d_StructureManager) myStructureManager; - Standard_Integer myImmediateModeOn; - PrsMgr_ListOfPresentations myImmediateList; - PrsMgr_ListOfPresentations myViewDependentImmediateList; - - private: //! Handles the structures from and displays it separating view-dependent structures and taking into account //! structure visibility by setting proper affinity. void displayImmediate (const Handle(V3d_Viewer)& theViewer); -}; - - -#include - +protected: + Handle(Graphic3d_StructureManager) myStructureManager; + Standard_Integer myImmediateModeOn; + PrsMgr_ListOfPresentations myImmediateList; + PrsMgr_ListOfPresentations myViewDependentImmediateList; +}; #endif // _PrsMgr_PresentationManager_HeaderFile diff --git a/src/PrsMgr/PrsMgr_PresentationManager.lxx b/src/PrsMgr/PrsMgr_PresentationManager.lxx deleted file mode 100644 index 9724f0c77f..0000000000 --- a/src/PrsMgr/PrsMgr_PresentationManager.lxx +++ /dev/null @@ -1,25 +0,0 @@ -// Created on: 1998-04-23 -// 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 Standard_Boolean PrsMgr_PresentationManager::IsImmediateModeOn() const -{ - return myImmediateModeOn > 0; -} - -inline const Handle(Graphic3d_StructureManager)& PrsMgr_PresentationManager::StructureManager() const -{ - return myStructureManager; -} diff --git a/src/QABugs/QABugs_16.cxx b/src/QABugs/QABugs_16.cxx index 1db4da551f..e90a988d39 100644 --- a/src/QABugs/QABugs_16.cxx +++ b/src/QABugs/QABugs_16.cxx @@ -156,7 +156,7 @@ static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, c Handle(AIS_InteractiveObject) aCircle=new AIS_Circle(ahCircle); myAISContext->Display(aCircle); - const Handle(Graphic3d_HighlightStyle)& aSelStyle = myAISContext->SelectionStyle(); + const Handle(Prs3d_Drawer)& aSelStyle = myAISContext->SelectionStyle(); aSelStyle->SetColor (Quantity_NOC_BLUE1); myAISContext->AddOrRemoveSelected(aTrihedron); diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index c2b877059c..f432d89273 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -5309,10 +5309,21 @@ static Standard_Integer OCC27818 (Draw_Interpretor& /*theDI*/, Standard_Integer aBoxObjs[aBoxIdx]->SetHilightMode (AIS_Shaded); } - aBoxObjs[1]->HilightAttributes()->SetHighlightStyle (new Graphic3d_HighlightStyle ( - Aspect_TOHM_COLOR, Quantity_NOC_RED, 0.8f)); - aBoxObjs[2]->HilightAttributes()->SetSelectionStyle (new Graphic3d_HighlightStyle ( - Aspect_TOHM_COLOR, Quantity_NOC_RED, 0.0f)); + { + Handle(Prs3d_Drawer) aHiStyle = new Prs3d_Drawer(); + aBoxObjs[1]->SetDynamicHilightAttributes (aHiStyle); + aHiStyle->SetDisplayMode (AIS_Shaded); + aHiStyle->SetColor (Quantity_NOC_RED); + aHiStyle->SetTransparency (0.8f); + } + { + Handle(Prs3d_Drawer) aSelStyle = new Prs3d_Drawer(); + aBoxObjs[2]->SetHilightAttributes (aSelStyle); + aSelStyle->SetDisplayMode (AIS_Shaded); + aSelStyle->SetColor (Quantity_NOC_RED); + aSelStyle->SetTransparency (0.0f); + aSelStyle->SetZLayer (Graphic3d_ZLayerId_Topmost); + } for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx) { diff --git a/src/QABugs/QABugs_9.cxx b/src/QABugs/QABugs_9.cxx index 1daa6a2ab1..86e931cd53 100644 --- a/src/QABugs/QABugs_9.cxx +++ b/src/QABugs/QABugs_9.cxx @@ -128,21 +128,6 @@ static Standard_Integer OCC137 (Draw_Interpretor& di, Standard_Integer argc, con return 0; } -static Standard_Integer OCC137_z (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if(aContext.IsNull()) { - di << argv[0] << "ERROR : use 'vinit' command before \n"; - return 1; - } - if ( argc != 1 && argc != 2) { - di << "ERROR : Usage : " << argv[0] << " [ZDetection_mode]\n"; - return 1; - } - aContext->SetZDetection(((argc == 1 || (argc == 2 && Draw::Atoi(argv[1]) == 1)) ? Standard_True : Standard_False)); - return 0; -} - #include #include #include @@ -221,7 +206,6 @@ void QABugs::Commands_9(Draw_Interpretor& theCommands) { theCommands.Add ("BUC60857", "BUC60857", __FILE__, BUC60857, group); theCommands.Add("OCC137","OCC137 mode [shape]",__FILE__,OCC137,group); - theCommands.Add("OCC137_z","OCC137_z [ZDetection_mode]",__FILE__,OCC137_z,group); theCommands.Add("OCC24303", "OCC24303 SolID ", __FILE__, OCC24303,group); return; diff --git a/src/SelectBasics/SelectBasics_EntityOwner.cxx b/src/SelectBasics/SelectBasics_EntityOwner.cxx index f9473f72bf..fef12b0e95 100644 --- a/src/SelectBasics/SelectBasics_EntityOwner.cxx +++ b/src/SelectBasics/SelectBasics_EntityOwner.cxx @@ -14,18 +14,16 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include -#include -#include -IMPLEMENT_STANDARD_RTTIEXT(SelectBasics_EntityOwner,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(SelectBasics_EntityOwner, Standard_Transient) //======================================== -// Function : Create -// Purpose : +// Function : SelectBasics_EntityOwner +// Purpose : //======================================== -SelectBasics_EntityOwner -::SelectBasics_EntityOwner (const Standard_Integer aPriority): -mypriority(aPriority) -{} +SelectBasics_EntityOwner::SelectBasics_EntityOwner (const Standard_Integer thePriority) +: mypriority (thePriority) +{ + // +} diff --git a/src/SelectBasics/SelectBasics_EntityOwner.hxx b/src/SelectBasics/SelectBasics_EntityOwner.hxx index 507e1a006b..566960c283 100644 --- a/src/SelectBasics/SelectBasics_EntityOwner.hxx +++ b/src/SelectBasics/SelectBasics_EntityOwner.hxx @@ -18,16 +18,11 @@ #define _SelectBasics_EntityOwner_HeaderFile #include -#include - #include -#include +#include +#include #include -class TopLoc_Location; - - -class SelectBasics_EntityOwner; -DEFINE_STANDARD_HANDLE(SelectBasics_EntityOwner, MMgt_TShared) +#include //! defines an abstract owner of sensitive primitives. //! Owners are typically used to establish a connection @@ -44,50 +39,39 @@ DEFINE_STANDARD_HANDLE(SelectBasics_EntityOwner, MMgt_TShared) //! a user can give vertex priority [3], edges [2] faces [1] shape [0], //! so that if during selection one vertex one edge and one face are //! simultaneously detected, the vertex will only be hilighted. -class SelectBasics_EntityOwner : public MMgt_TShared +class SelectBasics_EntityOwner : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(SelectBasics_EntityOwner, Standard_Transient) public: - //! sets the selectable priority of the owner - void Set (const Standard_Integer aPriority); - - Standard_Integer Priority() const; - + void SetPriority (const Standard_Integer thePriority) { mypriority = thePriority; } + + Standard_Integer Priority() const { return mypriority; } + Standard_EXPORT virtual Standard_Boolean HasLocation() const = 0; - + Standard_EXPORT virtual void SetLocation (const TopLoc_Location& aLoc) = 0; - + Standard_EXPORT virtual void ResetLocation() = 0; - + Standard_EXPORT virtual TopLoc_Location Location() const = 0; +public: + //! sets the selectable priority of the owner + void Set (const Standard_Integer thePriority) { SetPriority (thePriority); } +protected: - DEFINE_STANDARD_RTTIEXT(SelectBasics_EntityOwner,MMgt_TShared) + Standard_EXPORT SelectBasics_EntityOwner (const Standard_Integer thePriority = 0); protected: - - Standard_EXPORT SelectBasics_EntityOwner(const Standard_Integer aPriority = 0); - Standard_Integer mypriority; - -private: - - - - }; - -#include - - - - +DEFINE_STANDARD_HANDLE(SelectBasics_EntityOwner, Standard_Transient) #endif // _SelectBasics_EntityOwner_HeaderFile diff --git a/src/SelectMgr/FILES b/src/SelectMgr/FILES index 6997ac27cd..b01ff670af 100755 --- a/src/SelectMgr/FILES +++ b/src/SelectMgr/FILES @@ -9,7 +9,6 @@ SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors.hxx SelectMgr_DataMapOfObjectSelectors.hxx SelectMgr_EntityOwner.cxx SelectMgr_EntityOwner.hxx -SelectMgr_EntityOwner.lxx SelectMgr_Filter.cxx SelectMgr_Filter.hxx SelectMgr_Frustum.hxx diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index 76241fd123..ca0e6746bc 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -14,10 +14,9 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include -#include #include #include #include @@ -25,84 +24,101 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner) //================================================== -// Function: +// Function: SelectMgr_EntityOwner // Purpose : //================================================== -SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Standard_Integer aPriority): -SelectBasics_EntityOwner(aPriority), -mySelectable(NULL), -myIsSelected (Standard_False) +SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Standard_Integer thePriority) +: SelectBasics_EntityOwner (thePriority), + mySelectable (NULL), + myIsSelected (Standard_False), + myFromDecomposition (Standard_False) { + // } -SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO, - const Standard_Integer aPriority): -SelectBasics_EntityOwner(aPriority), -myIsSelected (Standard_False) +//================================================== +// Function: SelectMgr_EntityOwner +// Purpose : +//================================================== +SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_SelectableObject)& theSelObj, + const Standard_Integer thePriority) +: SelectBasics_EntityOwner (thePriority), + mySelectable (theSelObj.operator->()), + myIsSelected (Standard_False), + myFromDecomposition (Standard_False) { - mySelectable = aSO.operator->(); + // } -SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority) -: - SelectBasics_EntityOwner(aPriority), - mySelectable (theOwner->mySelectable) +//================================================== +// Function: SelectMgr_EntityOwner +// Purpose : +//================================================== +SelectMgr_EntityOwner::SelectMgr_EntityOwner (const Handle(SelectMgr_EntityOwner)& theOwner, + const Standard_Integer thePriority) +: SelectBasics_EntityOwner (thePriority), + mySelectable (theOwner->mySelectable), + myIsSelected (Standard_False), + myFromDecomposition (Standard_False) { + // } - //======================================================================= -//function : About Selectable... -//purpose : +//function : SetSelectable +//purpose : //======================================================================= -void SelectMgr_EntityOwner::Set(const Handle(SelectMgr_SelectableObject)& aSO) +void SelectMgr_EntityOwner::SetSelectable (const Handle(SelectMgr_SelectableObject)& theSelObj) { - mySelectable = aSO.operator->(); -} - -Standard_Boolean SelectMgr_EntityOwner::HasSelectable() const -{ - return mySelectable != NULL; + mySelectable = theSelObj.operator->(); } +//======================================================================= +//function : Selectable +//purpose : +//======================================================================= Handle(SelectMgr_SelectableObject) SelectMgr_EntityOwner::Selectable() const { return mySelectable; } //======================================================================= -//function : about Hilight -//purpose : +//function : IsHilighted +//purpose : //======================================================================= -Standard_Boolean SelectMgr_EntityOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) const -{if(HasSelectable()) - return PM->IsHighlighted(mySelectable,aMode); - return Standard_False; +Standard_Boolean SelectMgr_EntityOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePrsMgr, + const Standard_Integer theMode) const +{ + return mySelectable != NULL + && thePrsMgr->IsHighlighted (mySelectable, theMode); } void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode) { - if (HasSelectable()) + if (!HasSelectable()) { - if (IsAutoHilight()) - { - const Graphic3d_ZLayerId aLayerId = mySelectable->GlobalSelOwner().get() == this ? - Graphic3d_ZLayerId_Top : Graphic3d_ZLayerId_Topmost; - thePM->Color (mySelectable, theStyle, theMode, NULL, aLayerId); - } - else - mySelectable->HilightOwnerWithColor (thePM, theStyle, this); + return; + } + + if (IsAutoHilight()) + { + const Graphic3d_ZLayerId aHiLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : mySelectable->ZLayer(); + thePM->Color (mySelectable, theStyle, theMode, NULL, aHiLayer); + } + else + { + mySelectable->HilightOwnerWithColor (thePM, theStyle, this); } } -void SelectMgr_EntityOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) +void SelectMgr_EntityOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer ) { - if(HasSelectable()) - PM->Unhighlight(mySelectable,aMode); + if (HasSelectable()) + { + thePrsMgr->Unhighlight (mySelectable); + } } void SelectMgr_EntityOwner::Clear(const Handle(PrsMgr_PresentationManager)&, @@ -136,10 +152,8 @@ void SelectMgr_EntityOwner::ResetLocation() Standard_Boolean SelectMgr_EntityOwner::IsAutoHilight () const { - if ( mySelectable==0 ) - return Standard_True; - else - return mySelectable->IsAutoHilight(); + return mySelectable == NULL + || mySelectable->IsAutoHilight(); } Standard_Boolean SelectMgr_EntityOwner::IsForcedHilight () const diff --git a/src/SelectMgr/SelectMgr_EntityOwner.hxx b/src/SelectMgr/SelectMgr_EntityOwner.hxx index 4e1cced635..f52150d6c8 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.hxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.hxx @@ -17,26 +17,18 @@ #ifndef _SelectMgr_EntityOwner_HeaderFile #define _SelectMgr_EntityOwner_HeaderFile +#include +#include +#include +#include +#include #include -#include - -#include #include -#include #include -#include +#include #include -#include -#include -#include -class Standard_NoSuchObject; -class PrsMgr_PresentationManager; -class TopLoc_Location; -class V3d_Viewer; - -class SelectMgr_EntityOwner; -DEFINE_STANDARD_HANDLE(SelectMgr_EntityOwner, SelectBasics_EntityOwner) +class V3d_Viewer; //! A framework to define classes of owners of sensitive primitives. //! The owner is the link between application and @@ -45,31 +37,29 @@ DEFINE_STANDARD_HANDLE(SelectMgr_EntityOwner, SelectBasics_EntityOwner) //! it must define owner classes inheriting this framework. class SelectMgr_EntityOwner : public SelectBasics_EntityOwner { - + DEFINE_STANDARD_RTTIEXT(SelectMgr_EntityOwner, SelectBasics_EntityOwner) public: - //! Initializes the selection priority aPriority. Standard_EXPORT SelectMgr_EntityOwner(const Standard_Integer aPriority = 0); - + //! Constructs a framework with the selectable object //! anSO being attributed the selection priority aPriority. Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO, const Standard_Integer aPriority = 0); - + //! Constructs a framework from existing one //! anSO being attributed the selection priority aPriority. Standard_EXPORT SelectMgr_EntityOwner(const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aPriority = 0); //! Returns true if there is a selectable object to serve as an owner. - Standard_EXPORT Standard_Boolean HasSelectable() const; - + Standard_Boolean HasSelectable() const { return mySelectable != NULL; } + //! Returns a selectable object detected in the working context. Standard_EXPORT virtual Handle(SelectMgr_SelectableObject) Selectable() const; - - //! Sets the selectable object anSO to be used by the - //! second constructor above. - Standard_EXPORT void Set (const Handle(SelectMgr_SelectableObject)& aSO); - + + //! Sets the selectable object. + Standard_EXPORT virtual void SetSelectable (const Handle(SelectMgr_SelectableObject)& theSelObj); + //! Returns true if the presentation manager aPM //! highlights selections corresponding to the selection mode aMode. Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) const; @@ -79,16 +69,15 @@ public: //! selectable object manages highlighting on its own, execution will be passed to //! SelectMgr_SelectableObject::HilightOwnerWithColor method Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode = 0); - - //! Removes highlighting from the owner of a detected - //! selectable object in the presentation manager aPM. + + //! Removes highlighting from the owner of a detected selectable object in the presentation manager. //! This object could be the owner of a sensitive primitive. - //! The display mode for the highlight is aMode; this has - //! the default value of 0, that is, wireframe mode. - Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0); - + //! @param thePrsMgr presentation manager + //! @param theMode obsolete argument for compatibility, should be ignored by implementations + Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode = 0); + //! Clears the owners matching the value of the selection //! mode aMode from the presentation manager object aPM. Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0); @@ -103,17 +92,17 @@ public: //! Set the state of the owner. //! @param theIsSelected [in] shows if owner is selected. - void SetSelected (const Standard_Boolean theIsSelected); - + void SetSelected (const Standard_Boolean theIsSelected) { myIsSelected = theIsSelected; } + //! @return Standard_True if the owner is selected. - Standard_Boolean IsSelected() const; - + Standard_Boolean IsSelected() const { return myIsSelected; } + //! Set the state of the owner. //! The method is deprecated. Use SetSelected() instead. - void State (const Standard_Integer aStatus); - - Standard_Integer State() const; - + void State (const Standard_Integer theStatus) { myIsSelected = (theStatus == 1); } + + Standard_Integer State() const { return myIsSelected ? 1 : 0; } + //! if owner is not auto hilighted, for group contains many such owners //! will be called one method HilightSelected of SelectableObject Standard_EXPORT virtual Standard_Boolean IsAutoHilight() const; @@ -137,28 +126,25 @@ public: return mySelectable == theOther.get(); } + //! Returns TRUE if this owner points to a part of object and FALSE for entire object. + Standard_Boolean ComesFromDecomposition() const { return myFromDecomposition; } - DEFINE_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner) + //! Sets flag indicating this owner points to a part of object (TRUE) or to entire object (FALSE). + void SetComesFromDecomposition (const Standard_Boolean theIsFromDecomposition) { myFromDecomposition = theIsFromDecomposition; } -protected: - - - - -private: +public: + //! Sets the selectable object. + void Set (const Handle(SelectMgr_SelectableObject)& theSelObj) { SetSelectable (theSelObj); } - SelectMgr_SOPtr mySelectable; - Standard_Boolean myIsSelected; +protected: + SelectMgr_SelectableObject* mySelectable; //!< raw pointer to selectable object + Standard_Boolean myIsSelected; //!< flag indicating selected state + Standard_Boolean myFromDecomposition; //!< flag indicating this owner points to a part of object (TRUE) or to entire object (FALSE) }; - -#include - - - - +DEFINE_STANDARD_HANDLE(SelectMgr_EntityOwner, SelectBasics_EntityOwner) #endif // _SelectMgr_EntityOwner_HeaderFile diff --git a/src/SelectMgr/SelectMgr_EntityOwner.lxx b/src/SelectMgr/SelectMgr_EntityOwner.lxx deleted file mode 100644 index cad8ed7699..0000000000 --- a/src/SelectMgr/SelectMgr_EntityOwner.lxx +++ /dev/null @@ -1,27 +0,0 @@ -// Created on: 1998-06-17 -// 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 Standard_Integer SelectMgr_EntityOwner::State() const -{ return myIsSelected ? 1 : 0; } - -inline void SelectMgr_EntityOwner::State(const Standard_Integer aStatus) -{ myIsSelected = (aStatus == 1);} - -inline Standard_Boolean SelectMgr_EntityOwner::IsSelected() const -{ return myIsSelected; } - -inline void SelectMgr_EntityOwner::SetSelected (const Standard_Boolean theIsSelected) -{ myIsSelected = theIsSelected; } diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index 52fc4cfd91..555b96c1f3 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -50,23 +50,18 @@ static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq, return ifound; } - - //================================================== -// Function: +// Function: SelectMgr_SelectableObject // Purpose : //================================================== SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) : PrsMgr_PresentableObject (aTypeOfPresentation3d), - myDrawer (new Prs3d_Drawer()), - myHilightDrawer (new Prs3d_Drawer()), myAssemblyOwner (NULL), myAutoHilight (Standard_True), myGlobalSelMode (0) { - InitDefaultHilightAttributes (myHilightDrawer); - myHilightDrawer->Link (myDrawer); + // } //================================================== @@ -319,7 +314,7 @@ void SelectMgr_SelectableObject::ClearSelected () //purpose : //======================================================================= void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&, - const Handle(Graphic3d_HighlightStyle)&, + const Handle(Prs3d_Drawer)&, const Handle(SelectMgr_EntityOwner)&) { Standard_NotImplemented::Raise ("SelectMgr_SelectableObject::HilightOwnerWithColor"); @@ -438,120 +433,6 @@ void SelectMgr_SelectableObject::updateSelection (const Standard_Integer theMode } } -//======================================================================= -//function : SetAttributes -//purpose : -//======================================================================= -void SelectMgr_SelectableObject::SetAttributes (const Handle(Prs3d_Drawer)& theDrawer) -{ - myDrawer = theDrawer; -} - -//======================================================================= -//function : UnsetAttributes -//purpose : -//======================================================================= -void SelectMgr_SelectableObject::UnsetAttributes() -{ - Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer(); - if (myDrawer->HasLink()) - { - aDrawer->Link (myDrawer->Link()); - } - myDrawer = aDrawer; -} - -//======================================================================= -//function : SetHilightAttributes -//purpose : -//======================================================================= -void SelectMgr_SelectableObject::SetHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) -{ - myHilightDrawer = theDrawer; -} - -//======================================================================= -//function : UnsetAttributes -//purpose : -//======================================================================= -void SelectMgr_SelectableObject::UnsetHilightAttributes() -{ - Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer(); - InitDefaultHilightAttributes (aDrawer); - aDrawer->Link (myDrawer); - myHilightDrawer = aDrawer; -} - -//======================================================================= -//function : InitDefaultHilightAttributes -//purpose : -//======================================================================= -void SelectMgr_SelectableObject::InitDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) -{ - if (!theDrawer->HasOwnPointAspect()) - { - theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0)); - if (theDrawer->HasLink()) - { - *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect(); - } - } - if (!theDrawer->HasOwnLineAspect()) - { - theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); - if (theDrawer->HasLink()) - { - *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect(); - } - } - if (!theDrawer->HasOwnWireAspect()) - { - theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); - if (theDrawer->HasLink()) - { - *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect(); - } - } - if (!theDrawer->HasOwnPlaneAspect()) - { - theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect()); - if (theDrawer->HasLink()) - { - *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect(); - } - } - if (!theDrawer->HasOwnFreeBoundaryAspect()) - { - theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); - if (theDrawer->HasLink()) - { - *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect(); - } - } - if (!theDrawer->HasOwnUnFreeBoundaryAspect()) - { - theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); - if (theDrawer->HasLink()) - { - *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect(); - } - } - - theDrawer->WireAspect()->SetWidth(2.); - theDrawer->LineAspect()->SetWidth(2.); - theDrawer->PlaneAspect()->EdgesAspect()->SetWidth(2.); - theDrawer->FreeBoundaryAspect()->SetWidth(2.); - theDrawer->UnFreeBoundaryAspect()->SetWidth(2.); - theDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_POINT); - theDrawer->PointAspect()->SetScale(2.); - - // By default the hilight drawer has absolute type of deflection. - // It is supposed that absolute deflection is taken from Link(). - // It is necessary to use for all sub-shapes identical coefficient - // computed in ::Compute() call for whole shape and stored in base drawer. - theDrawer->SetTypeOfDeflection (Aspect_TOD_ABSOLUTE); -} - //======================================================================= //function : SetAssemblyOwner //purpose : Sets common entity owner for assembly sensitive object entities diff --git a/src/SelectMgr/SelectMgr_SelectableObject.hxx b/src/SelectMgr/SelectMgr_SelectableObject.hxx index 85909135d1..92f02da998 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.hxx @@ -53,7 +53,8 @@ DEFINE_STANDARD_HANDLE(SelectMgr_SelectableObject, PrsMgr_PresentableObject) //! in AIS. This is particularly true in the creation of new interactive objects. class SelectMgr_SelectableObject : public PrsMgr_PresentableObject { - + DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject) + friend class SelectMgr_SelectionManager; public: //! Clears all selections of the object @@ -143,7 +144,7 @@ public: //! Method which hilight an owner belonging to //! this selectable object ( for fast presentation draw ) Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner); //! If returns True, the old mechanism for highlighting @@ -176,34 +177,7 @@ public: //! by storing its minimum and maximum 3d coordinates //! to output parameters Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox) = 0; - - //! Initializes the drawing tool theDrawer. - Standard_EXPORT virtual void SetAttributes (const Handle(Prs3d_Drawer)& theDrawer); - - //! Returns the attributes settings. - const Handle(Prs3d_Drawer)& Attributes() const - { - return myDrawer; - } - - //! Clears settings provided by the drawing tool theDrawer. - Standard_EXPORT virtual void UnsetAttributes(); - - //! Initializes the hilight drawing tool theDrawer. - Standard_EXPORT virtual void SetHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer); - - //! Returns the hilight attributes settings. - const Handle(Prs3d_Drawer)& HilightAttributes() const - { - return myHilightDrawer; - } - //! Clears settings provided by the hilight drawing tool theDrawer. - Standard_EXPORT virtual void UnsetHilightAttributes(); - - //! Initializes theDrawer by default hilight settings. - Standard_EXPORT static void InitDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer); - //! Sets common entity owner for assembly sensitive object entities Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1); @@ -223,12 +197,6 @@ public: //! Returns the owner of mode for selection of object as a whole Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const; - -friend class SelectMgr_SelectionManager; - - - DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject) - protected: Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); @@ -243,8 +211,6 @@ protected: protected: SelectMgr_SequenceOfSelection myselections; - Handle(Prs3d_Drawer) myDrawer; - Handle(Prs3d_Drawer) myHilightDrawer; Handle(SelectMgr_EntityOwner) myAssemblyOwner; Standard_Boolean myAutoHilight; diff --git a/src/StdSelect/FILES b/src/StdSelect/FILES index 1ed626df24..394026ceec 100644 --- a/src/StdSelect/FILES +++ b/src/StdSelect/FILES @@ -17,7 +17,6 @@ StdSelect_Prs.lxx StdSelect_SensitivityMode.hxx StdSelect_Shape.cxx StdSelect_Shape.hxx -StdSelect_Shape.lxx StdSelect_ShapeTypeFilter.cxx StdSelect_ShapeTypeFilter.hxx StdSelect_ShapeTypeFilter.lxx diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx index 6a7a6b24bd..194f1924f4 100644 --- a/src/StdSelect/StdSelect_BRepOwner.cxx +++ b/src/StdSelect/StdSelect_BRepOwner.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -21,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -29,35 +29,43 @@ IMPLEMENT_STANDARD_RTTIEXT(StdSelect_BRepOwner,SelectMgr_EntityOwner) //================================================== -// Function: +// Function: StdSelect_BRepOwner // Purpose : //================================================== -StdSelect_BRepOwner::StdSelect_BRepOwner(const Standard_Integer aPriority): -SelectMgr_EntityOwner(aPriority), -myFromDecomposition(Standard_False), -myCurMode(0) +StdSelect_BRepOwner::StdSelect_BRepOwner (const Standard_Integer thePriority) +: SelectMgr_EntityOwner (thePriority), + myCurMode (0) { + // } -StdSelect_BRepOwner::StdSelect_BRepOwner(const TopoDS_Shape& aShape, - const Standard_Integer aPriority, - const Standard_Boolean ComesFromDecomposition): -SelectMgr_EntityOwner(aPriority), -myFromDecomposition(ComesFromDecomposition), -myShape(aShape), -myCurMode(0) +//================================================== +// Function: StdSelect_BRepOwner +// Purpose : +//================================================== +StdSelect_BRepOwner::StdSelect_BRepOwner (const TopoDS_Shape& theShape, + const Standard_Integer thePriority, + const Standard_Boolean theComesFromDecomposition) +: SelectMgr_EntityOwner (thePriority), + myShape (theShape), + myCurMode (0) { + myFromDecomposition = theComesFromDecomposition; } -StdSelect_BRepOwner::StdSelect_BRepOwner(const TopoDS_Shape& aShape, - const Handle (SelectMgr_SelectableObject)& theOrigin, - const Standard_Integer aPriority, - const Standard_Boolean ComesFromDecomposition): -SelectMgr_EntityOwner(theOrigin,aPriority), -myFromDecomposition(ComesFromDecomposition), -myShape(aShape), -myCurMode(0) +//================================================== +// Function: StdSelect_BRepOwner +// Purpose : +//================================================== +StdSelect_BRepOwner::StdSelect_BRepOwner (const TopoDS_Shape& theShape, + const Handle (SelectMgr_SelectableObject)& theOrigin, + const Standard_Integer thePriority, + const Standard_Boolean theComesFromDecomposition) +: SelectMgr_EntityOwner (theOrigin, thePriority), + myShape (theShape), + myCurMode (0) { + myFromDecomposition = theComesFromDecomposition; } //======================================================================= @@ -79,78 +87,69 @@ IsHilighted(const Handle(PrsMgr_PresentationManager)& PM, //purpose : //======================================================================= void StdSelect_BRepOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode) { - Standard_Integer M = (theMode < 0) ? myCurMode : theMode; - Graphic3d_ZLayerId aHiLayer = this == Selectable()->GlobalSelOwner().get() ? - Graphic3d_ZLayerId_Top : Graphic3d_ZLayerId_Topmost; - Handle(SelectMgr_SelectableObject) aSel = Selectable(); - - if (myFromDecomposition) + if (!HasSelectable()) { - // do the update flag check - if (!myPrsSh.IsNull()) - { - TColStd_ListOfInteger aModesList; - myPrsSh->ToBeUpdated (aModesList); - if (!aModesList.IsEmpty()) - myPrsSh.Nullify(); - } - - Handle(Prs3d_Drawer) aDrawer; - if (!aSel.IsNull()) - { - aDrawer = aSel->HilightAttributes(); - } - else - { - aDrawer = new Prs3d_Drawer(); - SelectMgr_SelectableObject::InitDefaultHilightAttributes (aDrawer); - } + return; + } - // generate new presentable shape - if(myPrsSh.IsNull()) - { - if(HasLocation()) - { - TopLoc_Location lbid = Location() * myShape.Location(); - TopoDS_Shape ShBis = myShape.Located(lbid); - myPrsSh = new StdSelect_Shape(ShBis, aDrawer); - } - else - myPrsSh = new StdSelect_Shape(myShape, aDrawer); - } - if (!aSel.IsNull()) - { - myPrsSh->SetZLayer (aSel->ZLayer()); - myPrsSh->SetTransformPersistence (aSel->TransformPersistence()); - } + const Standard_Integer aDispMode = (theMode < 0) ? myCurMode : theMode; + Handle(SelectMgr_SelectableObject) aSel = Selectable(); + const Graphic3d_ZLayerId aHiLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : aSel->ZLayer(); + if (!myFromDecomposition) + { + thePM->Color (aSel, theStyle, aDispMode, NULL, aHiLayer); + return; + } - // highlight with color and set layer - thePM->Color (myPrsSh, theStyle, M, aSel, aHiLayer); + // do the update flag check + if (!myPrsSh.IsNull()) + { + TColStd_ListOfInteger aModesList; + myPrsSh->ToBeUpdated (aModesList); + if (!aModesList.IsEmpty()) + myPrsSh.Nullify(); } - else + + // generate new presentable shape + if (myPrsSh.IsNull()) { - if (!myPrsSh.IsNull()) + if (HasLocation()) { - thePM->Color (myPrsSh, theStyle, M, aSel, aHiLayer); + TopLoc_Location lbid = Location() * myShape.Location(); + TopoDS_Shape ShBis = myShape.Located(lbid); + myPrsSh = new StdSelect_Shape (ShBis, theStyle); } else { - thePM->Color (aSel, theStyle, M, NULL, aHiLayer); + myPrsSh = new StdSelect_Shape (myShape, theStyle); } } + + // initialize presentation attributes of child presentation + myPrsSh->SetZLayer (aSel->ZLayer()); + myPrsSh->SetTransformPersistence (aSel->TransformPersistence()); + myPrsSh->Attributes()->SetLink (theStyle); + myPrsSh->Attributes()->SetColor (theStyle->Color()); + myPrsSh->Attributes()->SetTransparency (theStyle->Transparency()); + myPrsSh->Attributes()->SetBasicFillAreaAspect (theStyle->BasicFillAreaAspect()); + + // highlight with color and set layer + thePM->Color (myPrsSh, theStyle, aDispMode, aSel, aHiLayer); } -void StdSelect_BRepOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) +void StdSelect_BRepOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer ) { - Standard_Integer M = (aMode < 0) ? myCurMode : aMode; - if(myPrsSh.IsNull() || !myFromDecomposition) - PM->Unhighlight(Selectable(),M); + if (myPrsSh.IsNull() || !myFromDecomposition) + { + thePrsMgr->Unhighlight (Selectable()); + } else - PM->Unhighlight(myPrsSh,M); + { + thePrsMgr->Unhighlight (myPrsSh); + } } void StdSelect_BRepOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM, @@ -182,18 +181,6 @@ void StdSelect_BRepOwner::ResetLocation() myPrsSh->SetToUpdate(); } -//======================================================================= -//function : SetZLayer -//purpose : -//======================================================================= -void StdSelect_BRepOwner::SetZLayer (const Graphic3d_ZLayerId theLayerId) -{ - if (!myPrsSh.IsNull()) - { - myPrsSh->SetZLayer (theLayerId); - } -} - //======================================================================= //function : UpdateHighlightTrsf //purpose : diff --git a/src/StdSelect/StdSelect_BRepOwner.hxx b/src/StdSelect/StdSelect_BRepOwner.hxx index 141781bf7e..7d31b20d78 100644 --- a/src/StdSelect/StdSelect_BRepOwner.hxx +++ b/src/StdSelect/StdSelect_BRepOwner.hxx @@ -33,8 +33,6 @@ class SelectMgr_SelectableObject; class PrsMgr_PresentationManager; class TopLoc_Location; - -class StdSelect_BRepOwner; DEFINE_STANDARD_HANDLE(StdSelect_BRepOwner, SelectMgr_EntityOwner) //! Defines Specific Owners for Sensitive Primitives @@ -46,10 +44,9 @@ DEFINE_STANDARD_HANDLE(StdSelect_BRepOwner, SelectMgr_EntityOwner) //! must be redefined by each User. class StdSelect_BRepOwner : public SelectMgr_EntityOwner { - + DEFINE_STANDARD_RTTIEXT(StdSelect_BRepOwner, SelectMgr_EntityOwner) public: - //! Constructs an owner specification framework defined //! by the priority aPriority. Standard_EXPORT StdSelect_BRepOwner(const Standard_Integer aPriority); @@ -71,44 +68,41 @@ public: Standard_EXPORT StdSelect_BRepOwner(const TopoDS_Shape& aShape, const Handle(SelectMgr_SelectableObject)& theOrigin, const Standard_Integer aPriority = 0, const Standard_Boolean FromDecomposition = Standard_False); //! returns False if no shape was set - Standard_Boolean HasShape() const; - + Standard_Boolean HasShape() const { return !myShape.IsNull(); } + //! indicates whether //! comes from decomposition of a bigger shape. Standard_EXPORT void Set (const TopoDS_Shape& aShape, const Standard_Boolean FromDecomposition = Standard_False); - - Standard_Boolean ComesFromDecomposition() const; - - const TopoDS_Shape& Shape() const; - + + const TopoDS_Shape& Shape() const { return myShape; } //! Returns true if this framework has a highlight mode defined for it. - Standard_Boolean HasHilightMode() const; + Standard_Boolean HasHilightMode() const { return myCurMode == -1; } //! Sets the highlight mode for this framework. //! This defines the type of display used to highlight the //! owner of the shape when it is detected by the selector. //! The default type of display is wireframe, defined by the index 0. - void SetHilightMode (const Standard_Integer aMode); - + void SetHilightMode (const Standard_Integer theMode) { myCurMode = theMode; } + //! Resets the higlight mode for this framework. //! This defines the type of display used to highlight the //! owner of the shape when it is detected by the selector. //! The default type of display is wireframe, defined by the index 0. - void ResetHilightMode(); - + void ResetHilightMode() { myCurMode = -1; } + //! Returns the highlight mode for this framework. //! This defines the type of display used to highlight the //! owner of the shape when it is detected by the selector. //! The default type of display is wireframe, defined by the index 0. - Standard_Integer HilightMode() const; - + Standard_Integer HilightMode() const { return myCurMode; } + //! Returns true if an object with the selection mode //! aMode is highlighted in the presentation manager aPM. Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) const Standard_OVERRIDE; Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Prs3d_Drawer)& theStyle, const Standard_Integer theMode = 0) Standard_OVERRIDE; //! Removes highlighting from the type of shape @@ -122,38 +116,18 @@ public: Standard_EXPORT virtual void SetLocation (const TopLoc_Location& aLoc) Standard_OVERRIDE; Standard_EXPORT virtual void ResetLocation() Standard_OVERRIDE; - - //! Set Z layer ID and update all presentations. - Standard_EXPORT virtual void SetZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE; //! Implements immediate application of location transformation of parent object to dynamic highlight structure Standard_EXPORT virtual void UpdateHighlightTrsf (const Handle(V3d_Viewer)& theViewer, const Handle(PrsMgr_PresentationManager3d)& theManager, const Standard_Integer theDispMode) Standard_OVERRIDE; - DEFINE_STANDARD_RTTIEXT(StdSelect_BRepOwner,SelectMgr_EntityOwner) - protected: - - Standard_Boolean myFromDecomposition; TopoDS_Shape myShape; - - -private: - - Handle(StdSelect_Shape) myPrsSh; Standard_Integer myCurMode; - }; - -#include - - - - - #endif // _StdSelect_BRepOwner_HeaderFile diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.cxx b/src/StdSelect/StdSelect_BRepSelectionTool.cxx index 9b83721973..0d8ddf0231 100644 --- a/src/StdSelect/StdSelect_BRepSelectionTool.cxx +++ b/src/StdSelect/StdSelect_BRepSelectionTool.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -101,16 +101,15 @@ void StdSelect_BRepSelectionTool::PreBuildBVH (const Handle(SelectMgr_Selection) // Function: Load // Purpose : //================================================== -void StdSelect_BRepSelectionTool -::Load (const Handle(SelectMgr_Selection)& theSelection, - const TopoDS_Shape& theShape, - const TopAbs_ShapeEnum theType, - const Standard_Real theDeflection, - const Standard_Real theDeviationAngle, - const Standard_Boolean isAutoTriangulation, - const Standard_Integer thePriority, - const Standard_Integer theNbPOnEdge, - const Standard_Real theMaxParam) +void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSelection, + const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + const Standard_Real theDeflection, + const Standard_Real theDeviationAngle, + const Standard_Boolean isAutoTriangulation, + const Standard_Integer thePriority, + const Standard_Integer theNbPOnEdge, + const Standard_Real theMaxParam) { Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority; @@ -166,17 +165,16 @@ void StdSelect_BRepSelectionTool // Function: Load // Purpose : //================================================== -void StdSelect_BRepSelectionTool -::Load (const Handle(SelectMgr_Selection)& theSelection, - const Handle(SelectMgr_SelectableObject)& theSelectableObj, - const TopoDS_Shape& theShape, - const TopAbs_ShapeEnum theType, - const Standard_Real theDeflection, - const Standard_Real theDeviationAngle, - const Standard_Boolean isAutoTriangulation, - const Standard_Integer thePriority, - const Standard_Integer theNbPOnEdge, - const Standard_Real theMaxParam) +void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSelection, + const Handle(SelectMgr_SelectableObject)& theSelectableObj, + const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType, + const Standard_Real theDeflection, + const Standard_Real theDeviationAngle, + const Standard_Boolean isAutoTriangulation, + const Standard_Integer thePriority, + const Standard_Integer theNbPOnEdge, + const Standard_Real theMaxParam) { Load (theSelection, theShape, @@ -203,15 +201,14 @@ void StdSelect_BRepSelectionTool // Function: ComputeSensitive // Purpose : //================================================== -void StdSelect_BRepSelectionTool -::ComputeSensitive (const TopoDS_Shape& theShape, - const Handle(StdSelect_BRepOwner)& theOwner, - const Handle(SelectMgr_Selection)& theSelection, - const Standard_Real theDeflection, - const Standard_Real theDeviationAngle, - const Standard_Integer theNbPOnEdge, - const Standard_Real theMaxParam, - const Standard_Boolean isAutoTriangulation) +void StdSelect_BRepSelectionTool::ComputeSensitive (const TopoDS_Shape& theShape, + const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(SelectMgr_Selection)& theSelection, + const Standard_Real theDeflection, + const Standard_Real theDeviationAngle, + const Standard_Integer theNbPOnEdge, + const Standard_Real theMaxParam, + const Standard_Boolean isAutoTriangulation) { switch (theShape.ShapeType()) { @@ -434,21 +431,16 @@ static Standard_Boolean FindLimits (const Adaptor3d_Curve& theCurve, //===================================================== // Function : GetEdgeSensitive -// Purpose : create a sensitive edge to add it -// in computeselection to "aselection" (case of selection of an edge) -// or to "aSensitiveWire" (case of selection of a wire; in this case, -// the sensitive wire is added to "aselection" ) -// odl - for selection by rectangle - +// Purpose : //===================================================== -void StdSelect_BRepSelectionTool -::GetEdgeSensitive (const TopoDS_Shape& theShape, - const Handle(StdSelect_BRepOwner)& theOwner, - const Handle(SelectMgr_Selection)& theSelection, - const Standard_Real theDeflection, - const Standard_Real theDeviationAngle, - const Standard_Integer theNbPOnEdge, - const Standard_Real theMaxParam, - Handle(Select3D_SensitiveEntity)& theSensitive) +void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape, + const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(SelectMgr_Selection)& theSelection, + const Standard_Real theDeflection, + const Standard_Real theDeviationAngle, + const Standard_Integer theNbPOnEdge, + const Standard_Real theMaxParam, + Handle(Select3D_SensitiveEntity)& theSensitive) { const TopoDS_Edge& anEdge = TopoDS::Edge (theShape); BRepAdaptor_Curve cu3d; @@ -560,50 +552,17 @@ void StdSelect_BRepSelectionTool } } -//===================================================== -// Function : GetStandardPriority -// Purpose : -//===================================================== -Standard_Integer StdSelect_BRepSelectionTool::GetStandardPriority (const TopoDS_Shape& theShape, - const TopAbs_ShapeEnum theType) -{ - switch (theType) - { - case TopAbs_VERTEX: return 8; - case TopAbs_EDGE: return 7; - case TopAbs_WIRE: return 6; - case TopAbs_FACE: return 5; - case TopAbs_SHAPE: - default: - switch (theShape.ShapeType()) - { - case TopAbs_VERTEX: return 9; - case TopAbs_EDGE: return 8; - case TopAbs_WIRE: return 7; - case TopAbs_FACE: return 6; - case TopAbs_SHELL: return 5; - case TopAbs_COMPOUND: - case TopAbs_COMPSOLID: - case TopAbs_SOLID: - case TopAbs_SHAPE: - default: - return 4; - } - } -} - //======================================================================= //function : GetSensitiveEntityForFace //purpose : //======================================================================= -Standard_Boolean StdSelect_BRepSelectionTool -::GetSensitiveForFace (const TopoDS_Face& theFace, - const Handle(StdSelect_BRepOwner)& theOwner, - Select3D_EntitySequence& theSensitiveList, - const Standard_Boolean /*theAutoTriangulation*/, - const Standard_Integer NbPOnEdge, - const Standard_Real theMaxParam, - const Standard_Boolean theInteriorFlag) +Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_Face& theFace, + const Handle(SelectMgr_EntityOwner)& theOwner, + Select3D_EntitySequence& theSensitiveList, + const Standard_Boolean /*theAutoTriangulation*/, + const Standard_Integer NbPOnEdge, + const Standard_Real theMaxParam, + const Standard_Boolean theInteriorFlag) { // check if there is triangulation of the face... TopLoc_Location aLoc; diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.hxx b/src/StdSelect/StdSelect_BRepSelectionTool.hxx index 289d4edb3c..4f5cd24aea 100644 --- a/src/StdSelect/StdSelect_BRepSelectionTool.hxx +++ b/src/StdSelect/StdSelect_BRepSelectionTool.hxx @@ -66,10 +66,8 @@ class TopoDS_Face; class StdSelect_BRepSelectionTool { public: - DEFINE_STANDARD_ALLOC - //! Decomposition of into sensitive entities following //! a mode of decomposition . These entities are stored in . //! BrepOwners are created to store the identity of the picked shapes @@ -99,50 +97,90 @@ public: //! You can use the function Load to modify the //! selection priority of an owner to make one entity //! more selectable than another one. - Standard_EXPORT static Standard_Integer GetStandardPriority (const TopoDS_Shape& aShap, const TopAbs_ShapeEnum aType); - - //! Computes the sensitive primitives corresponding to - //! the subshape aShape with the owner anOwner. - //! Stores them in the SelectMgr_Selection object, and returns this object. - //! The number NbPOnEdge is used to define edges and wires. - //! In the case of infinite objects, the value - //! MaximalParameter serves to limit computation time - //! by limiting the sensitive area. The default value is 500. - //! If AutoTriangulation is true, triangulation will be - //! computed for the faces which have none. If it is false, - //! sensitive entities on these faces will be calculated. - Standard_EXPORT static void ComputeSensitive (const TopoDS_Shape& aShape, const Handle(StdSelect_BRepOwner)& anOwner, const Handle(SelectMgr_Selection)& aSelection, const Standard_Real theDeflection, const Standard_Real theDeviationAngle, const Standard_Integer NbPOnEdge, const Standard_Real MaximalParameter, const Standard_Boolean AutoTriangulation = Standard_True); - - //! appends to the 3D - //! sensitive entities created for selection of - //! if = False the face will be sensitive only on its boundary - Standard_EXPORT static Standard_Boolean GetSensitiveForFace (const TopoDS_Face& aFace, const Handle(StdSelect_BRepOwner)& anOwner, Select3D_EntitySequence& OutList, const Standard_Boolean AutoTriangulation = Standard_True, const Standard_Integer NbPOnEdge = 9, const Standard_Real MaxiParam = 500, const Standard_Boolean InteriorFlag = Standard_True); + static Standard_Integer GetStandardPriority (const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType) + { + switch (theType) + { + case TopAbs_VERTEX: return 8; + case TopAbs_EDGE: return 7; + case TopAbs_WIRE: return 6; + case TopAbs_FACE: return 5; + case TopAbs_SHAPE: + default: break; + } + + switch (theShape.ShapeType()) + { + case TopAbs_VERTEX: return 9; + case TopAbs_EDGE: return 8; + case TopAbs_WIRE: return 7; + case TopAbs_FACE: return 6; + case TopAbs_SHELL: return 5; + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + case TopAbs_SOLID: + case TopAbs_SHAPE: + default: + return 4; + } + } + + //! Computes the sensitive primitives, stores them in the SelectMgr_Selection object, and returns this object. + //! @param theShape shape to compute sensitive entities + //! @param theOwner selectable owner object + //! @param theSelection selection to append new sensitive entities + //! @param theDeflection linear deflection + //! @param theDeflAngle angular deflection + //! @param theNbPOnEdge sensitivity parameters for edges and wires + //! @param theMaxiParam sensitivity parameters for infinite objects (the default value is 500) + //! @param theAutoTriang flag to compute triangulation for the faces which have none + Standard_EXPORT static void ComputeSensitive (const TopoDS_Shape& theShape, + const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(SelectMgr_Selection)& theSelection, + const Standard_Real theDeflection, + const Standard_Real theDeflAngle, + const Standard_Integer theNbPOnEdge, + const Standard_Real theMaxiParam, + const Standard_Boolean theAutoTriang = Standard_True); + + //! Creates the 3D sensitive entities for Face selection. + //! @param theFace face to compute sensitive entities + //! @param theOwner selectable owner object + //! @param theOutList output result list to append created entities + //! @param theAutoTriang obsolete flag (has no effect) + //! @param theNbPOnEdge sensitivity parameters + //! @param theMaxiParam sensitivity parameters + //! @param theInteriorFlag flag indicating that face interior (TRUE) or face boundary (FALSE) should be selectable + Standard_EXPORT static Standard_Boolean GetSensitiveForFace (const TopoDS_Face& theFace, + const Handle(SelectMgr_EntityOwner)& theOwner, + Select3D_EntitySequence& theOutList, + const Standard_Boolean theAutoTriang = Standard_True, + const Standard_Integer theNbPOnEdge = 9, + const Standard_Real theMaxiParam = 500, + const Standard_Boolean theInteriorFlag = Standard_True); + + //! Create a sensitive edge or sensitive wire. + //! @param theShape either TopoDS_Edge or TopoDS_Wire to compute sensitive entities + //! @param theOwner selectable owner object + //! @param theSelection selection to append new sensitive entities + //! @param theDeflection linear deflection + //! @param theDeviationAngle angular deflection + //! @param theNbPOnEdge sensitivity parameters + //! @param theMaxiParam sensitivity parameters + Standard_EXPORT static void GetEdgeSensitive (const TopoDS_Shape& theShape, + const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(SelectMgr_Selection)& theSelection, + const Standard_Real theDeflection, + const Standard_Real theDeviationAngle, + const Standard_Integer theNbPOnEdge, + const Standard_Real theMaxiParam, + Handle(Select3D_SensitiveEntity)& theSensitive); //! Traverses the selection given and pre-builds BVH trees for heavyweight - //! sensitive entities containing more than BVH_PRIMITIVE_LIMIT (defined in .cxx file) - //! sub-elements + //! sensitive entities containing more than BVH_PRIMITIVE_LIMIT (defined in .cxx file) sub-elements. Standard_EXPORT static void PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection); - -protected: - - - - - -private: - - Standard_EXPORT static void GetEdgeSensitive (const TopoDS_Shape& aShape, const Handle(StdSelect_BRepOwner)& anOwner, const Handle(SelectMgr_Selection)& aSelection, const Standard_Real theDeflection, const Standard_Real theDeflectionAngle, const Standard_Integer NbPOnEdge, const Standard_Real MaximalParameter, Handle(Select3D_SensitiveEntity)& aSensitive); - - - - }; - - - - - - #endif // _StdSelect_BRepSelectionTool_HeaderFile diff --git a/src/StdSelect/StdSelect_Shape.cxx b/src/StdSelect/StdSelect_Shape.cxx index de07e0a655..5293d3706a 100644 --- a/src/StdSelect/StdSelect_Shape.cxx +++ b/src/StdSelect/StdSelect_Shape.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -22,16 +23,20 @@ #include #include #include -#include #include #include IMPLEMENT_STANDARD_RTTIEXT(StdSelect_Shape,PrsMgr_PresentableObject) -StdSelect_Shape::StdSelect_Shape (const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer): - mysh (theShape), - myDrawer (theDrawer) -{} +StdSelect_Shape::StdSelect_Shape (const TopoDS_Shape& theShape, + const Handle(Prs3d_Drawer)& theDrawer) +: mysh (theShape) +{ + if (!theDrawer.IsNull()) + { + myDrawer->SetLink (theDrawer); + } +} void StdSelect_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*PM*/, const Handle(Prs3d_Presentation)& P, diff --git a/src/StdSelect/StdSelect_Shape.hxx b/src/StdSelect/StdSelect_Shape.hxx index 73bf5e0e5b..250f1992b9 100644 --- a/src/StdSelect/StdSelect_Shape.hxx +++ b/src/StdSelect/StdSelect_Shape.hxx @@ -25,23 +25,19 @@ #include #include #include + class TopoDS_Shape; class Prs3d_Presentation; class Prs3d_Projector; class Geom_Transformation; - -class StdSelect_Shape; -DEFINE_STANDARD_HANDLE(StdSelect_Shape, PrsMgr_PresentableObject) - //! Presentable shape only for purpose of display for BRepOwner... class StdSelect_Shape : public PrsMgr_PresentableObject { - + DEFINE_STANDARD_RTTIEXT(StdSelect_Shape, PrsMgr_PresentableObject) public: - - Standard_EXPORT StdSelect_Shape(const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer); + Standard_EXPORT StdSelect_Shape(const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer = Handle(Prs3d_Drawer)()); Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE; @@ -53,37 +49,21 @@ public: //! WARNING : must be applied //! to the object to display before computation !!! Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; - - const TopoDS_Shape& Shape() const; - - void Shape (const TopoDS_Shape& sh); - - - - - DEFINE_STANDARD_RTTIEXT(StdSelect_Shape,PrsMgr_PresentableObject) - -protected: - + const TopoDS_Shape& Shape() const { return mysh; } + void Shape (const TopoDS_Shape& theShape) { mysh = theShape; } private: - Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; - TopoDS_Shape mysh; - Handle(Prs3d_Drawer) myDrawer; +private: + TopoDS_Shape mysh; }; - -#include - - - - +DEFINE_STANDARD_HANDLE(StdSelect_Shape, PrsMgr_PresentableObject) #endif // _StdSelect_Shape_HeaderFile diff --git a/src/StdSelect/StdSelect_Shape.lxx b/src/StdSelect/StdSelect_Shape.lxx deleted file mode 100644 index df42f6159d..0000000000 --- a/src/StdSelect/StdSelect_Shape.lxx +++ /dev/null @@ -1,13 +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. diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 3c6df45d50..f00eaa0bde 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -3038,13 +3038,13 @@ inline void bndPresentation (Draw_Interpretor& theDI, const Standard_Integer theDispMode, const TCollection_AsciiString& theName, const ViewerTest_BndAction theAction, - const Handle(Graphic3d_HighlightStyle)& theStyle) + const Handle(Prs3d_Drawer)& theStyle) { switch (theAction) { case BndAction_Hide: { - theMgr->Unhighlight (theObj, theDispMode); + theMgr->Unhighlight (theObj); break; } case BndAction_Show: @@ -3091,7 +3091,7 @@ int VBounding (Draw_Interpretor& theDI, ViewerTest_BndAction anAction = BndAction_Show; Standard_Integer aMode = -1; - Handle(Graphic3d_HighlightStyle) aStyle; + Handle(Prs3d_Drawer) aStyle; Standard_Integer anArgIter = 1; for (; anArgIter < theArgNb; ++anArgIter) @@ -3126,7 +3126,11 @@ int VBounding (Draw_Interpretor& theDI, } if (anAction == BndAction_Show) - aStyle = new Graphic3d_HighlightStyle (Aspect_TOHM_BOUNDBOX, Quantity_NOC_GRAY99, 0.0); + { + aStyle = new Prs3d_Drawer(); + aStyle->SetMethod (Aspect_TOHM_BOUNDBOX); + aStyle->SetColor (Quantity_NOC_GRAY99); + } Standard_Integer aHighlightedMode = -1; if (anArgIter < theArgNb) diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 2899bdb087..ddd534db1f 100644 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -5396,8 +5396,14 @@ static int VSetEdgeType (Draw_Interpretor& theDI, Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName)); - // Enable trianle edge mode - anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOn(); + // Enable triangle edge mode + if (!anObject->Attributes()->HasOwnShadingAspect()) + { + anObject->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect()); + *anObject->Attributes()->ShadingAspect()->Aspect() = *anObject->Attributes()->Link()->ShadingAspect()->Aspect(); + } + const Handle(Prs3d_ShadingAspect)& aFillAreaAspect = anObject->Attributes()->ShadingAspect(); + aFillAreaAspect->Aspect()->SetEdgeOn(); // Parse parameters for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt) @@ -5440,7 +5446,7 @@ static int VSetEdgeType (Draw_Interpretor& theDI, aB > 1 ? aB / 255.0 : aB, Quantity_TOC_RGB); - anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeColor (aColor); + aFillAreaAspect->Aspect()->SetEdgeColor (aColor); } else if (aParam.IsEqual ("-force")) { @@ -5462,7 +5468,7 @@ static int VSetEdgeType (Draw_Interpretor& theDI, } else { - anObject->SetAspect (anObject->Attributes()->ShadingAspect()); + anObject->SetAspect (aFillAreaAspect); } //Update view diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 717221728b..4f2bd01db8 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -9952,43 +9952,6 @@ static int VManipulator (Draw_Interpretor& theDi, return 0; } -//=============================================================================================== -//function : parseColor -//purpose : -//=============================================================================================== -static Standard_Boolean parseColor (ViewerTest_CmdParser& theParser, - const std::string& theOptionName, - Quantity_Color& theColor) -{ - std::string aColorArg = theParser.Arg (theOptionName, 0); - if (std::isdigit (aColorArg[0])) - { - Graphic3d_Vec3d aColor = theParser.ArgVec3d (theOptionName); - if (aColor.x() < 0.0 || aColor.x() > 1.0 - || aColor.y() < 0.0 || aColor.y() > 1.0 - || aColor.z() < 0.0 || aColor.z() > 1.0) - { - std::cerr << "Error: RGB color values should be within range 0..1!\n"; - return Standard_False; - } - theColor.SetValues (aColor.x(), aColor.y(), aColor.z(), Quantity_TOC_RGB); - } - else - { - Quantity_NameOfColor aName = Quantity_NOC_BLACK; - if (!Quantity_Color::ColorFromName (aColorArg.c_str(), aName)) - { - std::cerr << "Name: " << theParser.Arg (theOptionName, 0) - << " does not correspond to any color in Quantity_NameOfColor!" - << std::endl; - return Standard_False; - } - theColor.SetValues (aName); - } - - return Standard_True; -} - //=============================================================================================== //function : VSelectionProperties //purpose : @@ -10004,71 +9967,226 @@ static int VSelectionProperties (Draw_Interpretor& theDi, return 1; } - ViewerTest_CmdParser aCmd; + Standard_Boolean toPrint = theArgsNb == 1; + Standard_Boolean toRedraw = Standard_False; + Standard_Integer anArgIter = 1; + Prs3d_TypeOfHighlight aType = Prs3d_TypeOfHighlight_None; + if (anArgIter < theArgsNb) + { + TCollection_AsciiString anArgFirst (theArgVec[anArgIter]); + anArgFirst.LowerCase(); + ++anArgIter; + if (anArgFirst == "dynhighlight" + || anArgFirst == "dynhilight" + || anArgFirst == "dynamichighlight" + || anArgFirst == "dynamichilight") + { + aType = Prs3d_TypeOfHighlight_Dynamic; + } + else if (anArgFirst == "localdynhighlight" + || anArgFirst == "localdynhilight" + || anArgFirst == "localdynamichighlight" + || anArgFirst == "localdynamichilight") + { + aType = Prs3d_TypeOfHighlight_LocalDynamic; + } + else if (anArgFirst == "selhighlight" + || anArgFirst == "selhilight" + || anArgFirst == "selectedhighlight" + || anArgFirst == "selectedhilight") + { + aType = Prs3d_TypeOfHighlight_Selected; + } + else if (anArgFirst == "localselhighlight" + || anArgFirst == "localselhilight" + || anArgFirst == "localselectedhighlight" + || anArgFirst == "localselectedhilight") + { + aType = Prs3d_TypeOfHighlight_LocalSelected; + } + else + { + --anArgIter; + } + } + for (; anArgIter < theArgsNb; ++anArgIter) + { + TCollection_AsciiString anArg (theArgVec[anArgIter]); + anArg.LowerCase(); + if (anArg == "-help") + { + theDi.PrintHelp (theArgVec[0]); + return 0; + } + else if (anArg == "-print") + { + toPrint = Standard_True; + } + else if (anArg == "-autoactivate") + { + Standard_Boolean toEnable = Standard_True; + if (anArgIter + 1 < theArgsNb + && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toEnable)) + { + ++anArgIter; + } + aCtx->SetAutoActivateSelection (toEnable); + } + else if (anArg == "-pixtol" + && anArgIter + 1 < theArgsNb) + { + aCtx->SetPixelTolerance (Draw::Atoi (theArgVec[++anArgIter])); + } + else if ((anArg == "-mode" + || anArg == "-dispmode") + && anArgIter + 1 < theArgsNb) + { + if (aType == Prs3d_TypeOfHighlight_None) + { + std::cout << "Syntax error: type of highlighting is undefined\n"; + return 1; + } - aCmd.AddOption ("autoActivate"); - aCmd.AddOption ("pixTol"); + const Standard_Integer aDispMode = Draw::Atoi (theArgVec[++anArgIter]); + const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); + aStyle->SetDisplayMode (aDispMode); + toRedraw = Standard_True; + } + else if (anArg == "-layer" + && anArgIter + 1 < theArgsNb) + { + if (aType == Prs3d_TypeOfHighlight_None) + { + std::cout << "Syntax error: type of highlighting is undefined\n"; + return 1; + } - aCmd.AddOption ("selColor"); - aCmd.AddOption ("hiColor"); - aCmd.AddOption ("selTransp"); - aCmd.AddOption ("hiTransp"); + const Standard_Integer aNewLayer = Draw::Atoi (theArgVec[++anArgIter]); + if (aNewLayer != Graphic3d_ZLayerId_UNKNOWN) + { + TColStd_SequenceOfInteger aLayers; + aCtx->CurrentViewer()->GetAllZLayers (aLayers); + if (std::find (aLayers.begin(), aLayers.end(), aNewLayer) == aLayers.end()) + { + std::cout << "Syntax error: Layer " << aNewLayer << " is undefined\n"; + return 1; + } + } - aCmd.AddOption ("print"); + const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); + aStyle->SetZLayer (aNewLayer); + toRedraw = Standard_True; + } + else if (anArg == "-hicolor" + || anArg == "-selcolor" + || anArg == "-color") + { + if (anArg.StartsWith ("-hi")) + { + aType = Prs3d_TypeOfHighlight_Dynamic; + } + else if (anArg.StartsWith ("-sel")) + { + aType = Prs3d_TypeOfHighlight_Selected; + } + else if (aType == Prs3d_TypeOfHighlight_None) + { + std::cout << "Syntax error: type of highlighting is undefined\n"; + return 1; + } - aCmd.Parse (theArgsNb, theArgVec); + Quantity_Color aColor; + Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIter - 1, + theArgVec + anArgIter + 1, + aColor); + if (aNbParsed == 0) + { + std::cout << "Syntax error: need more arguments.\n"; + return 1; + } + anArgIter += aNbParsed; - if (aCmd.HasOption ("help")) - { - theDi.PrintHelp (theArgVec[0]); - return 0; - } + const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); + aStyle->SetColor (aColor); + toRedraw = Standard_True; + } + else if ((anArg == "-transp" + || anArg == "-transparency" + || anArg == "-hitransp" + || anArg == "-seltransp" + || anArg == "-hitransplocal" + || anArg == "-seltransplocal") + && anArgIter + 1 < theArgsNb) + { + if (anArg.StartsWith ("-hi")) + { + aType = Prs3d_TypeOfHighlight_Dynamic; + } + else if (anArg.StartsWith ("-sel")) + { + aType = Prs3d_TypeOfHighlight_Selected; + } + else if (aType == Prs3d_TypeOfHighlight_None) + { + std::cout << "Syntax error: type of highlighting is undefined\n"; + return 1; + } - if (aCmd.HasOption ("autoActivate", 1, Standard_False)) - { - aCtx->SetAutoActivateSelection (aCmd.ArgBool ("autoActivate")); - } - if (aCmd.HasOption ("pixTol", 1, Standard_False)) - { - aCtx->SetPixelTolerance (aCmd.ArgInt ("pixTol")); - } + const Standard_Real aTransp = Draw::Atof (theArgVec[++anArgIter]); + const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); + aStyle->SetTransparency ((Standard_ShortReal )aTransp); + toRedraw = Standard_True; + } + else if ((anArg == "-mat" + || anArg == "-material") + && anArgIter + 1 < theArgsNb) + { + if (aType == Prs3d_TypeOfHighlight_None) + { + std::cout << "Syntax error: type of highlighting is undefined\n"; + return 1; + } - const Handle(Graphic3d_HighlightStyle)& aHiStyle = aCtx->HighlightStyle(); - const Handle(Graphic3d_HighlightStyle)& aSelStyle = aCtx->SelectionStyle(); - Standard_Boolean toRedraw = Standard_False; - if (aCmd.HasOption ("selColor")) - { - Quantity_Color aNewColor; - if (!parseColor (aCmd, "selColor", aNewColor)) - return 1; - aSelStyle->SetColor (aNewColor); - toRedraw = Standard_True; - } - if (aCmd.HasOption ("hiColor")) - { - Quantity_Color aNewColor; - if (!parseColor (aCmd, "hiColor", aNewColor)) - return 1; - aHiStyle->SetColor (aNewColor); - } - if (aCmd.HasOption ("selTransp")) - { - aSelStyle->SetTransparency (aCmd.ArgFloat ("selTransp")); - toRedraw = Standard_True; - } - if (aCmd.HasOption ("hiTransp")) - { - aHiStyle->SetTransparency (aCmd.ArgFloat ("hiTransp")); + const Handle(Prs3d_Drawer)& aStyle = aCtx->HighlightStyle (aType); + Graphic3d_NameOfMaterial aMatName = Graphic3d_MaterialAspect::MaterialFromName (theArgVec[anArgIter + 1]); + if (aMatName != Graphic3d_NOM_DEFAULT) + { + ++anArgIter; + Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d(); + *anAspect = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect(); + Graphic3d_MaterialAspect aMat (aMatName); + aMat.SetColor (aStyle->Color()); + aMat.SetTransparency (aStyle->Transparency()); + anAspect->SetFrontMaterial (aMat); + anAspect->SetInteriorColor (aStyle->Color()); + aStyle->SetBasicFillAreaAspect (anAspect); + } + else + { + aStyle->SetBasicFillAreaAspect (Handle(Graphic3d_AspectFillArea3d)()); + } + toRedraw = Standard_True; + } + else + { + std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + } } - if (aCmd.HasOption ("print") || theArgsNb == 1) + if (toPrint) { + const Handle(Prs3d_Drawer)& aHiStyle = aCtx->HighlightStyle(); + const Handle(Prs3d_Drawer)& aSelStyle = aCtx->SelectionStyle(); theDi << "Auto-activation : " << (aCtx->GetAutoActivateSelection() ? "On" : "Off") << "\n"; theDi << "Selection pixel tolerance : " << aCtx->MainSelector()->PixelTolerance() << "\n"; - theDi << "Selection color : " << Quantity_Color::StringName (aCtx->SelectionStyle()->Color().Name()) << "\n"; - theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aCtx->HighlightStyle()->Color().Name()) << "\n"; - theDi << "Selection transparency : " << aCtx->SelectionStyle()->Transparency() << "\n"; - theDi << "Dynamic highlight transparency : " << aCtx->HighlightStyle()->Transparency() << "\n"; + theDi << "Selection color : " << Quantity_Color::StringName (aSelStyle->Color().Name()) << "\n"; + theDi << "Dynamic highlight color : " << Quantity_Color::StringName (aHiStyle->Color().Name()) << "\n"; + theDi << "Selection transparency : " << aSelStyle->Transparency() << "\n"; + theDi << "Dynamic highlight transparency : " << aHiStyle->Transparency() << "\n"; + theDi << "Selection mode : " << aSelStyle->DisplayMode() << "\n"; + theDi << "Dynamic highlight mode : " << aHiStyle->DisplayMode() << "\n"; + theDi << "Selection layer : " << aSelStyle->ZLayer() << "\n"; + theDi << "Dynamic layer : " << aHiStyle->ZLayer() << "\n"; } if (aCtx->NbSelected() != 0 && toRedraw) @@ -10686,14 +10804,15 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) __FILE__, VManipulator, group); theCommands.Add("vselprops", - "\n vselprops [options]" + "\n vselprops [dynHighlight|localDynHighlight|selHighlight|localSelHighlight] [options]" "\n Customizes selection and dynamic highlight parameters for the whole interactive context:" "\n -autoActivate {0|1} : disables|enables default computation and activation of global selection mode" "\n -pixTol value : sets up pixel tolerance" - "\n -selColor {name|r g b} : sets selection color" - "\n -hiColor {name|r g b} : sets dynamic highlight color" - "\n -selTransp value : sets transparency coefficient for selection" - "\n -hiTransp value : sets transparency coefficient for dynamic highlight" + "\n -dispMode dispMode : sets display mode for highlighting" + "\n -layer ZLayer : sets ZLayer for highlighting" + "\n -color {name|r g b} : sets highlight color" + "\n -transp value : sets transparency coefficient for highlight" + "\n -material material : sets highlight material" "\n -print : prints current state of all mentioned parameters", __FILE__, VSelectionProperties, group); diff --git a/tests/bugs/vis/bug137_4 b/tests/bugs/vis/bug137_4 deleted file mode 100755 index c80fdaf0a3..0000000000 --- a/tests/bugs/vis/bug137_4 +++ /dev/null @@ -1,53 +0,0 @@ - -puts "========================" -puts "OCC137" -puts "========================" -############################################################### -#Patch description: -# -#MIT010717 : 3D selection management -#>>> MIT010717 : Selection management -# -# * Package OpenGl (OpenGl_execstruct.c) -# -# @ Avoid drawing quality problem on selected face, -# enable/disable Z offset on highlighted faces. -# -#>>> MIT010717 : drawing management -# -# * Package OpenGl (OpenGl_indexpolygon.c, ...) -# -# @ Avoid to undraw faces with confused points -############################################################### -puts "========================" - -vinit -box b 10 10 10 -vdisplay b -vfit -vsetdispmode 1 - -puts "Only bottom face should be highlighted." - -vselmode 4 1 - -OCC137 1 -OCC137_z - -set x_coord 105 -set y_coord 348 - -vmoveto $x_coord $y_coord - -set x_coord 105 -set y_coord 340 - -checkcolor $x_coord $y_coord 0 1 1 - -set x_coord 105 -set y_coord 340 -vviewparams -scale 60.6309 -proj 0.592163 -0.60038 -0.537482 -up 0.369921 -0.390032 0.843228 -at 3.29057034725635 6.73314999296002 6.55157729015654 - -checkcolor $x_coord $y_coord 0.78 0.54 0.09 - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/vis/bug137_5 b/tests/bugs/vis/bug137_5 deleted file mode 100755 index e9cf320d8a..0000000000 --- a/tests/bugs/vis/bug137_5 +++ /dev/null @@ -1,53 +0,0 @@ - -puts "========================" -puts "OCC137" -puts "========================" -############################################################### -#Patch description: -# -#MIT010717 : 3D selection management -#>>> MIT010717 : Selection management -# -# * Package OpenGl (OpenGl_execstruct.c) -# -# @ Avoid drawing quality problem on selected face, -# enable/disable Z offset on highlighted faces. -# -#>>> MIT010717 : drawing management -# -# * Package OpenGl (OpenGl_indexpolygon.c, ...) -# -# @ Avoid to undraw faces with confused points -############################################################### -puts "========================" - -vinit -box b 10 10 10 -vdisplay b -vfit -vsetdispmode 1 - -puts "Only bottom face should be highlighted." - -OCC137 1 -OCC137_z - -vselmode 4 1 - -set x_coord 105 -set y_coord 348 - -vmoveto $x_coord $y_coord - -set x_coord 105 -set y_coord 340 - -checkcolor $x_coord $y_coord 0 1 1 - -vviewparams -scale 60.6309 -proj 0.592163 -0.60038 -0.537482 -up 0.369921 -0.390032 0.843228 -at 3.29057034725635 6.73314999296002 6.55157729015654 -set x_coord 105 -set y_coord 340 - -checkcolor $x_coord $y_coord 0.78 0.54 0.09 - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/vis/bug25695 b/tests/bugs/vis/bug25695 new file mode 100644 index 0000000000..d43c37c3d8 --- /dev/null +++ b/tests/bugs/vis/bug25695 @@ -0,0 +1,22 @@ +puts "===========" +puts "OCC25695" +puts "Visualization, AIS_InteractiveContext - define default HilightMode" +puts "===========" +puts "" + +# display a sphere +pload MODELING VISUALIZATION +psphere s 1 + +vclear +vinit View1 +vdisplay -dispMode 1 s +vfit + +# setup dynamic highlighting style +vselprops dynHighlight -dispMode -1 -transp 0.5 -material PLASTIC +vmoveto 250 250 + +if { [vreadpixel 250 250 rgb name] != "PALEGREEN3" } { puts "Error: wrong highlighting color" } + +vdump $imagedir/${casename}.png diff --git a/tests/v3d/materials/bug27818_1 b/tests/v3d/materials/bug27818_1 index f89c13cfb7..8cfb4916b3 100644 --- a/tests/v3d/materials/bug27818_1 +++ b/tests/v3d/materials/bug27818_1 @@ -16,8 +16,8 @@ pcone p 15 0 40 vinit vclear -vdisplay b -dispMode 1 -highMode 1 -vdisplay p -dispMode 1 -highMode 1 +vdisplay b -dispMode 1 +vdisplay p -dispMode 1 vsetcolor b RED vsetcolor p GREEN @@ -25,7 +25,7 @@ vviewparams -scale 17.8 -proj 0.9 -0.3 0.3 vviewparams -up -0.2 0.4 0.9 -at 1.99 2.4 20.9 vviewparams -eye 56.1 -17.7 39.4 -vselprops -hiTransp 0.1 -hiColor PALEGREEN2 +vselprops dynHighlight -transp 0.1 -color PALEGREEN2 -dispMode 1 vmoveto 167 263 set aPixelColor [vreadpixel 167 263 name rgba] -- 2.20.1