const static char* FEATURE_INTERNAL = "internal";
const static char* SOURCE_FILE = "path";
+const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param";
// doublevalue properties:
const static char* INFO_WDG_TEXT = FEATURE_TEXT;
const Config_WidgetAPI* theData)
: ModuleBase_ModelWidget(theParent, theData)
{
+ myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)),
theParent);
QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
+
bool isBlocked = this->blockSignals(true);
myXSpin->setValue(thePoint->x());
myYSpin->setValue(thePoint->y());
}
return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
}
+
+void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+{
+ if (myOptionParam.length() == 0)
+ return;
+ boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
+ if (aPoint) {
+ bool isBlocked = this->blockSignals(true);
+ myXSpin->setValue(aPoint->x());
+ this->blockSignals(isBlocked);
+ myYSpin->setValue(aPoint->y());
+ }
+}
/// \param theEvent the processed event
virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
+ void initFromPrevious(FeaturePtr theFeature);
+
private:
QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
+
+ std::string myOptionParam; /// Parameter name which has to be taken from previous feature
};
#endif
myActiveWidget = theWidget;
if (myInitFeature && myActiveWidget) {
- // TODO: to be realized in the custom point selector. The last point values of the init feature
- // should be to to the start point of a new feature
- //myActiveWidget->init(myInitFeature);
- //PartSet_FeatureLinePrs::setFeature(myInitFeature, SM_FirstPoint);
+ ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+ if (aWgt)
+ aWgt->initFromPrevious(myInitFeature);
myInitFeature = FeaturePtr();
emit activateNextWidget(myActiveWidget);
}
<point_selector id="PointCoordindates" title="Point" tooltip="Point"/>
</feature>
<feature id="SketchLine" title="Line" tooltip="Create a new line" icon=":icons/line.png">
- <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
+ <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line" previous_feature_param="EndPoint"/>
<point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
</feature>
<feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon="">