1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-30 12:14:08 +03:00

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.
This commit is contained in:
mpa 2016-04-08 09:47:47 +03:00 committed by bugmaster
parent 83da37b115
commit 016e595986
39 changed files with 313 additions and 778 deletions

View File

@ -11,11 +11,9 @@
#include "RadiusParamsPage.h"
#include "ParamsFacesPage.h"
#include <Standard_Macro.hxx>
#include <AIS_InteractiveContext.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <AIS_LocalContext.hxx>
#include <AIS_Selection.hxx>
#include <Quantity_Color.hxx>
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());
}

View File

@ -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 };

View File

@ -60,7 +60,6 @@ CButton* CLengthParamsEdgePage::GetButton()
return (CButton*)GetDlgItem (IDC_ChooseEdgeBtn);
}
#include <AIS_Selection.hxx>
//=======================================================================
//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();

View File

@ -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();

View File

@ -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());

View File

@ -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 &&

View File

@ -27,7 +27,6 @@
#include <AIS_LocalStatus.hxx>
#include <AIS_MapIteratorOfMapOfInteractive.hxx>
#include <AIS_MultipleConnectedInteractive.hxx>
#include <AIS_Selection.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Trihedron.hxx>
#include <Geom_Axis2Placement.hxx>
@ -67,21 +66,6 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext,MMgt_TShared)
//#include <AIS_DataMapIteratorOfDataMapOfInteractiveInteger.hxx>
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<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners;
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::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),
@ -118,20 +103,8 @@ myIsAutoActivateSelMode( Standard_True )
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())
{

View File

@ -49,6 +49,7 @@
#include <SelectMgr_ListOfFilter.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <Standard_CString.hxx>
#include <AIS_Selection.hxx>
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;

View File

@ -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;}

View File

@ -44,7 +44,6 @@
#include <TCollection_ExtendedString.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Shape.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_Light.hxx>
@ -55,6 +54,11 @@
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > 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<Handle(AIS_InteractiveObject)> 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();

View File

@ -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){

View File

@ -23,7 +23,6 @@
#include <AIS_ListOfInteractive.hxx>
#include <AIS_LocalContext.hxx>
#include <AIS_LocalStatus.hxx>
#include <AIS_Selection.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Graphic3d_Structure.hxx>
@ -51,17 +50,6 @@
#include <stdio.h>
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);

View File

@ -40,6 +40,7 @@
#include <TColStd_MapOfTransient.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Standard_Real.hxx>
#include <AIS_Selection.hxx>
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;

View File

@ -18,9 +18,8 @@
#include <SelectMgr_OrFilter.hxx>
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;}

View File

@ -50,9 +50,13 @@
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <TopoDS_Shape.hxx>
#include <V3d_View.hxx>
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,8 +524,7 @@ 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 <Handle(SelectMgr_SelectableObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > SelectMgr_DataMapOfObjectOwners;
SelectMgr_DataMapOfObjectOwners aMap;
@ -525,7 +532,7 @@ void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
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<Handle(SelectMgr_SelectableObject)> 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 <anIObj> 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);
@ -1103,12 +1100,9 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)&
}
}
// cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<<mySelName<<endl;
const Handle(AIS_Selection)& S = AIS_Selection::Selection(mySelName.ToCString());
if (!S.IsNull())
if (!mySelection.IsNull())
{
AIS_SelectStatus aStatus = S->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 "
<<mySelName<<" Nulle "<<endl;
@ -1455,7 +1447,7 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO
return EO;
}
Standard_Boolean found(Standard_False);
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();
@ -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 "<<mySelName<<" Nulle "<<endl;
#endif
@ -1546,13 +1537,11 @@ void AIS_LocalContext::NextDetected()
//=======================================================================
const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const
{
static TopoDS_Shape aDummyShape;
Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
if (aCurrentShape.IsNull())
{
return aDummyShape;
return AIS_myDummyShape;
}
return aCurrentShape->Shape();

View File

@ -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);

View File

@ -21,147 +21,50 @@
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <Standard_TypeMismatch.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfTransient.hxx>
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 <myresult> 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();
}

View File

@ -20,7 +20,6 @@
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <AIS_NListTransient.hxx>
#include <AIS_NListIteratorOfListTransient.hxx>
#include <AIS_NDataMapOfTransientIteratorOfListTransient.hxx>
@ -45,63 +44,33 @@ 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 static void Remove (const Standard_CString aName);
Standard_EXPORT AIS_Selection();
//! returns True if a selection having this name exsits.
Standard_EXPORT static Standard_Boolean Find (const Standard_CString aName);
//! removes all the object of the selection.
Standard_EXPORT void Select();
//! 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 <aName>
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 void ClearAndSelect (const Handle(Standard_Transient)& anObject);
Standard_EXPORT static Standard_Boolean IsSelected (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();
@ -115,11 +84,6 @@ public:
const AIS_NListTransient& Objects() const;
Standard_EXPORT static Standard_Integer Index (const Standard_CString aName);
DEFINE_STANDARD_RTTIEXT(AIS_Selection,MMgt_TShared)
protected:
@ -129,8 +93,6 @@ protected:
private:
TCollection_AsciiString myName;
AIS_NListTransient myresult;
AIS_NListIteratorOfListTransient myIterator;
AIS_NDataMapOfTransientIteratorOfListTransient myResultMap;

View File

@ -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

View File

@ -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

View File

@ -17,6 +17,7 @@
#include "Graphic3d_Structure.pxx"
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransModeFlags.hxx>
#include <Graphic3d_GraphicDriver.hxx>
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,

View File

@ -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);
}

View File

@ -40,6 +40,7 @@
#include <Standard_Address.hxx>
#include <Image_PixMap.hxx>
#include <Graphic3d_BufferType.hxx>
#include <Aspect_GenId.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Graphic3d_ExportFormat.hxx>
@ -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:

