From eab9279a71a6574d01240930bdc31d6d8597e150 Mon Sep 17 00:00:00 2001 From: Nicolas RECHATIN Date: Tue, 3 Oct 2023 16:00:28 +0200 Subject: [PATCH] feat : Add getMediumList in OperaAPI_Tools --- src/OperaAPI/CMakeLists.txt | 2 ++ src/OperaAPI/OperaAPI.i | 2 ++ src/OperaAPI/OperaAPI_Tools.cpp | 35 +++++++++++++++++++++++++ src/OperaAPI/OperaAPI_Tools.h | 45 +++++++++++++++++++++++++++++++++ src/OperaAPI/OperaAPI_swig.h | 1 + 5 files changed, 85 insertions(+) create mode 100644 src/OperaAPI/OperaAPI_Tools.cpp create mode 100644 src/OperaAPI/OperaAPI_Tools.h diff --git a/src/OperaAPI/CMakeLists.txt b/src/OperaAPI/CMakeLists.txt index 192634bd9..05da53cdc 100644 --- a/src/OperaAPI/CMakeLists.txt +++ b/src/OperaAPI/CMakeLists.txt @@ -23,11 +23,13 @@ SET(PROJECT_HEADERS OperaAPI.h OperaAPI_Volume.h OperaAPI_AddNode.h + OperaAPI_Tools.h ) SET(PROJECT_SOURCES OperaAPI_Volume.cpp OperaAPI_AddNode.cpp + OperaAPI_Tools.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/OperaAPI/OperaAPI.i b/src/OperaAPI/OperaAPI.i index 57223e944..6268a8b51 100644 --- a/src/OperaAPI/OperaAPI.i +++ b/src/OperaAPI/OperaAPI.i @@ -40,7 +40,9 @@ // shared pointers %shared_ptr(OperaAPI_Volume) %shared_ptr(OperaAPI_AddNode) +%shared_ptr(OperaAPI_Tools) // all supported interfaces %include "OperaAPI_Volume.h" %include "OperaAPI_AddNode.h" +%include "OperaAPI_Tools.h" diff --git a/src/OperaAPI/OperaAPI_Tools.cpp b/src/OperaAPI/OperaAPI_Tools.cpp new file mode 100644 index 000000000..2cec12913 --- /dev/null +++ b/src/OperaAPI/OperaAPI_Tools.cpp @@ -0,0 +1,35 @@ +// 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 "OperaAPI_Tools.h" + +//================================================================================================= +static std::list OperaAPI_Tools::getMediumList() +{ + SessionPtr aSession = ModelAPI_Session::get(); + DocumentPtr aDocument = aSession->activeDocument(); + std::list aFeatures = aDocument->allFeatures(); + + std::list aMediumList; + std::list::iterator itFeature = aFeatures.begin(); + for (; itFeature != aFeatures.end(); ++itFeature) + if ((*itFeature)->getKind() == "Volume") + aMediumList.push_back((*itFeature)->data()->string(OperaPlugin_Volume::MEDIUM_ID())->value()); + + return aMediumList; +} diff --git a/src/OperaAPI/OperaAPI_Tools.h b/src/OperaAPI/OperaAPI_Tools.h new file mode 100644 index 000000000..a221a3e53 --- /dev/null +++ b/src/OperaAPI/OperaAPI_Tools.h @@ -0,0 +1,45 @@ +// 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 OPERAAPI_TOOLS_H_ +#define OPERAAPI_TOOLS_H_ + +#include "OperaAPI.h" + +#include + +#include "ModelAPI_Session.h" +#include +#include + +class ModelHighAPI_Double; +class ModelHighAPI_Selection; + +/// \class OperaAPI_Tools +/// \ingroup CPPHighAPI +/// \brief Interface for AddNode feature. +class OperaAPI_Tools : public ModelHighAPI_Interface +{ +public: + /// Get medium list + OPERAAPI_EXPORT + static std::list getMediumList(); +}; + +#endif // OPERAAPI_TOOLS_H_ diff --git a/src/OperaAPI/OperaAPI_swig.h b/src/OperaAPI/OperaAPI_swig.h index 661e51618..f1cc3497e 100644 --- a/src/OperaAPI/OperaAPI_swig.h +++ b/src/OperaAPI/OperaAPI_swig.h @@ -25,5 +25,6 @@ #include "OperaAPI.h" #include "OperaAPI_Volume.h" #include "OperaAPI_AddNode.h" + #include "OperaAPI_Tools.h" #endif // OPERAAPI_SWIG_H_ -- 2.39.2