]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
2D point selection in multi-rotation/multi-translation.
authornds <nds@opencascade.com>
Tue, 22 Dec 2015 10:29:16 +0000 (13:29 +0300)
committernds <nds@opencascade.com>
Tue, 22 Dec 2015 10:29:49 +0000 (13:29 +0300)
21 files changed:
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2dAngle.cpp [deleted file]
src/PartSet/PartSet_WidgetPoint2dAngle.h [deleted file]
src/SketchPlugin/SketchPlugin_MultiRotation.cpp
src/SketchPlugin/SketchPlugin_MultiRotation.h
src/SketchPlugin/SketchPlugin_MultiTranslation.cpp
src/SketchPlugin/SketchPlugin_Tools.cpp
src/SketchPlugin/SketchPlugin_Tools.h
src/SketchPlugin/Test/TestMultiRotation.py
src/SketchPlugin/Test/TestMultiTranslation.py
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Builder.h
src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp
src/SketchSolver/SketchSolver_ConstraintMultiRotation.h
src/SketchSolver/SketchSolver_ConstraintMultiTranslation.cpp
src/SketchSolver/SketchSolver_ConstraintMultiTranslation.h
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.h
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Transformation.cpp

index 05e04db0d625f32a8408a639cb3c6e10a14c22e0..743e937fe279fd8ebcdabc81e52575e604c5abf2 100644 (file)
@@ -15,7 +15,6 @@ SET(PROJECT_HEADERS
        PartSet_WidgetSketchLabel.h
        PartSet_Validators.h
        PartSet_WidgetPoint2d.h
-       PartSet_WidgetPoint2dAngle.h
        PartSet_WidgetEditor.h
        PartSet_WidgetMultiSelector.h
        PartSet_WidgetPoint2dDistance.h
@@ -43,7 +42,6 @@ SET(PROJECT_SOURCES
        PartSet_WidgetEditor.cpp
        PartSet_WidgetMultiSelector.cpp
        PartSet_WidgetPoint2d.cpp
-       PartSet_WidgetPoint2dAngle.cpp
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetPoint2DFlyout.cpp
        PartSet_WidgetShapeSelector.cpp
index ba4ba6680848f035e6aa5452f4cd6b0ab80c7bf8..fb633f631f74732dd83902a51aa880447962a1cf 100755 (executable)
@@ -8,7 +8,6 @@
 #include "PartSet_WidgetPoint2dDistance.h"
 #include "PartSet_WidgetPoint2DFlyout.h"
 #include "PartSet_WidgetShapeSelector.h"
-#include "PartSet_WidgetPoint2dAngle.h"
 #include "PartSet_WidgetMultiSelector.h"
 #include "PartSet_WidgetEditor.h"
 #include "PartSet_WidgetFileSelector.h"
@@ -512,11 +511,6 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
                                                         aWorkshop, theWidgetApi, theParentId);
     aDistanceWgt->setSketch(mySketchMgr->activeSketch());
     aWgt = aDistanceWgt;
-  } else if(theType == "point2dangle") {
-    PartSet_WidgetPoint2dAngle* anAngleWgt = new PartSet_WidgetPoint2dAngle(theParent,
-                                                           aWorkshop, theWidgetApi, theParentId);
-    anAngleWgt->setSketch(mySketchMgr->activeSketch());
-    aWgt = anAngleWgt;
   } else if (theType == "sketch_shape_selector") {
     PartSet_WidgetShapeSelector* aShapeSelectorWgt =
       new PartSet_WidgetShapeSelector(theParent, aWorkshop, theWidgetApi, theParentId);
diff --git a/src/PartSet/PartSet_WidgetPoint2dAngle.cpp b/src/PartSet/PartSet_WidgetPoint2dAngle.cpp
deleted file mode 100644 (file)
index 86c4def..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_WidgetPoint2dAngle.cpp
-// Created:     23 June 2014
-// Author:      Vitaly Smetannikov
-
-#include "PartSet_WidgetPoint2dAngle.h"
-
-#include <ModuleBase_ParamSpinBox.h>
-
-#include <ModuleBase_Tools.h>
-
-#include <GeomAPI_Pnt2d.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <QMouseEvent>
-
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_XY.h>
-
-#define PI 3.1415926535897932
-
-PartSet_WidgetPoint2dAngle::PartSet_WidgetPoint2dAngle(QWidget* theParent,
-                                                       ModuleBase_IWorkshop* theWorkshop,
-                                                       const Config_WidgetAPI* theData,
-                                                       const std::string& theParentId)
-: PartSet_WidgetPoint2dDistance(theParent, theWorkshop, theData, theParentId)
-{
-}
-
-PartSet_WidgetPoint2dAngle::~PartSet_WidgetPoint2dAngle()
-{
-}
-
-double PartSet_WidgetPoint2dAngle::computeValue(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPnt,
-                                                const std::shared_ptr<GeomAPI_Pnt2d>& theCurrentPnt)
-{
-  std::shared_ptr<GeomAPI_Dir2d> aHorizontalDir(new GeomAPI_Dir2d(1, 0));
-  std::shared_ptr<GeomAPI_XY> aStartPnt = theFirstPnt->xy();
-  std::shared_ptr<GeomAPI_XY> aEndPnt = theCurrentPnt->xy();
-
-  std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-
-  double aValue = aHorizontalDir->angle(aLineDir);
-  aValue *= 180.0 / PI;
-
-  return aValue;
-}
diff --git a/src/PartSet/PartSet_WidgetPoint2dAngle.h b/src/PartSet/PartSet_WidgetPoint2dAngle.h
deleted file mode 100644 (file)
index 93e4fdd..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_WidgetPoint2dAngle.h
-// Created:     30 Apr 2015
-// Author:      Natalia Ermolaeva
-
-#ifndef PartSet_WidgetPoint2dAngle_H
-#define PartSet_WidgetPoint2dAngle_H
-
-#include "PartSet.h"
-#include "PartSet_WidgetPoint2dDistance.h"
-
-#include <ModelAPI_Feature.h>
-
-class ModuleBase_IWorkshop;
-
-class GeomAPI_Pnt2d;
-
-/**
-* \ingroup Modules
-* Implementation of model widget for widget which provides input of an anble between two points
-* The XML definion is the same as the parent one.
-*/ 
-class PARTSET_EXPORT PartSet_WidgetPoint2dAngle : public PartSet_WidgetPoint2dDistance
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \param theParent the parent object
-  /// \param theWorkshop a current workshop
-  /// \param theData the widget configuation. The attribute of the model widget is obtained from
-  /// \param theParentId is Id of a parent of the current attribute
-  PartSet_WidgetPoint2dAngle(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
-                             const Config_WidgetAPI* theData, const std::string& theParentId);
-
-  virtual ~PartSet_WidgetPoint2dAngle();
-
-protected:
-  /// Compute an angle between points
-  /// \param theFirstPnt a point value of the out point attribute
-  /// \param theCurrentPnt a point of the current widget
-  /// \return a double value
-  virtual double computeValue(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPnt,
-                              const std::shared_ptr<GeomAPI_Pnt2d>& theCurrentPnt);
-};
-
-#endif
index bd7fec21fbeb3e5f7064b8fe53b4c72191cf908c..e878ea50d612b3a9db9d9899f0ec7bb2879f4853 100755 (executable)
@@ -8,6 +8,7 @@
 #include "SketchPlugin_Tools.h"
 
 #include <GeomDataAPI_Point2D.h>
