Salome HOME
Multiple fixes (issue #1757 , issue #1799 , issue #1842 , etc):
[modules/shaper.git] / src / Model / Model_SelectionNaming.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_SelectionNaming.h
4 // Created:     11 Aug 2015
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_SelectionNaming_H_
8 #define Model_SelectionNaming_H_
9
10 #include <ModelAPI_Result.h>
11 #include <GeomAPI_Shape.h>
12 #include <Model_Document.h>
13 #include <TDF_Label.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <NCollection_DataMap.hxx>
16 #include <Geom_Curve.hxx>
17 #include <TopoDS_Edge.hxx>
18
19 /**\class Model_SelectionNaming
20  * \ingroup DataModel
21  * \brief The set of methods that allow to generate a string-name for the selection attribute.
22  */
23
24 class Model_SelectionNaming
25 {
26   TDF_Label myLab; ///< Selection label of the selection attribute
27 public:
28   /// Constructor for the selection attribute by the selection label
29   Model_SelectionNaming(TDF_Label theSelectionLab);
30
31   /// Produces the string-name for the selected shape
32   std::string namingName(ResultPtr& theContext, std::shared_ptr<GeomAPI_Shape> theSubSh,
33     const std::string& theDefaultName, const bool theAnotherDoc);
34   
35   /// Makes a selection by the string-name
36   /// \param theType string of the type of the shape
37   /// \param theSubShapeName string-identifier of the selected shape
38   /// \param theDoc document where the selected shape is searched
39   /// \param theShapeToBeSelected resulting selected shape
40   /// \param theCont the selection context of the resulting selected shape
41   bool selectSubShape(const std::string& theType, const std::string& theSubShapeName,
42     std::shared_ptr<Model_Document> theDoc, std::shared_ptr<GeomAPI_Shape>& theShapeToBeSelected,
43     std::shared_ptr<ModelAPI_Result>& theCont);
44
45   /// Searches the face more appropriate to the given curves (with higher level of matched parameters)
46   /// \param theConstr construction result that contains one or several  faces
47   /// \param theCurves map from the face edges curves to orientation (-1 reversed, 0 unknown, 1 forward)
48   /// \param theIsWire for wire algorithm isquite the same, but if in face several wires, it returns the needed wire
49   /// \returns faces fron this construction if found
50   static std::shared_ptr<GeomAPI_Shape> findAppropriateFace(
51     std::shared_ptr<ModelAPI_Result>& theConstr, 
52     NCollection_DataMap<Handle(Geom_Curve), int>& theCurves, const bool theIsWire);
53
54   /// Returns orientation of the edge in the context shape
55   static int edgeOrientation(const TopoDS_Shape& theContext, TopoDS_Edge& theEdge);
56
57   /// Returns the name of sketch sub-element, shortened by exclusion of some symbols and with added
58   /// the vertex position (if needed)
59   /// \param theConstr result with name - basis for the name
60   /// \param theEdgeVertexPos position of the vertex on edge: 1 - first , 2 - second
61   /// \returns the generated name
62   static std::string shortName(std::shared_ptr<ModelAPI_ResultConstruction>& theConstr,
63     const int theEdgeVertexPos = 0);
64
65 protected:
66   /// Gets the stored name from the document
67   std::string getShapeName(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape& theShape,
68     ResultPtr& theContext, const bool theAnotherDoc, const bool theWholeContext);
69 };
70
71 #endif