]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetPoint2dAngle.cpp
Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2dAngle.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetPoint2dAngle.h
4 // Created:     23 June 2014
5 // Author:      Vitaly Smetannikov
6
7 #include "PartSet_WidgetPoint2dAngle.h"
8
9 #include <ModuleBase_ParamSpinBox.h>
10
11 #include <ModuleBase_Tools.h>
12
13 #include <GeomAPI_Pnt2d.h>
14 #include <GeomDataAPI_Point2D.h>
15
16 #include <ModelAPI_Data.h>
17 #include <ModelAPI_AttributeDouble.h>
18
19 #include <QMouseEvent>
20
21 #include <GeomAPI_Dir2d.h>
22 #include <GeomAPI_XY.h>
23
24 #define PI 3.1415926535897932
25
26 PartSet_WidgetPoint2dAngle::PartSet_WidgetPoint2dAngle(QWidget* theParent,
27                                                        const Config_WidgetAPI* theData,
28                                                        const std::string& theParentId)
29 : PartSet_WidgetPoint2dDistance(theParent, theData, theParentId)
30 {
31 }
32
33 PartSet_WidgetPoint2dAngle::~PartSet_WidgetPoint2dAngle()
34 {
35 }
36
37 double PartSet_WidgetPoint2dAngle::computeValue(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPnt,
38                                                 const std::shared_ptr<GeomAPI_Pnt2d>& theCurrentPnt)
39 {
40   std::shared_ptr<GeomAPI_Dir2d> aHorizontalDir(new GeomAPI_Dir2d(1, 0));
41   std::shared_ptr<GeomAPI_XY> aStartPnt = theFirstPnt->xy();
42   std::shared_ptr<GeomAPI_XY> aEndPnt = theCurrentPnt->xy();
43
44   std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
45
46   double aValue = aHorizontalDir->angle(aLineDir);
47   aValue *= 180.0 / PI;
48
49   return aValue;
50 }