+#include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeInteger.h>
 #define PI 3.1415926535897932
 
 SketchPlugin_MultiRotation::SketchPlugin_MultiRotation()
-: myBlockAngle(false)
 {
 }
 
 void SketchPlugin_MultiRotation::initAttributes()
 {
-  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(CENTER_ID(), ModelAPI_AttributeRefAttr::typeId());
 
   data()->addAttribute(ANGLE_TYPE(),   ModelAPI_AttributeString::typeId());
   data()->addAttribute(ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(ANGLE_FULL_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(NUMBER_OF_OBJECTS_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
@@ -61,26 +60,15 @@ void SketchPlugin_MultiRotation::execute()
     return;
 
   // Obtain center and angle of rotation
-  std::shared_ptr<GeomDataAPI_Point2D> aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      attribute(CENTER_ID()));
+  AttributeRefAttrPtr aCenter = data()->refattr(CENTER_ID());
   if (!aCenter || !aCenter->isInitialized())
     return;
 
-  if (attribute(ANGLE_ID())->isInitialized() && !attribute(ANGLE_FULL_ID())->isInitialized()) {
-    myBlockAngle = true;
-    SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()),
-                                             aNbCopies, true);
-    myBlockAngle = false;
-  }
-
-  // make a visible points
-  SketchPlugin_Sketch::createPoint2DResult(this, sketch(), CENTER_ID(), 0);
-
-  double anAngle = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-                                                             attribute(ANGLE_ID()))->value();
+  //double anAngle = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+  //                                                           attribute(ANGLE_ID()))->value();
 
   // Convert angle to radians
-  anAngle *= PI / 180.0;
+  //anAngle *= PI / 180.0;
 
   // Wait all objects being created, then send update events
   static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
@@ -250,7 +238,7 @@ ObjectPtr SketchPlugin_MultiRotation::copyFeature(ObjectPtr theObject)
   return ObjectPtr();
 }
 
