{
if (theActionName == "COLOR_CMD" ||
theActionName == "DEFLECTION_CMD" ||
- theActionName == "TRANSPARENCY_CMD" ||
+ theActionName == "TRANSPARENCY_CMD" ||
theActionName == "EDGE_THICKNESS_CMD") {
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
//**************************************************************
void setEdgeThickness(int theThickness, const QObjectPtrList& theObjects)
{
- foreach(ObjectPtr anObj, theObjects) {
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
- if (aResult.get() != NULL) {
- ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
- if (aBodyResult.get() != NULL) { // change property for all sub-solids
- std::list<ResultPtr> allRes;
- ModelAPI_Tools::allSubs(aBodyResult, allRes);
- std::list<ResultPtr>::iterator aRes;
- for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- ModelAPI_Tools::setEdgeThickness(*aRes, theThickness);
+ foreach(ObjectPtr obj, theObjects) {
+ ResultPtr result = std::dynamic_pointer_cast<ModelAPI_Result>(obj);
+ if (result) {
+ ResultBodyPtr resultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(result);
+ if (resultBody) {
+ std::list<ResultPtr> subResults;
+ ModelAPI_Tools::allSubs(resultBody, subResults);
+ for(auto itSubResult = subResults.begin(); itSubResult != subResults.end(); itSubResult++) {
+ ModelAPI_Tools::setEdgeThickness(*itSubResult, theThickness);
}
}
- ModelAPI_Tools::setEdgeThickness(aResult, theThickness);
+ ModelAPI_Tools::setEdgeThickness(result, theThickness);
}
}
}
//**************************************************************
void XGUI_Workshop::changeEdgeThickness(const QObjectPtrList& theObjects)
{
- AttributeIntegerPtr aDoubleAttr;
// 1. Get current value.
- int aCurrentValue = -1;
- foreach(ObjectPtr anObject, theObjects) {
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
- if (aResult.get()) {
- aCurrentValue = ModelAPI_Tools::getEdgeThickness(aResult);
- if (aCurrentValue < 0)
- aCurrentValue = getDefaultEdgeThickness();
- }
- if (aCurrentValue > 0)
+ int currentValue = -1;
+ foreach(ObjectPtr object, theObjects) {
+ ResultPtr result = std::dynamic_pointer_cast<ModelAPI_Result>(object);
+ if (!result)
+ continue;
+
+ currentValue = ModelAPI_Tools::getEdgeThickness(result);
+ if (currentValue < 0)
+ currentValue = getDefaultEdgeThickness();
+
+ if (currentValue > 0)
break;
}
- if (aCurrentValue < 0)
+ if (currentValue < 0)
return;
if (!abortAllOperations())
return;
// 2. Show the dialog.
- XGUI_PropertyDialog* aDlg = new XGUI_PropertyDialog(desktop());
- aDlg->setWindowTitle(tr("Edge Thickness"));
- XGUI_EdgeThicknessWidget* aEdgeThicknessWidget = new XGUI_EdgeThicknessWidget(aDlg);
- connect(aEdgeThicknessWidget, SIGNAL(thicknessValueChanged()), this, SLOT(onEdgeThicknessValueChanged()));
- aDlg->setContent(aEdgeThicknessWidget);
- aEdgeThicknessWidget->setValue(aCurrentValue);
+ const auto dialog = new XGUI_PropertyDialog(desktop());
+ dialog->setWindowTitle(tr("Edge Thickness"));
+ XGUI_EdgeThicknessWidget* edgeThicknessWidget = new XGUI_EdgeThicknessWidget(dialog);
+ connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged()), this, SLOT(onEdgeThicknessValueChanged()));
+ dialog->setContent(edgeThicknessWidget);
+ aEdgeThicknessWidget->setValue(currentValue);
// 3. Abort the previous operation and start a new one.
- SessionPtr aMgr = ModelAPI_Session::get();
- QString aDescription = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text();
- aMgr->startOperation(aDescription.toStdString());
+ SessionPtr session = ModelAPI_Session::get();
+ QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text();
+ session->startOperation(description.toStdString());
- if (aDlg->exec() == QDialog::Accepted) {
+ if (dialog->exec() == QDialog::Accepted) {
// 4. Set the value to all results.
- aCurrentValue = aEdgeThicknessWidget->getValue();
- setEdgeThickness(aCurrentValue, theObjects);
- aMgr->finishOperation();
+ currentValue = edgeThicknessWidget->getValue();
+ setEdgeThickness(currentValue, theObjects);
+ session->finishOperation();
} else {
- aMgr->abortOperation();
+ session->abortOperation();
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}