mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0029470: Samples - eliminate references to deprecated Local Context from MFC sample
AIS_InteractiveContext::MoveTo(), ::Select(), ::ShiftSelect() now throw an exception on invalid V3d_View argument instead of returning empty results. AIS_InteractiveContext::DetectedShape() and ::BeginImmediateDraw() now can be called without opened Local Context. Draw Harness - removed unused commands vsetam, vunsetam. Removed unused methods ViewerTest::StandardModeActivation(), ::PickObject(), PickObjects(). Interactive input of Selection modes 0..7 now redirects to vselmode instead of removed ViewerTest::StandardModeActivation().
This commit is contained in:
parent
d9ca2e0cb1
commit
8c088c52fc
@ -73,7 +73,6 @@
|
||||
#include <AIS_Line.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_TextLabel.hxx>
|
||||
|
||||
#include <Aspect_TypeOfline.hxx>
|
||||
|
@ -3,7 +3,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include "OCC_2dDoc.h"
|
||||
|
||||
|
@ -681,55 +681,55 @@ void CViewer3dDoc::Popup (const Standard_Integer x,
|
||||
//Set faces selection mode
|
||||
void CViewer3dDoc::OnFaces()
|
||||
{
|
||||
myAISContext->Deactivate();
|
||||
myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_FACE));
|
||||
|
||||
myCResultDialog.SetTitle("Standard mode: TopAbs_FACE");
|
||||
myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
|
||||
" \n"
|
||||
" myAISContext->ActivateStandardMode(TopAbs_FACE); \n"
|
||||
" \n");
|
||||
myCResultDialog.SetText(" myAISContext->Deactivate();\n"
|
||||
" myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_FACE));\n\n");
|
||||
SetTitle (L"Standard mode: TopAbs_FACE");
|
||||
}
|
||||
|
||||
//Set edges selection mode
|
||||
void CViewer3dDoc::OnEdges()
|
||||
{
|
||||
myAISContext->Deactivate();
|
||||
myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));
|
||||
|
||||
myCResultDialog.SetTitle("Standard mode: TopAbs_EDGE");
|
||||
myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
|
||||
" \n"
|
||||
" myAISContext->ActivateStandardMode(TopAbs_EDGE); \n"
|
||||
" \n");
|
||||
myCResultDialog.SetText(" myAISContext->Deactivate();\n"
|
||||
" myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));\n\n");
|
||||
SetTitle (L"Standard mode: TopAbs_EDGE");
|
||||
}
|
||||
|
||||
// Set vertices selection mode
|
||||
void CViewer3dDoc::OnVertices()
|
||||
{
|
||||
myAISContext->Deactivate();
|
||||
myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));
|
||||
|
||||
myCResultDialog.SetTitle("Standard mode: TopAbs_VERTEX");
|
||||
myCResultDialog.SetText(" myAISContext->OpenLocalContext(); \n"
|
||||
" \n"
|
||||
" myAISContext->ActivateStandardMode(TopAbs_VERTEX); \n"
|
||||
" \n");
|
||||
myCResultDialog.SetText(" myAISContext->Deactivate();\n"
|
||||
" myAISContext->Activate (AIS_Shape::SelectionMode (TopAbs_VERTEX));\n\n");
|
||||
SetTitle (L"Standard mode: TopAbs_VERTEX");
|
||||
}
|
||||
|
||||
//Neutral selection mode
|
||||
void CViewer3dDoc::OnNeutral()
|
||||
{
|
||||
myAISContext->Deactivate();
|
||||
myAISContext->Activate (0);
|
||||
|
||||
myCResultDialog.SetTitle("Standard mode: Neutral");
|
||||
myCResultDialog.SetText(" myAISContext->CloseAllContexts(); \n"
|
||||
" \n");
|
||||
myCResultDialog.SetText(" myAISContext->Deactivate();\n"
|
||||
" myAISContext->Activate (0);\n\n");
|
||||
SetTitle (L"Standard mode: Neutral");
|
||||
}
|
||||
|
||||
// Change the color of faces on a user cylinder
|
||||
void CViewer3dDoc::OnUsercylinderChangefacecolor()
|
||||
{
|
||||
myAISContext->Activate(myAISContext->SelectedInteractive(), 4);
|
||||
myAISContext->Activate (myAISContext->SelectedInteractive(), AIS_Shape::SelectionMode (TopAbs_FACE));
|
||||
myState = FACE_COLOR;
|
||||
// see the following of treatment in inputevent
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "DimensionDlg.h"
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
#include <AIS_AngleDimension.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDimensionDlg, CDialog)
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
#include <GC_MakePlane.hxx>
|
||||
#include <TopExp.hxx>
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "LengthParamsEdgesPage.h"
|
||||
#include "DimensionDlg.h"
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
#include <AIS_AngleDimension.hxx>
|
||||
#include <GC_MakePlane.hxx>
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "DimensionDlg.h"
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
#include <GC_MakePlane.hxx>
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <res\OCC_Resource.h>
|
||||
#include "ImportExport/ImportExport.h"
|
||||
#include "AISDialogs.h"
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "DimensionDlg.h"
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <AIS_RadiusDimension.hxx>
|
||||
#include <AIS_DiameterDimension.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
207
src/AIS/AIS.hxx
207
src/AIS/AIS.hxx
@ -46,8 +46,6 @@ class Prs3d_Presentation;
|
||||
class AIS_Triangulation;
|
||||
class AIS_InteractiveContext;
|
||||
class AIS_GraphicTool;
|
||||
class AIS_LocalContext;
|
||||
class AIS_LocalStatus;
|
||||
class AIS_GlobalStatus;
|
||||
class AIS_InteractiveObject;
|
||||
class AIS_Point;
|
||||
@ -87,112 +85,52 @@ class AIS_BadEdgeFilter;
|
||||
class AIS_Selection;
|
||||
|
||||
|
||||
//! Application Interactive Services provide the means to
|
||||
//! create links between an application GUI viewer and
|
||||
//! the packages which are used to manage selection
|
||||
//! and presentation. The tools AIS defined in order to
|
||||
//! do this include different sorts of entities: both the
|
||||
//! selectable viewable objects themselves and the
|
||||
//! context and attribute managers to define their
|
||||
//! selection and display.
|
||||
//! To orient the user as he works in a modeling
|
||||
//! environment, views and selections must be
|
||||
//! comprehensible. There must be several different sorts
|
||||
//! of selectable and viewable object defined. These must
|
||||
//! also be interactive, that is, connecting graphic
|
||||
//! representation and the underlying reference
|
||||
//! geometry. These entities are called Interactive
|
||||
//! Objects, and are divided into four types:
|
||||
//! Application Interactive Services provide the means to create links between an application GUI viewer and
|
||||
//! the packages which are used to manage selection and presentation.
|
||||
//! The tools AIS defined in order to do this include different sorts of entities:
|
||||
//! both the selectable viewable objects themselves and the context and attribute managers to define their selection and display.
|
||||
//! To orient the user as he works in a modeling environment, views and selections must be comprehensible.
|
||||
//! There must be several different sorts of selectable and viewable object defined.
|
||||
//! These must also be interactive, that is, connecting graphic representation and the underlying reference geometry.
|
||||
//! These entities are called Interactive Objects, and are divided into four types:
|
||||
//! - the Datum
|
||||
//! - the Relation
|
||||
//! - the Object
|
||||
//! - None.
|
||||
//! The Datum groups together the construction elements
|
||||
//! such as lines, circles, points, trihedra, plane trihedra,
|
||||
//! planes and axes.
|
||||
//! The Relation is made up of constraints on one or
|
||||
//! more interactive shapes and the corresponding
|
||||
//! reference geometry. For example, you might want to
|
||||
//! constrain two edges in a parallel relation. This
|
||||
//! contraint is considered as an object in its own right,
|
||||
//! and is shown as a sensitive primitive. This takes the
|
||||
//! graphic form of a perpendicular arrow marked with
|
||||
//! the || symbol and lying between the two edges.
|
||||
//! The Object type includes topological shapes, and
|
||||
//! connections between shapes.
|
||||
//! None, in order not to eliminate the object, tells the
|
||||
//! application to look further until it finds an object
|
||||
//! definition in its generation which is accepted.
|
||||
//! Inside these categories, you have the possibility
|
||||
//! of an additional characterization by means of a
|
||||
//! signature. The signature provides an index to the
|
||||
//! further characterization. By default, the Interactive
|
||||
//! Object has a None type and a signature of 0
|
||||
//! (equivalent to None.) If you want to give a particular
|
||||
//! type and signature to your interactive object, you must
|
||||
//! redefine the two virtual methods: Type and Signature.
|
||||
//! In the C++ inheritance structure of the package, each
|
||||
//! class representing a specific Interactive Object
|
||||
//! inherits AIS_InteractiveObject. Among these
|
||||
//! inheriting classes, AIS_Relation functions as the
|
||||
//! abstract mother class for tinheriting classes defining
|
||||
//! display of specific relational constraints and types of
|
||||
//! dimension. Some of these include:
|
||||
//! - display of constraints based on relations of
|
||||
//! symmetry, tangency, parallelism and concentricity
|
||||
//! - display of dimensions for angles, offsets,
|
||||
//! diameters, radii and chamfers.
|
||||
//! No viewer can show everything at once with any
|
||||
//! coherence or clarity. Views must be managed
|
||||
//! carefully both sequentially and at any given instant.
|
||||
//! Another function of the view is that of a context to
|
||||
//! carry out design in. The design changes are applied
|
||||
//! to the objects in the view and then extended to the
|
||||
//! underlying reference geometry by a solver. To make
|
||||
//! sense of this complicated visual data, several display
|
||||
//! and selection tools are required. To facilitate
|
||||
//! management, each object and each construction
|
||||
//! element has a selection priority. There are also
|
||||
//! means to modify the default priority.
|
||||
//! To define an environment of dynamic detection, you
|
||||
//! can use standard filter classes or create your own. A
|
||||
//! filter questions the owner of the sensitive primitive in
|
||||
//! local context to determine if it has the the desired
|
||||
//! qualities. If it answers positively, it is kept. If not, it is rejected.
|
||||
//! The Datum groups together the construction elements such as lines, circles, points, trihedra, plane trihedra, planes and axes.
|
||||
//! The Relation is made up of constraints on one or more interactive shapes and the corresponding reference geometry.
|
||||
//! For example, you might want to constrain two edges in a parallel relation.
|
||||
//! This contraint is considered as an object in its own right, and is shown as a sensitive primitive.
|
||||
//! This takes the graphic form of a perpendicular arrow marked with the || symbol and lying between the two edges.
|
||||
//! The Object type includes topological shapes, and connections between shapes.
|
||||
//! None, in order not to eliminate the object, tells the application to look further until it finds an object definition in its generation which is accepted.
|
||||
//! Inside these categories, you have the possibility of an additional characterization by means of a signature.
|
||||
//! The signature provides an index to the further characterization.
|
||||
//! By default, the Interactive Object has a None type and a signature of 0 (equivalent to None.)
|
||||
//! If you want to give a particular type and signature to your interactive object, you must redefine the two virtual methods: Type and Signature.
|
||||
//! In the C++ inheritance structure of the package, each class representing a specific Interactive Object inherits AIS_InteractiveObject.
|
||||
//! Among these inheriting classes, AIS_Relation functions as the abstract mother class for tinheriting classes defining display of specific relational constraints and types of dimension.
|
||||
//! Some of these include:
|
||||
//! - display of constraints based on relations of symmetry, tangency, parallelism and concentricity
|
||||
//! - display of dimensions for angles, offsets, diameters, radii and chamfers.
|
||||
//! No viewer can show everything at once with any coherence or clarity.
|
||||
//! Views must be managed carefully both sequentially and at any given instant.
|
||||
//! Another function of the view is that of a context to carry out design in.
|
||||
//! The design changes are applied to the objects in the view and then extended to the underlying reference geometry by a solver.
|
||||
//! To make sense of this complicated visual data, several display and selection tools are required.
|
||||
//! To facilitate management, each object and each construction element has a selection priority.
|
||||
//! There are also means to modify the default priority.
|
||||
//! To define an environment of dynamic detection, you can use standard filter classes or create your own.
|
||||
//! A filter questions the owner of the sensitive primitive to determine if it has the the desired qualities.
|
||||
//! If it answers positively, it is kept. If not, it is rejected.
|
||||
//! The standard filters supplied in AIS include:
|
||||
//! AIS_AttributeFilter
|
||||
//! AIS_SignatureFilter
|
||||
//! AIS_TypeFilter.
|
||||
//! Only the type filter can be used in the default
|
||||
//! operating mode, the neutral point. The others can
|
||||
//! only be used in open local contexts.
|
||||
//! Neutral point and local context constitute the two
|
||||
//! operating modes of the central entity which pilots
|
||||
//! visualizations and selections, the Interactive Context.
|
||||
//! It is linked to a main viewer and if you like, a trash bin
|
||||
//! viewer as well.
|
||||
//! The neutral point, which is the default mode, allows
|
||||
//! you to easily visualize and select interactive objects
|
||||
//! which have been loaded into the context. Opening
|
||||
//! local contexts allows you to prepare and use a
|
||||
//! temporary selection environment without disturbing
|
||||
//! the neutral point. A set of functions allows you to
|
||||
//! choose the interactive objects which you want to act
|
||||
//! on, the selection modes which you want to activate,
|
||||
//! and the temporary visualizations which you will
|
||||
//! execute. When the operation is finished, you close the
|
||||
//! current local context and return to the state in which
|
||||
//! you were before opening it (neutral point or previous
|
||||
//! local context).
|
||||
//! An interactive object can have a certain number of
|
||||
//! graphic attributes which are specific to it, such as
|
||||
//! visualization mode, color, and material. By the same
|
||||
//! token, the interactive context has a set of graphic
|
||||
//! attributes, the Drawer which is valid by default for the
|
||||
//! objects it controls. When an interactive object is
|
||||
//! visualized, the required graphic attributes are first
|
||||
//! taken from the object's own Drawer if one exists, or
|
||||
//! from the context drawer for the others.
|
||||
//! - AIS_AttributeFilter
|
||||
//! - AIS_SignatureFilter
|
||||
//! - AIS_TypeFilter.
|
||||
//! A set of functions allows you to choose the interactive objects which you want to act on, the selection modes which you want to activate.
|
||||
//! An interactive object can have a certain number of graphic attributes which are specific to it, such as visualization mode, color, and material.
|
||||
//! By the same token, the interactive context has a set of graphic attributes, the Drawer which is valid by default for the objects it controls.
|
||||
//! When an interactive object is visualized, the required graphic attributes are first taken from the object's own Drawer if one exists, or from the context drawer for the others.
|
||||
class AIS
|
||||
{
|
||||
public:
|
||||
@ -312,69 +250,6 @@ public:
|
||||
|
||||
Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
friend class AIS_Triangulation;
|
||||
friend class AIS_InteractiveContext;
|
||||
friend class AIS_GraphicTool;
|
||||
friend class AIS_LocalContext;
|
||||
friend class AIS_LocalStatus;
|
||||
friend class AIS_GlobalStatus;
|
||||
friend class AIS_InteractiveObject;
|
||||
friend class AIS_Point;
|
||||
friend class AIS_Axis;
|
||||
friend class AIS_Trihedron;
|
||||
friend class AIS_PlaneTrihedron;
|
||||
friend class AIS_Line;
|
||||
friend class AIS_Circle;
|
||||
friend class AIS_Plane;
|
||||
friend class AIS_Shape;
|
||||
friend class AIS_ConnectedInteractive;
|
||||
friend class AIS_MultipleConnectedInteractive;
|
||||
friend class AIS_DimensionOwner;
|
||||
friend class AIS_Relation;
|
||||
friend class AIS_EllipseRadiusDimension;
|
||||
friend class AIS_MaxRadiusDimension;
|
||||
friend class AIS_MinRadiusDimension;
|
||||
friend class AIS_Chamf2dDimension;
|
||||
friend class AIS_Chamf3dDimension;
|
||||
friend class AIS_OffsetDimension;
|
||||
friend class AIS_FixRelation;
|
||||
friend class AIS_PerpendicularRelation;
|
||||
friend class AIS_ParallelRelation;
|
||||
friend class AIS_TangentRelation;
|
||||
friend class AIS_ConcentricRelation;
|
||||
friend class AIS_IdenticRelation;
|
||||
friend class AIS_SymmetricRelation;
|
||||
friend class AIS_MidPointRelation;
|
||||
friend class AIS_EqualRadiusRelation;
|
||||
friend class AIS_EqualDistanceRelation;
|
||||
friend class AIS_TypeFilter;
|
||||
friend class AIS_SignatureFilter;
|
||||
friend class AIS_ExclusionFilter;
|
||||
friend class AIS_AttributeFilter;
|
||||
friend class AIS_C0RegularityFilter;
|
||||
friend class AIS_BadEdgeFilter;
|
||||
friend class AIS_Selection;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AIS_HeaderFile
|
||||
|
@ -122,6 +122,7 @@ myCurHighlighted(0),
|
||||
myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable),
|
||||
myIsAutoActivateSelMode(Standard_True)
|
||||
{
|
||||
mgrSelector->Add (myMainSel);
|
||||
myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer;
|
||||
myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer();
|
||||
myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer();
|
||||
@ -2694,7 +2695,6 @@ Standard_Boolean AIS_InteractiveContext::IsInLocal (const Handle(AIS_Interactive
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::InitAttributes()
|
||||
{
|
||||
mgrSelector->Add (myMainSel);
|
||||
|
||||
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS);
|
||||
myDefaultDrawer->ShadingAspect()->SetMaterial (aMat);
|
||||
|
@ -57,7 +57,6 @@ class Prs3d_LineAspect;
|
||||
class Prs3d_BasicAspect;
|
||||
class SelectMgr_EntityOwner;
|
||||
class SelectMgr_Filter;
|
||||
class TCollection_AsciiString;
|
||||
|
||||
//! The Interactive Context allows you to manage graphic behavior and selection of Interactive Objects in one or more viewers.
|
||||
//! Class methods make this highly transparent.
|
||||
@ -153,7 +152,7 @@ public: //! @name object display management
|
||||
Standard_EXPORT void Remove (const Handle(AIS_InteractiveObject)& theIObj,
|
||||
const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! Removes all the objects from all opened Local Contexts and from the Neutral Point.
|
||||
//! Removes all the objects from Context.
|
||||
Standard_EXPORT void RemoveAll (const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! Recomputes the seen parts presentation of the Object.
|
||||
@ -341,7 +340,6 @@ public: //! @name mouse picking logic (detection and dynamic highlighting of ent
|
||||
|
||||
//! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
|
||||
//! This is done by the view theView passing this position to the main viewer and updating it.
|
||||
//! Functions in both Neutral Point and local contexts.
|
||||
//! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
|
||||
//! @sa PickingStrategy()
|
||||
Standard_EXPORT AIS_StatusOfDetection MoveTo (const Standard_Integer theXPix,
|
||||
@ -502,7 +500,7 @@ public: //! @name Selection management
|
||||
Standard_EXPORT void UnhilightSelected (const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! Updates the list of selected objects:
|
||||
//! i.e. highlights the newely selected ones and unhighlights previously selected objects.
|
||||
//! i.e. highlights the newly selected ones and unhighlights previously selected objects.
|
||||
//! @sa HilightSelected().
|
||||
Standard_EXPORT void UpdateSelected (const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
@ -646,7 +644,7 @@ public: //! @name management of active Selection Modes
|
||||
//! Deactivates all the activated selection mode at all displayed objects.
|
||||
Standard_EXPORT void Deactivate();
|
||||
|
||||
//! Returns the list of activated selection modes in an open context.
|
||||
//! Returns the list of activated selection modes.
|
||||
Standard_EXPORT void ActivatedModes (const Handle(AIS_InteractiveObject)& anIobj, TColStd_ListOfInteger& theList) const;
|
||||
|
||||
//! Returns a collection containing all entity owners created for the interactive object in specified selection mode (in all active modes if the Mode == -1)
|
||||
@ -1111,17 +1109,17 @@ public: //! @name Local Context management (deprecated)
|
||||
//! If you have opened a local context by loading an object with the default options (<AllowShapeDecomposition >= Standard_True),
|
||||
//! all objects of the "Shape" type are also activated with the same modes.
|
||||
//! You can act on the state of these "Standard" objects by using SetShapeDecomposition(Status).
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::Activate() and AIS_Shape::SelectionMode() should be used instead")
|
||||
Standard_EXPORT void ActivateStandardMode (const TopAbs_ShapeEnum aStandardActivation);
|
||||
|
||||
//! Provides an alternative to the Display methods when deactivating specific selection modes.
|
||||
//! This has the effect of deactivating the corresponding selection mode aStandardActivation for all objects
|
||||
//! in Local Context which accept decomposition into sub-shapes.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::Deactivate() should be used instead")
|
||||
Standard_EXPORT void DeactivateStandardMode (const TopAbs_ShapeEnum aStandardActivation);
|
||||
|
||||
//! Returns the list of activated standard selection modes available in a local context.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - list of activated Selection Modes should be tracked on application side; see also ::ActivatedModes()")
|
||||
Standard_EXPORT const TColStd_ListOfInteger& ActivatedStandardModes() const;
|
||||
|
||||
//! returns if possible, the first local context where the object is seen
|
||||
@ -1174,51 +1172,51 @@ public:
|
||||
|
||||
//! Initializes a scan of the current selected objects in Neutral Point.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::InitSelected() should be called instead")
|
||||
Standard_EXPORT void InitCurrent();
|
||||
|
||||
//! Returns true if there is another object found by the scan of the list of current objects.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::MoreSelected() should be called instead")
|
||||
Standard_EXPORT Standard_Boolean MoreCurrent() const;
|
||||
|
||||
//! Continues the scan to the next object in the list of current objects.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::NextSelected() should be called instead")
|
||||
Standard_EXPORT void NextCurrent();
|
||||
|
||||
//! Returns the current interactive object.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::SelectedInteractive() should be called instead")
|
||||
Standard_EXPORT Handle(AIS_InteractiveObject) Current() const;
|
||||
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::NbSelected() should be called instead")
|
||||
Standard_EXPORT Standard_Integer NbCurrents();
|
||||
|
||||
//! Highlights current objects.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::HilightSelected() should be called instead")
|
||||
Standard_EXPORT void HilightCurrents (const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! Removes highlighting from current objects.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::UnhilightSelected() should be called instead")
|
||||
Standard_EXPORT void UnhilightCurrents (const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! Empties previous current objects in order to get the current objects detected by the selector using UpdateCurrent.
|
||||
//! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects.
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::ClearSelected() should be called instead")
|
||||
Standard_EXPORT void ClearCurrents (const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! @return current mouse-detected shape or empty (null) shape, if current interactive object
|
||||
//! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all.
|
||||
//! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected().
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
|
||||
Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const;
|
||||
|
||||
//! @return current mouse-detected interactive object or null object, if there is no currently detected interactives
|
||||
//! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected().
|
||||
Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context")
|
||||
Standard_DEPRECATED ("Local Context is deprecated - ::DetectedCurrentOwner() should be called instead")
|
||||
Standard_EXPORT Handle(AIS_InteractiveObject) DetectedCurrentObject() const;
|
||||
|
||||
public: //! @name sub-intensity management (deprecated)
|
||||
|
@ -303,6 +303,11 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean theToRedrawOnUpdate)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument");
|
||||
}
|
||||
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
myWasLastMain = Standard_True;
|
||||
@ -313,11 +318,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
||||
myCurHighlighted = 0;
|
||||
myDetectedSeq.Clear();
|
||||
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
return AIS_SOD_Error;
|
||||
}
|
||||
|
||||
// preliminaires
|
||||
myLastPicked = myLastinMain;
|
||||
myWasLastMain = Standard_True;
|
||||
@ -454,6 +454,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||
}
|
||||
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
|
||||
@ -466,18 +471,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
|
||||
|
||||
ClearSelected (Standard_False);
|
||||
|
||||
Handle(StdSelect_ViewerSelector3d) aSelector;
|
||||
|
||||
if (theView->Viewer() == myMainVwr)
|
||||
myWasLastMain = Standard_True;
|
||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
aSelector = myMainSel;
|
||||
myWasLastMain = Standard_True;
|
||||
}
|
||||
|
||||
aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter);
|
||||
const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter);
|
||||
if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
|
||||
continue;
|
||||
|
||||
@ -503,6 +501,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||
}
|
||||
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
|
||||
@ -513,18 +516,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
|
||||
|
||||
ClearSelected (Standard_False);
|
||||
|
||||
Handle(StdSelect_ViewerSelector3d) aSelector;
|
||||
|
||||
if (theView->Viewer() == myMainVwr)
|
||||
myWasLastMain = Standard_True;
|
||||
myMainSel->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
aSelector = myMainSel;
|
||||
myWasLastMain = Standard_True;
|
||||
}
|
||||
|
||||
aSelector->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
||||
continue;
|
||||
|
||||
@ -640,6 +636,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
||||
}
|
||||
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
|
||||
@ -648,21 +649,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
||||
|
||||
UnhilightSelected (Standard_False);
|
||||
|
||||
Handle(StdSelect_ViewerSelector3d) aSelector;
|
||||
if (theView->Viewer() == myMainVwr)
|
||||
myWasLastMain = Standard_True;
|
||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
aSelector = myMainSel;
|
||||
myWasLastMain = Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AIS_SOP_NothingSelected;
|
||||
}
|
||||
|
||||
aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
||||
continue;
|
||||
|
||||
@ -688,6 +679,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
||||
}
|
||||
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
|
||||
@ -695,22 +691,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
|
||||
|
||||
UnhilightSelected (Standard_False);
|
||||
|
||||
Handle(StdSelect_ViewerSelector3d) aSelector;
|
||||
|
||||
if (theView->Viewer() == myMainVwr)
|
||||
myWasLastMain = Standard_True;
|
||||
myMainSel->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
aSelector= myMainSel;
|
||||
myWasLastMain = Standard_True;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AIS_SOP_NothingSelected;
|
||||
}
|
||||
|
||||
aSelector->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
||||
continue;
|
||||
|
||||
@ -1482,21 +1467,30 @@ Standard_Boolean AIS_InteractiveContext::HasDetected() const
|
||||
|
||||
Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
|
||||
{
|
||||
if(HasOpenedContext())
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
|
||||
return !anOwner.IsNull()
|
||||
&& anOwner->HasShape();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DetectedShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopoDS_Shape&
|
||||
AIS_InteractiveContext::DetectedShape() const
|
||||
const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->DetectedShape();
|
||||
}
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->DetectedShape();
|
||||
}
|
||||
|
||||
Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked);
|
||||
return anOwner->Shape();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DetectedInteractive
|
||||
@ -1696,13 +1690,9 @@ const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
if (aCurrentShape.IsNull())
|
||||
{
|
||||
return AIS_InteractiveContext_myDummyShape;
|
||||
}
|
||||
|
||||
return aCurrentShape->Shape();
|
||||
return !aCurrentShape.IsNull()
|
||||
? aCurrentShape->Shape()
|
||||
: AIS_InteractiveContext_myDummyShape;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -1717,8 +1707,8 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() co
|
||||
}
|
||||
|
||||
return MoreDetected()
|
||||
? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
|
||||
: NULL;
|
||||
? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
|
||||
: Handle(AIS_InteractiveObject)();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -781,8 +781,11 @@ Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& V
|
||||
|
||||
Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const
|
||||
{
|
||||
if(!HasOpenedContext()) return Standard_False;
|
||||
return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn();
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->IsImmediateModeOn();
|
||||
}
|
||||
return myMainPM->IsImmediateModeOn();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -792,8 +795,17 @@ Standard_Boolean AIS_InteractiveContext::IsImmediateModeOn() const
|
||||
|
||||
Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
|
||||
{
|
||||
return HasOpenedContext()
|
||||
&& myLocalContexts (myCurLocalIndex)->BeginImmediateDraw();
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->BeginImmediateDraw();
|
||||
}
|
||||
|
||||
if (myMainPM->IsImmediateModeOn())
|
||||
{
|
||||
myMainPM->BeginImmediateDraw();
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -804,8 +816,18 @@ Standard_Boolean AIS_InteractiveContext::BeginImmediateDraw()
|
||||
Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
return HasOpenedContext()
|
||||
&& myLocalContexts (myCurLocalIndex)->ImmediateAdd (theObj, theMode);
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->ImmediateAdd (theObj, theMode);
|
||||
}
|
||||
|
||||
if (!myMainPM->IsImmediateModeOn())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myMainPM->AddToImmediateList (myMainPM->Presentation (theObj, theMode)->Presentation());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -815,8 +837,18 @@ Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_Interact
|
||||
|
||||
Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView)
|
||||
{
|
||||
return HasOpenedContext()
|
||||
&& myLocalContexts (myCurLocalIndex)->EndImmediateDraw (theView->Viewer());
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->EndImmediateDraw (theView->Viewer());
|
||||
}
|
||||
|
||||
if (!myMainPM->IsImmediateModeOn())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myMainPM->EndImmediateDraw (theView->Viewer());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -826,12 +858,18 @@ Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View
|
||||
|
||||
Standard_Boolean AIS_InteractiveContext::EndImmediateDraw()
|
||||
{
|
||||
if (!HasOpenedContext())
|
||||
if (HasOpenedContext())
|
||||
{
|
||||
return myLocalContexts(myCurLocalIndex)->EndImmediateDraw (myMainVwr);
|
||||
}
|
||||
|
||||
if (!myMainPM->IsImmediateModeOn())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return myLocalContexts (myCurLocalIndex)->EndImmediateDraw (myMainVwr);
|
||||
myMainPM->EndImmediateDraw (myMainVwr);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <AIS_GlobalStatus.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#include <Prs3d_BasicAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
@ -726,60 +726,6 @@ void ViewerTest::Clear()
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//function : StandardModesActivation
|
||||
//purpose : Activate a selection mode, vertex, edge, wire ..., in a local
|
||||
// Context
|
||||
//==============================================================================
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
void ViewerTest::StandardModeActivation(const Standard_Integer mode )
|
||||
{
|
||||
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
|
||||
if(mode==0) {
|
||||
if (TheAISContext()->HasOpenedContext())
|
||||
{
|
||||
aContext->CloseLocalContext();
|
||||
}
|
||||
} else {
|
||||
|
||||
if(!aContext->HasOpenedContext()) {
|
||||
// To unhilight the preselected object
|
||||
aContext->UnhilightSelected(Standard_False);
|
||||
// Open a local Context in order to be able to select subshape from
|
||||
// the selected shape if any or for all if there is no selection
|
||||
if (!aContext->FirstSelectedObject().IsNull()){
|
||||
aContext->OpenLocalContext(Standard_False);
|
||||
|
||||
for(aContext->InitSelected();aContext->MoreSelected();aContext->NextSelected()){
|
||||
aContext->Load( aContext->SelectedInteractive(),-1,Standard_True);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aContext->OpenLocalContext();
|
||||
}
|
||||
}
|
||||
|
||||
const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (mode);
|
||||
const char* cmode = mode >= 0 && mode <= 8
|
||||
? TopAbs::ShapeTypeToString (aShapeType)
|
||||
: "???";
|
||||
if(theactivatedmodes.Contains(mode))
|
||||
{ // Desactivate
|
||||
aContext->DeactivateStandardMode(AIS_Shape::SelectionType(mode));
|
||||
theactivatedmodes.Remove(mode);
|
||||
cout<<"Mode "<< cmode <<" OFF"<<endl;
|
||||
}
|
||||
else
|
||||
{ // Activate
|
||||
aContext->ActivateStandardMode(AIS_Shape::SelectionType(mode));
|
||||
theactivatedmodes.Add(mode);
|
||||
cout<<"Mode "<< cmode << " ON" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
//==============================================================================
|
||||
//function : CopyIsoAspect
|
||||
//purpose : Returns copy Prs3d_IsoAspect with new number of isolines.
|
||||
@ -3315,7 +3261,6 @@ int VErase (Draw_Interpretor& theDI,
|
||||
|
||||
//==============================================================================
|
||||
//function : VDisplayAll
|
||||
//author : ege
|
||||
//purpose : Display all the objects of the Map
|
||||
//==============================================================================
|
||||
static int VDisplayAll (Draw_Interpretor& ,
|
||||
@ -4717,216 +4662,6 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
|
||||
TheAISContext()->Redisplay (TheAisIO, Standard_True);
|
||||
return 0;
|
||||
}
|
||||
//==============================================================================
|
||||
//function : HaveMode
|
||||
//use : VActivatedModes
|
||||
//==============================================================================
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
|
||||
Standard_Boolean HaveMode(const Handle(AIS_InteractiveObject)& TheAisIO,const Standard_Integer mode )
|
||||
{
|
||||
TColStd_ListOfInteger List;
|
||||
TheAISContext()->ActivatedModes (TheAisIO,List);
|
||||
TColStd_ListIteratorOfListOfInteger it;
|
||||
Standard_Boolean Found=Standard_False;
|
||||
for (it.Initialize(List); it.More()&&!Found; it.Next() ){
|
||||
if (it.Value()==mode ) Found=Standard_True;
|
||||
}
|
||||
return Found;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//function : VActivatedMode
|
||||
//author : ege
|
||||
//purpose : permet d'attribuer a chacune des shapes un mode d'activation
|
||||
// (edges,vertex...)qui lui est propre et le mode de selection standard.
|
||||
// La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer)
|
||||
// Dans le cas ou on veut psser la shape en argument, la fonction n'autorise
|
||||
// qu'un nom et qu'un mode.
|
||||
//Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7)
|
||||
//==============================================================================
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
|
||||
static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
|
||||
{
|
||||
Standard_Boolean ThereIsName = Standard_False ;
|
||||
|
||||
if(!a3DView().IsNull()){
|
||||
|
||||
const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
|
||||
// verification des arguments
|
||||
if (HaveToSet) {
|
||||
if (argc<2||argc>3) { di<<" Syntaxe error\n";return 1;}
|
||||
ThereIsName = (argc == 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
// vunsetam
|
||||
if (argc>1) {di<<" Syntaxe error\n";return 1;}
|
||||
else {
|
||||
di<<" R.A.Z de tous les modes de selecion\n";
|
||||
di<<" Fermeture du Context local\n";
|
||||
if (TheAISContext()->HasOpenedContext())
|
||||
{
|
||||
TheAISContext()->CloseLocalContext();
|
||||
}
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
|
||||
// IL n'y a aps de nom de shape passe en argument
|
||||
if (HaveToSet && !ThereIsName){
|
||||
Standard_Integer aMode=Draw::Atoi(argv [1]);
|
||||
const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (aMode);
|
||||
const char* cmode = aMode >= 0 && aMode <= 8
|
||||
? TopAbs::ShapeTypeToString (aShapeType)
|
||||
: "???";
|
||||
if( !TheAISContext()->HasOpenedContext() ) {
|
||||
// il n'y a pas de Context local d'ouvert
|
||||
// on en ouvre un et on charge toutes les shapes displayees
|
||||
// on load tous les objets displayees et on Activate les objets de la liste
|
||||
AIS_ListOfInteractive ListOfIO;
|
||||
// on sauve dans une AISListOfInteractive tous les objets currents
|
||||
if (TheAISContext()->NbSelected()>0 ){
|
||||
TheAISContext()->UnhilightSelected(Standard_False);
|
||||
|
||||
for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
|
||||
ListOfIO.Append(TheAISContext()->SelectedInteractive() );
|
||||
}
|
||||
}
|
||||
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
TheAISContext()->OpenLocalContext(Standard_False);
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
|
||||
it (GetMapOfAIS());
|
||||
while(it.More()){
|
||||
Handle(AIS_InteractiveObject) aIO =
|
||||
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
|
||||
if (!aIO.IsNull())
|
||||
TheAISContext()->Load(aIO,0,Standard_False);
|
||||
it.Next();
|
||||
}
|
||||
// traitement des objets qui etaient currents dans le Contexte global
|
||||
if (!ListOfIO.IsEmpty() ) {
|
||||
// il y avait des objets currents
|
||||
AIS_ListIteratorOfListOfInteractive iter;
|
||||
for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) {
|
||||
Handle(AIS_InteractiveObject) aIO=iter.Value();
|
||||
TheAISContext()->Activate(aIO,aMode);
|
||||
di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// On applique le mode a tous les objets displayes
|
||||
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
|
||||
it2 (GetMapOfAIS());
|
||||
while(it2.More()){
|
||||
Handle(AIS_InteractiveObject) aIO =
|
||||
Handle(AIS_InteractiveObject)::DownCast(it2.Key1());
|
||||
if (!aIO.IsNull()) {
|
||||
di<<" Mode: "<<cmode<<" ON pour "<<it2.Key2().ToCString() <<"\n";
|
||||
TheAISContext()->Activate(aIO,aMode);
|
||||
}
|
||||
it2.Next();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
// un Context local est deja ouvert
|
||||
// Traitement des objets du Context local
|
||||
if (TheAISContext()->NbSelected()>0 ){
|
||||
TheAISContext()->UnhilightSelected(Standard_False);
|
||||
// il y a des objets selected,on les parcourt
|
||||
for (TheAISContext()->InitSelected(); TheAISContext()->MoreSelected(); TheAISContext()->NextSelected() ){
|
||||
Handle(AIS_InteractiveObject) aIO=TheAISContext()->SelectedInteractive();
|
||||
|
||||
|
||||
if (HaveMode(aIO,aMode) ) {
|
||||
di<<" Mode: "<<cmode<<" OFF pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
|
||||
TheAISContext()->Deactivate(aIO,aMode);
|
||||
}
|
||||
else{
|
||||
di<<" Mode: "<<cmode<<" ON pour "<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
|
||||
TheAISContext()->Activate(aIO,aMode);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
// il n'y a pas d'objets selected
|
||||
// tous les objets diplayes sont traites
|
||||
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
|
||||
it (GetMapOfAIS());
|
||||
while(it.More()){
|
||||
Handle(AIS_InteractiveObject) aIO =
|
||||
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
|
||||
if (!aIO.IsNull()) {
|
||||
if (HaveMode(aIO,aMode) ) {
|
||||
di<<" Mode: "<<cmode<<" OFF pour "
|
||||
<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
|
||||
TheAISContext()->Deactivate(aIO,aMode);
|
||||
}
|
||||
else{
|
||||
di<<" Mode: "<<cmode<<" ON pour"
|
||||
<<GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
|
||||
TheAISContext()->Activate(aIO,aMode);
|
||||
}
|
||||
}
|
||||
it.Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (HaveToSet && ThereIsName){
|
||||
Standard_Integer aMode=Draw::Atoi(argv [2]);
|
||||
Handle(AIS_InteractiveObject) aIO =
|
||||
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[1]));
|
||||
|
||||
if (!aIO.IsNull()) {
|
||||
const TopAbs_ShapeEnum aShapeType = AIS_Shape::SelectionType (aMode);
|
||||
const char* cmode = aMode >= 0 && aMode <= 8
|
||||
? TopAbs::ShapeTypeToString (aShapeType)
|
||||
: "???";
|
||||
if( !TheAISContext()->HasOpenedContext() ) {
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
TheAISContext()->OpenLocalContext(Standard_False);
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
// On charge tous les objets de la map
|
||||
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS());
|
||||
while(it.More()){
|
||||
Handle(AIS_InteractiveObject) aShape=
|
||||
Handle(AIS_InteractiveObject)::DownCast(it.Key1());
|
||||
if (!aShape.IsNull())
|
||||
TheAISContext()->Load(aShape,0,Standard_False);
|
||||
it.Next();
|
||||
}
|
||||
TheAISContext()->Activate(aIO,aMode);
|
||||
di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
|
||||
}
|
||||
|
||||
else {
|
||||
// un Context local est deja ouvert
|
||||
if (HaveMode(aIO,aMode) ) {
|
||||
di<<" Mode: "<<cmode<<" OFF pour "<<argv[1]<<"\n";
|
||||
TheAISContext()->Deactivate(aIO,aMode);
|
||||
}
|
||||
else{
|
||||
di<<" Mode: "<<cmode<<" ON pour "<<argv[1]<<"\n";
|
||||
TheAISContext()->Activate(aIO,aMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Auxiliary method to print Interactive Object information
|
||||
static void objInfo (const NCollection_Map<Handle(AIS_InteractiveObject)>& theDetected,
|
||||
@ -5228,347 +4963,200 @@ static Standard_Integer VState (Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PickObjects
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& arr,
|
||||
const AIS_KindOfInteractive TheType,
|
||||
const Standard_Integer TheSignature,
|
||||
const Standard_Integer MaxPick)
|
||||
{
|
||||
Handle(AIS_InteractiveObject) IO;
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
// step 1: prepare the data
|
||||
if(curindex !=0){
|
||||
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
|
||||
// step 2 : wait for the selection...
|
||||
Standard_Integer NbPickGood (0),NbToReach(arr->Length());
|
||||
Standard_Integer NbPickFail(0);
|
||||
Standard_Integer argccc = 5;
|
||||
const char *bufff[] = { "A", "B", "C","D", "E" };
|
||||
const char **argvvv = (const char **) bufff;
|
||||
|
||||
|
||||
while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
|
||||
while(ViewerMainLoop(argccc,argvvv)){}
|
||||
Standard_Integer NbStored = TheAISContext()->NbSelected();
|
||||
if(NbStored != NbPickGood)
|
||||
NbPickGood= NbStored;
|
||||
else
|
||||
NbPickFail++;
|
||||
cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<endl;
|
||||
}
|
||||
|
||||
// step3 get result.
|
||||
|
||||
if (NbPickFail >= NbToReach)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Integer i(0);
|
||||
for(TheAISContext()->InitSelected();
|
||||
TheAISContext()->MoreSelected();
|
||||
TheAISContext()->NextSelected()){
|
||||
i++;
|
||||
Handle(AIS_InteractiveObject) IO2 = TheAISContext()->SelectedInteractive();
|
||||
arr->SetValue(i,IO2);
|
||||
}
|
||||
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
if (curindex > 0)
|
||||
{
|
||||
TheAISContext()->CloseLocalContext(curindex);
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PickObject
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive TheType,
|
||||
const Standard_Integer TheSignature,
|
||||
const Standard_Integer MaxPick)
|
||||
{
|
||||
Handle(AIS_InteractiveObject) IO;
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
// step 1: prepare the data
|
||||
|
||||
if(curindex !=0){
|
||||
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
|
||||
// step 2 : wait for the selection...
|
||||
Standard_Boolean IsGood (Standard_False);
|
||||
Standard_Integer NbPick(0);
|
||||
Standard_Integer argccc = 5;
|
||||
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
|
||||
const char **argvvv = (const char **) bufff;
|
||||
|
||||
|
||||
while(!IsGood && NbPick<= MaxPick){
|
||||
while(ViewerMainLoop(argccc,argvvv)){}
|
||||
IsGood = (TheAISContext()->NbSelected()>0) ;
|
||||
NbPick++;
|
||||
cout<<"Nb Pick :"<<NbPick<<endl;
|
||||
}
|
||||
|
||||
|
||||
// step3 get result.
|
||||
if(IsGood){
|
||||
TheAISContext()->InitSelected();
|
||||
IO = TheAISContext()->SelectedInteractive();
|
||||
}
|
||||
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
if (curindex != 0)
|
||||
{
|
||||
TheAISContext()->CloseLocalContext(curindex);
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
return IO;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PickShape
|
||||
//purpose : First Activate the rightmode + Put Filters to be able to
|
||||
// pick objets that are of type <TheType>...
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape ViewerTest::PickShape(const TopAbs_ShapeEnum TheType,
|
||||
const Standard_Integer MaxPick)
|
||||
TopoDS_Shape ViewerTest::PickShape (const TopAbs_ShapeEnum theShapeType,
|
||||
const Standard_Integer theMaxPick)
|
||||
{
|
||||
|
||||
// step 1: prepare the data
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
Standard_Integer curindex = TheAISContext()->OpenLocalContext();
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
TopoDS_Shape result;
|
||||
|
||||
if(TheType==TopAbs_SHAPE){
|
||||
Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
else{
|
||||
Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
|
||||
TheAISContext()->AddFilter(TF);
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
TheAISContext()->ActivateStandardMode(TheType);
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
}
|
||||
|
||||
|
||||
// step 2 : wait for the selection...
|
||||
Standard_Boolean NoShape (Standard_True);
|
||||
Standard_Integer NbPick(0);
|
||||
Standard_Integer argccc = 5;
|
||||
const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
|
||||
const char **argvvv = (const char **) bufff;
|
||||
|
||||
|
||||
while(NoShape && NbPick<= MaxPick){
|
||||
while(ViewerMainLoop(argccc,argvvv)){}
|
||||
NoShape = (TheAISContext()->NbSelected()==0) ;
|
||||
NbPick++;
|
||||
cout<<"Nb Pick :"<<NbPick<<endl;
|
||||
}
|
||||
|
||||
// step3 get result.
|
||||
|
||||
if(!NoShape){
|
||||
|
||||
TheAISContext()->InitSelected();
|
||||
if(TheAISContext()->HasSelectedShape())
|
||||
result = TheAISContext()->SelectedShape();
|
||||
else{
|
||||
Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
|
||||
result = Handle(AIS_Shape)::DownCast (IO)->Shape();
|
||||
}
|
||||
}
|
||||
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
if (curindex > 0)
|
||||
{
|
||||
TheAISContext()->CloseLocalContext(curindex);
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
return result;
|
||||
Handle(TopTools_HArray1OfShape) aResArray = new TopTools_HArray1OfShape (1, 1);
|
||||
PickShapes (theShapeType, aResArray, theMaxPick);
|
||||
return aResArray->First();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : PickShapes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum TheType,
|
||||
Handle(TopTools_HArray1OfShape)& thearr,
|
||||
const Standard_Integer MaxPick)
|
||||
Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
|
||||
Handle(TopTools_HArray1OfShape)& theResArray,
|
||||
const Standard_Integer theMaxPick)
|
||||
{
|
||||
|
||||
Standard_Integer Taille = thearr->Length();
|
||||
if(Taille>1)
|
||||
cout<<" WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
|
||||
const Standard_Integer aNbToReach = theResArray->Length();
|
||||
if (aNbToReach > 1)
|
||||
{
|
||||
std::cout << " WARNING : Pick with Shift+ MB1 for Selection of more than 1 object\n";
|
||||
}
|
||||
|
||||
// step 1: prepare the data
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
Standard_Integer curindex = TheAISContext()->OpenLocalContext();
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
if(TheType==TopAbs_SHAPE){
|
||||
Handle(AIS_TypeFilter) F1 = new AIS_TypeFilter(AIS_KOI_Shape);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||
aCtx->RemoveFilters();
|
||||
AIS_ListOfInteractive aDispObjects;
|
||||
aCtx->DisplayedObjects (aDispObjects);
|
||||
if (theShapeType == TopAbs_SHAPE)
|
||||
{
|
||||
aCtx->AddFilter (new AIS_TypeFilter (AIS_KOI_Shape));
|
||||
}
|
||||
else{
|
||||
Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType);
|
||||
TheAISContext()->AddFilter(TF);
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
TheAISContext()->ActivateStandardMode(TheType);
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
else
|
||||
{
|
||||
aCtx->AddFilter (new StdSelect_ShapeTypeFilter (theShapeType));
|
||||
}
|
||||
|
||||
// step 2 : wait for the selection...
|
||||
Standard_Integer NbPickGood (0),NbToReach(thearr->Length());
|
||||
Standard_Integer NbPickFail(0);
|
||||
Standard_Integer argccc = 5;
|
||||
const char *bufff[] = { "A", "B", "C","D", "E" };
|
||||
const char **argvvv = (const char **) bufff;
|
||||
|
||||
|
||||
while(NbPickGood<NbToReach && NbPickFail <= MaxPick){
|
||||
while(ViewerMainLoop(argccc,argvvv)){}
|
||||
Standard_Integer NbStored = TheAISContext()->NbSelected();
|
||||
if (NbStored != NbPickGood)
|
||||
NbPickGood= NbStored;
|
||||
else
|
||||
NbPickFail++;
|
||||
cout<<"NbPicked = "<<NbPickGood<<" | Nb Pick Fail :"<<NbPickFail<<"\n";
|
||||
}
|
||||
|
||||
// step3 get result.
|
||||
|
||||
if (NbPickFail >= NbToReach)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Integer i(0);
|
||||
for(TheAISContext()->InitSelected();TheAISContext()->MoreSelected();TheAISContext()->NextSelected()){
|
||||
i++;
|
||||
if(TheAISContext()->HasSelectedShape())
|
||||
thearr->SetValue(i,TheAISContext()->SelectedShape());
|
||||
else{
|
||||
Handle(AIS_InteractiveObject) IO = TheAISContext()->SelectedInteractive();
|
||||
thearr->SetValue(i,Handle(AIS_Shape)::DownCast (IO)->Shape());
|
||||
const Standard_Integer aSelMode = AIS_Shape::SelectionMode (theShapeType);
|
||||
for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next())
|
||||
{
|
||||
if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value()))
|
||||
{
|
||||
aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
TheAISContext()->CloseLocalContext(curindex);
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
// step 2 : wait for the selection...
|
||||
Standard_Integer aNbPickGood = 0, aNbPickFail = 0;
|
||||
Standard_Integer argccc = 5;
|
||||
const char *bufff[] = { "A", "B", "C", "D", "E" };
|
||||
const char **argvvv = (const char** )bufff;
|
||||
for (; aNbPickGood < aNbToReach && aNbPickFail <= theMaxPick; )
|
||||
{
|
||||
while (ViewerMainLoop (argccc, argvvv)) {}
|
||||
Standard_Integer aNbStored = aCtx->NbSelected();
|
||||
if (aNbStored != aNbPickGood)
|
||||
{
|
||||
aNbPickGood = aNbStored;
|
||||
}
|
||||
else
|
||||
{
|
||||
++aNbPickFail;
|
||||
}
|
||||
std::cout << "NbPicked = " << aNbPickGood << " | Nb Pick Fail :" << aNbPickFail << "\n";
|
||||
}
|
||||
|
||||
// step3 get result.
|
||||
if (aNbPickFail >= aNbToReach)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Integer anIndex = theResArray->Lower();
|
||||
for (aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected(), ++anIndex)
|
||||
{
|
||||
if (aCtx->HasSelectedShape())
|
||||
{
|
||||
theResArray->SetValue (anIndex, aCtx->SelectedShape());
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(AIS_InteractiveObject) IO = aCtx->SelectedInteractive();
|
||||
theResArray->SetValue (anIndex, Handle(AIS_Shape)::DownCast (IO)->Shape());
|
||||
}
|
||||
}
|
||||
|
||||
aCtx->RemoveFilters();
|
||||
if (theShapeType != TopAbs_SHAPE)
|
||||
{
|
||||
for (AIS_ListOfInteractive::Iterator anObjIter (aDispObjects); anObjIter.More(); anObjIter.Next())
|
||||
{
|
||||
if (Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (anObjIter.Value()))
|
||||
{
|
||||
aCtx->SetSelectionModeActive (aShapePrs, aSelMode, true, AIS_SelectionModesConcurrency_Single);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : VPickShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static int VPickShape( Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
TopoDS_Shape PickSh;
|
||||
TopAbs_ShapeEnum theType = TopAbs_COMPOUND;
|
||||
|
||||
if(argc==1)
|
||||
theType = TopAbs_SHAPE;
|
||||
else{
|
||||
if(!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX;
|
||||
else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE;
|
||||
else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE;
|
||||
else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE;
|
||||
else if(!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE;
|
||||
else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL;
|
||||
else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID;
|
||||
}
|
||||
|
||||
static Standard_Integer nbOfSub[8]={0,0,0,0,0,0,0,0};
|
||||
static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
|
||||
|
||||
TCollection_AsciiString name;
|
||||
|
||||
|
||||
Standard_Integer NbToPick = argc>2 ? argc-2 : 1;
|
||||
if(NbToPick==1){
|
||||
PickSh = ViewerTest::PickShape(theType);
|
||||
|
||||
if(PickSh.IsNull())
|
||||
TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
|
||||
if (argc != 1)
|
||||
{
|
||||
TCollection_AsciiString aShapeArg (argv[1]);
|
||||
aShapeArg.LowerCase();
|
||||
aShapeType = TopAbs_COMPOUND;
|
||||
if (aShapeArg == "v"
|
||||
|| aShapeArg == "vertex") aShapeType = TopAbs_VERTEX;
|
||||
else if (aShapeArg == "e"
|
||||
|| aShapeArg == "edge") aShapeType = TopAbs_EDGE;
|
||||
else if (aShapeArg == "w"
|
||||
|| aShapeArg == "wire") aShapeType = TopAbs_WIRE;
|
||||
else if (aShapeArg == "f"
|
||||
|| aShapeArg == "face") aShapeType = TopAbs_FACE;
|
||||
else if (aShapeArg == "shape") aShapeType = TopAbs_SHAPE;
|
||||
else if (aShapeArg == "shell") aShapeType = TopAbs_SHELL;
|
||||
else if (aShapeArg == "solid") aShapeType = TopAbs_SOLID;
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << argv[1] << "'\n";
|
||||
return 1;
|
||||
if(argc>2){
|
||||
name += argv[2];
|
||||
}
|
||||
else{
|
||||
|
||||
if(!PickSh.IsNull()){
|
||||
nbOfSub[Standard_Integer(theType)]++;
|
||||
name += "Picked_";
|
||||
name += nameType[Standard_Integer(theType)];
|
||||
TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
|
||||
name +="_";
|
||||
name+=indxstring;
|
||||
}
|
||||
}
|
||||
// si on avait une petite methode pour voir si la shape
|
||||
// est deja dans la Double map, ca eviterait de creer....
|
||||
DBRep::Set(name.ToCString(),PickSh);
|
||||
|
||||
Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
|
||||
GetMapOfAIS().Bind(newsh, name);
|
||||
TheAISContext()->Display (newsh, Standard_True);
|
||||
di<<"Nom de la shape pickee : "<<name.ToCString()<<"\n";
|
||||
}
|
||||
|
||||
// Plusieurs objets a picker, vite vite vite....
|
||||
//
|
||||
else{
|
||||
Standard_Boolean autonaming = !strcasecmp(argv[2],".");
|
||||
Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
|
||||
if(ViewerTest::PickShapes(theType,arr)){
|
||||
for(Standard_Integer i=1;i<=NbToPick;i++){
|
||||
PickSh = arr->Value(i);
|
||||
if(!PickSh.IsNull()){
|
||||
if(autonaming){
|
||||
nbOfSub[Standard_Integer(theType)]++;
|
||||
name.Clear();
|
||||
name += "Picked_";
|
||||
name += nameType[Standard_Integer(theType)];
|
||||
TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]);
|
||||
name +="_";
|
||||
name+=indxstring;
|
||||
}
|
||||
}
|
||||
else
|
||||
name = argv[1+i];
|
||||
|
||||
DBRep::Set(name.ToCString(),PickSh);
|
||||
Handle(AIS_Shape) newsh = new AIS_Shape(PickSh);
|
||||
GetMapOfAIS().Bind(newsh, name);
|
||||
di<<"display of picke shape #"<<i<<" - nom : "<<name.ToCString()<<"\n";
|
||||
TheAISContext()->Display (newsh, Standard_False);
|
||||
|
||||
}
|
||||
TheAISContext()->UpdateCurrentViewer();
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Integer THE_NB_SHAPES_OF_TYPE[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const TCollection_AsciiString THE_NAME_TYPE[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"};
|
||||
|
||||
const Standard_Integer aNbToPick = argc > 2 ? argc - 2 : 1;
|
||||
if (aNbToPick == 1)
|
||||
{
|
||||
TopoDS_Shape aPickedShape = ViewerTest::PickShape (aShapeType);
|
||||
if (aPickedShape.IsNull())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aName;
|
||||
if (argc > 2)
|
||||
{
|
||||
aName = argv[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)];
|
||||
aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex;
|
||||
}
|
||||
|
||||
DBRep::Set (aName.ToCString(), aPickedShape);
|
||||
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape);
|
||||
ViewerTest::Display (aName, aShapePrs, false, true);
|
||||
di << "Name of picked shape: " << aName <<"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString aName (argv[2]);
|
||||
aName.LowerCase();
|
||||
const Standard_Boolean isAutoNaming = aName == ".";
|
||||
Handle(TopTools_HArray1OfShape) aPickedArray = new TopTools_HArray1OfShape (1, aNbToPick);
|
||||
if (ViewerTest::PickShapes (aShapeType, aPickedArray))
|
||||
{
|
||||
for (Standard_Integer aPickedIter = aPickedArray->Lower(); aPickedIter <= aPickedArray->Upper(); ++aPickedIter)
|
||||
{
|
||||
TopoDS_Shape aPickedShape = aPickedArray->Value (aPickedIter);
|
||||
aName.Clear();
|
||||
if (!aPickedShape.IsNull()
|
||||
&& isAutoNaming)
|
||||
{
|
||||
const int aShapeIndex = ++THE_NB_SHAPES_OF_TYPE[Standard_Integer(aShapeType)];
|
||||
aName = TCollection_AsciiString ("Picked_") + THE_NAME_TYPE[Standard_Integer(aShapeType)] + "_" + aShapeIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
aName = argv[1 + aPickedIter];
|
||||
}
|
||||
|
||||
DBRep::Set (aName.ToCString(), aPickedShape);
|
||||
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aPickedShape);
|
||||
di << "Display of picked shape #" << aPickedIter << " - name: " << aName <<"\n";
|
||||
ViewerTest::Display (aName, aShapePrs, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
TheAISContext()->UpdateCurrentViewer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -6550,24 +6138,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: Alias for vtexture name -default.",
|
||||
VTexture,group);
|
||||
|
||||
theCommands.Add("vsetam",
|
||||
"vsetam [shapename] mode"
|
||||
"\n\t\t: Activates selection mode for all selected or named shapes."
|
||||
"\n\t\t: Mod can be:"
|
||||
"\n\t\t: 0 - for shape itself"
|
||||
"\n\t\t: 1 - vertices"
|
||||
"\n\t\t: 2 - edges"
|
||||
"\n\t\t: 3 - wires"
|
||||
"\n\t\t: 4 - faces"
|
||||
"\n\t\t: 5 - shells"
|
||||
"\n\t\t: 6 - solids"
|
||||
"\n\t\t: 7 - compounds"
|
||||
__FILE__,VActivatedMode,group);
|
||||
|
||||
theCommands.Add("vunsetam",
|
||||
"vunsetam : Deactivates all selection modes for all shapes.",
|
||||
__FILE__,VActivatedMode,group);
|
||||
|
||||
theCommands.Add("vstate",
|
||||
"vstate [-entities] [-hasSelected] [name1] ... [nameN]"
|
||||
"\n\t\t: Reports show/hidden state for selected or named objects"
|
||||
@ -6576,8 +6146,10 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
__FILE__,VState,group);
|
||||
|
||||
theCommands.Add("vpickshapes",
|
||||
"vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]",
|
||||
__FILE__,VPickShape,group);
|
||||
"vpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]"
|
||||
"\n\t\t: Hold Ctrl and pick object by clicking Left mouse button."
|
||||
"\n\t\t: Hold also Shift for multiple selection.",
|
||||
__FILE__, VPickShape, group);
|
||||
|
||||
theCommands.Add("vtypes",
|
||||
"vtypes : list of known types and signatures in AIS - To be Used in vpickobject command for selection with filters",
|
||||
|
@ -106,22 +106,6 @@ public:
|
||||
Handle(TopTools_HArray1OfShape)& thepicked,
|
||||
const Standard_Integer MaxPick = 5);
|
||||
|
||||
//! waits until an interactive object of a given Type
|
||||
//! and signature is picked (default values authorize
|
||||
//! selection of any Interactive Object)
|
||||
//! exit if number of unsuccessful picks = <MaxPick>
|
||||
Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type = AIS_KOI_None,
|
||||
const Standard_Integer Signature = -1,
|
||||
const Standard_Integer MaxPick = 5);
|
||||
|
||||
//! selection of several interactive objects.
|
||||
//! Number is given by the size of <thepicked>
|
||||
//! exit if number of unsuccesfull picks = <MaxPick>
|
||||
Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked,
|
||||
const AIS_KindOfInteractive Type = AIS_KOI_None,
|
||||
const Standard_Integer Signature = -1,
|
||||
const Standard_Integer MaxPick = 5);
|
||||
|
||||
Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
|
||||
|
||||
Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
|
||||
@ -166,8 +150,6 @@ public:
|
||||
|
||||
Standard_EXPORT static void RemoveSelected();
|
||||
|
||||
Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
|
||||
|
||||
Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
|
||||
|
||||
//! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
|
||||
|
@ -1724,9 +1724,30 @@ void VT_ProcessKeyPress (const char* buf_ret)
|
||||
else
|
||||
{
|
||||
// Number
|
||||
Standard_Integer Num = Draw::Atoi(buf_ret);
|
||||
if(Num>=0 && Num<=7)
|
||||
ViewerTest::StandardModeActivation(Num);
|
||||
const Standard_Integer aSelMode = Draw::Atoi(buf_ret);
|
||||
if (aSelMode >= 0 && aSelMode <= 7)
|
||||
{
|
||||
bool toEnable = true;
|
||||
if (const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext())
|
||||
{
|
||||
AIS_ListOfInteractive aPrsList;
|
||||
aCtx->DisplayedObjects (aPrsList);
|
||||
for (AIS_ListOfInteractive::Iterator aPrsIter (aPrsList); aPrsIter.More() && toEnable; aPrsIter.Next())
|
||||
{
|
||||
TColStd_ListOfInteger aModes;
|
||||
aCtx->ActivatedModes (aPrsIter.Value(), aModes);
|
||||
for (TColStd_ListOfInteger::Iterator aModeIter (aModes); aModeIter.More() && toEnable; aModeIter.Next())
|
||||
{
|
||||
if (aModeIter.Value() == aSelMode)
|
||||
{
|
||||
toEnable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TCollection_AsciiString aCmd = TCollection_AsciiString ("vselmode ") + aSelMode + (toEnable ? " 1" : " 0");
|
||||
Draw_Interprete (aCmd.ToCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,13 +531,6 @@ static Standard_Integer mdisplay
|
||||
di << "The context is null\n";
|
||||
else
|
||||
{
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
if (aContext->HasOpenedContext())
|
||||
{
|
||||
aContext->CloseLocalContext();
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
aContext->Display (aMesh, Standard_True);
|
||||
}
|
||||
}
|
||||
@ -561,13 +554,6 @@ static Standard_Integer merase
|
||||
di << "The context is null\n";
|
||||
else
|
||||
{
|
||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||
if (aContext->HasOpenedContext())
|
||||
{
|
||||
aContext->CloseLocalContext();
|
||||
}
|
||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
aContext->Erase (aMesh, Standard_True);
|
||||
}
|
||||
}
|
||||
|
@ -29,21 +29,19 @@ vdump $imagedir/${casename}_h_pres.png
|
||||
|
||||
# Activate the local selection by edges and hilight small circle edge.
|
||||
# It's discretization should coincide with discretization of whole shape hiligting.
|
||||
vsetam 2
|
||||
vselmode p -set EDGE 1
|
||||
vmoveto 130 80
|
||||
vdump $imagedir/${casename}_local_h_pres.png
|
||||
|
||||
vunsetam
|
||||
|
||||
# Explode object on faces
|
||||
explode p F
|
||||
# Create colored shape: set another color to one face
|
||||
vaspects p -subshapes p_3 -setcolor RED
|
||||
|
||||
vsetam 0
|
||||
vselmode p -set 0 1
|
||||
vmoveto 100 100
|
||||
vdump $imagedir/${casename}_h_sub_pres.png
|
||||
|
||||
vsetam 2
|
||||
vselmode p -set EDGE 1
|
||||
vmoveto 130 80
|
||||
vdump $imagedir/${casename}_local_h_sub_pres.png
|
||||
|
@ -17,9 +17,6 @@
|
||||
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#if OCC_VERSION_HEX < 0x060901
|
||||
#include <AIS_LocalContext.hxx>
|
||||
#endif
|
||||
#include <AIS_Selection.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_Trihedron.hxx>
|
||||
@ -224,23 +221,11 @@ void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveCo
|
||||
|
||||
theContext->UnhilightSelected(Standard_False);
|
||||
|
||||
//TODO: processing in local context only
|
||||
#if OCC_VERSION_HEX < 0x060901
|
||||
Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
|
||||
TCollection_AsciiString aSelectionName = aLContext->SelectionName();
|
||||
aLContext->UnhilightPicked(Standard_False);
|
||||
#endif
|
||||
|
||||
for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(theOwners);
|
||||
anOwnersIt.More(); anOwnersIt.Next())
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
|
||||
#if OCC_VERSION_HEX > 0x060901
|
||||
theContext->AddOrRemoveSelected (anOwner, Standard_False);
|
||||
#else
|
||||
AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
|
||||
anOwner->SetSelected(Standard_True);
|
||||
#endif
|
||||
}
|
||||
theContext->UpdateCurrentViewer();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user