-void SketchPlugin_MultiRotation::rotateFeature(
+/*void SketchPlugin_MultiRotation::rotateFeature(
     ObjectPtr theInitial, ObjectPtr theTarget,
     double theCenterX, double theCenterY, double theAngle)
 {
@@ -288,7 +276,7 @@ void SketchPlugin_MultiRotation::rotateFeature(
 
   // unblock feature update
   aTargetFeature->data()->blockSendAttributeUpdated(false);
-}
+}*/
 
 
 void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
@@ -325,45 +313,4 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID)
         data()->attribute(SketchPlugin_Constraint::ENTITY_B()))->clear();
     }
   }
-  else if (theID == ANGLE_ID() && !myBlockAngle) {
-    int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1;
-    if (aNbCopies > 0) {
-      myBlockAngle = true;
-      SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()),
-                                               aNbCopies, true);
-      myBlockAngle = false;
-      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-    }
-  }
-  else if (theID == ANGLE_FULL_ID() && !myBlockAngle) {
-    int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1;
-    if (aNbCopies > 0) {
-      myBlockAngle = true;
-      SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_FULL_ID()), attribute(ANGLE_ID()),
-                                               aNbCopies, false);
-      myBlockAngle = false;
-      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-    }
-  }
-  else if (theID == NUMBER_OF_OBJECTS_ID()) {
-    if (attribute(NUMBER_OF_OBJECTS_ID())->isInitialized() &&
-        attribute(ANGLE_ID())->isInitialized() &&
-        attribute(ANGLE_TYPE())->isInitialized()) {
-      AttributeStringPtr aMethodTypeAttr = string(ANGLE_TYPE());
-      std::string aMethodType = aMethodTypeAttr->value();
-      int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value() - 1;
-      if (aNbCopies > 0) {
-        myBlockAngle = true;
-        if (aMethodType == "SingleAngle")
-          SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_ID()), attribute(ANGLE_FULL_ID()),
-                                                   aNbCopies, true);
-        else {
-          SketchPlugin_Tools::updateMultiAttribute(attribute(ANGLE_FULL_ID()), attribute(ANGLE_ID()),
-                                                   aNbCopies, false);
-        }
-        myBlockAngle = false;
-        Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-      }
-    }
-  }
 }
index 416f477b14ef26bfe20fb94fbb89ad319e53dbd5..97528ebc0aaa6c5d42582d0e0cb7656956442bc7 100644 (file)
@@ -65,12 +65,6 @@ class SketchPlugin_MultiRotation : public SketchPlugin_ConstraintBase
     static const std::string MY_ANGLE_ID("MultiRotationAngle");
     return MY_ANGLE_ID;
   }
-  /// End point of translation
-  inline static const std::string& ANGLE_FULL_ID()
-  {
-    static const std::string MY_ANGLE_FULL_ID("MultiRotationFullAngle");
-    return MY_ANGLE_FULL_ID;
-  }
 
   /// Total number of objects, initial and translated objects
   inline static const std::string& NUMBER_OF_OBJECTS_ID()
@@ -97,13 +91,10 @@ class SketchPlugin_MultiRotation : public SketchPlugin_ConstraintBase
 
 private:
   ObjectPtr copyFeature(ObjectPtr theObject);
-  void rotateFeature(ObjectPtr theInitial, ObjectPtr theTarget,
-                     double theCenterX, double theCenterY, double theAngle);
+  //void rotateFeature(ObjectPtr theInitial, ObjectPtr theTarget,
+  //                   double theCenterX, double theCenterY, double theAngle);
 
   bool updateFullAngleValue();
-
-private:
-  bool myBlockAngle; /// a boolean state to avoid recusive angle change in attributeChanged
 };
 
 #endif
index bc4a1675580c4d4019d10e6a62ec74b9d4b11781..df1643454b5ebf784154cdcf37d0778a82b17be5 100755 (executable)
@@ -62,10 +62,8 @@ void SketchPlugin_MultiTranslation::execute()
     return;
 
   DataPtr aData = data();
-  std::shared_ptr<GeomDataAPI_Point2D> aStart = GeomDataAPI_Point2D::getPoint2D(aData,
-                                                                                START_POINT_ID());
-  std::shared_ptr<GeomDataAPI_Point2D> aEnd = GeomDataAPI_Point2D::getPoint2D(aData,
-                                                                              END_POINT_ID());
+  AttributePoint2DPtr aStart = GeomDataAPI_Point2D::getPoint2D(aData, START_POINT_ID());
+  AttributePoint2DPtr aEnd = GeomDataAPI_Point2D::getPoint2D(aData, END_POINT_ID());
   if (!aStart || !aEnd)
     return;
 
index a9aa9d90c9227f17193f72ea945b42141ec2fd42..82c5a3f93986c9c07d3857e797771ec59f7cdc52 100644 (file)
@@ -101,57 +101,4 @@ void findCoincidences(const FeaturePtr theStartCoin,
   }
 }
 
