From: Nicolas RECHATIN Date: Mon, 19 Jul 2021 08:37:06 +0000 (+0200) Subject: wip Opera menu and addVolume feature in GUI X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=53ee16fde88041b767ae51e23dbc6a87cb9901eb;p=modules%2Fshaper.git wip Opera menu and addVolume feature in GUI --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c566338c3..9b92e0a3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,9 @@ ADD_SUBDIRECTORY (src/PartSetPlugin) ADD_SUBDIRECTORY (src/ConstructionPlugin) ADD_SUBDIRECTORY (src/BuildPlugin) ADD_SUBDIRECTORY (src/PrimitivesPlugin) + +ADD_SUBDIRECTORY (src/OperaPlugin) + ADD_SUBDIRECTORY (src/GDMLPlugin) ADD_SUBDIRECTORY (src/FeaturesPlugin) ADD_SUBDIRECTORY (src/CollectionPlugin) diff --git a/src/Config/plugins.xml.in b/src/Config/plugins.xml.in index 7c23b377e..a9e6b148f 100644 --- a/src/Config/plugins.xml.in +++ b/src/Config/plugins.xml.in @@ -6,6 +6,7 @@ + diff --git a/src/OperaPlugin/CMakeLists.txt b/src/OperaPlugin/CMakeLists.txt new file mode 100644 index 000000000..be7b24ea5 --- /dev/null +++ b/src/OperaPlugin/CMakeLists.txt @@ -0,0 +1,66 @@ +# Copyright (C) 2014-2021 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(PROJECT_HEADERS + OperaPlugin.h + OperaPlugin_Plugin.h + OperaPlugin_Volume.h +) + +SET(PROJECT_SOURCES + OperaPlugin_Plugin.cpp + OperaPlugin_Volume.cpp + +) + +SET(XML_RESOURCES + plugin-Opera.xml + addvolume_widget.xml +) + +SET(TEXT_RESOURCES + OperaPlugin_msg_fr.ts +) + +SOURCE_GROUP ("XML Files" FILES ${XML_RESOURCES}) +SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES}) + +INCLUDE_DIRECTORIES( + ../ModelAPI + ../GeomAPI + ../GeomAlgoAPI + ../Events +) + +SET(PROJECT_LIBRARIES + Events + ModelAPI + GeomAPI + GeomAlgoAPI +) + +ADD_DEFINITIONS(-DOPERAPLUGIN_EXPORTS) +ADD_LIBRARY(OperaPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES}) +TARGET_LINK_LIBRARIES(OperaPlugin ${PROJECT_LIBRARIES}) + +INSTALL(TARGETS OperaPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES}) +INSTALL(FILES ${XML_RESOURCES} ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) +INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Opera) + + diff --git a/src/OperaPlugin/OperaPlugin.h b/src/OperaPlugin/OperaPlugin.h new file mode 100644 index 000000000..85a17bfac --- /dev/null +++ b/src/OperaPlugin/OperaPlugin.h @@ -0,0 +1,37 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef OPERAPLUGIN_H +#define OPERAPLUGIN_H + +#if defined OPERAPLUGIN_EXPORTS +#if defined WIN32 +#define OPERAPLUGIN_EXPORT __declspec( dllexport ) +#else +#define OPERAPLUGIN_EXPORT +#endif +#else +#if defined WIN32 +#define OPERAPLUGIN_EXPORT __declspec( dllimport ) +#else +#define OPERAPLUGIN_EXPORT +#endif +#endif + +#endif diff --git a/src/OperaPlugin/OperaPlugin_Plugin.cpp b/src/OperaPlugin/OperaPlugin_Plugin.cpp new file mode 100644 index 000000000..25c7762ec --- /dev/null +++ b/src/OperaPlugin/OperaPlugin_Plugin.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include + +#include + +#include +#include +#include + +// the only created instance of this plugin +static OperaPlugin_Plugin* MY_PRIMITIVES_INSTANCE = new OperaPlugin_Plugin(); + +OperaPlugin_Plugin::OperaPlugin_Plugin() +{ + // register this plugin + ModelAPI_Session::get()->registerPlugin(this); +} + +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_Plugin.h b/src/OperaPlugin/OperaPlugin_Plugin.h new file mode 100644 index 000000000..b4fd54ca7 --- /dev/null +++ b/src/OperaPlugin/OperaPlugin_Plugin.h @@ -0,0 +1,43 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef OperaPlugin_Plugin_H_ +#define OperaPlugin_Plugin_H_ + +#include "OperaPlugin.h" +#include +#include + +/**\class OperaPlugin_Plugin + * \ingroup Plugins + * \brief The main class managing Primitive Features as plugins. + */ +class OPERAPLUGIN_EXPORT OperaPlugin_Plugin : public ModelAPI_Plugin +{ + public: + /// Creates the feature object of this plugin by the feature string ID + virtual FeaturePtr createFeature(std::string theFeatureID); + + public: + /// Default constructor + OperaPlugin_Plugin(); + +}; + +#endif diff --git a/src/OperaPlugin/OperaPlugin_Volume.cpp b/src/OperaPlugin/OperaPlugin_Volume.cpp new file mode 100644 index 000000000..5ef8b4bbb --- /dev/null +++ b/src/OperaPlugin/OperaPlugin_Volume.cpp @@ -0,0 +1,90 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include +#include +#include +#include +#include +#include + +#include + + +#include +#include + + +#include +#include + +//================================================================================================= +OperaPlugin_Volume::OperaPlugin_Volume() // Nothing to do during instantiation +{ +} + +//================================================================================================= +void OperaPlugin_Volume::initAttributes() +{ + data()->addAttribute(OperaPlugin_Volume::MEDIUM(), ModelAPI_AttributeString::typeId()); + + // AttributeSelectionListPtr aList = + // std::dynamic_pointer_cast(data()->addAttribute( + // OperaPlugin_Volume::LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); + + AttributeSelectionListPtr aList = std::dynamic_pointer_cast( + data()->addAttribute(OperaPlugin_Volume::LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); + aList->setWholeResultAllowed(true); // allow to select the whole result + +} + +#include +//================================================================================================= +void OperaPlugin_Volume::execute() +{ + // Getting objects. + std::cout << "Before" << std::endl; + + std::cout << "EXECUTE" << std::endl; + + std::cout << "After" << std::endl; +} + +//================================================================================================= +void OperaPlugin_Volume::loadNamingDS(std::shared_ptr theBoxAlgo, + std::shared_ptr theResultBox) +{ + // Load the result + theResultBox->store(theBoxAlgo->shape()); + + // Prepare the naming + theBoxAlgo->prepareNamingFaces(); + + // Insert to faces + std::map< std::string, std::shared_ptr > listOfFaces = + theBoxAlgo->getCreatedFaces(); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultBox->generated((*it).second, (*it).first); + } +} diff --git a/src/OperaPlugin/OperaPlugin_Volume.h b/src/OperaPlugin/OperaPlugin_Volume.h new file mode 100644 index 000000000..1769684d1 --- /dev/null +++ b/src/OperaPlugin/OperaPlugin_Volume.h @@ -0,0 +1,82 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef OperaPlugin_Volume_H_ +#define OperaPlugin_Volume_H_ + +#include +#include +#include + +class GeomAPI_Shape; +class ModelAPI_ResultBody; + +/**\class OperaPlugin_Volume + * \ingroup Plugins + * \brief Feature for creation of a box primitive using various methods. + * + * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via three + * methods : using two points that define a diagonal, a point that define a center and 3 lengths + * that define the half-lengths on X, Y and Z-axes, or using 3 lengths that define the + * rectangular dimensions. + */ +class OperaPlugin_Volume : public ModelAPI_Feature +{ + public: + /// Box kind + inline static const std::string& ID() + { + static const std::string MY_VOLUME_ID("addVolume"); + return MY_VOLUME_ID; + } + inline static const std::string& MEDIUM() + { + static const std::string MY_MEDIUM_ID("medium"); + return MY_MEDIUM_ID; + } + /// attribute name of selected entities list + inline static const std::string& LIST_ID() + { + static const std::string MY_VOLUME_LIST_ID("volume_list"); + return MY_VOLUME_LIST_ID; + } + + // Creates a new part document if needed + OPERAPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + OPERAPLUGIN_EXPORT virtual void initAttributes(); + + /// Returns the kind of a feature + OPERAPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = OperaPlugin_Volume::ID(); + return MY_KIND; + } + + /// Use plugin manager for features creation + OperaPlugin_Volume(); + + private: + // + void loadNamingDS(std::shared_ptr theBoxAlgo, + std::shared_ptr theResultBox); +}; + +#endif diff --git a/src/OperaPlugin/OperaPlugin_msg_fr.ts b/src/OperaPlugin/OperaPlugin_msg_fr.ts new file mode 100644 index 000000000..22d0de57f --- /dev/null +++ b/src/OperaPlugin/OperaPlugin_msg_fr.ts @@ -0,0 +1,408 @@ + + + + + + workshop + + Primitives + Primitives + + + Box + Boîte + + + Cone + Cône + + + Cylinder + Cylindre + + + Sphere + Sphère + + + Torus + Tore + + + + + Box + + Box + Boîte + + + Create a box + Créer une boîte + + + + Box:CreationMethod + + By dimensions + Par dimensions + + + By two points + Par deux points + + + + Box:FirstPoint + + First point + Premier point + + + Select a first point + Sélectionnez un premier point + + + + Box:FirstPoint + + Attribute "%1" is not initialized. + Sélectionnez un premier point. + + + + Box:SecondPoint + + Attribute "%1" is not initialized. + Sélectionnez un deuxième point. + + + + Box:SecondPoint + + Second point + Deuxième point + + + Select a second point + Sélectionnez un deuxième point + + + + Box:dx + + DX + DX + + + Dimension in X + Dimension en X + + + + Box:dy + + DY + DY + + + Dimension in Y + Dimension en Y + + + + Box:dz + + DZ + DZ + + + Dimension in Z + Dimension en Z + + + + + Cone + + Cone + Cône + + + Create a Cone + Créer un cône + + + + Cone:axis + + Select the axis of the cone + Sélectionnez l'axe du cône + + + Attribute "%1" is not initialized. + Sélectionnez l'axe du cône + + + axis + axe + + + + Cone:base_point + + Select the center of the base of the cone + Sélectionnez le centre de la base du cône + + + base_point + point de base + + + + Cone:base_radius + + Base radius + Rayon de la base + + + Enter the base radius of the cone + Entrez le rayon de base du cône + + + + Cone:height + + Enter the height of the cone + Entrez la hauteur du cône + + + height + hauteur + + + + Cone:top_radius + + Enter the top radius of the cone + Entrez le rayon supérieur du cône + + + Top radius + Rayon supérieur + + + + Cone:base_point + + Attribute "%1" is not initialized. + Sélectionnez le centre de la base du cône. + + + + Cone:base_point:GeomValidators_ConstructionComposite + + The result is empty + Le résultat est vide + + + + + Cylinder + + Create a cylinder + Créer un cylindre + + + Cylinder + Cylindre + + + + Cylinder:CreationMethod + + Cylinder + Cylindre + + + Portion of cylinder + Portion de cylindre + + + + Cylinder:angle + + Enter the angle of the portion of the cylinder + Entrez l'angle de la portion du cylindre + + + angle + angle + + + + Cylinder:axis + + Select the axis of the cylinder + Sélectionnez l'axe du cylindre. + + + Attribute "%1" is not initialized. + Sélectionnez l'axe du cylindre. + + + axis + axe + + + + Cylinder:base_point + + Select the center of the base of the cylinder + Sélectionnez le centre de la base du cylindre + + + base_point + point de base + + + + Cylinder:height + + Enter the height of the cylinder + Entrez la hauteur du cylindre + + + height + hauteur + + + + Cylinder:radius + + Enter the radius of the cylinder + Entrez le rayon du cylindre + + + radius + rayon + + + + Cylinder:base_point + + Attribute "%1" is not initialized. + Sélectionnez le centre de la base du cylindre. + + + + Cylinder:base_point:GeomValidators_ConstructionComposite + + The result is empty + Le résultat est vide + + + + + Sphere + + Create a sphere + Créer une sphère + + + Sphere + Sphère + + + + Sphere:center_point + + Center point + Point central + + + Select a center point + Sélectionnez un point central. + + + Attribute "%1" is not initialized. + Sélectionnez un point central. + + + + Sphere:radius + + Enter a radius + Entrez un rayon + + + Radius + Rayon + + + + + Torus + + Create a Torus + Créer un tore + + + Torus + Tore + + + + Torus:axis + + Select the axis of the torus + Sélectionnez l'axe du tore. + + + Attribute "%1" is not initialized. + Sélectionnez l'axe du tore. + + + axis + axe + + + + Torus:base_point + + Select the center of the torus + Sélectionnez le centre du tore. + + + Attribute "%1" is not initialized. + Sélectionnez le centre du tore. + + + base_point + point de base + + + + Torus:radius + + Enter the radius of the torus + Entrez le rayon du tore + + + Radius + Rayon + + + + Torus:ring_radius + + Enter the ring radius of the torus + Entrez le rayon de l'anneau du tore + + + Ring radius + Rayon de l'anneau + + + + diff --git a/src/OperaPlugin/addvolume_widget.xml b/src/OperaPlugin/addvolume_widget.xml new file mode 100644 index 000000000..3f90ef6e8 --- /dev/null +++ b/src/OperaPlugin/addvolume_widget.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/src/OperaPlugin/doc/addvolumeFeature.rst b/src/OperaPlugin/doc/addvolumeFeature.rst new file mode 100644 index 000000000..e91466c20 --- /dev/null +++ b/src/OperaPlugin/doc/addvolumeFeature.rst @@ -0,0 +1,136 @@ +.. |Box_button.icon| image:: images/Box_button.png + +Box +=== + +Box feature creates a box solid. + +To create a Box in the active part: + +#. select in the Main Menu *Primitives - > Box* item or +#. click |Box_button.icon| **Box** button in the toolbar: + +There are 3 algorithms for creation of a Box: + +.. figure:: images/box_dxyz_32x32.png + :align: left + :height: 24px + +**By dimensions** + +.. figure:: images/box_2pt_32x32.png + :align: left + :height: 24px + +**By two points** + +.. figure:: images/box_pt_dxyz_32x32.png + :align: left + :height: 24px + +**By coordinates of a point and dimensions** + +-------------------------------------------------------------------------------- + +By dimensions +------------- + +Box is created by dimensions along X, Y, Z axis starting from the origin. + +.. figure:: images/Box_dimensions.png + :align: center + +Input fields: + +- **DX**, **DY**, **DZ** define dimensions of the box along the corresponding coordinate axes. + +**TUI Command**: + +.. py:function:: model.addBox(Part_doc, DX, DY, DZ) + + :param part: The current part object. + :param real: Size along X. + :param real: Size along Y. + :param real: Size along Z. + :return: Result object. + +Result +"""""" + +A solid box based on the origin of coordinates and with edges parallel to the coordinate axes. + +.. figure:: images/Box1.png + :align: center + +**See Also** a sample TUI Script of a :ref:`tui_create_boxdim` operation. + +By two points +------------- + +Box is created by two points of the box diagonal. + +.. figure:: images/Box_2points.png + :align: center + +Input fields: + +- **Point 1** and **Point 2** define diagonal points of the box selected in 3D OCC viewer or object browser. + +**TUI Command**: + +.. py:function:: model.addBox(Part_doc, point1, point2) + + :param part: The current part object. + :param object: First vertex of diagonal. + :param object: Second vertex of diagonal. + :return: Result object. + +Result +"""""" + +A solid box based on two points and with edges parallel to the coordinate axes. + +.. figure:: images/Box2.png + :align: center + + Created boxes + +**See Also** a sample TUI Script of :ref:`tui_create_boxpnt` operation. + +By coordinates of a point and dimensions +---------------------------------------- + +Box is created by dimensions along X, Y, Z axis starting from the point of coordinates (x,y,z). + +.. figure:: images/Box_ptAndDims.png + :align: center + +Input fields: + +- **OX**, **OY**, **OZ** define coordinates of the center of box. +- **DX**, **DY**, **DZ** define dimensions (hafl length) of the box along the corresponding coordinate axes. + +**TUI Command**: + +.. py:function:: model.addBox(Part_doc, OX, OY, OZ, DX, DY, DZ) + + :param part: The current part object. + :param real: X coordinate of the center point + :param real: Y coordinate of the center point + :param real: Z coordinate of the center point + :param real: Half size along X. + :param real: Half size along Y. + :param real: Half size along Z. + :return: Result object. + +Result +"""""" + +A solid box whose point coordinates are the center and the dimensions are half lengths on one side and the other on the axes relative to the center. + +.. figure:: images/Box3.png + :align: center + + Created boxes + +**See Also** a sample TUI Script of :ref:`tui_create_boxptdim` operation. diff --git a/src/OperaPlugin/icons/addVolume.png b/src/OperaPlugin/icons/addVolume.png new file mode 100644 index 000000000..2b0757b05 Binary files /dev/null and b/src/OperaPlugin/icons/addVolume.png differ diff --git a/src/OperaPlugin/plugin-Opera.xml b/src/OperaPlugin/plugin-Opera.xml new file mode 100644 index 000000000..97914e06a --- /dev/null +++ b/src/OperaPlugin/plugin-Opera.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp index 906cd11f7..feea6763d 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp @@ -203,7 +203,6 @@ void PrimitivesPlugin_Box::createBoxByOnePointAndDims() ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); loadNamingDS(aBoxAlgo, aResultBox); setResult(aResultBox, aResultIndex); - setVolume(aResultBox, aResultIndex); } //=================================================================================================