Salome HOME
4eed19ac3f78d349a7a78b79ce134cf4e7d265d0
[modules/shaper.git] / src / PartSet / PartSet_ExternalPointsMgr.h
1 // Copyright (C) 2017-2023  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 email : webmaster.salome@opencascade.com
18 //
19
20 // File:        PartSet_ExternalPointsMgr.h
21 // Created:     26 April 2017
22 // Author:      Vitaly SMETANNIKOV
23
24 #ifndef PartSet_ExternalPointsMgr_H
25 #define PartSet_ExternalPointsMgr_H
26
27
28 #include <ModelAPI_CompositeFeature.h>
29 #include <ModelAPI_Result.h>
30 #include <GeomAPI_Pln.h>
31 #include <GeomAPI_AISObject.h>
32
33 #include <QObject>
34 #include <QMap>
35
36 class ModuleBase_ViewerPrs;
37 class ModuleBase_IWorkshop;
38
39
40 /**
41 * \ingroup Modules
42 * A class to manage display of presentations of center points of circular
43 * edges outside of a current sketcher
44 */
45 class PartSet_ExternalPointsMgr: public QObject
46 {
47   Q_OBJECT
48 public:
49   PartSet_ExternalPointsMgr(ModuleBase_IWorkshop* theWorkshop,
50                             const CompositeFeaturePtr& theSketch);
51
52   virtual ~PartSet_ExternalPointsMgr();
53
54 public slots:
55   /**
56   * A slot which processes display of object
57   * \param theObj the displayed object
58   * \param theAIS its presentation
59   */
60   void onDisplayObject(ObjectPtr theObj, AISObjectPtr theAIS);
61
62   /**
63   * A slot which processes erase of object
64   * \param theObj the displayed object
65   * \param theAIS its presentation
66   */
67   void onEraseObject(ObjectPtr theObj, AISObjectPtr theAIS);
68
69   // Called on selection changed
70   void onSelectionChanged();
71
72 private:
73   /**
74   * Returns list of presentations which have displayed shapes with circular edges
75   * (circles, arcs) which are in pane of of the given sketch
76   * \param theSketch - the sketch
77   */
78   QList<std::shared_ptr<ModuleBase_ViewerPrs>> findCircularEdgesInPlane();
79
80   /// Creates presentations of centers
81   void updateCenterPresentations();
82
83   /// Returns plane of the current sketch
84   GeomPlanePtr plane() const;
85
86   /**
87   * Checks that the given object is an object of the current sketch
88   * \param theRes an object to check
89   * \return True if the given object is a sub-object of the current sketch
90   */
91   bool isSketchObject(const ObjectPtr& theRes) const;
92
93 private:
94   /// Workshop
95   ModuleBase_IWorkshop* myWorkshop;
96
97   /// Current sketch
98   CompositeFeaturePtr mySketch;
99
100   /// Type for list of created AIS objects
101   typedef QList<AISObjectPtr> ListOfAIS;
102
103   /// Map of created AIS objects
104   QMap<ObjectPtr, ListOfAIS> myPresentations;
105 };
106
107 #endif