From 8e5fb5eabc309751064ef241ba5ae45995697204 Mon Sep 17 00:00:00 2001 From: vpa Date: Wed, 28 Sep 2016 12:43:17 +0300 Subject: [PATCH] 0027818: Visualization - provide an interface to define highlight presentation properties - introduces a wrapper for setting up highlight properties: Graphic3d_HighlightStyle; - API of all methods that use highlight or selection color is changed to deal with Graphic3d_HighlightStyle; - highlight in shading mode now supports transparency, implemented via blending; - transparency for selection can also be set, but implementing custom entity owners with additional presentation on application level; - methods PrsMgr_PresentationManager::Highlight, PrsMgr_PresentationManager::BoundBox that highlight object with hard-coded color are removed; - deprecated methods of SelectMgr_EntityOwner, that use presentation manager's highlight method, were removed; - methods of IsHilighted AIS context with selection color checks were replaced; - added API to store dynamic and selection highlight to Prs3d_Drawer class; - customization of dynamic and selection highlight for particular objects is now available through SelectMgr_SelectableObject::HilightAttributes(); - AIS_InteractiveContext highlight methods were updated to support individual highlight styles of interactive objects; - introduced new command - vselprops, that allows to customize global selection and highlight properties like autoactivation, pixel tolerance and colors; - Draw Harness commands vautoactivatesel and vselprecision were removed, use vselprops instead; - fixed bug in command's parser; - test case for issue #27818 --- dox/dev_guides/upgrade/upgrade.md | 20 ++ .../Common/Primitive/Sample2D_Face.cpp | 4 +- .../standard/Common/Primitive/Sample2D_Face.h | 2 +- src/AIS/AIS_DimensionOwner.cxx | 19 +- src/AIS/AIS_DimensionOwner.hxx | 6 +- src/AIS/AIS_GlobalStatus.cxx | 3 - src/AIS/AIS_GlobalStatus.hxx | 26 +- src/AIS/AIS_GlobalStatus.lxx | 5 - src/AIS/AIS_InteractiveContext.cxx | 257 ++++++++---------- src/AIS/AIS_InteractiveContext.hxx | 205 ++++++++++---- src/AIS/AIS_InteractiveContext.lxx | 29 -- src/AIS/AIS_InteractiveContext_1.cxx | 219 ++++++++++++--- src/AIS/AIS_InteractiveContext_2.cxx | 84 +++--- src/AIS/AIS_LocalContext.cxx | 57 ++-- src/AIS/AIS_LocalContext.hxx | 19 +- src/AIS/AIS_LocalContext_1.cxx | 41 ++- src/AIS/AIS_LocalStatus.cxx | 31 ++- src/AIS/AIS_LocalStatus.hxx | 34 +-- src/AIS/AIS_LocalStatus.lxx | 6 - src/AIS/AIS_Manipulator.cxx | 10 +- src/AIS/AIS_Manipulator.hxx | 4 +- src/AIS/AIS_ManipulatorOwner.cxx | 21 +- src/AIS/AIS_ManipulatorOwner.hxx | 6 +- src/AIS/AIS_MultipleConnectedInteractive.cxx | 31 +-- src/Graphic3d/FILES | 2 + src/Graphic3d/Graphic3d_CStructure.hxx | 20 +- src/Graphic3d/Graphic3d_CView.cxx | 15 +- src/Graphic3d/Graphic3d_CView.hxx | 3 +- src/Graphic3d/Graphic3d_HighlightStyle.cxx | 18 ++ src/Graphic3d/Graphic3d_HighlightStyle.hxx | 117 ++++++++ src/Graphic3d/Graphic3d_Structure.cxx | 65 +---- src/Graphic3d/Graphic3d_Structure.hxx | 26 +- src/Graphic3d/Graphic3d_StructureManager.cxx | 5 +- src/Graphic3d/Graphic3d_StructureManager.hxx | 2 +- src/MeshVS/MeshVS_Mesh.cxx | 45 +-- src/MeshVS/MeshVS_Mesh.hxx | 4 +- src/MeshVS/MeshVS_MeshEntityOwner.cxx | 25 +- src/MeshVS/MeshVS_MeshEntityOwner.hxx | 10 +- src/MeshVS/MeshVS_MeshOwner.cxx | 4 +- src/MeshVS/MeshVS_MeshOwner.hxx | 4 +- src/OpenGl/OpenGl_Context.cxx | 1 + src/OpenGl/OpenGl_PrimitiveArray.cxx | 29 ++ src/OpenGl/OpenGl_Structure.cxx | 68 ++--- src/OpenGl/OpenGl_Structure.hxx | 26 +- src/Prs3d/Prs3d_Drawer.cxx | 29 +- src/Prs3d/Prs3d_Drawer.hxx | 36 +++ src/PrsMgr/PrsMgr_Presentation.cxx | 6 +- src/PrsMgr/PrsMgr_Presentation.hxx | 3 +- src/PrsMgr/PrsMgr_PresentationManager.cxx | 62 +---- src/PrsMgr/PrsMgr_PresentationManager.hxx | 12 +- src/QABugs/QABugs_16.cxx | 3 +- src/QABugs/QABugs_19.cxx | 42 +++ src/SelectMgr/SelectMgr_EntityOwner.cxx | 25 +- src/SelectMgr/SelectMgr_EntityOwner.hxx | 29 +- src/SelectMgr/SelectMgr_SelectableObject.cxx | 7 +- src/SelectMgr/SelectMgr_SelectableObject.hxx | 4 +- src/SelectMgr/SelectMgr_SequenceOfOwner.hxx | 3 +- src/StdSelect/StdSelect_BRepOwner.cxx | 73 +---- src/StdSelect/StdSelect_BRepOwner.hxx | 10 +- src/ViewerTest/ViewerTest.cxx | 172 +++--------- src/ViewerTest/ViewerTest_CmdParser.cxx | 2 +- src/ViewerTest/ViewerTest_CmdParser.hxx | 2 +- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 139 ++++++++++ tests/bugs/vis/bug23012 | 2 +- tests/bugs/vis/bug25532 | 2 +- tests/bugs/vis/bug26159 | 2 +- tests/bugs/vis/bug26413 | 8 +- tests/v3d/materials/bug27818_1 | 44 +++ tests/v3d/materials/bug27818_2 | 36 +++ 69 files changed, 1380 insertions(+), 1001 deletions(-) create mode 100644 src/Graphic3d/Graphic3d_HighlightStyle.cxx create mode 100644 src/Graphic3d/Graphic3d_HighlightStyle.hxx create mode 100644 tests/v3d/materials/bug27818_1 create mode 100644 tests/v3d/materials/bug27818_2 diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index 740b5dfd1b..834113253e 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1045,6 +1045,24 @@ Flags *Graphic3d_TMF_PanPers* and *Graphic3d_TMF_FullPers* has been removed. Several transformation persistence methods in PrsMgr_PresentableObject have been marked deprecated. Transformation persistence should be defined using directly Graphic3d_TransformPers constructor and passed by a handle, not value. +@subsection_upgrade_710_selprops Dynamic highlight and selection properties + +Release 7.1.0 introduces *Graphic3d_HighlightStyle* - an entity that allows flexible customization of highlighting parameters (such as method, highlight color and transparency). Therefore, API of methods related to highlighting in the following core classes: +- *AIS_InteractiveContext* (methods HilightWithColor(), Hilight()); +- *PrsMgr_PresentationManager* (method Color()); +- *SelectMgr_EntityOwner* (method HilightWithColor()) +was changed to process Graphic3d_HighlightStyle instead of Quantity_Color. + +Method AIS_InteractiveContext::Hilight is now deprecated and highlights interactive object with selection style. + +Group of methods AIS_InteractiveContext::IsHilighted changed behavior - now they only check object's or owner's highlight flags in global status. If highlight color is required on application level, overloaded methods AIS_InteractiveContext::HighlightStyle for owner and object must be used instead. + +The following methods were replaced in AIS_InteractiveContext API: +- *HilightColor*, *SetHilightColor* were replaced by *HighlightStyle*, *ChangeHighlightStyle*; +- *SelectionColor* setter and getter were replaced by *SelectionStyle*, *ChangeSelectionStyle*. + +API of Prs3d_Drawer was extended to allow setting up styles for both dynamic selection and highlighting. Therefore, on application level changing highlight style for particular object must be implemented via SelectMgr_SelectableObject::HilightAttributes() and processed in entity owner. + @subsection upgrade_710_removed Removed features The following obsolete features have been removed: @@ -1057,6 +1075,8 @@ The following obsolete features have been removed: * 3D viewer printing API *V3d_View::Print()* has been removed. This functionality was available on Windows platforms only. Applications should use general image dump API *V3d_View::ToPixMap()* and manage printing using platform-specific API at application level. Text resolution can be managed by rendering parameter *Graphic3d_RenderingParams::Resolution*, returned by *V3d_View::ChangeRenderingParams()*. +* Methods PrsMgr_PresentationManager::BoundBox, PrsMgr_PresentationManager::Hilight and SelectMgr_EntityOwner::Hilight were removed as not used. + Corresponding method in custom implementations of SelectMgr_EntityOwner can be removed safely. PrsMgr_PresentationManager::Color with corresponding style must be used instead of removed presentation manager's methods. @subsection upgrade_occt710_correction_of_TObj_Model Correction in TObj_Model class diff --git a/samples/mfc/standard/Common/Primitive/Sample2D_Face.cpp b/samples/mfc/standard/Common/Primitive/Sample2D_Face.cpp index 264de85a3d..1c9f44ac7d 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 Quantity_NameOfColor theColor, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner) { Handle( Prs3d_Presentation ) aHighlightPrs; @@ -347,7 +347,7 @@ void Sample2D_Face::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationMana Prs3d_Root::NewGroup ( aHighlightPrs ); Handle (Graphic3d_Group) aHilightGroup = Prs3d_Root::CurrentGroup(aHighlightPrs); Handle(Graphic3d_AspectLine3d) aLineAspect = - new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID,2); + new Graphic3d_AspectLine3d(theStyle->Color(), Aspect_TOL_SOLID,2); switch(theOwner->Priority()) { case 7: diff --git a/samples/mfc/standard/Common/Primitive/Sample2D_Face.h b/samples/mfc/standard/Common/Primitive/Sample2D_Face.h index e511d7d449..860dc04005 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 Quantity_NameOfColor theColor, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Handle(SelectMgr_EntityOwner)& theOwner); void Compute ( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, diff --git a/src/AIS/AIS_DimensionOwner.cxx b/src/AIS/AIS_DimensionOwner.cxx index 1b3c368b78..76415545fc 100755 --- a/src/AIS/AIS_DimensionOwner.cxx +++ b/src/AIS/AIS_DimensionOwner.cxx @@ -80,21 +80,6 @@ Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_Presentati return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode)); } -//======================================================================= -//function : Hilight -//purpose : -//======================================================================= -void AIS_DimensionOwner::Hilight (const Handle(PrsMgr_PresentationManager)& thePM, - const Standard_Integer /*theMode*/) -{ - if (!HasSelectable()) - { - return; - } - - thePM->Highlight (Selectable(), HighlightMode (mySelectionMode)); -} - //======================================================================= //function : Unhilight //purpose : @@ -115,8 +100,8 @@ void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& th //purpose : //======================================================================= void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Quantity_NameOfColor theColor, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer /*theMode*/) { - thePM->Color (Selectable(), theColor, HighlightMode (mySelectionMode)); + thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode)); } diff --git a/src/AIS/AIS_DimensionOwner.hxx b/src/AIS/AIS_DimensionOwner.hxx index c32b4edfa8..339f298938 100644 --- a/src/AIS/AIS_DimensionOwner.hxx +++ b/src/AIS/AIS_DimensionOwner.hxx @@ -57,14 +57,14 @@ public: Standard_EXPORT AIS_DimensionSelectionMode SelectionMode() const; - Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, const Quantity_NameOfColor theColor, const Standard_Integer theMode = 0) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode = 0) Standard_OVERRIDE; //! 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)& thePM, const Standard_Integer theMode = 0) const Standard_OVERRIDE; - Standard_EXPORT virtual void Hilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode = 0) Standard_OVERRIDE; - //! 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; diff --git a/src/AIS/AIS_GlobalStatus.cxx b/src/AIS/AIS_GlobalStatus.cxx index 04bc386728..7625b4c0aa 100644 --- a/src/AIS/AIS_GlobalStatus.cxx +++ b/src/AIS/AIS_GlobalStatus.cxx @@ -27,7 +27,6 @@ myStatus(AIS_DS_None), myDispMode(AIS_WireFrame), myLayerIndex(0), myIsHilit(Standard_False), -myHiCol(Quantity_NOC_WHITE), mySubInt(Standard_False) { } @@ -36,13 +35,11 @@ AIS_GlobalStatus::AIS_GlobalStatus(const AIS_DisplayStatus DS, const Standard_Integer DMode, const Standard_Integer SMode, const Standard_Boolean /*ishilighted*/, - const Quantity_NameOfColor TheHiCol, const Standard_Integer Layer): myStatus(DS), myDispMode(DMode), myLayerIndex(Layer), myIsHilit(Standard_False), -myHiCol(TheHiCol), mySubInt(Standard_False) { mySelModes.Append(SMode); diff --git a/src/AIS/AIS_GlobalStatus.hxx b/src/AIS/AIS_GlobalStatus.hxx index 18e44a2427..2e9079dc38 100644 --- a/src/AIS/AIS_GlobalStatus.hxx +++ b/src/AIS/AIS_GlobalStatus.hxx @@ -21,10 +21,10 @@ #include #include +#include #include #include #include -#include #include @@ -46,7 +46,7 @@ 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 Quantity_NameOfColor TheHiCol = Quantity_NOC_WHITE, const Standard_Integer aLayerIndex = 0); + 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); @@ -61,9 +61,19 @@ public: void SetLayerIndex (const Standard_Integer AnIndex); void SetHilightStatus (const Standard_Boolean aStat); - - void SetHilightColor (const Quantity_NameOfColor aHiCol); - + + //! Changes applied highlight style for a particular object + void SetHilightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) + { + myHiStyle = theStyle; + } + + //! Returns applied highlight style for a particular object + const Handle(Graphic3d_HighlightStyle)& HilightStyle() const + { + return myHiStyle; + } + Standard_Boolean IsSubIntensityOn() const; void SubIntensityOn(); @@ -81,9 +91,7 @@ public: const TColStd_ListOfInteger& SelectionModes() const; Standard_Boolean IsHilighted() const; - - Quantity_NameOfColor HilightColor() const; - + Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const; //! Returns layer index. @@ -109,7 +117,7 @@ private: TColStd_ListOfInteger mySelModes; Standard_Integer myLayerIndex; Standard_Boolean myIsHilit; - Quantity_NameOfColor myHiCol; + Handle(Graphic3d_HighlightStyle) myHiStyle; Standard_Boolean mySubInt; diff --git a/src/AIS/AIS_GlobalStatus.lxx b/src/AIS/AIS_GlobalStatus.lxx index dc0561e8a3..bd970dbb88 100644 --- a/src/AIS/AIS_GlobalStatus.lxx +++ b/src/AIS/AIS_GlobalStatus.lxx @@ -37,8 +37,6 @@ inline void AIS_GlobalStatus::SetHilightStatus(const Standard_Boolean aStat) { myIsHilit = aStat; } -inline void AIS_GlobalStatus::SetHilightColor(const Quantity_NameOfColor aCol) -{myHiCol = aCol;} inline Standard_Boolean AIS_GlobalStatus::IsSubIntensityOn() const { @@ -74,6 +72,3 @@ inline Standard_Boolean AIS_GlobalStatus::IsHilighted() const { return myIsHilit; } - -inline Quantity_NameOfColor AIS_GlobalStatus::HilightColor() const -{return myHiCol;} diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index fdcd290f44..a15351d91a 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -88,10 +88,10 @@ myFilters(new SelectMgr_OrFilter()), myDefaultDrawer(new Prs3d_Drawer()), mySelection(new AIS_Selection()), myDefaultColor(Quantity_NOC_GOLDENROD), -myHilightColor(Quantity_NOC_CYAN1), -mySelectionColor(Quantity_NOC_GRAY80), +myHiStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_CYAN1)), +mySelStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_GRAY80)), myPreselectionColor(Quantity_NOC_GREEN), -mySubIntensity(Quantity_NOC_GRAY40), +mySubintStyle(new Graphic3d_HighlightStyle (Aspect_TOHM_COLOR, Quantity_NOC_GRAY40)), myDisplayMode(0), myCurLocalIndex(0), myAISCurDetected(0), @@ -445,7 +445,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO { if(myMainPM->IsHighlighted (theIObj, anOldMode)) { - myMainPM->Unhighlight (theIObj, anOldMode); + unhighlightGlobal (theIObj, anOldMode); } myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); } @@ -457,7 +457,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO if (aStatus->IsHilighted()) { const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; - myMainPM->Color (theIObj, aStatus->HilightColor(), aHiMod); + highlightGlobal (theIObj, aStatus->HilightStyle(), aHiMod); } if (theSelectionMode != -1) { @@ -847,85 +847,47 @@ void AIS_InteractiveContext::ClearPrs (const Handle(AIS_InteractiveObject)& theI } //======================================================================= -//function : Hilight -//purpose : +//function : HilightWithColor +//purpose : //======================================================================= -void AIS_InteractiveContext::Hilight (const Handle(AIS_InteractiveObject)& theIObj, - const Standard_Boolean theToUpdateViewer) +void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Boolean theIsToUpdate) { - if (theIObj.IsNull()) - { + if (theObj.IsNull()) return; - } - if (!theIObj->HasInteractiveContext()) - { - theIObj->SetContext (this); - } + if (!theObj->HasInteractiveContext()) + theObj->SetContext (this); + if (!HasOpenedContext()) { - if (!myObjects.IsBound (theIObj)) - { + if (!myObjects.IsBound (theObj)) return; - } - Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); + const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj); aStatus->SetHilightStatus (Standard_True); + if (aStatus->GraphicStatus() == AIS_DS_Displayed) { - Standard_Integer aHilightMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; - myMainPM->Highlight (theIObj, aHilightMode); + const Standard_Integer aHilightMode = theObj->HasHilightMode() ? theObj->HilightMode() : 0; + highlightGlobal (theObj, theStyle, aHilightMode); + aStatus->SetHilightStyle (theStyle); } } else { - myLocalContexts (myCurLocalIndex)->Hilight (theIObj); + myLocalContexts (myCurLocalIndex)->Hilight (theObj, theStyle); } - if (theToUpdateViewer) - { + if (theIsToUpdate) myMainVwr->Update(); - } -} -//======================================================================= -//function : Hilight -//purpose : -//======================================================================= - -void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& anIObj, - const Quantity_NameOfColor aCol, - const Standard_Boolean updateviewer) -{ - if(anIObj.IsNull()) return; - - if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); - - if (!HasOpenedContext()) - { - if(!myObjects.IsBound(anIObj)) return; - - const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj); - aStatus->SetHilightStatus (Standard_True); - - if (aStatus->GraphicStatus() == AIS_DS_Displayed) - { - const Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; - myMainPM->Color (anIObj, aCol, aHilightMode); - aStatus->SetHilightColor (aCol); - } - } - else - { - myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol); - } - if(updateviewer) myMainVwr->Update(); } //======================================================================= //function : Unhilight //purpose : //======================================================================= - void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer) { if(anIObj.IsNull()) return; @@ -936,12 +898,12 @@ void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIO const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj); aStatus->SetHilightStatus (Standard_False); - aStatus->SetHilightColor(Quantity_NOC_WHITE); + aStatus->SetHilightStyle (new Graphic3d_HighlightStyle()); if (aStatus->GraphicStatus() == AIS_DS_Displayed) { Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; - myMainPM->Unhighlight (anIObj, aHilightMode); + unhighlightGlobal (anIObj, aHilightMode); } } else @@ -953,66 +915,35 @@ void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIO //======================================================================= //function : IsHilighted -//purpose : +//purpose : Returns true if the objects global status is set to highlighted. //======================================================================= - -Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj) const +Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const { - if(anIObj.IsNull()) return Standard_False; - - if (!HasOpenedContext()){ - if(!myObjects.IsBound(anIObj)) + if (!HasOpenedContext()) + { + if (!myObjects.IsBound (theObj)) return Standard_False; - return myObjects(anIObj)->IsHilighted(); - } - AIS_DataMapIteratorOfDataMapOfILC ItM(myLocalContexts); - for(;ItM.More();ItM.Next()){ - if(ItM.Value()->IsHilighted(anIObj)) - return Standard_True; - } - return Standard_False; -} -Standard_Boolean AIS_InteractiveContext::IsHilighted(const Handle(AIS_InteractiveObject)& anIObj, - Standard_Boolean& WithColor, - Quantity_NameOfColor& TheHiCol) const -{ - if(!HasOpenedContext()){ - if(myObjects.IsBound(anIObj)){ - const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); - if(STAT->IsHilighted()){ - if(STAT->HilightColor()!=Quantity_NOC_WHITE){ - WithColor=Standard_True; - TheHiCol = STAT->HilightColor(); - } - else - WithColor = Standard_False; - return Standard_True; - } - } - return Standard_False; + return myObjects (theObj)->IsHilighted(); } - Standard_Integer MaxIndex = HighestIndex(); - for(Standard_Integer i=MaxIndex;i>=1 ; i--){ - if(myLocalContexts.IsBound(i)){ - if(myLocalContexts(i)->IsHilighted(anIObj,WithColor,TheHiCol)) + + for (Standard_Integer aCtxIdx = HighestIndex(); aCtxIdx >= 1; aCtxIdx--) + { + if (myLocalContexts.IsBound (aCtxIdx)) + { + if (myLocalContexts (aCtxIdx)->IsHilighted (theObj)) return Standard_True; } - } + return Standard_False; } //======================================================================= //function : IsHilighted -//purpose : Returns true if the objects global status is set to highlighted. -// theIsCustomColor flag defines if highlight color is not equal to OCCT's -// default Quantity_NOC_WHITE color. If theIsCustomColor is true, -// custom highlight color name will be stored to theCustomColorName +//purpose : Returns true if the owner is highlighted with selection style. //======================================================================= -Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner, - Standard_Boolean& theIsCustomColor, - Quantity_NameOfColor& theCustomColorName) const +Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const { if (theOwner.IsNull() || !theOwner->HasSelectable()) return Standard_False; @@ -1020,26 +951,72 @@ Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_Ent const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); - if (!myObjects.IsBound (anObj)) + if (anObj->GlobalSelOwner() == theOwner) + { + if (!myObjects.IsBound (anObj)) + return Standard_False; + + return myObjects (anObj)->IsHilighted(); + } + + return theOwner->IsSelected(); +} + +//======================================================================= +//function : HighlightStyle +//purpose : +//======================================================================= +Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, + Handle(Graphic3d_HighlightStyle)& theStyle) const +{ + if (HasOpenedContext()) + myLocalContexts (myCurLocalIndex)->HighlightStyle (theObj, theStyle); + + if (IsHilighted (theObj)) + { + theStyle = myObjects (theObj)->HilightStyle(); + return Standard_True; + } + else + { + theStyle.Nullify(); return Standard_False; + } +} - const Handle(AIS_GlobalStatus)& anObjStatus = myObjects (anObj); - if (anObjStatus->IsHilighted()) +//======================================================================= +//function : HighlightStyle +//purpose : +//======================================================================= +Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, + Handle(Graphic3d_HighlightStyle)& theStyle) const +{ + if (theOwner.IsNull() || !theOwner->HasSelectable()) + return Standard_False; + + if (IsHilighted (theOwner)) { - if (anObjStatus->HilightColor() != Quantity_NOC_WHITE) + const Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + if (anObj->GlobalSelOwner() == theOwner) { - theIsCustomColor = Standard_True; - theCustomColorName = anObjStatus->HilightColor(); + theStyle = myObjects (anObj)->HilightStyle(); } else { - theIsCustomColor = Standard_False; + // since part selection style is not stored in global status, + // 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); } - return Standard_True; } - - return Standard_False; + else + { + theStyle.Nullify(); + return Standard_False; + } } //======================================================================= @@ -1356,7 +1333,7 @@ void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& t // if the object or its part is highlighted dynamically, it is necessary to apply location transformation // to its highlight structure immediately - if (!myLastPicked.IsNull() && myLastPicked->Selectable() == theIObj) + if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) { myLastPicked->UpdateHighlightTrsf (myMainVwr, myMainPM, @@ -1517,15 +1494,15 @@ void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode, if (aStatus->GraphicStatus() == AIS_DS_Displayed) { myMainPM->Display (anObj, theMode); - if (!myLastPicked.IsNull() && myLastPicked->Selectable() == anObj) + if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj)) { myMainPM->BeginImmediateDraw(); - myMainPM->Unhighlight (anObj, myDisplayMode); + unhighlightGlobal (anObj, myDisplayMode); myMainPM->EndImmediateDraw (myMainVwr); } if (aStatus->IsSubIntensityOn()) { - myMainPM->Color (anObj, mySubIntensity, theMode); + highlightWithSubintensity (anObj, theMode); } myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False); } @@ -1574,7 +1551,7 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject) { if (myMainPM->IsHighlighted (theIObj, anOldMode)) { - myMainPM->Unhighlight (theIObj, anOldMode); + unhighlightGlobal (theIObj, anOldMode); } myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); } @@ -1586,11 +1563,11 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject) GetDefModes (theIObj, aDispMode, aHiMode, aSelMode); if (aStatus->IsHilighted()) { - myMainPM->Highlight (theIObj, aHiMode); + highlightGlobal (theIObj, getSelStyle (theIObj), aHiMode); } if (aStatus->IsSubIntensityOn()) { - myMainPM->Color (theIObj, mySubIntensity, theMode); + highlightWithSubintensity (theIObj, theMode); } if (theToUpdateViewer) @@ -1632,7 +1609,7 @@ void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObjec { if (myMainPM->IsHighlighted (theIObj, anOldMode)) { - myMainPM->Unhighlight (theIObj, anOldMode); + unhighlightGlobal (theIObj, anOldMode); } myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); myMainPM->Display (theIObj, myDisplayMode); @@ -1641,11 +1618,11 @@ void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObjec GetDefModes (theIObj, aDispMode, aHiMode, aSelMode); if (aStatus->IsHilighted()) { - myMainPM->Highlight (theIObj, aHiMode); + highlightSelected (theIObj->GlobalSelOwner()); } if (aStatus->IsSubIntensityOn()) { - myMainPM->Color (theIObj, mySubIntensity, myDisplayMode); + highlightWithSubintensity (theIObj, myDisplayMode); } if (theToUpdateViewer) @@ -2054,17 +2031,21 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI theIObj->SetWidth (theWidth); redisplayPrsRecModes (theIObj, theToUpdateViewer); - if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj) + if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj)) { if (myLastinMain->IsAutoHilight()) { const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; - myLastinMain->HilightWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, aHiMode); + myLastinMain->HilightWithColor (myMainPM, + myLastinMain->IsSelected() ? getSelStyle (theIObj) : getHiStyle (theIObj), + aHiMode); } else { - theIObj->HilightOwnerWithColor (myMainPM, myLastinMain->IsSelected() ? mySelectionColor : myHilightColor, myLastinMain); + theIObj->HilightOwnerWithColor (myMainPM, + myLastinMain->IsSelected() ? getSelStyle (theIObj) : getHiStyle (theIObj), + myLastinMain); } } } @@ -2344,7 +2325,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t } else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode())) { - myMainPM->Unhighlight (theIObj, aStatus->DisplayMode()); + unhighlightGlobal (theIObj, aStatus->DisplayMode()); } } @@ -2353,11 +2334,11 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t if (aStatus->IsHilighted() && theIObj->HasHilightMode()) { - myMainPM->Unhighlight (theIObj, aDispMode); + unhighlightGlobal (theIObj, aDispMode); } if (!myLastPicked.IsNull() - && myLastPicked->Selectable() == theIObj) + && myLastPicked->IsSameSelectable (theIObj)) { myMainPM->ClearImmediateDraw(); } @@ -2390,7 +2371,7 @@ void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObje SelectMgr_SequenceOfOwner aSeq; for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { - if (aSelIter.Value()->Selectable() == theObject + if (aSelIter.Value()->IsSameSelectable (theObject) && aSelIter.Value()->IsSelected()) { aSeq.Append (aSelIter.Value()); @@ -2447,9 +2428,9 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get()); } - if (!myLastinMain.IsNull() && myLastinMain->Selectable() == theIObj) + if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj)) myLastinMain.Nullify(); - if (!myLastPicked.IsNull() && myLastPicked->Selectable() == theIObj) + if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) myLastPicked.Nullify(); myMainPM->ClearImmediateDraw(); @@ -2480,7 +2461,7 @@ void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject) if (aDispMode == theMode && myMainPM->IsHighlighted (theIObj, theMode)) { - myMainPM->Unhighlight (theIObj, theMode); + unhighlightGlobal (theIObj, theMode); } myMainPM->Erase (theIObj, theMode); diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 7840794ddd..198a44f3fa 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -277,8 +278,11 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. - Standard_EXPORT void Hilight (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Boolean updateviewer = Standard_True); - + Standard_DEPRECATED("Deprecated method Hilight()") + void Hilight (const Handle(AIS_InteractiveObject)& theObj, const Standard_Boolean theIsToUpdateViewer = Standard_True) + { + return HilightWithColor (theObj, mySelStyle, theIsToUpdateViewer); + } //! Changes the color of all the lines of the object in view, //! aniobj. It paints these lines the color passed as the @@ -287,7 +291,9 @@ public: //! Standard_False, the presentation of the Interactive //! Object activates the selection mode; the object is //! displayed but no viewer will be updated. - Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& aniobj, const Quantity_NameOfColor aCol, const Standard_Boolean updateviewer = Standard_True); + Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& theObj, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Boolean theIsToUpdate = Standard_True); //! Removes hilighting from the entity aniobj. Updates the viewer. @@ -559,19 +565,25 @@ public: Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const; Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer aMode) const; - - Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& aniobj) const; - - //! if is hilighted with a specific color - //! will be returned TRUE - //! gives the name of the hilightcolor - Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& anIobj, Standard_Boolean& WithColor, Quantity_NameOfColor& theHiCol) const; - //! if is hilighted with a specific color, than will be set - //! to true and will have the name of the color stored - Standard_EXPORT Standard_Boolean IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner, - Standard_Boolean& theIsCustomColor, - Quantity_NameOfColor& theCustomColorName) const; + //! Returns true if the object is marked as highlighted via its global + //! status + //! @param theObj [in] the object to check + Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const; + + //! Returns true if the owner is marked as selected + //! @param theOwner [in] the owner to check + Standard_EXPORT Standard_Boolean IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const; + + //! 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; + + //! 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; //! Returns the display priority of the entity anIobj. This //! will be display mode of anIobj if it is in the main @@ -621,15 +633,46 @@ public: Standard_Integer DisplayMode() const; - //! Returns the name of the color used to show - //! highlighted entities, that is, entities picked out by the mouse. - Quantity_NameOfColor HilightColor() const; - + //! 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 + { + return myHiStyle; + } + + //! Allows to manage the style of dynamic highlighting. + //! 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. + Handle(Graphic3d_HighlightStyle)& ChangeHighlightStyle() + { + return myHiStyle; + } + + //! 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 + { + return mySelStyle; + } + + //! Allows to manage the style of selection highlighting. + //! 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. + Handle(Graphic3d_HighlightStyle)& ChangeSelectionStyle() + { + return mySelStyle; + } - //! Returns the name of the color used to show selected entities. - //! By default, this is Quantity_NOC_GRAY80. - Quantity_NameOfColor SelectionColor() const; - //! Returns the name of the color used to show preselection. //! By default, this is Quantity_NOC_GREEN. Quantity_NameOfColor PreSelectionColor() const; @@ -640,34 +683,33 @@ public: Quantity_NameOfColor DefaultColor() const; - //! Returns the name of the color used to show that an - //! object is not currently selected. - //! By default, this is Quantity_NOC_GRAY40. - Quantity_NameOfColor SubIntensityColor() const; - - - //! Sets the color used to show highlighted entities, that - //! is, entities picked by the mouse. - //! By default, this is Quantity_NOC_CYAN1. - void SetHilightColor (const Quantity_NameOfColor aHiCol); - + //! Sub-intensity allows temporary highlighting of particular + //! objects with specified color in a manner of selection highlight, + //! but without actual selection (e.g., global status and owner's + //! selection state will not be updated). + //! The method returns the color of such highlighting. + //! By default, it is Quantity_NOC_GRAY40. + const Quantity_Color& SubIntensityColor() const + { + return mySubintStyle->Color(); + } - //! Sets the color used to show selected entities. - //! By default, this is Quantity_NOC_GRAY80. - void SelectionColor (const Quantity_NameOfColor aCol); - + //! Sub-intensity allows temporary highlighting of particular + //! objects with specified color in a manner of selection highlight, + //! but without actual selection (e.g., global status and owner's + //! selection state will not be updated). + //! The method sets up the color for such highlighting. + //! By default, this is Quantity_NOC_GRAY40. + void SetSubIntensityColor (const Quantity_Color& theColor) + { + mySubintStyle->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 color used to show that an object is not currently selected. - //! By default, this is Quantity_NOC_GRAY40. - void SetSubIntensityColor (const Quantity_NameOfColor aCol); - //! Sets the display mode of seen Interactive Objects. //! aMode provides the display mode index of the entity aniobj. @@ -1586,20 +1628,21 @@ protected: //! Helper function to unhighlight all entity owners currently highlighted with seleciton color. Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject); - //! Helper function that highlights the owner given with without + //! Helper function that highlights the owner given with without //! performing AutoHighlight checks, e.g. is used for dynamic highlight. - //! If the parameter is set and is true, highlight will be synchronized - //! automatically in all views of the viewer. Standard_EXPORT void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner, - const Quantity_NameOfColor theColor, const Handle(V3d_Viewer)& theViewer = NULL); - //! Helper function that highlights the owner given with with check + //! Helper function that highlights the owner given with with check //! for AutoHighlight, e.g. is used for selection. - //! If the parameter is set and is true, selection color will be synchronized - //! automatically in all views of the viewer. - Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner, - const Quantity_NameOfColor theSelColor); + Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner); + + //! Helper function that highlights global owner of the object given with with check + //! 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; //! 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. @@ -1607,6 +1650,56 @@ protected: //! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color. Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False); + //! 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; + + //! Helper function that turns on sub-intensity in global status and highlights + //! given objects with sub-intensity color + //! @param theObject [in] the object. If NULL is given, than sub-intensity will be turned on for + //! all inveractive objects of the context + //! @param theDispMode [in] display mode. If -1 is given, sub-intensity will be turned on for + //! all display modes in global status's list of modes + //! @param theIsDisplayedOnly [in] is true if sub-intensity should be applied only to objects with + //! status AIS_DS_Displayed + Standard_EXPORT void turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject = NULL, + const Standard_Integer theDispMode = -1, + const Standard_Boolean theIsDisplayedOnly = Standard_True) const; + + //! Helper function that highlights the object with sub-intensity color without any checks + //! @param theObject [in] the object that will be highlighted + //! @param theMode [in] display mode + Standard_EXPORT void highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject, + const Standard_Integer theMode) const; + + //! Helper function that highlights the owner with sub-intensity color without any checks + //! @param theOwner [in] the owner that will be highlighted + //! @param theMode [in] display mode + Standard_EXPORT void highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner, + const Standard_Integer theMode) const; + + //! 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 + const Handle(Graphic3d_HighlightStyle)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj) const + { + const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes(); + return !aHiDrawer.IsNull() && aHiDrawer->HasOwnHighlightStyle() + ? aHiDrawer->HighlightStyle() : myHiStyle; + } + + //! 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)& aHiDrawer = theObj->HilightAttributes(); + return !aHiDrawer.IsNull() && aHiDrawer->HasOwnSelectionStyle() + ? aHiDrawer->SelectionStyle() : mySelStyle; + } + protected: AIS_DataMapOfIOStatus myObjects; @@ -1624,10 +1717,10 @@ protected: Handle(Prs3d_Drawer) myDefaultDrawer; Handle(AIS_Selection) mySelection; Quantity_NameOfColor myDefaultColor; - Quantity_NameOfColor myHilightColor; - Quantity_NameOfColor mySelectionColor; + Handle(Graphic3d_HighlightStyle) myHiStyle; + Handle(Graphic3d_HighlightStyle) mySelStyle; Quantity_NameOfColor myPreselectionColor; - Quantity_NameOfColor mySubIntensity; + Handle(Graphic3d_HighlightStyle) mySubintStyle; Standard_Integer myDisplayMode; AIS_DataMapOfILC myLocalContexts; Standard_Integer myCurLocalIndex; diff --git a/src/AIS/AIS_InteractiveContext.lxx b/src/AIS/AIS_InteractiveContext.lxx index 2529b17110..9f3b25bc0e 100644 --- a/src/AIS/AIS_InteractiveContext.lxx +++ b/src/AIS/AIS_InteractiveContext.lxx @@ -17,16 +17,6 @@ inline const Handle(V3d_Viewer)& AIS_InteractiveContext::CurrentViewer() const return myMainVwr; } -inline Quantity_NameOfColor AIS_InteractiveContext::HilightColor() const -{ - return myHilightColor; -} - -inline Quantity_NameOfColor AIS_InteractiveContext::SelectionColor() const -{ - return mySelectionColor; -} - inline Quantity_NameOfColor AIS_InteractiveContext::PreSelectionColor() const { return myPreselectionColor; @@ -36,30 +26,11 @@ inline Quantity_NameOfColor AIS_InteractiveContext::DefaultColor() const { return myDefaultColor; } -inline Quantity_NameOfColor AIS_InteractiveContext::SubIntensityColor() const -{ - return mySubIntensity; -} -inline void AIS_InteractiveContext::SetHilightColor(const Quantity_NameOfColor aHiCol) -{ - myHilightColor = aHiCol; -} - -inline void AIS_InteractiveContext::SelectionColor(const Quantity_NameOfColor aCol) -{ - mySelectionColor = aCol; -} - inline void AIS_InteractiveContext::SetPreselectionColor(const Quantity_NameOfColor aCol) { myPreselectionColor = aCol; } -inline void AIS_InteractiveContext::SetSubIntensityColor(const Quantity_NameOfColor aCol) -{ - mySubIntensity = aCol; -} - inline Standard_Integer AIS_InteractiveContext::DisplayMode() const { return myDisplayMode; diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 7eeeff4193..e526bcdffc 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -64,7 +64,6 @@ namespace //purpose : //======================================================================= void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner, - const Quantity_NameOfColor theColor, const Handle(V3d_Viewer)& theViewer) { const Handle(AIS_InteractiveObject) anObj = @@ -74,7 +73,7 @@ void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOw const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; myMainPM->BeginImmediateDraw(); - theOwner->HilightWithColor (myMainPM, theColor, aHiMode); + theOwner->HilightWithColor (myMainPM, getHiStyle (anObj), aHiMode); myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer); } @@ -82,8 +81,7 @@ void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOw //function : highlightSelected //purpose : //======================================================================= -void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner, - const Quantity_NameOfColor theSelColor) +void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner) { const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); @@ -96,7 +94,7 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn SelectMgr_SequenceOfOwner aSeq; for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { - if (aSelIter.Value()->Selectable() == anObj) + if (aSelIter.Value()->IsSameSelectable (anObj)) { aSeq.Append (aSelIter.Value()); } @@ -105,7 +103,43 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn } else { - theOwner->HilightWithColor (myMainPM, theSelColor, aHiMode); + theOwner->HilightWithColor (myMainPM, getSelStyle (anObj), aHiMode); + } +} + +//======================================================================= +//function : highlightGlobal +//purpose : +//======================================================================= +void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode) const +{ + if (theObj.IsNull()) + return; + const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); + + if (aGlobOwner.IsNull()) + { + myMainPM->Color (theObj, theStyle, theMode); + return; + } + + if (!aGlobOwner->IsAutoHilight()) + { + SelectMgr_SequenceOfOwner aSeq; + for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) + { + if (aSelIter.Value()->IsSameSelectable (theObj)) + { + aSeq.Append (aSelIter.Value()); + } + } + theObj->HilightSelected (myMainPM, aSeq); + } + else + { + aGlobOwner->HilightWithColor (myMainPM, theStyle, theMode); } } @@ -128,7 +162,7 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo { if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn()) { - anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode); + highlightWithSubintensity (anOwner, aHiMode); } } } @@ -152,6 +186,112 @@ 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 +{ + if (theObj.IsNull()) + return; + const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); + + if (aGlobOwner.IsNull()) + { + myMainPM->Unhighlight (theObj, theMode); + return; + } + + if (aGlobOwner->IsAutoHilight()) + { + aGlobOwner->Unhilight (myMainPM, theMode); + } + else + { + myMainPM->Unhighlight (theObj, theMode); + theObj->ClearSelected(); + } +} + +//======================================================================= +//function : turnOnSubintensity +//purpose : +//======================================================================= +void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject, + 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()); + + if (theObject.IsNull()) + { + for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next()) + { + const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value(); + if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly) + continue; + + aStatus->SubIntensityOn(); + + if (theDispMode == -1) + { + myMainPM->Color (anObjsIter.Key(), mySubintStyle, aStatus->DisplayMode()); + } + else + myMainPM->Color (anObjsIter.Key(), mySubintStyle, theDispMode); + } + } + else + { + Handle(AIS_GlobalStatus) aStatus; + if (!myObjects.Find (theObject, aStatus)) + return; + + if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly) + return; + + aStatus->SubIntensityOn(); + + if (theDispMode == -1) + { + myMainPM->Color (theObject, mySubintStyle, aStatus->DisplayMode()); + } + else + myMainPM->Color (theObject, mySubintStyle, theDispMode); + } +} + +//======================================================================= +//function : highlightWithSubintensity +//purpose : +//======================================================================= +void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject, + const Standard_Integer theMode) const +{ + // the only differ with selection highlight is color, so + // sync transparency values + mySubintStyle->SetTransparency (mySelStyle->Transparency()); + + myMainPM->Color (theObject, mySubintStyle, theMode); +} + +//======================================================================= +//function : highlightWithSubintensity +//purpose : +//======================================================================= +void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner, + const Standard_Integer theMode) const +{ + // the only differ with selection highlight is color, so + // sync transparency values + mySubintStyle->SetTransparency (mySelStyle->Transparency()); + + theOwner->HilightWithColor (myMainPM, mySubintStyle, theMode); +} + //======================================================================= //function : MoveTo //purpose : @@ -241,7 +381,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th } else if (myToHilightSelected) { - highlightWithColor (aNewPickedOwner, mySelectionColor, theView->Viewer()); + highlightSelected (aNewPickedOwner); toUpdateViewer = Standard_True; } } @@ -255,7 +395,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th { if (!myLastPicked->IsSelected() || myToHilightSelected) { - highlightWithColor (myLastPicked, myHilightColor, theView->Viewer()); + highlightWithColor (myLastPicked, theView->Viewer()); toUpdateViewer = Standard_True; } @@ -284,7 +424,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th } else if (myToHilightSelected) { - highlightSelected (myLastPicked, mySelectionColor); + highlightSelected (myLastPicked); toUpdateViewer = Standard_True; } } @@ -766,11 +906,12 @@ 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); if (anOwner == anObj->GlobalSelOwner()) { Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObj); aState->SetHilightStatus (Standard_True); - aState->SetHilightColor (mySelectionColor); + aState->SetHilightStyle (anObjSelStyle); } anOwner->State (1); if (!anOwner->IsAutoHilight()) @@ -790,7 +931,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate else { const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; - anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode); + anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); } } @@ -891,15 +1032,17 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t if (theObject->HasSelection (0)) return; + const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = + getSelStyle (theObject); + if (NbSelected() == 1 && myObjects (theObject)->IsHilighted()) { - Quantity_NameOfColor aHiCol; - Standard_Boolean hasHiCol = Standard_False; - if (IsHilighted (theObject, hasHiCol, aHiCol)) + Handle(Graphic3d_HighlightStyle) aCustomStyle; + if (HighlightStyle (theObject, aCustomStyle)) { - if (hasHiCol && aHiCol!= mySelectionColor) + if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) { - HilightWithColor (theObject, mySelectionColor, theToUpdateViewer); + HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer); } } return; @@ -936,20 +1079,19 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t { Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (theObject); aState->SetHilightStatus (Standard_True); - aState->SetHilightColor (mySelectionColor); + aState->SetHilightStyle (anObjSelStyle); } - Quantity_NameOfColor aHiCol; - Standard_Boolean hasHiCol = Standard_False; - if (IsHilighted (theObject, hasHiCol, aHiCol)) + Handle(Graphic3d_HighlightStyle) aCustomStyle; + if (HighlightStyle (theObject, aCustomStyle)) { - if (hasHiCol && aHiCol!= mySelectionColor) + if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) { - HilightWithColor (theObject, mySelectionColor, Standard_False); + HilightWithColor (theObject, anObjSelStyle, Standard_False); } } else { - HilightWithColor (theObject, mySelectionColor, Standard_False); + HilightWithColor (theObject, anObjSelStyle, Standard_False); } if (theToUpdateViewer) @@ -968,17 +1110,18 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = + getSelStyle (anObject); if (NbSelected() == 1 && theOwner->IsSelected()) { - Quantity_NameOfColor aCustomColor; - Standard_Boolean isCustomColorSet; - if (IsHilighted (theOwner, isCustomColorSet, aCustomColor)) + Handle(Graphic3d_HighlightStyle) aCustomStyle; + if (HighlightStyle (theOwner, aCustomStyle)) { - if (isCustomColorSet && aCustomColor != mySelectionColor) + if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle) { const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0; - theOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode); + theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); } } return; @@ -990,19 +1133,19 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t unhighlightSelected(); mySelection->ClearAndSelect (theOwner); - theOwner->State (1); - Quantity_NameOfColor aCustomColor; - Standard_Boolean isCustomColorSet; - if (!IsHilighted (theOwner, isCustomColorSet, aCustomColor) || (isCustomColorSet && aCustomColor!= mySelectionColor)) + Handle(Graphic3d_HighlightStyle) aCustomStyle; + if (!HighlightStyle (theOwner, aCustomStyle) || + (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle)) { - highlightSelected (theOwner, mySelectionColor); + highlightSelected (theOwner); } + theOwner->State (1); if (theOwner == anObject->GlobalSelOwner()) { Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject); aState->SetHilightStatus (Standard_True); - aState->SetHilightColor (mySelectionColor); + aState->SetHilightStyle (anObjSelStyle); } if (theToUpdateViewer) @@ -1083,11 +1226,11 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0; if (aState == 1) { - highlightSelected (theOwner, mySelectionColor); + highlightSelected (theOwner); if (isGlobal) { aStatus->SetHilightStatus (Standard_True); - aStatus->SetHilightColor (mySelectionColor); + aStatus->SetHilightStyle (getSelStyle (anObj)); } } else @@ -1097,7 +1240,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO else anObj->ClearSelected(); aStatus->SetHilightStatus (Standard_False); - aStatus->SetHilightColor (Quantity_NOC_WHITE); + aStatus->SetHilightStyle (new Graphic3d_HighlightStyle()); } if (theToUpdateViewer) diff --git a/src/AIS/AIS_InteractiveContext_2.cxx b/src/AIS/AIS_InteractiveContext_2.cxx index f83461d332..f5d04ef424 100644 --- a/src/AIS/AIS_InteractiveContext_2.cxx +++ b/src/AIS/AIS_InteractiveContext_2.cxx @@ -60,7 +60,7 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects, const Handle(AIS_InteractiveObject) aLastPickedAIS = Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()); Standard_Integer HiMod = aLastPickedAIS->HasHilightMode()?aLastPickedAIS->HilightMode():0; - myMainPM->Unhighlight (aLastPickedAIS, HiMod); + unhighlightGlobal (aLastPickedAIS, HiMod); }} if(!mylastmoveview.IsNull()){ @@ -356,36 +356,18 @@ void AIS_InteractiveContext:: SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer) { - if(!HasOpenedContext()){ - if(!myObjects.IsBound(anIObj)) - return; - const Handle(AIS_GlobalStatus)& GB=myObjects(anIObj); - if(GB->IsSubIntensityOn()) - return; - GB->SubIntensityOn(); - Standard_Boolean UpdMain(Standard_False); - - if (GB->GraphicStatus() == AIS_DS_Displayed) - { - myMainPM->Color (anIObj, mySubIntensity, GB->DisplayMode()); - UpdMain = Standard_True; - } - if(updateviewer){ - if(UpdMain) - myMainVwr->Update(); - } + if(!HasOpenedContext()) + { + turnOnSubintensity (anIObj); } - else { - if(myObjects.IsBound(anIObj)){ - const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); - STAT->SubIntensityOn(); - myMainPM->Color (anIObj, mySubIntensity, STAT->DisplayMode()); - } - else - myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj); - - if(updateviewer) myMainVwr->Update(); + else + { + turnOnSubintensity (anIObj, -1, Standard_False); + myLocalContexts(myCurLocalIndex)->SubIntensityOn (anIObj); } + + if (updateviewer) + myMainVwr->Update(); } //======================================================================= //function : SubIntensityOff @@ -414,7 +396,7 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, Standard_Integer DM,HM,SM; GetDefModes(anIObj,DM,HM,SM); if(IsSelected(anIObj)) - myMainPM->Highlight(anIObj,HM); + highlightSelected (anIObj->GlobalSelOwner()); if(updateviewer){ if(UpdMain) @@ -422,17 +404,19 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, } } else { + const Handle(Graphic3d_HighlightStyle)& anObjSelStyle = + getSelStyle (anIObj); if(myObjects.IsBound(anIObj)){ const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); STAT->SubIntensityOff(); myMainPM->Unhighlight (anIObj, STAT->DisplayMode()); - if(STAT->IsHilighted()) - Hilight(anIObj); + if (STAT->IsHilighted()) + HilightWithColor (anIObj, anObjSelStyle, Standard_False); } else myLocalContexts(myCurLocalIndex)->SubIntensityOff(anIObj); - if(IsSelected(anIObj)) - Hilight(anIObj); + if (IsSelected(anIObj)) + HilightWithColor (anIObj, anObjSelStyle, Standard_False); if(updateviewer) myMainVwr->Update(); } @@ -442,21 +426,15 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, //function : SubIntensityOn //purpose : ALL THE DISPLAYED OBJECTS HAVE SUBINTENSITY... //======================================================================= - -void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer) +void AIS_InteractiveContext::SubIntensityOn (const Standard_Boolean theIsToUpdateViewer) { - if(!HasOpenedContext()) return; - - AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); - for(;It.More();It.Next()){ - const Handle(AIS_GlobalStatus)& STAT = It.Value(); - if(STAT->GraphicStatus()==AIS_DS_Displayed) - { - STAT->SubIntensityOn(); - myMainPM->Color (It.Key(), mySubIntensity, STAT->DisplayMode()); - } - } - if(updateviewer) myMainVwr->Update(); + if (!HasOpenedContext()) + return; + + turnOnSubintensity(); + + if (theIsToUpdateViewer) + myMainVwr->Update(); } //======================================================================= @@ -782,11 +760,11 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie // part display... myMainPM->Display (iobj, STAT->DisplayMode()); - if(STAT->IsHilighted()){ - if(STAT->HilightColor()!=Quantity_NOC_WHITE) - HilightWithColor(iobj,STAT->HilightColor(),Standard_False); - else - Hilight(iobj,Standard_False); + if(STAT->IsHilighted()) + { + const Handle(Graphic3d_HighlightStyle)& aStyle = STAT->HilightStyle(); + if (!aStyle.IsNull() && getSelStyle (iobj) != aStyle) + HilightWithColor(iobj,aStyle,Standard_False); } //part selection for(itl.Initialize(STAT->SelectionModes());itl.More();itl.Next()){ diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 7c4f7dedac..80123e9a23 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -77,7 +77,8 @@ mySelection(new AIS_Selection()), mylastindex(0), mylastgood(0), myCurDetected(0), -myAISCurDetected(0) +myAISCurDetected(0), +mySubintStyle (new Graphic3d_HighlightStyle (aCtx->SelectionStyle())) { // bind self to AIS_InteractiveContext::myLocalContexts. Further, the @@ -636,11 +637,14 @@ void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) void AIS_LocalContext::SubIntensityOn(const Handle(AIS_InteractiveObject)& anObject) { if(!myActiveObjects.IsBound(anObject)) return; + mySubintStyle->SetColor (myCTX->SubIntensityColor()); const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); - if(Att->IsTemporary()) - myMainPM->Color(anObject,myCTX->SubIntensityColor(),Att->DisplayMode()); + if(Att->IsTemporary()) + { + myMainPM->Color (anObject, mySubintStyle, Att->DisplayMode()); + } Att->SubIntensityOn(); } @@ -677,7 +681,7 @@ void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) } const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); - myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode()); + myMainPM->Color(anObject, getHiStyle (anObject), Att->HilightMode()); Att->SubIntensityOn(); } //======================================================================= @@ -685,21 +689,19 @@ void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject) //purpose : //======================================================================= -void AIS_LocalContext::Hilight(const Handle(AIS_InteractiveObject)& anObject, - const Quantity_NameOfColor Col) +void AIS_LocalContext::Hilight (const Handle(AIS_InteractiveObject)& theObj, + const Handle(Graphic3d_HighlightStyle)& theStyle) { - if(!myActiveObjects.IsBound(anObject)){ - Standard_Integer HiMod = anObject->HasHilightMode()? anObject->HilightMode() : 0; - Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(Standard_True, - Standard_False, - -1,-1,HiMod); - myActiveObjects.Bind(anObject,Att); - + if (!myActiveObjects.IsBound (theObj)) + { + Handle(AIS_LocalStatus) aStatus = new AIS_LocalStatus + (Standard_True, Standard_False, -1, -1, theObj->HasHilightMode() ? theObj->HilightMode() : 0); + myActiveObjects.Bind (theObj, aStatus); } - const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject); - myMainPM->Color(anObject,Col,Att->HilightMode()); - Att->SubIntensityOn(); - Att->SetHilightColor(Col); + const Handle(AIS_LocalStatus)& aStatus = myActiveObjects (theObj); + myMainPM->Color (theObj, theStyle, aStatus->HilightMode()); + aStatus->SubIntensityOn(); + aStatus->SetHilightStyle (theStyle); } //======================================================================= @@ -723,7 +725,7 @@ void AIS_LocalContext::Unhilight(const Handle(AIS_InteractiveObject)& anObject) myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False); Att->SubIntensityOff(); - Att->SetHilightColor(Quantity_NOC_WHITE); + Att->SetHilightStyle (new Graphic3d_HighlightStyle()); } @@ -749,19 +751,18 @@ Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObjec return myActiveObjects(anObject)->IsSubIntensityOn(); } -Standard_Boolean AIS_LocalContext::IsHilighted(const Handle(AIS_InteractiveObject)& anObject, - Standard_Boolean& WithColor, - Quantity_NameOfColor& HiCol) const +Standard_Boolean AIS_LocalContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObject, + Handle(Graphic3d_HighlightStyle)& theStyle) const { - if(!myActiveObjects.IsBound(anObject)) return Standard_False; - if( myActiveObjects(anObject)->IsSubIntensityOn()){ - HiCol = myActiveObjects(anObject)->HilightColor(); - if(HiCol==Quantity_NOC_WHITE) - WithColor = Standard_True; - else - WithColor = Standard_False; + if (!myActiveObjects.IsBound (theObject)) + return Standard_False; + + if (myActiveObjects (theObject)->IsSubIntensityOn()) + { + theStyle = myActiveObjects (theObject)->HilightStyle(); return Standard_True; } + return Standard_False; } diff --git a/src/AIS/AIS_LocalContext.hxx b/src/AIS/AIS_LocalContext.hxx index c8c648b205..1bbd5f5b64 100644 --- a/src/AIS/AIS_LocalContext.hxx +++ b/src/AIS/AIS_LocalContext.hxx @@ -302,13 +302,15 @@ public: Standard_EXPORT void Hilight (const Handle(AIS_InteractiveObject)& anObject); - Standard_EXPORT void Hilight (const Handle(AIS_InteractiveObject)& anObject, const Quantity_NameOfColor aCol); + Standard_EXPORT void Hilight (const Handle(AIS_InteractiveObject)& theObj, + const Handle(Graphic3d_HighlightStyle)& 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 IsHilighted (const Handle(AIS_InteractiveObject)& anObject, Standard_Boolean& WithColor, Quantity_NameOfColor& HiCol) const; + Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObject, + Handle(Graphic3d_HighlightStyle)& theStyle) const; //! Define the current selection sensitivity for //! this local context according to the view size. @@ -370,8 +372,17 @@ public: 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: @@ -429,7 +440,7 @@ private: Standard_Integer myCurDetected; AIS_SequenceOfInteractive myAISDetectedSeq; Standard_Integer myAISCurDetected; - + Handle(Graphic3d_HighlightStyle) mySubintStyle; }; diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 0fc721b2ed..921d245198 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -62,6 +62,28 @@ 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 : @@ -482,7 +504,7 @@ void AIS_LocalContext::Hilight (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable())); myMainPM->BeginImmediateDraw(); - theOwner->HilightWithColor (myMainPM, myCTX->HilightColor(), aHilightMode); + theOwner->HilightWithColor (myMainPM, getHiStyle (theOwner->Selectable()), aHilightMode); myMainPM->EndImmediateDraw (theView->Viewer()); } @@ -498,12 +520,13 @@ void AIS_LocalContext::Unhilight (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 Standard_Integer aHilightMode = GetHiMod (anObj); if (IsSelected (theOwner)) { if (theOwner->IsAutoHilight()) { - theOwner->HilightWithColor (myMainPM, myCTX->SelectionColor(), aHilightMode); + theOwner->HilightWithColor (myMainPM, getSelStyle (anObj), aHilightMode); } } else @@ -536,7 +559,7 @@ void AIS_LocalContext::HilightPicked (const Standard_Boolean theToUpdateviewer) { Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(aSelObj); const Standard_Integer aHighMode = GetHiMod (anIO); - anOwner->HilightWithColor (myMainPM, myCTX->SelectionColor(), aHighMode); + anOwner->HilightWithColor (myMainPM, getSelStyle (anIO), aHighMode); continue; } @@ -773,7 +796,7 @@ void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj SelectMgr_SequenceOfOwner aSeq; for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { - if (aSelIter.Value()->Selectable() == anobj) + if (aSelIter.Value()->IsSameSelectable (anobj)) { aSeq.Append (aSelIter.Value()); } @@ -863,7 +886,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec for (Standard_Integer anIdx = 1; anIdx <= myDetectedSeq.Length(); ++anIdx) { Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (anIdx)); - if (anOwner.IsNull() || anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner)) + if (anOwner.IsNull() || !anOwner->IsSameSelectable (theIO) || aValidOwners.Contains (anOwner)) { continue; } @@ -885,7 +908,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); - if (anOwner->Selectable() != theIO) + if (!anOwner->IsSameSelectable (theIO)) { continue; } @@ -921,7 +944,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec continue; } - if (anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner)) + if (!anOwner->IsSameSelectable (theIO) || aValidOwners.Contains (anOwner)) { anOwnersToKeep.Add (anOwner); } @@ -1405,7 +1428,7 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO (const H for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { - if (theObj != aSelIter.Value()->Selectable()) + if (!aSelIter.Value()->IsSameSelectable (theObj)) { continue; } diff --git a/src/AIS/AIS_LocalStatus.cxx b/src/AIS/AIS_LocalStatus.cxx index 9423020f60..faa8e7351c 100644 --- a/src/AIS/AIS_LocalStatus.cxx +++ b/src/AIS/AIS_LocalStatus.cxx @@ -20,22 +20,23 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_LocalStatus,MMgt_TShared) -AIS_LocalStatus::AIS_LocalStatus(const Standard_Boolean IsTemp, - const Standard_Boolean Decomp, - const Standard_Integer DMode, - const Standard_Integer SMode, - const Standard_Integer HMode, - const Standard_Boolean SubIntensity, - const Quantity_NameOfColor HiCol): -myDecomposition(Decomp), -myIsTemporary(IsTemp), -myDMode(DMode), -myFirstDisplay(Standard_False), -myHMode(HMode), -mySubIntensity(SubIntensity), -myHiCol(HiCol) +AIS_LocalStatus::AIS_LocalStatus (const Standard_Boolean theIsTemporary, + const Standard_Boolean theIsToDecompose, + const Standard_Integer theDisplayMode, + const Standard_Integer theSelectionMode, + const Standard_Integer theHilightMode, + const Standard_Boolean theIsSubIntensity, + const Handle(Graphic3d_HighlightStyle)& theStyle) +: myDecomposition (theIsToDecompose), + myIsTemporary (theIsTemporary), + myDMode (theDisplayMode), + myFirstDisplay (Standard_False), + myHMode (theHilightMode), + mySubIntensity (theIsSubIntensity), + myHiStyle (theStyle) { - if(SMode!=-1) mySModes.Append(SMode); + if (theSelectionMode != -1) + mySModes.Append (theSelectionMode); } diff --git a/src/AIS/AIS_LocalStatus.hxx b/src/AIS/AIS_LocalStatus.hxx index 8586690c8a..9315e350fa 100644 --- a/src/AIS/AIS_LocalStatus.hxx +++ b/src/AIS/AIS_LocalStatus.hxx @@ -17,14 +17,13 @@ #ifndef _AIS_LocalStatus_HeaderFile #define _AIS_LocalStatus_HeaderFile +#include +#include #include #include - #include #include #include -#include -#include class Standard_Transient; @@ -38,7 +37,13 @@ class AIS_LocalStatus : public MMgt_TShared public: - Standard_EXPORT AIS_LocalStatus(const Standard_Boolean IsTemporary = Standard_True, const Standard_Boolean Decompose = Standard_False, const Standard_Integer DisplayMode = -1, const Standard_Integer SelectionMode = -1, const Standard_Integer HilightMode = 0, const Standard_Boolean SubIntensity = 0, const Quantity_NameOfColor TheHiCol = Quantity_NOC_WHITE); + 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); Standard_Boolean Decomposed() const; @@ -54,7 +59,10 @@ public: Standard_Boolean IsSubIntensityOn() const; - Quantity_NameOfColor HilightColor() const; + const Handle(Graphic3d_HighlightStyle)& HilightStyle() const + { + return myHiStyle; + } void SetDecomposition (const Standard_Boolean astatus); @@ -76,7 +84,10 @@ public: void SetHilightMode (const Standard_Integer aMode); - void SetHilightColor (const Quantity_NameOfColor aHiCol); + void SetHilightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle) + { + myHiStyle = theStyle; + } void SubIntensityOn(); @@ -91,14 +102,7 @@ public: DEFINE_STANDARD_RTTIEXT(AIS_LocalStatus,MMgt_TShared) -protected: - - - - private: - - Standard_Boolean myDecomposition; Standard_Boolean myIsTemporary; Standard_Integer myDMode; @@ -106,10 +110,8 @@ private: Standard_Integer myHMode; TColStd_ListOfInteger mySModes; Standard_Boolean mySubIntensity; - Quantity_NameOfColor myHiCol; Handle(Standard_Transient) myPreviousState; - - + Handle(Graphic3d_HighlightStyle) myHiStyle; }; diff --git a/src/AIS/AIS_LocalStatus.lxx b/src/AIS/AIS_LocalStatus.lxx index 08e263949c..1c14641f73 100644 --- a/src/AIS/AIS_LocalStatus.lxx +++ b/src/AIS/AIS_LocalStatus.lxx @@ -63,9 +63,3 @@ inline void AIS_LocalStatus::SetFirstDisplay(const Standard_Boolean aStat) inline Standard_Boolean AIS_LocalStatus::IsFirstDisplay() const {return myFirstDisplay;} - -inline void AIS_LocalStatus::SetHilightColor(const Quantity_NameOfColor aCol) -{myHiCol = aCol;} - -inline Quantity_NameOfColor AIS_LocalStatus::HilightColor() const -{return myHiCol;} diff --git a/src/AIS/AIS_Manipulator.cxx b/src/AIS/AIS_Manipulator.cxx index 7b46d2b7d0..0d4afa7152 100644 --- a/src/AIS/AIS_Manipulator.cxx +++ b/src/AIS/AIS_Manipulator.cxx @@ -840,12 +840,12 @@ void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager3d if (!theSeq (1)->IsKind (STANDARD_TYPE (AIS_ManipulatorOwner))) { - thePM->Color (this, GetContext()->HilightColor(), 0); + thePM->Color (this, GetContext()->HighlightStyle(), 0); return; } Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theSeq (1)); - myHighlightAspect->Aspect()->SetInteriorColor (GetContext()->HilightColor()); + myHighlightAspect->Aspect()->SetInteriorColor (GetContext()->HighlightStyle()->Color()); Handle(Graphic3d_Group) aGroup = getGroup (anOwner->Index(), anOwner->Mode()); if (aGroup.IsNull()) { @@ -871,7 +871,9 @@ void AIS_Manipulator::ClearSelected() //function : HilightOwnerWithColor //purpose : //======================================================================= -void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner) +void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner) { Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theOwner); Handle(Prs3d_Presentation) aPresentation = getHighlightPresentation (anOwner); @@ -879,7 +881,7 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan { return; } - aPresentation->Highlight (Aspect_TOHM_COLOR, theColor); + aPresentation->Highlight (theStyle); for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups()); aGroupIter.More(); aGroupIter.Next()) { diff --git a/src/AIS/AIS_Manipulator.hxx b/src/AIS/AIS_Manipulator.hxx index 2cc9c864b3..13588bafc0 100644 --- a/src/AIS/AIS_Manipulator.hxx +++ b/src/AIS/AIS_Manipulator.hxx @@ -323,7 +323,9 @@ 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 Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; protected: diff --git a/src/AIS/AIS_ManipulatorOwner.cxx b/src/AIS/AIS_ManipulatorOwner.cxx index dd8e98f900..8aaa83181e 100644 --- a/src/AIS/AIS_ManipulatorOwner.cxx +++ b/src/AIS/AIS_ManipulatorOwner.cxx @@ -36,16 +36,16 @@ AIS_ManipulatorOwner::AIS_ManipulatorOwner (const Handle(SelectMgr_SelectableObj //purpose : //======================================================================= void AIS_ManipulatorOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, - const Quantity_NameOfColor theColor, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode) { if (theMode == 0) { - SelectMgr_EntityOwner::HilightWithColor (thePM, theColor, theMode); + SelectMgr_EntityOwner::HilightWithColor (thePM, theStyle, theMode); return; } - Selectable()->HilightOwnerWithColor (thePM, theColor, this); + Selectable()->HilightOwnerWithColor (thePM, theStyle, this); } //======================================================================= @@ -63,21 +63,6 @@ Standard_Boolean AIS_ManipulatorOwner::IsHilighted (const Handle(PrsMgr_Presenta return thePM->IsHighlighted (Selectable(), myMode); } -//======================================================================= -//function : Hilight -//purpose : -//======================================================================= -void AIS_ManipulatorOwner::Hilight (const Handle(PrsMgr_PresentationManager)& thePM, - const Standard_Integer /*theMode*/) -{ - if (!HasSelectable()) - { - return; - } - - thePM->Highlight (Selectable(), myMode); -} - //======================================================================= //function : Unhilight //purpose : diff --git a/src/AIS/AIS_ManipulatorOwner.hxx b/src/AIS/AIS_ManipulatorOwner.hxx index 95b31bb671..ac087856cb 100644 --- a/src/AIS/AIS_ManipulatorOwner.hxx +++ b/src/AIS/AIS_ManipulatorOwner.hxx @@ -37,13 +37,13 @@ public: Standard_EXPORT virtual ~AIS_ManipulatorOwner() {} - Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, const Quantity_NameOfColor theColor, const Standard_Integer theMode) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode) Standard_OVERRIDE; Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode) const Standard_OVERRIDE; - Standard_EXPORT virtual void Hilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode) Standard_OVERRIDE; - Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode) Standard_OVERRIDE; Standard_EXPORT AIS_ManipulatorMode Mode() const { return myMode; } diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 0aa8061564..69de42e23f 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -52,11 +52,9 @@ namespace Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode) const; - void Hilight (const Handle(PrsMgr_PresentationManager)& PM,const Standard_Integer aMode); - - void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, - const Quantity_NameOfColor aColor, - const Standard_Integer aMode); + void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode); void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer aMode); @@ -103,36 +101,23 @@ Standard_Boolean SelectMgr_AssemblyEntityOwner::IsHilighted (const Handle(PrsMgr return Standard_False; } -//======================================================================= -//function : Hilight -//purpose : -//======================================================================= -void SelectMgr_AssemblyEntityOwner::Hilight (const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) -{ - if (HasSelectable()) - { - PM->Highlight (myAssembly, aMode); - } -} - //======================================================================= //function : HilightWithColor //purpose : //======================================================================= -void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, - const Quantity_NameOfColor aColor, - const Standard_Integer aMode) +void SelectMgr_AssemblyEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode) { if (HasSelectable()) { if (IsAutoHilight()) { - PM->Color (myAssembly, aColor, aMode); + thePM->Color (myAssembly, theStyle, theMode); } else { - myAssembly->HilightOwnerWithColor (PM, aColor, this); + myAssembly->HilightOwnerWithColor (thePM, theStyle, this); } } } diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 6d6274f99b..7d802f65e9 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -58,6 +58,8 @@ Graphic3d_Group.cxx Graphic3d_Group.hxx Graphic3d_GroupAspect.hxx Graphic3d_GroupDefinitionError.hxx +Graphic3d_HighlightStyle.hxx +Graphic3d_HighlightStyle.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 973705d200..101c073b11 100644 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -98,6 +99,10 @@ public: //! Get z layer ID Graphic3d_ZLayerId ZLayer() const { return myZLayer; } + //! 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; } + public: //! Update structure visibility state @@ -112,13 +117,13 @@ public: //! Disconnect other structure to this one virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0; - //! Highlight entire structure with color - virtual void HighlightWithColor (const Graphic3d_Vec3& theColor, - const Standard_Boolean theToCreate) = 0; + //! Highlights structure with the given style + virtual void GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Graphic3d_Structure)& theStruct) = 0; - //! Highlight structure using boundary box - virtual void HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct, - const Standard_Boolean theToCreate) = 0; + //! Unhighlights the structure and invalidates pointer to structure's highlight + //! style + virtual void GraphicUnhighlight() = 0; //! Create shadow link to this structure virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0; @@ -136,8 +141,6 @@ public: int Priority; int PreviousPriority; - Quantity_Color HighlightColor; - int ContainsFacet; Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask @@ -164,6 +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 public: diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index 062072ad2d..db561f40d5 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -230,7 +230,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode) const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex); if (!aCompStruct->IsHighlighted()) { - aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False); + aCompStruct->Highlight (aStruct->HighlightStyle(), Standard_False); } } } @@ -248,7 +248,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode) if (aStruct->IsHighlighted()) { - aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False); + aCompStruct->Highlight (aStruct->HighlightStyle(), Standard_False); } Standard_Boolean hasResult = Standard_False; @@ -335,7 +335,7 @@ void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct) if (theStruct->IsHighlighted()) { - aCompStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False); + aCompStruct->Highlight (theStruct->HighlightStyle(), Standard_False); } // The previous calculation is removed and the new one is displayed @@ -848,7 +848,7 @@ void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure, if (theStructure->IsHighlighted()) { - aStruct->Highlight (Aspect_TOHM_COLOR, theStructure->HighlightColor(), Standard_False); + aStruct->Highlight (theStructure->HighlightStyle(), Standard_False); } // It is displayed only if the calculated structure @@ -912,14 +912,13 @@ void Graphic3d_CView::Erase (const Handle(Graphic3d_Structure)& theStructure, // function : Highlight // purpose : // ======================================================================= -void Graphic3d_CView::Highlight (const Handle(Graphic3d_Structure)& theStructure, - const Aspect_TypeOfHighlightMethod theMethod) +void Graphic3d_CView::Highlight (const Handle(Graphic3d_Structure)& theStructure) { const Standard_Integer anIndex = IsComputed (theStructure); if (anIndex != 0) { const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex); - aCompStruct->Highlight (theMethod, theStructure->HighlightColor(), Standard_False); + aCompStruct->Highlight (theStructure->HighlightStyle(), Standard_False); } } @@ -971,7 +970,7 @@ void Graphic3d_CView::UnHighlight (const Handle(Graphic3d_Structure)& theStructu if (anIndex != 0) { const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex); - aCompStruct->GraphicUnHighlight(); + aCompStruct->CStructure()->GraphicUnhighlight(); } } diff --git a/src/Graphic3d/Graphic3d_CView.hxx b/src/Graphic3d/Graphic3d_CView.hxx index 2a539a1485..2835629d92 100644 --- a/src/Graphic3d/Graphic3d_CView.hxx +++ b/src/Graphic3d/Graphic3d_CView.hxx @@ -189,8 +189,7 @@ private: const Aspect_TypeOfUpdate theUpdateMode); //! Highlights the structure in the view. - Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure, - const Aspect_TypeOfHighlightMethod theMethod); + Standard_EXPORT void Highlight (const Handle(Graphic3d_Structure)& theStructure); //! Transforms the structure in the view. Standard_EXPORT void SetTransform (const Handle(Graphic3d_Structure)& theStructure, diff --git a/src/Graphic3d/Graphic3d_HighlightStyle.cxx b/src/Graphic3d/Graphic3d_HighlightStyle.cxx new file mode 100644 index 0000000000..41327015e1 --- /dev/null +++ b/src/Graphic3d/Graphic3d_HighlightStyle.cxx @@ -0,0 +1,18 @@ +// Created on: 2016-09-23 +// 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. + +#include + +IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_HighlightStyle, Standard_Transient) diff --git a/src/Graphic3d/Graphic3d_HighlightStyle.hxx b/src/Graphic3d/Graphic3d_HighlightStyle.hxx new file mode 100644 index 0000000000..f9d945c072 --- /dev/null +++ b/src/Graphic3d/Graphic3d_HighlightStyle.hxx @@ -0,0 +1,117 @@ +// 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_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) + +#endif // _Graphic3d_HighlightStyle_HeaderFile diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 3d5a487005..d9a062c4b6 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -44,8 +44,6 @@ Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManage : myStructureManager (theManager.operator->()), myFirstStructureManager (theManager.operator->()), myComputeVisual (Graphic3d_TOS_ALL), - myHighlightColor (Quantity_NOC_WHITE), - myHighlightMethod (Aspect_TOHM_COLOR), myOwner (NULL), myVisual (Graphic3d_TOS_ALL) { @@ -61,8 +59,6 @@ Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManage : myStructureManager (theManager.operator->()), myFirstStructureManager (theManager.operator->()), myComputeVisual (thePrs->myComputeVisual), - myHighlightColor (thePrs->myHighlightColor), - myHighlightMethod (thePrs->myHighlightMethod), myOwner (thePrs->myOwner), myVisual (thePrs->myVisual) { @@ -273,17 +269,14 @@ void Graphic3d_Structure::Erase() //function : Highlight //purpose : //============================================================================= -void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod theMethod, - const Quantity_Color& theColor, - const Standard_Boolean theToUpdateMgr) +void Graphic3d_Structure::Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Boolean theToUpdateMgr) { if (IsDeleted()) { return; } - myHighlightColor = theColor; - // Highlight on already Highlighted structure. if (myCStructure->highlight) { @@ -304,7 +297,7 @@ void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod theMetho SetDisplayPriority (Structure_MAX_PRIORITY - 1); - GraphicHighlight (theMethod); + myCStructure->GraphicHighlight (theStyle, this); if (!theToUpdateMgr) { @@ -313,7 +306,7 @@ void Graphic3d_Structure::Highlight (const Aspect_TypeOfHighlightMethod theMetho if (myCStructure->stick) { - myStructureManager->Highlight (this, theMethod); + myStructureManager->Highlight (this); } Update(); @@ -350,7 +343,7 @@ void Graphic3d_Structure::UnHighlight() { myCStructure->highlight = 0; - GraphicUnHighlight(); + myCStructure->GraphicUnhighlight(); myStructureManager->UnHighlight (this); ResetDisplayPriority(); @@ -359,12 +352,12 @@ void Graphic3d_Structure::UnHighlight() } //============================================================================= -//function : HighlightColor +//function : HighlightStyle //purpose : //============================================================================= -const Quantity_Color& Graphic3d_Structure::HighlightColor() const +const Handle(Graphic3d_HighlightStyle)& Graphic3d_Structure::HighlightStyle() const { - return myHighlightColor; + return myCStructure->HighlightStyle(); } //============================================================================= @@ -1302,30 +1295,6 @@ void Graphic3d_Structure::Update (const bool theUpdateLayer) const theUpdateLayer ? myCStructure->ZLayer() : Graphic3d_ZLayerId_UNKNOWN); } -//============================================================================= -//function : GraphicHighlight -//purpose : -//============================================================================= -void Graphic3d_Structure::GraphicHighlight (const Aspect_TypeOfHighlightMethod theMethod) -{ - myCStructure->highlight = 1; - myHighlightMethod = theMethod; - switch (theMethod) - { - case Aspect_TOHM_COLOR: - { - myCStructure->HighlightWithColor (myHighlightColor, Standard_True); - break; - } - case Aspect_TOHM_BOUNDBOX: - { - myCStructure->HighlightColor = myHighlightColor; - myCStructure->HighlightWithBndBox (this, Standard_True); - break; - } - } -} - //============================================================================= //function : GraphicTransform //purpose : @@ -1335,24 +1304,6 @@ void Graphic3d_Structure::GraphicTransform (const Handle(Geom_Transformation)& t myCStructure->SetTransformation (theTrsf); } -//============================================================================= -//function : GraphicUnHighlight -//purpose : -//============================================================================= -void Graphic3d_Structure::GraphicUnHighlight() -{ - myCStructure->highlight = 0; - switch (myHighlightMethod) - { - case Aspect_TOHM_COLOR: - myCStructure->HighlightWithColor (Graphic3d_Vec3 (0.0f, 0.0f, 0.0f), Standard_False); - break; - case Aspect_TOHM_BOUNDBOX: - myCStructure->HighlightWithBndBox (this, Standard_False); - break; - } -} - //============================================================================= //function : ComputeVisual //purpose : diff --git a/src/Graphic3d/Graphic3d_Structure.hxx b/src/Graphic3d/Graphic3d_Structure.hxx index 655bf3d6ec..4f3671f836 100644 --- a/src/Graphic3d/Graphic3d_Structure.hxx +++ b/src/Graphic3d/Graphic3d_Structure.hxx @@ -22,8 +22,6 @@ #include #include -#include -#include #include #include #include @@ -46,7 +44,6 @@ class Graphic3d_StructureDefinitionError; class Graphic3d_TransformError; class Graphic3d_Group; class Graphic3d_StructureManager; -class Quantity_Color; class Graphic3d_DataStructureManager; class Bnd_Box; class gp_Pnt; @@ -105,10 +102,11 @@ public: //! of the visualiser. Standard_EXPORT virtual void Erase(); - //! Highlights the structure in all the views of the visualiser, using the following methods: - //! TOHM_COLOR = drawn in the highlight color - //! TOHM_BOUNDBOX = enclosed by the boundary box - Standard_EXPORT void Highlight (const Aspect_TypeOfHighlightMethod theMethod, const Quantity_Color& theColor, const Standard_Boolean theToUpdateMgr = Standard_True); + //! Highlights the structure in all the views with the given style + //! @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); //! Suppress the structure . //! It will be erased at the next screen update. @@ -234,7 +232,7 @@ public: //! Returns the highlight color for the Highlight method //! with the highlight method TOHM_COLOR or TOHM_BOUNDBOX. - Standard_EXPORT const Quantity_Color& HighlightColor() const; + Standard_EXPORT const Handle(Graphic3d_HighlightStyle)& HighlightStyle() const; //! Returns Standard_True if the structure is deleted. //! is deleted after the call Remove (me). @@ -362,16 +360,10 @@ public: Standard_EXPORT void GraphicConnect (const Handle(Graphic3d_Structure)& ADaughter); Standard_EXPORT void GraphicDisconnect (const Handle(Graphic3d_Structure)& ADaughter); - - //! Highlights the structure . - Standard_EXPORT void GraphicHighlight (const Aspect_TypeOfHighlightMethod Method); - + //! Internal method which sets new transformation without calling graphic manager callbacks. Standard_EXPORT void GraphicTransform (const Handle(Geom_Transformation)& theTrsf); - - //! Suppress the highlight for the structure . - Standard_EXPORT void GraphicUnHighlight(); - + //! Returns the identification number of the structure . Standard_EXPORT Standard_Integer Identification() const; @@ -454,8 +446,6 @@ protected: Handle(Graphic3d_CStructure) myCStructure; Graphic3d_IndexedMapOfAddress myAncestors; Graphic3d_IndexedMapOfAddress myDescendants; - Quantity_Color myHighlightColor; - Aspect_TypeOfHighlightMethod myHighlightMethod; Standard_Address myOwner; Graphic3d_TypeOfStructure myVisual; diff --git a/src/Graphic3d/Graphic3d_StructureManager.cxx b/src/Graphic3d/Graphic3d_StructureManager.cxx index 8e7373f769..1da498fc14 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cxx +++ b/src/Graphic3d/Graphic3d_StructureManager.cxx @@ -355,15 +355,14 @@ void Graphic3d_StructureManager::Erase (const Handle(Graphic3d_Structure)& theSt // function : Erase // purpose : // ======================================================================== -void Graphic3d_StructureManager::Highlight (const Handle(Graphic3d_Structure)& theStructure, - const Aspect_TypeOfHighlightMethod theMethod) +void Graphic3d_StructureManager::Highlight (const Handle(Graphic3d_Structure)& theStructure) { myHighlightedStructure.Add (theStructure); // Highlight in all defined views for (Graphic3d_IndexedMapOfView::Iterator aViewIt (myDefinedViews); aViewIt.More(); aViewIt.Next()) { - aViewIt.Value()->Highlight (theStructure, theMethod); + aViewIt.Value()->Highlight (theStructure); } } diff --git a/src/Graphic3d/Graphic3d_StructureManager.hxx b/src/Graphic3d/Graphic3d_StructureManager.hxx index 35fd6a7f6a..4157f21418 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.hxx +++ b/src/Graphic3d/Graphic3d_StructureManager.hxx @@ -130,7 +130,7 @@ public: Standard_EXPORT virtual void Erase (const Handle(Graphic3d_Structure)& theStructure); //! Highlights the structure. - Standard_EXPORT virtual void Highlight (const Handle(Graphic3d_Structure)& theStructure, const Aspect_TypeOfHighlightMethod theMethod); + Standard_EXPORT virtual void Highlight (const Handle(Graphic3d_Structure)& theStructure); //! Transforms the structure. Standard_EXPORT virtual void SetTransform (const Handle(Graphic3d_Structure)& theStructure, const Handle(Geom_Transformation)& theTrsf); diff --git a/src/MeshVS/MeshVS_Mesh.cxx b/src/MeshVS/MeshVS_Mesh.cxx index a1a911cf20..eed2b17486 100644 --- a/src/MeshVS/MeshVS_Mesh.cxx +++ b/src/MeshVS/MeshVS_Mesh.cxx @@ -135,6 +135,9 @@ 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)); } //================================================================ @@ -951,8 +954,9 @@ void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)& if (theOwners.Value (i) == GlobalSelOwner()) { const Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0; - const Quantity_NameOfColor aSelColor = GetContext().IsNull() ? Quantity_NOC_GRAY80 : GetContext()->SelectionColor(); - thePM->Color (this, aSelColor, aHiMode); + const Handle(Graphic3d_HighlightStyle)& aSelStyle = GetContext().IsNull() + ? HilightAttributes()->SelectionStyle() : GetContext()->SelectionStyle(); + thePM->Color (this, aSelStyle, aHiMode); continue; } anOwner = Handle (MeshVS_MeshEntityOwner)::DownCast ( theOwners.Value ( i ) ); @@ -1059,17 +1063,18 @@ void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)& // Function : HilightOwnerWithColor // Purpose : //================================================================ -void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManager3d)& PM, - const Quantity_NameOfColor Color, - const Handle(SelectMgr_EntityOwner)& Owner) +void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner) { - if (Owner.IsNull()) + if (theOwner.IsNull()) return; - if (Owner == GlobalSelOwner()) + const Quantity_Color& aColor = theStyle->Color(); + if (theOwner == GlobalSelOwner()) { Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0; - PM->Color (this, Color, aHiMode, NULL, Graphic3d_ZLayerId_Top); + thePM->Color (this, theStyle, aHiMode, NULL, Graphic3d_ZLayerId_Top); return; } @@ -1077,7 +1082,7 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage return; Handle( Prs3d_Presentation ) aHilightPrs; - aHilightPrs = GetHilightPresentation( PM ); + aHilightPrs = GetHilightPresentation( thePM ); aHilightPrs->Clear(); @@ -1086,26 +1091,26 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage aHilightPrs->SetTransformPersistence (Presentation()->TransformPersistence()); //---------------- - const Standard_Boolean isMeshEntityOwner = Owner->IsKind ( STANDARD_TYPE ( MeshVS_MeshEntityOwner ) ); + const Standard_Boolean isMeshEntityOwner = theOwner->IsKind ( STANDARD_TYPE ( MeshVS_MeshEntityOwner ) ); const Standard_Boolean isWholeMeshOwner = //agv !Owner.IsNull() && Owner==myWholeMeshOwner; - IsWholeMeshOwner (Owner); + IsWholeMeshOwner (theOwner); Standard_Integer aDispMode = MeshVS_DMF_Shading; if ( HasDisplayMode() && ( DisplayMode() & MeshVS_DMF_OCCMask ) > MeshVS_DMF_WireFrame ) aDispMode = ( DisplayMode() & MeshVS_DMF_OCCMask ); //It because we draw hilighted owners only in shading or shrink (not in wireframe) - myHilightDrawer->SetColor( MeshVS_DA_InteriorColor, Color ); - myHilightDrawer->SetColor( MeshVS_DA_BackInteriorColor, Color ); - myHilightDrawer->SetColor( MeshVS_DA_EdgeColor, Color ); - myHilightDrawer->SetColor( MeshVS_DA_BeamColor, Color ); - myHilightDrawer->SetColor( MeshVS_DA_MarkerColor, Color ); + myHilightDrawer->SetColor( MeshVS_DA_InteriorColor, aColor ); + myHilightDrawer->SetColor( MeshVS_DA_BackInteriorColor, aColor ); + myHilightDrawer->SetColor( MeshVS_DA_EdgeColor, aColor ); + myHilightDrawer->SetColor( MeshVS_DA_BeamColor, aColor ); + myHilightDrawer->SetColor( MeshVS_DA_MarkerColor, aColor ); myHilighter->SetDrawer( myHilightDrawer ); if( isMeshEntityOwner ) { - Handle ( MeshVS_MeshEntityOwner ) theAISOwner = Handle ( MeshVS_MeshEntityOwner )::DownCast ( Owner ); + Handle ( MeshVS_MeshEntityOwner ) theAISOwner = Handle ( MeshVS_MeshEntityOwner )::DownCast ( theOwner ); MeshVS_EntityType aType = theAISOwner->Type(); Standard_Integer anID = theAISOwner->ID(); @@ -1136,7 +1141,7 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage } else { - Handle(MeshVS_MeshOwner) aMeshOwner = Handle(MeshVS_MeshOwner)::DownCast ( Owner ); + Handle(MeshVS_MeshOwner) aMeshOwner = Handle(MeshVS_MeshOwner)::DownCast ( theOwner ); if( !aMeshOwner.IsNull() ) { Handle(TColStd_HPackedMapOfInteger) aNodes = aMeshOwner->GetDetectedNodes(); @@ -1159,9 +1164,9 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage aHilightPrs->SetZLayer (Graphic3d_ZLayerId_Topmost); - if (PM->IsImmediateModeOn()) + if (thePM->IsImmediateModeOn()) { - PM->AddToImmediateList (aHilightPrs); + thePM->AddToImmediateList (aHilightPrs); } myHilighter->SetDrawer ( 0 ); } diff --git a/src/MeshVS/MeshVS_Mesh.hxx b/src/MeshVS/MeshVS_Mesh.hxx index d15c562833..90ea105cb6 100644 --- a/src/MeshVS/MeshVS_Mesh.hxx +++ b/src/MeshVS/MeshVS_Mesh.hxx @@ -64,7 +64,9 @@ public: Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Owners) Standard_OVERRIDE; //! Draw hilighted owner presentation - Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, const Quantity_NameOfColor Color, const Handle(SelectMgr_EntityOwner)& Owner) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theColor, + const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; //! Clears internal selection presentation Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.cxx b/src/MeshVS/MeshVS_MeshEntityOwner.cxx index 39f1be5545..9604ced648 100644 --- a/src/MeshVS/MeshVS_MeshEntityOwner.cxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.cxx @@ -89,30 +89,13 @@ Standard_Boolean MeshVS_MeshEntityOwner::IsHilighted ( const Handle(PrsMgr_Prese return Standard_False; } -//================================================================ -// Function : Hilight -// Purpose : -//================================================================ -void MeshVS_MeshEntityOwner::Hilight () -{ -} - -//================================================================ -// Function : Hilight -// Purpose : -//================================================================ -void MeshVS_MeshEntityOwner::Hilight ( const Handle(PrsMgr_PresentationManager)&, - const Standard_Integer ) -{ -} - //================================================================ // Function : HilightWithColor // Purpose : //================================================================ -void MeshVS_MeshEntityOwner::HilightWithColor ( const Handle(PrsMgr_PresentationManager3d)& thePM, - const Quantity_NameOfColor theColor, - const Standard_Integer /*theMode*/ ) +void MeshVS_MeshEntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer /*theMode*/ ) { Handle( SelectMgr_SelectableObject ) aSelObj; if ( HasSelectable() ) @@ -121,7 +104,7 @@ void MeshVS_MeshEntityOwner::HilightWithColor ( const Handle(PrsMgr_Presentation if ( thePM->IsImmediateModeOn() && aSelObj->IsKind( STANDARD_TYPE( MeshVS_Mesh ) ) ) { Handle( MeshVS_Mesh ) aMesh = Handle( MeshVS_Mesh )::DownCast ( aSelObj ); - aMesh->HilightOwnerWithColor ( thePM, theColor, this ); + aMesh->HilightOwnerWithColor ( thePM, theStyle, this ); } } diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.hxx b/src/MeshVS/MeshVS_MeshEntityOwner.hxx index fd98274058..a3eb78a221 100644 --- a/src/MeshVS/MeshVS_MeshEntityOwner.hxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.hxx @@ -60,14 +60,10 @@ public: //! Returns true if owner is hilighted Standard_EXPORT virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer Mode = 0) const Standard_OVERRIDE; - //! Hilights owner - Standard_EXPORT virtual void Hilight() Standard_OVERRIDE; - - //! Hilights owner - Standard_EXPORT virtual void Hilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer Mode = 0) Standard_OVERRIDE; - //! Hilights owner with the certain color - Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, const Quantity_NameOfColor theColor, const Standard_Integer Mode = 0) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode = 0) Standard_OVERRIDE; //! Strip hilight of owner Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& PM, const Standard_Integer Mode = 0) Standard_OVERRIDE; diff --git a/src/MeshVS/MeshVS_MeshOwner.cxx b/src/MeshVS/MeshVS_MeshOwner.cxx index 3a01f700a6..b9c56b84f6 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 Quantity_NameOfColor theColor, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer /*theMode*/) { Handle( SelectMgr_SelectableObject ) aSelObj; @@ -167,7 +167,7 @@ void MeshVS_MeshOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager // hilight detected entities Handle( MeshVS_Mesh ) aMesh = Handle( MeshVS_Mesh )::DownCast ( aSelObj ); - aMesh->HilightOwnerWithColor ( thePM, theColor, this ); + aMesh->HilightOwnerWithColor ( thePM, theStyle, this ); } } diff --git a/src/MeshVS/MeshVS_MeshOwner.hxx b/src/MeshVS/MeshVS_MeshOwner.hxx index 4b293a3401..93a5aa5e80 100644 --- a/src/MeshVS/MeshVS_MeshOwner.hxx +++ b/src/MeshVS/MeshVS_MeshOwner.hxx @@ -67,7 +67,9 @@ public: //! Saves ids of hilighted mesh entities Standard_EXPORT void SetDetectedEntities (const Handle(TColStd_HPackedMapOfInteger)& Nodes, const Handle(TColStd_HPackedMapOfInteger)& Elems); - Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& PM, const Quantity_NameOfColor theColor, const Standard_Integer Mode = 0) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& 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 fe8be66d39..bc7ecf8bb8 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -2880,6 +2880,7 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect, if (theHighlightColor != NULL) { aParams.SetColor (*theHighlightColor); + aParams.Diffuse.a() = theHighlightColor->a(); } myActiveProgram->SetUniform (this, aLoc, OpenGl_Material::NbOfVec4(), diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 5bab0c4bcc..8c84665682 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -828,7 +828,36 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_HIDDENLINE ? myBounds->Colors : NULL; + + const Standard_Boolean isHighlightWithTransparency = toHilight && + myDrawMode > GL_LINE_STRIP && + theWorkspace->InteriorColor().a() > 0.05f; + GLint aPrevBlendSrc = GL_SRC_ALPHA, aPrevBlendDst = GL_ONE_MINUS_SRC_ALPHA; + GLboolean wasBlendEnabled = GL_FALSE; + if (isHighlightWithTransparency) + { + wasBlendEnabled = glIsEnabled (GL_BLEND); + #if !defined(GL_ES_VERSION_2_0) + glGetIntegerv (GL_BLEND_SRC, &aPrevBlendSrc); + glGetIntegerv (GL_BLEND_DST, &aPrevBlendDst); + #endif + if (!wasBlendEnabled) + { + glEnable (GL_BLEND); + } + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + drawArray (theWorkspace, aFaceColors, hasColorAttrib); + + if (isHighlightWithTransparency) + { + glBlendFunc (aPrevBlendSrc, aPrevBlendDst); + if (!wasBlendEnabled) + { + glDisable (GL_BLEND); + } + } } if (myDrawMode <= GL_LINE_STRIP) diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 75a0ac29e1..26b654e557 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -119,7 +119,6 @@ public: // ======================================================================= OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager) : Graphic3d_CStructure (theManager), - myHighlightColor (NULL), myInstancedStructure (NULL), myIsRaytracable (Standard_False), myModificationState (0), @@ -174,33 +173,13 @@ void OpenGl_Structure::clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx } } -// ======================================================================= -// function : HighlightWithColor -// purpose : -// ======================================================================= -void OpenGl_Structure::HighlightWithColor (const Graphic3d_Vec3& theColor, - const Standard_Boolean theToCreate) -{ - const Handle(OpenGl_Context)& aContext = GlDriver()->GetSharedContext(); - if (theToCreate) - setHighlightColor (aContext, theColor); - else - clearHighlightColor (aContext); -} - // ======================================================================= // function : HighlightWithBndBox // purpose : // ======================================================================= -void OpenGl_Structure::HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct, - const Standard_Boolean theToCreate) +void OpenGl_Structure::highlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct) { const Handle(OpenGl_Context)& aContext = GlDriver()->GetSharedContext(); - if (!theToCreate) - { - clearHighlightBox (aContext); - return; - } if (!myHighlightBox.IsNull()) { @@ -211,39 +190,43 @@ void OpenGl_Structure::HighlightWithBndBox (const Handle(Graphic3d_Structure)& t myHighlightBox = new OpenGl_Group (theStruct); } - myHighlightBox->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (HighlightColor, Aspect_TOL_SOLID, 1.0)); + myHighlightBox->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myHighlightStyle->Color(), Aspect_TOL_SOLID, 1.0)); OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (myBndBox); myHighlightBox->AddElement (aBndBoxPrs); } // ======================================================================= -// function : setHighlightColor +// function : GraphicHighlight // purpose : // ======================================================================= -void OpenGl_Structure::setHighlightColor (const Handle(OpenGl_Context)& theGlCtx, - const Graphic3d_Vec3& theColor) +void OpenGl_Structure::GraphicHighlight (const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(Graphic3d_Structure)& theStruct) { - clearHighlightBox (theGlCtx); - if (myHighlightColor == NULL) - { - myHighlightColor = new OpenGl_Vec4 (theColor, 1.0f); - } - else + myHighlightStyle = theStyle; + + highlight = 1; + if (myHighlightStyle->Method() == Aspect_TOHM_BOUNDBOX) { - myHighlightColor->xyz() = theColor; + highlightWithBndBox (theStruct); } } // ======================================================================= -// function : clearHighlightColor +// function : GraphicUnhighlight // purpose : // ======================================================================= -void OpenGl_Structure::clearHighlightColor (const Handle(OpenGl_Context)& theGlCtx) +void OpenGl_Structure::GraphicUnhighlight() { - clearHighlightBox(theGlCtx); - delete myHighlightColor; - myHighlightColor = NULL; + highlight = 0; + + if (myHighlightStyle->Method() == Aspect_TOHM_BOUNDBOX) + { + const Handle(OpenGl_Context)& aContext = GlDriver()->GetSharedContext(); + clearHighlightBox (aContext); + } + + myHighlightStyle.Nullify(); } // ======================================================================= @@ -450,7 +433,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); // Render named status - if (highlight) + if (highlight && myHighlightBox.IsNull()) { theWorkspace->SetHighlight (true); } @@ -521,8 +504,8 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con // Apply highlight color const OpenGl_Vec4* aHighlightColor = theWorkspace->HighlightColor; - if (myHighlightColor) - theWorkspace->HighlightColor = myHighlightColor; + if (!myHighlightStyle.IsNull()) + theWorkspace->HighlightColor = myHighlightStyle->ColorFltPtr(); // Collect clipping planes of structure scope aCtx->ChangeClipping().SetLocalPlanes (aCtx, myClipPlanes); @@ -655,7 +638,8 @@ void OpenGl_Structure::Release (const Handle(OpenGl_Context)& theGlCtx) { // Release groups Clear (theGlCtx); - clearHighlightColor (theGlCtx); + clearHighlightBox (theGlCtx); + myHighlightStyle.Nullify(); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Structure.hxx b/src/OpenGl/OpenGl_Structure.hxx index 6d30b8c6b7..efac3ace6d 100644 --- a/src/OpenGl/OpenGl_Structure.hxx +++ b/src/OpenGl/OpenGl_Structure.hxx @@ -80,13 +80,13 @@ public: //! Synchronize structure transformation Standard_EXPORT virtual void SetTransformation (const Handle(Geom_Transformation)& theTrsf) Standard_OVERRIDE; - //! Highlight entire structure with color - Standard_EXPORT virtual void HighlightWithColor (const Graphic3d_Vec3& theColor, - const Standard_Boolean theToCreate) Standard_OVERRIDE; + //! 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; - //! Highlight structure using boundary box - Standard_EXPORT virtual void HighlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct, - const Standard_Boolean theToCreate) Standard_OVERRIDE; + //! Unighlights structure and updates corresponding class fields (highlight status and style) + Standard_EXPORT virtual void GraphicUnhighlight() Standard_OVERRIDE; //! Create shadow link to this structure Standard_EXPORT virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const Standard_OVERRIDE; @@ -105,13 +105,6 @@ public: return (OpenGl_GraphicDriver* )myGraphicDriver.operator->(); } - void clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx); - - void setHighlightColor (const Handle(OpenGl_Context)& theGlCtx, - const Graphic3d_Vec3& theColor); - - void clearHighlightColor (const Handle(OpenGl_Context)& theGlCtx); - Standard_EXPORT void Clear (const Handle(OpenGl_Context)& theGlCtx); //! Renders the structure. @@ -181,10 +174,15 @@ protected: Standard_EXPORT void renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace, bool& theHasClosed) const; + //! Highlight structure using boundary box + Standard_EXPORT void highlightWithBndBox (const Handle(Graphic3d_Structure)& theStruct); + + //! Invalidates highlight box and releases graphic resources it uses + Standard_EXPORT void clearHighlightBox (const Handle(OpenGl_Context)& theGlCtx); + protected: Handle(OpenGl_Group) myHighlightBox; - OpenGl_Vec4* myHighlightColor; OpenGl_Structure* myInstancedStructure; diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index c701a587ee..723cb72876 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -94,7 +94,10 @@ Prs3d_Drawer::Prs3d_Drawer() myHasOwnDimLengthModelUnits (Standard_False), myHasOwnDimAngleModelUnits (Standard_False), myHasOwnDimLengthDisplayUnits (Standard_False), - myHasOwnDimAngleDisplayUnits (Standard_False) + myHasOwnDimAngleDisplayUnits (Standard_False), + + myHasOwnHighlightStyle (Standard_False), + myHasOwnSelectionStyle (Standard_False) { myDimensionModelUnits.SetLengthUnits ("m"); myDimensionModelUnits.SetAngleUnits ("rad"); @@ -1013,6 +1016,8 @@ void Prs3d_Drawer::ClearLocalAttributes() myDatumAspect.Nullify(); myDimensionAspect.Nullify(); mySectionAspect.Nullify(); + myHighlightStyle.Nullify(); + mySelectionStyle.Nullify(); myHasOwnUIsoAspect = Standard_False; myHasOwnVIsoAspect = Standard_False; @@ -1054,6 +1059,8 @@ 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; @@ -1240,3 +1247,23 @@ 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 5aa6900f2e..f8541dfa70 100644 --- a/src/Prs3d/Prs3d_Drawer.hxx +++ b/src/Prs3d/Prs3d_Drawer.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -823,6 +824,36 @@ 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; } @@ -937,6 +968,11 @@ 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) diff --git a/src/PrsMgr/PrsMgr_Presentation.cxx b/src/PrsMgr/PrsMgr_Presentation.cxx index d6ca61cb18..23a73f7d91 100644 --- a/src/PrsMgr/PrsMgr_Presentation.cxx +++ b/src/PrsMgr/PrsMgr_Presentation.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -125,8 +126,7 @@ void PrsMgr_Presentation::SetVisible (const Standard_Boolean theValue) //function : Highlight //purpose : //======================================================================= -void PrsMgr_Presentation::Highlight (const Aspect_TypeOfHighlightMethod theMethod, - const Quantity_Color& theColor) +void PrsMgr_Presentation::Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle) { if (!IsHighlighted()) { @@ -134,7 +134,7 @@ void PrsMgr_Presentation::Highlight (const Aspect_TypeOfHighlightMethod theMetho } display (Standard_True); - myStructure->Highlight (theMethod, theColor); + myStructure->Highlight (theStyle); } //======================================================================= diff --git a/src/PrsMgr/PrsMgr_Presentation.hxx b/src/PrsMgr/PrsMgr_Presentation.hxx index 3db0230d61..768a20e7bc 100644 --- a/src/PrsMgr/PrsMgr_Presentation.hxx +++ b/src/PrsMgr/PrsMgr_Presentation.hxx @@ -32,6 +32,7 @@ class PrsMgr_PresentableObject; class Quantity_Color; class Geom_Transformation; class Prs3d_Presentation; +class Graphic3d_HighlightStyle; class Graphic3d_Structure; class Graphic3d_DataStructureManager; class Prs3d_Projector; @@ -85,7 +86,7 @@ private: Standard_EXPORT void SetVisible (const Standard_Boolean theValue); - Standard_EXPORT void Highlight (const Aspect_TypeOfHighlightMethod theMethod, const Quantity_Color& theColor); + Standard_EXPORT void Highlight (const Handle(Graphic3d_HighlightStyle)& theStyle); Standard_EXPORT void Unhighlight() const; diff --git a/src/PrsMgr/PrsMgr_PresentationManager.cxx b/src/PrsMgr/PrsMgr_PresentationManager.cxx index 6be9a18204..e637bd5f4b 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.cxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.cxx @@ -35,8 +35,7 @@ IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_PresentationManager,MMgt_TShared) // ======================================================================= PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager) : myStructureManager (theStructureManager), - myImmediateModeOn (0), - mySelectionColor (Quantity_NOC_GRAY99) + myImmediateModeOn (0) { // } @@ -157,40 +156,6 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO Presentation (thePrsObj, theMode)->SetVisible (theValue); } -// ======================================================================= -// function : Highlight -// purpose : -// ======================================================================= -void PrsMgr_PresentationManager::Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Standard_Integer theMode) -{ - for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) - { - Highlight (anIter.Value(), theMode); - } - if (!thePrsObj->HasOwnPresentations()) - { - return; - } - - Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True); - if (aPrs->MustBeUpdated()) - { - Update (thePrsObj, theMode); - } - - if (myImmediateModeOn > 0) - { - Handle(Prs3d_PresentationShadow) aShadow = new Prs3d_PresentationShadow (myStructureManager, aPrs->Presentation()); - aShadow->Highlight (Aspect_TOHM_COLOR, mySelectionColor); - AddToImmediateList (aShadow); - } - else - { - aPrs->Highlight (Aspect_TOHM_COLOR, mySelectionColor); - } -} - // ======================================================================= // function : Unhighlight // purpose : @@ -373,7 +338,7 @@ void PrsMgr_PresentationManager::displayImmediate (const Handle(V3d_Viewer)& the aShadowPrs->SetZLayer (aViewDepPrs->CStructure()->ZLayer()); aShadowPrs->SetClipPlanes (aViewDepPrs->ClipPlanes()); aShadowPrs->CStructure()->IsForHighlight = 1; - aShadowPrs->Highlight (Aspect_TOHM_COLOR, aPrs->HighlightColor()); + aShadowPrs->Highlight (aPrs->HighlightStyle()); myViewDependentImmediateList.Append (aShadowPrs); } // handles custom highlight presentations which were defined in overridden @@ -602,14 +567,14 @@ void PrsMgr_PresentationManager::Transform (const Handle(PrsMgr_PresentableObjec // purpose : // ======================================================================= void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Quantity_NameOfColor theColor, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode, const Handle(PrsMgr_PresentableObject)& theSelObj, const Standard_Integer theImmediateStructLayerId) { for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next()) { - Color (anIter.Value(), theColor, theMode, NULL, theImmediateStructLayerId); + Color (anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId); } if (!thePrsObj->HasOwnPresentations()) { @@ -628,28 +593,13 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)& aShadow->SetZLayer (theImmediateStructLayerId); aShadow->SetClipPlanes (aPrs->Presentation()->ClipPlanes()); aShadow->CStructure()->IsForHighlight = 1; - aShadow->Highlight (Aspect_TOHM_COLOR, theColor); + aShadow->Highlight (theStyle); AddToImmediateList (aShadow); } else { - aPrs->Highlight (Aspect_TOHM_COLOR, theColor); - } -} - -// ======================================================================= -// function : BoundBox -// purpose : -// ======================================================================= -void PrsMgr_PresentationManager::BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObj, - const Standard_Integer theMode) -{ - Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode, Standard_True); - if (aPrs->MustBeUpdated()) - { - Update (thePrsObj, theMode); + aPrs->Highlight (theStyle); } - aPrs->Highlight (Aspect_TOHM_BOUNDBOX, mySelectionColor); } namespace diff --git a/src/PrsMgr/PrsMgr_PresentationManager.hxx b/src/PrsMgr/PrsMgr_PresentationManager.hxx index 86a2ccb483..0d1c4f9af5 100644 --- a/src/PrsMgr/PrsMgr_PresentationManager.hxx +++ b/src/PrsMgr/PrsMgr_PresentationManager.hxx @@ -68,11 +68,7 @@ public: //! Sets the visibility of presentable object. Standard_EXPORT void SetVisibility (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode, const Standard_Boolean theValue); - - //! Highlights the presentation of the presentable object - //! thePrsObject in this framework with the display mode theMode. - Standard_EXPORT void Highlight (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); - + //! 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); @@ -129,13 +125,10 @@ public: //! 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 Quantity_NameOfColor theColor = Quantity_NOC_YELLOW, + const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode = 0, const Handle(PrsMgr_PresentableObject)& theSelObj = NULL, const Graphic3d_ZLayerId theImmediateStructLayerId = Graphic3d_ZLayerId_Topmost); - - //! highlights the boundbox of the presentation - Standard_EXPORT void BoundBox (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Standard_Integer theMode = 0); Standard_EXPORT void Connect (const Handle(PrsMgr_PresentableObject)& thePrsObject, const Handle(PrsMgr_PresentableObject)& theOtherObject, const Standard_Integer theMode = 0, const Standard_Integer theOtherMode = 0); @@ -179,7 +172,6 @@ protected: Standard_Integer myImmediateModeOn; PrsMgr_ListOfPresentations myImmediateList; PrsMgr_ListOfPresentations myViewDependentImmediateList; - Quantity_Color mySelectionColor; private: diff --git a/src/QABugs/QABugs_16.cxx b/src/QABugs/QABugs_16.cxx index a4957a81d9..3359f1cbd4 100644 --- a/src/QABugs/QABugs_16.cxx +++ b/src/QABugs/QABugs_16.cxx @@ -156,7 +156,8 @@ static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, c Handle(AIS_InteractiveObject) aCircle=new AIS_Circle(ahCircle); myAISContext->Display(aCircle); - myAISContext->SelectionColor(Quantity_NOC_BLUE1); + Handle(Graphic3d_HighlightStyle)& aSelStyle = myAISContext->ChangeSelectionStyle(); + aSelStyle->SetColor (Quantity_NOC_BLUE1); myAISContext->AddOrRemoveSelected(aTrihedron); myAISContext->AddOrRemoveSelected(aCircle); diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index 13bbade078..e2d38288db 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -5271,6 +5271,45 @@ static Standard_Integer OCC27757 (Draw_Interpretor& /*theDI*/, Standard_Integer return 0; } +//======================================================================== +//function : OCC27818 +//purpose : Creates three boxes and highlights one of them with own style +//======================================================================== +static Standard_Integer OCC27818 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv) +{ + const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); + if (aCtx.IsNull()) + { + std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n"; + return 1; + } + + Handle(AIS_Shape) aBoxObjs[3]; + for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx) + { + TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20.0, 20.0, 20.0).Shape(); + aBoxObjs[aBoxIdx] = new AIS_Shape (aBox); + gp_Trsf aTrsf; + aTrsf.SetTranslationPart (gp_Vec (30.0 * aBoxIdx, 30.0 * aBoxIdx, 0.0)); + aBoxObjs[aBoxIdx]->SetLocalTransformation (aTrsf); + 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)); + + for (Standard_Integer aBoxIdx = 0; aBoxIdx < 3; ++aBoxIdx) + { + aCtx->Display (aBoxObjs[aBoxIdx], AIS_Shaded, 0, Standard_False); + } + + aCtx->UpdateCurrentViewer(); + + return 0; +} + //======================================================================== //function : Commands_19 //purpose : @@ -5401,5 +5440,8 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("OCC27757", "OCC27757: Creates a box that has a sphere as child object and displays it", __FILE__, OCC27757, group); + theCommands.Add ("OCC27818", + "OCC27818: Creates three boxes and highlights one of them with own style", + __FILE__, OCC27818, group); return; } diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index 560a32aaf4..76241fd123 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -80,25 +80,21 @@ Standard_Boolean SelectMgr_EntityOwner::IsHilighted(const Handle(PrsMgr_Presenta return PM->IsHighlighted(mySelectable,aMode); return Standard_False; } -void SelectMgr_EntityOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) -{if(HasSelectable()) - PM->Highlight(mySelectable,aMode); -} -void SelectMgr_EntityOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager3d)& PM, - const Quantity_NameOfColor aColor, - const Standard_Integer aMode) +void SelectMgr_EntityOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode) { - if( HasSelectable() ) { - if( IsAutoHilight() ) + if (HasSelectable()) + { + if (IsAutoHilight()) { const Graphic3d_ZLayerId aLayerId = mySelectable->GlobalSelOwner().get() == this ? Graphic3d_ZLayerId_Top : Graphic3d_ZLayerId_Topmost; - PM->Color(mySelectable,aColor,aMode, NULL, aLayerId); + thePM->Color (mySelectable, theStyle, theMode, NULL, aLayerId); } else - mySelectable->HilightOwnerWithColor( PM, aColor, this ); + mySelectable->HilightOwnerWithColor (thePM, theStyle, this); } } @@ -115,11 +111,6 @@ void SelectMgr_EntityOwner::Clear(const Handle(PrsMgr_PresentationManager)&, // nothing done on the selectable here... } - -void SelectMgr_EntityOwner:: -Hilight(){} - - //======================================================================= //function : about Transformation //purpose : diff --git a/src/SelectMgr/SelectMgr_EntityOwner.hxx b/src/SelectMgr/SelectMgr_EntityOwner.hxx index 1d0b6fcbb1..4e1cced635 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.hxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.hxx @@ -26,9 +26,10 @@ #include #include #include +#include #include +#include class Standard_NoSuchObject; -class SelectMgr_SelectableObject; class PrsMgr_PresentationManager; class TopLoc_Location; class V3d_Viewer; @@ -69,23 +70,17 @@ public: //! second constructor above. Standard_EXPORT void Set (const Handle(SelectMgr_SelectableObject)& aSO); - //! Provides a framework to highlight any selectable - //! object found subsequently which can serve as an - //! owner of a sensitive primitive. - Standard_EXPORT virtual void Hilight(); - //! 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; - //! Highlights the owner of a detected selectable object in - //! the presentation manager aPM. 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 Hilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0); - - Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM, const Quantity_NameOfColor aColor, const Standard_Integer aMode = 0); + //! Highlights selectable object's presentation with mode theMode in presentation manager + //! with given highlight style. Also a check for auto-highlight is performed - if + //! 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 Standard_Integer theMode = 0); //! Removes highlighting from the owner of a detected //! selectable object in the presentation manager aPM. @@ -136,6 +131,12 @@ public: const Handle(PrsMgr_PresentationManager3d)& theManager, const Standard_Integer theDispMode); + //! Returns true if pointer to selectable object of this owner is equal to the given one + Standard_Boolean IsSameSelectable (const Handle(SelectMgr_SelectableObject)& theOther) const + { + return mySelectable == theOther.get(); + } + DEFINE_STANDARD_RTTIEXT(SelectMgr_EntityOwner,SelectBasics_EntityOwner) diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index 8b18242bb4..52fc4cfd91 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -318,10 +318,9 @@ void SelectMgr_SelectableObject::ClearSelected () //function : HilightOwnerWithColor //purpose : //======================================================================= -void SelectMgr_SelectableObject::HilightOwnerWithColor - ( const Handle(PrsMgr_PresentationManager3d)&, - const Quantity_NameOfColor, - const Handle(SelectMgr_EntityOwner)&) +void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&, + const Handle(Graphic3d_HighlightStyle)&, + const Handle(SelectMgr_EntityOwner)&) { Standard_NotImplemented::Raise ("SelectMgr_SelectableObject::HilightOwnerWithColor"); } diff --git a/src/SelectMgr/SelectMgr_SelectableObject.hxx b/src/SelectMgr/SelectMgr_SelectableObject.hxx index 3ce3d8ac92..85909135d1 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.hxx @@ -142,7 +142,9 @@ 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 Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner); + Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner); //! If returns True, the old mechanism for highlighting //! selected objects is used (HilightSelected Method may be empty). diff --git a/src/SelectMgr/SelectMgr_SequenceOfOwner.hxx b/src/SelectMgr/SelectMgr_SequenceOfOwner.hxx index 56235e472e..0b020979c6 100644 --- a/src/SelectMgr/SelectMgr_SequenceOfOwner.hxx +++ b/src/SelectMgr/SelectMgr_SequenceOfOwner.hxx @@ -17,9 +17,10 @@ #ifndef SelectMgr_SequenceOfOwner_HeaderFile #define SelectMgr_SequenceOfOwner_HeaderFile -#include #include +class SelectMgr_EntityOwner; + typedef NCollection_Sequence SelectMgr_SequenceOfOwner; diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx index 1606886005..6a7a6b24bd 100644 --- a/src/StdSelect/StdSelect_BRepOwner.cxx +++ b/src/StdSelect/StdSelect_BRepOwner.cxx @@ -75,71 +75,18 @@ IsHilighted(const Handle(PrsMgr_PresentationManager)& PM, } //======================================================================= -//function : Hilight/Unhilight Methods... -//purpose : +//function : HilightWithColor +//purpose : //======================================================================= -void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM, - const Standard_Integer aMode) -{ - - Standard_Integer M = (aMode < 0) ? myCurMode : aMode; - Handle(SelectMgr_SelectableObject) aSel = Selectable(); - if (myFromDecomposition) - { - // 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); - } - - // generate new presentable shape - if (myPrsSh.IsNull()) - { - myPrsSh = new StdSelect_Shape (myShape, aDrawer); - } - if (!aSel.IsNull()) - { - myPrsSh->SetZLayer (aSel->ZLayer()); - myPrsSh->SetTransformPersistence (aSel->TransformPersistence()); - } - - // highlight and set layer - PM->Highlight (myPrsSh, M); - } - else - { - if(myPrsSh.IsNull()) - PM->Highlight(aSel,M); - else - PM->Highlight(myPrsSh,M); - } -} - -void StdSelect_BRepOwner::Hilight() -{} - -void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager3d)& PM, - const Quantity_NameOfColor aCol, - const Standard_Integer aMode) +void StdSelect_BRepOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode) { - Standard_Integer M = (aMode < 0) ? myCurMode : aMode; + 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) { // do the update flag check @@ -181,17 +128,17 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag } // highlight with color and set layer - PM->Color (myPrsSh, aCol, M, aSel, aHiLayer); + thePM->Color (myPrsSh, theStyle, M, aSel, aHiLayer); } else { if (!myPrsSh.IsNull()) { - PM->Color (myPrsSh, aCol, M, aSel, aHiLayer); + thePM->Color (myPrsSh, theStyle, M, aSel, aHiLayer); } else { - PM->Color (aSel, aCol, M, NULL, aHiLayer); + thePM->Color (aSel, theStyle, M, NULL, aHiLayer); } } } diff --git a/src/StdSelect/StdSelect_BRepOwner.hxx b/src/StdSelect/StdSelect_BRepOwner.hxx index 55bc9bc2f9..141781bf7e 100644 --- a/src/StdSelect/StdSelect_BRepOwner.hxx +++ b/src/StdSelect/StdSelect_BRepOwner.hxx @@ -107,13 +107,9 @@ public: //! 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 Hilight() Standard_OVERRIDE; - - //! Returns the selection mode aMode defining the type - //! of shape highlighted in the presentation manager aPM. - Standard_EXPORT virtual void Hilight (const Handle(PrsMgr_PresentationManager)& aPM, const Standard_Integer aMode = 0) Standard_OVERRIDE; - - Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM, const Quantity_NameOfColor aCol, const Standard_Integer aMode = 0) Standard_OVERRIDE; + Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Standard_Integer theMode = 0) Standard_OVERRIDE; //! Removes highlighting from the type of shape //! identified the selection mode aMode in the presentation manager aPM. diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index f66ed35102..f656fad181 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -735,47 +735,6 @@ static int VDir (Draw_Interpretor& theDI, return 0; } -//============================================================================== -//function : VSelPrecision -//purpose : To set the selection tolerance value -//Draw arg : Selection tolerance value (real value determining the width and -// height of selecting frustum bases). Without arguments the function -// just prints current tolerance. -//============================================================================== -static int VSelPrecision(Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - if( argc > 2 ) - { - di << "Wrong parameters! Must be: " << argv[0] << " [-unset] [tolerance]\n"; - return 1; - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if( aContext.IsNull() ) - return 1; - - if( argc == 1 ) - { - Standard_Real aPixelTolerance = aContext->PixelTolerance(); - di << "Pixel tolerance : " << aPixelTolerance << "\n"; - } - else if (argc == 2) - { - TCollection_AsciiString anArg = TCollection_AsciiString (argv[1]); - anArg.LowerCase(); - if (anArg == "-unset") - { - aContext->SetPixelTolerance (-1); - } - else - { - aContext->SetPixelTolerance (anArg.IntegerValue()); - } - } - - return 0; -} - //! Auxiliary enumeration enum ViewerTest_StereoPair { @@ -2918,32 +2877,33 @@ static int VDisplayAll (Draw_Interpretor& , return 0; } -//! Auxiliary method to find presentation -inline Handle(PrsMgr_Presentation) findPresentation (const Handle(AIS_InteractiveContext)& theCtx, - const Handle(AIS_InteractiveObject)& theIO, - const Standard_Integer theMode) +//! Auxiliary method to check if presentation exists +inline Standard_Integer checkMode (const Handle(AIS_InteractiveContext)& theCtx, + const Handle(AIS_InteractiveObject)& theIO, + const Standard_Integer theMode) { - if (theIO.IsNull()) + if (theIO.IsNull() || theCtx.IsNull()) { - return Handle(PrsMgr_Presentation)(); + return -1; } if (theMode != -1) { if (theCtx->MainPrsMgr()->HasPresentation (theIO, theMode)) { - return theCtx->MainPrsMgr()->Presentation (theIO, theMode); + return theMode; } } else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theIO->DisplayMode())) { - return theCtx->MainPrsMgr()->Presentation (theIO, theIO->DisplayMode()); + return theIO->DisplayMode(); } else if (theCtx->MainPrsMgr()->HasPresentation (theIO, theCtx->DisplayMode())) { - return theCtx->MainPrsMgr()->Presentation (theIO, theCtx->DisplayMode()); + return theCtx->DisplayMode(); } - return Handle(PrsMgr_Presentation)(); + + return -1; } enum ViewerTest_BndAction @@ -2954,28 +2914,36 @@ enum ViewerTest_BndAction }; //! Auxiliary method to print bounding box of presentation -inline void bndPresentation (Draw_Interpretor& theDI, - const Handle(PrsMgr_Presentation)& thePrs, - const TCollection_AsciiString& theName, - const ViewerTest_BndAction theAction) +inline void bndPresentation (Draw_Interpretor& theDI, + const Handle(PrsMgr_PresentationManager)& theMgr, + const Handle(AIS_InteractiveObject)& theObj, + const Standard_Integer theDispMode, + const TCollection_AsciiString& theName, + const ViewerTest_BndAction theAction, + const Handle(Graphic3d_HighlightStyle)& theStyle) { switch (theAction) { case BndAction_Hide: { - thePrs->Presentation()->GraphicUnHighlight(); + theMgr->Unhighlight (theObj, theDispMode); break; } case BndAction_Show: { - Handle(Graphic3d_Structure) aPrs (thePrs->Presentation()); - aPrs->CStructure()->HighlightColor = Quantity_NOC_GRAY99; - aPrs->CStructure()->HighlightWithBndBox (aPrs, Standard_True); + theMgr->Color (theObj, theStyle, theDispMode); break; } case BndAction_Print: { - Bnd_Box aBox = thePrs->Presentation()->MinMaxValues(); + Bnd_Box aBox; + for (PrsMgr_Presentations::Iterator aPrsIter (theObj->Presentations()); aPrsIter.More(); aPrsIter.Next()) + { + if (aPrsIter.Value().Mode() != theDispMode) + continue; + + aBox = aPrsIter.Value().Presentation()->Presentation()->MinMaxValues(); + } gp_Pnt aMin = aBox.CornerMin(); gp_Pnt aMax = aBox.CornerMax(); theDI << theName << "\n" @@ -3005,6 +2973,8 @@ int VBounding (Draw_Interpretor& theDI, ViewerTest_BndAction anAction = BndAction_Show; Standard_Integer aMode = -1; + Handle(Graphic3d_HighlightStyle) aStyle; + Standard_Integer anArgIter = 1; for (; anArgIter < theArgNb; ++anArgIter) { @@ -3037,6 +3007,10 @@ int VBounding (Draw_Interpretor& theDI, } } + if (anAction == BndAction_Show) + aStyle = new Graphic3d_HighlightStyle (Aspect_TOHM_BOUNDBOX, Quantity_NOC_GRAY99, 0.0); + + Standard_Integer aHighlightedMode = -1; if (anArgIter < theArgNb) { // has a list of names @@ -3050,13 +3024,13 @@ int VBounding (Draw_Interpretor& theDI, } Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName)); - Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); - if (aPrs.IsNull()) + aHighlightedMode = checkMode (aCtx, anIO, aMode); + if (aHighlightedMode == -1) { - std::cout << "Error: presentation " << aName << " does not exist\n"; + std::cout << "Error: object " << aName << " has no presentation with mode " << aMode << std::endl; return 1; } - bndPresentation (theDI, aPrs, aName, anAction); + bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, aName, anAction, aStyle); } } else if (aCtx->NbSelected() > 0) @@ -3065,10 +3039,11 @@ int VBounding (Draw_Interpretor& theDI, for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected()) { Handle(AIS_InteractiveObject) anIO = aCtx->SelectedInteractive(); - Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); - if (!aPrs.IsNull()) + aHighlightedMode = checkMode (aCtx, anIO, aMode); + if (aHighlightedMode != -1) { - bndPresentation (theDI, aPrs, GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction); + bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, + GetMapOfAIS().IsBound1 (anIO) ? GetMapOfAIS().Find1 (anIO) : "", anAction, aStyle); } } } @@ -3079,10 +3054,10 @@ int VBounding (Draw_Interpretor& theDI, anIter.More(); anIter.Next()) { Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1()); - Handle(PrsMgr_Presentation) aPrs = findPresentation (aCtx, anIO, aMode); - if (!aPrs.IsNull()) + aHighlightedMode = checkMode (aCtx, anIO, aMode); + if (aHighlightedMode != -1) { - bndPresentation (theDI, aPrs, anIter.Key2(), anAction); + bndPresentation (theDI, aCtx->MainPrsMgr(), anIO, aHighlightedMode, anIter.Key2(), anAction, aStyle); } } } @@ -5540,51 +5515,6 @@ static Standard_Integer VLoadSelection (Draw_Interpretor& /*theDi*/, return 0; } -//============================================================================== -//function : VAutoActivateSelection -//purpose : Activates or deactivates auto computation of selection -//============================================================================== -static int VAutoActivateSelection (Draw_Interpretor& theDi, - Standard_Integer theArgNb, - const char** theArgVec) -{ - - if (theArgNb > 2) - { - std::cerr << theArgVec[0] << "Error: wrong number of arguments.\n"; - return 1; - } - - Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); - if (aCtx.IsNull()) - { - ViewerTest::ViewerInit(); - aCtx = ViewerTest::GetAISContext(); - } - - if (theArgNb == 1) - { - TCollection_AsciiString aSelActivationString; - if (aCtx->GetAutoActivateSelection()) - { - aSelActivationString.Copy ("ON"); - } - else - { - aSelActivationString.Copy ("OFF"); - } - - theDi << "Auto activation of selection is: " << aSelActivationString << "\n"; - } - else - { - Standard_Boolean toActivate = Draw::Atoi (theArgVec[1]) != 0; - aCtx->SetAutoActivateSelection (toActivate); - } - - return 0; -} - //============================================================================== //function : ViewerTest::Commands //purpose : Add all the viewer command in the Draw_Interpretor @@ -5828,12 +5758,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "vsensera : erase active entities", __FILE__,VClearSensi,group); - theCommands.Add("vselprecision", - "vselprecision [-unset] [tolerance_value]" - "\n\t\t Manages selection precision or prints current value if no parameter is passed." - "\n\t\t -unset - restores default selection tolerance behavior, based on individual entity tolerance", - __FILE__,VSelPrecision,group); - theCommands.Add("vperf", "vperf: vperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)" "\n\t\t: Tests the animation of an object along a predefined trajectory.", @@ -5944,12 +5868,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: -local - open local context before selection computation", __FILE__, VLoadSelection, group); - theCommands.Add ("vautoactivatesel", - "vautoactivatesel [0|1] : manage or display the option to automatically" - "\n\t\t: activate selection for newly displayed objects" - "\n\t\t: [0|1] - turn off | on auto activation of selection", - __FILE__, VAutoActivateSelection, group); - theCommands.Add("vbsdf", "vbsdf [name] [options]" "\nAdjusts parameters of material BSDF:" "\n -help : Shows this message" diff --git a/src/ViewerTest/ViewerTest_CmdParser.cxx b/src/ViewerTest/ViewerTest_CmdParser.cxx index 2e72813149..d20def44ea 100644 --- a/src/ViewerTest/ViewerTest_CmdParser.cxx +++ b/src/ViewerTest/ViewerTest_CmdParser.cxx @@ -95,7 +95,7 @@ void ViewerTest_CmdParser::Parse (Standard_Integer theArgsNb, const char** theAr for (Standard_Integer anIter = 1; anIter < theArgsNb; ++anIter) { - if (theArgVec[anIter][0] == '-') + if (theArgVec[anIter][0] == '-' && !std::isdigit (theArgVec[anIter][1])) { std::string anOptionName (&theArgVec[anIter][1]); std::transform (anOptionName.begin(), anOptionName.end(), anOptionName.begin(), ::tolower); diff --git a/src/ViewerTest/ViewerTest_CmdParser.hxx b/src/ViewerTest/ViewerTest_CmdParser.hxx index d53c942b4a..22487ca412 100644 --- a/src/ViewerTest/ViewerTest_CmdParser.hxx +++ b/src/ViewerTest/ViewerTest_CmdParser.hxx @@ -40,7 +40,7 @@ public: } //! Adds option to available option list. Several names may be provided if separated with '|'. - void AddOption (const std::string& theOptionNames, const std::string& theOptionDescription); + void AddOption (const std::string& theOptionNames, const std::string& theOptionDescription = ""); //! Prints help message based on provided command and options descriptions. void Help(); diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 1aa1699feb..2baaea1c53 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -9025,6 +9025,133 @@ 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 : +//=============================================================================================== +static int VSelectionProperties (Draw_Interpretor& theDi, + Standard_Integer theArgsNb, + const char** theArgVec) +{ + const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext(); + if (aCtx.IsNull()) + { + std::cerr << "No active viewer!\n"; + return 1; + } + + ViewerTest_CmdParser aCmd; + + aCmd.AddOption ("autoActivate"); + aCmd.AddOption ("pixTol"); + + aCmd.AddOption ("selColor"); + aCmd.AddOption ("hiColor"); + aCmd.AddOption ("selTransp"); + aCmd.AddOption ("hiTransp"); + + aCmd.AddOption ("print"); + + aCmd.Parse (theArgsNb, theArgVec); + + if (aCmd.HasOption ("help")) + { + theDi.PrintHelp (theArgVec[0]); + return 0; + } + + if (aCmd.HasOption ("autoActivate", 1, Standard_False)) + { + aCtx->SetAutoActivateSelection (aCmd.ArgBool ("autoActivate")); + } + if (aCmd.HasOption ("pixTol", 1, Standard_False)) + { + aCtx->SetPixelTolerance (aCmd.ArgInt ("pixTol")); + } + + Handle(Graphic3d_HighlightStyle)& aHiStyle = aCtx->ChangeHighlightStyle(); + Handle(Graphic3d_HighlightStyle)& aSelStyle = aCtx->ChangeSelectionStyle(); + 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")); + } + + if (aCmd.HasOption ("print") || theArgsNb == 1) + { + 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"; + } + + if (aCtx->NbSelected() != 0 && toRedraw) + { + aCtx->HilightSelected (Standard_True); + } + + return 0; +} + //======================================================================= //function : ViewerCommands //purpose : @@ -9583,6 +9710,18 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) "\n '-zoomable {0|1}' - set zoom persistence", __FILE__, VManipulator, group); + theCommands.Add("vselprops", + "\n vselprops [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 -print : prints current state of all mentioned parameters", + __FILE__, VSelectionProperties, group); + #if defined(_WIN32) theCommands.Add("vprogressive", "vprogressive", diff --git a/tests/bugs/vis/bug23012 b/tests/bugs/vis/bug23012 index f3799b7b31..b46ef469f0 100755 --- a/tests/bugs/vis/bug23012 +++ b/tests/bugs/vis/bug23012 @@ -21,7 +21,7 @@ stepread [locate_data_file OCC23012-Sample_9.stp] b * vdisplay a_1 b_1 vsetdispmode a_1 1 vsetdispmode b_1 1 -vselprecision 0 +vselprops -pixtol 0 set ColorBefore [vreadpixel ${x1} ${y1} rgb] diff --git a/tests/bugs/vis/bug25532 b/tests/bugs/vis/bug25532 index 14d888e409..8b1bbbe169 100644 --- a/tests/bugs/vis/bug25532 +++ b/tests/bugs/vis/bug25532 @@ -19,7 +19,7 @@ vaxo vcaps -vbo 0 vsetdispmode 1 vdefaults absDefl=1.0 -vautoactivatesel 0 +vselprops -autoactivate 0 set aMemInit [meminfo h] set aNb 1000 diff --git a/tests/bugs/vis/bug26159 b/tests/bugs/vis/bug26159 index 08d94f64ca..4f149dcdd5 100644 --- a/tests/bugs/vis/bug26159 +++ b/tests/bugs/vis/bug26159 @@ -19,5 +19,5 @@ vmoveto 58 324 checkcolor 58 324 0 1 1 # to print tolerance in case of failure: -puts [vselprecision] +puts [vselprops -print] vdump $imagedir/${casename} diff --git a/tests/bugs/vis/bug26413 b/tests/bugs/vis/bug26413 index 6f00faa49b..50773e17c4 100644 --- a/tests/bugs/vis/bug26413 +++ b/tests/bugs/vis/bug26413 @@ -40,7 +40,7 @@ checkcolor ${x_on_edge} ${y_on_edge} 1 1 0 vmoveto 0 0 # increase selection precision -vselprecision 8 +vselprops -pixtol 8 # check precise selection of the edge vmoveto ${x_sel_precise} ${y_sel_precise} @@ -52,7 +52,7 @@ checkcolor ${x_on_edge} ${y_on_edge} 0 1 1 # check that after precision reset selection works as usual vmoveto 0 0 -vselprecision -1 +vselprops -pixtol -1 vmoveto ${x_sel_precise} ${y_sel_precise} checkcolor ${x_on_edge} ${y_on_edge} 0 1 1 vmoveto 0 0 @@ -63,7 +63,7 @@ checkcolor ${x_on_edge} ${y_on_edge} 1 1 0 # sensitive entities vmoveto 0 0 vselmode b 1 1 -vselprecision -1 +vselprops -pixtol -1 vmoveto ${x_notol} ${y_notol} # check that vertex is highlighted and edge is not @@ -71,7 +71,7 @@ checkcolor ${x_on_edge} ${y_on_edge} 1 1 0 checkcolor ${x_on_vert} ${y_on_vert} 0 1 1 vmoveto 0 0 -vselprecision 8 +vselprops -pixtol 8 vmoveto ${x_tol} ${y_tol} # check that vertex is highlighted and edge is not checkcolor ${x_on_edge} ${y_on_edge} 1 1 0 diff --git a/tests/v3d/materials/bug27818_1 b/tests/v3d/materials/bug27818_1 new file mode 100644 index 0000000000..f89c13cfb7 --- /dev/null +++ b/tests/v3d/materials/bug27818_1 @@ -0,0 +1,44 @@ +puts "============" +puts "OCC27818_1" +puts "============" +puts "" +#################################################################################### +# Visualization - provide an interface to define highlight presentation properties: +# test change of highlight properties for whole interactive context +#################################################################################### + + +pload VISUALIZATION MODELING + +box b 10 20 30 +pcone p 15 0 40 + +vinit +vclear + +vdisplay b -dispMode 1 -highMode 1 +vdisplay p -dispMode 1 -highMode 1 +vsetcolor b RED +vsetcolor p GREEN + +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 + +vmoveto 167 263 +set aPixelColor [vreadpixel 167 263 name rgba] +set aTransp [lindex [split $aPixelColor { }] 1] +if { $aTransp == 1 } { + puts "Error: highlighting of a cone is not transparent!" +} + +vmoveto 285 212 +set aPixelColor [vreadpixel 285 212 name rgba] +set aTransp [lindex [split $aPixelColor { }] 1] +if { $aTransp == 1 } { + puts "Error: highlighting of a box is not transparent!" +} + +vdump $imagedir/${casename}.png diff --git a/tests/v3d/materials/bug27818_2 b/tests/v3d/materials/bug27818_2 new file mode 100644 index 0000000000..44d02b7fd0 --- /dev/null +++ b/tests/v3d/materials/bug27818_2 @@ -0,0 +1,36 @@ +puts "============" +puts "OCC27818_2" +puts "============" +puts "" +#################################################################################### +# Visualization - provide an interface to define highlight presentation properties: +# test change of highlight and selection properties for particular objects +#################################################################################### + + +pload QAcommands VISUALIZATION + +vinit +OCC27818 + +vfit + +vmoveto 200 200 +set aPixelColor [vreadpixel 200 200 name rgba] +set aColor [lindex [split $aPixelColor { }] 0] +set aTrsp [lindex [split $aPixelColor { }] 1] +if {$aColor != "CHOCOLATE3" && abs($aTrsp - 1.0) < 0.1} { + puts "ERROR: dynamic highlight of 2nd box is displayed with wrong color!" +} + +vdump $imagedir/${casename}_dyn.png + +vselect 50 200 1 +vselect 200 200 1 +vselect 350 200 1 + +if {[vreadpixel 350 200 name rgba] != "RED3 1" || [vreadpixel 350 200 1 rgba] == [vreadpixel 200 200 1 rgba]} { + puts "ERROR: selection highlight of 3rd box is displayed with wrong color!" +} + +vdump $imagedir/${casename}_sel.png -- 2.20.1