Salome HOME
3da59f0ff8a220b4b3c1fc5cc7260b93bd4c78fa
[modules/shaper.git] / src / SketchAPI / SketchAPI_Rectangle.cpp
1 // Name   : SketchAPI_Rectangle.cpp
2 // Purpose: 
3 //
4 // History:
5 // 17/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Rectangle.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Pnt2d.h>
11 //--------------------------------------------------------------------------------------
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
14 //--------------------------------------------------------------------------------------
15 SketchAPI_Rectangle::SketchAPI_Rectangle(
16     const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
18 {
19   initialize();
20 }
21
22 SketchAPI_Rectangle::SketchAPI_Rectangle(
23     const std::shared_ptr<ModelAPI_Feature> & theFeature,
24     double theX1, double theY1, double theX2, double theY2)
25 : SketchAPI_SketchEntity(theFeature)
26 {
27   if (initialize()) {
28     setByCoordinates(theX1, theY1, theX2, theY2);
29   }
30 }
31
32 SketchAPI_Rectangle::SketchAPI_Rectangle(
33     const std::shared_ptr<ModelAPI_Feature> & theFeature,
34     const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
35     const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
36 : SketchAPI_SketchEntity(theFeature)
37 {
38   if (initialize()) {
39     setByPoints(theStartPoint, theEndPoint);
40   }
41 }
42
43 SketchAPI_Rectangle::~SketchAPI_Rectangle()
44 {
45 }
46
47 //--------------------------------------------------------------------------------------
48 void SketchAPI_Rectangle::setByCoordinates(
49     double theX1, double theY1, double theX2, double theY2)
50 {
51   fillAttribute(startPoint(), theX1, theY1);
52   fillAttribute(endPoint(), theX2, theY2);
53
54   execute();
55 }
56
57 void SketchAPI_Rectangle::setByPoints(
58     const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
59     const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
60 {
61   fillAttribute(theStartPoint, startPoint());
62   fillAttribute(theEndPoint, endPoint());
63
64   execute();
65 }
66
67 //--------------------------------------------------------------------------------------
68