Salome HOME
Issue #3140: Modify Iso-lines of a shape presentation
authorvsv <vsv@opencascade.com>
Fri, 7 Feb 2020 14:20:41 +0000 (17:20 +0300)
committervsr <vsr@opencascade.com>
Mon, 10 Feb 2020 14:15:57 +0000 (17:15 +0300)
14 files changed:
src/Model/Model_Data.cpp
src/Model/Model_ResultPart.cpp
src/ModelAPI/ModelAPI_Result.cpp
src/ModelAPI/ModelAPI_Result.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/iso_lines.png [new file with mode: 0644]

index 2a25c5136913462dd8887e5249277880e80ac42a..ecafd0c205aa3ba99940aa7c8651440c12127d6f 100644 (file)
@@ -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);
     }
index f89eff7d738ec5632febcd3f19e9f44ff4b2046a..fd752bc7282da60eb110f4a8ae70d5e44b590378 100644 (file)
@@ -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()))
index 18c96fbc91edff5665d7319f270921dd2fb66244..b3d3dc574a5731da280aa7f220bdbff995d8d04a 100644 (file)
@@ -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<ModelAPI_Result> theThis, const bool theFlag)
index 81709e749e22f35a65e570547bae02b8aeb16a87..a53c1e04fd8b4fdce4811494a1a6fb0bad0d96dd 100644 (file)
@@ -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();
 
index 413f52c4ce616edd2c2e4cb49f84f0621dde2737..3d293492e517645cf583bdf62eb22a8c7fdea2d4 100644 (file)
@@ -785,6 +785,19 @@ void removeResults(const std::list<ResultPtr>& 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<ModelAPI_Result>& theResult)
@@ -803,6 +816,22 @@ double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult)
   return aDeflection;
 }
 
+//******************************************************
+void setColor(ResultPtr theResult, const std::vector<int>& 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<ModelAPI_Result>& theResult, std::vector<int>& theColor)
 {
@@ -819,6 +848,49 @@ void getColor(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int
   }
 }
 
+//******************************************************
+void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult, std::vector<int>& 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<int>& 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<ModelAPI_Result>& 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()) {
index b0af5520bae730e1b3a1252f24df5a358bb42e70..f9502dc823ca62cf1546ca1f12abde88afa19ff8 100644 (file)
@@ -216,6 +216,13 @@ MODELAPI_EXPORT void removeResults(const std::list<std::shared_ptr<ModelAPI_Resu
 */
 MODELAPI_EXPORT double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult);
 
+/*! Sets the deflection value
+* \param theResult a result object
+* \param a deflection value
+*/
+MODELAPI_EXPORT void setDeflection(std::shared_ptr<ModelAPI_Result> 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<ModelAPI_Result>& the
 MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result>& theResult,
   std::vector<int>& 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<ModelAPI_Result> theResult,
+  const std::vector<int>& 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<ModelAPI_Result>& theResult,
+  std::vector<int>& 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<ModelAPI_Result> theResult,
+  const std::vector<int>& 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<ModelAPI_Result>& theResult);
 
+/*! Set transparency for the given result
+* \param theResult a result object
+* \param a transparency value
+*/
+MODELAPI_EXPORT void setTransparency(std::shared_ptr<ModelAPI_Result> 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
index 405dfb85a29df16395612eabc5589b1ceb23cca7..e63531e586aa811b69082a142e06202d4c65fab7 100644 (file)
@@ -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<int> 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()
index 84500eba65dfff600d2f6cbad61b76defbefa624..a93089e98dbca8b8c5e09686d4e5469410747554 100644 (file)
@@ -30,6 +30,7 @@
 #include <ViewerData_AISShape.hxx>
 #include <Standard_DefineHandle.hxx>
 #include <TopoDS_Compound.hxx>
+#include <Prs3d_IsoAspect.hxx>
 
 #include <QMap>
 
@@ -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;
 };
 
 
index a174bea87b737f8ae17402cf8e0e725739ea0687..3c5146ffcfaffd7f49285e134e6a20363b00bbc8 100644 (file)
@@ -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"));
   }
index 3f7d23326ef5544ae0d448665bd08a89e2c2c3bf..da590b502d1aee301e32b733e4464c46b66ab039 100644 (file)
@@ -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<int> 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();
 
index c1598b82984a957edf34ca9ffef6a2e70d6b2562..799f5c00f172d71a5e96d06d435cd5b7b6381204 100644 (file)
 #include <QDesktopWidget>
 #include <QProcess>
 #include <QDesktopServices>
+#include <QFormLayout>
+#include <QSpinBox>
+#include <QDialogButtonBox>
 
 #include <iterator>
 
@@ -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<int>& 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<ResultPtr> allRes;
         ModelAPI_Tools::allSubs(aBodyResult, allRes);
         for(std::list<ResultPtr>::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<ResultPtr>::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<ResultPtr> allRes;
         ModelAPI_Tools::allSubs(aBodyResult, allRes);
         for(std::list<ResultPtr>::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<int> aValues;
+  if (theObjects.size() == 1) {
+    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(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<ModelAPI_Result>(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
index 45f9d4a6e7342d3004fc41e6b6b34e77c02d4998..2a3eacc147a1e7beb0fa42e3c9338c95b3f1901d 100644 (file)
@@ -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);
 
index 2178d9dda21d4ebf86037792b770e8fcd2f5c9c2..1225bcc3205411410d31cc2b11a1982605738a30 100644 (file)
@@ -95,5 +95,6 @@
      <file>pictures/ArrowCursor.png</file>
      <file>pictures/CrossCursor.png</file>
      <file>pictures/HandCursor.png</file>
+     <file>pictures/iso_lines.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/iso_lines.png b/src/XGUI/pictures/iso_lines.png
new file mode 100644 (file)
index 0000000..20f86bc
Binary files /dev/null and b/src/XGUI/pictures/iso_lines.png differ