-void updateMultiAttribute(const AttributePtr& theFirstAngleAttribute,
-                          const AttributePtr& theSecondAngleAttribute,
-                          const int& theValue,
-                          const bool toMultiply)
-{
-  if (theValue == 0 || !theFirstAngleAttribute->isInitialized())
-    return;
-
-  AttributeDoublePtr aDoubleFirstAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-                                                                theFirstAngleAttribute);
-  double aValue = aDoubleFirstAttr->value();
-
-  AttributeDoublePtr aDoubleSecondAttr = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-                                                                theSecondAngleAttribute);
-  if (toMultiply)
-    aDoubleSecondAttr->setValue(aValue*theValue);
-  else
-    aDoubleSecondAttr->setValue(aValue/theValue);
-}
-
-void updateMultiAttribute(const AttributePtr& theFirstAttribute,
-                          const AttributePtr& theSecondAttribute,
-                          const AttributePtr& theModifiedAttribute,
-                          const int& theValue,
-                          const bool toMultiply)
-{
-  if (theValue == 0 || !theFirstAttribute->isInitialized()
-                    || !theSecondAttribute->isInitialized())
-    return;
-
-  std::shared_ptr<GeomDataAPI_Point2D> aFirstPoint = 
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFirstAttribute);
-  std::shared_ptr<GeomDataAPI_Point2D> aSecondPoint = 
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theSecondAttribute);
-  std::shared_ptr<GeomDataAPI_Point2D> aModifiedPoint = 
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theModifiedAttribute);
-
-  if (!aFirstPoint.get() || !aSecondPoint.get() || !aModifiedPoint.get())
-    return;
-
-  if (aFirstPoint->pnt()->isEqual(aSecondPoint->pnt()))
-    aModifiedPoint->setValue(aFirstPoint->pnt());
-  else {
-    double aDx = aSecondPoint->x() - aFirstPoint->x();
-    double aDy = aSecondPoint->y() - aFirstPoint->y();
-
-    double aX  = toMultiply ? aDx * theValue : aDx / theValue;
-    double anY = toMultiply ? aDy * theValue : aDy / theValue;
-
-    aModifiedPoint->setValue(aFirstPoint->x() + aX, aFirstPoint->y() + anY);
-  }
-}
-
 } // namespace SketchPlugin_Tools
index 6b242532bb74ce7fdd5e443d9a42336c074f0ccc..32dfbb129670f402fe0cccaa981a84c8fc3d9527 100644 (file)
@@ -28,28 +28,6 @@ std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin
 void findCoincidences(const FeaturePtr theStartCoin,
                       const std::string& theAttr,
                       std::set<FeaturePtr>& theList);
-
-/// Changes the second attribute value to be multiplied or divided by the given value.
-/// \param theFirstAngleAttribute the source attribute
-/// \param theSecondAngleAttribute the changed attribute
-/// \param theValue a value for modification
-/// \param toMultiply a type of modification
-void updateMultiAttribute(const AttributePtr& theFirstAngleAttribute,
-                          const AttributePtr& theSecondAngleAttribute,
-                          const int& theValue,
-                          const bool toMultiply);
-
-/// Changes the second attribute value to be multiplied or divided by the given value.
-/// \param theFirstAngleAttribute the source attribute
-/// \param theSecondAngleAttribute the changed attribute
-/// \param theValue a value for modification
-/// \param toMultiply a type of modification
-void updateMultiAttribute(const AttributePtr& theFirstAttribute,
-                          const AttributePtr& theSecondAttribute,
-                          const AttributePtr& theModifiedAttribute,
-                          const int& theValue,
-                          const bool toMultiply);
-
 }; // namespace SketchPlugin_Tools
 
 #endif // SKETCHPLUGIN_TOOLS_H_
\ No newline at end of file
index 68a3b6a392cea8b78803a0c35b1a5d512d327809..34cb0387f29851d687656c5aceca99e33de33062 100644 (file)
@@ -112,6 +112,14 @@ CENTER_X = 0.
 CENTER_Y = 0.
 ANGLE = 30.
 #=========================================================================
+# Create rotation point
+#=========================================================================
+aSession.startOperation()
+aRotationPoint = aSketchFeature.addFeature("SketchPoint")
+aRotationPointPoint = geomDataAPI_Point2D(aRotationPoint.attribute("PointCoordindates"))
+aRotationPointPoint.setValue(CENTER_X, CENTER_Y)
+aSession.finishOperation()
+#=========================================================================
 # Create the Rotation constraint
 #=========================================================================
 aSession.startOperation()
@@ -125,12 +133,17 @@ for aFeature in aFeaturesList:
 aValueType = aMultiRotation.string("AngleType")
 aValueType.setValue("SingleValue")
 
-aCenter = geomDataAPI_Point2D(aMultiRotation.attribute("MultiRotationCenter"))
+aCenter = aMultiRotation.refattr("MultiRotationCenter")
+aCenter.setAttr(aRotationPointPoint)
+
 anAngle = aMultiRotation.real("MultiRotationAngle")
