- 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.
#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)
}
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());
-}
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 };
return (CButton*)GetDlgItem (IDC_ChooseEdgeBtn);
}
-#include <AIS_Selection.hxx>
//=======================================================================
//function : OnBnClickedChooseEdgeBtn
//purpose :
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();
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();
}
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();
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();
}
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());
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 &&
#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>
//#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;
}
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),
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...
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 :
}
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;
}
}
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)
}
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();
}
//=======================================================================
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();
}
}
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);
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())
{
#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;
class TCollection_ExtendedString;
class Prs3d_LineAspect;
class Prs3d_BasicAspect;
-class TopoDS_Shape;
class SelectMgr_EntityOwner;
class Standard_Transient;
class SelectMgr_Filter;
//! 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
//! 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;
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;
Standard_Boolean myToHilightSelected;
Handle(SelectMgr_OrFilter) myFilters;
Handle(Prs3d_Drawer) myDefaultDrawer;
+ Handle(AIS_Selection) mySelection;
Quantity_NameOfColor myDefaultColor;
Quantity_NameOfColor myHilightColor;
Quantity_NameOfColor mySelectionColor;
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;}
#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>
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
+namespace
+{
+ TopoDS_Shape AIS_myDummyShape;
+}
+
//=======================================================================
//function : highlightWithColor
//purpose :
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);
//=======================================================================
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;
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 :
}
aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
for (aSelector->Init(); aSelector->More(); aSelector->Next())
{
if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
continue;
- AIS_Selection::Select (aCurOwner);
+ mySelection->Select (aCurOwner);
aCurOwner->State (1);
}
}
aSelector->Pick (thePolyline, theView);
- AIS_Selection::SetCurrentSelection (myCurrentName.ToCString());
for (aSelector->Init(); aSelector->More(); aSelector->Next())
{
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
anOwner->State (1);
}
{
unhighlightSelected (Standard_True);
- AIS_Selection::Select();
+ mySelection->Select();
if (toUpdateViewer && myWasLastMain)
{
UpdateCurrentViewer();
}
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);
}
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);
}
// 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 =
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 =
unhighlightSelected();
- AIS_Selection::Select();
+ mySelection->Select();
myMainPM->ClearImmediateDraw();
if (theToUpdateViewer)
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;
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())
{
unhighlightSelected();
- AIS_Selection::ClearAndSelect (theOwner);
+ mySelection->ClearAndSelect (theOwner);
theOwner->State (1);
Quantity_NameOfColor aCustomColor;
Standard_Boolean isCustomColorSet;
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);
return;
}
- AIS_Selection::Selection (myCurrentName.ToCString())->Init();
+ mySelection->Init();
}
//=======================================================================
if (HasOpenedContext())
return myLocalContexts (myCurLocalIndex)->MoreSelected();
- return AIS_Selection::Selection (myCurrentName.ToCString())->More();
+ return mySelection->More();
}
//=======================================================================
return;
}
- AIS_Selection::Selection (myCurrentName.ToCString())->Next();
+ mySelection->Next();
}
//=======================================================================
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();
}
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;
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;
}
//=======================================================================
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();
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){
#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>
#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 :
myFilters(new SelectMgr_OrFilter()),
myAutoHilight(Standard_True),
myMapOfOwner (new SelectMgr_IndexedMapOfOwner()),
+mySelection(new AIS_Selection()),
mylastindex(0),
mylastgood(0),
myCurDetected(0),
myMainVS->ResetSelectionActivationStatus();
myMainPM = aCtx->MainPrsMgr();
- mySelName = AIS_Local_SelName(this, Index);
- AIS_Selection::CreateSelection(mySelName.ToCString());
mySM->Add(myMainVS);
if(myLoadDisplayed) LoadContextObjects();
// 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);
#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;
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);
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);
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;
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;
#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;}
#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;
}
}
+//=======================================================================
+//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 :
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);
if (!anOwner->IsSelected()) // anOwner is not selected
{
anOwner->SetSelected (Standard_True);
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
}
if (myAutoHilight)
}
}
- return (AIS_Selection::Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected;
+ return (mySelection->Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected;
}
//=======================================================================
UnhilightPicked (Standard_False);
}
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
myMainVS->Init();
if (!myMainVS->More())
if (!anOwner->IsSelected())
{
anOwner->SetSelected (Standard_True);
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
}
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
{
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())
{
// it can be helpful to classify this owner immediately...
if (!anOwner->IsSelected())
{
- AIS_Selection::AddSelect (anOwner);
+ mySelection->AddSelect (anOwner);
anOwner->SetSelected (Standard_True);
}
}
}
}
- 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;
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)
}
}
- 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;
{
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())
if(myFilters->IsOk (anOwner))
{
Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
anOwner->SetSelected (toSelect);
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
{
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())
{
if (myFilters->IsOk (anOwner))
{
Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
anOwner->SetSelected (toSelect);
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
//=======================================================================
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;
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())
{
{
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();
void AIS_LocalContext::
InitSelected()
{
- AIS_Selection::SetCurrentSelection(mySelName.ToCString());
- AIS_Selection::CurrentSelection()->Init();
+ mySelection->Init();
}
//==================================================
Standard_Boolean AIS_LocalContext::
MoreSelected() const
{
- return AIS_Selection::CurrentSelection()->More();
+ return mySelection->More();
}
//==================================================
void AIS_LocalContext::
NextSelected()
{
- AIS_Selection::CurrentSelection()->Next();
+ mySelection->Next();
}
//==================================================
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);
//================================================================
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;
//==================================================
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() )
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;
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;
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 );
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();
(*((const Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False);
}
}
- AIS_Selection::Select();
+ mySelection->Select();
mylastindex = 0;
}
// 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())
{
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
//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()){
ClearSelected(Standard_False);
- AIS_Selection::Select(EO);
+ mySelection->Select(EO);
EO->SetSelected (Standard_True);
HilightPicked(updateviewer);
EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
}
}
-
-// 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);
}
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);
Standard_Boolean toSelect = theOwner->IsSelected() ? Standard_False : Standard_True;
- AIS_Selection::Selection (mySelName.ToCString())->Select (theOwner);
+ mySelection->Select(theOwner);
theOwner->SetSelected (toSelect);
if(myAutoHilight)
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;
}
//=======================================================================
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;
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();
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
//=======================================================================
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();
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);
#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
// 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;
}
}
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;
}
//=======================================================================
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;
}
//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);
-
}
//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();
}
//=======================================================================
//=======================================================================
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();
-}
#include <Standard.hxx>
#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
#include <AIS_NListTransient.hxx>
#include <AIS_NListIteratorOfListTransient.hxx>
#include <AIS_NDataMapOfTransientIteratorOfListTransient.hxx>
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);
-
- Standard_EXPORT static void Remove (const Standard_CString aName);
-
- //! 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 <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();
+ //! creates a new selection.
+
+ Standard_EXPORT AIS_Selection();
- //! removes all the object of the currentselection.
- Standard_EXPORT static void Select();
+ //! removes all the object of the selection.
+ Standard_EXPORT 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)
private:
-
- TCollection_AsciiString myName;
AIS_NListTransient myresult;
AIS_NListIteratorOfListTransient myIterator;
AIS_NDataMapOfTransientIteratorOfListTransient myResultMap;
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);
myInitAng(0.)
{
Set (shap);
- myFirstCompute = Standard_True;
SetHilightMode(0);
myDrawer->SetShadingAspectGlobal(Standard_False);
}
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
Graphic3d_StructureDefinitionError.hxx
Graphic3d_StructureManager.cxx
Graphic3d_StructureManager.hxx
-Graphic3d_StructureManager.pxx
Graphic3d_StructureManagerPtr.hxx
Graphic3d_StructurePtr.hxx
Graphic3d_TextPath.hxx
#include "Graphic3d_Structure.pxx"
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransModeFlags.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
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),
Is2dText (Standard_False),
myGraphicDriver (theManager->GraphicDriver())
{
+ Id = myGraphicDriver->NewIdentification();
+
ContextLine.IsDef = 1,
ContextFillArea.IsDef = 1,
ContextMarker.IsDef = 1,
{
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
#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>
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:
Handle(Aspect_DisplayConnection) myDisplayConnection;
Standard_Boolean myDeviceLostFlag;
+ Aspect_GenId myStructGenId;
+
private:
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
// 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);
- }
}
//=============================================================================
#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
#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)
{
+ 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<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 ();
- myAspectFillArea3d = new Graphic3d_AspectFillArea3d ();
-
- myUpdateMode = Aspect_TOU_WAIT;
- myGraphicDriver = theDriver;
+ myUpdateMode = Aspect_TOU_WAIT;
+ myGraphicDriver = theDriver;
}
Graphic3d_StructureManager::~Graphic3d_StructureManager ()
{
- myDisplayedStructure.Clear ();
- myHighlightedStructure.Clear ();
- myDefinedViews.Clear();
- StructureManager_ArrayId[myId] = 0;
+ myDisplayedStructure.Clear ();
+ myHighlightedStructure.Clear ();
+ myDefinedViews.Clear();
}
}
-void Graphic3d_StructureManager::Remove (const Standard_Integer theId) {
-
- myStructGenId.Free (theId);
-
-}
-
void Graphic3d_StructureManager::DisplayedStructures (Graphic3d_MapOfStructure& SG) const {
SG.Assign(myDisplayedStructure);
}
-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;
}
-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 {
-
- return (myGraphicDriver);
-
+const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver () const
+{
+ return (myGraphicDriver);
}
void Graphic3d_StructureManager::RecomputeStructures()
//! 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;
//! 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);
//! 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);
//! 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;
+++ /dev/null
-// 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
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
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();
Handle(Graphic3d_TextureEnv) myTextureEnvData;
Graphic3d_GraduatedTrihedron myGTrihedronData;
+ OpenGl_ListOfLight myNoShadingLight;
OpenGl_ListOfLight myLights;
OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers
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();
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());
}
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);
{
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();
}
//=======================================================================
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++)
MyActiveLights(),
myActiveLightsIterator(),
SwitchSetFront (Standard_False),
+ myZRotation (Standard_False),
MyTrsf (1, 4, 1, 4)
{
myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
MyActiveLights(),
myActiveLightsIterator(),
SwitchSetFront(Standard_False),
+ myZRotation (Standard_False),
MyTrsf (1, 4, 1, 4)
{
myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
//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)
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;
}
}
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 {
Standard_Real gz;
Standard_Boolean myComputedMode;
Standard_Boolean SwitchSetFront;
+ Standard_Boolean myZRotation;
Standard_Integer MyZoomAtPointX;
Standard_Integer MyZoomAtPointY;
Handle(Aspect_Grid) MyGrid;
#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)
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);