]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_PositionMgr.h
Salome HOME
Issue #2208: positioning of tangent and perpendicular symbols
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_PositionMgr.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 SketcherPrs_PositionMgr_H
22 #define SketcherPrs_PositionMgr_H
23
24 #include "SketcherPrs_SymbolPrs.h"
25
26 #include <GeomAPI_Shape.h>
27 #include <GeomAPI_Pnt.h>
28 #include <gp_Pnt.hxx>
29 #include <ModelAPI_Object.h>
30
31 #include <map>
32
33 /**
34 * \ingroup GUI
35 * A class Position Manager which manages position of constraints symbols along a source object line.
36 * it expects that symbol icons have size 16x16 px
37 */
38 class SketcherPrs_PositionMgr
39 {
40 public:
41   /// Returns current instance of position manager
42   static SketcherPrs_PositionMgr* get();
43
44   /// Returns position of symbol for the given presentation
45   /// \param theLine constrained object
46   /// \param thePrs a presentation of constraint
47   /// \param theStep step between symbols
48   gp_Pnt getPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
49                      double theStep = 20, GeomPointPtr thePnt = GeomPointPtr());
50
51   /// Deletes constraint object from internal structures. Has to be called on constraint delete.
52   /// \param thePrs a constraint presentation
53   void deleteConstraint(const SketcherPrs_SymbolPrs* thePrs);
54
55 private:
56   /// Constructor
57   SketcherPrs_PositionMgr();
58
59   /// Returns position index of the given constraint
60   /// \param theLine constrained object
61   /// \param thePrs a presentation of constraint
62   int getPositionIndex(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs);
63
64   gp_Pnt getPointPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
65                           double theStep, GeomPointPtr thePnt);
66
67 private:
68   typedef std::map<const SketcherPrs_SymbolPrs*, int> PositionsMap;
69
70   /// The map which contains position of presentation
71   PositionsMap myIndexes;
72
73   /// The map contains position index
74   std::map<ObjectPtr, PositionsMap> myShapes;
75 };
76
77 #endif