-aCenter.setValue(CENTER_X, CENTER_Y)
 anAngle.setValue(ANGLE)
+
+anAngle = aMultiRotation.string("AngleType")
+anAngle.setValue("SingleAngle")
+
 aNbCopies = aMultiRotation.integer("MultiRotationObjects")
-aNbCopies.setValue(1)
+aNbCopies.setValue(2)
 aMultiRotation.execute()
 aSession.finishOperation()
 #=========================================================================
index 6333048465c6babc065303e804d84f6115cc3fe3..4dca56c495ccc26fd4b5712f59209024197192a5 100644 (file)
@@ -60,12 +60,12 @@ def checkTranslation(theObjects, theNbObjects, theDeltaX, theDeltaY):
             anAttributes.append('ArcStartPoint')
             anAttributes.append('ArcEndPoint')
             
-        #for attr in anAttributes:
-            #aPoint1 = geomDataAPI_Point2D(feat.attribute(attr))
-            #aPoint2 = geomDataAPI_Point2D(next.attribute(attr))
-            #aDiffX = aPoint2.x() - aPoint1.x() - theDeltaX
-            #aDiffY = aPoint2.y() - aPoint1.y() - theDeltaY
-            #assert(aDiffX**2 + aDiffY**2 < 1.e-15)
+        for attr in anAttributes:
+             aPoint1 = geomDataAPI_Point2D(feat.attribute(attr))
+             aPoint2 = geomDataAPI_Point2D(next.attribute(attr))
+             aDiffX = aPoint2.x() - aPoint1.x() - theDeltaX
+             aDiffY = aPoint2.y() - aPoint1.y() - theDeltaY
+             assert(aDiffX**2 + aDiffY**2 < 1.e-15)
     # Check the number of copies is as planed
     assert(anInd == theNbObjects-1)
 
index eaf7601d398e6225c40797422391989a8b99f129..3ea9cd2caebbb4fca27cc6eb456be1298660fb6c 100644 (file)
                     label="Start point"
                     tooltip="Start point of translation"
                     shape_types="vertex">
-                <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
                 <validator id="PartSet_DifferentObjects"/>
                 <validator id="GeomValidators_ShapeType" parameters="vertex"/>
               </sketch_shape_selector>
                     label="End point"
                     tooltip="Final point of translation"
                     shape_types="vertex">
-                <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
                 <validator id="PartSet_DifferentObjects"/>
                 <validator id="GeomValidators_ShapeType" parameters="vertex"/>
               </sketch_shape_selector>
                     label="Start point"
                     tooltip="Start point of translation"
                     shape_types="vertex">
-                <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
                 <validator id="PartSet_DifferentObjects"/>
                 <validator id="GeomValidators_ShapeType" parameters="vertex"/>
               </sketch_shape_selector>
                     label="End point"
                     tooltip="Final point of translation"
                     shape_types="vertex">
-                <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
                 <validator id="PartSet_DifferentObjects"/>
                 <validator id="GeomValidators_ShapeType" parameters="vertex"/>
               </sketch_shape_selector>
             use_external="true">
           <validator id="SketchPlugin_CopyValidator" />
         </sketch_multi_selector>
-        <sketch-2dpoint_selector
-            id="MultiRotationCenter"
-            title="Center of rotation"
-            tooltip="Center of rotation"
-            default="0"/>
+        <sketch_shape_selector
+              id="MultiRotationCenter"
+              label="Center of rotation"
+              tooltip="Center of rotation"
+              shape_types="vertex">
+          <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+        </sketch_shape_selector>
         <toolbox id="AngleType">
           <box id="SingleAngle" title="Single angle" icon=":icons/angle_up_32x32.png">
-            <point2dangle id="MultiRotationAngle"
-                         first_point="MultiRotationCenter"
+            <doublevalue id="MultiRotationAngle"
                          label="Angle"
                          icon=":icons/angle.png"
                          tooltip="Rotation angle"
-                         default="90"/>
+                         default="90" use_reset="false"/>
           </box>
           <box id="FullAngle" title="Full angle" icon=":icons/angle_up_full_32x32.png">
-            <point2dangle id="MultiRotationFullAngle"
-                         first_point="MultiRotationCenter"
-                         label="Full angle"
+            <doublevalue id="MultiRotationAngle"
+                         label="Angle"
                          icon=":icons/angle.png"
-                         tooltip="Rotation angle"/>
+                         tooltip="Rotation angle"
+                         default="90" use_reset="false"/>
           </box>
         </toolbox>
         <integervalue id="MultiRotationObjects"
index 3da7e2fd7e958fe7b64c3c4cd91151d02ad0814b..1595950154d4ecac69ce967984b3508696822463 100644 (file)
@@ -74,6 +74,7 @@ public:
                      const EntityID& theSketchID,
                      const SketchSolver_ConstraintType& theType,
                      const double& theValue,
