mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
2
src/SelectMgr/FILES
Executable file
2
src/SelectMgr/FILES
Executable file
@@ -0,0 +1,2 @@
|
||||
SelectMgr_DataMapOfObjectOwners.hxx
|
||||
SelectMgr_CompareResults.hxx
|
273
src/SelectMgr/SelectMgr.cdl
Executable file
273
src/SelectMgr/SelectMgr.cdl
Executable file
@@ -0,0 +1,273 @@
|
||||
-- File: SelectMgr.cdl
|
||||
-- Created: Mon Feb 6 14:08:38 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
package SelectMgr
|
||||
|
||||
---Purpose: SelectMgr manages the process of dynamic
|
||||
-- selection through the following services:
|
||||
-- - activating and deactivating selection modes for Interactive Objects
|
||||
-- - adding and removing viewer selectors
|
||||
-- - definitions of abstract filter classes
|
||||
-- The principle of graphic selection consists in
|
||||
-- representing the objects which you want to select
|
||||
-- by a bounding box in the selection view. The object
|
||||
-- is selected when you use the mouse to designate
|
||||
-- the zone produced by the object.
|
||||
-- To realize this, the application creates a selection
|
||||
-- structure which is independent of the point of view.
|
||||
-- This structure is made up of sensitive primitives
|
||||
-- which have one owner object associated to each of
|
||||
-- them. The role of the sensitive primitive is to reply
|
||||
-- to the requests of the selection algorithm whereas
|
||||
-- the owner's purpose is to make the link between
|
||||
-- the sensitive primitive and the object to be selected.
|
||||
-- Each selection structure corresponds to a selection
|
||||
-- mode which defines the elements that can be selected.
|
||||
-- For example, to select a complete geometric model,
|
||||
-- the application can create a sensitive primitive for
|
||||
-- each face of the interactive object representing the
|
||||
-- geometric model. In this case, all the primitives
|
||||
-- share the same owner. On the other hand, to select
|
||||
-- an edge in a model, the application must create
|
||||
-- one sensitive primitive per edge.
|
||||
-- Example
|
||||
-- void
|
||||
-- InteractiveBox::ComputeSelection
|
||||
-- (const Handle(SelectMgr_Selection)& Sel,
|
||||
-- const Standard_Integer Mode){ switch(Mode){ case 0:
|
||||
-- // locating the whole box by making its faces sensitive ...
|
||||
-- {
|
||||
-- Handle(SelectMgr_EntityOwner)
|
||||
-- Ownr = new
|
||||
-- SelectMgr_EntityOwner(this,5);
|
||||
-- for(Standard_Integer
|
||||
-- I=1;I<=Nbfaces;I++){Sel->Add(new Select3D_SensitiveFace
|
||||
-- (Ownr,[array of the vertices] face I);
|
||||
-- break;
|
||||
-- }
|
||||
-- case 1: // locates the edges
|
||||
-- {
|
||||
-- for(Standard_Integer
|
||||
-- i=1;i<=12;i++){
|
||||
-- // 1 owner per edge...
|
||||
-- Handle(mypk_EdgeOwner)
|
||||
-- Ownr = new
|
||||
-- mypk_EdgeOwner(this,i,6);
|
||||
-- // 6->priority
|
||||
-- Sel->Add(new
|
||||
-- Select3D_SensitiveSegment
|
||||
-- (Ownr,firstpt(i),lastpt(i));
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
-- The algorithms for creating selection structures
|
||||
-- store the sensitive primitives in a
|
||||
-- SelectMgr_Selection object. To do this, a set of
|
||||
-- ready-made sensitive primitives is supplied in the
|
||||
-- Select2D and Select3D packages. New sensitive
|
||||
-- primitives can be defined through inheritance
|
||||
-- from SensitiveEntity. For the application to make
|
||||
-- its own objects selectable, it must define owner
|
||||
-- classes inheriting SelectMgr_EntityOwner.
|
||||
-- For any object inheriting from
|
||||
-- AIS_InteractiveObject, you redefine its
|
||||
-- ComputeSelection functions. In the example below
|
||||
-- there are different modes of selection on the
|
||||
-- topological shape contained within the interactive
|
||||
-- object -selection of the shape itself, the vertices,
|
||||
-- the edges, the wires, the faces.
|
||||
-- Example
|
||||
-- void
|
||||
-- MyPack_MyClass::ComputeSelection(
|
||||
-- const Handle(SelectMgr_Selection)& aSelection,
|
||||
-- const Standard_Integer aMode)
|
||||
-- {
|
||||
-- switch(aMode){
|
||||
-- case 0:
|
||||
-- StdSelect_BRepSelectionTool::Load(
|
||||
-- aSelection,this,myShape,TopAbs_SHAPE);
|
||||
-- break;
|
||||
-- }
|
||||
-- case 1:
|
||||
-- StdSelect_BRepSelectionTool::Load(
|
||||
-- aSelection,this,myShape,TopAbs_VERTEX);
|
||||
-- break;
|
||||
-- }
|
||||
-- case 2:
|
||||
-- StdSelect_BRepSelectionTool::Load(
|
||||
-- aSelection,this,myShape,TopAbs_EDGE);
|
||||
-- break;
|
||||
-- }
|
||||
-- case 3:
|
||||
-- StdSelect_BRepSelectionTool::Load(
|
||||
-- aSelection,this,myShape,TopAbs_WIRE);
|
||||
-- break;
|
||||
-- }
|
||||
-- case 4:
|
||||
-- StdSelect_BRepSelectionTool::Load(
|
||||
-- aSelection,this,myShape,TopAbs_FACE);
|
||||
-- break;
|
||||
-- }
|
||||
-- }
|
||||
-- The StdSelect_BRepSelectionTool object
|
||||
-- provides a high level service which will make the
|
||||
-- shape 'myShape' selectable when the
|
||||
-- AIS_InteractiveContext is asked to display your object.
|
||||
-- Note: The traditional way of highlighting selected entity
|
||||
-- owners adopted by the Open CASCADE library assumes that
|
||||
-- each entity owner highlights itself on its own. This approach
|
||||
-- has two drawbacks:
|
||||
-- - each entity owner has to maintain its own
|
||||
-- Prs3d_Presentation object, that results in
|
||||
-- large memory overhead for thousands of owners;
|
||||
-- - drawing selected owners one by one is not
|
||||
-- efficient from the OpenGL usage viewpoint.
|
||||
-- That is why a different method has been introduced. On the basis of
|
||||
-- SelectMgr_EntityOwner::IsAutoHilight() return value an AIS_LocalContext
|
||||
-- object either uses the traditional way of highlighting
|
||||
-- (IsAutoHilight() returned true) or groups such owners according
|
||||
-- to their Selectable Objects and finally calls
|
||||
-- SelectMgr_SelectableObject::HilightSelected()
|
||||
-- or ClearSelected(), passing a group of owners as an argument.
|
||||
-- Hence, an application can derive its own interactive object and
|
||||
-- redefine HilightSelected(), ClearSelected() and
|
||||
-- HilightOwnerWithColor() virtual methods to take advantage of
|
||||
-- such OpenGL technique as arrays of primitives. In any case,
|
||||
-- these methods should at least have empty implementation.
|
||||
-- The AIS_LocalContext::UpdateSelected(const Handle(AIS_InteratciveObject)&,
|
||||
-- Standard_Boolean) method can be used for efficient redrawing a
|
||||
-- selection presentation for a given interactive object from an
|
||||
-- application code.
|
||||
-- Additionally, the SelectMgr_SelectableObject::ClearSelections()
|
||||
-- method now accepts an optional boolean argument. This parameter
|
||||
-- defines whether all object selections should be flagged for
|
||||
-- further update or not. This improved method can be used to
|
||||
-- re-compute an object selection (without redisplaying the object
|
||||
-- completely) when some selection mode is activated not for the first time.
|
||||
|
||||
uses
|
||||
Standard,
|
||||
MMgt,
|
||||
TCollection,
|
||||
TColStd,
|
||||
TColgp,
|
||||
Quantity,
|
||||
Bnd,
|
||||
TopLoc,
|
||||
TopAbs,
|
||||
TopoDS,
|
||||
SelectBasics,
|
||||
PrsMgr,
|
||||
Prs3d,
|
||||
Graphic3d
|
||||
|
||||
|
||||
is
|
||||
|
||||
enumeration StateOfSelection is
|
||||
SOS_Activated,
|
||||
SOS_Deactivated,
|
||||
SOS_Sleeping,
|
||||
SOS_Any,
|
||||
SOS_Unknown;
|
||||
---Purpose: different state of a Selection in a ViewerSelector...
|
||||
|
||||
|
||||
enumeration TypeOfUpdate is TOU_Full,TOU_Partial,TOU_None;
|
||||
---Purpose: Provides values for types of update, including
|
||||
-- - full
|
||||
-- - partial
|
||||
-- - none.
|
||||
deferred class SelectableObject;
|
||||
|
||||
deferred class ViewerSelector;
|
||||
---Purpose: class selector dedicated to a view ;
|
||||
-- contains all the sensitive Entities present
|
||||
-- in a view at selection time
|
||||
|
||||
|
||||
deferred class Filter;
|
||||
|
||||
deferred class CompositionFilter;
|
||||
|
||||
class AndFilter;
|
||||
---Purpose: AND filter
|
||||
|
||||
class OrFilter;
|
||||
---Purpose: OR filter
|
||||
|
||||
|
||||
|
||||
class EntityOwner;
|
||||
---Purpose: Inherits EntityOwner from SelectBasics;
|
||||
-- knows the selectable object it was made from;
|
||||
--
|
||||
|
||||
|
||||
class Selection;
|
||||
---Purpose: set of primitives for a mode an an Object;
|
||||
-- In fact a Selectable Object will have one or many
|
||||
-- modes of selection or decomposition;
|
||||
-- A Selection object will contain all the primitives
|
||||
-- coming from one decomposition.
|
||||
|
||||
|
||||
|
||||
class SelectionManager;
|
||||
---Purpose: manages all the Operations before selection -
|
||||
-- i.e. add specific selections for an object in a selectionview
|
||||
|
||||
|
||||
|
||||
|
||||
---Category: instantiations of classes from TCollection...
|
||||
|
||||
class SequenceOfFilter instantiates Sequence from TCollection
|
||||
(Filter from SelectMgr);
|
||||
|
||||
class ListOfFilter instantiates List from TCollection
|
||||
(Filter from SelectMgr);
|
||||
|
||||
class SequenceOfOwner instantiates Sequence from TCollection
|
||||
(EntityOwner from SelectMgr);
|
||||
|
||||
class IndexedMapOfOwner instantiates IndexedMap from TCollection
|
||||
(EntityOwner from SelectMgr,MapTransientHasher from TColStd);
|
||||
|
||||
class DataMapOfIntegerSensitive instantiates DataMap from TCollection
|
||||
(Integer, SensitiveEntity from SelectBasics,
|
||||
MapIntegerHasher from TColStd);
|
||||
|
||||
class SequenceOfSelector instantiates Sequence from TCollection
|
||||
(ViewerSelector);
|
||||
|
||||
class SequenceOfSelection instantiates Sequence from TCollection
|
||||
(Selection);
|
||||
|
||||
|
||||
class DataMapOfSelectionActivation instantiates DataMap from TCollection
|
||||
(Selection,Integer,MapTransientHasher from TColStd);
|
||||
|
||||
class DataMapOfObjectSelectors instantiates DataMap from TCollection
|
||||
(SelectableObject,SequenceOfSelector,MapTransientHasher from TColStd);
|
||||
|
||||
private class IndexedDataMapOfOwnerCriterion
|
||||
instantiates IndexedDataMap from TCollection
|
||||
(EntityOwner from SelectBasics,
|
||||
SortCriterion from SelectMgr,
|
||||
MapTransientHasher from TColStd);
|
||||
|
||||
private class SortCriterion;
|
||||
|
||||
pointer SOPtr to SelectableObject from SelectMgr;
|
||||
|
||||
imported CompareResults;
|
||||
---Purpose: Redefine CompareOfInteger from TCollection, to be used
|
||||
-- in method SortResult from class ViewerSelector
|
||||
|
||||
end SelectMgr;
|
29
src/SelectMgr/SelectMgr_AndFilter.cdl
Executable file
29
src/SelectMgr/SelectMgr_AndFilter.cdl
Executable file
@@ -0,0 +1,29 @@
|
||||
-- File: AndFilter.cdl
|
||||
-- Created: Mon Dec 4 17:45:11 1995
|
||||
-- Author: Stephane MORTAUD
|
||||
-- <smo@gibson>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class AndFilter from SelectMgr inherits CompositionFilter from SelectMgr
|
||||
|
||||
---Purpose: A framework to define a selection filter for two or
|
||||
-- more types of entity.
|
||||
|
||||
uses
|
||||
|
||||
Filter from SelectMgr,
|
||||
Transient from Standard,
|
||||
Boolean from Standard,
|
||||
EntityOwner from SelectMgr
|
||||
is
|
||||
|
||||
Create
|
||||
returns mutable AndFilter from SelectMgr;
|
||||
--- Purpose: Constructs an empty selection filter object for two or
|
||||
-- more types of entity.
|
||||
|
||||
IsOk(me; anobj :EntityOwner from SelectMgr)
|
||||
returns Boolean from Standard ;
|
||||
|
||||
end AndFilter;
|
18
src/SelectMgr/SelectMgr_AndFilter.cxx
Executable file
18
src/SelectMgr/SelectMgr_AndFilter.cxx
Executable file
@@ -0,0 +1,18 @@
|
||||
#include <SelectMgr_AndFilter.ixx>
|
||||
|
||||
#include <SelectMgr_Filter.hxx>
|
||||
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
|
||||
|
||||
SelectMgr_AndFilter::SelectMgr_AndFilter()
|
||||
{
|
||||
}
|
||||
Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
|
||||
{
|
||||
SelectMgr_ListIteratorOfListOfFilter it(myFilters);
|
||||
for ( ; it.More();it.Next())
|
||||
if(!it.Value()->IsOk(anobj))
|
||||
return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
46
src/SelectMgr/SelectMgr_CompareResults.hxx
Executable file
46
src/SelectMgr/SelectMgr_CompareResults.hxx
Executable file
@@ -0,0 +1,46 @@
|
||||
// File: SelectMgr_CompareResults.hxx
|
||||
// Created: 23.10.03 20:31:03
|
||||
// Author: Alexander GRIGORIEV
|
||||
// Copyright: Open Cascade 2003
|
||||
|
||||
#include <SelectMgr_IndexedDataMapOfOwnerCriterion.hxx>
|
||||
#include <SelectMgr_SortCriterion.hxx>
|
||||
#include <TCollection_CompareOfInteger.hxx>
|
||||
|
||||
class SelectMgr_CompareResults: public TCollection_CompareOfInteger
|
||||
{
|
||||
public:
|
||||
SelectMgr_CompareResults
|
||||
(const SelectMgr_IndexedDataMapOfOwnerCriterion& aMapOfCriterion)
|
||||
: myMapOfCriterion (aMapOfCriterion) {}
|
||||
Standard_Boolean IsLower
|
||||
(const Standard_Integer&, const Standard_Integer&) const;
|
||||
Standard_Boolean IsGreater
|
||||
(const Standard_Integer&, const Standard_Integer&) const;
|
||||
private:
|
||||
const SelectMgr_IndexedDataMapOfOwnerCriterion& myMapOfCriterion;
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLower
|
||||
//purpose : The sort order should be inverse (the greatest to come first)
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean SelectMgr_CompareResults::IsLower
|
||||
(const Standard_Integer &Left,const Standard_Integer &Right) const
|
||||
{
|
||||
return (myMapOfCriterion.FindFromIndex(Left) >
|
||||
myMapOfCriterion.FindFromIndex(Right));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsGreater
|
||||
//purpose : The sort order should be inverse (the greatest to come first)
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean SelectMgr_CompareResults::IsGreater
|
||||
(const Standard_Integer &Left,const Standard_Integer &Right) const
|
||||
{
|
||||
return (myMapOfCriterion.FindFromIndex(Left) <
|
||||
myMapOfCriterion.FindFromIndex(Right));
|
||||
}
|
47
src/SelectMgr/SelectMgr_CompositionFilter.cdl
Executable file
47
src/SelectMgr/SelectMgr_CompositionFilter.cdl
Executable file
@@ -0,0 +1,47 @@
|
||||
-- File: SelectMgr_CompositionFilter.cdl
|
||||
-- Created: Mon Jan 29 17:47:00 1996
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@fidox>
|
||||
---Copyright: Matra Datavision 1996
|
||||
|
||||
|
||||
|
||||
deferred class CompositionFilter from SelectMgr inherits Filter from SelectMgr
|
||||
---Purpose: A framework to define a compound filter composed of
|
||||
-- two or more simple filters.
|
||||
|
||||
uses
|
||||
Boolean from Standard,
|
||||
ListOfFilter from SelectMgr,
|
||||
ShapeEnum from TopAbs
|
||||
is
|
||||
|
||||
Add(me : mutable; afilter : Filter from SelectMgr);
|
||||
--- Purpose: Adds the filter afilter to a filter object created by a
|
||||
-- filter class inheriting this framework.
|
||||
Remove(me:mutable;aFilter : Filter from SelectMgr);
|
||||
|
||||
--- Purpose: Removes the filter aFilter from this framework.
|
||||
IsEmpty(me) returns Boolean;
|
||||
---Purpose: Returns true if this framework is empty.
|
||||
IsIn(me;aFilter : Filter from SelectMgr)
|
||||
returns Boolean;
|
||||
|
||||
--- Purpose: Returns true if the filter aFilter is in this framework.
|
||||
|
||||
StoredFilters(me) returns ListOfFilter from SelectMgr;
|
||||
---C++: return const &
|
||||
---C++: inline
|
||||
---Purpose: Returns the list of stored filters from this framework.
|
||||
|
||||
Clear(me:mutable);
|
||||
---Purpose: Clears the filters used in this framework.
|
||||
ActsOn(me; aStandardMode : ShapeEnum from TopAbs)
|
||||
returns Boolean from Standard is redefined virtual;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myFilters : ListOfFilter from SelectMgr is protected;
|
||||
|
||||
end CompositionFilter;
|
57
src/SelectMgr/SelectMgr_CompositionFilter.cxx
Executable file
57
src/SelectMgr/SelectMgr_CompositionFilter.cxx
Executable file
@@ -0,0 +1,57 @@
|
||||
// File: SelectMgr_CompositionFilter.cxx
|
||||
// Created: Mon Jan 29 17:49:34 1996
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@fidox>
|
||||
|
||||
|
||||
#include <SelectMgr_CompositionFilter.ixx>
|
||||
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
|
||||
|
||||
void SelectMgr_CompositionFilter::Add(const Handle(SelectMgr_Filter)& afilter)
|
||||
{
|
||||
myFilters.Append(afilter);
|
||||
}
|
||||
|
||||
void SelectMgr_CompositionFilter::Remove(const Handle(SelectMgr_Filter)& afilter)
|
||||
{
|
||||
SelectMgr_ListIteratorOfListOfFilter It(myFilters);
|
||||
for(;It.More();It.Next()){
|
||||
if (afilter==It.Value()){
|
||||
myFilters.Remove(It);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_CompositionFilter::IsEmpty() const
|
||||
{
|
||||
return myFilters.IsEmpty();
|
||||
}
|
||||
|
||||
Standard_Boolean SelectMgr_CompositionFilter::IsIn(const Handle(SelectMgr_Filter)& afilter) const
|
||||
{
|
||||
SelectMgr_ListIteratorOfListOfFilter It(myFilters);
|
||||
for(;It.More();It.Next())
|
||||
if (afilter==It.Value())
|
||||
return Standard_True;
|
||||
return Standard_False;
|
||||
|
||||
}
|
||||
|
||||
void SelectMgr_CompositionFilter::Clear()
|
||||
{
|
||||
myFilters.Clear();
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_CompositionFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const
|
||||
{
|
||||
SelectMgr_ListIteratorOfListOfFilter It(myFilters);
|
||||
for(;It.More();It.Next()){
|
||||
if (It.Value()->ActsOn(aStandardMode))
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
9
src/SelectMgr/SelectMgr_CompositionFilter.lxx
Executable file
9
src/SelectMgr/SelectMgr_CompositionFilter.lxx
Executable file
@@ -0,0 +1,9 @@
|
||||
// File: SelectMgr_CompositionFilter.lxx
|
||||
// Created: Tue Jan 21 15:05:42 1997
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
inline const SelectMgr_ListOfFilter& SelectMgr_CompositionFilter::
|
||||
StoredFilters() const
|
||||
{return myFilters;}
|
26
src/SelectMgr/SelectMgr_DataMapOfObjectOwners.hxx
Executable file
26
src/SelectMgr/SelectMgr_DataMapOfObjectOwners.hxx
Executable file
@@ -0,0 +1,26 @@
|
||||
// File: SelectMgr_DataMapOfObjectOwners.hxx
|
||||
// Created: 16.10.2003
|
||||
// Author: Alexander Solovyov
|
||||
|
||||
#ifndef _SelectMgr_DataMapOfObjectOwners_HeaderFile
|
||||
#define _SelectMgr_DataMapOfObjectOwners_HeaderFile
|
||||
|
||||
#include <NCollection_DefineDataMap.hxx>
|
||||
#include <Handle_SelectMgr_SelectableObject.hxx>
|
||||
#include <SelectMgr_SequenceOfOwner.hxx>
|
||||
|
||||
inline Standard_Boolean IsEqual (const Handle_SelectMgr_SelectableObject& theH1,
|
||||
const Handle_SelectMgr_SelectableObject& theH2)
|
||||
{
|
||||
return (theH1 == theH2);
|
||||
}
|
||||
|
||||
DEFINE_BASECOLLECTION(SelectMgr_CollectionOfSequenceOfOwner, SelectMgr_SequenceOfOwner)
|
||||
DEFINE_DATAMAP(SelectMgr_DataMapOfObjectOwners, SelectMgr_CollectionOfSequenceOfOwner,
|
||||
Handle(SelectMgr_SelectableObject), SelectMgr_SequenceOfOwner)
|
||||
|
||||
typedef SelectMgr_DataMapOfObjectOwners::Iterator
|
||||
SelectMgr_DataMapIteratorOfMapOfObjectOwners;
|
||||
|
||||
|
||||
#endif
|
142
src/SelectMgr/SelectMgr_EntityOwner.cdl
Executable file
142
src/SelectMgr/SelectMgr_EntityOwner.cdl
Executable file
@@ -0,0 +1,142 @@
|
||||
-- File: SelectMgr_EntityOwner.cdl
|
||||
-- Created: Tue May 23 10:01:09 1995
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@photon>
|
||||
--Modified by rob October 25 97 store locations...
|
||||
--
|
||||
-- jun 17 98 : Add virtual methods HasShape, GetShape.
|
||||
-- by default return False and Null Shape...
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
|
||||
class EntityOwner from SelectMgr inherits EntityOwner from SelectBasics
|
||||
|
||||
---Purpose: A framework to define classes of owners of sensitive primitives.
|
||||
-- The owner is the link between application and
|
||||
-- selection data structures.
|
||||
-- For the application to make its own objects selectable,
|
||||
-- it must define owner classes inheriting this framework.
|
||||
--
|
||||
|
||||
uses
|
||||
SelectableObject from SelectMgr,
|
||||
SOPtr from SelectMgr,
|
||||
NameOfColor from Quantity,
|
||||
Location from TopLoc,
|
||||
PresentationManager from PrsMgr,
|
||||
PresentationManager3d from PrsMgr
|
||||
|
||||
raises
|
||||
NoSuchObject from Standard
|
||||
is
|
||||
|
||||
Create (aPriority: Integer = 0) returns mutable EntityOwner from SelectMgr;
|
||||
--- Purpose: Initializes the selection priority aPriority.
|
||||
Create (aSO : SelectableObject;
|
||||
aPriority : Integer=0)
|
||||
returns mutable EntityOwner from SelectMgr;
|
||||
---Purpose: Constructs a framework with the selectable object
|
||||
-- anSO being attributed the selection priority aPriority.
|
||||
|
||||
HasSelectable(me) returns Boolean from Standard;
|
||||
---Purpose: Returns true if there is a selectable object to serve as an owner.
|
||||
|
||||
Selectable(me) returns any SelectableObject from SelectMgr
|
||||
---Purpose: Returns a selectable object detected in the working context.
|
||||
raises NoSuchObject from Standard
|
||||
is static;
|
||||
|
||||
Set(me:mutable; aSO : SelectableObject) is static;
|
||||
---Purpose: Sets the selectable object anSO to be used by the
|
||||
-- second constructor above.
|
||||
|
||||
---Category: hilight of the owner when detected...
|
||||
-- the following virtual methods have a default
|
||||
-- implementation which acts on stored selectable
|
||||
-- if it exists. else does nothing.
|
||||
-- WARNING: if methods are redefined in inheriting
|
||||
-- classes :
|
||||
-- if the hilight methods don't use presentable objects
|
||||
-- YOU MUST :
|
||||
-- 1) ask The presentationManager if it is in
|
||||
-- immediate mode
|
||||
-- 2) if it is, add your presentation to
|
||||
-- the immediate list of presentation manager.
|
||||
--
|
||||
|
||||
Hilight(me:mutable) is virtual;
|
||||
---Purpose: Provides a framework to highlight any selectable
|
||||
-- object found subsequently which can serve as an
|
||||
-- owner of a sensitive primitive.
|
||||
IsHilighted (me ;
|
||||
aPM : PresentationManager from PrsMgr;
|
||||
aMode : Integer from Standard =0)
|
||||
returns Boolean from Standard is virtual;
|
||||
---Purpose: Returns true if the presentation manager aPM
|
||||
-- highlights selections corresponding to the selection mode aMode.
|
||||
|
||||
Hilight(me : mutable;
|
||||
aPM : PresentationManager from PrsMgr;
|
||||
aMode : Integer from Standard =0) is virtual;
|
||||
---Purpose: Highlights the owner of a detected selectable object in
|
||||
-- the presentation manager aPM. This object could be
|
||||
-- the owner of a sensitive primitive.
|
||||
-- The display mode for the highlight is aMode; this has
|
||||
-- the default value of 0, that is, wireframe mode.
|
||||
|
||||
HilightWithColor (me : mutable;
|
||||
aPM : PresentationManager3d from PrsMgr;
|
||||
aColor: NameOfColor from Quantity;
|
||||
aMode : Integer from Standard =0) is virtual;
|
||||
|
||||
Unhilight(me : mutable;
|
||||
aPM : PresentationManager from PrsMgr;
|
||||
aMode : Integer from Standard =0) is virtual;
|
||||
---Purpose: Removes highlighting from the owner of a detected
|
||||
-- selectable object in the presentation manager aPM.
|
||||
-- This object could be the owner of a sensitive primitive.
|
||||
-- The display mode for the highlight is aMode; this has
|
||||
-- the default value of 0, that is, wireframe mode.
|
||||
|
||||
Clear(me: mutable;
|
||||
aPM : PresentationManager from PrsMgr;
|
||||
aMode : Integer from Standard =0) is virtual;
|
||||
---Purpose: Clears the owners matching the value of the selection
|
||||
-- mode aMode from the presentation manager object aPM.
|
||||
|
||||
---Category: internal methods for location on objects...
|
||||
-- Default implementations of HasLocation() and Location() rely on
|
||||
-- location obtained from <mySelectable> field, to minimize memory usage.
|
||||
-- SetLocation() and ResetLocation() do nothing by default.
|
||||
HasLocation(me) returns Boolean from Standard is redefined;
|
||||
SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined;
|
||||
ResetLocation(me:mutable) is redefined;
|
||||
Location(me) returns Location from TopLoc is redefined;
|
||||
---C++: return const&
|
||||
|
||||
|
||||
|
||||
--very Internal method (to be used in selection process only...)
|
||||
|
||||
State(me:mutable;aStatus:Integer from Standard);
|
||||
---C++: inline
|
||||
State(me) returns Integer from Standard;
|
||||
---C++: inline
|
||||
|
||||
IsAutoHilight ( me ) returns Boolean from Standard is virtual;
|
||||
---Purpose: if owner is not auto hilighted, for group contains many such owners
|
||||
-- will be called one method HilightSelected of SelectableObject
|
||||
|
||||
IsForcedHilight ( me ) returns Boolean from Standard is virtual;
|
||||
---Purpose: if this method returns TRUE the owner will allways call method
|
||||
-- Hilight for SelectableObject when the owner is detected. By default
|
||||
-- it always return FALSE.
|
||||
|
||||
fields
|
||||
|
||||
mySelectable : SOPtr;
|
||||
mystate : Integer from Standard;
|
||||
|
||||
end EntityOwner;
|
136
src/SelectMgr/SelectMgr_EntityOwner.cxx
Executable file
136
src/SelectMgr/SelectMgr_EntityOwner.cxx
Executable file
@@ -0,0 +1,136 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectMgr_EntityOwner.cxx
|
||||
// Created: Tue May 23 10:18:48 1995
|
||||
// Author: Robert COUBLANC
|
||||
// <rob>
|
||||
|
||||
|
||||
|
||||
#include <SelectMgr_EntityOwner.ixx>
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function:
|
||||
// Purpose :
|
||||
//==================================================
|
||||
SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Standard_Integer aPriority):
|
||||
SelectBasics_EntityOwner(aPriority),
|
||||
mySelectable(NULL),
|
||||
mystate(0)
|
||||
{
|
||||
}
|
||||
|
||||
SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO,
|
||||
const Standard_Integer aPriority):
|
||||
SelectBasics_EntityOwner(aPriority),
|
||||
mystate(0)
|
||||
{
|
||||
mySelectable = aSO.operator->();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : About Selectable...
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_EntityOwner::Set(const Handle(SelectMgr_SelectableObject)& aSO)
|
||||
{
|
||||
mySelectable = aSO.operator->();
|
||||
}
|
||||
|
||||
Standard_Boolean SelectMgr_EntityOwner::HasSelectable() const
|
||||
{
|
||||
Handle(Standard_Transient) aNull;
|
||||
if(mySelectable != aNull.operator->()){
|
||||
if(!Selectable().IsNull()) return Standard_True;}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(SelectMgr_SelectableObject) SelectMgr_EntityOwner::Selectable() const
|
||||
{
|
||||
return mySelectable;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : about Hilight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_EntityOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& PM,
|
||||
const Standard_Integer aMode) const
|
||||
{if(HasSelectable())
|
||||
return PM->IsHighlighted(mySelectable,aMode);
|
||||
return Standard_False;
|
||||
}
|
||||
void SelectMgr_EntityOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
|
||||
const Standard_Integer aMode)
|
||||
{if(HasSelectable())
|
||||
PM->Highlight(mySelectable,aMode);
|
||||
}
|
||||
|
||||
void SelectMgr_EntityOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager3d)& PM,
|
||||
const Quantity_NameOfColor aColor,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
if( HasSelectable() )
|
||||
if( IsAutoHilight() )
|
||||
PM->Color(mySelectable,aColor,aMode);
|
||||
else
|
||||
mySelectable->HilightOwnerWithColor( PM, aColor, this );
|
||||
}
|
||||
|
||||
void SelectMgr_EntityOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
if(HasSelectable())
|
||||
PM->Unhighlight(mySelectable,aMode);
|
||||
}
|
||||
|
||||
void SelectMgr_EntityOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
// nothing done on the selectable here...
|
||||
}
|
||||
|
||||
|
||||
void SelectMgr_EntityOwner::
|
||||
Hilight(){}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : about Location
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean SelectMgr_EntityOwner::HasLocation() const
|
||||
{
|
||||
return (HasSelectable() && mySelectable->HasLocation());
|
||||
}
|
||||
|
||||
void SelectMgr_EntityOwner::SetLocation(const TopLoc_Location&)
|
||||
{
|
||||
}
|
||||
|
||||
const TopLoc_Location& SelectMgr_EntityOwner::Location() const
|
||||
{
|
||||
static TopLoc_Location anIdentity;
|
||||
return HasSelectable() ? mySelectable->Location() : anIdentity;
|
||||
}
|
||||
|
||||
void SelectMgr_EntityOwner::ResetLocation()
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean SelectMgr_EntityOwner::IsAutoHilight () const
|
||||
{
|
||||
if ( mySelectable==0 )
|
||||
return Standard_True;
|
||||
else
|
||||
return mySelectable->IsAutoHilight();
|
||||
}
|
||||
|
||||
Standard_Boolean SelectMgr_EntityOwner::IsForcedHilight () const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
10
src/SelectMgr/SelectMgr_EntityOwner.lxx
Executable file
10
src/SelectMgr/SelectMgr_EntityOwner.lxx
Executable file
@@ -0,0 +1,10 @@
|
||||
// File: SelectMgr_EntityOwner.lxx
|
||||
// Created: Wed Jun 17 11:49:40 1998
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
inline Standard_Integer SelectMgr_EntityOwner::State() const
|
||||
{return mystate;}
|
||||
|
||||
inline void SelectMgr_EntityOwner::State(const Standard_Integer aStatus)
|
||||
{mystate = aStatus;}
|
50
src/SelectMgr/SelectMgr_Filter.cdl
Executable file
50
src/SelectMgr/SelectMgr_Filter.cdl
Executable file
@@ -0,0 +1,50 @@
|
||||
-- File: SelectMgr_Filter.cdl
|
||||
-- Created: Wed Mar 5 13:51:25 1997
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@robox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
deferred class Filter from SelectMgr inherits TShared from MMgt
|
||||
|
||||
---Purpose: The root class to define filter objects for selection.
|
||||
-- Advance handling of objects requires the services of
|
||||
-- filters. These only allow dynamic detection and
|
||||
-- selection of objects which correspond to the criteria defined in each.
|
||||
-- Eight standard filters inheriting SelectMgr_Filter are
|
||||
-- defined in Open CASCADE.
|
||||
-- You can create your own filters by defining new filter
|
||||
-- classes inheriting this framework. You use these
|
||||
-- filters by loading them into an AIS interactive context.
|
||||
|
||||
uses
|
||||
EntityOwner from SelectMgr,
|
||||
ShapeEnum from TopAbs
|
||||
is
|
||||
IsOk(me; anObj : EntityOwner from SelectMgr)
|
||||
returns Boolean from Standard
|
||||
is deferred;
|
||||
---Purpose: Indicates that the selected Interactive Object
|
||||
-- passes the filter. The owner, anObj, can be either
|
||||
-- direct or user. A direct owner is the corresponding
|
||||
-- construction element, whereas a user is the
|
||||
-- compound shape of which the entity forms a part.
|
||||
-- When an object is detected by the mouse - in AIS,
|
||||
-- this is done through a context selector - its owner
|
||||
-- is passed to the filter as an argument.
|
||||
-- If the object returns Standard_True, it is kept; if
|
||||
-- not, it is rejected.
|
||||
-- If you are creating a filter class inheriting this
|
||||
-- framework, and the daughter class is to be used in
|
||||
-- an AIS local context, you will need to implement the
|
||||
-- virtual function ActsOn.
|
||||
|
||||
ActsOn(me; aStandardMode : ShapeEnum from TopAbs)
|
||||
returns Boolean from Standard is virtual;
|
||||
---Purpose: Returns true in an AIS local context, if this filter
|
||||
-- operates on a type of subshape defined in a filter
|
||||
-- class inheriting this framework.
|
||||
-- This function completes IsOk in an AIS local context.
|
||||
|
||||
|
||||
end Filter;
|
11
src/SelectMgr/SelectMgr_Filter.cxx
Executable file
11
src/SelectMgr/SelectMgr_Filter.cxx
Executable file
@@ -0,0 +1,11 @@
|
||||
// File: SelectMgr_Filter.cxx
|
||||
// Created: Wed Mar 5 15:50:45 1997
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <SelectMgr_Filter.ixx>
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_Filter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const
|
||||
{return Standard_False;}
|
27
src/SelectMgr/SelectMgr_OrFilter.cdl
Executable file
27
src/SelectMgr/SelectMgr_OrFilter.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: OrFilter.cdl
|
||||
-- Created: Mon Dec 4 17:45:11 1995
|
||||
-- Author: Stephane MORTAUD
|
||||
-- <smo@gibson>
|
||||
--last modifs by rob 29-01-96 : heritage de CompositionFilter
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class OrFilter from SelectMgr inherits CompositionFilter from SelectMgr
|
||||
|
||||
---Purpose: A framework to define an or selection filter.
|
||||
-- This selects one or another type of sensitive entity.
|
||||
uses
|
||||
|
||||
Filter from SelectMgr,
|
||||
Transient from Standard,
|
||||
EntityOwner from SelectMgr
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns mutable OrFilter from SelectMgr;
|
||||
---Purpose: Constructs an empty or selection filter.
|
||||
IsOk(me; anobj : EntityOwner from SelectMgr)
|
||||
returns Boolean from Standard ;
|
||||
|
||||
end OrFilter;
|
20
src/SelectMgr/SelectMgr_OrFilter.cxx
Executable file
20
src/SelectMgr/SelectMgr_OrFilter.cxx
Executable file
@@ -0,0 +1,20 @@
|
||||
#include <SelectMgr_OrFilter.ixx>
|
||||
|
||||
#include <SelectMgr_Filter.hxx>
|
||||
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
|
||||
SelectMgr_OrFilter::SelectMgr_OrFilter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_OrFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
|
||||
{
|
||||
|
||||
if(myFilters.IsEmpty())
|
||||
return Standard_True;
|
||||
SelectMgr_ListIteratorOfListOfFilter it(myFilters);
|
||||
for ( ; it.More();it.Next())
|
||||
if(it.Value()->IsOk(anobj))
|
||||
return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
188
src/SelectMgr/SelectMgr_SelectableObject.cdl
Executable file
188
src/SelectMgr/SelectMgr_SelectableObject.cdl
Executable file
@@ -0,0 +1,188 @@
|
||||
-- File: SelectMgr_SelectableOject.cdl
|
||||
-- Created: Mon Feb 20 17:39:48 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
|
||||
deferred class SelectableObject from SelectMgr inherits PresentableObject from PrsMgr
|
||||
|
||||
---Purpose: A framework to supply the structure of the object to be
|
||||
-- selected. At the first pick, this structure is created by
|
||||
-- calling the appropriate algorithm and retaining this
|
||||
-- framework for further picking.
|
||||
-- This abstract framework is inherited in Application
|
||||
-- Interactive Services (AIS), notably in AIS_InteractiveObject.
|
||||
-- Consequently, 3D selection should be handled by the
|
||||
-- relevant daughter classes and their member functions
|
||||
-- in AIS. This is particularly true in the creation of new interactive objects.
|
||||
|
||||
|
||||
uses
|
||||
|
||||
SelectionManager from SelectMgr,
|
||||
Selection from SelectMgr,
|
||||
SequenceOfSelection from SelectMgr,
|
||||
TypeOfPresentation3d from PrsMgr,
|
||||
Presentation from Prs3d,
|
||||
PresentationManager3d from PrsMgr,
|
||||
SequenceOfOwner from SelectMgr,
|
||||
NameOfColor from Quantity,
|
||||
EntityOwner from SelectMgr,
|
||||
TransModeFlags from Graphic3d
|
||||
|
||||
raises
|
||||
NotImplemented from Standard
|
||||
|
||||
is
|
||||
|
||||
|
||||
---Category: deferred Methods
|
||||
|
||||
|
||||
Initialize(aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView);
|
||||
|
||||
ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr;
|
||||
aMode : Integer) is deferred private;
|
||||
---Purpose: Recovers and calculates any sensitive primitive,
|
||||
-- aSelection, available in Shape mode, specified by
|
||||
-- aMode. As a rule, these are sensitive faces.
|
||||
-- This method is defined as virtual. This enables you to
|
||||
-- implement it in the creation of a new class of AIS
|
||||
-- Interactive Object. You need to do this and in so
|
||||
-- doing, redefine this method, if you create a class
|
||||
-- which enriches the list of signatures and types.
|
||||
|
||||
NbPossibleSelection(me) returns Integer from Standard is virtual;
|
||||
---Level: Public
|
||||
---Purpose: defines the number of different modes of selection
|
||||
-- (or decomposition) for an Object.
|
||||
|
||||
|
||||
|
||||
---Category:
|
||||
|
||||
|
||||
UpdateSelection (me:mutable) is static;
|
||||
---Purpose: re-computes the sensitive primitives for all modes
|
||||
|
||||
UpdateSelection (me:mutable; aMode: Integer from Standard) is static;
|
||||
---Purpose: re-computes the sensitive primitives which correspond to
|
||||
-- the <amode>th selection mode.
|
||||
|
||||
|
||||
AddSelection(me:mutable ;aSelection:mutable Selection from SelectMgr;
|
||||
aMode : Integer)
|
||||
is static;
|
||||
---Purpose: Adds the selection aSelection with the selection mode
|
||||
-- index aMode to this framework.
|
||||
|
||||
|
||||
ClearSelections(me:mutable; update: Boolean from Standard = Standard_False) is static;
|
||||
---Level: Public
|
||||
---Purpose: Empties all the selections in the SelectableObject
|
||||
-- <update> parameter defines whether all object's
|
||||
-- selections should be flagged for further update or not.
|
||||
-- This improved method can be used to recompute an
|
||||
-- object's selection (without redisplaying the object
|
||||
-- completely) when some selection mode is activated not for the first time.
|
||||
|
||||
Selection(me;aMode : Integer)
|
||||
returns any Selection from SelectMgr
|
||||
is static;
|
||||
---C++: return const&
|
||||
---Purpose: Returns the selection Selection having the selection mode aMode.
|
||||
|
||||
HasSelection(me; aMode: Integer)
|
||||
returns Boolean from Standard is static ;
|
||||
--- Purpose: Returns true if a selection corresponding to the
|
||||
-- selection mode aMode is present in this framework.
|
||||
|
||||
|
||||
|
||||
Init(me:mutable) is static;
|
||||
---Purpose: Begins the iteration scanning for sensitive primitives.
|
||||
---C++: inline
|
||||
|
||||
|
||||
More(me) returns Boolean is static;
|
||||
---Purpose: Continues the iteration scanning for sensitive primitives.
|
||||
---C++: inline
|
||||
|
||||
|
||||
|
||||
Next(me:mutable) is static;
|
||||
---Purpose: Continues the iteration scanning for sensitive primitives.
|
||||
---C++: inline
|
||||
|
||||
|
||||
|
||||
CurrentSelection(me) returns any Selection from SelectMgr;
|
||||
---Purpose: Returns the current selection in this framework.
|
||||
---C++: return const&
|
||||
---C++: inline
|
||||
|
||||
|
||||
ResetLocation(me:mutable) is redefined static;
|
||||
|
||||
UpdateLocation(me:mutable) is redefined virtual;
|
||||
---Purpose: Recomputes the location of the selection aSelection.
|
||||
|
||||
UpdateLocation(me:mutable;aSelection: Selection from SelectMgr) is virtual protected;
|
||||
---Level: Internal
|
||||
---Purpose: Updates locations in all sensitive entities from <aSelection>
|
||||
-- and in corresponding entity owners.
|
||||
|
||||
HilightSelected ( me : mutable; PM : PresentationManager3d from PrsMgr;
|
||||
Seq : SequenceOfOwner from SelectMgr ) raises NotImplemented from Standard is virtual;
|
||||
---Purpose: Method which draws selected owners ( for fast presentation draw )
|
||||
|
||||
ClearSelected ( me : mutable ) is virtual;
|
||||
---Purpose: Method which clear all selected owners belonging
|
||||
-- to this selectable object ( for fast presentation draw )
|
||||
|
||||
HilightOwnerWithColor ( me : mutable; thePM : PresentationManager3d from PrsMgr;
|
||||
theColor : NameOfColor from Quantity;
|
||||
theOwner : EntityOwner from SelectMgr ) raises NotImplemented from Standard is virtual;
|
||||
---Purpose: Method which hilight an owner belonging to
|
||||
-- this selectable object ( for fast presentation draw )
|
||||
|
||||
IsAutoHilight ( me ) returns Boolean from Standard is virtual;
|
||||
---Purpose: If returns True, the old mechanism for highlighting
|
||||
-- selected objects is used (HilightSelected Method may be empty).
|
||||
-- If returns False, the HilightSelected method will be
|
||||
-- fully responsible for highlighting selected entity
|
||||
-- owners belonging to this selectable object.
|
||||
|
||||
SetAutoHilight ( me : mutable; newAutoHilight : Boolean from Standard ) is virtual;
|
||||
---Purpose: Set AutoHilight property to true or false
|
||||
|
||||
-- SetTransformPersistence( me : mutable;
|
||||
-- aFlag : TransModeFlags from Graphic3d ) is redefined;
|
||||
---Level: Public
|
||||
---Purpose: Sets up Transform Persistence Mode for this object
|
||||
---Category: Graphic attributes management
|
||||
|
||||
GetHilightPresentation( me: mutable;
|
||||
TheMgr: PresentationManager3d from PrsMgr ) returns Presentation from Prs3d is static;
|
||||
|
||||
GetSelectPresentation( me: mutable;
|
||||
TheMgr: PresentationManager3d from PrsMgr ) returns Presentation from Prs3d is static;
|
||||
|
||||
fields
|
||||
|
||||
myselections : SequenceOfSelection is protected;
|
||||
mycurrent : Integer;
|
||||
myAutoHilight : Boolean from Standard;
|
||||
|
||||
mySelectionPrs : Presentation from Prs3d;
|
||||
myHilightPrs : Presentation from Prs3d;
|
||||
|
||||
friends
|
||||
class SelectionManager from SelectMgr
|
||||
|
||||
end SelectableObject;
|
||||
|
||||
|
||||
|
305
src/SelectMgr/SelectMgr_SelectableObject.cxx
Executable file
305
src/SelectMgr/SelectMgr_SelectableObject.cxx
Executable file
@@ -0,0 +1,305 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectMgr_SelectableObject.cxx
|
||||
// Created: Mon Feb 20 17:40:49 1995
|
||||
// Author: Mister rmi
|
||||
// <rmi>
|
||||
|
||||
|
||||
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
#include <SelectMgr_SelectableObject.ixx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Select3D_SensitiveEntity.hxx>
|
||||
#include <SelectBasics_EntityOwner.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq,
|
||||
const Handle (SelectMgr_Selection)& theSel)
|
||||
{
|
||||
Standard_Integer ifound=0;
|
||||
for (Standard_Integer i=1;i<=seq.Length()&& ifound==0;i++)
|
||||
{if(theSel == seq.Value(i)) ifound=i;}
|
||||
return ifound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function:
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
SelectMgr_SelectableObject::SelectMgr_SelectableObject( const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):PrsMgr_PresentableObject(aTypeOfPresentation3d)
|
||||
{
|
||||
myAutoHilight = Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function:
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
Standard_Boolean SelectMgr_SelectableObject
|
||||
::HasSelection(const Standard_Integer aMode) const
|
||||
{
|
||||
Standard_Boolean Found=Standard_False;
|
||||
for (Standard_Integer I=1;I<= myselections.Length() && !Found;I++)
|
||||
{ if(((myselections.Value(I))->Mode())==aMode)
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: UpdateSelection
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectableObject::UpdateSelection()
|
||||
{
|
||||
for (Standard_Integer I=1;I<=myselections.Length();I++)
|
||||
{
|
||||
UpdateSelection(myselections.ChangeValue(I)->Mode());
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer SelectMgr_SelectableObject::NbPossibleSelection() const
|
||||
{return 0;}
|
||||
|
||||
//==================================================
|
||||
// Function: UpdateSelection
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectableObject::UpdateSelection(const Standard_Integer aMode)
|
||||
{
|
||||
for (Standard_Integer i =1; i<= myselections.Length(); i++ ) {
|
||||
if (myselections.Value(i)->Mode() == aMode) {
|
||||
myselections(i)->Clear();
|
||||
ComputeSelection(myselections(i),aMode);
|
||||
myselections(i)->UpdateStatus(SelectMgr_TOU_Partial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Handle(SelectMgr_Selection) S = new SelectMgr_Selection(aMode);
|
||||
ComputeSelection(S,aMode);
|
||||
S->UpdateStatus(SelectMgr_TOU_Partial);
|
||||
|
||||
myselections.Append(S);
|
||||
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: ClearSelections
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean update)
|
||||
{
|
||||
for (Standard_Integer i =1; i<= myselections.Length(); i++ ) {
|
||||
myselections.Value(i)->Clear();
|
||||
if(update)
|
||||
myselections.Value(i)->UpdateStatus(SelectMgr_TOU_Full);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Selection
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
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++)
|
||||
{
|
||||
if((myselections.Value(i))->Mode()==aMode){ Found = Standard_True;
|
||||
Rank=i;}}
|
||||
return myselections.Value(Rank);
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: AddSelection
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectableObject
|
||||
::AddSelection(const Handle(SelectMgr_Selection)& aSel,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
if(aSel->IsEmpty()){
|
||||
ComputeSelection(aSel,aMode);
|
||||
aSel->UpdateStatus(SelectMgr_TOU_Partial);
|
||||
}
|
||||
if(HasSelection(aMode))
|
||||
{
|
||||
const Handle(SelectMgr_Selection)& temp= Selection(aMode);
|
||||
Standard_Integer I = Search(myselections,temp);
|
||||
if(I!=0) myselections.Remove(I);
|
||||
}
|
||||
myselections.Append(aSel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReSetLocation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::ResetLocation()
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
|
||||
|
||||
// les selections
|
||||
Handle(Select3D_SensitiveEntity) SE;
|
||||
for(Init();More();Next()){
|
||||
const Handle(SelectMgr_Selection) & Sel = CurrentSelection();
|
||||
for(Sel->Init();Sel->More();Sel->Next()){
|
||||
SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive()));
|
||||
if(!SE.IsNull()){
|
||||
if(SE->HasLocation())
|
||||
if( SE->Location()==myLocation){
|
||||
SE->ResetLocation();
|
||||
const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId();
|
||||
(*((Handle(SelectMgr_EntityOwner)*)&EO))->ResetLocation();}
|
||||
else{
|
||||
const TopLoc_Location& iniloc =SE->Location();
|
||||
SE->SetLocation(iniloc*myLocation.Inverted());
|
||||
const Handle(SelectBasics_EntityOwner)& EO = SE->OwnerId();
|
||||
(*((Handle(SelectMgr_EntityOwner)*)&EO))->SetLocation(SE->Location());}
|
||||
|
||||
}
|
||||
}
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
}
|
||||
|
||||
PrsMgr_PresentableObject::ResetLocation();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateLocation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::UpdateLocation()
|
||||
{
|
||||
|
||||
Handle(Select3D_SensitiveEntity) SE;
|
||||
for(Init();More();Next()){
|
||||
const Handle(SelectMgr_Selection) & Sel = CurrentSelection();
|
||||
Sel->UpdateStatus(SelectMgr_TOU_Partial);
|
||||
}
|
||||
PrsMgr_PresentableObject::UpdateLocation();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateLocation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
|
||||
{
|
||||
Handle(Select3D_SensitiveEntity) SE;
|
||||
if(myLocation.IsIdentity()) return;
|
||||
for(Sel->Init();Sel->More();Sel->Next()){
|
||||
SE = *((Handle(Select3D_SensitiveEntity)*) &(Sel->Sensitive()));
|
||||
if(!SE.IsNull()){
|
||||
SE->UpdateLocation(myLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightSelected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::HilightSelected
|
||||
( const Handle(PrsMgr_PresentationManager3d)&,
|
||||
const SelectMgr_SequenceOfOwner&)
|
||||
{
|
||||
Standard_NotImplemented::Raise ("SelectMgr_SelectableObject::HilightSelected");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearSelected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::ClearSelected ()
|
||||
{
|
||||
//Standard_NotImplemented::Raise ("SelectMgr_SelectableObject::HilightOwnerWithColor");
|
||||
if( !mySelectionPrs.IsNull() )
|
||||
mySelectionPrs->Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightOwnerWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::HilightOwnerWithColor
|
||||
( const Handle(PrsMgr_PresentationManager3d)&,
|
||||
const Quantity_NameOfColor,
|
||||
const Handle(SelectMgr_EntityOwner)&)
|
||||
{
|
||||
Standard_NotImplemented::Raise ("SelectMgr_SelectableObject::HilightOwnerWithColor");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MaxFaceNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight () const
|
||||
{
|
||||
return myAutoHilight;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MaxFaceNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAutoHilight )
|
||||
{
|
||||
myAutoHilight = newAutoHilight;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetHilightPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation( const Handle(PrsMgr_PresentationManager3d)& TheMgr )
|
||||
{
|
||||
if( myHilightPrs.IsNull() && !TheMgr.IsNull() )
|
||||
{
|
||||
myHilightPrs = new Prs3d_Presentation( TheMgr->StructureManager() );
|
||||
myHilightPrs->SetTransformPersistence( GetTransformPersistenceMode(),
|
||||
GetTransformPersistencePoint() );
|
||||
}
|
||||
|
||||
return myHilightPrs;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetSelectPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation( const Handle(PrsMgr_PresentationManager3d)& TheMgr )
|
||||
{
|
||||
if( mySelectionPrs.IsNull() && !TheMgr.IsNull() ) {
|
||||
mySelectionPrs = new Prs3d_Presentation( TheMgr->StructureManager() );
|
||||
mySelectionPrs->SetTransformPersistence( GetTransformPersistenceMode(),
|
||||
GetTransformPersistencePoint() );
|
||||
}
|
||||
return mySelectionPrs;
|
||||
}
|
||||
|
14
src/SelectMgr/SelectMgr_SelectableObject.lxx
Executable file
14
src/SelectMgr/SelectMgr_SelectableObject.lxx
Executable file
@@ -0,0 +1,14 @@
|
||||
inline void SelectMgr_SelectableObject::Init()
|
||||
{mycurrent=1;}
|
||||
|
||||
inline Standard_Boolean SelectMgr_SelectableObject::More() const
|
||||
{return (mycurrent<=myselections.Length());}
|
||||
|
||||
inline void SelectMgr_SelectableObject::Next()
|
||||
{mycurrent++;}
|
||||
|
||||
inline const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::
|
||||
CurrentSelection() const
|
||||
{return myselections(mycurrent);}
|
||||
|
||||
|
135
src/SelectMgr/SelectMgr_Selection.cdl
Executable file
135
src/SelectMgr/SelectMgr_Selection.cdl
Executable file
@@ -0,0 +1,135 @@
|
||||
-- File: SelectMgr_Selection.cdl
|
||||
-- Created: Mon Feb 6 17:43:28 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
class Selection from SelectMgr inherits TShared from MMgt
|
||||
|
||||
---Purpose: Represents the state of a given selection mode for a
|
||||
-- Selectable Object. Contains all the sensitive entities available for this mode.
|
||||
-- An interactive object can have an indefinite number of
|
||||
-- modes of selection, each representing a
|
||||
-- "decomposition" into sensitive primitives; each
|
||||
-- primitive has an Owner (SelectMgr_EntityOwner)
|
||||
-- which allows us to identify the exact entity which has
|
||||
-- been detected. Each Selection mode is identified by
|
||||
-- an index. The set of sensitive primitives which
|
||||
-- correspond to a given mode is stocked in a
|
||||
-- SelectMgr_Selection object. By Convention, the
|
||||
-- default selection mode which allows us to grasp the
|
||||
-- Interactive object in its entirety will be mode 0.
|
||||
-- AIS_Trihedron : 4 selection modes
|
||||
-- - mode 0 : selection of a trihedron
|
||||
-- - mode 1 : selection of the origin of the trihedron
|
||||
-- - mode 2 : selection of the axes
|
||||
-- - mode 3 : selection of the planes XOY, YOZ, XOZ
|
||||
-- when you activate one of modes 1 2 3 4 , you pick AIS objects of type:
|
||||
-- - AIS_Point
|
||||
-- - AIS_Axis (and information on the type of axis)
|
||||
-- - AIS_Plane (and information on the type of plane).
|
||||
-- AIS_PlaneTrihedron offers 3 selection modes:
|
||||
-- - mode 0 : selection of the whole trihedron
|
||||
-- - mode 1 : selection of the origin of the trihedron
|
||||
-- - mode 2 : selection of the axes - same remarks as for the Trihedron.
|
||||
-- AIS_Shape : 7 maximum selection modes, depending
|
||||
-- on the complexity of the shape :
|
||||
-- - mode 0 : selection of the AIS_Shape
|
||||
-- - mode 1 : selection of the vertices
|
||||
-- - mode 2 : selection of the edges
|
||||
-- - mode 3 : selection of the wires
|
||||
-- - mode 4 : selection of the faces
|
||||
-- - mode 5 : selection of the shells
|
||||
-- - mode 6 : selection of the constituent solids.
|
||||
|
||||
uses
|
||||
SensitiveEntity from SelectBasics,
|
||||
ListOfSensitive from SelectBasics,
|
||||
ListIteratorOfListOfSensitive from SelectBasics,
|
||||
TypeOfUpdate from SelectMgr
|
||||
|
||||
raises
|
||||
NullObject
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create (IdMode : Integer = 0) returns mutable Selection;
|
||||
--- Purpose: Constructs a selection object defined by the selection mode IdMode.
|
||||
-- The default setting 0 is the selection mode for a shape in its entirety.
|
||||
|
||||
Add (me : mutable;
|
||||
aprimitive : SensitiveEntity from SelectBasics)
|
||||
---Purpose: Adds the sensitive primitive aprimitive to the list of
|
||||
-- stored entities in this object.
|
||||
-- Raises NullObject if the primitive is a null handle.
|
||||
raises NullObject
|
||||
is static;
|
||||
|
||||
Clear(me :mutable) is static;
|
||||
---Purpose: empties the selection from all the stored entities
|
||||
|
||||
IsEmpty(me) returns Boolean is static;
|
||||
---Purpose: returns true if no sensitive entity is stored.
|
||||
|
||||
Mode (me) returns Integer;
|
||||
---Purpose: returns the selection mode represented by this selection
|
||||
---C++: inline
|
||||
|
||||
|
||||
---Category: get the sensitive entities inside the Selection
|
||||
|
||||
Init(me:mutable) is static;
|
||||
---Purpose: Begins an iteration scanning for sensitive primitives.
|
||||
---C++: inline
|
||||
|
||||
More(me) returns Boolean is static;
|
||||
---Purpose: Continues the iteration scanning for sensitive
|
||||
-- primitives with the mode defined in this framework.
|
||||
---C++: inline
|
||||
|
||||
|
||||
Next(me:mutable) is static;
|
||||
---Purpose: Returns the next sensitive primitive found in the
|
||||
-- iteration. This is a scan for entities with the mode
|
||||
-- defined in this framework.
|
||||
---C++: inline
|
||||
|
||||
Sensitive (me) returns any SensitiveEntity from SelectBasics is static;
|
||||
---Purpose: Returns any sensitive primitive in this framework.
|
||||
---C++: return const&
|
||||
---C++: inline
|
||||
|
||||
---Category: Internal Methods for Management
|
||||
--
|
||||
-- sets and gets the update status of a selection
|
||||
|
||||
|
||||
|
||||
UpdateStatus(me) returns TypeOfUpdate from SelectMgr;
|
||||
---C++: inline
|
||||
---Purpose: Returns the flag UpdateFlag.
|
||||
-- This flage gives the update status of this framework
|
||||
-- in a ViewerSelector object:
|
||||
-- - full
|
||||
-- - partial, or
|
||||
-- - none.
|
||||
|
||||
|
||||
UpdateStatus(me:mutable;UpdateFlag : TypeOfUpdate from SelectMgr);
|
||||
---C++: inline
|
||||
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
myentities : ListOfSensitive from SelectBasics;
|
||||
myit : ListIteratorOfListOfSensitive from SelectBasics;
|
||||
myMode : Integer from Standard;
|
||||
myUpdateStatus : TypeOfUpdate from SelectMgr;
|
||||
|
||||
|
||||
end Selection;
|
||||
|
||||
|
57
src/SelectMgr/SelectMgr_Selection.cxx
Executable file
57
src/SelectMgr/SelectMgr_Selection.cxx
Executable file
@@ -0,0 +1,57 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectMgr_Selection.cxx
|
||||
// Created: Thu Feb 16 10:20:29 1995
|
||||
// Author: Mister rmi
|
||||
// <rmi>
|
||||
|
||||
|
||||
|
||||
#include <SelectMgr_Selection.ixx>
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Create
|
||||
// Purpose :
|
||||
//==================================================
|
||||
SelectMgr_Selection
|
||||
::SelectMgr_Selection (const Standard_Integer IdMode):
|
||||
myMode(IdMode)
|
||||
{}
|
||||
//==================================================
|
||||
// Function: ADD
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_Selection
|
||||
::Add (const Handle(SelectBasics_SensitiveEntity)& aprimitive)
|
||||
{
|
||||
// if input is null:
|
||||
// in debug mode raise exception
|
||||
Standard_NullObject_Raise_if
|
||||
(aprimitive.IsNull(), "Null sensitive entity is added to the selection");
|
||||
// in release mode do not add
|
||||
if (!aprimitive.IsNull())
|
||||
myentities.Append(aprimitive);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Clear
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_Selection
|
||||
::Clear () {myentities.Clear();}
|
||||
|
||||
//==================================================
|
||||
// Function: IsEmpty
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean SelectMgr_Selection
|
||||
::IsEmpty() const
|
||||
{
|
||||
return myentities.IsEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
19
src/SelectMgr/SelectMgr_Selection.lxx
Executable file
19
src/SelectMgr/SelectMgr_Selection.lxx
Executable file
@@ -0,0 +1,19 @@
|
||||
inline Standard_Integer SelectMgr_Selection::Mode() const {return myMode;}
|
||||
|
||||
inline void SelectMgr_Selection::Init ()
|
||||
{myit.Initialize(myentities);}
|
||||
|
||||
inline Standard_Boolean SelectMgr_Selection::More() const
|
||||
{return myit.More();}
|
||||
|
||||
inline void SelectMgr_Selection::Next()
|
||||
{myit.Next();}
|
||||
|
||||
inline const Handle (SelectBasics_SensitiveEntity)& SelectMgr_Selection::Sensitive () const
|
||||
{return myit.Value();}
|
||||
|
||||
inline void SelectMgr_Selection::UpdateStatus(const SelectMgr_TypeOfUpdate TheStat)
|
||||
{myUpdateStatus = TheStat;}
|
||||
|
||||
inline SelectMgr_TypeOfUpdate SelectMgr_Selection::UpdateStatus() const
|
||||
{return myUpdateStatus;}
|
267
src/SelectMgr/SelectMgr_SelectionManager.cdl
Executable file
267
src/SelectMgr/SelectMgr_SelectionManager.cdl
Executable file
@@ -0,0 +1,267 @@
|
||||
-- File: SelectMgr_SelectionManager.cdl
|
||||
-- Created: Mon Feb 13 13:36:01 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
-- Modified by ROB : Wed Oct 98
|
||||
-- Add One Method : RecomputeSelection
|
||||
-- Modification of Update Method (just computes the
|
||||
-- flagged selections)
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class SelectionManager from SelectMgr inherits TShared from MMgt
|
||||
|
||||
---Purpose: A framework to manage selection from the point of
|
||||
-- view of viewer selectors. These can be added and
|
||||
-- removed, and selection modes can be activated and
|
||||
-- deactivated. In addition, objects may be known to all
|
||||
-- selectors or only to some.
|
||||
|
||||
uses
|
||||
AsciiString from TCollection,
|
||||
ViewerSelector from SelectMgr,
|
||||
SelectableObject from SelectMgr,
|
||||
CString from Standard,
|
||||
MapOfTransient from TColStd,
|
||||
TypeOfUpdate from SelectMgr,
|
||||
DataMapOfObjectSelectors from SelectMgr
|
||||
|
||||
|
||||
is
|
||||
|
||||
|
||||
Create returns mutable SelectionManager from SelectMgr;
|
||||
--- Purpose: Constructs an empty selection manager object.
|
||||
|
||||
---Category: Management of the view selectors
|
||||
|
||||
|
||||
Add (me:mutable ; aSelector :ViewerSelector from SelectMgr)is static;
|
||||
---Purpose: Adds the viewer selector aSelector to this framework.
|
||||
|
||||
Remove (me:mutable; aSelector :ViewerSelector from SelectMgr) is static;
|
||||
---Level: Public
|
||||
---Purpose:
|
||||
|
||||
Contains (me;aSelector :ViewerSelector from SelectMgr) returns Boolean is static;
|
||||
---Purpose:
|
||||
-- Returns true if this framework contains the viewer selector aSelector.
|
||||
|
||||
Contains(me;aSelectableObject: SelectableObject from SelectMgr) returns Boolean is static;
|
||||
---Purpose: Returns true if this framework contains the
|
||||
-- selectable object aSelectableObject.
|
||||
|
||||
|
||||
---Category: about Presentable Objects which want to be pickable...
|
||||
-- Loading Phase!!! No Mode Activation !
|
||||
|
||||
|
||||
Load(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr ;
|
||||
aMode : Integer =-1) is static;
|
||||
---Purpose: Loads and computes one mode of
|
||||
-- selection if <aMode> notequal -1 ;
|
||||
-- if <anObject> already has a
|
||||
-- selection with this mode, it's emptied and the sensitive
|
||||
-- entities are computed for this mode else one Selection
|
||||
-- is created with this mode before computing.
|
||||
|
||||
|
||||
|
||||
Load(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr ;
|
||||
aSelector : ViewerSelector from SelectMgr;
|
||||
aMode : Integer = -1 ) is static;
|
||||
---Purpose: Local object available for
|
||||
-- <aSelector> Only. the sensitive entities for selection
|
||||
-- of mode <aMode> are computed if <aMode> not equal -1.
|
||||
-- if <aMode> =-1 oc compute is done
|
||||
|
||||
|
||||
Remove(me:mutable; anObject:SelectableObject from SelectMgr) is static;
|
||||
---Level: Public
|
||||
---Purpose: removes the object from All the ViewerSelectors where it was;
|
||||
|
||||
|
||||
Remove(me:mutable; anObject :SelectableObject from SelectMgr;
|
||||
aSelector :ViewerSelector from SelectMgr) is static;
|
||||
---Level: Public
|
||||
---Purpose: removes the object from aSelector;
|
||||
|
||||
|
||||
|
||||
---Category: Activation/desactivation phase.....
|
||||
-- Activation of desired selection modes in active views
|
||||
-- all the combinations activate/desactivate a mode of selection for
|
||||
-- an object in a view, in all the views, ....
|
||||
|
||||
|
||||
|
||||
Activate(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aMode : Integer = 0;
|
||||
AutomaticProj: Boolean = Standard_True)
|
||||
is static;
|
||||
---Purpose: Activates the selection mode aMode in a selector
|
||||
-- for the selectable object anObject.
|
||||
|
||||
Activate(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aMode : Integer;
|
||||
aSelector : ViewerSelector from SelectMgr;
|
||||
AutomaticProj : Boolean = Standard_True) is static;
|
||||
---Purpose: Activates the selection mode aMode in the selector
|
||||
-- aSelector for the selectable object anObject.
|
||||
|
||||
Deactivate (me : mutable ;
|
||||
anObject : SelectableObject from SelectMgr);
|
||||
---Purpose: Deactivate all the activated modes in any
|
||||
-- Selector for <anObject>
|
||||
|
||||
|
||||
Deactivate (me : mutable ;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aMode : Integer) is static;
|
||||
---Level: Public
|
||||
---Purpose: Deactivates the Mode <aMode> in every Selector where
|
||||
-- it was activated
|
||||
|
||||
|
||||
Deactivate(me : mutable ;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aMode : Integer;
|
||||
aSelector : ViewerSelector from SelectMgr) is static;
|
||||
--- Purpose: Deactivates the selection mode aMode in the
|
||||
-- selector aSelector for the selectable object anObject.
|
||||
|
||||
|
||||
Deactivate(me : mutable ;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aSelector : ViewerSelector from SelectMgr) is static;
|
||||
---Purpose: Deactivates all selection modes in the selector
|
||||
-- aSelector for the selectable object anObject.
|
||||
|
||||
|
||||
Sleep (me:mutable; aSelector :ViewerSelector from SelectMgr) is static;
|
||||
---Purpose: Ensures that no object in the selector aSelector will be active.
|
||||
|
||||
|
||||
Sleep(me:mutable; anObject : SelectableObject from SelectMgr);
|
||||
---Level: Public
|
||||
---Purpose: the objet is temporarily deactivated everywhere it was activated.
|
||||
|
||||
Sleep(me:mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aSelector: ViewerSelector from SelectMgr)is static ;
|
||||
---Level: Public
|
||||
---Purpose: Different from Deactivate; this method
|
||||
-- deactivates the activated modes of an object,
|
||||
-- but just for a time; when the Awake Method is called
|
||||
-- the sleeping modes are reactivated.
|
||||
|
||||
|
||||
Awake (me : mutable;
|
||||
aSelector : ViewerSelector from SelectMgr;
|
||||
AutomaticProj : Boolean = Standard_True) is static;
|
||||
---Level: Public
|
||||
---Purpose: activates all the deactivated objects in a selector.
|
||||
|
||||
|
||||
Awake(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
AutomaticProj : Boolean = Standard_True) is static;
|
||||
|
||||
Awake (me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aSelector : ViewerSelector from SelectMgr;
|
||||
AutomaticProj : Boolean = Standard_True) is static;
|
||||
---Level: Public
|
||||
---Purpose: activates all the deactivated modes
|
||||
-- of an object in a selector
|
||||
|
||||
IsActivated(me;
|
||||
anObject : SelectableObject from SelectMgr)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns true if the selection is active for the selectable object anObject.
|
||||
|
||||
IsActivated(me;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aMode : Integer from Standard) returns Boolean from Standard;
|
||||
---Purpose: Returns true if the selection mode aMode is active for the selectable object anObject.
|
||||
|
||||
IsActivated(me;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aSelector : ViewerSelector from SelectMgr;
|
||||
aMode : Integer from Standard) returns Boolean from Standard;
|
||||
---Purpose: Returns true if the selection mode aMode is active for the selectable
|
||||
-- object anObject in the viewer selector aSelector.
|
||||
|
||||
|
||||
RecomputeSelection(me : mutable;
|
||||
anIObj : SelectableObject from SelectMgr;
|
||||
ForceUpdate : Boolean from Standard = Standard_False;
|
||||
aMode : Integer from Standard = -1);
|
||||
---Purpose: computes Selections in <anIObj> if they are
|
||||
-- activated in at least one Selector.
|
||||
-- puts a recompute flag in each selection which is not active.
|
||||
-- if <aMode>=-1 all the selection modes will have to be
|
||||
-- recomputed.
|
||||
-- if <ForceUpdate> = True, all selections are recomputed,
|
||||
-- even if they are not active.
|
||||
|
||||
|
||||
Update(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
ForceUpdate : Boolean from Standard = Standard_True) is static;
|
||||
---Level: Public
|
||||
---Purpose: updates the selectionModes of <anObject>
|
||||
-- According to
|
||||
-- . the stored type of update in each selection
|
||||
-- mode,
|
||||
-- . the activation status of each selection mode
|
||||
-- if <ForceUpdate> == True Recompute
|
||||
|
||||
Update(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aSelector : ViewerSelector from SelectMgr;
|
||||
ForceUpdate : Boolean from Standard = Standard_True) is static;
|
||||
---Level: Public
|
||||
|
||||
|
||||
SetUpdateMode(me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aType : TypeOfUpdate from SelectMgr) is static;
|
||||
|
||||
|
||||
SetUpdateMode(me :mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
aSelMode : Integer from Standard;
|
||||
aType : TypeOfUpdate from SelectMgr) is static;
|
||||
|
||||
|
||||
---Category: Internal Verification methods ...
|
||||
|
||||
Status (me) returns AsciiString from TCollection is static;
|
||||
|
||||
Status (me; anObject : SelectableObject from SelectMgr)
|
||||
returns AsciiString from TCollection is static;
|
||||
|
||||
LoadMode(me:mutable;anObject: SelectableObject from SelectMgr;aMode:Integer) is static private;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
-- myselectors : selectors dedicated to one particular view;
|
||||
-- myglobal : objects which will be selectable in all the views
|
||||
-- mylocal : objects with the selectors where they are selectable
|
||||
|
||||
|
||||
myselectors : MapOfTransient from TColStd;
|
||||
myglobal : MapOfTransient from TColStd;
|
||||
mylocal : DataMapOfObjectSelectors from SelectMgr;
|
||||
|
||||
|
||||
end SelectionManager;
|
||||
|
||||
|
||||
|
867
src/SelectMgr/SelectMgr_SelectionManager.cxx
Executable file
867
src/SelectMgr/SelectMgr_SelectionManager.cxx
Executable file
@@ -0,0 +1,867 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectMgr_SelectionManager.cxx
|
||||
// Created: Mon Feb 13 14:40:56 1995
|
||||
// Author: Mister rmi
|
||||
// <rmi>
|
||||
|
||||
|
||||
// Modified jmi/rob 29/8/96
|
||||
// appel de Loadmode dans Load d'un objet fait une seule fois.
|
||||
//
|
||||
|
||||
#include <SelectMgr_SelectionManager.ixx>
|
||||
#include <SelectMgr_ViewerSelector.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <SelectMgr_SequenceOfSelector.hxx>
|
||||
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
|
||||
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
|
||||
|
||||
static Standard_Boolean SelectDebugModeOnSM()
|
||||
{
|
||||
static Standard_Integer isDebugMode( -1 );
|
||||
if ( isDebugMode < 0 ) {
|
||||
isDebugMode = 1;
|
||||
OSD_Environment selectdb("SELECTIONDEBUG");
|
||||
if ( selectdb.Value().IsEmpty() )
|
||||
isDebugMode = 0;
|
||||
}
|
||||
return ( isDebugMode != 0 );
|
||||
}
|
||||
|
||||
static Standard_Integer SMSearch(const SelectMgr_SequenceOfSelector& seq,
|
||||
const Handle(SelectMgr_ViewerSelector)& theSel)
|
||||
{
|
||||
Standard_Integer ifound=0;
|
||||
for (Standard_Integer i=1;i<=seq.Length()&& ifound==0;i++)
|
||||
{if(theSel==seq.Value(i)) ifound=i;}
|
||||
return ifound;
|
||||
|
||||
}
|
||||
|
||||
// Unused :
|
||||
#ifdef DEB
|
||||
static Standard_Boolean SMListContains(const TColStd_ListOfInteger& LL,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
TColStd_ListIteratorOfListOfInteger LIt;
|
||||
for (LIt.Initialize(LL);LIt.More();LIt.Next())
|
||||
{if(LIt.Value()==aMode) return Standard_True;}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//==================================================
|
||||
// Function: Create
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
SelectMgr_SelectionManager::SelectMgr_SelectionManager()
|
||||
{}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Add
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Add (const Handle(SelectMgr_ViewerSelector)& aViewSel)
|
||||
{
|
||||
myselectors.Add(aViewSel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Remove
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Remove (const Handle(SelectMgr_ViewerSelector)& aViewSel)
|
||||
{
|
||||
SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors It(mylocal);
|
||||
for(;It.More();It.Next())
|
||||
{
|
||||
SelectMgr_SequenceOfSelector& theviews =mylocal.ChangeFind(It.Key());
|
||||
Standard_Integer rank = SMSearch(theviews,aViewSel);
|
||||
if(rank!=0 && rank<=theviews.Length()) theviews.Remove(rank);
|
||||
}
|
||||
if(myselectors.Contains(aViewSel)) myselectors.Remove(aViewSel);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Contains
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean SelectMgr_SelectionManager::
|
||||
Contains (const Handle(SelectMgr_ViewerSelector)& aViewSel) const
|
||||
{return myselectors.Contains(aViewSel);}
|
||||
|
||||
//==================================================
|
||||
// Function: Contains
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean SelectMgr_SelectionManager::
|
||||
Contains (const Handle(SelectMgr_SelectableObject)& aSelObj) const
|
||||
{if (myglobal.Contains(aSelObj)) return Standard_True;
|
||||
if (mylocal.IsBound(aSelObj)) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Load
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Load (const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer amode)
|
||||
{
|
||||
if(!myglobal.Contains(anObject))
|
||||
myglobal.Add(anObject);
|
||||
if(amode!=-1)
|
||||
LoadMode (anObject,amode);
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Load
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Load (const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& aview,
|
||||
const Standard_Integer amode)
|
||||
{
|
||||
if(!myselectors.Contains(aview)) myselectors.Add(aview);
|
||||
if(amode!=-1)
|
||||
LoadMode (anObject,amode);
|
||||
|
||||
|
||||
if (mylocal.IsBound(anObject)){
|
||||
SelectMgr_SequenceOfSelector& theviews = mylocal.ChangeFind(anObject);
|
||||
if (SMSearch(theviews,aview)==0) theviews.Append(aview);
|
||||
}
|
||||
else {
|
||||
if(!myglobal.Contains(anObject)){
|
||||
SelectMgr_SequenceOfSelector newviews;
|
||||
newviews.Append(aview);
|
||||
mylocal.Bind(anObject,newviews);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Remove
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Remove(const Handle(SelectMgr_SelectableObject)& anObject)
|
||||
{
|
||||
|
||||
if(myglobal.Contains(anObject)) {
|
||||
TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
for(;It.More();It.Next())
|
||||
{
|
||||
Handle(SelectMgr_ViewerSelector) curview =
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast(It.Key());
|
||||
if(curview->Contains(anObject)){
|
||||
for(anObject->Init();anObject->More();anObject->Next())
|
||||
{
|
||||
curview->Remove(anObject->CurrentSelection());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
myglobal.Remove(anObject);
|
||||
}
|
||||
|
||||
else if(mylocal.IsBound(anObject)) {
|
||||
SelectMgr_SequenceOfSelector& seq = mylocal.ChangeFind (anObject);
|
||||
for (Standard_Integer i=1;i<=seq.Length();i++) {
|
||||
Handle(SelectMgr_ViewerSelector) curview =
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast(seq(i));
|
||||
if(curview->Contains(anObject)){
|
||||
for(anObject->Init();anObject->More();anObject->Next())
|
||||
{
|
||||
curview->Remove(anObject->CurrentSelection());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mylocal.UnBind(anObject);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Remove
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Remove(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& aVS)
|
||||
{
|
||||
if(aVS->Contains(anObject)) {
|
||||
for(anObject->Init();anObject->More();anObject->Next()){
|
||||
aVS->Remove(anObject->CurrentSelection());
|
||||
}
|
||||
|
||||
|
||||
if(mylocal.IsBound(anObject)) {
|
||||
SelectMgr_SequenceOfSelector& seq = mylocal.ChangeFind (anObject);
|
||||
Standard_Boolean NotFound (Standard_True);
|
||||
for (Standard_Integer i=1;i<=seq.Length()&&NotFound;i++) {
|
||||
if(seq(i)== aVS){
|
||||
seq.Remove(i);
|
||||
NotFound =Standard_False;
|
||||
}
|
||||
}
|
||||
if(seq.IsEmpty())
|
||||
mylocal.UnBind(anObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Activate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Activate(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer aMode,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
if(aMode==-1) return;
|
||||
// Standard_Boolean global = Standard_False;
|
||||
if(!anObject->HasSelection(aMode)) LoadMode(anObject,aMode);
|
||||
|
||||
|
||||
if(myglobal.Contains(anObject)) {
|
||||
TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
|
||||
for(;It.More();It.Next()){
|
||||
Handle(SelectMgr_ViewerSelector) curview =
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast(It.Key());
|
||||
Activate(anObject,aMode,curview,AutomaticProj);
|
||||
}
|
||||
}
|
||||
|
||||
else if(mylocal.IsBound(anObject)) {
|
||||
SelectMgr_SequenceOfSelector& seq = mylocal.ChangeFind (anObject);
|
||||
for (Standard_Integer i=1;i<=seq.Length();i++) {
|
||||
Handle(SelectMgr_ViewerSelector) curview =
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast(seq(i));
|
||||
// ATTENTION : si la selection est a remettre a jour, on le fait la ....
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->Selection(aMode);
|
||||
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(aMode); // pas de break expres...
|
||||
case SelectMgr_TOU_Partial:
|
||||
{
|
||||
if(anObject->HasLocation())
|
||||
anObject->UpdateLocation(Sel);
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
break;
|
||||
}
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
curview->Activate(Sel,AutomaticProj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Activate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Activate(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer aMode,
|
||||
const Handle(SelectMgr_ViewerSelector)& aViewSel,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
if(aMode==-1) return;
|
||||
|
||||
if(!myselectors.Contains(aViewSel)) return;
|
||||
|
||||
if (!anObject->HasSelection(aMode)) LoadMode(anObject,aMode);
|
||||
|
||||
// ATTENTION : si la selection est a remettre a jour, on le fait la ....
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->Selection(aMode);
|
||||
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(aMode);
|
||||
case SelectMgr_TOU_Partial:
|
||||
{
|
||||
if(anObject->HasLocation())
|
||||
anObject->UpdateLocation(Sel);
|
||||
break;
|
||||
}
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
|
||||
if (myglobal.Contains(anObject))
|
||||
aViewSel->Activate (anObject->Selection(aMode));
|
||||
|
||||
else {
|
||||
if (mylocal.IsBound(anObject)) {
|
||||
if (SMSearch(mylocal.Find(anObject),aViewSel)==0)
|
||||
(mylocal.ChangeFind (anObject)).Append(aViewSel);
|
||||
aViewSel->Activate (anObject->Selection(aMode),AutomaticProj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Deactivate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Deactivate(const Handle(SelectMgr_SelectableObject)& anObject)
|
||||
{
|
||||
Standard_Boolean global = Standard_False;
|
||||
if(myglobal.Contains(anObject)) global = Standard_True;
|
||||
TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
Handle(SelectMgr_ViewerSelector) curview;
|
||||
for(;It.More();It.Next()){
|
||||
curview = Handle(SelectMgr_ViewerSelector)::DownCast(It.Key());
|
||||
if (global || mylocal.IsBound (anObject)) {
|
||||
for (anObject->Init();anObject->More();anObject->Next())
|
||||
{curview->Deactivate(anObject->CurrentSelection());}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Deactivate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Deactivate(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer amode)
|
||||
|
||||
{
|
||||
Standard_Boolean global = Standard_False;
|
||||
if(myglobal.Contains(anObject)) global = Standard_True;
|
||||
TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
Handle(SelectMgr_ViewerSelector) curview;
|
||||
for(;It.More();It.Next()){
|
||||
curview = Handle(SelectMgr_ViewerSelector)::DownCast(It.Key());
|
||||
if (global || mylocal.IsBound(anObject)) {
|
||||
if(anObject->HasSelection(amode))
|
||||
curview->Deactivate(anObject->Selection(amode));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Deactivate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Deactivate(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer aMode,
|
||||
const Handle(SelectMgr_ViewerSelector)& aViewSel)
|
||||
{
|
||||
if(myselectors.Contains(aViewSel))
|
||||
{
|
||||
if(myglobal.Contains(anObject)|| mylocal.IsBound(anObject))
|
||||
if(anObject->HasSelection(aMode))
|
||||
aViewSel->Deactivate (anObject->Selection(aMode));
|
||||
}
|
||||
|
||||
}
|
||||
//==================================================
|
||||
// Function: Deactivate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Deactivate(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& aViewSel)
|
||||
|
||||
{
|
||||
if(myselectors.Contains(aViewSel))
|
||||
{
|
||||
if(myglobal.Contains(anObject)|| mylocal.IsBound(anObject)) {
|
||||
for (anObject->Init();anObject->More();anObject->Next())
|
||||
{aViewSel->Deactivate(anObject->CurrentSelection());}}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Sleep
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Sleep (const Handle(SelectMgr_ViewerSelector)& aViewSel)
|
||||
{
|
||||
if (myselectors.Contains(aViewSel))
|
||||
aViewSel->Sleep();
|
||||
}
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
Sleep (const Handle(SelectMgr_SelectableObject)& anObject)
|
||||
{
|
||||
|
||||
if(myglobal.Contains(anObject)){
|
||||
for( TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
It.More();It.Next())
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast(It.Key())->Sleep(anObject);
|
||||
}
|
||||
else if(mylocal.IsBound(anObject)){
|
||||
const SelectMgr_SequenceOfSelector & VSeq = mylocal(anObject);
|
||||
for (Standard_Integer I=1;I<=VSeq.Length();I++)
|
||||
VSeq(I)->Sleep(anObject);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Sleep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Sleep(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& aViewSel)
|
||||
{
|
||||
if(!myselectors.Contains(aViewSel)) return;
|
||||
|
||||
if(!myglobal.Contains(anObject)){
|
||||
if(!mylocal.IsBound(anObject))
|
||||
return;
|
||||
if(SMSearch(mylocal(anObject),aViewSel)==0)
|
||||
return;
|
||||
}
|
||||
aViewSel->Sleep(anObject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Awake
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Awake (const Handle(SelectMgr_ViewerSelector)& aViewSel,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
if (myselectors.Contains(aViewSel))
|
||||
aViewSel->Awake(AutomaticProj);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Awake
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectionManager::Awake (const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
if(myglobal.Contains(anObject)){
|
||||
for( TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
It.More();It.Next())
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast( It.Key())->Awake(anObject,AutomaticProj);
|
||||
}
|
||||
else if(mylocal.IsBound(anObject)){
|
||||
const SelectMgr_SequenceOfSelector & VSeq = mylocal(anObject);
|
||||
for (Standard_Integer I=1;I<=VSeq.Length();I++)
|
||||
VSeq(I)->Awake(anObject,AutomaticProj);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Awake
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectionManager::Awake (const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& aViewSel,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
if(!myselectors.Contains(aViewSel)) return;
|
||||
|
||||
if(!myglobal.Contains(anObject)){
|
||||
if(!mylocal.IsBound(anObject))
|
||||
return;
|
||||
if(SMSearch(mylocal(anObject),aViewSel)==0)
|
||||
return;
|
||||
}
|
||||
aViewSel->Awake(anObject,AutomaticProj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsActivated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectionManager::IsActivated(const Handle(SelectMgr_SelectableObject)& anObject) const
|
||||
{
|
||||
for(anObject->Init();anObject->More();anObject->Next()){
|
||||
if(IsActivated(anObject,anObject->CurrentSelection()->Mode()))
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsActivated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectionManager::IsActivated(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer aMode) const
|
||||
{
|
||||
if(!anObject->HasSelection(aMode)) return Standard_False;
|
||||
if (!(myglobal.Contains(anObject) || mylocal.IsBound(anObject)))
|
||||
return Standard_False;
|
||||
|
||||
Handle(Standard_Transient) Tr;
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->Selection(aMode);
|
||||
for(TColStd_MapIteratorOfMapOfTransient It(myselectors);It.More();It.Next()){
|
||||
Tr = It.Key();
|
||||
Handle(SelectMgr_ViewerSelector) VS = *((Handle(SelectMgr_ViewerSelector)*)&Tr);
|
||||
if(VS->Status(Sel)==SelectMgr_SOS_Activated)
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsActivated
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SelectionManager::IsActivated(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& VS,
|
||||
const Standard_Integer aMode) const
|
||||
{
|
||||
if(!anObject->HasSelection(aMode))
|
||||
return Standard_False;
|
||||
if(!myselectors.Contains(VS))
|
||||
return Standard_False;
|
||||
if (!(myglobal.Contains(anObject) || mylocal.IsBound(anObject)))
|
||||
return Standard_False;
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->Selection(aMode);
|
||||
return (VS->Status(Sel)==SelectMgr_SOS_Activated);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Update
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
RecomputeSelection (const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Boolean ForceUpdate,
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
if( SelectDebugModeOnSM() ) cout<<"===>SelectMgr_SelectionManager::Update"<<endl;
|
||||
|
||||
if(ForceUpdate){
|
||||
if( SelectDebugModeOnSM() ) cout<<"\tRecalcul Complet des selections"<<endl;
|
||||
if(aMode==-1){
|
||||
anObject->UpdateSelection();
|
||||
anObject->UpdateLocation();
|
||||
}
|
||||
else if(anObject->HasSelection(aMode)){
|
||||
anObject->UpdateSelection(aMode);
|
||||
anObject->UpdateLocation();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// l'objet n'est pas connu du SMgr.
|
||||
if (!(myglobal.Contains(anObject) || mylocal.IsBound(anObject))){
|
||||
if( SelectDebugModeOnSM() ) {cout<<"\tObjet non charge dans le SelectionManager"<<endl;
|
||||
cout<<"\t on flagge ses selections eventuelles"<<endl;}
|
||||
if( aMode == -1 ){
|
||||
for(anObject->Init();anObject->More();anObject->Next()){
|
||||
if( SelectDebugModeOnSM() ) cout<<"\t\t Mode "<<anObject->CurrentSelection()->Mode()<<" ";
|
||||
anObject->CurrentSelection()->UpdateStatus(SelectMgr_TOU_Full);
|
||||
}
|
||||
if( SelectDebugModeOnSM() )
|
||||
cout << endl;
|
||||
}
|
||||
else if (anObject->HasSelection(aMode))
|
||||
anObject->Selection(aMode)->UpdateStatus(SelectMgr_TOU_Full);
|
||||
}
|
||||
|
||||
// la il l'est, il s'agit de recalculer ce qui doit l'etre
|
||||
// et de flagger ce qui est en sommeil...
|
||||
else{
|
||||
TColStd_MapIteratorOfMapOfTransient It;
|
||||
Handle(Standard_Transient) Tr;
|
||||
Standard_Boolean Found;
|
||||
// on balaye les selections de l'objet
|
||||
|
||||
for(anObject->Init();anObject->More();anObject->Next()){
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->CurrentSelection();
|
||||
Sel->UpdateStatus(SelectMgr_TOU_Full);
|
||||
Standard_Integer curmode = Sel->Mode();
|
||||
Found = Standard_False;
|
||||
|
||||
// balayage des selecteurs ...
|
||||
for(It.Initialize(myselectors);It.More();It.Next()){
|
||||
Tr = It.Key();
|
||||
Handle(SelectMgr_ViewerSelector) VS = *((Handle(SelectMgr_ViewerSelector)*)&Tr);
|
||||
if(VS->Status(Sel)==SelectMgr_SOS_Activated){
|
||||
Found = Standard_True;
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(curmode); // pas de break expres...
|
||||
case SelectMgr_TOU_Partial:
|
||||
anObject->UpdateLocation(Sel);
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if(Found){
|
||||
VS->Convert(Sel);
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Update
|
||||
//purpose : On recalcule les Selections si elles sont flaggees
|
||||
// "A RECALCULER" et qu'elles sont activees dans un des selecteurs.
|
||||
// Si ForceUpdate = True, et qu'elles sont "A RECALCULER"
|
||||
// On le fait sans se preoccuper de l'etat d'activation.
|
||||
//=======================================================================
|
||||
void SelectMgr_SelectionManager::Update(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Boolean ForceUpdate)
|
||||
{
|
||||
Standard_Boolean wasrecomputed;
|
||||
|
||||
for(anObject->Init();anObject->More();anObject->Next()){
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->CurrentSelection();
|
||||
wasrecomputed = Standard_False;
|
||||
if(ForceUpdate){
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(Sel->Mode()); // pas de break expres...
|
||||
case SelectMgr_TOU_Partial:
|
||||
anObject->UpdateLocation(Sel);
|
||||
wasrecomputed = Standard_True;
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
}
|
||||
|
||||
// on regarde quels selecteurs sont concernes par la selection
|
||||
// pour refaire les projections si besoin est.
|
||||
Handle(Standard_Transient) Tr;
|
||||
for(TColStd_MapIteratorOfMapOfTransient It(myselectors);It.More();It.Next()){
|
||||
Tr = It.Key();
|
||||
Handle(SelectMgr_ViewerSelector) VS = *((Handle(SelectMgr_ViewerSelector)*)&Tr);
|
||||
if(VS->Status(Sel)==SelectMgr_SOS_Activated)
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(Sel->Mode()); // pas de break expres...
|
||||
case SelectMgr_TOU_Partial:
|
||||
anObject->UpdateLocation(Sel);
|
||||
wasrecomputed = Standard_True;
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if(wasrecomputed)
|
||||
VS->Convert(Sel);
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Update
|
||||
// Purpose : Attention, il faut savoir ce que l'on fait....
|
||||
//==================================================
|
||||
void SelectMgr_SelectionManager::
|
||||
Update(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Handle(SelectMgr_ViewerSelector)& aViewSel,
|
||||
const Standard_Boolean ForceUpdate)
|
||||
{
|
||||
if( SelectDebugModeOnSM() ) cout<<"==>SelectMgr_SelectionManager::Update(obj,VS)"<<endl;
|
||||
if(!myselectors.Contains(aViewSel)) return;
|
||||
|
||||
Standard_Boolean okay = myglobal.Contains(anObject);
|
||||
if(!okay)
|
||||
okay = (mylocal.IsBound(anObject) && (SMSearch(mylocal.Find(anObject),aViewSel)!=0)) ;
|
||||
if(!okay) return;
|
||||
|
||||
|
||||
//
|
||||
Standard_Boolean wasrecomputed;
|
||||
for(anObject->Init();anObject->More();anObject->Next()){
|
||||
const Handle(SelectMgr_Selection)& Sel = anObject->CurrentSelection();
|
||||
wasrecomputed = Standard_False;
|
||||
if(ForceUpdate){
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(Sel->Mode()); // pas de break expres...
|
||||
case SelectMgr_TOU_Partial:
|
||||
anObject->UpdateLocation(Sel);
|
||||
wasrecomputed = Standard_True;
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
}
|
||||
|
||||
if(aViewSel->Status(Sel) == SelectMgr_SOS_Activated){
|
||||
switch(Sel->UpdateStatus()){
|
||||
case SelectMgr_TOU_Full:
|
||||
anObject->UpdateSelection(Sel->Mode());
|
||||
case SelectMgr_TOU_Partial:
|
||||
if(anObject->HasLocation())
|
||||
anObject->UpdateLocation(Sel);
|
||||
wasrecomputed = Standard_True;
|
||||
break;
|
||||
#ifndef DEB
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if(wasrecomputed)
|
||||
aViewSel->Convert(Sel);
|
||||
Sel->UpdateStatus(SelectMgr_TOU_None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Status
|
||||
// Purpose :
|
||||
//==================================================
|
||||
TCollection_AsciiString SelectMgr_SelectionManager::
|
||||
Status() const{
|
||||
TCollection_AsciiString theMgrStatus("\t\t\tStatus of the SelectManager :;\n\t\t\t============================\n");
|
||||
|
||||
TCollection_AsciiString nbview (myselectors.Extent()),nbglobal(myglobal.Extent());
|
||||
|
||||
theMgrStatus += "\t Number of ViewerSelectors: ";
|
||||
theMgrStatus += nbview + "\n\t Number of global objects : " + nbglobal+"\n";
|
||||
theMgrStatus = theMgrStatus+"\t Number of local objects : " + TCollection_AsciiString (mylocal.Extent())+" \n";
|
||||
|
||||
return theMgrStatus;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Status
|
||||
// Purpose :
|
||||
//==================================================
|
||||
|
||||
|
||||
TCollection_AsciiString SelectMgr_SelectionManager::
|
||||
Status(const Handle(SelectMgr_SelectableObject)& anObject) const
|
||||
{
|
||||
TCollection_AsciiString TheStatus("\t\tStatus of object:");
|
||||
|
||||
if(myglobal.Contains(anObject))
|
||||
{TheStatus += "GLOBAL (available for all viewers in the SelectionManager)\n";}
|
||||
else if (mylocal.IsBound(anObject))TheStatus +="LOCAL:\n\t\t";
|
||||
TColStd_MapIteratorOfMapOfTransient It(myselectors);
|
||||
Standard_Integer iv = 0;
|
||||
// Standard_Boolean FirstTime=Standard_True;
|
||||
for(;It.More();It.Next()){
|
||||
const Handle(SelectMgr_ViewerSelector)& curview =
|
||||
Handle(SelectMgr_ViewerSelector)::DownCast(It.Key());
|
||||
iv++;
|
||||
TheStatus = TheStatus + "status in the ViewerSelector :"+TCollection_AsciiString(iv)+"\n\t\t";
|
||||
TheStatus+=curview->Status(anObject);
|
||||
TheStatus+="\n\t\t----------------------\n\t\t";
|
||||
}
|
||||
|
||||
return TheStatus;
|
||||
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: LoadMode
|
||||
// Purpose : Private Method
|
||||
//==================================================
|
||||
|
||||
|
||||
void SelectMgr_SelectionManager
|
||||
::LoadMode (const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer amode)
|
||||
{
|
||||
if(amode==-1) return;
|
||||
if(!anObject->HasSelection(amode))
|
||||
{
|
||||
Handle(SelectMgr_Selection) NewSel = new SelectMgr_Selection(amode);
|
||||
anObject->AddSelection (NewSel,amode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetUpdateMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
SetUpdateMode(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const SelectMgr_TypeOfUpdate aType)
|
||||
{
|
||||
for(anObject->Init();anObject->More();anObject->Next())
|
||||
anObject->CurrentSelection()->UpdateStatus(aType);
|
||||
|
||||
}
|
||||
|
||||
void SelectMgr_SelectionManager::
|
||||
SetUpdateMode(const Handle(SelectMgr_SelectableObject)& anObject,
|
||||
const Standard_Integer aMode,
|
||||
const SelectMgr_TypeOfUpdate aType)
|
||||
{
|
||||
if(anObject->HasSelection(aMode))
|
||||
anObject->Selection(aMode)->UpdateStatus(aType);
|
||||
}
|
||||
|
63
src/SelectMgr/SelectMgr_SortCriterion.cdl
Executable file
63
src/SelectMgr/SelectMgr_SortCriterion.cdl
Executable file
@@ -0,0 +1,63 @@
|
||||
-- File: SelectMgr_SortCriterion.cdl
|
||||
-- Created: Thu Mar 26 16:01:22 1998
|
||||
-- Author: Robert COUBLANC
|
||||
-- <rob@robox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1998
|
||||
|
||||
|
||||
private class SortCriterion from SelectMgr
|
||||
|
||||
---Purpose: This class provides data and criterion for sorting candidate
|
||||
-- entities in the process of interactive selection by mouse click
|
||||
|
||||
is
|
||||
Create returns SortCriterion from SelectMgr;
|
||||
|
||||
Create(thePriority: Integer from Standard;
|
||||
theDepth, theMinDist, theTol: Real from Standard;
|
||||
PreferClosest: Boolean from Standard)
|
||||
returns SortCriterion from SelectMgr;
|
||||
---Purpose: Defines parameters of selection criterion:
|
||||
-- - Priority: selection priority
|
||||
-- - Depth: distance from the view plane to the entity
|
||||
-- - MinDist: distance from the clicked point to the entity on the view plane
|
||||
-- - Tol: tolerance used for selecting candidates
|
||||
-- - PreferClosest: specify whether closest object is preferred even if
|
||||
-- if has less priority
|
||||
|
||||
SetPriority (me : in out; P:Integer from Standard);
|
||||
---C++: inline
|
||||
SetDepth (me : in out; D:Real from Standard);
|
||||
---C++: inline
|
||||
SetMinDist (me : in out; D:Real from Standard);
|
||||
---C++: inline
|
||||
SetTol (me : in out; T:Real from Standard);
|
||||
---C++: inline
|
||||
|
||||
Priority(me) returns Integer from Standard;
|
||||
---C++: inline
|
||||
Depth(me) returns Real from Standard;
|
||||
---C++: inline
|
||||
MinDist(me) returns Real from Standard;
|
||||
---C++: inline
|
||||
Tol(me) returns Real from Standard;
|
||||
---C++: inline
|
||||
|
||||
|
||||
IsGreater(me;anOtherCriterion:SortCriterion from SelectMgr)
|
||||
returns Boolean from Standard;
|
||||
---C++: alias operator >
|
||||
|
||||
IsLower(me;anOtherCriterion:SortCriterion from SelectMgr)
|
||||
returns Boolean from Standard;
|
||||
---C++: alias operator <
|
||||
|
||||
|
||||
fields
|
||||
myPrior: Integer from Standard;
|
||||
myDepth: Real from Standard;
|
||||
myDist : Real from Standard;
|
||||
myTol : Real from Standard;
|
||||
myPreferClosest: Boolean from Standard;
|
||||
|
||||
end SortCriterion;
|
94
src/SelectMgr/SelectMgr_SortCriterion.cxx
Executable file
94
src/SelectMgr/SelectMgr_SortCriterion.cxx
Executable file
@@ -0,0 +1,94 @@
|
||||
// File: SelectMgr_SortCriterion.cxx
|
||||
// Created: Thu Mar 26 17:32:47 1998
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <SelectMgr_SortCriterion.ixx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectMgr_SortCriterion
|
||||
//purpose : Empty constructor
|
||||
//=======================================================================
|
||||
|
||||
SelectMgr_SortCriterion::SelectMgr_SortCriterion()
|
||||
: myPrior (0),
|
||||
myDepth (0.0),
|
||||
myDist (0.0),
|
||||
myTol (0.0),
|
||||
myPreferClosest(Standard_True)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectMgr_SortCriterion
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
|
||||
SelectMgr_SortCriterion::SelectMgr_SortCriterion(const Standard_Integer Prior,
|
||||
const Standard_Real Depth,
|
||||
const Standard_Real Dist,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean PreferClosest)
|
||||
: myPrior (Prior),
|
||||
myDepth (Depth),
|
||||
myDist (Dist),
|
||||
myTol (Tol),
|
||||
myPreferClosest(PreferClosest)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsGreater
|
||||
//purpose : priorite d'abor, puis profondeur + distance...
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SortCriterion::IsGreater
|
||||
(const SelectMgr_SortCriterion& SC) const
|
||||
{
|
||||
if ( myPreferClosest )
|
||||
{
|
||||
// closest object is selected unless difference is within tolerance
|
||||
if ( Abs (myDepth - SC.Depth()) > myTol + SC.Tol() )
|
||||
return myDepth < SC.Depth();
|
||||
|
||||
// if two objects have similar depth, select the one with higher
|
||||
// priority or, if priorities are equal, one closest to the mouse
|
||||
return myPrior > SC.Priority() ? Standard_True :
|
||||
myPrior < SC.Priority() ? Standard_False :
|
||||
myDist < SC.MinDist();
|
||||
}
|
||||
|
||||
// old logic (OCCT version <= 6.3.1)
|
||||
if(myPrior>SC.Priority()) return Standard_True;
|
||||
if(myPrior<SC.Priority()) return Standard_False;
|
||||
if(Abs(myDepth-SC.Depth())<=Precision::Confusion())
|
||||
return myDist < SC.MinDist();
|
||||
return (myDepth < SC.Depth() );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLower
|
||||
//purpose : On n'utilise que les criteres de profondeur et de priorite...
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_SortCriterion::IsLower
|
||||
(const SelectMgr_SortCriterion& SC) const
|
||||
{
|
||||
if ( myPreferClosest )
|
||||
{
|
||||
// closest object is selected unless difference is within tolerance
|
||||
if ( myPreferClosest && Abs (myDepth - SC.Depth()) > myTol + SC.Tol() )
|
||||
return myDepth > SC.Depth();
|
||||
|
||||
// if two objects have similar depth, select the one with higher
|
||||
// priority or, if priorities are equal, one closest to the mouse
|
||||
return myPrior < SC.Priority() ? Standard_True :
|
||||
myPrior > SC.Priority() ? Standard_False :
|
||||
myDist > SC.MinDist();
|
||||
}
|
||||
|
||||
// old logic (OCCT version <= 6.3.1)
|
||||
if(myPrior>SC.Priority()) return Standard_False;
|
||||
if(myPrior<SC.Priority()) return Standard_True;
|
||||
if(Abs(myDepth-SC.Depth())<=Precision::Confusion())
|
||||
return myDist > SC.MinDist();
|
||||
return (myDepth > SC.Depth() );
|
||||
}
|
28
src/SelectMgr/SelectMgr_SortCriterion.lxx
Executable file
28
src/SelectMgr/SelectMgr_SortCriterion.lxx
Executable file
@@ -0,0 +1,28 @@
|
||||
// File: SelectMgr_SortCriterion.lxx
|
||||
// Created: Thu Mar 26 17:22:40 1998
|
||||
// Author: Robert COUBLANC
|
||||
// <rob@robox.paris1.matra-dtv.fr>
|
||||
|
||||
inline void SelectMgr_SortCriterion::SetPriority(const Standard_Integer Prior)
|
||||
{myPrior = Prior;}
|
||||
|
||||
inline void SelectMgr_SortCriterion::SetDepth(const Standard_Real Depth)
|
||||
{myDepth = Depth;}
|
||||
|
||||
inline void SelectMgr_SortCriterion::SetMinDist(const Standard_Real Dist)
|
||||
{myDist=Dist;}
|
||||
|
||||
inline void SelectMgr_SortCriterion::SetTol(const Standard_Real Tol)
|
||||
{myTol=Tol;}
|
||||
|
||||
inline Standard_Integer SelectMgr_SortCriterion::Priority() const
|
||||
{return myPrior;}
|
||||
|
||||
inline Standard_Real SelectMgr_SortCriterion::Depth() const
|
||||
{return myDepth;}
|
||||
|
||||
inline Standard_Real SelectMgr_SortCriterion::MinDist() const
|
||||
{return myDist;}
|
||||
|
||||
inline Standard_Real SelectMgr_SortCriterion::Tol() const
|
||||
{return myTol;}
|
373
src/SelectMgr/SelectMgr_ViewerSelector.cdl
Executable file
373
src/SelectMgr/SelectMgr_ViewerSelector.cdl
Executable file
@@ -0,0 +1,373 @@
|
||||
-- File: SelectMgr_ViewerSelector.cdl
|
||||
-- Created: Fri Feb 10 09:42:17 1995
|
||||
-- Author: Mister rmi
|
||||
-- <rmi@photon>
|
||||
--modified by rob -FEB 01 1996
|
||||
-- -JUL 23 1997 : optimize recompute of selections...
|
||||
-- insert real sleep/awake option....
|
||||
-- -APR 02 1998 : improvment of selection.
|
||||
-- Sort with new Criterions
|
||||
-- (depth + size +...)
|
||||
-- store detected in a best way...
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
deferred class ViewerSelector from SelectMgr inherits TShared from MMgt
|
||||
|
||||
---Purpose: A framework to define finding, sorting the sensitive
|
||||
-- primitives in a view. Services are also provided to
|
||||
-- define the return of the owners of those primitives
|
||||
-- selected. The primitives are sorted by criteria such
|
||||
-- as priority of the primitive or its depth in the view
|
||||
-- relative to that of other primitives.
|
||||
-- This framework is undefined for either 2D or 3D,
|
||||
-- and is consequently used by both
|
||||
-- StdSelect_ViewerSelector2d and
|
||||
-- StdSelect_ViewerSelector3d, which inherit it, and
|
||||
-- which in turn, return 2D and 3D owners of sensitive
|
||||
-- primitives respectively.
|
||||
-- Note that in 3D, the inheriting framework
|
||||
-- StdSelect_ViewerSelector3d is only to be used
|
||||
-- if you do not want to use the services provided by
|
||||
-- AIS. In 2D, you will, however, need the services
|
||||
-- provided by the StdSelect_ViewerSelector2d.
|
||||
-- Two tools are available to find and select objects
|
||||
-- found at a given position in the view. If you want to
|
||||
-- select the owners of all the objects detected at
|
||||
-- point x,y, you use the Init - More - Next - Picked
|
||||
-- loop. If, on the other hand, you want to select only
|
||||
-- one object detected at that point, you use the Init -
|
||||
-- More - OnePicked loop. In this iteration, More is
|
||||
-- used to see if an object was picked and
|
||||
-- OnePicked, to get the object closest to the pick position.
|
||||
-- Viewer selectors are driven by
|
||||
-- SelectMgr_SelectionManager, and manipulate
|
||||
-- the SelectMgr_Selection objects given to them by
|
||||
-- the selection manager.
|
||||
|
||||
uses
|
||||
AsciiString from TCollection,
|
||||
SelectableObject from SelectMgr,
|
||||
DataMapOfIntegerSensitive from SelectMgr,
|
||||
DataMapOfSelectionActivation from SelectMgr,
|
||||
Selection from SelectMgr,
|
||||
Box2d from Bnd,
|
||||
HArray1OfInteger from TColStd,
|
||||
ListOfInteger from TColStd,
|
||||
SequenceOfInteger from TColStd,
|
||||
MapOfTransient from TColStd,
|
||||
IndexedMapOfInteger from TColStd,
|
||||
IndexedDataMapOfOwnerCriterion from SelectMgr,
|
||||
SensitiveEntity from SelectBasics,
|
||||
SortAlgo from SelectBasics,
|
||||
EntityOwner from SelectMgr,
|
||||
StateOfSelection from SelectMgr,
|
||||
Array1OfPnt2d from TColgp
|
||||
|
||||
is
|
||||
|
||||
Initialize ;
|
||||
|
||||
|
||||
|
||||
|
||||
Convert (me:mutable;aSelection : mutable Selection from SelectMgr) is virtual;
|
||||
---Level: Public
|
||||
---Purpose: to be redefined if conversion is necessary for SensitiveEntities...
|
||||
|
||||
|
||||
|
||||
---Category: Activation/Desactivation Of Selection For Objects
|
||||
-- No general method like "activate a mode (integer) " is possible
|
||||
-- here because objects inside the selection view are of different type
|
||||
--
|
||||
|
||||
|
||||
Activate (me : mutable;
|
||||
aSelection : Selection from SelectMgr;
|
||||
AutomaticProj : Boolean = Standard_True)
|
||||
is static private;
|
||||
---Level: Internal
|
||||
|
||||
|
||||
|
||||
|
||||
---Category: Management Methods . Some following methods are private
|
||||
-- because they owed to be called only through The Selection Manager !!
|
||||
|
||||
Clear(me:mutable) is static;
|
||||
---Level: Public
|
||||
---Purpose: Empties all the tables, removes all selections...
|
||||
|
||||
UpdateConversion(me :mutable) is static;
|
||||
---Level: Public
|
||||
---Purpose: converts all the sensitive entities ;
|
||||
|
||||
Deactivate (me : mutable;
|
||||
aSelection : Selection from SelectMgr)
|
||||
is static private;
|
||||
---Level: Internal
|
||||
|
||||
Sleep (me:mutable) is static private;
|
||||
---Level: Internal
|
||||
---Purpose: Desactivates all the objects of the view;
|
||||
-- no object in this view will be selectable;
|
||||
|
||||
Awake (me :mutable;AutomaticProj : Boolean = Standard_True) is static private;
|
||||
---Level: Internal
|
||||
---Purpose: reactivates all the selection which were sleeping....
|
||||
|
||||
Sleep (me : mutable;
|
||||
anObject : SelectableObject from SelectMgr) is static private;
|
||||
|
||||
Awake (me : mutable;
|
||||
anObject : SelectableObject from SelectMgr;
|
||||
AutomaticProj : Boolean = Standard_True) is static private;
|
||||
|
||||
|
||||
Remove(me:mutable ; aSelection: Selection from SelectMgr) is static private;
|
||||
---Level: Public
|
||||
---Purpose: removes a Selection from the Selector
|
||||
|
||||
|
||||
|
||||
---Category: SELECTION OPERATIONS
|
||||
------------=====================
|
||||
|
||||
SetSensitivity (me : mutable ; aTol:Real) is static;
|
||||
---Level: Public
|
||||
---Purpose: changes the Sensitivity of picking
|
||||
-- Input value is Real.
|
||||
|
||||
SetClipping(me:mutable ; Xc,Yc,Height,Width:Real) is static;
|
||||
---Level: Public
|
||||
---Purpose: sets the clipping limits of dynamic picking
|
||||
-- input value are Real
|
||||
|
||||
SetClipping(me:mutable ; aRectangle : Box2d from Bnd) is static;
|
||||
---Level: Public
|
||||
---Purpose: sets the clipping limits of dynamic picking
|
||||
-- input value are Real
|
||||
|
||||
|
||||
|
||||
|
||||
InitSelect (me : mutable ; Xr,Yr : Real) is static;
|
||||
---Level: Public
|
||||
---Purpose: Performs a pick action. Xr, Yr are the real 2D mouse
|
||||
-- coordinates in the view. The selector looks for areas
|
||||
-- and owners that are touched.
|
||||
|
||||
InitSelect (me : mutable ; aRect: Box2d from Bnd) is static;
|
||||
---Level: Public
|
||||
---Purpose: Performs a pick action. aRect is a Box2d (real
|
||||
-- coordinates) for the selection. The selector looks for
|
||||
-- areas and owners that are touched.
|
||||
|
||||
InitSelect (me : mutable ; Xmin,Ymin,Xmax,Ymax: Real) is static;
|
||||
---Purpose: Performs a pick action
|
||||
-- - Xmin, Ymin define the coordinates of the minimum
|
||||
-- point in the lower left hand corner of the selection
|
||||
-- box, and XMax, YMax define the coordinates of
|
||||
-- the maximum point in the upper right hand corner
|
||||
-- of the selection box. The selector looks for areas
|
||||
-- and owners that are touched.
|
||||
|
||||
InitSelect (me : mutable ; Polyline:Array1OfPnt2d from TColgp) is static;
|
||||
---Level: Public
|
||||
---Purpose: pick action - input values of a polyline selection for selection.
|
||||
|
||||
|
||||
|
||||
|
||||
---Category: RESULT OF SELECTION...
|
||||
-- 2 Methods : *all the detected objects are given
|
||||
-- (use More - Next - Picked loop)
|
||||
-- *only one is wanted :
|
||||
-- (use More to know if something was picked and OnePicked
|
||||
-- to get the closest object of pick position).
|
||||
--
|
||||
--
|
||||
|
||||
SortResult(me:mutable) is virtual;
|
||||
---Purpose: Sorts the detected entites by priority and distance.
|
||||
-- to be redefined if other criterion are used...
|
||||
|
||||
Init(me:mutable) is static;
|
||||
---Purpose: Begins an iteration scanning for the owners detected at a position in the view.
|
||||
---C++: inline
|
||||
|
||||
More(me:mutable) returns Boolean from Standard is static;
|
||||
---Purpose: Continues the interation scanning for the owners
|
||||
-- detected at a position in the view, or
|
||||
-- - continues the iteration scanning for the owner
|
||||
-- closest to the position in the view.
|
||||
|
||||
Next(me:mutable) is static;
|
||||
---Purpose: Returns the next owner found in the iteration. This is
|
||||
-- a scan for the owners detected at a position in the view.
|
||||
---C++: inline
|
||||
|
||||
|
||||
Picked(me) returns any EntityOwner is static;
|
||||
---Level: Public
|
||||
---Purpose: Returns the current selected entity detected by the selector;
|
||||
|
||||
|
||||
OnePicked(me:mutable) returns any EntityOwner is static;
|
||||
---Purpose: Returns the picked element with the highest priority,
|
||||
-- and which is the closest to the last successful mouse position.
|
||||
|
||||
SetPickClosest(me: mutable; preferClosest: Boolean);
|
||||
---Purpose: Set preference of selecting one object for OnePicked() method:
|
||||
-- - If True, objects with less depth (distance fron the view plane) are
|
||||
-- preferred regardless of priority (priority is used then to choose among
|
||||
-- objects with similar depth),
|
||||
-- - If False, objects with higher priority are preferred regardless of the
|
||||
-- depth which is used to choose among objects of the same priority.
|
||||
---C++: inline
|
||||
|
||||
|
||||
NbPicked(me) returns Integer from Standard;
|
||||
---Purpose: Returns the number of owners found at a position in
|
||||
-- the view by the Init - More - Next - Picked iteration.
|
||||
|
||||
Picked(me;aRank:Integer from Standard)
|
||||
returns any EntityOwner from SelectMgr;
|
||||
---Purpose: Returns the entity which is at rank <aRank>
|
||||
-- in the list of stored ones.
|
||||
|
||||
|
||||
HasStored (me:mutable) returns Boolean is static;
|
||||
---Level: Public
|
||||
---Purpose: Returns True if a successful pick was stored,
|
||||
-- i.e. LastPosition method means something...
|
||||
|
||||
LastPosition (me; Xr,Yr : out Real ) is static;
|
||||
---Level: Public
|
||||
---Purpose: Gives the last successful pick position;
|
||||
-- is useful to get objects really picked
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---Category: INFORMATION ABOUT OBJECTS IN THE VIEWER SELECTOR
|
||||
|
||||
|
||||
Contains (me;aSelectableObject: SelectableObject from SelectMgr)
|
||||
returns Boolean is static;
|
||||
|
||||
|
||||
Modes (me;
|
||||
aSelectableObject:SelectableObject from SelectMgr;
|
||||
ModeList : in out ListOfInteger from TColStd;
|
||||
WantedState : StateOfSelection from SelectMgr = SelectMgr_SOS_Any) returns Boolean;
|
||||
---Purpose: Returns the list of selection modes ModeList found in
|
||||
-- this selector for the selectable object aSelectableObject.
|
||||
-- Returns true if aSelectableObject is referenced inside
|
||||
-- this selector; returns false if the object is not present
|
||||
-- in this selector.
|
||||
|
||||
IsActive (me;aSelectableObject:SelectableObject;aMode:Integer) returns Boolean is static ;
|
||||
---Purpose: Returns true if the selectable object
|
||||
-- aSelectableObject having the selection mode aMode
|
||||
-- is active in this selector.
|
||||
|
||||
IsInside (me;aSelectableObject:SelectableObject;aMode:Integer) returns Boolean is static ;
|
||||
---Purpose: Returns true if the selectable object
|
||||
-- aSelectableObject having the selection mode aMode
|
||||
-- is in this selector.
|
||||
|
||||
Status (me;aSelection :Selection from SelectMgr) returns StateOfSelection from SelectMgr;
|
||||
---Purpose: Returns the selection status Status of the selection aSelection.
|
||||
|
||||
Dump(me;S : in out OStream from Standard);
|
||||
|
||||
|
||||
Status (me;aSelectableObject:SelectableObject) returns AsciiString from TCollection is static;
|
||||
|
||||
Status (me) returns AsciiString from TCollection is static;
|
||||
---Level: Internal
|
||||
---Purpose: gives general information about the Selector
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
---Category: Internal Methods
|
||||
|
||||
|
||||
NbBoxes(me:mutable) returns Integer is static private;
|
||||
---Level: Internal
|
||||
|
||||
UpdateSort (me:mutable) is static;
|
||||
---Level: Internal
|
||||
|
||||
LoadResult (me:mutable) is virtual protected;
|
||||
---Level: Internal
|
||||
|
||||
LoadResult (me:mutable;aBox:Box2d from Bnd) is virtual protected;
|
||||
---Level: Internal
|
||||
|
||||
LoadResult (me:mutable;Polyline:Array1OfPnt2d from TColgp) is virtual protected;
|
||||
---Level: Internal
|
||||
|
||||
|
||||
|
||||
Primitive(me;Rank:Integer from Standard)
|
||||
returns SensitiveEntity from SelectBasics;
|
||||
---Level: Internal
|
||||
|
||||
Primitives(me)
|
||||
returns DataMapOfIntegerSensitive from SelectMgr;
|
||||
---Level: Internal
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
|
||||
SetUpdateSortPossible( me: mutable; possible : Boolean from Standard );
|
||||
IsUpdateSortPossible( me ) returns Boolean from Standard;
|
||||
|
||||
|
||||
fields
|
||||
|
||||
--before selection
|
||||
myentities : DataMapOfIntegerSensitive is protected;
|
||||
myselections : DataMapOfSelectionActivation is protected;
|
||||
toupdate : Boolean is protected;
|
||||
tosort : Boolean is protected;
|
||||
preferclosest: Boolean is protected;
|
||||
--for selection
|
||||
mytolerance : Real is protected;
|
||||
myselector : SortAlgo from SelectBasics is protected;
|
||||
myclip : Box2d from Bnd is protected;
|
||||
myactivenb : Integer;
|
||||
--after selection -results... we sort the list of indexes not the map...
|
||||
mystored : IndexedDataMapOfOwnerCriterion from SelectMgr is protected;
|
||||
myIndexes : HArray1OfInteger from TColStd;
|
||||
myprim : SequenceOfInteger from TColStd; -- for debug only
|
||||
myCurRank : Integer from Standard;
|
||||
|
||||
lastx : Real;
|
||||
lasty : Real;
|
||||
|
||||
myUpdateSortPossible : Boolean from Standard;
|
||||
|
||||
friends
|
||||
class SelectionManager from SelectMgr
|
||||
|
||||
end ViewerSelector;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
950
src/SelectMgr/SelectMgr_ViewerSelector.cxx
Executable file
950
src/SelectMgr/SelectMgr_ViewerSelector.cxx
Executable file
@@ -0,0 +1,950 @@
|
||||
// Copyright: Matra-Datavision 1995
|
||||
// File: SelectMgr_ViewerSelector.cxx
|
||||
// Created: Wed Feb 15 13:54:24 1995
|
||||
// Author: Roberc Coublanc
|
||||
// <rob>
|
||||
// Modified by ...
|
||||
// ROB JAN/07/98 : Improve Storage of detected entities
|
||||
// AGV OCT/23/03 : Optimize the method SortResult() (OCC4201)
|
||||
|
||||
#include <SelectMgr_ViewerSelector.ixx>
|
||||
#include <SelectMgr_CompareResults.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <Bnd_HArray1OfBox2d.hxx>
|
||||
#include <Bnd_Array1OfBox2d.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <SelectBasics_ListIteratorOfListOfBox2d.hxx>
|
||||
#include <SelectBasics_SensitiveEntity.hxx>
|
||||
#include <SelectBasics_EntityOwner.hxx>
|
||||
#include <SelectBasics_ListOfBox2d.hxx>
|
||||
#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
|
||||
#include <SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation.hxx>
|
||||
#include <SelectMgr_SortCriterion.hxx>
|
||||
#include <Select3D_SensitiveEntity.hxx>
|
||||
#include <SortTools_QuickSortOfInteger.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
|
||||
static Standard_Boolean SelectDebugModeOnVS()
|
||||
{
|
||||
static Standard_Integer isDebugMode( -1 );
|
||||
if ( isDebugMode < 0 ) {
|
||||
isDebugMode = 1;
|
||||
OSD_Environment selectdb("SELDEBUGMODE");
|
||||
if ( selectdb.Value().IsEmpty() )
|
||||
isDebugMode = 0;
|
||||
}
|
||||
return ( isDebugMode != 0 );
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Initialize
|
||||
// Purpose :
|
||||
//==================================================
|
||||
SelectMgr_ViewerSelector::SelectMgr_ViewerSelector():
|
||||
toupdate(Standard_True),
|
||||
tosort(Standard_True),
|
||||
preferclosest(Standard_True),
|
||||
mytolerance(0.),
|
||||
myCurRank(0),
|
||||
lastx (Precision::Infinite()),
|
||||
lasty (Precision::Infinite()),
|
||||
myUpdateSortPossible( Standard_True )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Activate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::
|
||||
Activate (const Handle(SelectMgr_Selection)& aSelection,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
tosort = Standard_True;
|
||||
|
||||
if (!myselections.IsBound(aSelection))
|
||||
{
|
||||
myselections.Bind(aSelection,0);
|
||||
}
|
||||
else if (myselections(aSelection)!=0)
|
||||
{
|
||||
myselections(aSelection)= 0;
|
||||
}
|
||||
if(AutomaticProj)
|
||||
Convert(aSelection);
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Deactivate
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::
|
||||
Deactivate (const Handle(SelectMgr_Selection)& aSel)
|
||||
{
|
||||
if(myselections.IsBound(aSel))
|
||||
{myselections(aSel)=1;
|
||||
tosort = Standard_True;}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Sleep
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::Sleep()
|
||||
{ SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It(myselections);
|
||||
for (;It.More();It.Next()){
|
||||
if(It.Value()==0) myselections(It.Key())= 2;
|
||||
}
|
||||
UpdateSort();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Sleep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SelectMgr_ViewerSelector::Sleep(const Handle(SelectMgr_SelectableObject)& SO)
|
||||
{
|
||||
|
||||
for(SO->Init();SO->More();SO->Next()){
|
||||
if(myselections.IsBound(SO->CurrentSelection())){
|
||||
myselections(SO->CurrentSelection()) = 2;
|
||||
}
|
||||
}
|
||||
UpdateSort();
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Awake
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::Awake(const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It(myselections);
|
||||
for (;It.More();It.Next()){
|
||||
if(It.Value()==2)
|
||||
myselections(It.Key())=0;
|
||||
if(AutomaticProj)
|
||||
UpdateConversion();
|
||||
UpdateSort();
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMgr_ViewerSelector::Awake(const Handle(SelectMgr_SelectableObject)& SO,
|
||||
const Standard_Boolean AutomaticProj)
|
||||
{
|
||||
for(SO->Init();SO->More();SO->Next()){
|
||||
if(myselections.IsBound(SO->CurrentSelection())){
|
||||
myselections(SO->CurrentSelection()) =0;
|
||||
if(AutomaticProj)
|
||||
Convert(SO->CurrentSelection());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//==================================================
|
||||
// Function: Clear
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::Clear()
|
||||
{
|
||||
myentities.Clear();
|
||||
myselections.Clear();
|
||||
toupdate = Standard_True;
|
||||
tosort = Standard_True;
|
||||
mystored.Clear();
|
||||
lastx = Precision::Infinite();
|
||||
lasty = Precision::Infinite();
|
||||
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: UpdateConversion
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::UpdateConversion()
|
||||
{
|
||||
if( SelectDebugModeOnVS() )
|
||||
cout<<"\t\t\t\t\t SelectMgr_VS::UpdateConversion"<<endl;
|
||||
|
||||
SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It(myselections);
|
||||
for(;It.More();It.Next()){
|
||||
//Convert only if active...
|
||||
if(It.Value()==0)
|
||||
Convert(It.Key());
|
||||
}
|
||||
toupdate = Standard_False;
|
||||
tosort = Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Convert
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::
|
||||
Convert (const Handle(SelectMgr_Selection)& /*aSel*/) {tosort=Standard_True;}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: UpdateSort
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::UpdateSort()
|
||||
{
|
||||
if( !myUpdateSortPossible )
|
||||
return;
|
||||
|
||||
if( SelectDebugModeOnVS() )
|
||||
cout<<"\t\t\t\t\t SelectMgr_ViewerSelector::UpdateSort()"<<endl;
|
||||
mystored.Clear();
|
||||
myentities.Clear();
|
||||
myactivenb = NbBoxes();
|
||||
|
||||
if(myactivenb > 0) {
|
||||
Standard_Boolean NoClip = myclip.IsVoid();
|
||||
Handle(Bnd_HArray1OfBox2d) refToTab = new Bnd_HArray1OfBox2d(1,myactivenb);
|
||||
Bnd_Array1OfBox2d & tab = refToTab->ChangeArray1();
|
||||
Standard_Real xmin=Precision::Infinite(),ymin=Precision::Infinite(),xmax=-Precision::Infinite(),ymax=-Precision::Infinite();
|
||||
Standard_Real curxmin,curymin,curxmax,curymax;
|
||||
// Standard_Integer boxindex=0,indexsel=0,indexprim=0;
|
||||
Standard_Integer boxindex=0;
|
||||
|
||||
SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It;
|
||||
SelectBasics_ListIteratorOfListOfBox2d LIt;
|
||||
Handle(SelectMgr_Selection) curEntity;
|
||||
Standard_Real ScaleFactor;
|
||||
for(It.Initialize(myselections);It.More();It.Next()){
|
||||
if(It.Value()== 0)
|
||||
{ curEntity = It.Key();
|
||||
for(curEntity->Init();curEntity->More();curEntity->Next())
|
||||
{
|
||||
static SelectBasics_ListOfBox2d BoxList;
|
||||
BoxList.Clear();
|
||||
curEntity->Sensitive()->Areas(BoxList);
|
||||
ScaleFactor = curEntity->Sensitive()->SensitivityFactor();
|
||||
|
||||
|
||||
for(LIt.Initialize(BoxList);LIt.More();LIt.Next()){
|
||||
boxindex++;
|
||||
|
||||
tab.SetValue(boxindex,LIt.Value());
|
||||
|
||||
tab(boxindex).SetGap(mytolerance*ScaleFactor);
|
||||
myentities.Bind(boxindex,curEntity->Sensitive());
|
||||
if(NoClip){
|
||||
if (!tab(boxindex).IsVoid()) {
|
||||
tab(boxindex).Get(curxmin,curymin,curxmax,curymax);
|
||||
if(curxmin<xmin) xmin=curxmin;
|
||||
if(curxmax>xmax) xmax=curxmax;
|
||||
if(curymin<ymin) ymin=curymin;
|
||||
if(curymax>ymax) ymax=curymax;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(NoClip) {myclip.SetVoid();myclip.Update(xmin,ymin,xmax,ymax);}
|
||||
myselector.Initialize(myclip, mytolerance,refToTab);
|
||||
tosort = Standard_False;
|
||||
if(NoClip) myclip.SetVoid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Remove
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::
|
||||
Remove(const Handle(SelectMgr_Selection)& aSel)
|
||||
{
|
||||
if (myselections.IsBound(aSel))
|
||||
{ myselections.UnBind(aSel);
|
||||
tosort = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: SetSensitivity
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::SetSensitivity(const Standard_Real aVal)
|
||||
{mytolerance = aVal;
|
||||
tosort=Standard_True;}
|
||||
|
||||
//==================================================
|
||||
// Function: SetClipping
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::SetClipping(const Standard_Real Xc,
|
||||
const Standard_Real Yc,
|
||||
const Standard_Real Height,
|
||||
const Standard_Real Width)
|
||||
{
|
||||
Bnd_Box2d aClip;
|
||||
aClip.Set(gp_Pnt2d(Xc-Width/2, Yc-Height/2));
|
||||
aClip.Add(gp_Pnt2d(Xc+Width/2, Yc+Height/2));
|
||||
myclip = aClip;
|
||||
tosort = Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: SetClipping
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::SetClipping (const Bnd_Box2d& abox)
|
||||
{myclip = abox;
|
||||
tosort = Standard_True;
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: InitSelect
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::InitSelect(const Standard_Real Xr,
|
||||
const Standard_Real Yr)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(Abs(Xr-Precision::Infinite())<=Precision::Confusion() ||
|
||||
Abs(Yr-Precision::Infinite())<=Precision::Confusion(),
|
||||
" Infinite values in IniSelect");
|
||||
mystored.Clear();
|
||||
myprim.Clear();
|
||||
if (toupdate) UpdateConversion();
|
||||
if (tosort) UpdateSort();
|
||||
if(myactivenb!=0){
|
||||
myselector.InitSelect(Xr,Yr);
|
||||
if(myselector.More()) {lastx = Xr;lasty=Yr;}
|
||||
LoadResult();
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: InitSelect
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::InitSelect(const Bnd_Box2d& aBox)
|
||||
{
|
||||
mystored.Clear();
|
||||
if(toupdate) UpdateConversion();
|
||||
if (tosort) UpdateSort();
|
||||
if (myactivenb!=0){
|
||||
myselector.InitSelect(aBox);
|
||||
LoadResult(aBox);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: InitSelect
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::InitSelect(const Standard_Real Xmin,
|
||||
const Standard_Real Ymin,
|
||||
const Standard_Real Xmax,
|
||||
const Standard_Real Ymax)
|
||||
{
|
||||
mystored.Clear();
|
||||
|
||||
if (toupdate) UpdateConversion();
|
||||
if (tosort) UpdateSort();
|
||||
if (myactivenb!=0){
|
||||
Bnd_Box2d aBox;
|
||||
aBox.Update(Xmin,Ymin,Xmax,Ymax);
|
||||
myselector.InitSelect(aBox);
|
||||
LoadResult(aBox);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: InitSelect
|
||||
// Purpose : Polyline Selection
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::InitSelect(const TColgp_Array1OfPnt2d& aPoly)
|
||||
{
|
||||
mystored.Clear();
|
||||
|
||||
if (toupdate) UpdateConversion();
|
||||
if (tosort) UpdateSort();
|
||||
if (myactivenb!=0){
|
||||
// on utilise les Bnd box dans un premier temps
|
||||
Bnd_Box2d aBox;
|
||||
Standard_Integer NbPnt = aPoly.Length();
|
||||
Standard_Integer i;
|
||||
for(i=1;i<=NbPnt;i++) {
|
||||
aBox.Update(aPoly(i).X(),aPoly(i).Y());
|
||||
}
|
||||
myselector.InitSelect(aBox);
|
||||
LoadResult(aPoly);
|
||||
// LoadResult(aBox);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: LoadResult
|
||||
// Purpose : on laisse tomber pour l'instant la taille
|
||||
// de la primitive dans les criteres de tri...
|
||||
// On prend la priorite, la profondeur et
|
||||
// la distance mini au CDG ou Bords...
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::
|
||||
LoadResult()
|
||||
{
|
||||
// Handle(SelectMgr_EntityOwner) OWNR;
|
||||
if(myselector.More())
|
||||
{
|
||||
// Standard_Boolean Found(Standard_False);
|
||||
Standard_Real DMin;
|
||||
Standard_Integer nument;
|
||||
for(;myselector.More();myselector.Next()){
|
||||
nument = myselector.Value();
|
||||
const Handle(SelectBasics_SensitiveEntity)& SE = myentities(nument);
|
||||
if (SE->Matches(lastx,lasty,mytolerance,DMin)) {
|
||||
const Handle(SelectBasics_EntityOwner)& OWNR = SE->OwnerId();
|
||||
|
||||
if(!OWNR.IsNull()){
|
||||
Standard_Real TheDepth = SE->Depth();
|
||||
Standard_Integer Prior = OWNR->Priority();
|
||||
|
||||
SelectMgr_SortCriterion SC(Prior,TheDepth,DMin,mytolerance,preferclosest);
|
||||
if ( mystored.Contains(OWNR) )
|
||||
{
|
||||
SelectMgr_SortCriterion& Crit = mystored.ChangeFromKey(OWNR);
|
||||
if ( SC > Crit )
|
||||
{
|
||||
Crit = SC;
|
||||
|
||||
// update previously recorded entity for this owner
|
||||
for (int i=1; i <= myprim.Length(); i++)
|
||||
if (myentities(myprim(i))->OwnerId() == OWNR) {
|
||||
myprim.SetValue (i, nument);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mystored.Add(OWNR,SC);
|
||||
|
||||
// record entity
|
||||
myprim.Append(nument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SortResult();
|
||||
}
|
||||
if( SelectDebugModeOnVS() ){
|
||||
cout<<"\tSelectMgr_VS:: Resultat du move"<<endl;
|
||||
cout<<"\tNb Detectes :"<<mystored.Extent()<<endl;
|
||||
for(Standard_Integer i=1;i<=mystored.Extent();i++){
|
||||
const SelectMgr_SortCriterion& Crit = mystored(myIndexes->Value(i));
|
||||
cout<<"\t"<<i<<" - Prior"<<Crit.Priority()<<" - prof :"<<Crit.Depth()<<" - Dist. :"<<Crit.MinDist()<<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
//==================================================
|
||||
// Function: LoadResult
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::LoadResult(const Bnd_Box2d& abox)
|
||||
{
|
||||
mystored.Clear();
|
||||
|
||||
// Handle(SelectMgr_EntityOwner) OWNR;
|
||||
if(myselector.More())
|
||||
{ Standard_Real xmin,ymin,xmax,ymax;
|
||||
abox.Get(xmin,ymin,xmax,ymax);
|
||||
// Standard_Boolean Found(Standard_False);
|
||||
// Standard_Real DMin=0.;
|
||||
Standard_Integer nument;
|
||||
for(;myselector.More();myselector.Next()){
|
||||
nument = myselector.Value();
|
||||
const Handle(SelectBasics_SensitiveEntity)& SE = myentities(nument);
|
||||
if (SE->Matches(xmin,ymin,xmax,ymax,0.0)){
|
||||
const Handle(SelectBasics_EntityOwner)& OWNR = SE->OwnerId();
|
||||
if(!OWNR.IsNull()){
|
||||
if(!mystored.Contains(OWNR)){
|
||||
SelectMgr_SortCriterion SC(OWNR->Priority(),Precision::Infinite(),
|
||||
Precision::Infinite(),mytolerance,preferclosest);
|
||||
mystored.Add(OWNR,SC);
|
||||
myprim.Append(nument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pas de tri a faire dans le cas d'une selection par rectangle elastique (BUG ANALYST)
|
||||
if(mystored.IsEmpty()) return;
|
||||
if(myIndexes.IsNull())
|
||||
myIndexes = new TColStd_HArray1OfInteger(1,mystored.Extent());
|
||||
else if(mystored.Extent() !=myIndexes->Length())
|
||||
myIndexes = new TColStd_HArray1OfInteger (1,mystored.Extent());
|
||||
|
||||
// pour travailler plus vite...
|
||||
TColStd_Array1OfInteger& thearr = myIndexes->ChangeArray1();
|
||||
for(Standard_Integer I=1;I<=mystored.Extent();I++)
|
||||
thearr(I)=I;
|
||||
}
|
||||
}
|
||||
//==================================================
|
||||
// Function: LoadResult
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::LoadResult(const TColgp_Array1OfPnt2d& aPoly)
|
||||
{
|
||||
mystored.Clear();
|
||||
Bnd_Box2d aBox;
|
||||
Standard_Integer NbPnt = aPoly.Length();
|
||||
Standard_Integer i;
|
||||
for(i=1;i<=NbPnt;i++) {
|
||||
aBox.Update(aPoly(i).X(),aPoly(i).Y());
|
||||
}
|
||||
Standard_Integer NB=0;
|
||||
// Handle(SelectMgr_EntityOwner) OWNR;
|
||||
if(myselector.More())
|
||||
{
|
||||
Standard_Integer nument;
|
||||
|
||||
for(;myselector.More();myselector.Next()){
|
||||
NB++;
|
||||
nument = myselector.Value();
|
||||
const Handle(SelectBasics_SensitiveEntity)& SE = myentities(nument);
|
||||
if (SE->Matches(aPoly,aBox,0.0)){
|
||||
const Handle(SelectBasics_EntityOwner)& OWNR = SE->OwnerId();
|
||||
if(!OWNR.IsNull()){
|
||||
if(!mystored.Contains(OWNR)){
|
||||
SelectMgr_SortCriterion SC(OWNR->Priority(),Precision::Infinite(),
|
||||
Precision::Infinite(),mytolerance,preferclosest);
|
||||
mystored.Add(OWNR,SC);
|
||||
myprim.Append(nument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mystored.IsEmpty()) return;
|
||||
if(myIndexes.IsNull())
|
||||
myIndexes = new TColStd_HArray1OfInteger(1,mystored.Extent());
|
||||
else if(mystored.Extent() !=myIndexes->Length())
|
||||
myIndexes = new TColStd_HArray1OfInteger (1,mystored.Extent());
|
||||
|
||||
// pour travailler plus vite...
|
||||
TColStd_Array1OfInteger& thearr = myIndexes->ChangeArray1();
|
||||
for(Standard_Integer I=1;I<=mystored.Extent();I++)
|
||||
thearr(I)=I;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: HasStored
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean SelectMgr_ViewerSelector::
|
||||
HasStored ()
|
||||
{
|
||||
if(Abs(lastx-Precision::Infinite())<=Precision::Confusion()) return Standard_False;
|
||||
if(Abs(lasty-Precision::Infinite())<=Precision::Confusion()) return Standard_False;
|
||||
InitSelect(lastx,lasty);
|
||||
Init();
|
||||
return More();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Picked
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector
|
||||
::Picked() const
|
||||
{
|
||||
Standard_Integer RankInMap = myIndexes->Value(myCurRank);
|
||||
const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(RankInMap);
|
||||
Handle(SelectMgr_EntityOwner) Ownr = *((Handle(SelectMgr_EntityOwner)*) &toto);
|
||||
return Ownr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : More
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_ViewerSelector::More()
|
||||
{
|
||||
if(mystored.Extent()==0) return Standard_False;
|
||||
if(myCurRank==0) return Standard_False;
|
||||
return myCurRank <= myIndexes->Length();
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: OnePicked
|
||||
// Purpose : only the best one is chosen
|
||||
// depend on priority and mindist...
|
||||
//==================================================
|
||||
|
||||
Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector
|
||||
::OnePicked()
|
||||
{
|
||||
|
||||
Init();
|
||||
if(More()){
|
||||
Standard_Integer RankInMap = myIndexes->Value(1);
|
||||
const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(RankInMap);
|
||||
Handle(SelectMgr_EntityOwner) Ownr = *((Handle(SelectMgr_EntityOwner)*) &toto);
|
||||
return Ownr;
|
||||
}
|
||||
|
||||
Handle (SelectMgr_EntityOwner) NullObj; //returns a null Handle if there was not successfull pick...
|
||||
return NullObj;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbPicked
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer SelectMgr_ViewerSelector::NbPicked() const
|
||||
{
|
||||
return mystored.Extent();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Picked
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector::Picked(const Standard_Integer aRank) const
|
||||
{
|
||||
|
||||
Handle(SelectMgr_EntityOwner) Own;
|
||||
if (aRank<1 || aRank>NbPicked())
|
||||
return Own;
|
||||
Standard_Integer Indx = myIndexes->Value(aRank);
|
||||
|
||||
|
||||
const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(Indx);
|
||||
Own = *((Handle(SelectMgr_EntityOwner)*) &toto);
|
||||
return Own;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Primitive
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(SelectBasics_SensitiveEntity) SelectMgr_ViewerSelector::Primitive
|
||||
(const Standard_Integer /*Index*/) const
|
||||
{
|
||||
return myentities(myprim(myCurRank));
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: LastPosition
|
||||
// Purpose :
|
||||
//==================================================
|
||||
void SelectMgr_ViewerSelector::LastPosition(Standard_Real& Xlast,
|
||||
Standard_Real& YLast) const
|
||||
{ Xlast = lastx;YLast = lasty;}
|
||||
|
||||
|
||||
|
||||
//===================================================
|
||||
//
|
||||
// INTERNAL METHODS ....
|
||||
//
|
||||
//==================================================
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: NbBoxes
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Integer SelectMgr_ViewerSelector::NbBoxes()
|
||||
{
|
||||
SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It(myselections);
|
||||
// Standard_Integer Nbb=0, first,last;
|
||||
Standard_Integer Nbb=0;
|
||||
|
||||
for(;It.More();It.Next()){
|
||||
if(It.Value()==0){
|
||||
for(It.Key()->Init();It.Key()->More();It.Key()->Next())
|
||||
{Nbb+= It.Key()->Sensitive()->MaxBoxes();}
|
||||
}
|
||||
}
|
||||
return Nbb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Contains
|
||||
// Purpose :
|
||||
//==================================================
|
||||
Standard_Boolean SelectMgr_ViewerSelector::
|
||||
Contains(const Handle(SelectMgr_SelectableObject)& anObject) const
|
||||
{
|
||||
for (anObject->Init();anObject->More();anObject->Next()){
|
||||
if(myselections.IsBound(anObject->CurrentSelection()))
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: ActiveModes
|
||||
// Purpose : return all the modes with a given state for an object
|
||||
//==================================================
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_ViewerSelector::
|
||||
Modes(const Handle(SelectMgr_SelectableObject)& SO,
|
||||
TColStd_ListOfInteger& TheActiveList,
|
||||
const SelectMgr_StateOfSelection WantedState) const
|
||||
{
|
||||
Standard_Boolean Found= Standard_False;
|
||||
for(SO->Init();SO->More();SO->Next()){
|
||||
if(myselections.IsBound(SO->CurrentSelection())){
|
||||
if(WantedState==SelectMgr_SOS_Any)
|
||||
TheActiveList.Append(SO->CurrentSelection()->Mode());
|
||||
else if( myselections(SO->CurrentSelection())==WantedState)
|
||||
TheActiveList.Append(SO->CurrentSelection()->Mode());
|
||||
|
||||
if(!Found) Found=Standard_True;
|
||||
}
|
||||
}
|
||||
return Found;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_ViewerSelector::
|
||||
IsActive(const Handle(SelectMgr_SelectableObject)& SO,
|
||||
const Standard_Integer aMode) const
|
||||
{
|
||||
for(SO->Init();SO->More();SO->Next()){
|
||||
if(aMode==SO->CurrentSelection()->Mode()){
|
||||
if(myselections.IsBound(SO->CurrentSelection()) &&
|
||||
myselections(SO->CurrentSelection())==SelectMgr_SOS_Activated)
|
||||
return Standard_True;
|
||||
else return Standard_False;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean SelectMgr_ViewerSelector::
|
||||
IsInside(const Handle(SelectMgr_SelectableObject)& SO,
|
||||
const Standard_Integer aMode) const
|
||||
{
|
||||
for(SO->Init();SO->More();SO->Next()){
|
||||
if(aMode==SO->CurrentSelection()->Mode()){
|
||||
if(myselections.IsBound(SO->CurrentSelection())) return Standard_True;
|
||||
else return Standard_False;
|
||||
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Status
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
SelectMgr_StateOfSelection SelectMgr_ViewerSelector::Status(const Handle(SelectMgr_Selection)& aSel) const
|
||||
{
|
||||
if(!myselections.IsBound(aSel)) return SelectMgr_SOS_Unknown;
|
||||
//JR/Hp
|
||||
Standard_Integer ie = myselections(aSel) ;
|
||||
return SelectMgr_StateOfSelection( ie );
|
||||
// return SelectMgr_StateOfSelection(myselections(aSel));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SelectMgr_ViewerSelector::Dump(Standard_OStream& S) const
|
||||
{
|
||||
S<<"=========================="<<endl;
|
||||
S<<" SelectMgr_ViewerSelector "<<endl;
|
||||
S<<"=========================="<<endl;
|
||||
S<<" "<<endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
// Function: Status
|
||||
// Purpose : gives Information about selectors
|
||||
//==================================================
|
||||
|
||||
TCollection_AsciiString SelectMgr_ViewerSelector::
|
||||
Status(const Handle(SelectMgr_SelectableObject)& SO) const
|
||||
{
|
||||
TCollection_AsciiString Status("Status Objet :\n\t");
|
||||
Standard_Boolean Found= Standard_False;
|
||||
for(SO->Init();SO->More();SO->Next()){
|
||||
if(myselections.IsBound(SO->CurrentSelection()))
|
||||
{
|
||||
Found = Standard_True;
|
||||
Status = Status + "Mode " +
|
||||
TCollection_AsciiString(SO->CurrentSelection()->Mode()) +
|
||||
" present - " ;
|
||||
if(myselections(SO->CurrentSelection()))
|
||||
Status = Status + " Actif \n\t";
|
||||
else
|
||||
Status = Status + " Inactif \n\t";
|
||||
}
|
||||
}
|
||||
|
||||
if(!Found) Status = Status + "Non Present dans le selecteur\n\n";
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
TCollection_AsciiString SelectMgr_ViewerSelector::
|
||||
Status () const
|
||||
{
|
||||
// les primitives sensibles presentes
|
||||
//------------------------------------
|
||||
TCollection_AsciiString Status("\t\tSelector Status :\n\t");
|
||||
// les selections
|
||||
//---------------
|
||||
Standard_Integer NbActive =0,NbPrim=0;
|
||||
Status = Status + "Number of already computed selections : " +
|
||||
TCollection_AsciiString(myselections.Extent());
|
||||
|
||||
SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It(myselections);
|
||||
for(;It.More();It.Next())
|
||||
{
|
||||
if(It.Value()==0) {NbActive++;
|
||||
for(It.Key()->Init();It.Key()->More();It.Key()->Next()){NbPrim++;}
|
||||
}
|
||||
}
|
||||
Status = Status + " - " + TCollection_AsciiString(NbActive) + " activated ones\n\t";
|
||||
Status = Status + "Number of active sensitive primitives : " +
|
||||
TCollection_AsciiString(NbPrim)+"\n\t";
|
||||
Status = Status + "Real stored Pick Tolerance : " + TCollection_AsciiString(mytolerance) +"\n\t";
|
||||
if(toupdate) {
|
||||
Status = Status + "\nWARNING : those informations will be obsolete for the next Pick\n"
|
||||
+"to get the real status of the selector - make One pick and call Status again\n";
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SortResult
|
||||
//purpose : on a un certain nombre d'entites rangees avec leur critere
|
||||
// (profondeur, taille, priorite , distance de la souris
|
||||
// par rapport aux bords ou au CDG de la primitive detectee.
|
||||
// on va trier :
|
||||
// les priorites maxi.
|
||||
// puis un savant dosage entre profondeur et distance...
|
||||
// enfin on stocke dans myindexes les rangs en fonction de ce tri.
|
||||
// il ne reste plus qu'a lire
|
||||
//=======================================================================
|
||||
void SelectMgr_ViewerSelector::SortResult()
|
||||
{
|
||||
if(mystored.IsEmpty()) return;
|
||||
|
||||
const Standard_Integer anExtent = mystored.Extent();
|
||||
if(myIndexes.IsNull() || anExtent != myIndexes->Length())
|
||||
myIndexes = new TColStd_HArray1OfInteger (1, anExtent);
|
||||
|
||||
// pour travailler plus vite...
|
||||
TColStd_Array1OfInteger& thearr = myIndexes->ChangeArray1();
|
||||
|
||||
// on charge les index de 1 a N
|
||||
Standard_Integer I ;
|
||||
for (I=1; I <= anExtent; I++)
|
||||
thearr(I)=I;
|
||||
|
||||
// OCC4201 (AGV): This loop is inefficient on large arrays, so I replace it
|
||||
// with a standard sort algo
|
||||
// // on trie suivant les criteres (i) (Owner) (SortCriterion)
|
||||
// Standard_Boolean OKSort;
|
||||
// Standard_Integer temp,indx,indx1;
|
||||
// Standard_Integer tmprim;
|
||||
// // merci lbr...
|
||||
// do{
|
||||
// OKSort =Standard_True;
|
||||
// for(I=1;I<thearr.Length();I++){
|
||||
// indx = thearr(I);
|
||||
// indx1 = thearr(I+1);
|
||||
// if(mystored(indx) < mystored(indx1)){
|
||||
// OKSort = Standard_False;
|
||||
//
|
||||
// temp = thearr(I+1);
|
||||
// thearr(I+1) = thearr (I);
|
||||
// thearr(I) = temp;
|
||||
//
|
||||
// tmprim = myprim(I+1);
|
||||
// myprim(I+1) = myprim(I);
|
||||
// myprim(I) = tmprim;
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// } while (OKSort==Standard_False);
|
||||
//
|
||||
// OCC4201 (AGV): debut
|
||||
|
||||
SortTools_QuickSortOfInteger::Sort (thearr,
|
||||
SelectMgr_CompareResults(mystored));
|
||||
TColStd_Array1OfInteger myPrimArr (1, myprim.Length());
|
||||
for (I = 1; I <= myPrimArr.Length(); I++)
|
||||
myPrimArr (I) = myprim (I);
|
||||
for (I = 1; I <= thearr.Length(); I++) {
|
||||
const Standard_Integer ind = thearr(I);
|
||||
if (ind > 0 && ind <= myPrimArr.Upper())
|
||||
myprim (I) = myPrimArr (ind);
|
||||
}
|
||||
// OCC4201 (AGV): fin
|
||||
// ne nous restera plus qu'a recuperer les proprietaires correspondant aux index tries...
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean SelectMgr_ViewerSelector::IsUpdateSortPossible() const
|
||||
{
|
||||
return myUpdateSortPossible;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SelectMgr_ViewerSelector::SetUpdateSortPossible( const Standard_Boolean possible )
|
||||
{
|
||||
myUpdateSortPossible = possible;
|
||||
}
|
24
src/SelectMgr/SelectMgr_ViewerSelector.lxx
Executable file
24
src/SelectMgr/SelectMgr_ViewerSelector.lxx
Executable file
@@ -0,0 +1,24 @@
|
||||
#define OCC9026 //AEL Additional method to optimize performance
|
||||
//of the FindSelectedOwnerFromShape() method.
|
||||
|
||||
inline void SelectMgr_ViewerSelector::Init()
|
||||
{
|
||||
myCurRank = 1;
|
||||
}
|
||||
|
||||
inline void SelectMgr_ViewerSelector::Next()
|
||||
{
|
||||
myCurRank++;
|
||||
}
|
||||
|
||||
inline void SelectMgr_ViewerSelector::SetPickClosest (const Standard_Boolean preferClosest)
|
||||
{
|
||||
preferclosest = preferClosest;
|
||||
}
|
||||
|
||||
#ifdef OCC9026
|
||||
inline const SelectMgr_DataMapOfIntegerSensitive& SelectMgr_ViewerSelector::Primitives() const
|
||||
{
|
||||
return myentities;
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user