From: Artem Zhidkov Date: Mon, 16 Aug 2021 14:42:39 +0000 (+0300) Subject: Refactoring of the Bounding Box feature (change names of classes to be more evident) X-Git-Tag: V9_8_0a1~26^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1d8e244d3e75b9a09954594e1ce8332ddff3e662;p=modules%2Fshaper.git Refactoring of the Bounding Box feature (change names of classes to be more evident) --- diff --git a/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp b/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp index 123a0a4a2..ff60f54f3 100644 --- a/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp @@ -19,7 +19,7 @@ #include "FeaturesAPI_BoundingBox.h" -#include +#include #include #include #include @@ -60,7 +60,7 @@ void FeaturesAPI_BoundingBox::dump(ModelHighAPI_Dumper& theDumper) const const std::string& aDocName = theDumper.name(aBase->document()); AttributeSelectionPtr anAttrObject; - anAttrObject = aBase->selection(FeaturesPlugin_CreateBoundingBox::OBJECT_ID()); + anAttrObject = aBase->selection(FeaturesPlugin_BoundingBox::OBJECT_ID()); theDumper << aBase << " = model.getBoundingBox(" << aDocName << ", " << anAttrObject; @@ -73,7 +73,7 @@ BoundingBoxPtr getBoundingBox(const std::shared_ptr& thePart, { FeaturePtr aFeature = - thePart->addFeature(FeaturesPlugin_CreateBoundingBox::ID()); + thePart->addFeature(FeaturesPlugin_BoundingBox::ID()); BoundingBoxPtr aBoundingBox; diff --git a/src/FeaturesAPI/FeaturesAPI_BoundingBox.h b/src/FeaturesAPI/FeaturesAPI_BoundingBox.h index 959d0d41c..488563dcd 100644 --- a/src/FeaturesAPI/FeaturesAPI_BoundingBox.h +++ b/src/FeaturesAPI/FeaturesAPI_BoundingBox.h @@ -22,7 +22,7 @@ #include "FeaturesAPI.h" -#include "FeaturesPlugin_CreateBoundingBox.h" +#include "FeaturesPlugin_BoundingBox.h" #include #include @@ -50,8 +50,8 @@ public: FEATURESAPI_EXPORT virtual ~FeaturesAPI_BoundingBox(); - INTERFACE_1(FeaturesPlugin_CreateBoundingBox::ID(), - objectSelected, FeaturesPlugin_CreateBoundingBox::OBJECT_ID(), + INTERFACE_1(FeaturesPlugin_BoundingBox::ID(), + objectSelected, FeaturesPlugin_BoundingBox::OBJECT_ID(), ModelAPI_AttributeSelection, /** object selected*/) /// Dump wrapped feature diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 4d52c6119..91dee176f 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -70,8 +70,8 @@ SET(PROJECT_HEADERS FeaturesPlugin_PointCoordinates.h FeaturesPlugin_GeometryCalculation.h FeaturesPlugin_BoundingBox.h - FeaturesPlugin_CommonBoundingBox.h - FeaturesPlugin_CreateBoundingBox.h + FeaturesPlugin_BoundingBoxBase.h + FeaturesPlugin_InspectBoundingBox.h ) SET(PROJECT_SOURCES @@ -122,8 +122,8 @@ SET(PROJECT_SOURCES FeaturesPlugin_PointCoordinates.cpp FeaturesPlugin_GeometryCalculation.cpp FeaturesPlugin_BoundingBox.cpp - FeaturesPlugin_CommonBoundingBox.cpp - FeaturesPlugin_CreateBoundingBox.cpp + FeaturesPlugin_BoundingBoxBase.cpp + FeaturesPlugin_InspectBoundingBox.cpp ) SET(XML_RESOURCES diff --git a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp index f2867fec9..158f9013d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp @@ -19,20 +19,20 @@ #include "FeaturesPlugin_BoundingBox.h" -#include - -#include - -#include - #include #include -#include #include +#include + #include #include #include +#include + +#include +#include + #include #include @@ -54,7 +54,7 @@ void FeaturesPlugin_BoundingBox::initAttributes() data()->addAttribute(X_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(Y_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(Z_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(CREATEBOX_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COORD_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COORD_ID()); @@ -62,13 +62,12 @@ void FeaturesPlugin_BoundingBox::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COORD_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COORD_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATEBOX_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), RESULT_VALUES_ID()); - + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_ID()); data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId()); data()->realArray(RESULT_VALUES_ID())->setSize(6); - + data()->boolean(COMPUTE_ID())->setValue(true); } //================================================================================================= @@ -78,44 +77,21 @@ void FeaturesPlugin_BoundingBox::execute() return; createBoxByTwoPoints(); - - if (boolean(CREATEBOX_ID())->value()) { - if (!myCreateFeature.get()) - createBox(); - updateBox(); - } else { - if (myCreateFeature.get()) { - myCreateFeature->eraseResults(); - SessionPtr aSession = ModelAPI_Session::get(); - DocumentPtr aDoc = aSession->activeDocument(); - aDoc->removeFeature(myCreateFeature); - myCreateFeature.reset(); - } - } -} - -//================================================================================================= -void FeaturesPlugin_BoundingBox::attributeChanged(const std::string& theID) -{ - if (theID == OBJECT_ID()) { - if (myCreateFeature.get()) - updateBox(); - } } //================================================================================================= -AttributePtr FeaturesPlugin_BoundingBox::attributResultValues() +void FeaturesPlugin_BoundingBox::attributeChanged(const std::string&) { - return attribute(RESULT_VALUES_ID()); } //================================================================================================= bool FeaturesPlugin_BoundingBox::updateValues() { AttributeSelectionPtr aSelection = selection(OBJECT_ID()); - if (aSelection->isInitialized()) { - AttributeDoubleArrayPtr aValues = + AttributeDoubleArrayPtr aValues = std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); + + if (aSelection->isInitialized()) { std::stringstream streamxmin; std::stringstream streamymin; std::stringstream streamzmin; @@ -130,6 +106,12 @@ bool FeaturesPlugin_BoundingBox::updateValues() aShape = aSelection->context()->shape(); } + AttributeBooleanPtr anIsCompute = boolean(COMPUTE_ID()); + if (!anIsCompute->value()) { + myShape = aShape; + anIsCompute->setValue(true); + } + if (aShape && !aShape->isEqual(myShape)) { double aXmin, aXmax, aYmin, aYmax, aZmin, aZmax; std::string anError; @@ -141,7 +123,6 @@ bool FeaturesPlugin_BoundingBox::updateValues() setError("Error in bounding box calculation :" + anError); return false; } - myShape = aShape; streamxmin << std::setprecision(14) << aXmin; aValues->setValue(0, aXmin); @@ -155,45 +136,27 @@ bool FeaturesPlugin_BoundingBox::updateValues() aValues->setValue(4, aZmin); streamzmax << std::setprecision(14) << aZmax; aValues->setValue(5, aZmax); - string(X_MIN_COORD_ID() )->setValue( "X = " + streamxmin.str() ); - string(Y_MIN_COORD_ID() )->setValue( "Y = " + streamymin.str() ); - string(Z_MIN_COORD_ID() )->setValue( "Z = " + streamzmin.str() ); - string(X_MAX_COORD_ID() )->setValue( "X = " + streamxmax.str() ); - string(Y_MAX_COORD_ID() )->setValue( "Y = " + streamymax.str() ); - string(Z_MAX_COORD_ID() )->setValue( "Z = " + streamzmax.str() ); + } else { + streamxmin << std::setprecision(14) << aValues->value(0); + streamxmax << std::setprecision(14) << aValues->value(1); + streamymin << std::setprecision(14) << aValues->value(2); + streamymax << std::setprecision(14) << aValues->value(3); + streamzmin << std::setprecision(14) << aValues->value(4); + streamzmax << std::setprecision(14) << aValues->value(5); } - } - return true; -} - -//================================================================================================= -void FeaturesPlugin_BoundingBox::createBox() -{ - SessionPtr aSession = ModelAPI_Session::get(); - - DocumentPtr aDoc = aSession->activeDocument(); - if (aDoc.get()) { - myCreateFeature = aDoc->addFeature(FeaturesPlugin_CreateBoundingBox::ID()); + string(X_MIN_COORD_ID() )->setValue( "X = " + streamxmin.str() ); + string(Y_MIN_COORD_ID() )->setValue( "Y = " + streamymin.str() ); + string(Z_MIN_COORD_ID() )->setValue( "Z = " + streamzmin.str() ); + string(X_MAX_COORD_ID() )->setValue( "X = " + streamxmax.str() ); + string(Y_MAX_COORD_ID() )->setValue( "Y = " + streamymax.str() ); + string(Z_MAX_COORD_ID() )->setValue( "Z = " + streamzmax.str() ); } + return true; } //================================================================================================= -void FeaturesPlugin_BoundingBox::updateBox() +AttributePtr FeaturesPlugin_BoundingBox::attributResultValues() { - myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(false); - myCreateFeature->selection(FeaturesPlugin_CreateBoundingBox::OBJECT_ID()) - ->setValue(selection(OBJECT_ID())->context(), - selection(OBJECT_ID())->value()); - - AttributeDoubleArrayPtr aValuesFeatures = - std::dynamic_pointer_cast - (myCreateFeature->attribute(RESULT_VALUES_ID())); - AttributeDoubleArrayPtr aValues = - std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); - for (int anI=0; anI < 6; anI++) - aValuesFeatures->setValue(anI,aValues->value(anI)); - - myCreateFeature->execute(); - myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(true); + return attribute(RESULT_VALUES_ID()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h index 9238942c4..0f8f14dce 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h @@ -20,19 +20,19 @@ #ifndef FeaturesPlugin_BoundingBox_H_ #define FeaturesPlugin_BoundingBox_H_ -#include +#include /// \class FeaturesPlugin_BoundingBox /// \ingroup Plugins -/// \brief Feature to view the Bounding Box. +/// \brief Persistence feature to create the bounding box. -class FeaturesPlugin_BoundingBox : public FeaturesPlugin_CommonBoundingBox +class FeaturesPlugin_BoundingBox : public FeaturesPlugin_BoundingBoxBase { public: - /// Bounding box macro kind. + /// Bounding box kind. inline static const std::string& ID() { - static const std::string MY_ID("BoundingBoxMacro"); + static const std::string MY_ID("BoundingBox"); return MY_ID; } @@ -85,13 +85,6 @@ public: return MY_Z_MAX_COORD_ID; } - /// Attribute name for checkbox create box. - inline static const std::string& CREATEBOX_ID() - { - static const std::string MY_CREATEBOX_ID("createbox"); - return MY_CREATEBOX_ID; - } - /// Attribute name for values of result. inline static const std::string& RESULT_VALUES_ID() { @@ -99,6 +92,13 @@ public: return MY_RESULT_VALUES_ID; } + /// Attribute name for indicate to compute the bounding box. + inline static const std::string& COMPUTE_ID() + { + static const std::string MY_COMPUTE_ID("compute"); + return MY_COMPUTE_ID; + } + /// \return the kind of a feature. virtual const std::string& getKind() { @@ -115,25 +115,15 @@ public: /// \param theID identifier of changed attribute FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); - /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true. - FEATURESPLUGIN_EXPORT virtual bool isMacro() const { return true; } + /// Return Attribut values of result. + FEATURESPLUGIN_EXPORT virtual AttributePtr attributResultValues(); /// Use plugin manager for features creation FeaturesPlugin_BoundingBox(); private: - /// Return Attribut values of result. - virtual AttributePtr attributResultValues(); - /// Update values displayed. bool updateValues(); - /// Create Box - void createBox(); - /// Update Box - void updateBox(); - - /// Feature to create box - FeaturePtr myCreateFeature; }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_BoundingBoxBase.cpp b/src/FeaturesPlugin/FeaturesPlugin_BoundingBoxBase.cpp new file mode 100644 index 000000000..7da95c85d --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BoundingBoxBase.cpp @@ -0,0 +1,115 @@ +// Copyright (C) 2018-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 "FeaturesPlugin_BoundingBoxBase.h" + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + + + +//================================================================================================= +void FeaturesPlugin_BoundingBoxBase::createBoxByTwoPoints() +{ + AttributeDoubleArrayPtr aValues = + std::dynamic_pointer_cast(attributResultValues()); + + SessionPtr aSession = ModelAPI_Session::get(); + + DocumentPtr aDoc = aSession->activeDocument(); + + GeomVertexPtr vertexFirst = + GeomAlgoAPI_PointBuilder::vertex(aValues->value(0), + aValues->value(2), + aValues->value(4)); + + GeomVertexPtr vertexSecond = + GeomAlgoAPI_PointBuilder::vertex(aValues->value(1), + aValues->value(3), + aValues->value(5)); + + + std::shared_ptr aBoxAlgo; + + + aBoxAlgo = std::shared_ptr( + new GeomAlgoAPI_Box(vertexFirst->point(),vertexSecond->point())); + + + // These checks should be made to the GUI for the feature but + // the corresponding validator does not exist yet. + if (!aBoxAlgo->check()) { + setError(aBoxAlgo->getError()); + return; + } + + // Build the box + aBoxAlgo->build(); + + // Check if the creation of the box + if (!aBoxAlgo->isDone()) { + // The error is not displayed in a popup window. It must be in the message console. + setError(aBoxAlgo->getError()); + return; + } + if (!aBoxAlgo->checkValid("Box builder with two points")) { + // The error is not displayed in a popup window. It must be in the message console. + setError(aBoxAlgo->getError()); + return; + } + + int aResultIndex = 0; + ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); + loadNamingDS(aBoxAlgo, aResultBox); + setResult(aResultBox, aResultIndex); +} + +//================================================================================================= +void FeaturesPlugin_BoundingBoxBase::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/FeaturesPlugin/FeaturesPlugin_BoundingBoxBase.h b/src/FeaturesPlugin/FeaturesPlugin_BoundingBoxBase.h new file mode 100644 index 000000000..862aae8c8 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BoundingBoxBase.h @@ -0,0 +1,59 @@ +// Copyright (C) 2018-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 FeaturesPlugin_BoundingBoxBase_H_ +#define FeaturesPlugin_BoundingBoxBase_H_ + +#include "FeaturesPlugin.h" +#include + +#include + +#include +#include + +#include + +/// \class FeaturesPlugin_BoundingBoxBase +/// \ingroup Plugins +/// \brief Base feature to inspect properties of bounding box +/// and create that box for the selected shape. +class FeaturesPlugin_BoundingBoxBase : public ModelAPI_Feature +{ +public: + /// Performs the algorithm and stores results it in the data structure. + FEATURESPLUGIN_EXPORT virtual void execute(){}; + + /// Return Attribut values of result. + virtual AttributePtr attributResultValues() = 0; + +protected: + FeaturesPlugin_BoundingBoxBase() {} + + /// Create box with two points + void createBoxByTwoPoints(); + + /// Create namming + void loadNamingDS(std::shared_ptr theBoxAlgo, + std::shared_ptr theResultBox); + + GeomShapePtr myShape; +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp deleted file mode 100644 index 531616ff2..000000000 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2018-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 "FeaturesPlugin_CommonBoundingBox.h" - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - - - -//================================================================================================= -void FeaturesPlugin_CommonBoundingBox::createBoxByTwoPoints() -{ - AttributeDoubleArrayPtr aValues = - std::dynamic_pointer_cast(attributResultValues()); - - SessionPtr aSession = ModelAPI_Session::get(); - - DocumentPtr aDoc = aSession->activeDocument(); - - GeomVertexPtr vertexFirst = - GeomAlgoAPI_PointBuilder::vertex(aValues->value(0), - aValues->value(2), - aValues->value(4)); - - GeomVertexPtr vertexSecond = - GeomAlgoAPI_PointBuilder::vertex(aValues->value(1), - aValues->value(3), - aValues->value(5)); - - - std::shared_ptr aBoxAlgo; - - - aBoxAlgo = std::shared_ptr( - new GeomAlgoAPI_Box(vertexFirst->point(),vertexSecond->point())); - - - // These checks should be made to the GUI for the feature but - // the corresponding validator does not exist yet. - if (!aBoxAlgo->check()) { - setError(aBoxAlgo->getError()); - return; - } - - // Build the box - aBoxAlgo->build(); - - // Check if the creation of the box - if (!aBoxAlgo->isDone()) { - // The error is not displayed in a popup window. It must be in the message console. - setError(aBoxAlgo->getError()); - return; - } - if (!aBoxAlgo->checkValid("Box builder with two points")) { - // The error is not displayed in a popup window. It must be in the message console. - setError(aBoxAlgo->getError()); - return; - } - - int aResultIndex = 0; - ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); - loadNamingDS(aBoxAlgo, aResultBox); - setResult(aResultBox, aResultIndex); -} - -//================================================================================================= -void FeaturesPlugin_CommonBoundingBox::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/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h deleted file mode 100644 index c461535d6..000000000 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2018-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 FeaturesPlugin_CommonBoundingBox_H_ -#define FeaturesPlugin_CommonBoundingBox_H_ - -#include "FeaturesPlugin.h" -#include - -#include - -#include -#include - -#include - -/// \class FeaturesPlugin_CommonBoundingBox -/// \ingroup Plugins -/// \brief Feature to view the Bounding Box. - -class FeaturesPlugin_CommonBoundingBox : public ModelAPI_Feature -{ -public: - /// Performs the algorithm and stores results it in the data structure. - FEATURESPLUGIN_EXPORT virtual void execute(){}; - - /// Return Attribut values of result. - virtual AttributePtr attributResultValues() = 0; - -protected: - FeaturesPlugin_CommonBoundingBox() {} - - /// Create box with two points - void createBoxByTwoPoints(); - - /// Create namming - void loadNamingDS(std::shared_ptr theBoxAlgo, - std::shared_ptr theResultBox); - - GeomShapePtr myShape; -}; - -#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp deleted file mode 100644 index c3c9bea53..000000000 --- a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (C) 2018-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 "FeaturesPlugin_CreateBoundingBox.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include - -//================================================================================================= -FeaturesPlugin_CreateBoundingBox::FeaturesPlugin_CreateBoundingBox() -{ -} - -//================================================================================================= -void FeaturesPlugin_CreateBoundingBox::initAttributes() -{ - // attribute for object selected - data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); - - // attributes for result message and values - data()->addAttribute(X_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(X_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId()); - - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MIN_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COORD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_ID()); - data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId()); - - data()->realArray(RESULT_VALUES_ID())->setSize(6); - data()->boolean(COMPUTE_ID())->setValue(true); -} - -//================================================================================================= -void FeaturesPlugin_CreateBoundingBox::execute() -{ - if (!updateValues()) - return; - - createBoxByTwoPoints(); -} - -//================================================================================================= -void FeaturesPlugin_CreateBoundingBox::attributeChanged(const std::string& theID) -{ -} - -//================================================================================================= -bool FeaturesPlugin_CreateBoundingBox::updateValues() -{ - AttributeSelectionPtr aSelection = selection(OBJECT_ID()); - AttributeDoubleArrayPtr aValues = - std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); - - if (aSelection->isInitialized()) { - std::stringstream streamxmin; - std::stringstream streamymin; - std::stringstream streamzmin; - std::stringstream streamxmax; - std::stringstream streamymax; - std::stringstream streamzmax; - - GeomShapePtr aShape; - if (aSelection && aSelection->isInitialized()) { - aShape = aSelection->value(); - if (!aShape && aSelection->context()) - aShape = aSelection->context()->shape(); - } - - AttributeBooleanPtr anIsCompute = boolean(COMPUTE_ID()); - if (!anIsCompute->value()) { - myShape = aShape; - anIsCompute->setValue(true); - } - - if (aShape && !aShape->isEqual(myShape)) { - double aXmin, aXmax, aYmin, aYmax, aZmin, aZmax; - std::string anError; - if (!GetBoundingBox(aShape, - aXmin, aXmax, - aYmin, aYmax, - aZmin, aZmax, - anError)) { - setError("Error in bounding box calculation :" + anError); - return false; - } - myShape = aShape; - streamxmin << std::setprecision(14) << aXmin; - aValues->setValue(0, aXmin); - streamxmax << std::setprecision(14) << aXmax; - aValues->setValue(1, aXmax); - streamymin << std::setprecision(14) << aYmin; - aValues->setValue(2, aYmin); - streamymax << std::setprecision(14) << aYmax; - aValues->setValue(3, aYmax); - streamzmin << std::setprecision(14) << aZmin; - aValues->setValue(4, aZmin); - streamzmax << std::setprecision(14) << aZmax; - aValues->setValue(5, aZmax); - } else { - streamxmin << std::setprecision(14) << aValues->value(0); - streamxmax << std::setprecision(14) << aValues->value(1); - streamymin << std::setprecision(14) << aValues->value(2); - streamymax << std::setprecision(14) << aValues->value(3); - streamzmin << std::setprecision(14) << aValues->value(4); - streamzmax << std::setprecision(14) << aValues->value(5); - } - - string(X_MIN_COORD_ID() )->setValue( "X = " + streamxmin.str() ); - string(Y_MIN_COORD_ID() )->setValue( "Y = " + streamymin.str() ); - string(Z_MIN_COORD_ID() )->setValue( "Z = " + streamzmin.str() ); - string(X_MAX_COORD_ID() )->setValue( "X = " + streamxmax.str() ); - string(Y_MAX_COORD_ID() )->setValue( "Y = " + streamymax.str() ); - string(Z_MAX_COORD_ID() )->setValue( "Z = " + streamzmax.str() ); - } - return true; -} - -//================================================================================================= -AttributePtr FeaturesPlugin_CreateBoundingBox::attributResultValues() -{ - return attribute(RESULT_VALUES_ID()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h deleted file mode 100644 index c7ead9044..000000000 --- a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2018-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 FeaturesPlugin_CreateBoundingBox_H_ -#define FeaturesPlugin_CreateBoundingBox_H_ - -#include - -/// \class FeaturesPlugin_BoundingBox -/// \ingroup Plugins -/// \brief Feature to view the Bounding Box. - -class FeaturesPlugin_CreateBoundingBox : public FeaturesPlugin_CommonBoundingBox -{ -public: - /// Bounding box kind. - inline static const std::string& ID() - { - static const std::string MY_ID("BoundingBox"); - return MY_ID; - } - - /// Attribute name for object selected. - inline static const std::string& OBJECT_ID() - { - static const std::string MY_OBJECT_ID("main_object"); - return MY_OBJECT_ID; - } - - /// Attribute name for x coodinate. - inline static const std::string& X_MIN_COORD_ID() - { - static const std::string MY_X_MIN_COORD_ID("xmincoordinate"); - return MY_X_MIN_COORD_ID; - } - - /// Attribute name for y coodinate. - inline static const std::string& Y_MIN_COORD_ID() - { - static const std::string MY_Y_MIN_COORD_ID("ymincoordinate"); - return MY_Y_MIN_COORD_ID; - } - - /// Attribute name for z coodinate. - inline static const std::string& Z_MIN_COORD_ID() - { - static const std::string MY_Z_MIN_COORD_ID("zmincoordinate"); - return MY_Z_MIN_COORD_ID; - } - - /// Attribute name for x max coodinate. - inline static const std::string& X_MAX_COORD_ID() - { - static const std::string MY_X_MAX_COORD_ID("xmaxcoordinate"); - return MY_X_MAX_COORD_ID; - } - - /// Attribute name for y max coodinate. - inline static const std::string& Y_MAX_COORD_ID() - { - static const std::string MY_Y_MAX_COORD_ID("ymaxcoordinate"); - return MY_Y_MAX_COORD_ID; - } - - /// Attribute name for z max coodinate. - inline static const std::string& Z_MAX_COORD_ID() - { - static const std::string MY_Z_MAX_COORD_ID("zmaxcoordinate"); - return MY_Z_MAX_COORD_ID; - } - - /// Attribute name for values of result. - inline static const std::string& RESULT_VALUES_ID() - { - static const std::string MY_RESULT_VALUES_ID("result_values"); - return MY_RESULT_VALUES_ID; - } - - /// Attribute name for indicate to compute the bounding box. - inline static const std::string& COMPUTE_ID() - { - static const std::string MY_COMPUTE_ID("compute"); - return MY_COMPUTE_ID; - } - - /// \return the kind of a feature. - virtual const std::string& getKind() - { - return ID(); - } - - /// Performs the algorithm and stores results it in the data structure. - FEATURESPLUGIN_EXPORT virtual void execute(); - - /// Request for initialization of data model of the feature: adding all attributes - FEATURESPLUGIN_EXPORT virtual void initAttributes(); - - /// Called on change of any argument-attribute of this object - /// \param theID identifier of changed attribute - FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); - - /// Return Attribut values of result. - FEATURESPLUGIN_EXPORT virtual AttributePtr attributResultValues(); - - /// Use plugin manager for features creation - FeaturesPlugin_CreateBoundingBox(); - -private: - /// Update values displayed. - bool updateValues(); - -}; - -#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_InspectBoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_InspectBoundingBox.cpp new file mode 100644 index 000000000..aed9de077 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_InspectBoundingBox.cpp @@ -0,0 +1,199 @@ +// Copyright (C) 2018-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 "FeaturesPlugin_InspectBoundingBox.h" + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//================================================================================================= +FeaturesPlugin_InspectBoundingBox::FeaturesPlugin_InspectBoundingBox() +{ +} + +//================================================================================================= +void FeaturesPlugin_InspectBoundingBox::initAttributes() +{ + // attribute for object selected + data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + + // attributes for result message and values + data()->addAttribute(X_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(X_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(CREATEBOX_ID(), ModelAPI_AttributeBoolean::typeId()); + + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATEBOX_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), RESULT_VALUES_ID()); + + data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId()); + + data()->realArray(RESULT_VALUES_ID())->setSize(6); + +} + +//================================================================================================= +void FeaturesPlugin_InspectBoundingBox::execute() +{ + if (!updateValues()) + return; + + createBoxByTwoPoints(); + + if (boolean(CREATEBOX_ID())->value()) { + if (!myCreateFeature.get()) + createBox(); + updateBox(); + } else { + if (myCreateFeature.get()) { + myCreateFeature->eraseResults(); + SessionPtr aSession = ModelAPI_Session::get(); + DocumentPtr aDoc = aSession->activeDocument(); + aDoc->removeFeature(myCreateFeature); + myCreateFeature.reset(); + } + } +} + +//================================================================================================= +void FeaturesPlugin_InspectBoundingBox::attributeChanged(const std::string& theID) +{ + if (theID == OBJECT_ID()) { + if (myCreateFeature.get()) + updateBox(); + } +} + +//================================================================================================= +AttributePtr FeaturesPlugin_InspectBoundingBox::attributResultValues() +{ + return attribute(RESULT_VALUES_ID()); +} + +//================================================================================================= +bool FeaturesPlugin_InspectBoundingBox::updateValues() +{ + AttributeSelectionPtr aSelection = selection(OBJECT_ID()); + if (aSelection->isInitialized()) { + AttributeDoubleArrayPtr aValues = + std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); + std::stringstream streamxmin; + std::stringstream streamymin; + std::stringstream streamzmin; + std::stringstream streamxmax; + std::stringstream streamymax; + std::stringstream streamzmax; + + GeomShapePtr aShape; + if (aSelection && aSelection->isInitialized()) { + aShape = aSelection->value(); + if (!aShape && aSelection->context()) + aShape = aSelection->context()->shape(); + } + + if (aShape && !aShape->isEqual(myShape)) { + double aXmin, aXmax, aYmin, aYmax, aZmin, aZmax; + std::string anError; + if (!GetBoundingBox(aShape, + aXmin, aXmax, + aYmin, aYmax, + aZmin, aZmax, + anError)) { + setError("Error in bounding box calculation :" + anError); + return false; + } + + myShape = aShape; + streamxmin << std::setprecision(14) << aXmin; + aValues->setValue(0, aXmin); + streamxmax << std::setprecision(14) << aXmax; + aValues->setValue(1, aXmax); + streamymin << std::setprecision(14) << aYmin; + aValues->setValue(2, aYmin); + streamymax << std::setprecision(14) << aYmax; + aValues->setValue(3, aYmax); + streamzmin << std::setprecision(14) << aZmin; + aValues->setValue(4, aZmin); + streamzmax << std::setprecision(14) << aZmax; + aValues->setValue(5, aZmax); + string(X_MIN_COORD_ID() )->setValue( "X = " + streamxmin.str() ); + string(Y_MIN_COORD_ID() )->setValue( "Y = " + streamymin.str() ); + string(Z_MIN_COORD_ID() )->setValue( "Z = " + streamzmin.str() ); + string(X_MAX_COORD_ID() )->setValue( "X = " + streamxmax.str() ); + string(Y_MAX_COORD_ID() )->setValue( "Y = " + streamymax.str() ); + string(Z_MAX_COORD_ID() )->setValue( "Z = " + streamzmax.str() ); + } + } + return true; +} + +//================================================================================================= +void FeaturesPlugin_InspectBoundingBox::createBox() +{ + SessionPtr aSession = ModelAPI_Session::get(); + + DocumentPtr aDoc = aSession->activeDocument(); + + if (aDoc.get()) { + myCreateFeature = aDoc->addFeature(FeaturesPlugin_CreateBoundingBox::ID()); + } +} + +//================================================================================================= +void FeaturesPlugin_InspectBoundingBox::updateBox() +{ + myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(false); + myCreateFeature->selection(FeaturesPlugin_CreateBoundingBox::OBJECT_ID()) + ->setValue(selection(OBJECT_ID())->context(), + selection(OBJECT_ID())->value()); + + AttributeDoubleArrayPtr aValuesFeatures = + std::dynamic_pointer_cast + (myCreateFeature->attribute(RESULT_VALUES_ID())); + AttributeDoubleArrayPtr aValues = + std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); + for (int anI=0; anI < 6; anI++) + aValuesFeatures->setValue(anI,aValues->value(anI)); + + myCreateFeature->execute(); + myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(true); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_InspectBoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_InspectBoundingBox.h new file mode 100644 index 000000000..3e224d43a --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_InspectBoundingBox.h @@ -0,0 +1,140 @@ +// Copyright (C) 2018-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 FeaturesPlugin_InspectBoundingBox_H_ +#define FeaturesPlugin_InspectBoundingBox_H_ + +#include + +/// \class FeaturesPlugin_InspectBoundingBox +/// \ingroup Plugins +/// \brief Feature to view the Bounding Box. + +class FeaturesPlugin_InspectBoundingBox : public FeaturesPlugin_BoundingBoxBase +{ +public: + /// Bounding box macro kind. + inline static const std::string& ID() + { + static const std::string MY_ID("BoundingBoxMacro"); + return MY_ID; + } + + /// Attribute name for object selected. + inline static const std::string& OBJECT_ID() + { + static const std::string MY_OBJECT_ID("main_object"); + return MY_OBJECT_ID; + } + + /// Attribute name for x coodinate. + inline static const std::string& X_MIN_COORD_ID() + { + static const std::string MY_X_MIN_COORD_ID("xmincoordinate"); + return MY_X_MIN_COORD_ID; + } + + /// Attribute name for y coodinate. + inline static const std::string& Y_MIN_COORD_ID() + { + static const std::string MY_Y_MIN_COORD_ID("ymincoordinate"); + return MY_Y_MIN_COORD_ID; + } + + /// Attribute name for z coodinate. + inline static const std::string& Z_MIN_COORD_ID() + { + static const std::string MY_Z_MIN_COORD_ID("zmincoordinate"); + return MY_Z_MIN_COORD_ID; + } + + /// Attribute name for x max coodinate. + inline static const std::string& X_MAX_COORD_ID() + { + static const std::string MY_X_MAX_COORD_ID("xmaxcoordinate"); + return MY_X_MAX_COORD_ID; + } + + /// Attribute name for y max coodinate. + inline static const std::string& Y_MAX_COORD_ID() + { + static const std::string MY_Y_MAX_COORD_ID("ymaxcoordinate"); + return MY_Y_MAX_COORD_ID; + } + + /// Attribute name for z max coodinate. + inline static const std::string& Z_MAX_COORD_ID() + { + static const std::string MY_Z_MAX_COORD_ID("zmaxcoordinate"); + return MY_Z_MAX_COORD_ID; + } + + /// Attribute name for checkbox create box. + inline static const std::string& CREATEBOX_ID() + { + static const std::string MY_CREATEBOX_ID("createbox"); + return MY_CREATEBOX_ID; + } + + /// Attribute name for values of result. + inline static const std::string& RESULT_VALUES_ID() + { + static const std::string MY_RESULT_VALUES_ID("result_values"); + return MY_RESULT_VALUES_ID; + } + + /// \return the kind of a feature. + virtual const std::string& getKind() + { + return ID(); + } + + /// Performs the algorithm and stores results it in the data structure. + FEATURESPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + FEATURESPLUGIN_EXPORT virtual void initAttributes(); + + /// Called on change of any argument-attribute of this object + /// \param theID identifier of changed attribute + FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); + + /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true. + FEATURESPLUGIN_EXPORT virtual bool isMacro() const { return true; } + + /// Use plugin manager for features creation + FeaturesPlugin_InspectBoundingBox(); + +private: + /// Return Attribut values of result. + virtual AttributePtr attributResultValues(); + + /// Update values displayed. + bool updateValues(); + /// Create Box + void createBox(); + /// Update Box + void updateBox(); + + /// Feature to create box + FeaturePtr myCreateFeature; + +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 63d0241e3..20121610e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -205,10 +205,10 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new FeaturesPlugin_PointCoordinates); } else if (theFeatureID == FeaturesPlugin_GeometryCalculation::ID()) { return FeaturePtr(new FeaturesPlugin_GeometryCalculation); + } else if (theFeatureID == FeaturesPlugin_InspectBoundingBox::ID()) { + return FeaturePtr(new FeaturesPlugin_InspectBoundingBox); } else if (theFeatureID == FeaturesPlugin_BoundingBox::ID()) { return FeaturePtr(new FeaturesPlugin_BoundingBox); - } else if (theFeatureID == FeaturesPlugin_CreateBoundingBox::ID()) { - return FeaturePtr(new FeaturesPlugin_CreateBoundingBox); }