+                     const bool& theFullValue,
                      const EntityWrapperPtr& thePoint1,
                      const EntityWrapperPtr& thePoint2,
                      const std::list<EntityWrapperPtr>& theTrsfEnt) const = 0;
index 597d313ebf79306e38ac20356238b60596544528..5fc487e120e199815f7fae6f6b9486fbbaa03603 100644 (file)
@@ -4,10 +4,13 @@
 
 #include <SketchPlugin_MultiRotation.h>
 
+#include <ModelAPI_AttributeString.h>
+
 #include <math.h>
 
 void SketchSolver_ConstraintMultiRotation::getAttributes(
     EntityWrapperPtr& theCenter, double& theAngle,
+    bool& theFullValue,
     std::list< std::list<EntityWrapperPtr> >& theEntities)
 {
   DataPtr aData = myBaseConstraint->data();
@@ -25,6 +28,9 @@ void SketchSolver_ConstraintMultiRotation::getAttributes(
   myStorage->update(aCenterAttr, GID_OUTOFGROUP);
   theCenter = myStorage->entity(aCenterAttr);
 
+  AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiRotation::ANGLE_TYPE());
+  theFullValue = aMethodTypeAttr->value() != "SingleAngle";
+
   getEntitiesAndCopies(theEntities);
 }
 
@@ -37,8 +43,9 @@ void SketchSolver_ConstraintMultiRotation::process()
   }
 
   EntityWrapperPtr aRotationCenter;
+  bool isFullValue;
   std::list<std::list<EntityWrapperPtr> > anEntitiesAndCopies;
-  getAttributes(aRotationCenter, myAngle, anEntitiesAndCopies);
+  getAttributes(aRotationCenter, myAngle, isFullValue, anEntitiesAndCopies);
   if (!myErrorMsg.empty())
     return;
 
@@ -49,7 +56,7 @@ void SketchSolver_ConstraintMultiRotation::process()
   for (; anEntIt != anEntitiesAndCopies.end(); ++anEntIt) {
     std::list<ConstraintWrapperPtr> aNewConstraints =
         aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType,
-        myAngle, aRotationCenter, EntityWrapperPtr(), *anEntIt);
+        myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), *anEntIt);
     aRotConstraints.insert(aRotConstraints.end(), aNewConstraints.begin(), aNewConstraints.end());
   }
   myStorage->addConstraint(myBaseConstraint, aRotConstraints);
@@ -68,9 +75,49 @@ void SketchSolver_ConstraintMultiRotation::updateLocal()
   myAngle = aValue;
 
   // update center
-  AttributePtr aCenterAttr = myBaseConstraint->attribute(SketchPlugin_MultiRotation::CENTER_ID());
-  if (myStorage->update(aCenterAttr, myGroupID)) {
-    myStorage->update(aCenterAttr, GID_UNKNOWN);
+  DataPtr aData = myBaseConstraint->data();
+  AttributePoint2DPtr aCenterPointAttribute = GeomDataAPI_Point2D::getPoint2D(aData,
+                                           SketchPlugin_MultiRotation::CENTER_ID());
+  bool aCenterPointChanged = aCenterPointAttribute != myCenterPointAttribute;
+  if (aCenterPointChanged)
+    myCenterPointAttribute = aCenterPointAttribute;
+
+  AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiRotation::ANGLE_TYPE());
+  bool aFullValue = aMethodTypeAttr->value() != "SingleAngle";
+  bool isMethodChanged = aFullValue != myIsFullValue;
+  if (isMethodChanged)
+    myIsFullValue = aFullValue;
+
+  if (aCenterPointChanged || isMethodChanged) {
+    DataPtr aData = myBaseConstraint->data();
+    std::list<ConstraintWrapperPtr> aConstraints = myStorage->constraint(myBaseConstraint);
+    std::list<ConstraintWrapperPtr>::const_iterator anIt = aConstraints.begin(),
+      aLast = aConstraints.end();
+    std::list<EntityWrapperPtr> anEntities;
+    for (; anIt != aLast; anIt++) {
+      ConstraintWrapperPtr aConstraint = *anIt;
+      aConstraint->setIsFullValue(myIsFullValue);
+      if (aCenterPointChanged) {
+        anEntities.clear();
+        const std::list<EntityWrapperPtr>& aConstraintEntities = aConstraint->entities();
+        std::list<EntityWrapperPtr>::const_iterator aSIt = aConstraintEntities.begin(),
+          aSLast = aConstraintEntities.end();
+        EntityWrapperPtr aCenterPointEntity = *aSIt++;
+        if (aCenterPointChanged) {
+          AttributePtr aCenterPointAttr = aData->attribute(SketchPlugin_MultiRotation::CENTER_ID());
+          myStorage->update(aCenterPointAttr);
+          aCenterPointEntity = myStorage->entity(aCenterPointAttr);
+        }
+        anEntities.push_back(aCenterPointEntity);
+
+        for (; aSIt != aSLast; ++aSIt)
+          anEntities.push_back(*aSIt);
+
+        aConstraint->setEntities(anEntities);
+      }
+    }
+    myStorage->addConstraint(myBaseConstraint, aConstraints);
+
     myAdjusted = false;
   }
 }
