Salome HOME
oubli
[modules/shaper.git] / src / SketchAPI / SketchAPI_Rectangle.cpp
index f9ee374e5b93cdf0fc2eaa2da1874b85fdd8b378..21f4f276fd85d3e88fe76fcda7e5c6afb01dd7bf 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -33,9 +33,8 @@ SketchAPI_Rectangle::SketchAPI_Rectangle(
   initialize();
 }
 
-SketchAPI_Rectangle::SketchAPI_Rectangle(
-    const std::shared_ptr<ModelAPI_Feature> & theFeature,
-    double theX1, double theY1, double theX2, double theY2)
+SketchAPI_Rectangle::SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                                         double theX1, double theY1, double theX2, double theY2)
   : SketchAPI_SketchEntity(theFeature)
 {
   if (initialize()) {
@@ -43,14 +42,13 @@ SketchAPI_Rectangle::SketchAPI_Rectangle(
   }
 }
 
-SketchAPI_Rectangle::SketchAPI_Rectangle(
-    const std::shared_ptr<ModelAPI_Feature> & theFeature,
-    const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
-    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+SketchAPI_Rectangle::SketchAPI_Rectangle(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                                         const std::shared_ptr<GeomAPI_Pnt2d> & theFirstPoint,
+                                         const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
   : SketchAPI_SketchEntity(theFeature)
 {
   if (initialize()) {
-    setByPoints(theStartPoint, theEndPoint);
+    setByPoints(theFirstPoint, theEndPoint);
   }
 }
 
@@ -62,19 +60,18 @@ SketchAPI_Rectangle::~SketchAPI_Rectangle()
 void SketchAPI_Rectangle::setByCoordinates(
     double theX1, double theY1, double theX2, double theY2)
 {
+  fillAttribute("RectangleTypeByCorners", type());
   fillAttribute(startPoint(), theX1, theY1);
   fillAttribute(endPoint(), theX2, theY2);
-
   execute();
 }
 
-void SketchAPI_Rectangle::setByPoints(
-    const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
-    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+void SketchAPI_Rectangle::setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theFirstPoint,
+                                      const std::shared_ptr<GeomAPI_Pnt2d> & theSecondPoint)
 {
-  fillAttribute(theStartPoint, startPoint());
-  fillAttribute(theEndPoint, endPoint());
-
+  fillAttribute("RectangleTypeByCorners", type());
+  fillAttribute(theFirstPoint, startPoint());
+  fillAttribute(theSecondPoint, endPoint());
   execute();
 }
 
@@ -89,34 +86,3 @@ std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Rectangle::lines()
     aFeatures.push_back(ModelAPI_Feature::feature(*anIt));
   return SketchAPI_SketchEntity::wrap(aFeatures);
 }
-
-//==================================================================================================
-void SketchAPI_Rectangle::dump(ModelHighAPI_Dumper& theDumper) const
-{
-
- FeaturePtr aBase = feature();
-
-  /// do not dump sub-features eg: lines and lines constraints
-  AttributeRefListPtr noToDumpList =  aBase->reflist(SketchPlugin_Rectangle::NOT_TO_DUMP_LIST_ID());
-  for( int i = 0; i < noToDumpList->size(); i++){
-    theDumper.doNotDumpFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(noToDumpList->object(i)));
-  }
-
-  if (isCopy())
-    return; // no need to dump copied feature
-
-  const std::string& aSketchName = theDumper.parentName(aBase);
-
-  AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
-  if (anExternal->context()) {
-    // rectangle is external
-    theDumper << aBase << " = " << aSketchName << ".addRectangle(" << anExternal << ")" << std::endl;
-  } else {
-    // rectangle given by start and end points
-    theDumper << aBase << " = " << aSketchName << ".addRectangle("
-              << startPoint() << ", " << endPoint() << ")" << std::endl;
-  }
-  // dump "auxiliary" flag if necessary
-  SketchAPI_SketchEntity::dump(theDumper);
-
-}