Salome HOME
Task 2.3: Creation of Intersection
[modules/shaper.git] / src / PartSet / PartSet_ExternalPointsMgr.h
1 // Copyright (C) 2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 // File:        PartSet_ExternalPointsMgr.h
22 // Created:     26 April 2017
23 // Author:      Vitaly SMETANNIKOV
24
25 #ifndef PartSet_ExternalPointsMgr_H
26 #define PartSet_ExternalPointsMgr_H
27
28
29 #include <ModelAPI_CompositeFeature.h>
30 #include <ModelAPI_Result.h>
31 #include <GeomAPI_Pln.h>
32 #include <GeomAPI_AISObject.h>
33
34 #include <QObject>
35 #include <QMap>
36
37 class ModuleBase_ViewerPrs;
38 class ModuleBase_IWorkshop;
39
40
41 /**
42 * \ingroup Modules
43 * A class to manage display of presentations of center points of circular
44 * edges outside of a current sketcher
45 */
46 class PartSet_ExternalPointsMgr: public QObject
47 {
48   Q_OBJECT
49 public:
50   PartSet_ExternalPointsMgr(ModuleBase_IWorkshop* theWorkshop,
51                             const CompositeFeaturePtr& theSketch);
52
53   virtual ~PartSet_ExternalPointsMgr();
54
55 public slots:
56   /**
57   * A slot which processes display of object
58   * \param theObj the displayed object
59   * \param theAIS its presentation
60   */
61   void onDisplayObject(ObjectPtr theObj, AISObjectPtr theAIS);
62
63   /**
64   * A slot which processes erase of object
65   * \param theObj the displayed object
66   * \param theAIS its presentation
67   */
68   void onEraseObject(ObjectPtr theObj, AISObjectPtr theAIS);
69
70   // Called on selection changed
71   void onSelectionChanged();
72
73 private:
74   /**
75   * Returns list of presentations which have displayed shapes with circular edges
76   * (circles, arcs) which are in pane of of the given sketch
77   * \param theSketch - the sketch
78   */
79   QList<std::shared_ptr<ModuleBase_ViewerPrs>> findCircularEdgesInPlane();
80
81   /// Creates presentations of centers
82   void updateCenterPresentations();
83
84   /// Returns plane of the current sketch
85   GeomPlanePtr plane() const;
86
87   /**
88   * Checks that the given object is an object of the current sketch
89   * \param theRes an object to check
90   * \return True if the given object is a sub-object of the current sketch
91   */
92   bool isSketchObject(const ObjectPtr& theRes) const;
93
94 private:
95   /// Workshop
96   ModuleBase_IWorkshop* myWorkshop;
97
98   /// Current sketch
99   CompositeFeaturePtr mySketch;
100
101   /// Type for list of created AIS objects
102   typedef QList<AISObjectPtr> ListOfAIS;
103
104   /// Map of created AIS objects
105   QMap<ObjectPtr, ListOfAIS> myPresentations;
106 };
107
108 #endif