]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
WIP addNode IHM nrn/Opera/addVolume
authorNicolas RECHATIN <nicolas.rechatin@cea.fr>
Thu, 5 Aug 2021 10:26:08 +0000 (12:26 +0200)
committerNicolas RECHATIN <nicolas.rechatin@cea.fr>
Thu, 5 Aug 2021 10:26:08 +0000 (12:26 +0200)
src/OperaPlugin/CMakeLists.txt
src/OperaPlugin/OperaPlugin_Node.cpp [new file with mode: 0644]
src/OperaPlugin/OperaPlugin_Node.h [new file with mode: 0644]
src/OperaPlugin/OperaPlugin_Plugin.cpp
src/OperaPlugin/icons/Node.png [new file with mode: 0644]
src/OperaPlugin/node_widget.xml [new file with mode: 0644]
src/OperaPlugin/plugin-Opera.xml

index a1f7fd6002df40552a1e1df478d468f9b99bc432..d4698815f7b1a3404c9033dd1be3a13fda0e7d66 100644 (file)
@@ -21,17 +21,19 @@ SET(PROJECT_HEADERS
     OperaPlugin.h
     OperaPlugin_Plugin.h
     OperaPlugin_Volume.h
+    OperaPlugin_Node.h
 )
 
 SET(PROJECT_SOURCES
     OperaPlugin_Plugin.cpp
     OperaPlugin_Volume.cpp
-
+    OperaPlugin_Node.cpp
 )
 
 SET(XML_RESOURCES
   plugin-Opera.xml
   volume_widget.xml
+  node_widget.xml
 )
 
 SET(TEXT_RESOURCES
diff --git a/src/OperaPlugin/OperaPlugin_Node.cpp b/src/OperaPlugin/OperaPlugin_Node.cpp
new file mode 100644 (file)
index 0000000..dc64085
--- /dev/null
@@ -0,0 +1,52 @@
+// 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 <OperaPlugin_Node.h>
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Tools.h>
+
+#include <sstream>
+#include <memory>
+
+//=================================================================================================
+OperaPlugin_Node::OperaPlugin_Node() // Nothing to do during instantiation
+{
+}
+
+//=================================================================================================
+void OperaPlugin_Node::initAttributes()
+{
+  // Get main object
+  data()->addAttribute(MAIN_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+
+  // Get tools object
+  data()->addAttribute(TOOLS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+#include <iostream>
+//=================================================================================================
+void OperaPlugin_Node::execute()
+{
+  AttributeSelectionPtr anObject = selection(MAIN_OBJECT_ID());
+  AttributeSelectionListPtr aList = selectionList(TOOLS_LIST_ID());
+}
diff --git a/src/OperaPlugin/OperaPlugin_Node.h b/src/OperaPlugin/OperaPlugin_Node.h
new file mode 100644 (file)
index 0000000..fb561ea
--- /dev/null
@@ -0,0 +1,72 @@
+// 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_Node_H_
+#define OperaPlugin_Node_H_
+
+#include <OperaPlugin.h>
+#include <ModelAPI_Feature.h>
+
+/**\class OperaPlugin_Node
+ * \ingroup Plugins
+ * \brief Feature for creation of a Node using solids.
+ *
+ * Node creates Node object - This Node takes selected solids shape
+ * and transform the result to a Node with a medium for OPERA.
+ */
+class OperaPlugin_Node : public ModelAPI_Feature
+{
+  public:
+    /// Node kind
+    inline static const std::string& ID()
+    {
+      static const std::string MY_NODE_ID("Node");
+      return MY_NODE_ID;
+    }
+    /// Attribute name of main object.
+    inline static const std::string& MAIN_OBJECT_ID()
+    {
+      static const std::string MY_MAIN_OBJECT_ID("main_object");
+      return MY_MAIN_OBJECT_ID;
+    }
+    /// Attribute name of selected tools list
+    inline static const std::string& TOOLS_LIST_ID()
+    {
+      static const std::string MY_TOOLS_LIST_ID("tools_list");
+      return MY_TOOLS_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_Node::ID();
+      return MY_KIND;
+    }
+
+    /// Use plugin manager for features creation
+    OperaPlugin_Node();
+};
+
+#endif
index 894925751c8bcf529ff952bc4bfb5bcde0ddcd9b..3c8085982bb78307c3a7c85999fe9f7c349e7662 100644 (file)
 
 #include <OperaPlugin_Plugin.h>
 #include <OperaPlugin_Volume.h>
+#include <OperaPlugin_Node.h>
 
 #include <ModelAPI_Session.h>
 
-#include <string>
-
 // the only created instance of this plugin
 static OperaPlugin_Plugin* MY_PRIMITIVES_INSTANCE = new OperaPlugin_Plugin();
 
@@ -37,6 +36,8 @@ FeaturePtr OperaPlugin_Plugin::createFeature(std::string theFeatureID)
 {
   if (theFeatureID == OperaPlugin_Volume::ID()) {
     return FeaturePtr(new OperaPlugin_Volume);
+  } else if (theFeatureID == OperaPlugin_Node::ID()) {
+    return FeaturePtr(new OperaPlugin_Node);
   } else {
     return FeaturePtr();
   }
diff --git a/src/OperaPlugin/icons/Node.png b/src/OperaPlugin/icons/Node.png
new file mode 100644 (file)
index 0000000..457dc0f
Binary files /dev/null and b/src/OperaPlugin/icons/Node.png differ
diff --git a/src/OperaPlugin/node_widget.xml b/src/OperaPlugin/node_widget.xml
new file mode 100644 (file)
index 0000000..ab9fc84
--- /dev/null
@@ -0,0 +1,16 @@
+<source>
+  <shape_selector id="main_object"
+                  label="Main object"
+                  tooltip="Select a main object"
+                  shape_types="solids">
+    <validator id="GeomValidators_ShapeType" parameters="solid"/>
+  </shape_selector>
+  <multi_selector id="tools_list"
+                  label="Tools object"
+                  tooltip="Select solid objects"
+                  shape_types="solids"
+                  concealment="true">
+    <validator id="PartSet_DifferentObjects"/>
+    <validator id="GeomValidators_ShapeType" parameters="solid"/>
+  </multi_selector>
+</source>
index f16bf394b0218e0cfd07a44f8b4324de15645942..180653905472d9c8b4330bc12b565ca4f93480b4 100644 (file)
@@ -9,6 +9,14 @@
                helpfile="volumeFeature.html">
         <source path="volume_widget.xml"/>
       </feature>
+      <feature id="Node"
+               title="Node"
+               tooltip="Perform OPERA Add Node"
+               icon="icons/Opera/Node.png"
+               auto_preview="true"
+               helpfile="nodeFeature.html">
+        <source path="node_widget.xml"/>
+      </feature>
     </group>
   </workbench>
 </plugin>