From: vsv Date: Fri, 7 Feb 2020 14:20:41 +0000 (+0300) Subject: Issue #3140: Modify Iso-lines of a shape presentation X-Git-Tag: V9_5_0a1~14^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=845faaf1f35a4054431eb57656ab52b5c1d6655a;p=modules%2Fshaper.git Issue #3140: Modify Iso-lines of a shape presentation --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 2a25c5136..ecafd0c20 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -437,7 +437,8 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) } else { // trim: need to redisplay or set color in the python script if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" || - theAttr->id() == "Transparency" || theAttr->id() == "Deflection")) { + theAttr->id() == "Transparency" || theAttr->id() == "Deflection" || + theAttr->id() == "Iso_lines")) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index f89eff7d7..fd752bc72 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -54,6 +54,7 @@ void Model_ResultPart::initAttributes() data()->addAttribute(BASE_REF_ID(), ModelAPI_AttributeReference::typeId()); data()->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId()); if (aDocRef->isInitialized() && // initialized immediately means already exist and will be loaded !Model_Application::getApplication()->hasDocument(aDocRef->docId())) diff --git a/src/ModelAPI/ModelAPI_Result.cpp b/src/ModelAPI/ModelAPI_Result.cpp index 18c96fbc9..b3d3dc574 100644 --- a/src/ModelAPI/ModelAPI_Result.cpp +++ b/src/ModelAPI/ModelAPI_Result.cpp @@ -37,6 +37,7 @@ void ModelAPI_Result::initAttributes() aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false); aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false); aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false); + aData->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false); } bool ModelAPI_Result::setDisabled(std::shared_ptr theThis, const bool theFlag) diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index 81709e749..a53c1e04f 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -63,6 +63,14 @@ class ModelAPI_Result : public ModelAPI_Object return MY_TRANSPARENCY_ID; } + /// Reference to the transparency of the result. + /// The double value is used. The value is in [0, 1] range + inline static const std::string& ISO_LINES_ID() + { + static const std::string MY_ISO_LINES_ID("Iso_lines"); + return MY_ISO_LINES_ID; + } + /// Returns true if the result is concealed from the data tree (referenced by other objects) MODELAPI_EXPORT virtual bool isConcealed(); diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 413f52c4c..3d293492e 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -785,6 +785,19 @@ void removeResults(const std::list& theResults) } } + +//************************************************************** +void setDeflection(ResultPtr theResult, const double theDeflection) +{ + if (!theResult.get()) + return; + + AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID()); + if (aDeflectionAttr.get() != NULL) { + aDeflectionAttr->setValue(theDeflection); + } +} + // used by GUI only // LCOV_EXCL_START double getDeflection(const std::shared_ptr& theResult) @@ -803,6 +816,22 @@ double getDeflection(const std::shared_ptr& theResult) return aDeflection; } +//****************************************************** +void setColor(ResultPtr theResult, const std::vector& theColor) +{ + if (!theResult.get()) + return; + + AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); + if (aColorAttr.get() != NULL) { + if (!aColorAttr->size()) { + aColorAttr->setSize(3); + } + aColorAttr->setValue(0, theColor[0]); + aColorAttr->setValue(1, theColor[1]); + aColorAttr->setValue(2, theColor[2]); + } +} void getColor(const std::shared_ptr& theResult, std::vector& theColor) { @@ -819,6 +848,49 @@ void getColor(const std::shared_ptr& theResult, std::vector& theResult, std::vector& theNbLines) +{ + theNbLines.clear(); + // get color from the attribute of the result + if (theResult.get() != NULL && + theResult->data()->attribute(ModelAPI_Result::ISO_LINES_ID()).get() != NULL) { + AttributeIntArrayPtr aAttr = theResult->data()->intArray(ModelAPI_Result::ISO_LINES_ID()); + if (aAttr.get() && aAttr->size()) { + theNbLines.push_back(aAttr->value(0)); + theNbLines.push_back(aAttr->value(1)); + } + } +} + +//****************************************************** +void setIsoLines(ResultPtr theResult, const std::vector& theIso) +{ + if (!theResult.get()) + return; + + AttributeIntArrayPtr aAttr = theResult->data()->intArray(ModelAPI_Result::ISO_LINES_ID()); + if (aAttr.get() != NULL) { + if (!aAttr->size()) { + aAttr->setSize(2); + } + aAttr->setValue(0, theIso[0]); + aAttr->setValue(1, theIso[1]); + } +} + +//************************************************************** +void setTransparency(ResultPtr theResult, double theTransparency) +{ + if (!theResult.get()) + return; + + AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); + if (anAttribute.get() != NULL) { + anAttribute->setValue(theTransparency); + } +} + double getTransparency(const std::shared_ptr& theResult) { double aTransparency = -1; @@ -847,6 +919,16 @@ void copyVisualizationAttrs( aDestColor->setValue(a, aSourceColor->value(a)); } } + // Iso-lines + AttributeIntArrayPtr aSource = theSource->data()->intArray(ModelAPI_Result::ISO_LINES_ID()); + if (aSource.get() && aSource->isInitialized() && aSource->size()) { + AttributeIntArrayPtr aDest = theDest->data()->intArray(ModelAPI_Result::ISO_LINES_ID()); + if (aDest.get()) { + aDest->setSize(aSource->size()); + for(int a = 0; a < aSource->size(); a++) + aDest->setValue(a, aSource->value(a)); + } + } // deflection AttributeDoublePtr aSourceDefl = theSource->data()->real(ModelAPI_Result::DEFLECTION_ID()); if (aSourceDefl.get() && aSourceDefl->isInitialized()) { diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index b0af5520b..f9502dc82 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -216,6 +216,13 @@ MODELAPI_EXPORT void removeResults(const std::list& theResult); +/*! Sets the deflection value +* \param theResult a result object +* \param a deflection value +*/ +MODELAPI_EXPORT void setDeflection(std::shared_ptr theResult, + const double theDeflection); + /*! Returns current color of the current result * \param[in] theResult a result object * \param[out] theColor a color values if it is defined @@ -223,12 +230,41 @@ MODELAPI_EXPORT double getDeflection(const std::shared_ptr& the MODELAPI_EXPORT void getColor(const std::shared_ptr& theResult, std::vector& theColor); +/*! Set color of the result +* \param[in] theResult a result object +* \param[in] theColor a color values +*/ +MODELAPI_EXPORT void setColor(std::shared_ptr theResult, + const std::vector& theColor); + +/*! Returns number of iso-lines of the current result +* \param[in] theResult a result object +* \param[out] theNbLines values of iso-lines +*/ +MODELAPI_EXPORT void getIsoLines(const std::shared_ptr& theResult, + std::vector& theNbLines); + +/*! Set number of iso-lines of the result +* \param[in] theResult a result object +* \param[in] theIso nb iso-lines +*/ +MODELAPI_EXPORT void setIsoLines(std::shared_ptr theResult, + const std::vector& theIso); + /*! Returns current transparency in the given result * \param theResult a result object * \return a transparency value or -1 if it was not defined */ MODELAPI_EXPORT double getTransparency(const std::shared_ptr& theResult); +/*! Set transparency for the given result +* \param theResult a result object +* \param a transparency value +*/ +MODELAPI_EXPORT void setTransparency(std::shared_ptr theResult, + double theTransparency); + + /*! Copies all visualization attributes from one result to another. * \param theSource a result that contains the copied attributes * \param theDest a destination result that takes the visualization attributes diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index 405dfb85a..e63531e58 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -83,8 +83,19 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult) aDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1)); aDrawer->SetFaceBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1)); - aDrawer->VIsoAspect()->SetNumber(0); - aDrawer->UIsoAspect()->SetNumber(0); + Quantity_Color aColor; + Color(aColor); + + std::vector aIsoValues; + ModelAPI_Tools::getIsoLines(myResult, aIsoValues); + if (aIsoValues.size() == 0) { + aIsoValues.push_back(1); + aIsoValues.push_back(1); + } + myUIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[0]); + myVIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, aIsoValues[1]); + aDrawer->SetUIsoAspect(myUIsoAspect); + aDrawer->SetVIsoAspect(myVIsoAspect); if (aDrawer->HasOwnPointAspect()) aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS); @@ -95,8 +106,10 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult) if (aDrawer.IsNull()) { if (!ModuleBase_IViewer::DefaultHighlightDrawer.IsNull()) { aDrawer = new Prs3d_Drawer(*ModuleBase_IViewer::DefaultHighlightDrawer); - aDrawer->VIsoAspect()->SetNumber(0); - aDrawer->UIsoAspect()->SetNumber(0); + Handle(Prs3d_IsoAspect) aUIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, 0); + Handle(Prs3d_IsoAspect) aVIsoAspect = new Prs3d_IsoAspect(aColor, Aspect_TOL_SOLID, 1, 0); + aDrawer->SetUIsoAspect(aUIsoAspect); + aDrawer->SetVIsoAspect(aVIsoAspect); SetDynamicHilightAttributes(aDrawer); } } else { @@ -127,6 +140,8 @@ void ModuleBase_ResultPrs::SetColor (const Quantity_Color& theColor) ViewerData_AISShape::SetColor(theColor); myHiddenSubShapesDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel); setEdgesDefaultColor(); + myUIsoAspect->SetColor(theColor); + myVIsoAspect->SetColor(theColor); } void ModuleBase_ResultPrs::setEdgesDefaultColor() diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 84500eba6..a93089e98 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -112,10 +113,28 @@ public: /// \return false if parameter is out of [0, 1] Standard_EXPORT bool setHiddenSubShapeTransparency(double theTransparency); + /// Returns the original shape of the presentation Standard_EXPORT TopoDS_Shape originalShape() const { return myOriginalShape; } + /// Returns True if the original shape is substituted by a corresponded shell Standard_EXPORT bool isSubstituted() const { return myIsSubstituted; } + /// Set number of Iso-lines + /// \param theU a number of U Iso-lines + /// \param theV a number of V Iso-lines + Standard_EXPORT void setIsolinesNumber(int theU, int theV) { + myUIsoAspect->SetNumber(theU); myVIsoAspect->SetNumber(theV); + } + + /// Returns number of U Iso-lines + Standard_EXPORT int UIsoLines() const { + return myUIsoAspect->Number(); + } + + /// Returns number of V Iso-lines + Standard_EXPORT int VIsoLines() const { + return myVIsoAspect->Number(); + } DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape) @@ -171,6 +190,9 @@ private: /// selection priority that will be added to the standard /// selection priority of the selection entity int myAdditionalSelectionPriority; + + Handle(Prs3d_IsoAspect) myUIsoAspect; + Handle(Prs3d_IsoAspect) myVIsoAspect; }; diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index a174bea87..3c5146ffc 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -140,6 +140,10 @@ void XGUI_ContextMenuMgr::createActions() aDesktop); addAction("WIREFRAME_CMD", aAction); + aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Iso-lines..."), + aDesktop); + addAction("ISOLINES_CMD", aAction); + mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop); mySeparator1->setSeparator(true); @@ -308,9 +312,11 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() if (aMode != XGUI_Displayer::NoMode) { action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading); action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe); + action("ISOLINES_CMD")->setEnabled(true); } else { action("WIREFRAME_CMD")->setEnabled(true); action("SHADING_CMD")->setEnabled(true); + action("ISOLINES_CMD")->setEnabled(true); } } if (!hasFeature) { @@ -352,6 +358,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHOW_ONLY_CMD")->setEnabled(true); action("SHADING_CMD")->setEnabled(true); action("WIREFRAME_CMD")->setEnabled(true); + action("ISOLINES_CMD")->setEnabled(true); } if (hasFeature && myWorkshop->canMoveFeature()) { action("MOVE_CMD")->setEnabled(true); @@ -537,9 +544,11 @@ void XGUI_ContextMenuMgr::updateViewerMenu() if (aMode != XGUI_Displayer::NoMode) { action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading); action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe); + action("ISOLINES_CMD")->setEnabled(true); } else { action("WIREFRAME_CMD")->setEnabled(true); action("SHADING_CMD")->setEnabled(true); + action("ISOLINES_CMD")->setEnabled(true); } } action("SHOW_ONLY_CMD")->setEnabled(true); @@ -655,6 +664,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("COLOR_CMD")); aList.append(action("DEFLECTION_CMD")); aList.append(action("TRANSPARENCY_CMD")); + aList.append(action("ISOLINES_CMD")); aList.append(action("SHOW_FEATURE_CMD")); aList.append(mySeparator3); aList.append(action("DELETE_CMD")); @@ -730,6 +740,7 @@ void XGUI_ContextMenuMgr::buildViewerMenu() aList.append(action("COLOR_CMD")); aList.append(action("DEFLECTION_CMD")); aList.append(action("TRANSPARENCY_CMD")); + aList.append(action("ISOLINES_CMD")); aList.append(mySeparator3); aList.append(action("SET_VIEW_NORMAL_CMD")); aList.append(action("SET_VIEW_INVERTEDNORMAL_CMD")); @@ -783,6 +794,7 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const aActions.append(action("COLOR_CMD")); aActions.append(action("DEFLECTION_CMD")); aActions.append(action("TRANSPARENCY_CMD")); + aActions.append(action("ISOLINES_CMD")); aActions.append(action("CLEAN_HISTORY_CMD")); aActions.append(action("DELETE_CMD")); } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 3f7d23326..da590b502 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -314,6 +314,15 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) double aTransparency = ModelAPI_Tools::getTransparency(aResult); if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency())) aAISObj->setTransparency(aTransparency); + + // Set Iso-Lines + std::vector aIsoValues; + ModelAPI_Tools::getIsoLines(aResult, aIsoValues); + if (aIsoValues.size() > 0) { + Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO); + if (!aResPrs.IsNull()) + aResPrs->setIsolinesNumber(aIsoValues[0], aIsoValues[1]); + } } myWorkshop->module()->storeSelection(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index c1598b829..799f5c00f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -146,6 +146,9 @@ #include #include #include +#include +#include +#include #include @@ -1676,6 +1679,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) moveObjects(theId == "MOVE_SPLIT_CMD"); else if (theId == "COLOR_CMD") changeColor(aObjects); + else if (theId == "ISOLINES_CMD") + changeIsoLines(aObjects); else if (theId == "DEFLECTION_CMD") changeDeflection(aObjects); else if (theId == "TRANSPARENCY_CMD") @@ -2357,22 +2362,6 @@ bool XGUI_Workshop::canChangeProperty(const QString& theActionName) const return false; } -//****************************************************** -void setColor(ResultPtr theResult, const std::vector& theColor) -{ - if (!theResult.get()) - return; - - AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); - if (aColorAttr.get() != NULL) { - if (!aColorAttr->size()) { - aColorAttr->setSize(3); - } - aColorAttr->setValue(0, theColor[0]); - aColorAttr->setValue(1, theColor[1]); - aColorAttr->setValue(2, theColor[2]); - } -} //************************************************************** void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid, @@ -2455,10 +2444,10 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) std::list allRes; ModelAPI_Tools::allSubs(aBodyResult, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { - setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor()); + ModelAPI_Tools::setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor()); } } - setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor()); + ModelAPI_Tools::setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor()); } } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -2467,30 +2456,6 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) myViewerProxy->update(); } -//************************************************************** -void setDeflection(ResultPtr theResult, const double theDeflection) -{ - if (!theResult.get()) - return; - - AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID()); - if (aDeflectionAttr.get() != NULL) { - aDeflectionAttr->setValue(theDeflection); - } -} - -//************************************************************** -void setTransparency(ResultPtr theResult, double theTransparency) -{ - if (!theResult.get()) - return; - - AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); - if (anAttribute.get() != NULL) { - anAttribute->setValue(theTransparency); - } -} - //************************************************************** void setTransparency(double theTransparency, const QObjectPtrList& theObjects) { @@ -2503,10 +2468,10 @@ void setTransparency(double theTransparency, const QObjectPtrList& theObjects) ModelAPI_Tools::allSubs(aBodyResult, allRes); std::list::iterator aRes; for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) { - setTransparency(*aRes, theTransparency); + ModelAPI_Tools::setTransparency(*aRes, theTransparency); } } - setTransparency(aResult, theTransparency); + ModelAPI_Tools::setTransparency(aResult, theTransparency); } } } @@ -2594,10 +2559,10 @@ void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects) std::list allRes; ModelAPI_Tools::allSubs(aBodyResult, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { - setDeflection(*aRes, aDeflection); + ModelAPI_Tools::setDeflection(*aRes, aDeflection); } } - setDeflection(aResult, aDeflection); + ModelAPI_Tools::setDeflection(aResult, aDeflection); } } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -3197,3 +3162,62 @@ void XGUI_Workshop::deactivateCurrentSelector() { myActiveControlMgr->deactivateSelector(myActiveControlMgr->activeSelector()); } + +void XGUI_Workshop::changeIsoLines(const QObjectPtrList& theObjects) +{ + if (theObjects.isEmpty()) + return; + + std::vector aValues; + if (theObjects.size() == 1) { + ResultPtr aRes = std::dynamic_pointer_cast(theObjects.first()); + if (aRes.get()) + ModelAPI_Tools::getIsoLines(aRes, aValues); + else + return; + } + if (aValues.size() == 0) { + aValues.push_back(1); + aValues.push_back(1); + } + + if (!abortAllOperations()) + return; + + QDialog aDlg; + aDlg.setWindowTitle(tr("Number of Iso-lines")); + QFormLayout* aLayout = new QFormLayout(&aDlg); + + QSpinBox* aUNb = new QSpinBox(&aDlg); + aUNb->setValue(aValues[0]); + aLayout->addRow("U:", aUNb); + + QSpinBox* aVNb = new QSpinBox(&aDlg); + aVNb->setValue(aValues[1]); + aLayout->addRow("V:", aVNb); + + QDialogButtonBox* aButtons = + new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &aDlg); + connect(aButtons, SIGNAL(accepted()), &aDlg, SLOT(accept())); + connect(aButtons, SIGNAL(rejected()), &aDlg, SLOT(reject())); + aLayout->addRow(aButtons); + + if (aDlg.exec() == QDialog::Accepted) { + SessionPtr aMgr = ModelAPI_Session::get(); + QString aDescription = contextMenuMgr()->action("ISOLINES_CMD")->text(); + aMgr->startOperation(aDescription.toStdString()); + + aValues[0] = aUNb->value(); + aValues[1] = aVNb->value(); + ResultPtr aRes; + foreach(ObjectPtr aObj, theObjects) { + aRes = std::dynamic_pointer_cast(aObj); + if (aRes.get()) { + ModelAPI_Tools::setIsoLines(aRes, aValues); + } + } + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + aMgr->finishOperation(); + updateCommandStatus(); + } +} \ No newline at end of file diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 45f9d4a6e..2a3eacc14 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -213,6 +213,10 @@ Q_OBJECT /// theObjects a list of selected objects void changeTransparency(const QObjectPtrList& theObjects); + /// Change number of iso-lines for the given objects + /// theObjects a list of selected objects + void changeIsoLines(const QObjectPtrList& theObjects); + /// Show the given features in 3d Viewer void showObjects(const QObjectPtrList& theList, bool isVisible); diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 2178d9dda..1225bcc32 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -95,5 +95,6 @@ pictures/ArrowCursor.png pictures/CrossCursor.png pictures/HandCursor.png + pictures/iso_lines.png diff --git a/src/XGUI/pictures/iso_lines.png b/src/XGUI/pictures/iso_lines.png new file mode 100644 index 000000000..20f86bc9b Binary files /dev/null and b/src/XGUI/pictures/iso_lines.png differ