1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0021306: Visualization, AIS_InteractiveContext - revise DisplayedModes() semantics

Remove the AIS_InteractiveContext::DisplayedModes() method.
Remove list of active display modes from AIS_GlobalStatus.
This commit is contained in:
isk 2016-08-02 14:46:13 +03:00 committed by bugmaster
parent 57fbfb8e7b
commit 3db69e4133
6 changed files with 57 additions and 150 deletions

View File

@ -15,6 +15,7 @@
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <AIS_DisplayMode.hxx>
#include <AIS_GlobalStatus.hxx> #include <AIS_GlobalStatus.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx> #include <TColStd_ListIteratorOfListOfInteger.hxx>
@ -23,6 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus,MMgt_TShared)
AIS_GlobalStatus::AIS_GlobalStatus(): AIS_GlobalStatus::AIS_GlobalStatus():
myStatus(AIS_DS_None), myStatus(AIS_DS_None),
myDispMode(AIS_WireFrame),
myLayerIndex(0), myLayerIndex(0),
myIsHilit(Standard_False), myIsHilit(Standard_False),
myHiCol(Quantity_NOC_WHITE), myHiCol(Quantity_NOC_WHITE),
@ -37,28 +39,15 @@ AIS_GlobalStatus::AIS_GlobalStatus(const AIS_DisplayStatus DS,
const Quantity_NameOfColor TheHiCol, const Quantity_NameOfColor TheHiCol,
const Standard_Integer Layer): const Standard_Integer Layer):
myStatus(DS), myStatus(DS),
myDispMode(DMode),
myLayerIndex(Layer), myLayerIndex(Layer),
myIsHilit(Standard_False), myIsHilit(Standard_False),
myHiCol(TheHiCol), myHiCol(TheHiCol),
mySubInt(Standard_False) mySubInt(Standard_False)
{ {
myDispModes.Append(DMode);
mySelModes.Append(SMode); mySelModes.Append(SMode);
} }
void AIS_GlobalStatus::RemoveDisplayMode(const Standard_Integer aMode)
{
TColStd_ListIteratorOfListOfInteger anIt (myDispModes);
for (; anIt.More(); anIt.Next())
{
if (anIt.Value() == aMode)
{
myDispModes.Remove (anIt);
return;
}
}
}
void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode) void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode)
{ {
TColStd_ListIteratorOfListOfInteger anIt (mySelModes); TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
@ -77,19 +66,6 @@ void AIS_GlobalStatus::ClearSelectionModes()
mySelModes.Clear(); mySelModes.Clear();
} }
Standard_Boolean AIS_GlobalStatus::IsDModeIn(const Standard_Integer aMode) const
{
TColStd_ListIteratorOfListOfInteger anIt (myDispModes);
for (; anIt.More(); anIt.Next())
{
if (anIt.Value() == aMode)
{
return Standard_True;
}
}
return Standard_False;
}
Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const
{ {
TColStd_ListIteratorOfListOfInteger anIt (mySelModes); TColStd_ListIteratorOfListOfInteger anIt (mySelModes);

View File

@ -50,10 +50,14 @@ public:
void SetGraphicStatus (const AIS_DisplayStatus aStat); void SetGraphicStatus (const AIS_DisplayStatus aStat);
void AddDisplayMode (const Standard_Integer aMode);
void AddSelectionMode (const Standard_Integer aMode); void AddSelectionMode (const Standard_Integer aMode);
//! Sets display mode.
void SetDisplayMode (const Standard_Integer theMode);
//! Returns the display mode.
Standard_Integer DisplayMode() const;
void SetLayerIndex (const Standard_Integer AnIndex); void SetLayerIndex (const Standard_Integer AnIndex);
void SetHilightStatus (const Standard_Boolean aStat); void SetHilightStatus (const Standard_Boolean aStat);
@ -66,18 +70,12 @@ public:
void SubIntensityOff(); void SubIntensityOff();
Standard_EXPORT void RemoveDisplayMode (const Standard_Integer aMode);
Standard_EXPORT void RemoveSelectionMode (const Standard_Integer aMode); Standard_EXPORT void RemoveSelectionMode (const Standard_Integer aMode);
Standard_EXPORT void ClearSelectionModes(); Standard_EXPORT void ClearSelectionModes();
AIS_DisplayStatus GraphicStatus() const; AIS_DisplayStatus GraphicStatus() const;
//! keeps the information of displayed modes in the
//! main viewer.
const TColStd_ListOfInteger& DisplayedModes() const;
//! keeps the active selection modes of the object //! keeps the active selection modes of the object
//! in the main viewer. //! in the main viewer.
const TColStd_ListOfInteger& SelectionModes() const; const TColStd_ListOfInteger& SelectionModes() const;
@ -86,8 +84,6 @@ public:
Quantity_NameOfColor HilightColor() const; Quantity_NameOfColor HilightColor() const;
Standard_EXPORT Standard_Boolean IsDModeIn (const Standard_Integer aMode) const;
Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const; Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const;
//! Returns layer index. //! Returns layer index.
@ -109,7 +105,7 @@ private:
AIS_DisplayStatus myStatus; AIS_DisplayStatus myStatus;
TColStd_ListOfInteger myDispModes; Standard_Integer myDispMode;
TColStd_ListOfInteger mySelModes; TColStd_ListOfInteger mySelModes;
Standard_Integer myLayerIndex; Standard_Integer myLayerIndex;
Standard_Boolean myIsHilit; Standard_Boolean myIsHilit;

View File

@ -19,11 +19,10 @@ inline void AIS_GlobalStatus::SetGraphicStatus(const AIS_DisplayStatus aStat)
myStatus = aStat; myStatus = aStat;
} }
inline void AIS_GlobalStatus::AddDisplayMode(const Standard_Integer aMode) inline void AIS_GlobalStatus::SetDisplayMode (const Standard_Integer theMode)
{ {
if(!IsDModeIn(aMode)) myDispModes.Append(aMode); myDispMode = theMode;
} }
inline void AIS_GlobalStatus::AddSelectionMode(const Standard_Integer aMode) inline void AIS_GlobalStatus::AddSelectionMode(const Standard_Integer aMode)
{ {
if(!IsSModeIn(aMode)) mySelModes.Append(aMode); if(!IsSModeIn(aMode)) mySelModes.Append(aMode);
@ -61,9 +60,9 @@ inline AIS_DisplayStatus AIS_GlobalStatus::GraphicStatus() const
return myStatus; return myStatus;
} }
inline const TColStd_ListOfInteger& AIS_GlobalStatus::DisplayedModes() const inline Standard_Integer AIS_GlobalStatus::DisplayMode() const
{ {
return myDispModes; return myDispMode;
} }
inline const TColStd_ListOfInteger& AIS_GlobalStatus::SelectionModes() const inline const TColStd_ListOfInteger& AIS_GlobalStatus::SelectionModes() const

