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;
{
}
-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<GeomAPI_Pnt2d>& thePnt)
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();
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_ResultGroup.h>
+#include <ModelAPI_ResultParameter.h>
#include <ModuleBase_IModule.h>
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
bool hasResult = false;
bool hasFeature = false;
+ bool hasParameter = false;
foreach(ObjectPtr aObj, aObjects)
{
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
- if (aResult)
- hasResult = true;
- if (aFeature)
- hasFeature = true;
- if (hasFeature && hasResult) // && hasGroup)
+ ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
+
+ hasResult = (aResult.get() != NULL);
+ hasFeature = (aFeature.get() != NULL);
+ hasParameter = (aConstruction.get() != NULL);
+ if (hasFeature && hasResult && hasParameter)
break;
}
//Process Feature
}
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"));
aMenu->addAction(action("WIREFRAME_CMD"));
}
}
- if (hasFeature)
+ if (hasFeature || hasParameter)
aMenu->addAction(action("DELETE_CMD"));
}
if (myWorkshop->canChangeColor())
#include <QEvent>
#include <QMouseEvent>
#include <QAction>
+#include <QStyledItemDelegate>
+
+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<QLineEdit*>(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)
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&)));
}
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultGroup.h>
+#include <ModelAPI_AttributeDouble.h>
#include <QIcon>
#include <QBrush>
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<ModelAPI_ResultParameter>(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:
case ParamObject: {
ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameter::group(),
theIndex.row());
- if (aObject)
- return std::dynamic_pointer_cast<ModelAPI_Object>(aObject)->data()->name().c_str();
+ if (aObject) {
+ ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(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: {
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_ResultParameter.h>
//#include <PartSetPlugin_Part.h>
myDisplayer->eraseAll();
else if (theId == "EDIT_CMD") {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObjects.first());
- if (aFeature)
+ if (aFeature == NULL) {
+ ResultParameterPtr aParam =
+ std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObjects.first());
+ if (aParam.get() != NULL) {
+ aFeature = ModelAPI_Feature::feature(aParam);
+ }
+ }
+ if (aFeature.get() != NULL)
myModule->editFeature(aFeature);
}
}