Salome HOME
Selection correction for "objects" type defined in XML. It is not possible to use...
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_ResultPrs.h
4 // Created:     21 October 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef ModuleBase_ResultPrs_H
8 #define ModuleBase_ResultPrs_H
9
10 #include "ModuleBase.h"
11
12 #include <ModelAPI_Result.h>
13
14 #include <ViewerData_AISShape.hxx>
15 #include <Standard_DefineHandle.hxx>
16 #include <StdSelect_BRepOwner.hxx>
17
18 #include <QMap>
19
20 DEFINE_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner)
21
22 /**
23 * \ingroup GUI
24 * A redefinition of standard BRep Owner in order to provide specific selection
25 * of CompSolid objects. This owner is created only for selection mode TopAbs_COMPSOLID
26 */
27 class ModuleBase_BRepOwner: public StdSelect_BRepOwner
28 {
29 public:
30   /// Constructor
31   /// \param aShape an owner shape
32   /// \param aPriority drawig priority
33   /// \param ComesFromDecomposition decomposition flag
34   ModuleBase_BRepOwner(const TopoDS_Shape& aShape, 
35     const Standard_Integer aPriority = 0, 
36     const Standard_Boolean ComesFromDecomposition = Standard_False)
37     : StdSelect_BRepOwner(aShape, aPriority, ComesFromDecomposition) {}
38
39   /// Highlight the presentation with the given color
40   /// \param aPM a presentations manager
41   /// \param aCol a color
42   /// \param aMode a drawing mode
43   virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM, 
44     const Quantity_NameOfColor aCol, const Standard_Integer aMode = 0)
45   {  Selectable()->HilightOwnerWithColor(aPM, aCol, this); }
46
47   DEFINE_STANDARD_RTTI(ModuleBase_BRepOwner)
48 };
49
50
51
52 DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, ViewerData_AISShape)
53
54 /**
55 * \ingroup GUI
56 * A redefinition of standard AIS Interactive Object in order to provide specific behaviour 
57 * for wire presentations based in a one plane
58 */
59 class ModuleBase_ResultPrs: public ViewerData_AISShape
60 {
61 public:
62   enum SelectionModes {
63     Sel_Result = TopAbs_SHAPE + 1 /// it should be combined with Compsolid results, so it is not
64                                   /// the Shape type. It is not defined in XML as compound type
65                                   /// because this type is processed as shape with compounds inside.
66   };
67
68 public:
69   /// Constructor
70   /// \param theResult a result object
71   Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
72
73   //! Method which draws selected owners ( for fast presentation draw )
74   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
75                                                const SelectMgr_SequenceOfOwner& theOwners);
76   
77   //! Method which hilight an owner belonging to
78   //! this selectable object  ( for fast presentation draw )
79   Standard_EXPORT virtual void HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
80                                                      const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner);
81
82   /// Returns result object
83   Standard_EXPORT ResultPtr getResult() const { return myResult; }
84
85   /// Returns selection priorities that will be added to created selection owner
86   /// \return integer value
87   Standard_EXPORT int getAdditionalSelectionPriority() const { return myAdditionalSelectionPriority; }
88
89   /// Appends a special priority for the mode of selection
90   /// \param theSelectionMode a mode of selection, used in ComputeSelection
91   /// \param thePriority a new priority value
92   Standard_EXPORT void setAdditionalSelectionPriority(const int thePriority);
93
94   DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs)
95 protected:
96   /// Redefinition of virtual function
97   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
98     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
99
100   /// Redefinition of virtual function
101   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
102     const Standard_Integer aMode) ;
103
104 private:
105   /// Appens sensitive and owners for wires of the given shape into selection
106   /// \param theSelection a current filled selection
107   /// \param theShape a shape
108   void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
109                             const TopoDS_Shape& theShape);
110
111   /// Reference to result object
112   ResultPtr myResult;
113
114   /// Original shape of the result object
115   TopoDS_Shape myOriginalShape;
116   /// selection priority that will be added to the standard selection priority of the selection entity
117   int myAdditionalSelectionPriority;
118 };
119
120
121 #endif