#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultBody.h>
activatePart(ResultPartPtr());
else if (theId == "DELETE_CMD")
deleteObjects(aObjects);
+ else if (theId == "COLOR_CMD")
+ changeColor(aObjects);
else if (theId == "SHOW_CMD")
showObjects(aObjects, true);
else if (theId == "HIDE_CMD")
updateCommandStatus();
}
+bool hasResults(QObjectPtrList theObjects, const std::set<std::string>& theTypes)
+{
+ bool isFoundResultType = false;
+ foreach(ObjectPtr anObj, theObjects)
+ {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+ if (aResult.get() == NULL)
+ continue;
+
+ isFoundResultType = theTypes.find(aResult->groupName()) != theTypes.end();
+ if (isFoundResultType)
+ break;
+ }
+ return isFoundResultType;
+}
+
+//**************************************************************
+bool XGUI_Workshop::canChangeColor() const
+{
+ QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+
+ std::set<std::string> aTypes;
+ aTypes.insert(ModelAPI_ResultGroup::group());
+ aTypes.insert(ModelAPI_ResultConstruction::group());
+ aTypes.insert(ModelAPI_ResultBody::group());
+ return hasResults(aObjects, aTypes);
+}
+
+//**************************************************************
+#include <QDialog>
+#include <QHBoxLayout>
+#include <QLineEdit>
+void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
+{
+ // 1. find the initial value of the material
+ std::string aFirstValue = "";
+ foreach(ObjectPtr anObj, theObjects)
+ {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+ if (aResult.get() == NULL)
+ continue;
+ }
+
+ // 2. show the dialog to change the value
+ QDialog aDlg;
+ QHBoxLayout* aLay = new QHBoxLayout(&aDlg);
+
+ QLineEdit* anEditor = new QLineEdit("QString::number(theValue)", &aDlg);
+ anEditor->setText(aFirstValue.c_str());
+ anEditor->selectAll();
+ aLay->addWidget(anEditor);
+
+ QPoint aPoint = QCursor::pos();
+ aDlg.move(aPoint);
+
+ bool isDone = aDlg.exec() == QDialog::Accepted;
+ if (!isDone)
+ return;
+
+ std::string aValue = anEditor->text().toStdString();
+
+ // 3. abort the previous operation and start a new one
+
+ // 4. set the value to all results
+}
+
//**************************************************************
void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
{