View File

@ -1009,7 +1009,9 @@ typedef struct _Material
Graphic3d_TypeOfMaterial type;
} Material;
static Material theMaterials[] =
namespace
{
static const Material theMaterials[] =
{
{"Brass", Graphic3d_MATERIAL_PHYSIC},
{"Bronze", Graphic3d_MATERIAL_PHYSIC},
@ -1036,6 +1038,7 @@ static Material theMaterials[] =
{"Diamond", Graphic3d_MATERIAL_PHYSIC}
};
}
// =======================================================================
// function : NumberOfMaterials

View File

@ -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);
}
}
//=============================================================================

View File

@ -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

View File

@ -30,65 +30,17 @@
#include <Graphic3d_InitialisationError.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_StructureManager.hxx>
#include "Graphic3d_StructureManager.pxx"
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
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 <Graphic3d_MapIteratorOfMapOfStructure.hxx>
#include <Graphic3d_CView.hxx>
Graphic3d_StructureManager::Graphic3d_StructureManager (const Handle(Graphic3d_GraphicDriver)& theDriver)
: myViewGenId (0, 31)
{
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<Limit; i++) StructureManager_ArrayId[i] = 0;
StructureManager_CurrentId = 0;
StructureManager_ArrayId[0] = 1;
}
else {
for (i=0; i<Limit && NotFound; i++)
if (StructureManager_ArrayId[i] == 0) {
NotFound = Standard_False;
StructureManager_CurrentId = i;
StructureManager_ArrayId[i] = 1;
}
if (NotFound)
{
Standard_SStream anErrorDescription;
anErrorDescription<<"You are trying to create too many ViewManagers at the same time!\n"<<
"The number of simultaneously created ViewManagers can't exceed "<<Limit<<".\n";
Graphic3d_InitialisationError::Raise(anErrorDescription);
}
}
Coef = (Structure_IDMIN+Structure_IDMAX)/Limit;
Aspect_GenId theGenId(
Standard_Integer (Structure_IDMIN+Coef*(StructureManager_CurrentId)),
Standard_Integer (Structure_IDMIN+Coef*(StructureManager_CurrentId+1)-1));
myStructGenId = theGenId;
myId = StructureManager_CurrentId;
myAspectLine3d = new Graphic3d_AspectLine3d ();
myAspectText3d = new Graphic3d_AspectText3d ();
myAspectMarker3d = new Graphic3d_AspectMarker3d ();
@ -106,7 +58,6 @@ Graphic3d_StructureManager::~Graphic3d_StructureManager ()
myDisplayedStructure.Clear ();
myHighlightedStructure.Clear ();
myDefinedViews.Clear();
StructureManager_ArrayId[myId] = 0;
}
@ -227,12 +178,6 @@ Handle(Graphic3d_AspectFillArea3d) Graphic3d_StructureManager::FillArea3dAspect
}
void Graphic3d_StructureManager::Remove (const Standard_Integer theId) {
myStructGenId.Free (theId);
}
void Graphic3d_StructureManager::DisplayedStructures (Graphic3d_MapOfStructure& SG) const {
SG.Assign(myDisplayedStructure);
@ -264,14 +209,6 @@ void Graphic3d_StructureManager::HighlightedStructures (Graphic3d_MapOfStructure
}
Standard_Integer Graphic3d_StructureManager::NewIdentification () {
Standard_Integer Id = myStructGenId.Next ();
return Id;
}
Handle(Graphic3d_Structure) Graphic3d_StructureManager::Identification (const Standard_Integer AId) const {
// Standard_Integer ind=0;
@ -299,28 +236,9 @@ Handle(Graphic3d_Structure) Graphic3d_StructureManager::Identification (const St
}
Standard_Integer Graphic3d_StructureManager::Identification () const {
return (myId);
}
Standard_Integer Graphic3d_StructureManager::Limit () {
return (StructureManager_MAX);
}
Standard_Integer Graphic3d_StructureManager::CurrentId () {
return (StructureManager_CurrentId);
}
const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver () const {
const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver () const
{
return (myGraphicDriver);
}
void Graphic3d_StructureManager::RecomputeStructures()

View File

@ -129,9 +129,6 @@ public:
//! Returns the values of the current default attributes.
Standard_EXPORT Handle(Graphic3d_AspectFillArea3d) FillArea3dAspect() const;
//! Returns maximum number of managers defineable.
Standard_EXPORT static Standard_Integer Limit();
//! Returns the values of the current default attributes.
Standard_EXPORT Handle(Graphic3d_AspectLine3d) Line3dAspect() const;
@ -144,9 +141,6 @@ public:
//! Returns the values of the current default attributes.
Standard_EXPORT Handle(Graphic3d_AspectText3d) Text3dAspect() const;
//! Returns a current identifier available.
Standard_EXPORT static Standard_Integer CurrentId();
//! Forces a new construction of the structure.
//! if <theStructure> 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 <AId>.
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 <AStructure>.
Standard_EXPORT virtual void UnHighlight (const Handle(Graphic3d_Structure)& AStructure);
@ -237,15 +225,7 @@ protected:
//! Returns the structure displayed in visualizer <me>.
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;

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -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);

View File

@ -212,7 +212,7 @@ 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);
@ -222,7 +222,6 @@ void PrsMgr_PresentableObject::ToBeUpdated(TColStd_ListOfInteger& OutList) const
MI.Add(MP.Mode());
}
}
MI.Clear();
}
//=======================================================================

View File

@ -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++)

View File

@ -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 {

View File

@ -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;

View File

@ -50,28 +50,6 @@
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
/*----------------------------------------------------------------------*/
/*
* 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);