View File

@ -452,30 +452,17 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
// Mark the presentation modes hidden of interactive object different from aDispMode. // Mark the presentation modes hidden of interactive object different from aDispMode.
// Then make sure aDispMode is displayed and maybe highlighted. // Then make sure aDispMode is displayed and maybe highlighted.
// Finally, activate selection mode <SelMode> if not yet activated. // Finally, activate selection mode <SelMode> if not yet activated.
TColStd_ListOfInteger aModesToRemove; const Standard_Integer anOldMode = aStatus->DisplayMode();
for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next()) if (anOldMode != theDispMode)
{ {
const Standard_Integer anOldMode = aDispModeIter.Value(); if(myMainPM->IsHighlighted (theIObj, anOldMode))
if (anOldMode != theDispMode)
{ {
aModesToRemove.Append (anOldMode); myMainPM->Unhighlight (theIObj, anOldMode);
if(myMainPM->IsHighlighted (theIObj, anOldMode))
{
myMainPM->Unhighlight (theIObj, anOldMode);
}
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
} }
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
} }
for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next()) aStatus->SetDisplayMode (theDispMode);
{
aStatus->RemoveDisplayMode (aRemModeIter.Value());
}
if (!aStatus->IsDModeIn (theDispMode))
{
aStatus->AddDisplayMode (theDispMode);
}
myMainPM->Display (theIObj, theDispMode); myMainPM->Display (theIObj, theDispMode);
aStatus->SetGraphicStatus (AIS_DS_Displayed); aStatus->SetGraphicStatus (AIS_DS_Displayed);
@ -788,15 +775,6 @@ AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_Intera
return AIS_DS_None; return AIS_DS_None;
} }
//=======================================================================
//function : DisplayedModes
//purpose :
//=======================================================================
const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
{
return myObjects (theIObj)->DisplayedModes();
}
//======================================================================= //=======================================================================
//function : Remove //function : Remove
//purpose : //purpose :
@ -1115,7 +1093,7 @@ Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_Interacti
{ {
Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
if (aStatus->GraphicStatus() == AIS_DS_Displayed if (aStatus->GraphicStatus() == AIS_DS_Displayed
&& aStatus->IsDModeIn (theMode)) && theIObj->DisplayMode() == theMode)
{ {
return Standard_True; return Standard_True;
} }
@ -1546,12 +1524,8 @@ void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode theMode,
} }
Handle(AIS_GlobalStatus) aStatus = anObjIter.Value(); Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
if (aStatus->IsDModeIn (myDisplayMode)) aStatus->SetDisplayMode (theMode);
{
aStatus->RemoveDisplayMode (myDisplayMode);
}
aStatus->AddDisplayMode (theMode);
if (aStatus->GraphicStatus() == AIS_DS_Displayed) if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{ {
myMainPM->Display (anObj, theMode); myMainPM->Display (anObj, theMode);
@ -1607,30 +1581,17 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)
} }
// erase presentations for all display modes different from <aMode> // erase presentations for all display modes different from <aMode>
TColStd_ListOfInteger aModesToRemove; const Standard_Integer anOldMode = aStatus->DisplayMode();
for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next()) if (anOldMode != theMode)
{ {
const Standard_Integer anOldMode = aDispModeIter.Value(); if (myMainPM->IsHighlighted (theIObj, anOldMode))
if (anOldMode != theMode)
{ {
aModesToRemove.Append (anOldMode); myMainPM->Unhighlight (theIObj, anOldMode);
if (myMainPM->IsHighlighted (theIObj, anOldMode))
{
myMainPM->Unhighlight (theIObj, anOldMode);
}
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
} }
myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
} }
for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next()) aStatus->SetDisplayMode (theMode);
{
aStatus->RemoveDisplayMode (aRemModeIter.Value());
}
if (!aStatus->IsDModeIn (theMode))
{
aStatus->AddDisplayMode (theMode);
}
myMainPM->Display (theIObj, theMode); myMainPM->Display (theIObj, theMode);
Standard_Integer aDispMode, aHiMode, aSelMode; Standard_Integer aDispMode, aHiMode, aSelMode;
@ -1677,11 +1638,7 @@ void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObjec
} }
const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
aStatus->RemoveDisplayMode (anOldMode); aStatus->SetDisplayMode (myDisplayMode);
if (!aStatus->IsDModeIn(myDisplayMode))
{
aStatus->AddDisplayMode (myDisplayMode);
}
if (aStatus->GraphicStatus() == AIS_DS_Displayed) if (aStatus->GraphicStatus() == AIS_DS_Displayed)
{ {
@ -2330,12 +2287,10 @@ void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIOb
} }
theStatus += "\t| Active Display Modes in the MainViewer :\n"; theStatus += "\t| Active Display Modes in the MainViewer :\n";
for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next()) theStatus += "\t|\t Mode ";
{ theStatus += TCollection_AsciiString (aStatus->DisplayMode());
theStatus += "\t|\t Mode "; theStatus += "\n";
theStatus += TCollection_AsciiString (aDispModeIter.Value());
theStatus += "\n";
}
if (IsSelected(theIObj)) theStatus +="\t| Selected\n"; if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
theStatus += "\t| Active Selection Modes in the MainViewer :\n"; theStatus += "\t| Active Selection Modes in the MainViewer :\n";
@ -2393,23 +2348,20 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
return; return;
} }
for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next()) if (aStatus->IsHilighted())
{ {
if (aStatus->IsHilighted()) if (IsCurrent (theIObj))
{ {
if (IsCurrent (theIObj)) AddOrRemoveCurrentObject (theIObj, Standard_False);
{ }
AddOrRemoveCurrentObject (theIObj, Standard_False); else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode()))
} {
else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value())) myMainPM->Unhighlight (theIObj, aStatus->DisplayMode());
{
myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
}
} }
myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
} }
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
if (aStatus->IsHilighted() if (aStatus->IsHilighted()
&& theIObj->HasHilightMode()) && theIObj->HasHilightMode())
{ {
@ -2423,7 +2375,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
} }
if (IsSelected (theIObj) if (IsSelected (theIObj)
&& !aStatus->IsDModeIn (aDispMode)) && aStatus->DisplayMode() != aDispMode)
{ {
myMainPM->SetVisibility (theIObj, aDispMode, Standard_False); myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
} }
@ -2536,7 +2488,7 @@ void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)
} }
const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
if (aStatus->IsDModeIn (theMode)) if (aStatus->DisplayMode() == theMode)
{ {
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
if (aDispMode == theMode if (aDispMode == theMode

View File

@ -555,9 +555,6 @@ public:
Standard_EXPORT AIS_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const; Standard_EXPORT AIS_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const;
//! Returns the list of active display modes for the entity aniobj.
Standard_EXPORT const TColStd_ListOfInteger& DisplayedModes (const Handle(AIS_InteractiveObject)& aniobj) const;
//! Returns true if anIobj is displayed in the interactive context. //! Returns true if anIobj is displayed in the interactive context.
Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const; Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const;

View File

@ -365,12 +365,10 @@ SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
GB->SubIntensityOn(); GB->SubIntensityOn();
Standard_Boolean UpdMain(Standard_False); Standard_Boolean UpdMain(Standard_False);
for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){ if (GB->GraphicStatus() == AIS_DS_Displayed)
if (GB->GraphicStatus()==AIS_DS_Displayed) {
{ myMainPM->Color (anIObj, mySubIntensity, GB->DisplayMode());
myMainPM->Color(anIObj,mySubIntensity,It.Value()); UpdMain = Standard_True;
UpdMain = Standard_True;
}
} }
if(updateviewer){ if(updateviewer){
if(UpdMain) if(UpdMain)
@ -381,9 +379,7 @@ SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
if(myObjects.IsBound(anIObj)){ if(myObjects.IsBound(anIObj)){
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
STAT->SubIntensityOn(); STAT->SubIntensityOn();
TColStd_ListIteratorOfListOfInteger ItL; myMainPM->Color (anIObj, mySubIntensity, STAT->DisplayMode());
for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
} }
else else
myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj); myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj);
@ -409,12 +405,10 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
GB->SubIntensityOff(); GB->SubIntensityOff();
Standard_Boolean UpdMain(Standard_False); Standard_Boolean UpdMain(Standard_False);
for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){ if(GB->GraphicStatus() == AIS_DS_Displayed)
if(GB->GraphicStatus()==AIS_DS_Displayed) {
{ myMainPM->Unhighlight (anIObj, GB->DisplayMode());
myMainPM->Unhighlight(anIObj,It.Value()); UpdMain = Standard_True;
UpdMain = Standard_True;
}
} }
Standard_Integer DM,HM,SM; Standard_Integer DM,HM,SM;
@ -431,9 +425,7 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
if(myObjects.IsBound(anIObj)){ if(myObjects.IsBound(anIObj)){
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj); const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
STAT->SubIntensityOff(); STAT->SubIntensityOff();
TColStd_ListIteratorOfListOfInteger ItL; myMainPM->Unhighlight (anIObj, STAT->DisplayMode());
for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
myMainPM->Unhighlight(anIObj,ItL.Value());
if(STAT->IsHilighted()) if(STAT->IsHilighted())
Hilight(anIObj); Hilight(anIObj);
} }
@ -456,14 +448,12 @@ void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer)
if(!HasOpenedContext()) return; if(!HasOpenedContext()) return;
AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
TColStd_ListIteratorOfListOfInteger ItM;
for(;It.More();It.Next()){ for(;It.More();It.Next()){
const Handle(AIS_GlobalStatus)& STAT = It.Value(); const Handle(AIS_GlobalStatus)& STAT = It.Value();
if(STAT->GraphicStatus()==AIS_DS_Displayed) if(STAT->GraphicStatus()==AIS_DS_Displayed)
{ {
STAT->SubIntensityOn(); STAT->SubIntensityOn();
for(ItM.Initialize(STAT->DisplayedModes());ItM.More();ItM.Next()) myMainPM->Color (It.Key(), mySubIntensity, STAT->DisplayMode());
{myMainPM->Color(It.Key(),mySubIntensity,ItM.Value());}
} }
} }
if(updateviewer) myMainVwr->Update(); if(updateviewer) myMainVwr->Update();
@ -478,13 +468,11 @@ void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer
if(!HasOpenedContext()) return; if(!HasOpenedContext()) return;
AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects); AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
TColStd_ListIteratorOfListOfInteger ItL;
for(;It.More();It.Next()){ for(;It.More();It.Next()){
const Handle(AIS_GlobalStatus)& STAT = It.Value(); const Handle(AIS_GlobalStatus)& STAT = It.Value();
if(STAT->IsSubIntensityOn()) if(STAT->IsSubIntensityOn())
STAT->SubIntensityOff(); STAT->SubIntensityOff();
for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next()) myMainPM->Unhighlight (It.Key());
myMainPM->Unhighlight(It.Key());
} }
if(updateviewer) myMainVwr->Update(); if(updateviewer) myMainVwr->Update();
@ -800,8 +788,7 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie
upd_main = Standard_True; upd_main = Standard_True;
// part display... // part display...
for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next()) myMainPM->Display (iobj, STAT->DisplayMode());
myMainPM->Display(iobj,itl.Value());
if(STAT->IsHilighted()){ if(STAT->IsHilighted()){
if(STAT->HilightColor()!=Quantity_NOC_WHITE) if(STAT->HilightColor()!=Quantity_NOC_WHITE)
HilightWithColor(iobj,STAT->HilightColor(),Standard_False); HilightWithColor(iobj,STAT->HilightColor(),Standard_False);