index 6aad12d63d0ec244f42b662c571b54466fe74ae6..6d241f92df261b2b2929157e667242f429b65ca6 100644 (file)
@@ -10,6 +10,8 @@
 #include "SketchSolver.h"
 #include <SketchSolver_ConstraintMulti.h>
 
+#include "GeomDataAPI_Point2D.h"
+
 /** \class   SketchSolver_ConstraintMultiRotation
  *  \ingroup Plugins
  *  \brief   Convert rotated features to the list of SolveSpace constraints
@@ -29,8 +31,9 @@ protected:
   /// \brief Generate list of rotated entities
   /// \param[out] theCenter   central point of rotation
   /// \param[out] theAngle    rotation angle
+  /// \param[out] theFullValue  applying translation using the disstance as a full or single value
   /// \param[out] theEntities list of entities and their rotated copies
-  void getAttributes(EntityWrapperPtr& theCenter, double& theAngle,
+  void getAttributes(EntityWrapperPtr& theCenter, double& theAngle, bool& theFullValue,
                      std::list< std::list<EntityWrapperPtr> >& theEntities);
 
   /// \brief This method is used in derived objects to check consistence of constraint.
@@ -42,7 +45,10 @@ protected:
 private:
   /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
   virtual const std::string& nameNbObjects();
-  double       myAngle;           ///< angle of rotation
+
+  AttributePoint2DPtr myCenterPointAttribute; ///< a center of rotation
+  double              myAngle;           ///< angle of rotation
+  bool                myIsFullValue;     ///< value whether the angle is a full or single for objects
 };
 
 #endif
index dd4bbb0d8a9c4d71249081b28f8d2af3465c1c33..d5a08f06950028694e487d9efff6cff8e268574a 100644 (file)
@@ -10,7 +10,7 @@
 
 void SketchSolver_ConstraintMultiTranslation::getAttributes(
     EntityWrapperPtr& theStartPoint, EntityWrapperPtr& theEndPoint,
-    std::list< std::list<EntityWrapperPtr> >& theEntities)
+    bool& theFullValue, std::list< std::list<EntityWrapperPtr> >& theEntities)
 {
   DataPtr aData = myBaseConstraint->data();
   AttributePtr aStartPointAttr = aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID());
@@ -28,8 +28,10 @@ void SketchSolver_ConstraintMultiTranslation::getAttributes(
   myStorage->update(aEndPointAttr);
   theEndPoint = myStorage->entity(aEndPointAttr);
 
-  getEntitiesAndCopies(theEntities);
+  AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiTranslation::VALUE_TYPE());
+  theFullValue = aMethodTypeAttr->value() != "SingleValue";
 
+  getEntitiesAndCopies(theEntities);
 }
 
 void SketchSolver_ConstraintMultiTranslation::process()
@@ -41,8 +43,9 @@ void SketchSolver_ConstraintMultiTranslation::process()
   }
 
   EntityWrapperPtr aStartPoint, aEndPoint;
+  bool aFullValue;
   std::list<std::list<EntityWrapperPtr> > anEntitiesAndCopies;
-  getAttributes(aStartPoint, aEndPoint, anEntitiesAndCopies);
+  getAttributes(aStartPoint, aEndPoint, aFullValue, anEntitiesAndCopies);
   if (!myErrorMsg.empty())
     return;
 
@@ -58,7 +61,7 @@ void SketchSolver_ConstraintMultiTranslation::process()
   for (; anEntIt != anEntitiesAndCopies.end(); ++anEntIt) {
     std::list<ConstraintWrapperPtr> aNewConstraints =
         aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType,
-        0.0, aStartPoint, aEndPoint, *anEntIt);
+        0.0, aFullValue, aStartPoint, aEndPoint, *anEntIt);
     aTransConstraints.insert(aTransConstraints.end(), aNewConstraints.begin(), aNewConstraints.end());
   }
   std::list<ConstraintWrapperPtr>::iterator aTCIt = aTransConstraints.begin();
index a0f6ca525e8b89d153c3ea1c9caafe7230c85b22..ef9938a9c12785337cd7062f05e36819e68d4647 100644 (file)
@@ -31,9 +31,10 @@ protected:
   /// \brief Generate list of translated entities
   /// \param[out] theStartPoint start point of translation
   /// \param[out] theEndPoint   final point of translation
+  /// \param[out] theFullValue  applying translation using the disstance as a full or single value
   /// \param[out] theEntities   list of entities and their translated copies
   void getAttributes(EntityWrapperPtr& theStartPoint, EntityWrapperPtr& theEndPoint,
-                     std::list< std::list<EntityWrapperPtr> >& theEntities);
+                     bool& theFullValue, std::list< std::list<EntityWrapperPtr> >& theEntities);
 
   /// \brief Update parameters (called from base class)
   virtual void updateLocal();
index 5e1b85015d27534de5c319239072282ecb0fbfba..9b1105e248e0872fd79ae040498ef29ad6531765 100644 (file)
@@ -134,6 +134,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createConstraint(
     const EntityID& theSketchID,
     const SketchSolver_ConstraintType& theType,
     const double& theValue,
+    const bool& theFullValue,
     const EntityWrapperPtr& thePoint1,
     const EntityWrapperPtr& thePoint2,
     const std::list<EntityWrapperPtr>& theTrsfEnt) const
@@ -156,6 +157,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createConstraint(
 
   ConstraintWrapperPtr aResult(new SolveSpaceSolver_ConstraintWrapper(theConstraint, aConstraint));
   aResult->setValue(theValue);
+  aResult->setIsFullValue(theFullValue);
   aResult->setEntities(aConstrAttrList);
   return std::list<ConstraintWrapperPtr>(1, aResult);
 }
@@ -812,11 +814,19 @@ void adjustMultiRotation(ConstraintWrapperPtr theConstraint)
 {
   BuilderPtr aBuilder = SolveSpaceSolver_Builder::getInstance();
 
-  double anAngleRad = theConstraint->value() * PI / 180.0;
+  double anAngleValue = theConstraint->value();
+  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
+
+  bool isFullValue = theConstraint->isFullValue();
+  int aNbObjects = aSubs.size()-2;
+  if (isFullValue && aNbObjects > 0) {
+    anAngleValue /= aNbObjects;
+  }
+
+  double anAngleRad = anAngleValue * PI / 180.0;
   double aSin = sin(anAngleRad);
   double aCos = cos(anAngleRad);
 
-  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
   std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
 
   std::shared_ptr<GeomAPI_Pnt2d> aCenter = aBuilder->point(*aSIt++);
index f55330ad21e72100bd2c919083a7d10b684ca0c5..2f8e61be9931e9fee665be38601d36c237d6bb6e 100644 (file)
@@ -72,6 +72,7 @@ public:
                      const EntityID& theSketchID,
                      const SketchSolver_ConstraintType& theType,
                      const double& theValue,
+                     const bool& theFullValue,
                      const EntityWrapperPtr& thePoint1,
                      const EntityWrapperPtr& thePoint2,
                      const std::list<EntityWrapperPtr>& theTrsfEnt) const;
index 3c2b87cf5c440733e275bafd41cd9fd77546cd85..148f332ad5a0c8f6831a1110ff1bc487dbb7934f 100644 (file)
@@ -50,6 +50,7 @@ SET(PROJECT_LIBRARIES
     Config
     ModelAPI
     GeomAPI
+    GeomDataAPI
     Events
     ${CAS_KERNEL}
     ${CAS_MODELER}
index 929148d60ba25a5408a1bbd9b2fc985d4d843101..8639c3bb0351258ba7f42c3dc5c2f0ee858ed567 100644 (file)
@@ -88,11 +88,11 @@ void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& the
   drawListOfShapes(anAttrB, thePrs);
   if (myConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
     // If it is translation
-    std::shared_ptr<GeomDataAPI_Point2D> aStart = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID()));
-    std::shared_ptr<GeomDataAPI_Point2D> aEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aData->attribute(SketchPlugin_MultiTranslation::END_POINT_ID()));
-  
+    AttributePoint2DPtr aStart = GeomDataAPI_Point2D::getPoint2D(aData,
+                                            SketchPlugin_MultiTranslation::START_POINT_ID());
+    AttributePoint2DPtr aEnd = GeomDataAPI_Point2D::getPoint2D(aData,
+                                            SketchPlugin_MultiTranslation::END_POINT_ID());
+
     if (aStart.get() && aEnd.get() && aStart->isInitialized() && aEnd->isInitialized()) {
       // Add start point
       std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aStart->x(), aStart->y());
@@ -106,8 +106,7 @@ void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& the
     }
   } else if (myConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
     // if it is rotation
-    std::shared_ptr<GeomDataAPI_Point2D> aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aData->attribute(SketchPlugin_MultiRotation::CENTER_ID()));
+    AttributePoint2DPtr aCenter = GeomDataAPI_Point2D::getPoint2D(aData, SketchPlugin_MultiRotation::CENTER_ID());
     if (aCenter.get() && aCenter->isInitialized()) {
       // Show center of rotation
       std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aCenter->x(), aCenter->y());