Salome HOME
d38e0bd2906334eb58993925b777ca6841d03d13
[modules/shaper.git] / src / ModuleBase / ModuleBase_ArrowPrs.h
1 // Copyright (C) 2014-2023  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
18 //
19
20 #ifndef ModuleBase_ArrowPrs_H
21 #define ModuleBase_ArrowPrs_H
22
23 #include <ModuleBase.h>
24 #include <GeomAPI_Edge.h>
25 #include <AIS_InteractiveContext.hxx>
26
27 #include <map>
28
29 DEFINE_STANDARD_HANDLE(ModuleBase_ArrowPrs, AIS_InteractiveContext)
30
31 /**
32 * \ingroup GUI
33 * A presentation class for displaying a direction of edge
34 */
35
36 class ModuleBase_ArrowPrs : public AIS_InteractiveContext
37 {
38 public:
39   /// Constructor
40   /// \param theViewer a viewer which theEdge is displaying.
41   /// \param theEdge an edge whose direction to display.
42   Standard_EXPORT ModuleBase_ArrowPrs(const Handle(V3d_Viewer)& theViewer,
43                                       const GeomEdgePtr& theEdge);
44
45   /// Returns an edge shape
46   GeomEdgePtr Edge() const { return myEdge; }
47
48   /// Draw arrow that represent direction of the edge.
49   Standard_EXPORT void DrawArrow(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor);
50
51   /// \brief Compare addresses of edges
52   class Comparator
53   {
54   public:
55     /// Return \c true if the address of the first edge is less than the address of the second
56     MODULEBASE_EXPORT
57       bool operator ()(const std::shared_ptr<GeomAPI_Edge>& theEdge1,
58                        const std::shared_ptr<GeomAPI_Edge>& theEdge2) const;
59   };
60
61   DEFINE_STANDARD_RTTIEXT(ModuleBase_ArrowPrs, AIS_InteractiveContext)
62
63 private:
64
65   /// The edge whose direction to display.
66   GeomEdgePtr myEdge;
67 };
68
69 typedef std::pair<GeomEdgePtr, Handle(ModuleBase_ArrowPrs)> EdgeDirection;
70 typedef std::map<GeomEdgePtr, Handle(ModuleBase_ArrowPrs), ModuleBase_ArrowPrs::Comparator> EdgesDirectionMap;
71
72 #endif