]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
authornds <natalia.donis@opencascade.com>
Thu, 30 Apr 2015 14:23:54 +0000 (17:23 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 30 Apr 2015 14:23:54 +0000 (17:23 +0300)
Conflicts:
src/PartSet/PartSet_Module.cpp

src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2dAngle.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetPoint2dAngle.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_WidgetPoint2dDistance.h
src/SketchPlugin/plugin-Sketch.xml

index 1b8a05bc2d2774aa96c72abc467fd0f872909a0a..048fba1e1e803786339f8a21d89e5fe809a51837 100644 (file)
@@ -13,6 +13,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetSketchLabel.h
        PartSet_Validators.h
        PartSet_WidgetPoint2d.h
+       PartSet_WidgetPoint2dAngle.h
        PartSet_WidgetEditor.h
        PartSet_WidgetMultiSelector.h
        PartSet_WidgetPoint2dDistance.h
@@ -34,6 +35,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetEditor.cpp
        PartSet_WidgetMultiSelector.cpp
        PartSet_WidgetPoint2d.cpp
+       PartSet_WidgetPoint2dAngle.cpp
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetShapeSelector.cpp
        PartSet_Filters.cpp
index e32bba6435959e310ecd82e35c2a9f22ac5acc1c..8fc18d64cc18c85c42eac208c830abe18196f722 100644 (file)
@@ -7,6 +7,7 @@
 #include "PartSet_WidgetPoint2d.h"
 #include "PartSet_WidgetPoint2dDistance.h"
 #include "PartSet_WidgetShapeSelector.h"
+#include "PartSet_WidgetPoint2dAngle.h"
 #include "PartSet_WidgetMultiSelector.h"
 #include "PartSet_WidgetEditor.h"
 #include "PartSet_SketcherMgr.h"
@@ -476,7 +477,13 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
     aDistanceWgt->setWorkshop(aWorkshop);
     aDistanceWgt->setSketch(mySketchMgr->activeSketch());
     aWgt = aDistanceWgt;
-  } if (theType == "sketch_shape_selector") {
+  } if(theType == "point2dangle") {
+    PartSet_WidgetPoint2dAngle* anAngleWgt = new PartSet_WidgetPoint2dAngle(theParent, theWidgetApi, theParentId);
+    anAngleWgt->setWorkshop(aWorkshop);
+    anAngleWgt->setSketch(mySketchMgr->activeSketch());
+    aWgt = anAngleWgt;
+  }
+  if (theType == "sketch_shape_selector") {
     PartSet_WidgetShapeSelector* aShapeSelectorWgt =
       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
     aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
diff --git a/src/PartSet/PartSet_WidgetPoint2dAngle.cpp b/src/PartSet/PartSet_WidgetPoint2dAngle.cpp
new file mode 100644 (file)
index 0000000..b014d34
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetPoint2dAngle.h
+// 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,
+                                                       const Config_WidgetAPI* theData,
+                                                       const std::string& theParentId)
+: PartSet_WidgetPoint2dDistance(theParent, 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
new file mode 100644 (file)
index 0000000..6dac991
--- /dev/null
@@ -0,0 +1,44 @@
+// 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 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 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, 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 e20186a26a43eb68422d222064f729855b826731..07cf1877b7303c76a175fdc316933b3122bc3d61 100644 (file)
@@ -60,16 +60,22 @@ void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
   if (!aPoint)
     return;
 
-  double aRadius = thePnt->distance(aPoint->pnt());
+  double aValue = computeValue(aPoint->pnt(), thePnt);
   AttributeDoublePtr aReal = aData->real(attributeID());
-  if (aReal && (aReal->value() != aRadius)) {
-    aReal->setValue(aRadius);
+  if (aReal && (aReal->value() != aValue)) {
+    aReal->setValue(aValue);
     
-    ModuleBase_Tools::setSpinValue(mySpinBox, aRadius);
+    ModuleBase_Tools::setSpinValue(mySpinBox, aValue);
     storeValue();
   }
 }
 
+double PartSet_WidgetPoint2dDistance::computeValue(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPnt,
+                                                   const std::shared_ptr<GeomAPI_Pnt2d>& theCurrentPnt)
+{
+  return theCurrentPnt->distance(theFirstPnt);
+}
+
 void PartSet_WidgetPoint2dDistance::activateCustom()
 {
   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
index 95fc0ed19c450222bb2239c8c81d63f33cfcc7e4..c3020e3a97c5208ba601087d7dedc893b6928d7d 100644 (file)
@@ -85,11 +85,18 @@ protected:
   /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
   void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
 
+  /// Compute the distance 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);
+
 private slots:
   /// Process values changed event
   void onValuesChanged();
 
- private:
+protected:
   XGUI_Workshop* myWorkshop;
   std::string myFirstPntName;
 
index e42c826c89a811a2c2319cca2a2fc908fb77b1ab..82377a7f6d95c9e13a1c397629693d0867d04932 100644 (file)
             id="MultiRotationCenter"
             title="Center of rotation"
             tooltip="Center of rotation"/>
-        <doublevalue id="MultiRotationAngle"
-            label="Angle"
-            tooltip="Rotation angle"/>
+        <point2dangle id="MultiRotationAngle"
+                         first_point="MultiRotationCenter"
+                         label="Angle"
+                         icon=":icons/angle.png"
+                         tooltip="Rotation angle"/>
         <integervalue id="MultiRotationCopies"
             label="Number of copies"
             tooltip="Number of copies"