From: vsv Date: Wed, 15 Apr 2015 08:55:16 +0000 (+0300) Subject: Provide editing of parameters X-Git-Tag: V_1.1.0~27^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9cb7834747d789dce81ab8b30208eb162eedbaf8;p=modules%2Fshaper.git Provide editing of parameters --- diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index 413e7dc9b..ece600bcd 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -56,7 +56,7 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string&) std::ostringstream sstream; sstream << aValue; std::string aParamValue = sstream.str(); - data()->setName(aName + " ("+ aParamValue + ")"); + data()->setName(aName); aParam->data()->setName(aName); // Error std::string aStateMsg; diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index e8d24eb51..9da73baae 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -41,14 +41,15 @@ PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance() { } -void PartSet_WidgetPoint2dDistance::reset() -{ - bool isOk; - double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); - - ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0); - storeValueCustom(); -} +// It is not clear a necesity of this method also it contradicts to scenario defined in parent class +//void PartSet_WidgetPoint2dDistance::reset() +//{ +// bool isOk; +// double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk); +// +// ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0); +// storeValueCustom(); +//} void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const std::shared_ptr& thePnt) diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.h b/src/PartSet/PartSet_WidgetPoint2dDistance.h index 7d6a497c6..95fc0ed19 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.h +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.h @@ -48,7 +48,7 @@ Q_OBJECT virtual ~PartSet_WidgetPoint2dDistance(); /// Fills the widget with default values - virtual void reset(); + //virtual void reset(); /// The methiod called when widget is deactivated virtual void deactivate(); diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 1051298f4..868da0552 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -142,15 +143,17 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const XGUI_Displayer* aDisplayer = myWorkshop->displayer(); bool hasResult = false; bool hasFeature = false; + bool hasParameter = false; foreach(ObjectPtr aObj, aObjects) { FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); ResultPtr aResult = std::dynamic_pointer_cast(aObj); - if (aResult) - hasResult = true; - if (aFeature) - hasFeature = true; - if (hasFeature && hasResult) // && hasGroup) + ResultParameterPtr aConstruction = std::dynamic_pointer_cast(aResult); + + hasResult = (aResult.get() != NULL); + hasFeature = (aFeature.get() != NULL); + hasParameter = (aConstruction.get() != NULL); + if (hasFeature && hasResult && hasParameter) break; } //Process Feature @@ -175,17 +178,20 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const } aMenu->addSeparator(); aMenu->addAction(action("HIDE_CMD")); - } else { + } else if (!hasParameter) { aMenu->addAction(action("SHOW_CMD")); } - aMenu->addAction(action("SHOW_ONLY_CMD")); + if (hasParameter) + aMenu->addAction(action("EDIT_CMD")); + else + aMenu->addAction(action("SHOW_ONLY_CMD")); } } else { // If feature is 0 the it means that selected root object (document) if (aMgr->activeDocument() != aMgr->moduleDocument()) aMenu->addAction(action("ACTIVATE_PART_CMD")); } } else { - if (hasResult) { + if (hasResult && (!hasParameter)) { aMenu->addAction(action("SHOW_CMD")); aMenu->addAction(action("HIDE_CMD")); aMenu->addAction(action("SHOW_ONLY_CMD")); @@ -194,7 +200,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const aMenu->addAction(action("WIREFRAME_CMD")); } } - if (hasFeature) + if (hasFeature || hasParameter) aMenu->addAction(action("DELETE_CMD")); } if (myWorkshop->canChangeColor()) diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 2ff582bb7..df5625c89 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -18,6 +18,31 @@ #include #include #include +#include + +class XGUI_TreeViewItemDelegate: public QStyledItemDelegate +{ +public: + XGUI_TreeViewItemDelegate(XGUI_DataTree* theParent):QStyledItemDelegate(theParent), myTreedView(theParent) {} + + virtual void setEditorData ( QWidget* editor, const QModelIndex& index ) const + { + QLineEdit* aEditor = dynamic_cast(editor); + if (aEditor) { + XGUI_DocumentDataModel* aModel = myTreedView->dataModel(); + ObjectPtr aObj = aModel->object(index); + if (aObj.get() != NULL) { + aEditor->setText(aObj->data()->name().c_str()); + return; + } + } + QStyledItemDelegate::setEditorData(editor, index); + } + +private: + XGUI_DataTree* myTreedView; +}; + XGUI_DataTree::XGUI_DataTree(QWidget* theParent) : QTreeView(theParent) @@ -28,6 +53,8 @@ XGUI_DataTree::XGUI_DataTree(QWidget* theParent) setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); + setItemDelegateForColumn(0, new XGUI_TreeViewItemDelegate(this)); + connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); } diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index 3faa7bd6d..5ab579846 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -47,8 +48,13 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ParamObject: { DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameter::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); + if (aObject) { + ResultParameterPtr aParam = std::dynamic_pointer_cast(aObject); + AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); + QString aVal = QString::number(aValueAttribute->value()); + QString aTitle = QString(aObject->data()->name().c_str()); + return aTitle + "=" + aVal; + } } break; case ConstructFolder: @@ -274,8 +280,13 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons case ParamObject: { ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameter::group(), theIndex.row()); - if (aObject) - return std::dynamic_pointer_cast(aObject)->data()->name().c_str(); + if (aObject) { + ResultParameterPtr aParam = std::dynamic_pointer_cast(aObject); + AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); + QString aVal = QString::number(aValueAttribute->value()); + QString aTitle = QString(aObject->data()->name().c_str()); + return aTitle + "=" + aVal; + } } break; case ConstructObject: { diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 985f1f307..54815e0a4 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -40,6 +40,7 @@ #include #include #include +#include //#include @@ -1329,7 +1330,14 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) myDisplayer->eraseAll(); else if (theId == "EDIT_CMD") { FeaturePtr aFeature = std::dynamic_pointer_cast(aObjects.first()); - if (aFeature) + if (aFeature == NULL) { + ResultParameterPtr aParam = + std::dynamic_pointer_cast(aObjects.first()); + if (aParam.get() != NULL) { + aFeature = ModelAPI_Feature::feature(aParam); + } + } + if (aFeature.get() != NULL) myModule->editFeature(aFeature); } }