]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetPoint2dAngle.cpp
Salome HOME
A correction to check modified value in extrusion cut/sketch/etc operations.
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2dAngle.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_WidgetPoint2dAngle.cpp
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                                                        ModuleBase_IWorkshop* theWorkshop,
28                                                        const Config_WidgetAPI* theData,
29                                                        const std::string& theParentId)
30 : PartSet_WidgetPoint2dDistance(theParent, theWorkshop, theData, theParentId)
31 {
32 }
33
34 PartSet_WidgetPoint2dAngle::~PartSet_WidgetPoint2dAngle()
35 {
36 }
37
38 double PartSet_WidgetPoint2dAngle::computeValue(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPnt,
39                                                 const std::shared_ptr<GeomAPI_Pnt2d>& theCurrentPnt)
40 {
41   std::shared_ptr<GeomAPI_Dir2d> aHorizontalDir(new GeomAPI_Dir2d(1, 0));
42   std::shared_ptr<GeomAPI_XY> aStartPnt = theFirstPnt->xy();
43   std::shared_ptr<GeomAPI_XY> aEndPnt = theCurrentPnt->xy();
44
45   std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
46
47   double aValue = aHorizontalDir->angle(aLineDir);
48   aValue *= 180.0 / PI;
49
50   return aValue;
51 }