The problem with the Sketch creation line operation, which need to fill the property start point by the last point of another feature. The functionality the operation done in the startOperation() virtual method. After, the property panel throw down the values set.
The decision is to redesign the operation-widget_factory-property panel functionality in order to set the default values to the feature at the moment of a new feature creation.
void setRunning(bool theState);
// Data model methods.
- /// Stores a real value in model.
- /// \param theValue - to store
- virtual void storeReal(double theValue) = 0;
/// Stores a custom value in model.
virtual void storeCustomValue() = 0;
return true;
}
-void ModuleBase_Operation::storeReal(double theValue)
-{
- if(!myFeature){
- #ifdef _DEBUG
- qDebug() << "ModuleBase_Operation::storeReal: " <<
- "trying to store value without opening a transaction.";
- #endif
- return;
- }
- QString anId = sender()->objectName();
- boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
- aReal->setValue(theValue);
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
-}
-
void ModuleBase_Operation::storeCustomValue()
{
if(!myFeature){
virtual bool isNestedOperationsEnabled() const;
// Data model methods.
- /// Stores a real value in model.
- /// \param theValue - to store
- void storeReal(double theValue);
/// Stores a custom value in model.
void storeCustomValue();
QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
{
ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent, myWidgetApi);
- connectWidget(aWidget, WDG_POINT_SELECTOR);
+ QObject::connect(aWidget, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue()));
+
myModelWidgets.append(aWidget);
return aWidget->getControl();
}
-bool ModuleBase_WidgetFactory::connectWidget(QObject* theWidget, const QString& theType)
-{
- bool result = false;
- if (theType == WDG_DOUBLEVALUE) {
- result = QObject::connect(theWidget, SIGNAL(valueChanged(double)),
- myOperation, SLOT(storeReal(double)));
- }
- if (theType == WDG_POINT_SELECTOR) {
- result = QObject::connect(theWidget, SIGNAL(valuesChanged()),
- myOperation, SLOT(storeCustomValue()));
- }
- return result;
-}
-
QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
{
return QString::fromStdString(theStdString);
QWidget* selectorControl(QWidget* theParent);
QWidget* booleanControl(QWidget* theParent);
- bool connectWidget(QObject*, const QString&);
QString qs(const std::string& theStdString) const;
private: