}
return aValues;
}
+
+std::vector<int> XGUI_ColorDialog::randomColor()
+{
+ std::vector<int> aValues;
+ findRandomColor(aValues);
+ return aValues;
+}
/// \return a vector of values
std::vector<int> getRandomColor() const;
+ /// Returns a container with the current color value.
+ /// These are tree int values for RGB definition.
+ /// It returns the next random color.
+ /// \return a vector of values
+ static std::vector<int> randomColor();
+
private:
QButtonGroup* myButtonGroup; /// a group, contained random and certain color radio button choice
QtxColorButton* myColorButton; /// a control to select a color
aAction = ModuleBase_Tools::createAction(QIcon(":pictures/color.png"), tr("Color..."), aDesktop);
addAction("COLOR_CMD", aAction);
+ aAction = ModuleBase_Tools::createAction(QIcon(""), tr("Auto color"), aDesktop);
+ addAction("AUTOCOLOR_CMD", aAction);
+
aAction = ModuleBase_Tools::createAction(QIcon(""), tr("Deflection..."), aDesktop);
addAction("DEFLECTION_CMD", aAction);
action("COLOR_CMD")->setEnabled(myWorkshop->canChangeProperty("COLOR_CMD"));
action("DEFLECTION_CMD")->setEnabled(myWorkshop->canChangeProperty("DEFLECTION_CMD"));
action("TRANSPARENCY_CMD")->setEnabled(myWorkshop->canChangeProperty("TRANSPARENCY_CMD"));
+ action("AUTOCOLOR_CMD")->setEnabled(myWorkshop->canChangeProperty("AUTOCOLOR_CMD"));
+
#ifdef _DEBUG
#ifdef TINSPECTOR
action("TINSPECTOR_VIEW")->setEnabled(true);
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
// Group menu
- myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
myObjBrowserMenus[ModelAPI_ResultField::group()] = aList;
// Result part menu
myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList;
+
+ aList.clear();
+ aList.append(action("WIREFRAME_CMD"));
+ aList.append(action("SHADING_CMD"));
+ aList.append(mySeparator1); // this separator is not shown as this action is added after show only
+ // qt list container contains only one instance of the same action
+ aList.append(action("SHOW_CMD"));
+ aList.append(action("HIDE_CMD"));
+ aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(mySeparator2);
+ aList.append(action("AUTOCOLOR_CMD"));
+ aList.append(action("RENAME_CMD"));
+ aList.append(action("COLOR_CMD"));
+ aList.append(action("DEFLECTION_CMD"));
+ aList.append(action("TRANSPARENCY_CMD"));
+ aList.append(action("SHOW_ISOLINES_CMD"));
+ aList.append(action("ISOLINES_CMD"));
+ aList.append(action("SHOW_FEATURE_CMD"));
+ aList.append(mySeparator3);
+ aList.append(action("DELETE_CMD"));
+ // Group menu
+ myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
//-------------------------------------
// Feature menu
aList.clear();
#include <QSpinBox>
#include <QDialogButtonBox>
+#include <sstream>
#include <iterator>
#ifdef TINSPECTOR
moveObjects(theId == "MOVE_SPLIT_CMD");
else if (theId == "COLOR_CMD")
changeColor(aObjects);
+ else if (theId == "AUTOCOLOR_CMD")
+ changeAutoColor(aObjects);
else if (theId == "ISOLINES_CMD")
changeIsoLines(aObjects);
else if (theId == "SHOW_ISOLINES_CMD") {
return hasResults(aObjects, aTypes);
}
+ if (theActionName == "AUTOCOLOR_CMD") {
+
+ QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+
+ std::set<std::string> aTypes;
+ aTypes.insert(ModelAPI_ResultGroup::group());
+
+ return hasResults(aObjects, aTypes);
+ }
return false;
}
myViewerProxy->update();
}
+//**************************************************************
+void XGUI_Workshop::changeAutoColor(const QObjectPtrList& theObjects)
+{
+ if (!abortAllOperations())
+ return;
+
+ std::vector<int> aColor = XGUI_ColorDialog::randomColor();
+
+ // abort the previous operation and start a new one
+ SessionPtr aMgr = ModelAPI_Session::get();
+ QString aDescription = contextMenuMgr()->action("AUTOCOLOR_CMD")->text();
+ aMgr->startOperation(aDescription.toStdString());
+
+ Config_Prop* aProp = Config_PropManager::findProp("Visualization", "result_group_color");
+
+ if( aDescription == tr("Disable auto color"))
+ {
+ contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Auto color") );
+
+ aProp->setValue(ModelAPI_ResultGroup::DEFAULT_COLOR());
+
+ }else{
+ std::stringstream streamColor;
+ streamColor<< aColor[0] <<","<< aColor[1] <<"," <<aColor[2];
+
+ aProp->setValue(streamColor.str());
+
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aMgr->finishOperation();
+ updateCommandStatus();
+ myViewerProxy->update();
+ contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Disable auto color") );
+ }
+}
+
//**************************************************************
void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
{
/// theObjects a list of selected objects
void changeColor(const QObjectPtrList& theObjects);
+ /// Change Autocolor of the results if it is possible
+ /// The operation is available for group results
+ /// theObjects a list of selected objects
+ void changeAutoColor(const QObjectPtrList& theObjects);
+
/// Change deflection of the results if it is possible
/// The operation is available for construction, body and group results
/// theObjects a list of selected objects