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