PartSet_WidgetSketchLabel.h
PartSet_Validators.h
PartSet_WidgetPoint2d.h
+ PartSet_WidgetPoint2dAngle.h
PartSet_WidgetEditor.h
PartSet_WidgetMultiSelector.h
PartSet_WidgetPoint2dDistance.h
PartSet_WidgetEditor.cpp
PartSet_WidgetMultiSelector.cpp
PartSet_WidgetPoint2d.cpp
+ PartSet_WidgetPoint2dAngle.cpp
PartSet_WidgetPoint2dDistance.cpp
PartSet_WidgetShapeSelector.cpp
PartSet_Filters.cpp
#include <PartSet_Tools.h>
#include <PartSet_WidgetPoint2d.h>
#include <PartSet_WidgetPoint2dDistance.h>
+#include <PartSet_WidgetPoint2dAngle.h>
#include <PartSet_WidgetShapeSelector.h>
#include <PartSet_WidgetMultiSelector.h>
#include <PartSet_WidgetEditor.h>
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());
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
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();
/// 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;
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"