- 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
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:
* 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
//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;
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:
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,
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 :
//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));
}
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;
myDispMode(AIS_WireFrame),
myLayerIndex(0),
myIsHilit(Standard_False),
-myHiCol(Quantity_NOC_WHITE),
mySubInt(Standard_False)
{
}
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);
#include <Standard_Type.hxx>
#include <AIS_DisplayStatus.hxx>
+#include <Graphic3d_HighlightStyle.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
-#include <Quantity_NameOfColor.hxx>
#include <MMgt_TShared.hxx>
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);
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();
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.
TColStd_ListOfInteger mySelModes;
Standard_Integer myLayerIndex;
Standard_Boolean myIsHilit;
- Quantity_NameOfColor myHiCol;
+ Handle(Graphic3d_HighlightStyle) myHiStyle;
Standard_Boolean mySubInt;
{
myIsHilit = aStat;
}
-inline void AIS_GlobalStatus::SetHilightColor(const Quantity_NameOfColor aCol)
-{myHiCol = aCol;}
inline Standard_Boolean AIS_GlobalStatus::IsSubIntensityOn() const
{
{
return myIsHilit;
}
-
-inline Quantity_NameOfColor AIS_GlobalStatus::HilightColor() const
-{return myHiCol;}
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),
{
if(myMainPM->IsHighlighted (theIObj, anOldMode))
{
- myMainPM->Unhighlight (theIObj, anOldMode);
+ unhighlightGlobal (theIObj, anOldMode);
}
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
}
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)
{
}
//=======================================================================
-//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;
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
//=======================================================================
//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;
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;
+ }
}
//=======================================================================
// 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,
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);
}
{
if (myMainPM->IsHighlighted (theIObj, anOldMode))
{
- myMainPM->Unhighlight (theIObj, anOldMode);
+ unhighlightGlobal (theIObj, anOldMode);
}
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
}
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)
{
if (myMainPM->IsHighlighted (theIObj, anOldMode))
{
- myMainPM->Unhighlight (theIObj, anOldMode);
+ unhighlightGlobal (theIObj, anOldMode);
}
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
myMainPM->Display (theIObj, myDisplayMode);
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)
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);
}
}
}
}
else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode()))
{
- myMainPM->Unhighlight (theIObj, aStatus->DisplayMode());
+ unhighlightGlobal (theIObj, aStatus->DisplayMode());
}
}
if (aStatus->IsHilighted()
&& theIObj->HasHilightMode())
{
- myMainPM->Unhighlight (theIObj, aDispMode);
+ unhighlightGlobal (theIObj, aDispMode);
}
if (!myLastPicked.IsNull()
- && myLastPicked->Selectable() == theIObj)
+ && myLastPicked->IsSameSelectable (theIObj))
{
myMainPM->ClearImmediateDraw();
}
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());
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();
if (aDispMode == theMode
&& myMainPM->IsHighlighted (theIObj, theMode))
{
- myMainPM->Unhighlight (theIObj, theMode);
+ unhighlightGlobal (theIObj, theMode);
}
myMainPM->Erase (theIObj, theMode);
#include <AIS_KindOfInteractive.hxx>
#include <Standard_Real.hxx>
#include <Aspect_TypeOfFacingModel.hxx>
+#include <Graphic3d_HighlightStyle.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <Standard_ShortReal.hxx>
#include <TColStd_ListOfInteger.hxx>
//! 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
//! 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.
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 <anIObj> is hilighted with a specific color
- //! <WithColor> will be returned TRUE
- //! <theHiCol> gives the name of the hilightcolor
- Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& anIobj, Standard_Boolean& WithColor, Quantity_NameOfColor& theHiCol) const;
- //! if <theOwner> is hilighted with a specific color, than <theIsCustomColor> will be set
- //! to true and <theCustomColorName> 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
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;
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.
//! 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 <theColor> without
+ //! Helper function that highlights the owner given with <theStyle> without
//! performing AutoHighlight checks, e.g. is used for dynamic highlight.
- //! If the parameter <theViewer> is set and <theIsImmediate> 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 <theColor> with check
+ //! Helper function that highlights the owner given with <theStyle> with check
//! for AutoHighlight, e.g. is used for selection.
- //! If the parameter <theViewer> is set and <theIsImmediate> 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 <theStyle> 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.
//! 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;
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;
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;
{ 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;
//purpose :
//=======================================================================
void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
- const Quantity_NameOfColor theColor,
const Handle(V3d_Viewer)& theViewer)
{
const Handle(AIS_InteractiveObject) anObj =
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);
}
//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());
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());
}
}
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);
}
}
{
if (myObjects.IsBound (anInteractive) && myObjects (anInteractive)->IsSubIntensityOn())
{
- anOwner->HilightWithColor (myMainPM, mySubIntensity, aHiMode);
+ highlightWithSubintensity (anOwner, aHiMode);
}
}
}
}
}
+//=======================================================================
+//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 :
}
else if (myToHilightSelected)
{
- highlightWithColor (aNewPickedOwner, mySelectionColor, theView->Viewer());
+ highlightSelected (aNewPickedOwner);
toUpdateViewer = Standard_True;
}
}
{
if (!myLastPicked->IsSelected() || myToHilightSelected)
{
- highlightWithColor (myLastPicked, myHilightColor, theView->Viewer());
+ highlightWithColor (myLastPicked, theView->Viewer());
toUpdateViewer = Standard_True;
}
}
else if (myToHilightSelected)
{
- highlightSelected (myLastPicked, mySelectionColor);
+ highlightSelected (myLastPicked);
toUpdateViewer = Standard_True;
}
}
{
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())
else
{
const Standard_Integer aHiMode = anObj->HasHilightMode() ? anObj->HilightMode() : 0;
- anOwner->HilightWithColor (myMainPM, mySelectionColor, aHiMode);
+ anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
}
}
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;
{
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)
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;
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)
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
else
anObj->ClearSelected();
aStatus->SetHilightStatus (Standard_False);
- aStatus->SetHilightColor (Quantity_NOC_WHITE);
+ aStatus->SetHilightStyle (new Graphic3d_HighlightStyle());
}
if (theToUpdateViewer)
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()){
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
Standard_Integer DM,HM,SM;
GetDefModes(anIObj,DM,HM,SM);
if(IsSelected(anIObj))
- myMainPM->Highlight(anIObj,HM);
+ highlightSelected (anIObj->GlobalSelOwner());
if(updateviewer){
if(UpdMain)
}
}
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();
}
//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();
}
//=======================================================================
// 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()){
mylastindex(0),
mylastgood(0),
myCurDetected(0),
-myAISCurDetected(0)
+myAISCurDetected(0),
+mySubintStyle (new Graphic3d_HighlightStyle (aCtx->SelectionStyle()))
{
// bind self to AIS_InteractiveContext::myLocalContexts. Further, the
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();
}
}
const Handle(AIS_LocalStatus)& Att = myActiveObjects(anObject);
- myMainPM->Color(anObject,myCTX->HilightColor(),Att->HilightMode());
+ myMainPM->Color(anObject, getHiStyle (anObject), Att->HilightMode());
Att->SubIntensityOn();
}
//=======================================================================
//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);
}
//=======================================================================
myMainPM->SetVisibility (anObject, Att->HilightMode(), Standard_False);
Att->SubIntensityOff();
- Att->SetHilightColor(Quantity_NOC_WHITE);
+ Att->SetHilightStyle (new Graphic3d_HighlightStyle());
}
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;
}
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.
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:
Standard_Integer myCurDetected;
AIS_SequenceOfInteractive myAISDetectedSeq;
Standard_Integer myAISCurDetected;
-
+ Handle(Graphic3d_HighlightStyle) mySubintStyle;
};
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 :
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());
}
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
{
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;
}
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());
}
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;
}
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;
}
continue;
}
- if (anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
+ if (!anOwner->IsSameSelectable (theIO) || aValidOwners.Contains (anOwner))
{
anOwnersToKeep.Add (anOwner);
}
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- if (theObj != aSelIter.Value()->Selectable())
+ if (!aSelIter.Value()->IsSameSelectable (theObj))
{
continue;
}
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);
}
#ifndef _AIS_LocalStatus_HeaderFile
#define _AIS_LocalStatus_HeaderFile
+#include <Graphic3d_HighlightStyle.hxx>
+#include <MMgt_TShared.hxx>
#include <Standard.hxx>
#include <Standard_Type.hxx>
-
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_ListOfInteger.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <MMgt_TShared.hxx>
class Standard_Transient;
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;
Standard_Boolean IsSubIntensityOn() const;
- Quantity_NameOfColor HilightColor() const;
+ const Handle(Graphic3d_HighlightStyle)& HilightStyle() const
+ {
+ return myHiStyle;
+ }
void SetDecomposition (const Standard_Boolean astatus);
void SetHilightMode (const Standard_Integer aMode);
- void SetHilightColor (const Quantity_NameOfColor aHiCol);
+ void SetHilightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle)
+ {
+ myHiStyle = theStyle;
+ }
void SubIntensityOn();
DEFINE_STANDARD_RTTIEXT(AIS_LocalStatus,MMgt_TShared)
-protected:
-
-
-
-
private:
-
-
Standard_Boolean myDecomposition;
Standard_Boolean myIsTemporary;
Standard_Integer myDMode;
Standard_Integer myHMode;
TColStd_ListOfInteger mySModes;
Standard_Boolean mySubIntensity;
- Quantity_NameOfColor myHiCol;
Handle(Standard_Transient) myPreviousState;
-
-
+ Handle(Graphic3d_HighlightStyle) myHiStyle;
};
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;}
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())
{
//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);
{
return;
}
- aPresentation->Highlight (Aspect_TOHM_COLOR, theColor);
+ aPresentation->Highlight (theStyle);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
{
//! 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:
//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);
}
//=======================================================================
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 :
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; }
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);
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);
}
}
}
Graphic3d_Group.hxx
Graphic3d_GroupAspect.hxx
Graphic3d_GroupDefinitionError.hxx
+Graphic3d_HighlightStyle.hxx
+Graphic3d_HighlightStyle.cxx
Graphic3d_HorizontalTextAlignment.hxx
Graphic3d_IndexBuffer.hxx
Graphic3d_IndexedMapOfAddress.hxx
#include <Graphic3d_BndBox4f.hxx>
#include <Graphic3d_Group.hxx>
+#include <Graphic3d_HighlightStyle.hxx>
#include <Graphic3d_SequenceOfGroup.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_TypeOfComposition.hxx>
//! 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
//! 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;
int Priority;
int PreviousPriority;
- Quantity_Color HighlightColor;
-
int ContainsFacet;
Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
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:
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);
}
}
}
if (aStruct->IsHighlighted())
{
- aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
+ aCompStruct->Highlight (aStruct->HighlightStyle(), Standard_False);
}
Standard_Boolean hasResult = Standard_False;
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
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
// 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);
}
}
if (anIndex != 0)
{
const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
- aCompStruct->GraphicUnHighlight();
+ aCompStruct->CStructure()->GraphicUnhighlight();
}
}
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,
--- /dev/null
+// 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 <Graphic3d_HighlightStyle.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_HighlightStyle, Standard_Transient)
--- /dev/null
+// 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 <Aspect_TypeOfHighlightMethod.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+#include <Graphic3d_Vec4.hxx>
+#include <Quantity_ColorRGBA.hxx>
+
+//! 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
: myStructureManager (theManager.operator->()),
myFirstStructureManager (theManager.operator->()),
myComputeVisual (Graphic3d_TOS_ALL),
- myHighlightColor (Quantity_NOC_WHITE),
- myHighlightMethod (Aspect_TOHM_COLOR),
myOwner (NULL),
myVisual (Graphic3d_TOS_ALL)
{
: myStructureManager (theManager.operator->()),
myFirstStructureManager (theManager.operator->()),
myComputeVisual (thePrs->myComputeVisual),
- myHighlightColor (thePrs->myHighlightColor),
- myHighlightMethod (thePrs->myHighlightMethod),
myOwner (thePrs->myOwner),
myVisual (thePrs->myVisual)
{
//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)
{
SetDisplayPriority (Structure_MAX_PRIORITY - 1);
- GraphicHighlight (theMethod);
+ myCStructure->GraphicHighlight (theStyle, this);
if (!theToUpdateMgr)
{
if (myCStructure->stick)
{
- myStructureManager->Highlight (this, theMethod);
+ myStructureManager->Highlight (this);
}
Update();
{
myCStructure->highlight = 0;
- GraphicUnHighlight();
+ myCStructure->GraphicUnhighlight();
myStructureManager->UnHighlight (this);
ResetDisplayPriority();
}
//=============================================================================
-//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();
}
//=============================================================================
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 :
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 :
#include <Graphic3d_CStructure.hxx>
#include <Graphic3d_IndexedMapOfAddress.hxx>
-#include <Quantity_Color.hxx>
-#include <Aspect_TypeOfHighlightMethod.hxx>
#include <Standard_Address.hxx>
#include <Graphic3d_TypeOfStructure.hxx>
#include <MMgt_TShared.hxx>
class Graphic3d_TransformError;
class Graphic3d_Group;
class Graphic3d_StructureManager;
-class Quantity_Color;
class Graphic3d_DataStructureManager;
class Bnd_Box;
class gp_Pnt;
//! of the visualiser.
Standard_EXPORT virtual void Erase();
- //! Highlights the structure <me> 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 <me>.
//! It will be erased at the next screen update.
//! 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 <me> is deleted.
//! <me> is deleted after the call Remove (me).
Standard_EXPORT void GraphicConnect (const Handle(Graphic3d_Structure)& ADaughter);
Standard_EXPORT void GraphicDisconnect (const Handle(Graphic3d_Structure)& ADaughter);
-
- //! Highlights the structure <me>.
- 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 <me>.
- Standard_EXPORT void GraphicUnHighlight();
-
+
//! Returns the identification number of the structure <me>.
Standard_EXPORT Standard_Integer Identification() const;
Handle(Graphic3d_CStructure) myCStructure;
Graphic3d_IndexedMapOfAddress myAncestors;
Graphic3d_IndexedMapOfAddress myDescendants;
- Quantity_Color myHighlightColor;
- Aspect_TypeOfHighlightMethod myHighlightMethod;
Standard_Address myOwner;
Graphic3d_TypeOfStructure myVisual;
// 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);
}
}
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);
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));
}
//================================================================
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 ) );
// 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;
}
return;
Handle( Prs3d_Presentation ) aHilightPrs;
- aHilightPrs = GetHilightPresentation( PM );
+ aHilightPrs = GetHilightPresentation( thePM );
aHilightPrs->Clear();
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();
}
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();
aHilightPrs->SetZLayer (Graphic3d_ZLayerId_Topmost);
- if (PM->IsImmediateModeOn())
+ if (thePM->IsImmediateModeOn())
{
- PM->AddToImmediateList (aHilightPrs);
+ thePM->AddToImmediateList (aHilightPrs);
}
myHilighter->SetDrawer ( 0 );
}
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;
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() )
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 );
}
}
//! 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;
// 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;
// hilight detected entities
Handle( MeshVS_Mesh ) aMesh = Handle( MeshVS_Mesh )::DownCast ( aSelObj );
- aMesh->HilightOwnerWithColor ( thePM, theColor, this );
+ aMesh->HilightOwnerWithColor ( thePM, theStyle, this );
}
}
//! 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;
if (theHighlightColor != NULL)
{
aParams.SetColor (*theHighlightColor);
+ aParams.Diffuse.a() = theHighlightColor->a();
}
myActiveProgram->SetUniform (this, aLoc, OpenGl_Material::NbOfVec4(),
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)
// =======================================================================
OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager)
: Graphic3d_CStructure (theManager),
- myHighlightColor (NULL),
myInstancedStructure (NULL),
myIsRaytracable (Standard_False),
myModificationState (0),
}
}
-// =======================================================================
-// 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())
{
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();
}
// =======================================================================
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// Render named status
- if (highlight)
+ if (highlight && myHighlightBox.IsNull())
{
theWorkspace->SetHighlight (true);
}
// 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);
{
// Release groups
Clear (theGlCtx);
- clearHighlightColor (theGlCtx);
+ clearHighlightBox (theGlCtx);
+ myHighlightStyle.Nullify();
}
// =======================================================================
//! 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;
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.
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;
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");
myDatumAspect.Nullify();
myDimensionAspect.Nullify();
mySectionAspect.Nullify();
+ myHighlightStyle.Nullify();
+ mySelectionStyle.Nullify();
myHasOwnUIsoAspect = Standard_False;
myHasOwnVIsoAspect = Standard_False;
myHasOwnDimLengthDisplayUnits = Standard_False;
myHasOwnDimAngleModelUnits = Standard_False;
myHasOwnDimAngleDisplayUnits = Standard_False;
+ myHasOwnHighlightStyle = Standard_False;
+ myHasOwnSelectionStyle = Standard_False;
myVertexDrawMode = Prs3d_VDM_Inherited;
myTypeOfHLR = Prs3d_TOH_NotSet;
}
}
}
+
+// =======================================================================
+// 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();
+}
#include <Quantity_Length.hxx>
#include <Aspect_TypeOfDeflection.hxx>
#include <Graphic3d_GroupAspect.hxx>
+#include <Graphic3d_HighlightStyle.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Standard_Real.hxx>
#include <Prs3d_VertexDrawMode.hxx>
//! 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; }
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)
#include <PrsMgr_Presentation.hxx>
#include <Geom_Transformation.hxx>
+#include <Graphic3d_HighlightStyle.hxx>
#include <Graphic3d_DataStructureManager.hxx>
#include <Graphic3d_Structure.hxx>
#include <Precision.hxx>
//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())
{
}
display (Standard_True);
- myStructure->Highlight (theMethod, theColor);
+ myStructure->Highlight (theStyle);
}
//=======================================================================
class Quantity_Color;
class Geom_Transformation;
class Prs3d_Presentation;
+class Graphic3d_HighlightStyle;
class Graphic3d_Structure;
class Graphic3d_DataStructureManager;
class Prs3d_Projector;
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;
// =======================================================================
PrsMgr_PresentationManager::PrsMgr_PresentationManager (const Handle(Graphic3d_StructureManager)& theStructureManager)
: myStructureManager (theStructureManager),
- myImmediateModeOn (0),
- mySelectionColor (Quantity_NOC_GRAY99)
+ myImmediateModeOn (0)
{
//
}
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 :
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
// 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())
{
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
//! 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);
//! 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);
Standard_Integer myImmediateModeOn;
PrsMgr_ListOfPresentations myImmediateList;
PrsMgr_ListOfPresentations myViewDependentImmediateList;
- Quantity_Color mySelectionColor;
private:
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);
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 :
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;
}
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);
}
}
// nothing done on the selectable here...
}
-
-void SelectMgr_EntityOwner::
-Hilight(){}
-
-
//=======================================================================
//function : about Transformation
//purpose :
#include <Standard_Integer.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Quantity_NameOfColor.hxx>
+#include <Graphic3d_HighlightStyle.hxx>
#include <Graphic3d_ZLayerId.hxx>
+#include <SelectMgr_SelectableObject.hxx>
class Standard_NoSuchObject;
-class SelectMgr_SelectableObject;
class PrsMgr_PresentationManager;
class TopLoc_Location;
class V3d_Viewer;
//! 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.
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)
//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");
}
//! 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).
#ifndef SelectMgr_SequenceOfOwner_HeaderFile
#define SelectMgr_SequenceOfOwner_HeaderFile
-#include <SelectMgr_EntityOwner.hxx>
#include <NCollection_Sequence.hxx>
+class SelectMgr_EntityOwner;
+
typedef NCollection_Sequence<Handle(SelectMgr_EntityOwner)> SelectMgr_SequenceOfOwner;
}
//=======================================================================
-//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
}
// 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);
}
}
}
//! 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.
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
{
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
};
//! 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"
ViewerTest_BndAction anAction = BndAction_Show;
Standard_Integer aMode = -1;
+ Handle(Graphic3d_HighlightStyle) aStyle;
+
Standard_Integer anArgIter = 1;
for (; anArgIter < theArgNb; ++anArgIter)
{
}
}
+ 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
}
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)
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);
}
}
}
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);
}
}
}
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
"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.",
"\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"
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);
}
//! 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();
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 :
"\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",
vdisplay a_1 b_1
vsetdispmode a_1 1
vsetdispmode b_1 1
-vselprecision 0
+vselprops -pixtol 0
set ColorBefore [vreadpixel ${x1} ${y1} rgb]
vcaps -vbo 0
vsetdispmode 1
vdefaults absDefl=1.0
-vautoactivatesel 0
+vselprops -autoactivate 0
set aMemInit [meminfo h]
set aNb 1000
checkcolor 58 324 0 1 1
# to print tolerance in case of failure:
-puts [vselprecision]
+puts [vselprops -print]
vdump $imagedir/${casename}
vmoveto 0 0
# increase selection precision
-vselprecision 8
+vselprops -pixtol 8
# check precise selection of the edge
vmoveto ${x_sel_precise} ${y_sel_precise}
# 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
# 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
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
--- /dev/null
+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
--- /dev/null
+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