Salome HOME
Make symbols of constraints with fixed distance
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_PositionMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_PositionMgr.h
4 // Created:     13 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef SketcherPrs_PositionMgr_H
8 #define SketcherPrs_PositionMgr_H
9
10 #include "SketcherPrs_SymbolPrs.h"
11
12 #include <GeomAPI_Shape.h>
13 #include <gp_Pnt.hxx>
14 #include <ModelAPI_Object.h>
15
16 #include <map>
17
18 /**
19 * \ingroup GUI
20 * A class Position Manager which manages position of constraints symbols along a source object line.
21 * it expects that symbol icons have size 16x16 px
22 */
23 class SketcherPrs_PositionMgr
24 {
25 public:
26   /// Returns current instance of position manager
27   static SketcherPrs_PositionMgr* get();
28
29   /// Returns position of symbol for the given presentation
30   /// \param theLine constrained object 
31   /// \param thePrs a presentation of constraint
32   /// \param theStep step between symbols
33   gp_Pnt getPosition(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs, double theStep = 20);
34
35   /// Deletes constraint object from internal structures. Has to be called on constraint delete.
36   /// \param thePrs a constraint presentation
37   void deleteConstraint(Handle(SketcherPrs_SymbolPrs) thePrs);
38
39 private:
40   /// Constructor
41   SketcherPrs_PositionMgr();
42
43   /// Returns position index of the given constraint
44   /// \param theLine constrained object 
45   /// \param thePrs a presentation of constraint
46   int getPositionIndex(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
47
48 private:
49   typedef std::map<void*, int> PositionsMap;
50
51   /// The map which contains position of presentation
52   PositionsMap myIndexes;
53
54   /// The map contains position index 
55   std::map<ObjectPtr, PositionsMap> myShapes;
56 };
57
58 #endif