From 90886037e2aa365a0c9b88d12c08a2d11221f76d Mon Sep 17 00:00:00 2001 From: Nicolas RECHATIN Date: Tue, 3 Aug 2021 09:56:14 +0200 Subject: [PATCH] fix Volume documentation and test --- src/OperaAPI/OperaAPI_Volume.cpp | 4 ++-- src/OperaAPI/OperaAPI_Volume.h | 2 +- src/OperaPlugin/CMakeLists.txt | 2 +- src/OperaPlugin/OperaPlugin_Plugin.cpp | 2 -- src/OperaPlugin/OperaPlugin_Volume.cpp | 4 ++-- src/OperaPlugin/OperaPlugin_Volume.h | 2 +- src/OperaPlugin/Test/TestVolume.py | 2 +- src/OperaPlugin/doc/TUI_volume.rst | 11 +++++++++++ src/OperaPlugin/doc/volumeFeature.rst | 16 ++++++++-------- src/OperaPlugin/plugin-Opera.xml | 3 +-- 10 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 src/OperaPlugin/doc/TUI_volume.rst diff --git a/src/OperaAPI/OperaAPI_Volume.cpp b/src/OperaAPI/OperaAPI_Volume.cpp index b216ec67e..2612060d1 100644 --- a/src/OperaAPI/OperaAPI_Volume.cpp +++ b/src/OperaAPI/OperaAPI_Volume.cpp @@ -58,7 +58,7 @@ OperaAPI_Volume::~OperaAPI_Volume() {} //================================================================================================== void OperaAPI_Volume::setMedium(const ModelHighAPI_Double& theMedium) { - fillAttribute(OperaPlugin_Volume::MEDIUM(), medium()); + fillAttribute(OperaPlugin_Volume::MEDIUM_ID(), medium()); execute(); } @@ -75,7 +75,7 @@ void OperaAPI_Volume::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aDocName = theDumper.name(aBase->document()); - AttributeStringPtr anAttrMedium = aBase->string(OperaPlugin_Volume::MEDIUM()); + AttributeStringPtr anAttrMedium = aBase->string(OperaPlugin_Volume::MEDIUM_ID()); theDumper << aBase << " = model.addVolume(" << aDocName << ", " << anAttrMedium << ", "; AttributeSelectionListPtr anAttrList = aBase->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID()); diff --git a/src/OperaAPI/OperaAPI_Volume.h b/src/OperaAPI/OperaAPI_Volume.h index 11df68c11..46842b018 100644 --- a/src/OperaAPI/OperaAPI_Volume.h +++ b/src/OperaAPI/OperaAPI_Volume.h @@ -50,7 +50,7 @@ public: virtual ~OperaAPI_Volume(); INTERFACE_2(OperaPlugin_Volume::ID(), - medium, OperaPlugin_Volume::MEDIUM(), + medium, OperaPlugin_Volume::MEDIUM_ID(), ModelAPI_AttributeString, /** Volume medium */, volumeList, OperaPlugin_Volume::VOLUME_LIST_ID(), ModelAPI_AttributeSelectionList, /** Group list*/) diff --git a/src/OperaPlugin/CMakeLists.txt b/src/OperaPlugin/CMakeLists.txt index 7988af534..a1f7fd600 100644 --- a/src/OperaPlugin/CMakeLists.txt +++ b/src/OperaPlugin/CMakeLists.txt @@ -69,7 +69,7 @@ ADD_UNIT_TESTS(${TEST_NAMES}) if(${HAVE_SALOME}) enable_testing() - set(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/CollectionPlugin") + set(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/OperaPlugin") install(FILES CTestTestfileInstall.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} diff --git a/src/OperaPlugin/OperaPlugin_Plugin.cpp b/src/OperaPlugin/OperaPlugin_Plugin.cpp index 25c7762ec..e5791e516 100644 --- a/src/OperaPlugin/OperaPlugin_Plugin.cpp +++ b/src/OperaPlugin/OperaPlugin_Plugin.cpp @@ -40,8 +40,6 @@ FeaturePtr OperaPlugin_Plugin::createFeature(std::string theFeatureID) if (theFeatureID == OperaPlugin_Volume::ID()) { return FeaturePtr(new OperaPlugin_Volume); } else { - // else if (theFeatureID == OperaPlugin_addNode::ID()){ - // return FeaturePtr(new OperaPlugin_addNode); return FeaturePtr(); } } diff --git a/src/OperaPlugin/OperaPlugin_Volume.cpp b/src/OperaPlugin/OperaPlugin_Volume.cpp index 1a285745e..4c41960ae 100644 --- a/src/OperaPlugin/OperaPlugin_Volume.cpp +++ b/src/OperaPlugin/OperaPlugin_Volume.cpp @@ -63,7 +63,7 @@ static GeomShapePtr shapeOfSelection(AttributeSelectionPtr theSel) { void OperaPlugin_Volume::initAttributes() { // Get Medium - data()->addAttribute(MEDIUM(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(MEDIUM_ID(), ModelAPI_AttributeString::typeId()); // Get Objects data()->addAttribute(VOLUME_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); @@ -72,7 +72,7 @@ void OperaPlugin_Volume::initAttributes() //================================================================================================= void OperaPlugin_Volume::execute() { - std::string aCopiesMedium = string(MEDIUM())->value(); + std::string aCopiesMedium = string(MEDIUM_ID())->value(); if (aCopiesMedium.empty()) { setError("Error: Medium cannot be empty."); diff --git a/src/OperaPlugin/OperaPlugin_Volume.h b/src/OperaPlugin/OperaPlugin_Volume.h index 75dcf614f..e48e2ff5b 100644 --- a/src/OperaPlugin/OperaPlugin_Volume.h +++ b/src/OperaPlugin/OperaPlugin_Volume.h @@ -43,7 +43,7 @@ class OperaPlugin_Volume : public ModelAPI_Feature static const std::string MY_VOLUME_ID("Volume"); return MY_VOLUME_ID; } - inline static const std::string& MEDIUM() + inline static const std::string& MEDIUM_ID() { static const std::string MY_MEDIUM_ID("medium"); return MY_MEDIUM_ID; diff --git a/src/OperaPlugin/Test/TestVolume.py b/src/OperaPlugin/Test/TestVolume.py index bd6d2bccf..f85f3246d 100755 --- a/src/OperaPlugin/Test/TestVolume.py +++ b/src/OperaPlugin/Test/TestVolume.py @@ -45,7 +45,7 @@ Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin Volume_1 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Box_1_1")]) ### Create a volume from the cylinder and the sphere -Volume_2 = model.addVolume(Part_1_doc, "Concrete", [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Sphere_1_1")]) +Volume_2 = model.addVolume(Part_1_doc, "Eau", [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Sphere_1_1")]) #Checks from GeomAPI import GeomAPI_Shape diff --git a/src/OperaPlugin/doc/TUI_volume.rst b/src/OperaPlugin/doc/TUI_volume.rst new file mode 100644 index 000000000..f136686c6 --- /dev/null +++ b/src/OperaPlugin/doc/TUI_volume.rst @@ -0,0 +1,11 @@ + + .. tui_create_volume: + +Create Box by points +==================== + +.. literalinclude:: examples/volume.py + :linenos: + :language: python + +:download:`Download this script ` diff --git a/src/OperaPlugin/doc/volumeFeature.rst b/src/OperaPlugin/doc/volumeFeature.rst index f3541686e..66aa64285 100644 --- a/src/OperaPlugin/doc/volumeFeature.rst +++ b/src/OperaPlugin/doc/volumeFeature.rst @@ -1,5 +1,8 @@ .. |Volume_button.icon| image:: images/Volume_button.png +Volume +------------- + Volume feature creates a box solid. To create a Volume in the active part: @@ -7,11 +10,6 @@ To create a Volume in the active part: #. select in the Main Menu *Opera - > Volume* item or #. click |Volume_button.icon| **Volume** button in the toolbar: --------------------------------------------------------------------------------- - -by Medium and Solids -------------- - Volume is created by a Medium value and a list of solids .. figure:: images/Volume_create.png @@ -23,11 +21,11 @@ Input fields: **TUI Command**: -.. py:function:: model.addVolume(Part_doc, MEDIUM, VOLUME_LIST) +.. py:function:: model.addVolume(Part_doc, MediumString, model.selection["SOLID", "...", ...]) :param part: The current part object. - :param real: Medium name. - :param real: List of solids. + :param string: Medium name. + :param list: List of solids. :return: Result object. Result @@ -37,3 +35,5 @@ One solid for each selected solid in the volume list with according medium .. figure:: images/Volume1.png :align: center + +**See Also** a sample TUI Script of :ref:`tui_create_volume` operation. diff --git a/src/OperaPlugin/plugin-Opera.xml b/src/OperaPlugin/plugin-Opera.xml index 9691814c6..f16bf394b 100644 --- a/src/OperaPlugin/plugin-Opera.xml +++ b/src/OperaPlugin/plugin-Opera.xml @@ -1,8 +1,7 @@ -