SHAPER  9.12.0
SketcherPrs_PositionMgr.h
1 // Copyright (C) 2014-2023 CEA, EDF
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 #ifndef SketcherPrs_PositionMgr_H
21 #define SketcherPrs_PositionMgr_H
22 
23 #include "SketcherPrs.h"
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 #include <array>
33 
40 {
41 public:
43  SKETCHERPRS_EXPORT static SketcherPrs_PositionMgr* get();
44 
49  SKETCHERPRS_EXPORT gp_Pnt getPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
50  double theStep = 20, GeomPointPtr thePnt = GeomPointPtr());
51 
54  SKETCHERPRS_EXPORT void deleteConstraint(const SketcherPrs_SymbolPrs* thePrs);
55 
57  void clearAll() { myShapes.clear(); myPntShapes.clear(); }
58 
59 private:
62 
66  int getPositionIndex(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs);
67 
71  const std::array<int, 2>& getPositionIndex(GeomPointPtr thePos,
72  const SketcherPrs_SymbolPrs* thePrs);
73 
79  gp_Pnt getPointPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
80  double theStep, GeomPointPtr thePnt);
81 
82  static bool isPntConstraint(const std::string& theName);
83 
84 private:
85  typedef std::map<const SketcherPrs_SymbolPrs*, int> PositionsMap;
86  typedef std::map<const ModelAPI_Feature*, std::array<int, 2>> FeaturesMap;
87 
89  std::map<ObjectPtr, PositionsMap> myShapes;
90 
92  FeaturesMap myPntShapes;
93 };
94 
95 #endif
A class Position Manager which manages position of constraints symbols along a source object line.
Definition: SketcherPrs_PositionMgr.h:40
gp_Pnt getPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs *thePrs, double theStep=20, GeomPointPtr thePnt=GeomPointPtr())
Returns position of symbol for the given presentation.
Definition: SketcherPrs_PositionMgr.cpp:233
static SketcherPrs_PositionMgr * get()
Returns current instance of position manager.
Definition: SketcherPrs_PositionMgr.cpp:54
void clearAll()
Cleares all stored positions for all constraints.
Definition: SketcherPrs_PositionMgr.h:57
void deleteConstraint(const SketcherPrs_SymbolPrs *thePrs)
Deletes constraint object from internal structures.
Definition: SketcherPrs_PositionMgr.cpp:475
A base class of constraint presentation which is represented by an icon.
Definition: SketcherPrs_SymbolPrs.h:52