From 016e5959869350d2f9db99e909b40cceb3d6333d Mon Sep 17 00:00:00 2001 From: mpa Date: Fri, 8 Apr 2016 09:47:47 +0300 Subject: [PATCH] 0026886: Visualization, TKV3d - eliminate global variables - AIS_InteractiveContext - create new dummy class field to have an empty TopoDS_Shape object. - AIS_Point, PrsMgr_PresentableObject - rename static variables to local function variables. - AIS_Shape, SelectMgr_SelectableObject - remove unused static variables. - Graphic3d_MaterialAspect, V3d_Viewer - make global static variables as constant. - V3d_View - move global variable zRotation to class field. - Move a variable theCurrentSelection as a field of AIS_InteractiveContext and AIS_LocalContext classes. Multiple selection is not used now, so each Context have an own selection. - Move myStructGenId from Graphic3d_StructureManager to Graphic3d_GraphicDriver for identifying the structures in the driver. - Move default variable (no shading light) from static value to the class field of OpenGL_View. Porting note: - Static methods of AIS_Selection is not used now. Methods of AIS_InteractiveContext::InitSelected(),::MoreSelected(),::NextSelected() should be used instead of static methods of AIS_Selection. --- samples/mfc/standard/Common/DimensionDlg.cpp | 10 - samples/mfc/standard/Common/DimensionDlg.h | 6 - .../standard/Common/LengthParamsEdgePage.cpp | 5 +- .../standard/Common/LengthParamsEdgesPage.cpp | 8 +- .../mfc/standard/Common/ParamsFacesPage.cpp | 9 +- .../mfc/standard/Common/RadiusParamsPage.cpp | 4 +- src/AIS/AIS_InteractiveContext.cxx | 94 ++------ src/AIS/AIS_InteractiveContext.hxx | 23 +- src/AIS/AIS_InteractiveContext.lxx | 3 - src/AIS/AIS_InteractiveContext_1.cxx | 101 ++++---- src/AIS/AIS_InteractiveContext_2.cxx | 2 +- src/AIS/AIS_LocalContext.cxx | 26 +-- src/AIS/AIS_LocalContext.hxx | 7 +- src/AIS/AIS_LocalContext.lxx | 5 +- src/AIS/AIS_LocalContext_1.cxx | 149 ++++++------ src/AIS/AIS_Point.cxx | 4 +- src/AIS/AIS_Selection.cxx | 215 +++--------------- src/AIS/AIS_Selection.hxx | 80 ++----- src/AIS/AIS_Shape.cxx | 6 +- src/Graphic3d/FILES | 1 - src/Graphic3d/Graphic3d_CStructure.cxx | 6 +- src/Graphic3d/Graphic3d_GraphicDriver.cxx | 18 ++ src/Graphic3d/Graphic3d_GraphicDriver.hxx | 9 + src/Graphic3d/Graphic3d_MaterialAspect.cxx | 53 +++-- src/Graphic3d/Graphic3d_Structure.cxx | 8 +- src/Graphic3d/Graphic3d_Structure.pxx | 8 - src/Graphic3d/Graphic3d_StructureManager.cxx | 106 +-------- src/Graphic3d/Graphic3d_StructureManager.hxx | 20 -- src/Graphic3d/Graphic3d_StructureManager.pxx | 26 --- src/OpenGl/OpenGl_Light.hxx | 16 -- src/OpenGl/OpenGl_View.cxx | 8 + src/OpenGl/OpenGl_View.hxx | 1 + src/OpenGl/OpenGl_View_Raytrace.cxx | 2 +- src/OpenGl/OpenGl_View_Redraw.cxx | 4 +- src/PrsMgr/PrsMgr_PresentableObject.cxx | 7 +- src/SelectMgr/SelectMgr_SelectableObject.cxx | 1 - src/V3d/V3d_View.cxx | 11 +- src/V3d/V3d_View.hxx | 1 + src/V3d/V3d_Viewer_3.cxx | 28 +-- 39 files changed, 313 insertions(+), 778 deletions(-) delete mode 100644 src/Graphic3d/Graphic3d_StructureManager.pxx diff --git a/samples/mfc/standard/Common/DimensionDlg.cpp b/samples/mfc/standard/Common/DimensionDlg.cpp index e4e36489f8..1fe27f4366 100644 --- a/samples/mfc/standard/Common/DimensionDlg.cpp +++ b/samples/mfc/standard/Common/DimensionDlg.cpp @@ -11,11 +11,9 @@ #include "RadiusParamsPage.h" #include "ParamsFacesPage.h" #include -#include #include #include #include -#include #include BEGIN_MESSAGE_MAP(CDimensionDlg, CDialog) @@ -763,11 +761,3 @@ void CDimensionDlg::OnClose() } CDialog::OnClose(); } - -TopoDS_Shape CDimensionDlg::SelectedShape() -{ - Handle(Standard_Transient) aSelection = AIS_Selection::CurrentSelection()->Value(); - Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelection); - Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner); - return aBrepOwner->Shape().Located (aBrepOwner->Location() * aBrepOwner->Shape().Location()); -} diff --git a/samples/mfc/standard/Common/DimensionDlg.h b/samples/mfc/standard/Common/DimensionDlg.h index c948ae4228..b2b9bf547d 100755 --- a/samples/mfc/standard/Common/DimensionDlg.h +++ b/samples/mfc/standard/Common/DimensionDlg.h @@ -37,12 +37,6 @@ public: const TCollection_AsciiString GetUnits() const; const Quantity_Color GetDimensionColor() const; -public: - - // Workaround: AIS_LocalContext::SelectedShape() doesn't take into account local location of selected TopoDS shape, - // and operates with selected interactive object transformation only. - static TopoDS_Shape SelectedShape(); - public: // Dialog Data enum { IDD = IDD_Dimension }; diff --git a/samples/mfc/standard/Common/LengthParamsEdgePage.cpp b/samples/mfc/standard/Common/LengthParamsEdgePage.cpp index 41ff0b1bb4..6535e66c43 100644 --- a/samples/mfc/standard/Common/LengthParamsEdgePage.cpp +++ b/samples/mfc/standard/Common/LengthParamsEdgePage.cpp @@ -60,7 +60,6 @@ CButton* CLengthParamsEdgePage::GetButton() return (CButton*)GetDlgItem (IDC_ChooseEdgeBtn); } -#include //======================================================================= //function : OnBnClickedChooseEdgeBtn //purpose : @@ -76,9 +75,7 @@ void CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn() return; } - // Workaround for AIS_LocalContext::SelectedShape() - //TopoDS_Shape aSelShape = myAISContext->LocalContext()->SelectedShape(); - TopoDS_Shape aSelShape = CDimensionDlg::SelectedShape(); + TopoDS_Shape aSelShape = myAISContext->SelectedShape(); const TopoDS_Edge& anEdge = TopoDS::Edge (aSelShape); myAISContext->LocalContext()->ClearSelected(); diff --git a/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp b/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp index 430e9fa9bf..5dd10bd4dd 100644 --- a/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp +++ b/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp @@ -78,9 +78,7 @@ void CLengthParamsEdgesPage::OnBnClickedEdge1Btn() return; } - // Workaround for AIS_LocalContext::SelectedShape() - myFirstEdge = TopoDS::Edge (CDimensionDlg::SelectedShape()); - //myFirstEdge = TopoDS::Edge (myAISContext->LocalContext()->SelectedShape()); + myFirstEdge = TopoDS::Edge (myAISContext->SelectedShape()); myAISContext->LocalContext()->ClearSelected(); } @@ -100,9 +98,7 @@ void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() return; } - // Workaround for AIS_LocalContext::SelectedShape() - mySecondEdge = TopoDS::Edge (CDimensionDlg::SelectedShape()); - //mySecondEdge = TopoDS::Edge (myAISContext->LocalContext()->SelectedShape()); + mySecondEdge = TopoDS::Edge (myAISContext->SelectedShape()); myAISContext->LocalContext()->ClearSelected(); diff --git a/samples/mfc/standard/Common/ParamsFacesPage.cpp b/samples/mfc/standard/Common/ParamsFacesPage.cpp index d934801620..3aa5d740eb 100644 --- a/samples/mfc/standard/Common/ParamsFacesPage.cpp +++ b/samples/mfc/standard/Common/ParamsFacesPage.cpp @@ -51,9 +51,7 @@ void CParamsFacesPage::OnBnClickedFacesbtn1() return; } - // Workaround for AIS_LocalContext::SelectedShape() - myFirstFace = TopoDS::Face (CDimensionDlg::SelectedShape()); - //myFirstFace = TopoDS::Face (myAISContext->LocalContext()->SelectedShape()); + myFirstFace = TopoDS::Face (myAISContext->SelectedShape()); myAISContext->LocalContext()->ClearSelected(); } @@ -69,9 +67,8 @@ void CParamsFacesPage::OnBnClickedFacesbtn2() return; } - // Workaround for AIS_LocalContext::SelectedShape() - mySecondFace = TopoDS::Face (CDimensionDlg::SelectedShape()); - //mySecondFace = TopoDS::Face (myAISContext->LocalContext()->SelectedShape()); + mySecondFace = TopoDS::Face (myAISContext->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); diff --git a/samples/mfc/standard/Common/RadiusParamsPage.cpp b/samples/mfc/standard/Common/RadiusParamsPage.cpp index 002d23fd6b..d479e26f27 100644 --- a/samples/mfc/standard/Common/RadiusParamsPage.cpp +++ b/samples/mfc/standard/Common/RadiusParamsPage.cpp @@ -69,9 +69,7 @@ void CRadiusParamsPage::OnBnClickedObjectBtn() Standard_Boolean isAttachPoint = Standard_False; Standard_Real aFirstPar = 0, aLastPar = 0; - // Workaround for AIS_LocalContext::SelectedShape() - TopoDS_Shape aSelShape = CDimensionDlg::SelectedShape(); - //TopoDS_Shape aSelShape = myAISContext->LocalContext()->SelectedShape(); + TopoDS_Shape aSelShape = myAISContext->SelectedShape(); if (aSelShape.ShapeType() != TopAbs_EDGE && aSelShape.ShapeType() != TopAbs_FACE && diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 90a95ec5af..c6c7f93d4e 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -67,21 +66,6 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext,MMgt_TShared) //#include namespace { - static volatile Standard_Integer THE_AIS_INDEX_SEL = 0; - static volatile Standard_Integer THE_AIS_INDEX_CUR = 0; - - static TCollection_AsciiString AIS_Context_NewSelName() - { - return TCollection_AsciiString ("AIS_SelContext_") - + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_SEL)); - } - - static TCollection_AsciiString AIS_Context_NewCurName() - { - return TCollection_AsciiString ("AIS_CurContext_") - + TCollection_AsciiString (Standard_Atomic_Increment (&THE_AIS_INDEX_CUR)); - } - typedef NCollection_DataMap AIS_MapOfObjectOwners; typedef NCollection_DataMap::Iterator AIS_MapIteratorOfMapOfObjectOwners; } @@ -102,6 +86,7 @@ mySelectedTouched(Standard_False), myToHilightSelected(Standard_True), myFilters(new SelectMgr_OrFilter()), myDefaultDrawer(new Prs3d_Drawer()), +mySelection(new AIS_Selection()), myDefaultColor(Quantity_NOC_GOLDENROD), myHilightColor(Quantity_NOC_CYAN1), mySelectionColor(Quantity_NOC_GRAY80), @@ -111,27 +96,15 @@ myDisplayMode(0), myCurLocalIndex(0), myAISCurDetected(0), myZDetectionFlag(0), -myIsAutoActivateSelMode( Standard_True ) +myIsAutoActivateSelMode(Standard_True) { InitAttributes(); } void AIS_InteractiveContext::Delete() const { - // clear the static current selection - AIS_Selection::ClearCurrentSelection(); - - // to avoid an exception - if (AIS_Selection::Find (mySelectionName.ToCString())) - { - AIS_Selection::Remove (mySelectionName.ToCString()); - } - - // to avoid an exception - if (AIS_Selection::Find (myCurrentName.ToCString())) - { - AIS_Selection::Remove (myCurrentName.ToCString()); - } + // clear the current selection + mySelection->Select(); // let's remove one reference explicitly. this operation's supposed to // be performed when mgrSelector will be destroyed but anyway... @@ -151,20 +124,6 @@ void AIS_InteractiveContext::Delete() const MMgt_TShared::Delete(); } -//======================================================================= -//function : AIS_SelectionName -//purpose : -//======================================================================= -const TCollection_AsciiString& AIS_InteractiveContext::SelectionName() const -{ - if(!HasOpenedContext()) - return mySelectionName; - return myLocalContexts(myCurLocalIndex)->SelectionName(); - -} - - - //======================================================================= //function : UpdateCurrentViewer //purpose : @@ -697,10 +656,9 @@ void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdate } Standard_Boolean isFound = Standard_False; - Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString()); - for (aSelIter->Init(); aSelIter->More(); aSelIter->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { - Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value()); + Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()); Display (anObj, Standard_False); isFound = Standard_True; } @@ -723,18 +681,16 @@ void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateVi } Standard_Boolean isFound = Standard_False; - Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString()); - - aSelIter->Init(); - while (aSelIter->More()) + mySelection->Init(); + while (mySelection->More()) { - Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelIter->Value()); + Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); Erase (anObj, Standard_False); isFound = Standard_True; - aSelIter->Init(); + mySelection->Init(); } if (isFound && theToUpdateViewer) @@ -2285,16 +2241,14 @@ void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& } Standard_Boolean isFound = Standard_False; - Handle(AIS_Selection) aSelIter = AIS_Selection::Selection (myCurrentName.ToCString()); - for (aSelIter->Init(); aSelIter->More(); aSelIter->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { isFound = Standard_True; - Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value()); + Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()); anObj->SetAspect (theAspect, theIsGlobalChange); } - if (isFound - && theToUpdateViewer) + if (isFound && theToUpdateViewer) { myMainVwr->Update(); } @@ -2481,22 +2435,21 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t //======================================================================= void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject) { - Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString()); - aSel->Init(); - while (aSel->More()) + mySelection->Init(); + while (mySelection->More()) { const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (anOwner->Selectable() == theObject) { if (anOwner->IsSelected()) { AddOrRemoveSelected (anOwner, Standard_False); - aSel->Init(); + mySelection->Init(); continue; } } - aSel->Next(); + mySelection->Next(); } } @@ -2801,11 +2754,6 @@ Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_Interactive void AIS_InteractiveContext::InitAttributes() { mgrSelector->Add (myMainSel); - myCurrentName = AIS_Context_NewCurName(); - mySelectionName = AIS_Context_NewSelName(); - - AIS_Selection::CreateSelection (mySelectionName.ToCString()); - AIS_Selection::CreateSelection (myCurrentName.ToCString()); myDefaultDrawer->SetShadingAspectGlobal (Standard_False); Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); @@ -2974,13 +2922,11 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView, const Standard_Real theMargin, const Standard_Boolean theToUpdate) { - Standard_CString aSelName = HasOpenedContext() ? - myLocalContexts (myCurLocalIndex)->SelectionName().ToCString() - : myCurrentName.ToCString(); + const Handle(AIS_Selection)& aSelection = HasOpenedContext() ? + myLocalContexts(myCurLocalIndex)->Selection() : mySelection; Bnd_Box aBndSelected; - const Handle(AIS_Selection)& aSelection = AIS_Selection::Selection (aSelName); AIS_MapOfObjectOwners anObjectOwnerMap; for (aSelection->Init(); aSelection->More(); aSelection->Next()) { diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index e407076461..a6a90d0796 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -49,6 +49,7 @@ #include #include #include +#include class SelectMgr_SelectionManager; class V3d_Viewer; class AIS_InteractiveObject; @@ -60,7 +61,6 @@ class Quantity_Color; class TCollection_ExtendedString; class Prs3d_LineAspect; class Prs3d_BasicAspect; -class TopoDS_Shape; class SelectMgr_EntityOwner; class Standard_Transient; class SelectMgr_Filter; @@ -882,6 +882,9 @@ public: //! Same as previous methods in reverse direction... Standard_EXPORT Standard_Integer HilightPreviousDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True); + //! Adds object in the selection. + Standard_EXPORT AIS_StatusOfPick AddSelect (const Handle(Standard_Transient)& theObject); + //! Selects everything found in the bounding rectangle //! defined by the pixel minima and maxima, XPMin, //! YPMin, XPMax, and YPMax in the view, aView @@ -1489,21 +1492,6 @@ public: //! Returns true if there is an open context. Standard_Boolean HasOpenedContext() const; - - //! Returns the name of the current selected entity in Neutral Point. - //! Objects selected when there is no open local context - //! are called current objects; those selected in open - //! local context, selected objects. - const TCollection_AsciiString& CurrentName() const; - - - //! Returns the name of the current selected entity in - //! open local context. - //! Objects selected when there is no open local context - //! are called current objects; those selected in open - //! local context, selected objects. - Standard_EXPORT const TCollection_AsciiString& SelectionName() const; - //! Returns the domain name of the main viewer. Standard_EXPORT Standard_CString DomainOfMainViewer() const; @@ -1623,8 +1611,6 @@ private: Handle(PrsMgr_PresentationManager3d) myMainPM; Handle(V3d_Viewer) myMainVwr; Handle(StdSelect_ViewerSelector3d) myMainSel; - TCollection_AsciiString mySelectionName; - TCollection_AsciiString myCurrentName; Handle(SelectMgr_EntityOwner) myLastPicked; Handle(SelectMgr_EntityOwner) myLastinMain; Standard_Boolean myWasLastMain; @@ -1633,6 +1619,7 @@ private: Standard_Boolean myToHilightSelected; Handle(SelectMgr_OrFilter) myFilters; Handle(Prs3d_Drawer) myDefaultDrawer; + Handle(AIS_Selection) mySelection; Quantity_NameOfColor myDefaultColor; Quantity_NameOfColor myHilightColor; Quantity_NameOfColor mySelectionColor; diff --git a/src/AIS/AIS_InteractiveContext.lxx b/src/AIS/AIS_InteractiveContext.lxx index 5fba823974..2529b17110 100644 --- a/src/AIS/AIS_InteractiveContext.lxx +++ b/src/AIS/AIS_InteractiveContext.lxx @@ -79,9 +79,6 @@ inline Standard_Boolean AIS_InteractiveContext::HasOpenedContext() const inline Handle(AIS_LocalContext) AIS_InteractiveContext::LocalContext() const { return (myCurLocalIndex > 0) ? myLocalContexts(myCurLocalIndex) : NULL; } -inline const TCollection_AsciiString& AIS_InteractiveContext::CurrentName() const -{return myCurrentName;} - inline Standard_Boolean AIS_InteractiveContext::WasCurrentTouched() const {return myCurrentTouched;} diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index eaa9d9fd0b..1ec8365bce 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,11 @@ typedef NCollection_DataMap > AIS_MapOfObjSelectedOwners; +namespace +{ + TopoDS_Shape AIS_myDummyShape; +} + //======================================================================= //function : highlightWithColor //purpose : @@ -89,13 +93,11 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn if (!theOwner->IsAutoHilight()) { - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - const Handle(AIS_Selection)& aCurSel = AIS_Selection::CurrentSelection(); SelectMgr_SequenceOfOwner aSeq; - for (aCurSel->Init(); aCurSel->More(); aCurSel->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { const Handle(SelectMgr_EntityOwner) aSelOwnr = - Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (aSelOwnr->Selectable() != anObj) continue; aSeq.Append (aSelOwnr); @@ -114,13 +116,11 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn //======================================================================= void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity) { - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); NCollection_IndexedMap anObjToClear; - for (aCurSel->Init(); aCurSel->More(); aCurSel->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (anOwner.IsNull() || !anOwner->HasSelectable()) continue; @@ -304,6 +304,24 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th return aStatus; } +//======================================================================= +//function : AddSelect +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(Standard_Transient)& theObject) +{ + if (HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->AddSelect (theObject); + } + mySelection->AddSelect (theObject); + + Standard_Integer aSelNum = NbSelected(); + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; +} + //======================================================================= //function : Select //purpose : @@ -336,7 +354,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi } aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { @@ -344,7 +361,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner)) continue; - AIS_Selection::Select (aCurOwner); + mySelection->Select (aCurOwner); aCurOwner->State (1); } @@ -385,7 +402,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the } aSelector->Pick (thePolyline, theView); - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { @@ -393,7 +409,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; - AIS_Selection::Select (anOwner); + mySelection->Select (anOwner); anOwner->State (1); } @@ -442,7 +458,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate { unhighlightSelected (Standard_True); - AIS_Selection::Select(); + mySelection->Select(); if (toUpdateViewer && myWasLastMain) { UpdateCurrentViewer(); @@ -523,14 +539,13 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the } aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked(); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; - AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner); + AIS_SelectStatus aSelStatus = mySelection->Select (anOwner); Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; anOwner->State (aState); } @@ -574,14 +589,13 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d aSelector->Pick (thePolyline, theView); - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); for (aSelector->Init(); aSelector->More(); aSelector->Next()) { const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked(); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; - AIS_SelectStatus aSelStatus = AIS_Selection::Select (anOwner); + AIS_SelectStatus aSelStatus = mySelection->Select (anOwner); Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; anOwner->State (aState); } @@ -751,13 +765,11 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate // In case of selection without using local context myMainPM->ClearImmediateDraw(); - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString()); AIS_MapOfObjSelectedOwners anObjOwnerMap; - for (aSel->Init(); aSel->More(); aSel->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (!anOwner.IsNull() && anOwner->HasSelectable()) { const Handle(AIS_InteractiveObject) anObj = @@ -815,12 +827,10 @@ void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpda return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer); } - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - Handle(AIS_Selection) aSel = AIS_Selection::Selection (myCurrentName.ToCString()); - for (aSel->Init(); aSel->More(); aSel->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aSel->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (!anOwner.IsNull() && anOwner->HasSelectable()) { const Handle(AIS_InteractiveObject) anObj = @@ -854,7 +864,7 @@ void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateVi unhighlightSelected(); - AIS_Selection::Select(); + mySelection->Select(); myMainPM->ClearImmediateDraw(); if (theToUpdateViewer) @@ -908,12 +918,10 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t return; } - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); - for (aCurSel->Init(); aCurSel->More(); aCurSel->Next()) + for (mySelection->Init(); mySelection->More(); mySelection->Next()) { const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; @@ -934,7 +942,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t aSel->Init(); Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId()); - AIS_Selection::ClearAndSelect (anOwner); + mySelection->ClearAndSelect (anOwner); anOwner->State (1); if (anOwner == theObject->GlobalSelOwner()) { @@ -993,7 +1001,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t unhighlightSelected(); - AIS_Selection::ClearAndSelect (theOwner); + mySelection->ClearAndSelect (theOwner); theOwner->State (1); Quantity_NameOfColor aCustomColor; Standard_Boolean isCustomColorSet; @@ -1076,10 +1084,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO if (theOwner.IsNull() || !theOwner->HasSelectable()) return; - AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); - Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); - - AIS_SelectStatus aSelStat = AIS_Selection::Select (theOwner); + AIS_SelectStatus aSelStat = mySelection->Select (theOwner); Standard_Integer aState = aSelStat == AIS_SS_Added ? 1 : 0; theOwner->State (aState); @@ -1168,7 +1173,7 @@ void AIS_InteractiveContext::InitSelected() return; } - AIS_Selection::Selection (myCurrentName.ToCString())->Init(); + mySelection->Init(); } //======================================================================= @@ -1180,7 +1185,7 @@ Standard_Boolean AIS_InteractiveContext::MoreSelected() const if (HasOpenedContext()) return myLocalContexts (myCurLocalIndex)->MoreSelected(); - return AIS_Selection::Selection (myCurrentName.ToCString())->More(); + return mySelection->More(); } //======================================================================= @@ -1195,7 +1200,7 @@ void AIS_InteractiveContext::NextSelected() return; } - AIS_Selection::Selection (myCurrentName.ToCString())->Next(); + mySelection->Next(); } //======================================================================= @@ -1224,11 +1229,11 @@ TopoDS_Shape AIS_InteractiveContext::SelectedShape() const return myLocalContexts (myCurLocalIndex)->SelectedShape(); } - if (AIS_Selection::Selection (myCurrentName.ToCString())->Extent() == 0) + if (mySelection->Extent() == 0) return TopoDS_Shape(); const Handle(StdSelect_BRepOwner) anOwner = - Handle(StdSelect_BRepOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value()); + Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value()); if (!anOwner->HasSelectable()) return TopoDS_Shape(); @@ -1247,7 +1252,7 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() cons } const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (AIS_Selection::Selection (myCurrentName.ToCString())->Value()); + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()); if (anOwner.IsNull() || !anOwner->HasSelectable()) return NULL; @@ -1264,10 +1269,8 @@ Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const return myLocalContexts(myCurLocalIndex)->SelectedOwner(); } - Handle(AIS_Selection) aCurSel = AIS_Selection::Selection (myCurrentName.ToCString()); - - return aCurSel->Extent() > 0 ? - Handle(SelectMgr_EntityOwner)::DownCast (aCurSel->Value()) : NULL; + return mySelection->Extent() > 0 ? + Handle(SelectMgr_EntityOwner)::DownCast (mySelection->Value()) : NULL; } //======================================================================= @@ -1501,13 +1504,11 @@ const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape(); } - static TopoDS_Shape aDummyShape; - Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject()); if (aCurrentShape.IsNull()) { - return aDummyShape; + return AIS_myDummyShape; } return aCurrentShape->Shape(); diff --git a/src/AIS/AIS_InteractiveContext_2.cxx b/src/AIS/AIS_InteractiveContext_2.cxx index 95f447dd99..d5f4baee41 100644 --- a/src/AIS/AIS_InteractiveContext_2.cxx +++ b/src/AIS/AIS_InteractiveContext_2.cxx @@ -419,7 +419,7 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj, Standard_Integer DM,HM,SM; GetDefModes(anIObj,DM,HM,SM); - if(AIS_Selection::IsSelected(anIObj)) + if(mySelection->IsSelected(anIObj)) myMainPM->Highlight(anIObj,HM); if(updateviewer){ diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 2f1ccd9583..4481c93f3f 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -51,17 +50,6 @@ #include IMPLEMENT_STANDARD_RTTIEXT(AIS_LocalContext,MMgt_TShared) -static TCollection_AsciiString AIS_Local_SelName(const Standard_Address address, - const Standard_Integer anIndex) -{ -// TCollection_AsciiString SelName; - char string[100]; - sprintf(string,"%p_%d", address, anIndex); // works under any system - TCollection_AsciiString SelName(string); - return SelName; -} - - //======================================================================= //function : AIS_LocalContext //purpose : @@ -85,6 +73,7 @@ myMainVS(aCtx->MainSelector()), myFilters(new SelectMgr_OrFilter()), myAutoHilight(Standard_True), myMapOfOwner (new SelectMgr_IndexedMapOfOwner()), +mySelection(new AIS_Selection()), mylastindex(0), mylastgood(0), myCurDetected(0), @@ -98,8 +87,6 @@ myAISCurDetected(0) myMainVS->ResetSelectionActivationStatus(); myMainPM = aCtx->MainPrsMgr(); - mySelName = AIS_Local_SelName(this, Index); - AIS_Selection::CreateSelection(mySelName.ToCString()); mySM->Add(myMainVS); if(myLoadDisplayed) LoadContextObjects(); @@ -626,18 +613,13 @@ void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) // clear the selector... myMainVS->Clear(); - - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); Handle(Standard_Transient) Tr; - for(S->Init();S->More();S->Next()){ - Tr = S->Value(); + for (mySelection->Init(); mySelection->More(); mySelection->Next()){ + Tr = mySelection->Value(); Handle(SelectMgr_EntityOwner)::DownCast (Tr)->SetSelected (Standard_False); } - - AIS_Selection::Select(); - AIS_Selection::Remove(mySelName.ToCString()); + mySelection->Select(); Handle(V3d_View) aDummyView; myMainVS->ClearSensitive (aDummyView); diff --git a/src/AIS/AIS_LocalContext.hxx b/src/AIS/AIS_LocalContext.hxx index ce075af47b..26d7b328ec 100644 --- a/src/AIS/AIS_LocalContext.hxx +++ b/src/AIS/AIS_LocalContext.hxx @@ -40,6 +40,7 @@ #include #include #include +#include class AIS_InteractiveContext; class SelectMgr_SelectionManager; class SelectMgr_OrFilter; @@ -91,7 +92,7 @@ public: Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& aCtx); - const TCollection_AsciiString& SelectionName() const; + const Handle(AIS_Selection) Selection() const; Standard_EXPORT void Terminate (const Standard_Boolean updateviewer = Standard_True); @@ -166,6 +167,8 @@ public: Standard_EXPORT Standard_Boolean UnhilightLastDetected (const Handle(V3d_View)& aView); //! returns the number of selected + Standard_EXPORT AIS_StatusOfPick AddSelect (const Handle(Standard_Transient)& theObject); + Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean updateviewer = Standard_True); Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean updateviewer = Standard_True); @@ -411,7 +414,6 @@ private: Handle(SelectMgr_SelectionManager) mySM; Handle(StdSelect_ViewerSelector3d) myMainVS; Handle(PrsMgr_PresentationManager3d) myMainPM; - TCollection_AsciiString mySelName; Handle(StdSelect_ViewerSelector3d) myCollVS; AIS_DataMapOfSelStat myActiveObjects; Handle(SelectMgr_OrFilter) myFilters; @@ -419,6 +421,7 @@ private: Handle(SelectMgr_Filter) myStdFilters[9]; Standard_Boolean myAutoHilight; Handle(SelectMgr_IndexedMapOfOwner) myMapOfOwner; + Handle(AIS_Selection) mySelection; Standard_Integer mylastindex; Standard_Integer mylastgood; Standard_Integer myCurrentOwner; diff --git a/src/AIS/AIS_LocalContext.lxx b/src/AIS/AIS_LocalContext.lxx index c72cff74bf..e09769e336 100644 --- a/src/AIS/AIS_LocalContext.lxx +++ b/src/AIS/AIS_LocalContext.lxx @@ -18,9 +18,8 @@ #include -inline const TCollection_AsciiString& AIS_LocalContext:: -SelectionName() const -{return mySelName;} +inline const Handle(AIS_Selection) AIS_LocalContext::Selection() const +{return mySelection;} inline void AIS_LocalContext::SetAutomaticHilight(const Standard_Boolean aStatus) {myAutoHilight = aStatus;} diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index 68ecf0d8a3..f4f7a2b00f 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -50,9 +50,13 @@ #include #include #include -#include #include +namespace +{ + TopoDS_Shape AIS_myDummyShape; +} + static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO) { return IO->HasHilightMode() ? IO->HilightMode():0; @@ -135,6 +139,20 @@ AIS_StatusOfDetection AIS_LocalContext::MoveTo (const Standard_Integer theXpix, } } +//======================================================================= +//function : AddSelect +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_LocalContext::AddSelect (const Handle(Standard_Transient)& theObject) +{ + mySelection->AddSelect (theObject); + + Standard_Integer aSelNum = mySelection->Extent(); + return (aSelNum == 1) ? AIS_SOP_OneSelected + : (aSelNum > 1) ? AIS_SOP_SeveralSelected + : AIS_SOP_Error; +} + //======================================================================= //function : Select //purpose : @@ -146,13 +164,11 @@ AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Boolean toUpdateViewer UnhilightPicked (Standard_False); } - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); - Standard_Integer aDetIndex = DetectedIndex(); if (aDetIndex <= 0) { ClearSelected (toUpdateViewer); - return (AIS_Selection::Extent() == 0) ? AIS_SOP_NothingSelected : AIS_SOP_Removed; + return (mySelection->Extent() == 0) ? AIS_SOP_NothingSelected : AIS_SOP_Removed; } const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (aDetIndex); @@ -162,7 +178,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Boolean toUpdateViewer if (!anOwner->IsSelected()) // anOwner is not selected { anOwner->SetSelected (Standard_True); - AIS_Selection::Select (anOwner); + mySelection->Select (anOwner); } if (myAutoHilight) @@ -186,7 +202,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Boolean toUpdateViewer } } - return (AIS_Selection::Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected; + return (mySelection->Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected; } //======================================================================= @@ -208,8 +224,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Integer theXPMin, UnhilightPicked (Standard_False); } - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); - Standard_Integer aSelNum = AIS_Selection::Extent(); + Standard_Integer aSelNum = mySelection->Extent(); myMainVS->Init(); if (!myMainVS->More()) @@ -230,7 +245,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Integer theXPMin, if (!anOwner->IsSelected()) { anOwner->SetSelected (Standard_True); - AIS_Selection::Select (anOwner); + mySelection->Select (anOwner); } } } @@ -241,7 +256,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Integer theXPMin, } } - Standard_Integer aSelNum = AIS_Selection::Extent(); + Standard_Integer aSelNum = mySelection->Extent(); return (aSelNum == 1) ? AIS_SOP_OneSelected : (aSelNum > 1) ? AIS_SOP_SeveralSelected @@ -260,9 +275,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const TColgp_Array1OfPnt2d& thePolyli { myMainVS->Pick (thePolyline, theView); - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); - - Standard_Integer aLastSelNum = AIS_Selection::Extent(); + Standard_Integer aLastSelNum = mySelection->Extent(); myMainVS->Init(); if (!myMainVS->More()) { @@ -290,7 +303,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const TColgp_Array1OfPnt2d& thePolyli // it can be helpful to classify this owner immediately... if (!anOwner->IsSelected()) { - AIS_Selection::AddSelect (anOwner); + mySelection->AddSelect (anOwner); anOwner->SetSelected (Standard_True); } } @@ -302,7 +315,7 @@ AIS_StatusOfPick AIS_LocalContext::Select (const TColgp_Array1OfPnt2d& thePolyli } } - Standard_Integer aSelNum = AIS_Selection::Extent(); + Standard_Integer aSelNum = mySelection->Extent(); return (aSelNum == 1) ? AIS_SOP_OneSelected : (aSelNum > 1) ? AIS_SOP_SeveralSelected : AIS_SOP_Error; @@ -315,15 +328,13 @@ AIS_StatusOfPick AIS_LocalContext::Select (const TColgp_Array1OfPnt2d& thePolyli AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Boolean toUpdateViewer) { Standard_Integer aDetIndex = DetectedIndex(); - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); if(aDetIndex > 0) { - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); - Standard_Integer aSelNum = AIS_Selection::Extent(); + Standard_Integer aSelNum = mySelection->Extent(); const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (aDetIndex); Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True; - AIS_Selection::Select (anOwner); + mySelection->Select (anOwner); anOwner->SetSelected (toSelect); if(myAutoHilight) @@ -348,7 +359,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Boolean toUpdateV } } - Standard_Integer NS = AIS_Selection::Extent(); + Standard_Integer NS = mySelection->Extent(); if( NS == 1 ) return AIS_SOP_OneSelected; else if( NS > 1 ) return AIS_SOP_SeveralSelected; return aSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; @@ -373,8 +384,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Integer theXPMin { myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); - Standard_Integer aLastSelNum = AIS_Selection::Extent(); + Standard_Integer aLastSelNum = mySelection->Extent(); myMainVS->Init(); if (!myMainVS->More()) @@ -396,7 +406,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Integer theXPMin if(myFilters->IsOk (anOwner)) { Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True; - AIS_Selection::Select (anOwner); + mySelection->Select (anOwner); anOwner->SetSelected (toSelect); } } @@ -407,7 +417,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Integer theXPMin } } - Standard_Integer aSelNum = AIS_Selection::Extent(); + Standard_Integer aSelNum = mySelection->Extent(); return (aSelNum == 1) ? AIS_SOP_OneSelected : (aSelNum > 1) ? AIS_SOP_SeveralSelected @@ -426,9 +436,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const TColgp_Array1OfPnt2d& theP { myMainVS->Pick (thePolyline, theView); - AIS_Selection::SetCurrentSelection (mySelName.ToCString()); - - Standard_Integer aLastSelNum = AIS_Selection::Extent(); + Standard_Integer aLastSelNum = mySelection->Extent(); myMainVS->Init(); if(!myMainVS->More()) { @@ -449,7 +457,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const TColgp_Array1OfPnt2d& theP if (myFilters->IsOk (anOwner)) { Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True; - AIS_Selection::Select (anOwner); + mySelection->Select (anOwner); anOwner->SetSelected (toSelect); } } @@ -459,7 +467,7 @@ AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const TColgp_Array1OfPnt2d& theP } } - Standard_Integer aSelNum = AIS_Selection::Extent(); + Standard_Integer aSelNum = mySelection->Extent(); return (aSelNum == 1) ? AIS_SOP_OneSelected : (aSelNum > 1) ? AIS_SOP_SeveralSelected @@ -516,16 +524,15 @@ void AIS_LocalContext::Unhilight (const Handle(SelectMgr_EntityOwner)& theOwner, //======================================================================= void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer) { - Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString()); - if( Sel.IsNull() ) return; - + if( mySelection.IsNull() ) return; + typedef NCollection_DataMap > SelectMgr_DataMapOfObjectOwners; SelectMgr_DataMapOfObjectOwners aMap; Handle (PrsMgr_PresentationManager3d) PM = myMainPM; // to avoid problems when there is a loop searching for selected objects... - const AIS_NListTransient& Obj = Sel->Objects(); + const AIS_NListTransient& Obj = mySelection->Objects(); AIS_NListTransient::Iterator anIter( Obj ); for(; anIter.More(); anIter.Next()) { @@ -575,12 +582,11 @@ void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer) { myMainPM->ClearImmediateDraw(); - Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString()); - if( Sel.IsNull() ) return; + if( mySelection.IsNull() ) return; Handle (PrsMgr_PresentationManager3d) PM = myMainPM; NCollection_Map anObjMap; - const AIS_NListTransient& Obj = Sel->Objects(); + const AIS_NListTransient& Obj = mySelection->Objects(); AIS_NListTransient::Iterator anIter( Obj ); for(; anIter.More(); anIter.Next()){ const Handle(Standard_Transient)& Tr = anIter.Value(); @@ -639,8 +645,7 @@ Standard_Boolean AIS_LocalContext::IsSelected (const Handle(SelectMgr_EntityOwne void AIS_LocalContext:: InitSelected() { - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - AIS_Selection::CurrentSelection()->Init(); + mySelection->Init(); } //================================================== @@ -650,7 +655,7 @@ InitSelected() Standard_Boolean AIS_LocalContext:: MoreSelected() const { - return AIS_Selection::CurrentSelection()->More(); + return mySelection->More(); } //================================================== @@ -660,7 +665,7 @@ MoreSelected() const void AIS_LocalContext:: NextSelected() { - AIS_Selection::CurrentSelection()->Next(); + mySelection->Next(); } //================================================== @@ -670,7 +675,7 @@ NextSelected() Standard_Boolean AIS_LocalContext:: HasShape() const { - Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value(); + Handle(Standard_Transient) Tr = mySelection->Value(); if( Tr.IsNull() ) return Standard_False; Handle(SelectMgr_EntityOwner) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr); Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO); @@ -686,10 +691,10 @@ HasShape() const //================================================================ Standard_Boolean AIS_LocalContext::HasSelectedShape() const { - if (AIS_Selection::CurrentSelection()->Extent() == 0) + if (mySelection->Extent() == 0) return Standard_False; - Handle(Standard_Transient) aCurSelection = AIS_Selection::CurrentSelection()->Value(); + Handle(Standard_Transient) aCurSelection = mySelection->Value(); if (aCurSelection.IsNull()) return Standard_False; @@ -708,7 +713,7 @@ Standard_Boolean AIS_LocalContext::HasSelectedShape() const //================================================== TopoDS_Shape AIS_LocalContext::SelectedShape() const { - Handle(Standard_Transient) aTr = AIS_Selection::CurrentSelection()->Value(); + Handle(Standard_Transient) aTr = mySelection->Value(); Handle(SelectMgr_EntityOwner) anEO = Handle(SelectMgr_EntityOwner)::DownCast (aTr); Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(anEO); if( aBRO.IsNull() ) @@ -727,7 +732,7 @@ Handle(AIS_InteractiveObject) AIS_LocalContext:: SelectedInteractive() const { Handle(AIS_InteractiveObject) IO; - Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value(); + Handle(Standard_Transient) Tr = mySelection->Value(); if( !Tr.IsNull() ) { Handle(SelectMgr_EntityOwner) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr); Handle(SelectMgr_SelectableObject) SO; @@ -746,7 +751,7 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext:: SelectedOwner() const { Handle(SelectMgr_EntityOwner) EO; - Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value(); + Handle(Standard_Transient) Tr = mySelection->Value(); if( !Tr.IsNull() ) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr); return EO; @@ -797,12 +802,9 @@ void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj if (anobj.IsNull() || anobj->IsAutoHilight()) return; - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection(); - SelectMgr_SequenceOfOwner aSeq; - for ( Sel->Init(); Sel->More(); Sel->Next() ){ - Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(Sel->Value()); + for (mySelection->Init(); mySelection->More(); mySelection->Next() ){ + Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(mySelection->Value()); if ( !aOwner.IsNull() && aOwner->HasSelectable() && aOwner->Selectable() == anobj ) aSeq.Append( aOwner ); @@ -825,10 +827,8 @@ void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj void AIS_LocalContext::ClearSelected (const Standard_Boolean updateviewer) { UnhilightPicked(updateviewer); - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection(); - const AIS_NListTransient& Obj = Sel->Objects(); + const AIS_NListTransient& Obj = mySelection->Objects(); AIS_NListTransient::Iterator anIter( Obj ); for(; anIter.More(); anIter.Next()){ const Handle(Standard_Transient)& Tr = anIter.Value(); @@ -837,7 +837,7 @@ void AIS_LocalContext::ClearSelected (const Standard_Boolean updateviewer) (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False); } } - AIS_Selection::Select(); + mySelection->Select(); mylastindex = 0; } @@ -918,8 +918,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec // 3. AIS_Selection : remove entity owners from AIS_Selection const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); - Handle(AIS_Selection) aSelection = AIS_Selection::Selection (mySelName.ToCString()); - AIS_NListTransient::Iterator anIter (aSelection->Objects()); + AIS_NListTransient::Iterator anIter (mySelection->Objects()); AIS_NListTransient aRemoveEntites; for (; anIter.More(); anIter.Next()) { @@ -946,7 +945,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec AIS_NListTransient::Iterator anIterRemove (aRemoveEntites); for (; anIterRemove.More(); anIterRemove.Next()) { - aSelection->Select (anIterRemove.Value()); + mySelection->Select (anIterRemove.Value()); } // 4. AIS_LocalContext - myMapOfOwner : remove entity owners from myMapOfOwner @@ -1045,8 +1044,6 @@ void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj, //1st case, owner already as owner // and not separated is found... - Handle(AIS_Selection) sel = AIS_Selection::Selection(mySelName.ToCString()); - //Standard_Boolean found(Standard_False); Handle(Standard_Transient) Tr; Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromIO(anIObj); if(EO.IsNull()){ @@ -1065,7 +1062,7 @@ void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj, ClearSelected(Standard_False); - AIS_Selection::Select(EO); + mySelection->Select(EO); EO->SetSelected (Standard_True); HilightPicked(updateviewer); @@ -1102,13 +1099,10 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj); } } - -// cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<Select(EO); + AIS_SelectStatus aStatus = mySelection->Select(EO); EO->SetSelected (aStatus == AIS_SS_Added); } @@ -1126,7 +1120,7 @@ void AIS_LocalContext::AddOrRemoveSelected(const TopoDS_Shape& Sh, Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromShape(Sh); if (!EO.IsNull()) { - AIS_Selection::Selection(mySelName.ToCString())->Select(EO); + mySelection->Select(EO); EO->SetSelected (Standard_True); } HilightPicked (updateviewer); @@ -1142,7 +1136,7 @@ void AIS_LocalContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& Standard_Boolean toSelect = theOwner->IsSelected() ? Standard_False : Standard_True; - AIS_Selection::Selection (mySelName.ToCString())->Select (theOwner); + mySelection->Select(theOwner); theOwner->SetSelected (toSelect); if(myAutoHilight) @@ -1261,14 +1255,13 @@ Standard_Boolean AIS_LocalContext::HasDetectedShape() const const TopoDS_Shape& AIS_LocalContext::DetectedShape() const { - static TopoDS_Shape bidsh; if(mylastindex != 0) { Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner->FindKey (mylastindex)); - if(BROwnr.IsNull()) return bidsh; + if(BROwnr.IsNull()) return AIS_myDummyShape; return BROwnr->Shape(); } - return bidsh; + return AIS_myDummyShape; } //======================================================================= @@ -1446,8 +1439,7 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO Handle(SelectMgr_EntityOwner) EO,bid; if (anIObj.IsNull()) return EO; - Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString()); - if(Sel.IsNull()) { + if(mySelection.IsNull()) { #ifdef OCCT_DEBUG cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection " <Objects(); + const AIS_NListTransient& Obj = mySelection->Objects(); AIS_NListTransient::Iterator anIter( Obj ); for(; anIter.More(); anIter.Next()){ const Handle(Standard_Transient)& Tr = anIter.Value(); @@ -1485,8 +1477,7 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const Handle(SelectMgr_EntityOwner) EO, bid; if (sh.IsNull()) return EO; - Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString()); - if(Sel.IsNull()) { + if(mySelection.IsNull()) { #ifdef OCCT_DEBUG cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<Shape(); diff --git a/src/AIS/AIS_Point.cxx b/src/AIS/AIS_Point.cxx index 93325280c6..959fe9bd21 100644 --- a/src/AIS/AIS_Point.cxx +++ b/src/AIS/AIS_Point.cxx @@ -87,9 +87,7 @@ void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat StdPrs_Point::Add(aPresentation,myComponent,myDrawer); else if (aMode== -99) { - // Beeurk.. a revoir - rob-25/04/97 - static Handle(Graphic3d_AspectMarker3d) PtA = - new Graphic3d_AspectMarker3d (); + Handle(Graphic3d_AspectMarker3d) PtA = new Graphic3d_AspectMarker3d (); PtA->SetType(Aspect_TOM_PLUS); PtA->SetScale(3.); Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); diff --git a/src/AIS/AIS_Selection.cxx b/src/AIS/AIS_Selection.cxx index 5e05506a0b..ea2c849304 100644 --- a/src/AIS/AIS_Selection.cxx +++ b/src/AIS/AIS_Selection.cxx @@ -21,147 +21,50 @@ #include #include #include -#include -#include IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection,MMgt_TShared) #define MaxSizeOfResult 100000 -//current selection (handle) -static Handle(AIS_Selection) theCurrentSelection; -static void AIS_Sel_CurrentSelection (Handle(AIS_Selection)& InputSel) -{ - if(!InputSel.IsNull()) - theCurrentSelection = InputSel; - else - InputSel = theCurrentSelection; -} - -static TColStd_SequenceOfTransient& AIS_Sel_GetSelections() -{ - static TColStd_SequenceOfTransient Selections; - return Selections; -} - //======================================================================= //function : AIS_Selection //purpose : //======================================================================= -AIS_Selection::AIS_Selection(const Standard_CString aName) : -myName(TCollection_AsciiString(aName)), +AIS_Selection::AIS_Selection() : myNb(0) { myResultMap.ReSize( MaxSizeOfResult ); // for maximum performnace on medium selections ( < 100000 objects ) } -//======================================================================= -//function : CreateSelection -//purpose : -//======================================================================= -Standard_Boolean AIS_Selection::CreateSelection(const Standard_CString aName) -{ - Handle(AIS_Selection) S = AIS_Selection::Selection(aName); - if(!S.IsNull()) - return Standard_False; - S = new AIS_Selection(aName); - AIS_Sel_GetSelections().Prepend(S); - AIS_Sel_CurrentSelection(S); - return Standard_True; -} - - -//======================================================================= -//function : Selection -//purpose : -//======================================================================= -Handle(AIS_Selection) AIS_Selection::Selection(const Standard_CString aName) -{ - Handle(AIS_Selection) S; - if(AIS_Sel_GetSelections().IsEmpty()) return S; - - Handle(Standard_Transient) curobj; - Handle(AIS_Selection) Sel; -// Standard_Boolean found(Standard_False); - for(Standard_Integer I =1; I<= AIS_Sel_GetSelections().Length();I++){ - curobj = AIS_Sel_GetSelections().Value(I); - Sel = Handle(AIS_Selection)::DownCast (curobj); - if(Sel->myName.IsEqual(aName)) - return Sel; - } - - return S; -} - -//======================================================================= -//function : Find -//purpose : -//======================================================================= -Standard_Boolean AIS_Selection::Find(const Standard_CString aName) -{ - Handle(AIS_Selection) S = AIS_Selection::Selection(aName); - return !S.IsNull(); -} - -//======================================================================= -//function : SetCurrentSelection -//purpose : -//======================================================================= -Standard_Boolean AIS_Selection::SetCurrentSelection (const Standard_CString aName) -{ - AIS_Selection::CreateSelection(aName); - - - Handle(AIS_Selection) anAISSelection = AIS_Selection::Selection(aName) ; - AIS_Sel_CurrentSelection ( anAISSelection ) ; - return Standard_True; -} - //======================================================================= //function : Select //purpose : //======================================================================= void AIS_Selection::Select() { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - if(!S.IsNull()){ - S->myNb=0; - S->myresult.Clear(); - S->myResultMap.Clear(); - } + myNb=0; + myresult.Clear(); + myResultMap.Clear(); } -//======================================================================= -//function : CurrentSelection -//purpose : -//======================================================================= -Handle(AIS_Selection) AIS_Selection::CurrentSelection() { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - return S; -} //======================================================================= //function : Select //purpose : //======================================================================= AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObject) { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - if(S.IsNull()) return AIS_SS_NotDone; Handle(AIS_InteractiveObject) anAISObj; Handle(SelectMgr_EntityOwner) owner = Handle(SelectMgr_EntityOwner)::DownCast( anObject ); if ( owner.IsNull() ) anAISObj = Handle(AIS_InteractiveObject)::DownCast( anObject ); - if ( S->myResultMap.IsBound( anObject ) ){ - AIS_NListTransient::Iterator aListIter = S->myResultMap.Find( anObject ); + if ( myResultMap.IsBound( anObject ) ){ + AIS_NListTransient::Iterator aListIter = myResultMap.Find( anObject ); //skt----------------------------------------------------------------- - if( S->myIterator == aListIter ) { - if( S->myIterator.More() ) - S->myIterator.Next(); + if( myIterator == aListIter ) { + if( myIterator.More() ) + myIterator.Next(); else - S->myIterator = AIS_NListTransient::Iterator(); + myIterator = AIS_NListTransient::Iterator(); } //-------------------------------------------------------------------- // In the mode of advanced mesh selection only one owner is created @@ -170,16 +73,16 @@ AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObjec // the same as previous selected (IsForcedHilight call) if( !anAISObj.IsNull() || ( !owner.IsNull() && !owner->IsForcedHilight() ) ) { - S->myresult.Remove( aListIter ); - S->myResultMap.UnBind( anObject ); + myresult.Remove( aListIter ); + myResultMap.UnBind( anObject ); // update list iterator for next object in list if any if ( aListIter.More() ){ const Handle(Standard_Transient)& aNextObject = aListIter.Value(); - if ( S->myResultMap.IsBound( aNextObject ) ) - S->myResultMap( aNextObject ) = aListIter; + if ( myResultMap.IsBound( aNextObject ) ) + myResultMap( aNextObject ) = aListIter; else - S->myResultMap.Bind( aNextObject, aListIter ); + myResultMap.Bind( aNextObject, aListIter ); } return AIS_SS_Removed; } @@ -188,8 +91,8 @@ AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObjec } AIS_NListTransient::Iterator aListIter; - S->myresult.Append( anObject, aListIter ); - S->myResultMap.Bind( anObject, aListIter ); + myresult.Append( anObject, aListIter ); + myResultMap.Bind( anObject, aListIter ); return AIS_SS_Added; } @@ -199,16 +102,12 @@ AIS_SelectStatus AIS_Selection::Select(const Handle(Standard_Transient)& anObjec //======================================================================= AIS_SelectStatus AIS_Selection::AddSelect(const Handle(Standard_Transient)& anObject) { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - if(S.IsNull()) return AIS_SS_NotDone; - - if ( S->myResultMap.IsBound( anObject ) ) + if ( myResultMap.IsBound( anObject ) ) return AIS_SS_NotDone; AIS_NListTransient::Iterator aListIter; - S->myresult.Append( anObject, aListIter ); - S->myResultMap.Bind( anObject, aListIter ); + myresult.Append( anObject, aListIter ); + myResultMap.Bind( anObject, aListIter ); return AIS_SS_Added; } @@ -218,14 +117,10 @@ AIS_SelectStatus AIS_Selection::AddSelect(const Handle(Standard_Transient)& anOb //purpose : //======================================================================= -void AIS_Selection::ClearAndSelect(const Handle(Standard_Transient)& anObject) { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - if(S.IsNull()) return; - +void AIS_Selection::ClearAndSelect(const Handle(Standard_Transient)& anObject) +{ Select(); Select(anObject); - } @@ -233,14 +128,9 @@ void AIS_Selection::ClearAndSelect(const Handle(Standard_Transient)& anObject) { //function : Extent //purpose : //======================================================================= -Standard_Integer AIS_Selection::Extent() { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - - if (S.IsNull()) - return 0; - - return S->myresult.Extent(); +Standard_Integer AIS_Selection::Extent() const +{ + return myresult.Extent(); } //======================================================================= @@ -249,63 +139,16 @@ Standard_Integer AIS_Selection::Extent() { //======================================================================= Handle(Standard_Transient) AIS_Selection::Single() { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - - if (S.IsNull()) - return Handle(Standard_Transient)(); - - S->Init(); - return S->Value(); + Init(); + return Value(); } //======================================================================= //function : IsSelected //purpose : //======================================================================= -Standard_Boolean AIS_Selection::IsSelected(const Handle(Standard_Transient)& anObject) +Standard_Boolean AIS_Selection::IsSelected(const Handle(Standard_Transient)& anObject) const { - Handle(AIS_Selection) S; - AIS_Sel_CurrentSelection (S); - if(S.IsNull()) return Standard_False; - return S->myResultMap.IsBound( anObject ); + return myResultMap.IsBound( anObject ); } -//======================================================================= -//function : Index -//purpose : -//======================================================================= - -Standard_Integer AIS_Selection::Index(const Standard_CString aName) -{ - Handle (Standard_Transient) curobj; - for(Standard_Integer I =1; I<= AIS_Sel_GetSelections().Length();I++){ - curobj = AIS_Sel_GetSelections().Value(I); - if(Handle(AIS_Selection)::DownCast (curobj)->myName.IsEqual(aName)) - return I; - } - return 0; -} - -//======================================================================= -//function : Remove -//purpose : -//======================================================================= - -void AIS_Selection::Remove(const Standard_CString aName) -{ - Standard_Integer I = AIS_Selection::Index(aName); - if(I!=0) { - Handle(AIS_Selection) selection = Handle(AIS_Selection)::DownCast( AIS_Sel_GetSelections().Value(I) ); - Standard_Integer stored = selection->NbStored(); - if ( stored ) - selection->Select(); - AIS_Sel_GetSelections().Remove(I); - } -} - -// clean the static current selection handle -void AIS_Selection::ClearCurrentSelection() -{ - theCurrentSelection.Nullify(); -} diff --git a/src/AIS/AIS_Selection.hxx b/src/AIS/AIS_Selection.hxx index 19c8bb96ac..2da7936a78 100644 --- a/src/AIS/AIS_Selection.hxx +++ b/src/AIS/AIS_Selection.hxx @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -45,80 +44,45 @@ class AIS_Selection : public MMgt_TShared public: - //! creates a new selection and make it current in the session. - //! the selection will be accessible later through its name - //! to make it again current. - //! - //! Note that if a session has been created, a session with - //! the name "default" is created. - //! - //! In this case, the is always a current selection which - //! is the last one created until SetCurrentSelection is used. - //! - //! The class methods deals with the current selection. - //! - //! Warning : Better Call AIS_Selection::CreateSelection. - Standard_EXPORT AIS_Selection(const Standard_CString aName); + //! creates a new selection. + + Standard_EXPORT AIS_Selection(); - Standard_EXPORT static void Remove (const Standard_CString aName); + //! removes all the object of the selection. + Standard_EXPORT void Select(); - //! returns True if a selection having this name exsits. - Standard_EXPORT static Standard_Boolean Find (const Standard_CString aName); - - //! calls the private constructor and puts the new Selection - //! in the list of existing selections. - //! returns False if the selection exists. - Standard_EXPORT static Standard_Boolean CreateSelection (const Standard_CString aName); - - Standard_EXPORT static Handle(AIS_Selection) Selection (const Standard_CString aName); - - //! returns False if There is no selection of name - Standard_EXPORT static Standard_Boolean SetCurrentSelection (const Standard_CString aName); - - Standard_EXPORT static Handle(AIS_Selection) CurrentSelection(); - - //! Clears selection. - Standard_EXPORT static void ClearCurrentSelection(); - - //! removes all the object of the currentselection. - Standard_EXPORT static void Select(); - - //! if the object is not yet in the current selection, it will be added. - //! if the object is already in the current selection, it will be removed. - Standard_EXPORT static AIS_SelectStatus Select (const Handle(Standard_Transient)& anObject); + //! if the object is not yet in the selection, it will be added. + //! if the object is already in the selection, it will be removed. + Standard_EXPORT AIS_SelectStatus Select (const Handle(Standard_Transient)& anObject); //! the object is always add int the selection. //! faster when the number of objects selected is great. - Standard_EXPORT static AIS_SelectStatus AddSelect (const Handle(Standard_Transient)& anObject); + Standard_EXPORT AIS_SelectStatus AddSelect (const Handle(Standard_Transient)& anObject); //! clears the selection and adds the object in the selection. - Standard_EXPORT static void ClearAndSelect (const Handle(Standard_Transient)& anObject); - - Standard_EXPORT static Standard_Boolean IsSelected (const Handle(Standard_Transient)& anObject); + Standard_EXPORT void ClearAndSelect (const Handle(Standard_Transient)& anObject); + + //! checks if the object is in the selection. + Standard_EXPORT Standard_Boolean IsSelected (const Handle(Standard_Transient)& anObject) const; //! returns the number of objects selected. - Standard_EXPORT static Standard_Integer Extent(); + Standard_EXPORT Standard_Integer Extent() const; //! returns the single object selected. //! Warning: raises TypeMismatch from Standard if Extent is not equal to 1. - Standard_EXPORT static Handle(Standard_Transient) Single(); + Standard_EXPORT Handle(Standard_Transient) Single(); - void Init(); + void Init(); - Standard_Boolean More() const; + Standard_Boolean More() const; - void Next(); + void Next(); - const Handle(Standard_Transient)& Value() const; + const Handle(Standard_Transient)& Value() const; - Standard_Integer NbStored() const; + Standard_Integer NbStored() const; - const AIS_NListTransient& Objects() const; - - Standard_EXPORT static Standard_Integer Index (const Standard_CString aName); - - - + const AIS_NListTransient& Objects() const; DEFINE_STANDARD_RTTIEXT(AIS_Selection,MMgt_TShared) @@ -129,8 +93,6 @@ protected: private: - - TCollection_AsciiString myName; AIS_NListTransient myresult; AIS_NListIteratorOfListTransient myIterator; AIS_NDataMapOfTransientIteratorOfListTransient myResultMap; diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index c2721c53a0..170cc28714 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -70,8 +70,6 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject) -static Standard_Boolean myFirstCompute; - static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode) { TColStd_ListIteratorOfListOfInteger It(LL); @@ -92,7 +90,6 @@ AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant), myInitAng(0.) { Set (shap); - myFirstCompute = Standard_True; SetHilightMode(0); myDrawer->SetShadingAspectGlobal(Standard_False); } @@ -398,8 +395,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, return; } - static TopAbs_ShapeEnum TypOfSel; - TypOfSel = AIS_Shape::SelectionType(aMode); + TopAbs_ShapeEnum TypOfSel = AIS_Shape::SelectionType(aMode); TopoDS_Shape shape = myshape; // POP protection against crash in low layers diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 8e77ea0f46..258ff60536 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -118,7 +118,6 @@ Graphic3d_Structure.pxx Graphic3d_StructureDefinitionError.hxx Graphic3d_StructureManager.cxx Graphic3d_StructureManager.hxx -Graphic3d_StructureManager.pxx Graphic3d_StructureManagerPtr.hxx Graphic3d_StructurePtr.hxx Graphic3d_TextPath.hxx diff --git a/src/Graphic3d/Graphic3d_CStructure.cxx b/src/Graphic3d/Graphic3d_CStructure.cxx index 4826060e7a..9fa9fe9212 100644 --- a/src/Graphic3d/Graphic3d_CStructure.cxx +++ b/src/Graphic3d/Graphic3d_CStructure.cxx @@ -17,6 +17,7 @@ #include "Graphic3d_Structure.pxx" #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) @@ -26,8 +27,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient) //purpose : //============================================================================= Graphic3d_CStructure::Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager) -: Id (theManager->NewIdentification()), - myZLayer (Graphic3d_ZLayerId_Default), +: myZLayer (Graphic3d_ZLayerId_Default), Priority (Structure_MAX_PRIORITY / 2), PreviousPriority (Structure_MAX_PRIORITY / 2), ContainsFacet (0), @@ -41,6 +41,8 @@ Graphic3d_CStructure::Graphic3d_CStructure (const Handle(Graphic3d_StructureMana Is2dText (Standard_False), myGraphicDriver (theManager->GraphicDriver()) { + Id = myGraphicDriver->NewIdentification(); + ContextLine.IsDef = 1, ContextFillArea.IsDef = 1, ContextMarker.IsDef = 1, diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cxx b/src/Graphic3d/Graphic3d_GraphicDriver.cxx index 89ef87f13b..8024339646 100644 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cxx +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cxx @@ -55,3 +55,21 @@ void Graphic3d_GraphicDriver::ResetDeviceLostFlag() { myDeviceLostFlag = Standard_False; } + +// ======================================================================= +// function : NewIdentification +// purpose : +// ======================================================================= +Standard_Integer Graphic3d_GraphicDriver::NewIdentification() +{ + return myStructGenId.Next(); +} + +// ======================================================================= +// function : RemoveIdentification +// purpose : +// ======================================================================= +void Graphic3d_GraphicDriver::RemoveIdentification(const Standard_Integer theId) +{ + myStructGenId.Free(theId); +} \ No newline at end of file diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.hxx b/src/Graphic3d/Graphic3d_GraphicDriver.hxx index f81e9f4da8..01a326c690 100644 --- a/src/Graphic3d/Graphic3d_GraphicDriver.hxx +++ b/src/Graphic3d/Graphic3d_GraphicDriver.hxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -139,6 +140,12 @@ public: Standard_EXPORT void ResetDeviceLostFlag(); + //! Returns a new identification number for a new structure. + Standard_EXPORT Standard_Integer NewIdentification(); + + //! Frees the identifier of a structure. + Standard_EXPORT void RemoveIdentification(const Standard_Integer theId); + DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,MMgt_TShared) protected: @@ -150,6 +157,8 @@ protected: Handle(Aspect_DisplayConnection) myDisplayConnection; Standard_Boolean myDeviceLostFlag; + Aspect_GenId myStructGenId; + private: diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.cxx b/src/Graphic3d/Graphic3d_MaterialAspect.cxx index 627e66bb48..f908c939aa 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.cxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.cxx @@ -1009,33 +1009,36 @@ typedef struct _Material Graphic3d_TypeOfMaterial type; } Material; -static Material theMaterials[] = +namespace { - {"Brass", Graphic3d_MATERIAL_PHYSIC}, - {"Bronze", Graphic3d_MATERIAL_PHYSIC}, - {"Copper", Graphic3d_MATERIAL_PHYSIC}, - {"Gold", Graphic3d_MATERIAL_PHYSIC}, - {"Pewter", Graphic3d_MATERIAL_PHYSIC}, - {"Plastered", Graphic3d_MATERIAL_ASPECT}, - {"Plastified", Graphic3d_MATERIAL_ASPECT}, - {"Silver", Graphic3d_MATERIAL_PHYSIC}, - {"Steel", Graphic3d_MATERIAL_PHYSIC}, - {"Stone", Graphic3d_MATERIAL_PHYSIC}, - {"Shiny_plastified", Graphic3d_MATERIAL_ASPECT}, - {"Satined", Graphic3d_MATERIAL_ASPECT}, - {"Metalized", Graphic3d_MATERIAL_ASPECT}, - {"Ionized", Graphic3d_MATERIAL_ASPECT}, - {"Chrome", Graphic3d_MATERIAL_PHYSIC}, - {"Aluminium", Graphic3d_MATERIAL_PHYSIC}, - {"Obsidian", Graphic3d_MATERIAL_PHYSIC}, - {"Neon", Graphic3d_MATERIAL_PHYSIC}, - {"Jade", Graphic3d_MATERIAL_PHYSIC}, - {"Charcoal", Graphic3d_MATERIAL_PHYSIC}, - {"Water", Graphic3d_MATERIAL_PHYSIC}, - {"Glass", Graphic3d_MATERIAL_PHYSIC}, - {"Diamond", Graphic3d_MATERIAL_PHYSIC} + static const Material theMaterials[] = + { + {"Brass", Graphic3d_MATERIAL_PHYSIC}, + {"Bronze", Graphic3d_MATERIAL_PHYSIC}, + {"Copper", Graphic3d_MATERIAL_PHYSIC}, + {"Gold", Graphic3d_MATERIAL_PHYSIC}, + {"Pewter", Graphic3d_MATERIAL_PHYSIC}, + {"Plastered", Graphic3d_MATERIAL_ASPECT}, + {"Plastified", Graphic3d_MATERIAL_ASPECT}, + {"Silver", Graphic3d_MATERIAL_PHYSIC}, + {"Steel", Graphic3d_MATERIAL_PHYSIC}, + {"Stone", Graphic3d_MATERIAL_PHYSIC}, + {"Shiny_plastified", Graphic3d_MATERIAL_ASPECT}, + {"Satined", Graphic3d_MATERIAL_ASPECT}, + {"Metalized", Graphic3d_MATERIAL_ASPECT}, + {"Ionized", Graphic3d_MATERIAL_ASPECT}, + {"Chrome", Graphic3d_MATERIAL_PHYSIC}, + {"Aluminium", Graphic3d_MATERIAL_PHYSIC}, + {"Obsidian", Graphic3d_MATERIAL_PHYSIC}, + {"Neon", Graphic3d_MATERIAL_PHYSIC}, + {"Jade", Graphic3d_MATERIAL_PHYSIC}, + {"Charcoal", Graphic3d_MATERIAL_PHYSIC}, + {"Water", Graphic3d_MATERIAL_PHYSIC}, + {"Glass", Graphic3d_MATERIAL_PHYSIC}, + {"Diamond", Graphic3d_MATERIAL_PHYSIC} -}; + }; +} // ======================================================================= // function : NumberOfMaterials diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 0ecb12de8d..92a95a0dd4 100644 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -188,15 +188,9 @@ void Graphic3d_Structure::Remove() // Destruction of me in the graphic library const Standard_Integer aStructId = myCStructure->Id; + myCStructure->GraphicDriver()->RemoveIdentification(aStructId); myCStructure->GraphicDriver()->RemoveStructure (myCStructure); myCStructure.Nullify(); - - // Liberation of the identification if the destroyed structure - // in the first manager that performs creation of the structure. - if (myFirstStructureManager != NULL) - { - myFirstStructureManager->Remove (aStructId); - } } //============================================================================= diff --git a/src/Graphic3d/Graphic3d_Structure.pxx b/src/Graphic3d/Graphic3d_Structure.pxx index 41acdc7aef..c841755f09 100644 --- a/src/Graphic3d/Graphic3d_Structure.pxx +++ b/src/Graphic3d/Graphic3d_Structure.pxx @@ -20,12 +20,4 @@ #define Structure_MAX_PRIORITY 10 #define Structure_MIN_PRIORITY 0 -#include "Graphic3d_StructureManager.pxx" - -// structures identifiers : possible range - // check the value of View_IDMAX (must be < Structure_IDMIN) -#define Structure_IDMIN 10001 -// /2 pour eviter les problemes d'overflow -#define Structure_IDMAX INT_MAX/2 - #endif diff --git a/src/Graphic3d/Graphic3d_StructureManager.cxx b/src/Graphic3d/Graphic3d_StructureManager.cxx index de34df4ea9..a32ab8f5e0 100644 --- a/src/Graphic3d/Graphic3d_StructureManager.cxx +++ b/src/Graphic3d/Graphic3d_StructureManager.cxx @@ -30,72 +30,24 @@ #include #include #include -#include "Graphic3d_StructureManager.pxx" #include #include IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_StructureManager,MMgt_TShared) -static Standard_Boolean Initialisation = Standard_True; -static int StructureManager_ArrayId[StructureManager_MAX]; -static Standard_Integer StructureManager_CurrentId = 0; - -#include "Graphic3d_Structure.pxx" #include #include Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver) : myViewGenId (0, 31) { + myAspectLine3d = new Graphic3d_AspectLine3d (); + myAspectText3d = new Graphic3d_AspectText3d (); + myAspectMarker3d = new Graphic3d_AspectMarker3d (); + myAspectFillArea3d = new Graphic3d_AspectFillArea3d (); -Standard_Real Coef; -Standard_Integer i; -Standard_Boolean NotFound = Standard_True; -Standard_Integer Limit = Graphic3d_StructureManager::Limit (); - - /* Initialize PHIGS and start up */ - if (Initialisation) { - - Initialisation = Standard_False; - /* table to manage IDs of StructureManager */ - for (i=0; i is displayed and TOS_COMPUTED. Standard_EXPORT virtual void ReCompute (const Handle(Graphic3d_Structure)& theStructure); @@ -200,15 +194,9 @@ public: //! view must have an identification and we have different managers. Standard_EXPORT Standard_Integer MaxNumOfViews() const; - //! Returns the identification number of the manager. - Standard_EXPORT virtual Standard_Integer Identification() const; - //! Returns the structure with the identification number . Standard_EXPORT virtual Handle(Graphic3d_Structure) Identification (const Standard_Integer AId) const; - //! Returns a new identification number for a new structure in the manager. - Standard_EXPORT Standard_Integer NewIdentification(); - //! Suppress the highlighting on the structure . Standard_EXPORT virtual void UnHighlight (const Handle(Graphic3d_Structure)& AStructure); @@ -237,15 +225,7 @@ protected: //! Returns the structure displayed in visualizer . Standard_EXPORT Standard_Integer NumberOfDisplayedStructures() const; -private: - - //! Frees the identifier of a structure. - void Remove (const Standard_Integer theId); - -protected: - Standard_Integer myId; - Aspect_GenId myStructGenId; Aspect_GenId myViewGenId; Aspect_TypeOfUpdate myUpdateMode; Handle(Graphic3d_AspectLine3d) myAspectLine3d; diff --git a/src/Graphic3d/Graphic3d_StructureManager.pxx b/src/Graphic3d/Graphic3d_StructureManager.pxx deleted file mode 100644 index 1be8a4cd62..0000000000 --- a/src/Graphic3d/Graphic3d_StructureManager.pxx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef STRUCTUREMANAGER_PXX_INCLUDED -#define STRUCTUREMANAGER_PXX_INCLUDED - -//static Standard_Boolean Initialisation = Standard_True; - -#define StructureManager_MAX 100 - -//static int StructureManager_ArrayId[StructureManager_MAX]; - -//static Standard_Integer StructureManager_CurrentId = 0; - -#endif diff --git a/src/OpenGl/OpenGl_Light.hxx b/src/OpenGl/OpenGl_Light.hxx index 99319d883e..d1c0c36a3d 100644 --- a/src/OpenGl/OpenGl_Light.hxx +++ b/src/OpenGl/OpenGl_Light.hxx @@ -24,20 +24,4 @@ typedef Graphic3d_CLight OpenGl_Light; typedef Graphic3d_ListOfCLight OpenGl_ListOfLight; -static inline OpenGl_ListOfLight& OpenGl_NoShadingLight() -{ - static OpenGl_ListOfLight aLights; - if (aLights.IsEmpty()) - { - OpenGl_Light aLight; - aLight.Type = Graphic3d_TOLS_AMBIENT; - aLight.IsHeadlight = Standard_False; - aLight.Color.r() = 1.; - aLight.Color.g() = 1.; - aLight.Color.b() = 1.; - aLights.Append (aLight); - } - return aLights; -} - #endif // OpenGl_Light_Header diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index 6ec36bb84a..7d2b9b6952 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -104,6 +104,14 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr, if (sscanf (anAaEnv, "%d", &v) > 0) myAntiAliasing = v; } + OpenGl_Light aLight; + aLight.Type = Graphic3d_TOLS_AMBIENT; + aLight.IsHeadlight = Standard_False; + aLight.Color.r() = 1.; + aLight.Color.g() = 1.; + aLight.Color.b() = 1.; + myNoShadingLight.Append (aLight); + myCurrLightSourceState = myStateCounter->Increment(); myMainSceneFbos[0] = new OpenGl_FrameBuffer(); myMainSceneFbos[1] = new OpenGl_FrameBuffer(); diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index c255f42b2f..0b35e2ce35 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -565,6 +565,7 @@ protected: Handle(Graphic3d_TextureEnv) myTextureEnvData; Graphic3d_GraduatedTrihedron myGTrihedronData; + OpenGl_ListOfLight myNoShadingLight; OpenGl_ListOfLight myLights; OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 79094e312e..2b26fd1e4b 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -2068,7 +2068,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the myRaytraceGeometry.Ambient = BVH_Vec4f (0.0f, 0.0f, 0.0f, 0.0f); - OpenGl_ListOfLight::Iterator aLightIter (myShadingModel == Graphic3d_TOSM_NONE ? OpenGl_NoShadingLight() : myLights); + OpenGl_ListOfLight::Iterator aLightIter (myShadingModel == Graphic3d_TOSM_NONE ? myNoShadingLight : myLights); for (; aLightIter.More(); aLightIter.Next()) { const OpenGl_Light& aLight = aLightIter.Value(); diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index ae8fc975c7..64852d14db 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -783,7 +783,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, const Handle(OpenGl_ShaderManager)& aManager = aContext->ShaderManager(); if (StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()) != myLastLightSourceState) { - aManager->UpdateLightSourceStateTo (myShadingModel == Graphic3d_TOSM_NONE ? &OpenGl_NoShadingLight() : &myLights); + aManager->UpdateLightSourceStateTo (myShadingModel == Graphic3d_TOSM_NONE ? &myNoShadingLight : &myLights); myLastLightSourceState = StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()); } @@ -1270,7 +1270,7 @@ void OpenGl_View::renderScene (Graphic3d_Camera::Projection theProjection, THE_DEFAULT_AMBIENT[3]); GLenum aLightGlId = GL_LIGHT0; - OpenGl_ListOfLight::Iterator aLightIt (myShadingModel == Graphic3d_TOSM_NONE ? OpenGl_NoShadingLight() : myLights); + OpenGl_ListOfLight::Iterator aLightIt (myShadingModel == Graphic3d_TOSM_NONE ? myNoShadingLight : myLights); for (; aLightIt.More(); aLightIt.Next()) { bindLight (aLightIt.Value(), aLightGlId, anAmbientColor, myWorkspace); diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index f8deec61fe..b98d3cefca 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -212,17 +212,16 @@ void PrsMgr_PresentableObject::ToBeUpdated(TColStd_ListOfInteger& OutList) const { OutList.Clear(); // on dimensionne les buckets a la taille de la seq. - static TColStd_MapOfInteger MI(myPresentations.Length()); + TColStd_MapOfInteger MI(myPresentations.Length()); for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){ const PrsMgr_ModedPresentation& MP = myPresentations(IP); if(MP.Presentation()->MustBeUpdated()) if(!MI.Contains(MP.Mode())){ - OutList.Append(MP.Mode()); - MI.Add(MP.Mode()); + OutList.Append(MP.Mode()); + MI.Add(MP.Mode()); } } - MI.Clear(); } //======================================================================= diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index bb6260d212..2cfcdb3577 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -183,7 +183,6 @@ void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean update) const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject ::Selection(const Standard_Integer aMode) const { - static Handle(SelectMgr_Selection) bidsel; Standard_Boolean Found = Standard_False; Standard_Integer Rank=0; for (Standard_Integer i=1;i<=myselections.Length() && !Found;i++) diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index dbc6a99f89..49a9860071 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -131,6 +131,7 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView th MyActiveLights(), myActiveLightsIterator(), SwitchSetFront (Standard_False), + myZRotation (Standard_False), MyTrsf (1, 4, 1, 4) { myView = theViewer->Driver()->CreateView (theViewer->StructureManager()); @@ -188,6 +189,7 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& MyActiveLights(), myActiveLightsIterator(), SwitchSetFront(Standard_False), + myZRotation (Standard_False), MyTrsf (1, 4, 1, 4) { myView = theViewer->Driver()->CreateView (theViewer->StructureManager()); @@ -2777,7 +2779,6 @@ void V3d_View::FitAll(const Handle(Aspect_Window)& aWindow, //function : StartRotation //purpose : //============================================================================= -static Standard_Boolean zRotation = Standard_False; void V3d_View::StartRotation(const Standard_Integer X, const Standard_Integer Y, const Quantity_Ratio zRotationThreshold) @@ -2789,13 +2790,13 @@ void V3d_View::StartRotation(const Standard_Integer X, ry = Standard_Real(Convert(y)); Gravity(gx,gy,gz); Rotate(0.,0.,0.,gx,gy,gz,Standard_True); - zRotation = Standard_False; + myZRotation = Standard_False; if( zRotationThreshold > 0. ) { Standard_Real dx = Abs(sx - rx/2.); Standard_Real dy = Abs(sy - ry/2.); - // if( dx > rx/3. || dy > ry/3. ) zRotation = Standard_True; + // if( dx > rx/3. || dy > ry/3. ) myZRotation = Standard_True; Standard_Real dd = zRotationThreshold * (rx + ry)/2.; - if( dx > dd || dy > dd ) zRotation = Standard_True; + if( dx > dd || dy > dd ) myZRotation = Standard_True; } } @@ -2812,7 +2813,7 @@ void V3d_View::Rotation(const Standard_Integer X, return; } Standard_Real dx=0.,dy=0.,dz=0.; - if( zRotation ) { + if( myZRotation ) { dz = atan2(Standard_Real(X)-rx/2., ry/2.-Standard_Real(Y)) - atan2(sx-rx/2.,ry/2.-sy); } else { diff --git a/src/V3d/V3d_View.hxx b/src/V3d/V3d_View.hxx index e9bdcf3cff..5e93f929f6 100644 --- a/src/V3d/V3d_View.hxx +++ b/src/V3d/V3d_View.hxx @@ -1092,6 +1092,7 @@ private: Standard_Real gz; Standard_Boolean myComputedMode; Standard_Boolean SwitchSetFront; + Standard_Boolean myZRotation; Standard_Integer MyZoomAtPointX; Standard_Integer MyZoomAtPointY; Handle(Aspect_Grid) MyGrid; diff --git a/src/V3d/V3d_Viewer_3.cxx b/src/V3d/V3d_Viewer_3.cxx index f7f661f65f..2a5ca486eb 100644 --- a/src/V3d/V3d_Viewer_3.cxx +++ b/src/V3d/V3d_Viewer_3.cxx @@ -50,28 +50,6 @@ #include #include -/*----------------------------------------------------------------------*/ -/* - * Static variable - */ -static TCollection_AsciiString _XLetter() { - static TCollection_AsciiString XLetter("X"); -return XLetter; -} -#define XLetter _XLetter() - -static TCollection_AsciiString _YLetter() { - static TCollection_AsciiString YLetter("Y"); -return YLetter; -} -#define YLetter _YLetter() - -static TCollection_AsciiString _ZLetter() { - static TCollection_AsciiString ZLetter("Z"); -return ZLetter; -} -#define ZLetter _ZLetter() - /*----------------------------------------------------------------------*/ void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) @@ -127,17 +105,17 @@ void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quan const gp_Pnt pX(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.XDirection().XYZ()); aPrims->AddVertex(p0); aPrims->AddVertex(pX); - Group->Text(XLetter.ToCString(),Graphic3d_Vertex(pX.X(),pX.Y(),pX.Z()),1./81.); + Group->Text("X",Graphic3d_Vertex(pX.X(),pX.Y(),pX.Z()),1./81.); const gp_Pnt pY(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.YDirection().XYZ()); aPrims->AddVertex(p0); aPrims->AddVertex(pY); - Group->Text(YLetter.ToCString(),Graphic3d_Vertex(pY.X(),pY.Y(),pY.Z()),1./81.); + Group->Text("Y",Graphic3d_Vertex(pY.X(),pY.Y(),pY.Z()),1./81.); const gp_Pnt pZ(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.Direction().XYZ()); aPrims->AddVertex(p0); aPrims->AddVertex(pZ); - Group->Text(ZLetter.ToCString(),Graphic3d_Vertex(pZ.X(),pZ.Y(),pZ.Z()),1./81.); + Group->Text("Z",Graphic3d_Vertex(pZ.X(),pZ.Y(),pZ.Z()),1./81.); Group->AddPrimitiveArray(aPrims);