//Specific widget containers
const static char* WDG_POINT_SELECTOR = "point_selector";
+const static char* WDG_POINT2D_DISTANCE = "point2ddistance";
const static char* _ID = "id";
//const static char* WORKBENCH_ID = "id";
ModuleBase_WidgetSwitch.h
ModuleBase_WidgetSelector.h
ModuleBase_IWorkshop.h
+ ModuleBase_WidgetPoint2dDistance.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetPoint2D.cpp
ModuleBase_WidgetSwitch.cpp
ModuleBase_WidgetSelector.cpp
+ ModuleBase_WidgetPoint2dDistance.cpp
)
SET(PROJECT_LIBRARIES
Config
ModelAPI
+ GeomAPI
${QT_LIBRARIES}
${CAS_VIEWER}
${CAS_KERNEL}
/// \param theEvent the processed event
virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
-private:
+protected:
QWidget* myContainer;
QLabel* myLabel;
QDoubleSpinBox* mySpinBox;
#include <ModuleBase_WidgetSelector.h>
#include <ModuleBase_WidgetDoubleValue.h>
#include <ModuleBase_WidgetBoolValue.h>
+#include <ModuleBase_WidgetPoint2dDistance.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
} else if (theType == WDG_POINT_SELECTOR) {
result = pointSelectorControl(theParent);
+ } else if (theType == WDG_POINT2D_DISTANCE) {
+ result = point2dDistanceControl(theParent);
+
} else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
result = createContainer(theType, theParent);
}
myModelWidgets.append(aBoolWgt);
return aBoolWgt->getControl();
+}
+
+
+QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent)
+{
+ ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi);
+ myModelWidgets.append(aDistWgt);
+
+ return aDistWgt->getControl();
}
\ No newline at end of file
QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
QWidget* selectorControl(QWidget* theParent);
QWidget* booleanControl(QWidget* theParent);
+ QWidget* point2dDistanceControl(QWidget* theParent);
QString qs(const std::string& theStdString) const;
--- /dev/null
+// File: ModuleBase_WidgetPoint2dDistance.h
+// Created: 23 June 2014
+// Author: Vitaly Smetannikov
+
+#include "ModuleBase_WidgetPoint2dDistance.h"
+
+#include <GeomAPI_Pnt2d.h>
+#include <Config_WidgetAPI.h>
+#include <GeomDataAPI_Point2D.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <QDoubleSpinBox>
+
+ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData)
+ : ModuleBase_WidgetDoubleValue(theParent, theData)
+{
+ myFirstPntName = theData->getProperty("first_point");
+}
+
+ModuleBase_WidgetPoint2dDistance::~ModuleBase_WidgetPoint2dDistance()
+{
+}
+
+void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boost::shared_ptr<GeomAPI_Pnt2d>& thePnt)
+{
+ boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+ (aData->attribute(myFirstPntName));
+ double aRadius = thePnt->distance(aPoint->pnt());
+ AttributeDoublePtr aReal = aData->real(attributeID());
+ if (aReal && aReal->value() != mySpinBox->value()) {
+ aReal->setValue(aRadius);
+ mySpinBox->setValue(aRadius);
+ }
+}
\ No newline at end of file
--- /dev/null
+// File: ModuleBase_WidgetPoint2dDistance.h
+// Created: 23 June 2014
+// Author: Vitaly Smetannikov
+
+
+#ifndef ModuleBase_WidgetPoint2dDistance_H
+#define ModuleBase_WidgetPoint2dDistance_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_WidgetDoubleValue.h"
+
+class GeomAPI_Pnt2d;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetPoint2dDistance: public ModuleBase_WidgetDoubleValue
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \theParent the parent object
+ /// \theData the widget configuation. The attribute of the model widget is obtained from
+ ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData);
+
+ virtual ~ModuleBase_WidgetPoint2dDistance();
+
+ /// 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 boost::shared_ptr<GeomAPI_Pnt2d>& thePnt);
+
+private:
+ std::string myFirstPntName;
+};
+
+
+#endif
\ No newline at end of file
</feature>
<feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon="">
<point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
- <doublevalue id="CircleRadius" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius"/>
+ <point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius"/>
</feature>
<feature id="SketchArc" title="Arc" tooltip="Create a new arc of a circle" icon="">
<point_selector id="ArcCenter" title="Center" tooltip="Center of the arc"/>