From: cg246364 Date: Wed, 4 Aug 2021 07:07:19 +0000 (+0200) Subject: Corrections sur la documentation et le code X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6fa7c6d7164a2c9f880d25fd3b9269585dceeb27;p=modules%2Fshaper.git Corrections sur la documentation et le code --- diff --git a/src/CTestTestfileInstall.cmake b/src/CTestTestfileInstall.cmake index b52f407b3..daabb1b56 100644 --- a/src/CTestTestfileInstall.cmake +++ b/src/CTestTestfileInstall.cmake @@ -47,4 +47,5 @@ SUBDIRS(ConnectorAPI ModelGeomAlgo Locale test_API + OperaPlugin ) diff --git a/src/OperaAPI/OperaAPI_Volume.cpp b/src/OperaAPI/OperaAPI_Volume.cpp index 2612060d1..cf7dd40c9 100644 --- a/src/OperaAPI/OperaAPI_Volume.cpp +++ b/src/OperaAPI/OperaAPI_Volume.cpp @@ -18,15 +18,9 @@ // #include "OperaAPI_Volume.h" - - #include -#include #include -#include // std::wstring_convert -#include // std::codecvt_utf8 - //================================================================================================== OperaAPI_Volume::OperaAPI_Volume(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) @@ -37,35 +31,32 @@ OperaAPI_Volume::OperaAPI_Volume(const std::shared_ptr& theFea //================================================================================================== OperaAPI_Volume::OperaAPI_Volume(const std::shared_ptr& theFeature, - const ModelHighAPI_Double& theMedium, - const std::list& theObjectList) + const std::string& theMedium, + const std::list& theObjectsList) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - - std::wstring w_medium = theMedium.string(); - std::wstring_convert,wchar_t> cv; - std::string medium_str = cv.to_bytes(w_medium); - - fillAttribute(medium_str, medium()); - setObjectList(theObjectList); + fillAttribute(theMedium, medium()); + setObjectsList(theObjectsList); } } //================================================================================================== -OperaAPI_Volume::~OperaAPI_Volume() {} +OperaAPI_Volume::~OperaAPI_Volume() +{ +} //================================================================================================== -void OperaAPI_Volume::setMedium(const ModelHighAPI_Double& theMedium) +void OperaAPI_Volume::setMedium(const std::string& theMedium) { - fillAttribute(OperaPlugin_Volume::MEDIUM_ID(), medium()); + fillAttribute(theMedium, medium()); execute(); } //================================================================================================== -void OperaAPI_Volume::setObjectList(const std::list& theObjectList) +void OperaAPI_Volume::setObjectsList(const std::list& theObjectsList) { - fillAttribute(theObjectList, volumeList()); + fillAttribute(theObjectsList, objectsList()); execute(); } @@ -78,16 +69,16 @@ void OperaAPI_Volume::dump(ModelHighAPI_Dumper& theDumper) const AttributeStringPtr anAttrMedium = aBase->string(OperaPlugin_Volume::MEDIUM_ID()); theDumper << aBase << " = model.addVolume(" << aDocName << ", " << anAttrMedium << ", "; - AttributeSelectionListPtr anAttrList = aBase->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID()); + AttributeSelectionListPtr anAttrList = + aBase->selectionList(OperaPlugin_Volume::OBJECTS_LIST_ID()); theDumper << anAttrList << ")" << std::endl; } //================================================================================================== VolumePtr addVolume(const std::shared_ptr& thePart, - const ModelHighAPI_Double& theMedium, - const std::list& theObjectList) + const std::string& theMedium, + const std::list& theObjectsList) { std::shared_ptr aFeature = thePart->addFeature(OperaAPI_Volume::ID()); - //aFeature->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID())->setGeometricalSelection(true); - return VolumePtr(new OperaAPI_Volume(aFeature, theMedium, theObjectList)); + return VolumePtr(new OperaAPI_Volume(aFeature, theMedium, theObjectsList)); } diff --git a/src/OperaAPI/OperaAPI_Volume.h b/src/OperaAPI/OperaAPI_Volume.h index 46842b018..78aca0374 100644 --- a/src/OperaAPI/OperaAPI_Volume.h +++ b/src/OperaAPI/OperaAPI_Volume.h @@ -26,12 +26,11 @@ #include #include -class ModelHighAPI_Double; class ModelHighAPI_Selection; /// \class OperaAPI_Volume /// \ingroup CPPHighAPI -/// \brief Interface for primitive Box feature. +/// \brief Interface for Volume feature. class OperaAPI_Volume: public ModelHighAPI_Interface { public: @@ -42,8 +41,8 @@ public: /// Constructor with values. OPERAAPI_EXPORT explicit OperaAPI_Volume(const std::shared_ptr& theFeature, - const ModelHighAPI_Double& theMedium, - const std::list& theObjectList); + const std::string& theMedium, + const std::list& theObjectList); /// Destructor. OPERAAPI_EXPORT @@ -51,17 +50,17 @@ public: INTERFACE_2(OperaPlugin_Volume::ID(), medium, OperaPlugin_Volume::MEDIUM_ID(), - ModelAPI_AttributeString, /** Volume medium */, - volumeList, OperaPlugin_Volume::VOLUME_LIST_ID(), - ModelAPI_AttributeSelectionList, /** Group list*/) + ModelAPI_AttributeString, /** Medium */, + objectsList, OperaPlugin_Volume::OBJECTS_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Objects list*/) /// Set medium OPERAAPI_EXPORT - void setMedium(const ModelHighAPI_Double& theMedium); + void setMedium(const std::string& theMedium); /// Set main objects list. OPERAAPI_EXPORT - void setObjectList(const std::list& theObjectList); + void setObjectsList(const std::list& theObjectsList); /// Dump wrapped feature OPERAAPI_EXPORT @@ -75,7 +74,7 @@ typedef std::shared_ptr VolumePtr; /// \brief Create Volume feature. OPERAAPI_EXPORT VolumePtr addVolume(const std::shared_ptr& thePart, - const ModelHighAPI_Double& theMedium, - const std::list& theObjectList); + const std::string& theMedium, + const std::list& theObjectsList); -#endif // OperaAPI_Volume_H_ +#endif // OPERAAPI_VOLUME_H_ diff --git a/src/OperaPlugin/OperaPlugin_Plugin.cpp b/src/OperaPlugin/OperaPlugin_Plugin.cpp index e5791e516..894925751 100644 --- a/src/OperaPlugin/OperaPlugin_Plugin.cpp +++ b/src/OperaPlugin/OperaPlugin_Plugin.cpp @@ -23,8 +23,6 @@ #include #include -#include -#include // the only created instance of this plugin static OperaPlugin_Plugin* MY_PRIMITIVES_INSTANCE = new OperaPlugin_Plugin(); diff --git a/src/OperaPlugin/OperaPlugin_Volume.cpp b/src/OperaPlugin/OperaPlugin_Volume.cpp index 4c41960ae..57393a226 100644 --- a/src/OperaPlugin/OperaPlugin_Volume.cpp +++ b/src/OperaPlugin/OperaPlugin_Volume.cpp @@ -18,21 +18,15 @@ // #include -#include #include #include -#include #include #include #include #include -#include -#include - #include #include -#include //================================================================================================= OperaPlugin_Volume::OperaPlugin_Volume() // Nothing to do during instantiation @@ -66,7 +60,7 @@ void OperaPlugin_Volume::initAttributes() data()->addAttribute(MEDIUM_ID(), ModelAPI_AttributeString::typeId()); // Get Objects - data()->addAttribute(VOLUME_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); } //================================================================================================= @@ -81,7 +75,7 @@ void OperaPlugin_Volume::execute() int aResultIndex = 0; - AttributeSelectionListPtr aList = selectionList(VOLUME_LIST_ID()); + AttributeSelectionListPtr aList = selectionList(OBJECTS_LIST_ID()); std::wstring aBaseName; for (int aSelIndex = 0; aSelIndex < aList->size(); aSelIndex++) { AttributeSelectionPtr aSel = aList->value(aSelIndex); @@ -106,9 +100,7 @@ void OperaPlugin_Volume::execute() std::set anExistingNames; std::wstring aBaseName = aSel->context() ? aSel->context()->data()->name() : aSel->contextFeature()->firstResult()->data()->name(); - int anInd = 0; do { - anInd++; std::wostringstream aNameStr; aNameStr << "Volume_" << aBaseName; aName = aNameStr.str(); diff --git a/src/OperaPlugin/OperaPlugin_Volume.h b/src/OperaPlugin/OperaPlugin_Volume.h index e48e2ff5b..be8b73824 100644 --- a/src/OperaPlugin/OperaPlugin_Volume.h +++ b/src/OperaPlugin/OperaPlugin_Volume.h @@ -22,7 +22,6 @@ #include #include -#include class GeomAPI_Shape; class ModelAPI_ResultBody; @@ -49,10 +48,10 @@ class OperaPlugin_Volume : public ModelAPI_Feature return MY_MEDIUM_ID; } /// attribute name of selected entities list - inline static const std::string& VOLUME_LIST_ID() + inline static const std::string& OBJECTS_LIST_ID() { - static const std::string MY_VOLUME_LIST_ID("volume_list"); - return MY_VOLUME_LIST_ID; + static const std::string MY_OBJECTS_LIST_ID("objects_list"); + return MY_OBJECTS_LIST_ID; } // Creates a new part document if needed diff --git a/src/OperaPlugin/OperaPlugin_msg_fr.ts b/src/OperaPlugin/OperaPlugin_msg_fr.ts index 5d22d90ae..aca1a8815 100644 --- a/src/OperaPlugin/OperaPlugin_msg_fr.ts +++ b/src/OperaPlugin/OperaPlugin_msg_fr.ts @@ -2,56 +2,56 @@ - - workshop - - Volume - Volume - - + + workshop + + Volume + Volume + + - - Volume - - Volume - Volume - - - Create a volume - Créer un volume - - + + Volume + + Volume + Volume + + + Create a volume + Créer un volume + + - - Volume:medium - - Medium - Milieu - - - Please input the volumes medium - Veuillez indiquer le milieu des volumes - - + + Volume:medium + + Medium + Milieu + + + Please input the volumes medium + Veuillez indiquer le milieu des volumes + + - - Volume:volume_list - - Select solids - Selectionner les solides - - - Select solid objects - Sélectionnez les solides - - + + Volume:objects_list + + Objects + Objets + + + Select solid objects + Sélectionnez les solides + + - - Volume:volume_list - - Attribute "%1" is not initialized. - Sélectionnez les solides. - - + + Volume:objects_list + + Attribute "%1" is not initialized. + Sélectionnez les solides. + + diff --git a/src/OperaPlugin/Test/TestVolume.py b/src/OperaPlugin/Test/TestVolume.py index f85f3246d..66538baca 100755 --- a/src/OperaPlugin/Test/TestVolume.py +++ b/src/OperaPlugin/Test/TestVolume.py @@ -45,7 +45,8 @@ 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, "Eau", [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Sphere_1_1")]) +Volume_2 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Sphere_1_1")]) +Volume_2.setMedium("Eau") #Checks from GeomAPI import GeomAPI_Shape @@ -69,7 +70,7 @@ assert(Volume_3.feature().error() == "Error: Medium cannot be empty.") ### Create a volume with no shapes Volume_4 = model.addVolume(Part_1_doc, "Error", []) model.testNbResults(Volume_4, 0) -assert(Volume_4.feature().error() == "Attribute \"volume_list\" is not initialized.") +assert(Volume_4.feature().error() == "Attribute \"objects_list\" is not initialized.") ### Create a volume with bad shapes Volume_5 = model.addVolume(Part_1_doc, "Bad Shape", [model.selection("VERTEX", "PartSet/Origin")]) diff --git a/src/OperaPlugin/doc/OperaPlugin.rst b/src/OperaPlugin/doc/OperaPlugin.rst index 41da0e59a..f61f280bd 100644 --- a/src/OperaPlugin/doc/OperaPlugin.rst +++ b/src/OperaPlugin/doc/OperaPlugin.rst @@ -4,7 +4,7 @@ Opera plug-in ================== -The Opera plug-in contains features for creation of Opera items. Result of each feature is a solid. The plug-in includes the following features: +The Opera plug-in provides a set of common operations to ROOT geometry. It implements the following features: .. toctree:: :titlesonly: diff --git a/src/OperaPlugin/doc/TUI_volume.rst b/src/OperaPlugin/doc/TUI_volume.rst index f136686c6..3f3ecbd0f 100644 --- a/src/OperaPlugin/doc/TUI_volume.rst +++ b/src/OperaPlugin/doc/TUI_volume.rst @@ -1,11 +1,11 @@ - .. tui_create_volume: + .. _tui_create_volume: -Create Box by points -==================== +Create Volume +============= .. literalinclude:: examples/volume.py :linenos: :language: python -:download:`Download this script ` +:download:`Download this script ` diff --git a/src/OperaPlugin/doc/example/volume.py b/src/OperaPlugin/doc/example/volume.py deleted file mode 100644 index a21ef5396..000000000 --- a/src/OperaPlugin/doc/example/volume.py +++ /dev/null @@ -1,12 +0,0 @@ -from salome.shaper import model - -model.begin() -partSet = model.moduleDocument() -Part_1 = model.addPart(partSet) -Part_1_doc = Part_1.document() - -Box_1 = model.addBox(Part_1_doc, 10, 10, 10) -Volume_1 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Box_1_1")]) - -model.do() -model.end() diff --git a/src/OperaPlugin/doc/examples/volume.py b/src/OperaPlugin/doc/examples/volume.py new file mode 100644 index 000000000..a21ef5396 --- /dev/null +++ b/src/OperaPlugin/doc/examples/volume.py @@ -0,0 +1,12 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Volume_1 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Box_1_1")]) + +model.do() +model.end() diff --git a/src/OperaPlugin/doc/images/Volume.png b/src/OperaPlugin/doc/images/Volume.png new file mode 100644 index 000000000..281fc7197 Binary files /dev/null and b/src/OperaPlugin/doc/images/Volume.png differ diff --git a/src/OperaPlugin/doc/images/Volume_create.png b/src/OperaPlugin/doc/images/Volume_create.png deleted file mode 100644 index 63c1f2263..000000000 Binary files a/src/OperaPlugin/doc/images/Volume_create.png and /dev/null differ diff --git a/src/OperaPlugin/doc/volumeFeature.rst b/src/OperaPlugin/doc/volumeFeature.rst index 66aa64285..8ea5c8548 100644 --- a/src/OperaPlugin/doc/volumeFeature.rst +++ b/src/OperaPlugin/doc/volumeFeature.rst @@ -1,31 +1,33 @@ .. |Volume_button.icon| image:: images/Volume_button.png Volume -------------- +------ -Volume feature creates a box solid. +Volume feature creates a basic object used in bulding the ROOT geometrical hierarchy. 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: -Volume is created by a Medium value and a list of solids +Volume is created by a value and a list of solids -.. figure:: images/Volume_create.png +.. figure:: images/Volume.png :align: center Input fields: -- **MEDIUM**, **VOLUME_LIST** define medium and shapes of the volume. +- **Medium** defines the name of the medium; +- **Objects** defines the list of solid objects **TUI Command**: -.. py:function:: model.addVolume(Part_doc, MediumString, model.selection["SOLID", "...", ...]) +.. py:function:: + model.addVolume(Part_doc, medium, model.selection[("SOLID", ...), ...]) :param part: The current part object. - :param string: Medium name. - :param list: List of solids. + :param string: A medium name. + :param list: A list of solids. :return: Result object. Result @@ -36,4 +38,6 @@ One solid for each selected solid in the volume list with according medium .. figure:: images/Volume1.png :align: center + Volume created + **See Also** a sample TUI Script of :ref:`tui_create_volume` operation. diff --git a/src/OperaPlugin/volume_widget.xml b/src/OperaPlugin/volume_widget.xml index 8f18a004d..a0cbd22b7 100644 --- a/src/OperaPlugin/volume_widget.xml +++ b/src/OperaPlugin/volume_widget.xml @@ -3,8 +3,8 @@ label="Medium" tooltip="Please input the volumes medium"> - diff --git a/src/SHAPERGUI/resources/LightApp.xml.in b/src/SHAPERGUI/resources/LightApp.xml.in index 33908724f..6d303a073 100644 --- a/src/SHAPERGUI/resources/LightApp.xml.in +++ b/src/SHAPERGUI/resources/LightApp.xml.in @@ -22,6 +22,9 @@ +
+ +