Salome HOME
Revert selection of compsolid in RemoveSubshapes feature
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintMulti.h
1 // Copyright (C) 2014-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 #ifndef SketchSolver_ConstraintMulti_H_
22 #define SketchSolver_ConstraintMulti_H_
23
24 #include <SketchSolver_Constraint.h>
25
26 #include <vector>
27
28 /** \class   SketchSolver_ConstraintMulti
29  *  \ingroup Plugins
30  *  \brief   Common base class for the Multi constraints
31  */
32 class SketchSolver_ConstraintMulti : public SketchSolver_Constraint
33 {
34 public:
35   /// Constructor based on SketchPlugin constraint
36   SketchSolver_ConstraintMulti(ConstraintPtr theConstraint) :
37       SketchSolver_Constraint(theConstraint),
38       myNumberOfObjects(0),
39       myNumberOfCopies(0),
40       myIsFullValue(false),
41       myAdjusted(false),
42       myIsEventsBlocked(false),
43       myIsProcessingNotify(false)
44   {}
45
46   /// \brief Update constraint
47   virtual void update();
48
49   /// \brief Notify this object about the feature is changed somewhere
50   virtual void notify(const FeaturePtr& theFeature, PlaneGCSSolver_Update*);
51
52   /// \brief Tries to remove constraint
53   /// \return \c false, if current constraint contains another SketchPlugin
54   /// constraints (like for multiple coincidence)
55   virtual bool remove();
56
57   /// \brief Block or unblock events from this constraint
58   virtual void blockEvents(bool isBlocked);
59
60 protected:
61   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
62   virtual void process()
63   { /* do nothing here */ }
64
65   /// \brief Collect entities which are translated or rotated (not their copies)
66   void getEntities(std::list<EntityWrapperPtr>& theEntities);
67
68   /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
69   virtual void getAttributes(EntityWrapperPtr&, std::vector<EntityWrapperPtr>&)
70   { /* do nothing here */ }
71
72   /// \brief This method is used in derived objects to check consistence of constraint.
73   virtual void adjustConstraint();
74
75   /// \brief Update parameters of derived classes
76   virtual void updateLocal() = 0;
77
78   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
79   virtual const std::string& nameNbObjects() = 0;
80
81 protected:
82   /// \brief Convert absolute coordinates to relative coordinates
83   virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
84   /// \brief Convert relative coordinates to absolute coordinates
85   virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
86   /// \brief Apply transformation for relative coordinates
87   virtual void transformRelative(double& theX, double& theY) = 0;
88
89 protected:
90   int myNumberOfObjects; ///< number of previous initial objects
91   int myNumberOfCopies;  ///< number of previous copies of initial objects
92   bool myIsFullValue;    ///< value whether the angle/distance is a full or single for objects
93
94   bool myAdjusted; ///< the constraint is already adjusted (to not do it several times)
95
96   /// lists of original features and their copies to find whether some of them are disappeared
97   std::set<FeaturePtr> myOriginalFeatures;
98   std::set<FeaturePtr> myCopiedFeatures;
99
100   bool myIsEventsBlocked;
101   bool myIsProcessingNotify; ///< the notification is already processing
102 };
103
104 #endif