From 204e0ea91ab490ae6f2380897fe94a840f55658c Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 2 Apr 2008 11:07:08 +0000 Subject: [PATCH] NPAL14167: Keep the parameters of the object after a transformation. --- idl/GEOM_Gen.idl | 40 ++- src/BooleanGUI/BooleanGUI_Dialog.cxx | 18 +- src/BooleanGUI/BooleanGUI_Dialog.h | 1 + src/BuildGUI/BuildGUI_CompoundDlg.cxx | 18 +- src/BuildGUI/BuildGUI_CompoundDlg.h | 3 +- src/DlgRef/DlgRef_Skeleton_QTD.cxx | 110 +++--- src/DlgRef/DlgRef_Skeleton_QTD.h | 33 +- src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui | 215 ++++++------ src/GEOMBase/GEOMBase_Helper.cxx | 32 +- src/GEOMBase/GEOMBase_Helper.h | 5 +- src/GEOMBase/GEOMBase_Skeleton.cxx | 67 ++-- src/GEOMGUI/GEOM_msg_en.po | 8 +- src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 72 ++-- src/GEOM_I/GEOM_Gen_i.cc | 321 +++++++++++++++++- src/GEOM_I/GEOM_Gen_i.hh | 29 ++ src/GEOM_SWIG/geompyDC.py | 38 ++- .../OperationGUI_PartitionDlg.cxx | 84 ++--- src/OperationGUI/OperationGUI_PartitionDlg.h | 7 +- .../TransformationGUI_MirrorDlg.cxx | 121 ++++--- .../TransformationGUI_MirrorDlg.h | 16 +- .../TransformationGUI_OffsetDlg.cxx | 18 +- .../TransformationGUI_OffsetDlg.h | 17 +- .../TransformationGUI_PositionDlg.cxx | 75 ++-- .../TransformationGUI_PositionDlg.h | 15 +- .../TransformationGUI_RotationDlg.cxx | 18 +- .../TransformationGUI_RotationDlg.h | 12 +- .../TransformationGUI_ScaleDlg.cxx | 20 +- .../TransformationGUI_ScaleDlg.h | 12 +- .../TransformationGUI_TranslationDlg.cxx | 85 +++-- .../TransformationGUI_TranslationDlg.h | 5 +- 30 files changed, 1029 insertions(+), 486 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 82d6094b6..a01948267 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2639,7 +2639,7 @@ module GEOM void Redo (in long theStudyID); /*! - * Publishing manangement + * Publishing management * Adds in theStudy a object theObject under with a name theName, * if theFather is not NULL the object is placed under thFather's SObject. * Returns a SObject where theObject is placed @@ -2649,6 +2649,44 @@ module GEOM in string theName, in GEOM_Object theFather); + /*! + * Publish sub-shapes, standing for arguments and sub-shapes of arguments + * To be used from python scripts out of geompy.addToStudy (non-default usage) + * \param theStudy the study, in which theObject is published already, + * and in which the arguments will be published + * \param theObject published GEOM object, arguments of which will be published + * \param theArgs list of GEOM_Object, operation arguments to be published. + * If this list is empty, all operation arguments will be published + * \param isTrsf If True, search sub-shapes by indices, as in case of + * transformation they cannot be found by GetInPlace. + * The argument itself is not published in this case, + * because the whole shape corresponds to the argument. + * \return True in case of success, False otherwise. + */ + boolean RestoreSubShapesO (in SALOMEDS::Study theStudy, + in GEOM_Object theObject, + in ListOfGO theArgs, + in boolean isTrsf); + + /*! + * Publish sub-shapes, standing for arguments and sub-shapes of arguments + * To be used from GUI and from geompy.addToStudy + * \param theStudy the study, in which theObject is published already, + * and in which the arguments will be published + * \param theSObject study object, referencing GEOM object, arguments of which will be published + * \param theArgs list of GEOM_Object, operation arguments to be published. + * If this list is empty, all operation arguments will be published + * \param isTrsf If True, search sub-shapes by indices, as in case of + * transformation they cannot be found by GetInPlace. + * The argument itself is not published in this case, + * because the whole shape corresponds to the argument. + * \return True in case of success, False otherwise. + */ + boolean RestoreSubShapesSO (in SALOMEDS::Study theStudy, + in SALOMEDS::SObject theSObject, + in ListOfGO theArgs, + in boolean isTrsf); + /*! * Methods to access interfaces for objects creation and transformation */ diff --git a/src/BooleanGUI/BooleanGUI_Dialog.cxx b/src/BooleanGUI/BooleanGUI_Dialog.cxx index 39826043a..b611f35d4 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.cxx +++ b/src/BooleanGUI/BooleanGUI_Dialog.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -35,6 +35,7 @@ #include "LightApp_SelectionMgr.h" #include +#include using namespace std; @@ -130,6 +131,8 @@ BooleanGUI_Dialog::~BooleanGUI_Dialog() //================================================================================= void BooleanGUI_Dialog::Init() { + GroupBoxPublish->show(); + /* init variables */ myEditCurrentArgument = myGroup->LineEdit1; @@ -306,3 +309,16 @@ bool BooleanGUI_Dialog::execute( ObjectList& objects ) return true; } + +//================================================================================= +// function : restoreSubShapes +// purpose : +//================================================================================= +void BooleanGUI_Dialog::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) +{ + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false); + } +} diff --git a/src/BooleanGUI/BooleanGUI_Dialog.h b/src/BooleanGUI/BooleanGUI_Dialog.h index e42fd2be2..65bf4d880 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.h +++ b/src/BooleanGUI/BooleanGUI_Dialog.h @@ -52,6 +52,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: int myOperation; diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.cxx b/src/BuildGUI/BuildGUI_CompoundDlg.cxx index 4ea4ca696..8daea75f4 100644 --- a/src/BuildGUI/BuildGUI_CompoundDlg.cxx +++ b/src/BuildGUI/BuildGUI_CompoundDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -34,6 +34,7 @@ #include "LightApp_SelectionMgr.h" #include +#include //================================================================================= // class : BuildGUI_CompoundDlg() @@ -96,6 +97,8 @@ void BuildGUI_CompoundDlg::Init() myOkShapes = false; + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -229,3 +232,16 @@ bool BuildGUI_CompoundDlg::execute( ObjectList& objects ) return true; } + +//================================================================================= +// function : restoreSubShapes +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) +{ + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false); + } +} diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.h b/src/BuildGUI/BuildGUI_CompoundDlg.h index 31182622c..0d93fda82 100644 --- a/src/BuildGUI/BuildGUI_CompoundDlg.h +++ b/src/BuildGUI/BuildGUI_CompoundDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -51,6 +51,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& msg ); virtual bool execute( ObjectList& objects ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); diff --git a/src/DlgRef/DlgRef_Skeleton_QTD.cxx b/src/DlgRef/DlgRef_Skeleton_QTD.cxx index c1ee25ceb..9ff558c8c 100644 --- a/src/DlgRef/DlgRef_Skeleton_QTD.cxx +++ b/src/DlgRef/DlgRef_Skeleton_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_Skeleton_QTD.ui' ** -** Created: Wed Feb 13 17:37:30 2008 +** Created: Wed Mar 26 12:14:14 2008 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! @@ -11,11 +11,12 @@ #include #include -#include #include #include -#include +#include #include +#include +#include #include #include #include @@ -38,37 +39,6 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, boo Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 6 ); - GroupButtons->layout()->setMargin( 11 ); - GroupButtonsLayout = new QVBoxLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - - layout3 = new QGridLayout( 0, 1, 1, 0, 6, "layout3"); - Spacer1 = new QSpacerItem( 90, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - layout3->addItem( Spacer1, 0, 3 ); - - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - - layout3->addWidget( buttonOk, 0, 2 ); - - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - - layout3->addWidget( buttonApply, 0, 0 ); - - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - - layout3->addWidget( buttonCancel, 0, 1 ); - - buttonHelp = new QPushButton( GroupButtons, "buttonHelp" ); - - layout3->addWidget( buttonHelp, 0, 4 ); - GroupButtonsLayout->addLayout( layout3 ); - - Layout1->addWidget( GroupButtons, 3, 0 ); - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); GroupConstructors->setColumnLayout(0, Qt::Vertical ); @@ -101,20 +71,68 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, boo GroupBoxNameLayout = new QGridLayout( GroupBoxName->layout() ); GroupBoxNameLayout->setAlignment( Qt::AlignTop ); - Layout66 = new QGridLayout( 0, 1, 1, 0, 6, "Layout66"); + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); - ResultName = new QLineEdit( GroupBoxName, "ResultName" ); + NameLabel = new QLabel( GroupBoxName, "NameLabel" ); - Layout66->addWidget( ResultName, 0, 1 ); + Layout4->addWidget( NameLabel, 0, 0 ); - NameLabel = new QLabel( GroupBoxName, "NameLabel" ); + ResultName = new QLineEdit( GroupBoxName, "ResultName" ); - Layout66->addWidget( NameLabel, 0, 0 ); + Layout4->addWidget( ResultName, 0, 1 ); - GroupBoxNameLayout->addLayout( Layout66, 0, 0 ); + GroupBoxNameLayout->addLayout( Layout4, 0, 0 ); Layout1->addWidget( GroupBoxName, 1, 0 ); + GroupBoxPublish = new QGroupBox( this, "GroupBoxPublish" ); + GroupBoxPublish->setColumnLayout(0, Qt::Vertical ); + GroupBoxPublish->layout()->setSpacing( 6 ); + GroupBoxPublish->layout()->setMargin( 11 ); + GroupBoxPublishLayout = new QGridLayout( GroupBoxPublish->layout() ); + GroupBoxPublishLayout->setAlignment( Qt::AlignTop ); + + Layout5 = new QGridLayout( 0, 1, 1, 0, 6, "Layout5"); + + CheckBoxRestoreSS = new QCheckBox( GroupBoxPublish, "CheckBoxRestoreSS" ); + + Layout5->addWidget( CheckBoxRestoreSS, 0, 0 ); + + GroupBoxPublishLayout->addLayout( Layout5, 0, 0 ); + + Layout1->addWidget( GroupBoxPublish, 3, 0 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 6 ); + GroupButtons->layout()->setMargin( 11 ); + GroupButtonsLayout = new QVBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); + + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + + Layout3->addWidget( buttonApply, 0, 0 ); + + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + + Layout3->addWidget( buttonCancel, 0, 1 ); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + + Layout3->addWidget( buttonOk, 0, 2 ); + Spacer1 = new QSpacerItem( 90, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout3->addItem( Spacer1, 0, 3 ); + + buttonHelp = new QPushButton( GroupButtons, "buttonHelp" ); + + Layout3->addWidget( buttonHelp, 0, 4 ); + GroupButtonsLayout->addLayout( Layout3 ); + + Layout1->addWidget( GroupButtons, 4, 0 ); + DlgRef_Skeleton_QTDLayout->addLayout( Layout1, 0, 0 ); languageChange(); resize( QSize(615, 682).expandedTo(minimumSizeHint()) ); @@ -135,17 +153,5 @@ DlgRef_Skeleton_QTD::~DlgRef_Skeleton_QTD() */ void DlgRef_Skeleton_QTD::languageChange() { - setCaption( tr( "DlgRef_Skeleton_QTD" ) ); - GroupButtons->setTitle( QString::null ); - buttonOk->setText( QString::null ); - buttonApply->setText( QString::null ); - buttonCancel->setText( QString::null ); - buttonHelp->setText( QString::null ); - GroupConstructors->setTitle( QString::null ); - RadioButton1->setText( QString::null ); - RadioButton2->setText( QString::null ); - RadioButton3->setText( QString::null ); - RadioButton4->setText( QString::null ); - GroupBoxName->setTitle( QString::null ); } diff --git a/src/DlgRef/DlgRef_Skeleton_QTD.h b/src/DlgRef/DlgRef_Skeleton_QTD.h index 2afaefc84..f197e914c 100644 --- a/src/DlgRef/DlgRef_Skeleton_QTD.h +++ b/src/DlgRef/DlgRef_Skeleton_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_Skeleton_QTD.ui' ** -** Created: Wed Feb 13 17:37:30 2008 +** Created: Wed Mar 26 12:14:12 2008 ** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! @@ -17,12 +17,13 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QSpacerItem; -class QGroupBox; -class QPushButton; class QButtonGroup; class QRadioButton; -class QLineEdit; +class QGroupBox; class QLabel; +class QLineEdit; +class QCheckBox; +class QPushButton; class DlgRef_Skeleton_QTD : public QDialog { @@ -32,30 +33,34 @@ public: DlgRef_Skeleton_QTD( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~DlgRef_Skeleton_QTD(); - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonApply; - QPushButton* buttonCancel; - QPushButton* buttonHelp; QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; QRadioButton* RadioButton2; QRadioButton* RadioButton3; QRadioButton* RadioButton4; QGroupBox* GroupBoxName; - QLineEdit* ResultName; QLabel* NameLabel; + QLineEdit* ResultName; + QGroupBox* GroupBoxPublish; + QCheckBox* CheckBoxRestoreSS; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonCancel; + QPushButton* buttonOk; + QPushButton* buttonHelp; protected: QGridLayout* DlgRef_Skeleton_QTDLayout; QGridLayout* Layout1; - QVBoxLayout* GroupButtonsLayout; - QGridLayout* layout3; - QSpacerItem* Spacer1; QHBoxLayout* GroupConstructorsLayout; QHBoxLayout* Layout2; QGridLayout* GroupBoxNameLayout; - QGridLayout* Layout66; + QGridLayout* Layout4; + QGridLayout* GroupBoxPublishLayout; + QGridLayout* Layout5; + QVBoxLayout* GroupButtonsLayout; + QGridLayout* Layout3; + QSpacerItem* Spacer1; protected slots: virtual void languageChange(); diff --git a/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui b/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui index 99a216a36..4e6826996 100644 --- a/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui @@ -20,9 +20,6 @@ 0 - - DlgRef_Skeleton_QTD - true @@ -50,22 +47,19 @@ 6 - + - GroupButtons + GroupConstructors - 7 + 5 0 0 0 - - - - + unnamed @@ -77,81 +71,47 @@ - layout3 + Layout2 - + unnamed - - - Spacer1 - - - Horizontal - - - Expanding - - - - 90 - 20 - - - - + + 0 + + + 6 + + - buttonOk - - - + RadioButton1 - + - buttonApply - - - + RadioButton2 - + - buttonCancel - - - + RadioButton3 - + - buttonHelp - - - + RadioButton4 - + - + - + - GroupConstructors - - - - 5 - 0 - 0 - 0 - - - - + GroupBoxName - + unnamed @@ -161,11 +121,11 @@ 6 - + - Layout2 + Layout4 - + unnamed @@ -175,48 +135,23 @@ 6 - - - RadioButton1 - - - - - - - - RadioButton2 - - - - - - + - RadioButton3 - - - + NameLabel - + - RadioButton4 - - - + ResultName - + - + - + - GroupBoxName - - - + GroupBoxPublish @@ -230,7 +165,7 @@ - Layout66 + Layout5 @@ -242,19 +177,85 @@ 6 - + - ResultName + CheckBoxRestoreSS - + + + + + + + GroupButtons + + + + 7 + 0 + 0 + 0 + + + + + unnamed + + + 11 + + + 6 + + + + Layout3 + + + + unnamed + + - NameLabel + buttonApply + + + + + buttonCancel + + + + + buttonOk + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 90 + 20 + + + + + + buttonHelp - + diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 32f321691..a882d39c4 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -523,10 +523,31 @@ void GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* theN if ( !aStudy || theObj->_is_nil() ) return; + SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy); + GEOM::GEOM_Object_ptr aFatherObj = getFather( theObj ); - getGeomEngine()->AddInStudy(GeometryGUI::ClientStudyToStudy(aStudy), - theObj, theName, aFatherObj); + SALOMEDS::SObject_var aSO = + getGeomEngine()->AddInStudy(aStudyDS, theObj, theName, aFatherObj); + + // Each dialog is responsible for this method implementation, + // default implementation does nothing + restoreSubShapes(aStudyDS, aSO); +} + +//================================================================ +// Function : restoreSubShapes +// Purpose : restore tree of argument's sub-shapes under the resulting shape +//================================================================ +void GEOMBase_Helper::restoreSubShapes (SALOMEDS::Study_ptr /*theStudy*/, + SALOMEDS::SObject_ptr /*theSObject*/) +{ + // do nothing by default + + // example of implementation in particular dialog: + // GEOM::ListOfGO anArgs; + // anArgs.length(0); // empty list means that all arguments should be restored + // getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs, /*isTrsf=*/false); } //================================================================ @@ -751,10 +772,11 @@ bool GEOMBase_Helper::checkViewWindow() // It perfroms user input validation, then it // performs a proper operation and manages transactions, etc. //================================================================ -bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction ) +bool GEOMBase_Helper::onAccept (const bool publish, const bool useTransaction) { - SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); - if ( !appStudy ) return false; + SalomeApp_Study* appStudy = + dynamic_cast(SUIT_Session::session()->activeApplication()->activeStudy()); + if (!appStudy) return false; _PTR(Study) aStudy = appStudy->studyDS(); bool aLocked = (_PTR(AttributeStudyProperties) (aStudy->GetProperties()))->IsLocked(); diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 62d1f2bb0..6ae7318ca 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -106,7 +106,7 @@ protected: void prepareSelection( const ObjectList&, const int ); void prepareSelection( GEOM::GEOM_Object_ptr, const int ); - void addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); + void addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); bool openCommand (); bool abortCommand (); @@ -171,6 +171,9 @@ protected: // It should perform the required operation and put all new or modified objects into // argument.Should return if some error occurs during its execution. + virtual void restoreSubShapes (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject); + // This method is called by addInStudy(). + virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr theObj ); // This method is called by addInStudy(). It should return a father object // for or a nil reference if should be published diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx index 32f3ff2af..4507dc644 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.cxx +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -38,20 +38,21 @@ #include #include +#include using namespace std; //================================================================================= // class : GEOMBase_Skeleton() -// purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the +// purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GEOMBase_Skeleton::GEOMBase_Skeleton(GeometryGUI* theGeometryGUI, QWidget* parent, - const char* name, bool modal, WFlags fl) +GEOMBase_Skeleton::GEOMBase_Skeleton (GeometryGUI* theGeometryGUI, QWidget* parent, + const char* name, bool modal, WFlags fl) : DlgRef_Skeleton_QTD( parent, name, modal, WStyle_Customize | WStyle_NormalBorder - | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), + | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), GEOMBase_Helper( dynamic_cast( parent ) ), myGeomGUI( theGeometryGUI ) { @@ -61,6 +62,9 @@ GEOMBase_Skeleton::GEOMBase_Skeleton(GeometryGUI* theGeometryGUI, QWidget* paren GroupBoxName->setTitle(tr("GEOM_RESULT_NAME_GRP")); NameLabel->setText(tr("GEOM_RESULT_NAME_LBL")); + GroupBoxPublish->setTitle(tr("GEOM_PUBLISH_RESULT_GRP")); + CheckBoxRestoreSS->setText(tr("GEOM_RESTORE_SUB_SHAPES")); + buttonCancel->setText(tr("GEOM_BUT_CLOSE")); buttonOk->setText(tr("GEOM_BUT_APPLY_AND_CLOSE")); buttonApply->setText(tr("GEOM_BUT_APPLY")); @@ -71,7 +75,6 @@ GEOMBase_Skeleton::GEOMBase_Skeleton(GeometryGUI* theGeometryGUI, QWidget* paren Init(); } - //================================================================================= // function : ~GEOMBase_Skeleton() // purpose : Destroys the object and frees any allocated resources @@ -82,7 +85,6 @@ GEOMBase_Skeleton::~GEOMBase_Skeleton() myGeomGUI->SetActiveDialogBox( 0 ); } - //================================================================================= // function : Init() // purpose : @@ -94,11 +96,12 @@ void GEOMBase_Skeleton::Init() myGeomGUI = dynamic_cast( app->module( "Geometry" ) ); /* init variables */ - myGeomGUI->SetActiveDialogBox(this); + if (myGeomGUI) + myGeomGUI->SetActiveDialogBox(this); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - if (myGeomGUI) + if (myGeomGUI) { connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); @@ -111,10 +114,10 @@ void GEOMBase_Skeleton::Init() RadioButton1->setChecked(TRUE); RadioButton4->hide(); - return; + CheckBoxRestoreSS->setChecked(FALSE); + GroupBoxPublish->hide(); } - //================================================================================= // function : ClickOnCancel() // purpose : @@ -124,7 +127,6 @@ void GEOMBase_Skeleton::ClickOnCancel() close(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -139,14 +141,11 @@ void GEOMBase_Skeleton::LineEditReturnPressed() /* so SelectionIntoArgument() is automatically called. */ const QString objectUserName = myEditCurrentArgument->text(); QWidget* thisWidget = (QWidget*)this; - + if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO())) myEditCurrentArgument->setText(objectUserName); - - return; } - //================================================================================= // function : DeactivateActiveDialog() // purpose : @@ -155,13 +154,12 @@ void GEOMBase_Skeleton::DeactivateActiveDialog() { this->setEnabled(false); globalSelection(); - disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); - if (myGeomGUI) myGeomGUI->SetActiveDialogBox(0); - - return; + if (myGeomGUI) { + myGeomGUI->SetActiveDialogBox(0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + } } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -172,20 +170,17 @@ void GEOMBase_Skeleton::ActivateThisDialog() if (myGeomGUI) myGeomGUI->EmitSignalDeactivateDialog(); this->setEnabled(true); if (myGeomGUI) myGeomGUI->SetActiveDialogBox((QDialog*)this); - return; } - //================================================================================= // function : closeEvent() // purpose : same than click on cancel button //================================================================================= void GEOMBase_Skeleton::closeEvent(QCloseEvent* e) { - SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication()); - if(app) { - disconnect( app->selectionMgr(), 0, this, 0); - app->updateActions(); + if (myGeomGUI) { + disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->updateActions(); } QDialog::closeEvent( e ); } @@ -228,14 +223,14 @@ int GEOMBase_Skeleton::getConstructorId() const void GEOMBase_Skeleton::ClickOnHelp() { LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) + if (app) app->onHelpContextModule(myGeomGUI ? app->moduleName(myGeomGUI->moduleName()) : QString(""), myHelpFileName); else { - QString platform; + QString platform; #ifdef WIN32 - platform = "winapplication"; + platform = "winapplication"; #else - platform = "application"; + platform = "application"; #endif SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). @@ -243,11 +238,11 @@ void GEOMBase_Skeleton::ClickOnHelp() QObject::tr("BUT_OK")); } } + //================================================================================= // function : setHelpFileName() // purpose : set name for help file html //================================================================================= - void GEOMBase_Skeleton::setHelpFileName(const QString& theName) { myHelpFileName = theName; @@ -264,8 +259,8 @@ void GEOMBase_Skeleton::keyPressEvent( QKeyEvent* e ) return; if ( e->key() == Key_F1 ) - { - e->accept(); - ClickOnHelp(); - } + { + e->accept(); + ClickOnHelp(); + } } diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index d18ef12d5..c694fae09 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -15,7 +15,7 @@ # 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # This is a Qt message file in .po format. Each msgid starts with # a scope. This scope should *NOT* be translated - eg. translating @@ -3129,6 +3129,12 @@ msgstr "Result name" msgid "GEOM_RESULT_NAME_LBL" msgstr "Name" +msgid "GEOM_PUBLISH_RESULT_GRP" +msgstr "Advanced options" + +msgid "GEOM_RESTORE_SUB_SHAPES" +msgstr "Set presentation parameters and subshapes from arguments" + msgid "GEOM_ERR_GET_ENGINE" msgstr "Failed to obtain GEOM Engine component. Reload Geometry module and try again." diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index b94d8f569..e4487ec49 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -68,6 +68,7 @@ using namespace std; #include #include +#include #include #include @@ -2812,19 +2813,17 @@ static bool GetInPlaceOfShape (const Handle(GEOM_Function)& theWhereFunction, void GEOMImpl_IShapesOperations::GetShapeProperties( const TopoDS_Shape aShape, Standard_Real tab[], gp_Pnt & aVertex ) { - GProp_GProps SProps, VProps; + GProp_GProps theProps; gp_Pnt aCenterMass; TopoDS_Shape aPntShape; Standard_Real aShapeSize; - BRepGProp::VolumeProperties(aShape, VProps); - aCenterMass = VProps.CentreOfMass(); - aShapeSize = VProps.Mass(); - if (aShape.ShapeType() == TopAbs_FACE) { - BRepGProp::SurfaceProperties(aShape, SProps); - aCenterMass = SProps.CentreOfMass(); - aShapeSize = SProps.Mass(); - } + if (aShape.ShapeType() == TopAbs_EDGE) BRepGProp::LinearProperties(aShape, theProps); + else if (aShape.ShapeType() == TopAbs_FACE) BRepGProp::SurfaceProperties(aShape, theProps); + else BRepGProp::VolumeProperties(aShape, theProps); + + aCenterMass = theProps.CentreOfMass(); + aShapeSize = theProps.Mass(); aPntShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape(); aVertex = BRep_Tool::Pnt( TopoDS::Vertex( aPntShape ) ); @@ -2849,6 +2848,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) TopoDS_Shape aWhere = theShapeWhere->GetValue(); TopoDS_Shape aWhat = theShapeWhat->GetValue(); + TopoDS_Shape aPntShape; + TopoDS_Vertex aVertex; if (aWhere.IsNull() || aWhat.IsNull()) { SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null."); @@ -2871,6 +2872,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) bool isFound = false; Standard_Integer iType = TopAbs_SOLID; + Standard_Integer compType = TopAbs_SOLID; Standard_Real aWhat_Mass = 0., aWhere_Mass = 0.; Standard_Real tab_aWhat[4], tab_aWhere[4]; Standard_Real dl_l = 1e-3; @@ -2878,15 +2880,23 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) gp_Pnt aPnt, aPnt_aWhat; GProp_GProps aProps; - // 2D or 3D shapes - if ( aWhat.ShapeType() == TopAbs_COMPOUND || - aWhat.ShapeType() == TopAbs_SHELL || - aWhat.ShapeType() == TopAbs_COMPSOLID ) { - TopExp_Explorer Exp( aWhat, TopAbs_ShapeEnum( iType ) ); - if ( ! Exp.More() ) iType = TopAbs_FACE; + // Find the iType of the aWhat shape + if ( aWhat.ShapeType() == TopAbs_EDGE || aWhat.ShapeType() == TopAbs_WIRE ) iType = TopAbs_EDGE; + else if ( aWhat.ShapeType() == TopAbs_FACE || aWhat.ShapeType() == TopAbs_SHELL ) iType = TopAbs_FACE; + else if ( aWhat.ShapeType() == TopAbs_SOLID || aWhat.ShapeType() == TopAbs_COMPSOLID ) iType = TopAbs_SOLID; + else if ( aWhat.ShapeType() == TopAbs_COMPOUND ) { + // Only the iType of the first shape in the compound is taken into account + TopoDS_Iterator It (aWhat, Standard_True, Standard_True); + compType = It.Value().ShapeType(); + if ( compType == TopAbs_EDGE || compType == TopAbs_WIRE ) iType = TopAbs_EDGE; + else if ( compType == TopAbs_FACE || compType == TopAbs_SHELL) iType = TopAbs_FACE; + else if ( compType == TopAbs_SOLID || compType == TopAbs_COMPSOLID) iType = TopAbs_SOLID; + } + else { + cout << endl; + cout << "WARNING : shape to be extracted is of unknown type !" << endl; + cout << endl; } - else if ( aWhat.ShapeType() == TopAbs_FACE ) - iType = TopAbs_FACE; TopExp_Explorer Exp_aWhat( aWhat, TopAbs_ShapeEnum( iType ) ); TopExp_Explorer Exp_aWhere( aWhere, TopAbs_ShapeEnum( iType ) ); @@ -2905,29 +2915,31 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) Tol_3D = dl_l * ( min_l * min_l * min_l ) * ( 3. + (3 * dl_l) + (dl_l * dl_l) ); Tol_Mass = Tol_3D; - if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D; + if ( iType == TopAbs_EDGE ) Tol_Mass = Tol_1D; + else if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D; // Compute the ShapeWhat Mass for ( ; Exp_aWhat.More(); Exp_aWhat.Next() ) { - if ( iType == TopAbs_SOLID ) BRepGProp::VolumeProperties(Exp_aWhat.Current(), aProps); - else if ( iType == TopAbs_FACE ) BRepGProp::SurfaceProperties(Exp_aWhat.Current(), aProps); + if ( iType == TopAbs_EDGE ) BRepGProp::LinearProperties(Exp_aWhat.Current(), aProps); + else if ( iType == TopAbs_FACE ) BRepGProp::SurfaceProperties(Exp_aWhat.Current(), aProps); + else BRepGProp::VolumeProperties(Exp_aWhat.Current(), aProps); aWhat_Mass += aProps.Mass(); } - // Finding the Sub-ShapeWhere + // Searching for the sub-shapes inside the ShapeWhere shape for ( Exp_aWhere.ReInit(); Exp_aWhere.More(); Exp_aWhere.Next() ) { GetShapeProperties( Exp_aWhere.Current(), tab_aWhere, aPnt ); for ( Exp_aWhat.ReInit(); Exp_aWhat.More(); Exp_aWhat.Next() ) { GetShapeProperties( Exp_aWhat.Current(), tab_aWhat, aPnt_aWhat ); - if ( fabs(tab_aWhat[3] - tab_aWhere[3]) <= Tol_Mass && aPnt_aWhat.Distance(aPnt) <= Tol_1D ) - isFound = true; - else if ( tab_aWhat[3] - ( tab_aWhere[3] > Tol_Mass) ) { - BRepClass3d_SolidClassifier SC_aWhere (Exp_aWhere.Current(), aPnt, Precision::Confusion()); - BRepClass3d_SolidClassifier SC_aWhat (Exp_aWhat.Current(), aPnt, Precision::Confusion()); - // Block construction 3D - if ( SC_aWhere.State() == TopAbs_IN && SC_aWhat.State() == TopAbs_IN ) isFound = true; - // Block construction 2D - else if ( SC_aWhere.State() == TopAbs_ON && SC_aWhat.State() == TopAbs_ON ) isFound = true; + if ( fabs(tab_aWhat[3] - tab_aWhere[3]) <= Tol_Mass && aPnt_aWhat.Distance(aPnt) <= Tol_1D ) isFound = true; + else { + if ( (tab_aWhat[3] - tab_aWhere[3]) > Tol_Mass ) { + aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape(); + aVertex = TopoDS::Vertex( aPntShape ); + BRepExtrema_DistShapeShape aWhereDistance ( aVertex, Exp_aWhere.Current() ); + BRepExtrema_DistShapeShape aWhatDistance ( aVertex, Exp_aWhat.Current() ); + if ( fabs(aWhereDistance.Value() - aWhatDistance.Value()) <= Tol_1D ) isFound = true; + } } if ( isFound ) { aWhereIndex = aWhereIndices.FindIndex(Exp_aWhere.Current()); diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index b41b07f8b..2515aad88 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -522,7 +522,10 @@ char* GEOM_Gen_i::ComponentDataType() // function : AddInStudy // purpose : //============================================================================ -SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy(SALOMEDS::Study_ptr theStudy, GEOM::GEOM_Object_ptr theObject, const char* theName, GEOM::GEOM_Object_ptr theFather) +SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + const char* theName, + GEOM::GEOM_Object_ptr theFather) { SALOMEDS::SObject_var aResultSO; if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO; @@ -559,6 +562,322 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy(SALOMEDS::Study_ptr theStudy, GEOM: return aResultSO._retn(); } +//============================================================================ +// function : RestoreSubShapes +// purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments. +// To be used from python scripts out of geompy.addToStudy (non-default usage) +//============================================================================ +CORBA::Boolean GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + const GEOM::ListOfGO& theArgs, + CORBA::Boolean isTrsf) +{ + if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject)) + return false; + + // find SObject in the study + CORBA::String_var anIORo = _orb->object_to_string(theObject); + SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(anIORo.in()); + if (CORBA::is_nil(aSO)) + return false; + + return RestoreSubShapes(theStudy, theObject, aSO, theArgs, isTrsf); +} + +//============================================================================ +// function : RestoreSubShapes +// purpose : Publish sub-shapes, standing for arguments and sub-shapes of arguments. +// To be used from GUI and from geompy.addToStudy +//============================================================================ +CORBA::Boolean GEOM_Gen_i::RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + const GEOM::ListOfGO& theArgs, + CORBA::Boolean isTrsf) +{ + if (CORBA::is_nil(theStudy) || CORBA::is_nil(theSObject)) + return false; + + SALOMEDS::GenericAttribute_var anAttr; + if (!theSObject->FindAttribute(anAttr, "AttributeIOR")) + return false; + + SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var anIORso = anAttrIOR->Value(); + + // get Object from SObject + GEOM::GEOM_Object_var anO = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIORso)); + if (CORBA::is_nil(anO)) + return false; + + return RestoreSubShapes(theStudy, anO, theSObject, theArgs, isTrsf); +} + +//============================================================================ +// function : RestoreSubShapes +// purpose : Private method. Works only if both theObject and theSObject +// are defined, and does not check, if they correspond to each other. +//============================================================================ +CORBA::Boolean GEOM_Gen_i::RestoreSubShapes (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + SALOMEDS::SObject_ptr theSObject, + const GEOM::ListOfGO& theArgs, + CORBA::Boolean isTrsf) +{ + if (CORBA::is_nil(theStudy) || CORBA::is_nil(theObject) || CORBA::is_nil(theSObject)) + return false; + + if (isTrsf && theArgs.length() > 1) + // only one (the first) argument of transformation + // (the transformed shape) can be restored + return false; + + // Arguments to be published + GEOM::ListOfGO_var aList; + + // If theArgs list is empty, we try to publish all arguments, + // otherwise publish only passed args + Standard_Integer nbArgsActual = -1; // -1 means unknown + Standard_Integer aLength = theArgs.length(); + if (aLength > 0) { + aList = new GEOM::ListOfGO; + aList->length(aLength); + for (int i = 0; i < aLength; i++) { + aList[i] = theArgs[i]; + } + } + else { + // Get all arguments + aList = theObject->GetDependency(); + aLength = aList->length(); + nbArgsActual = aLength; + } + + if (aLength < 1) + return false; + + if (isTrsf) { + // In case of transformation we do not publish argument's reflection, + // but only reconstruct its published sub-shapes + + GEOM::GEOM_Object_var anArgO = aList[0]; + CORBA::String_var anIOR = _orb->object_to_string(anArgO); + SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in()); + + GEOM::ListOfGO_var aParts = + RestoreSubShapesOneLevel(theStudy, anArgSO, theSObject, theObject, isTrsf); + + // set the color of the transformed shape to the color of initial shape + theObject->SetColor(aList[0]->GetColor()); + + return (aParts->length() > 0); + } + else { + // in this case (not a transformation) we cannot detect, if the final + // shape should have the same color, as one of arguments, and we apply + // the same color only in case of single argument + if (nbArgsActual == 1) { + // set the color of the new shape to the color of its single argument + theObject->SetColor(aList[0]->GetColor()); + } + } + + // Get interface, containing method GetInPlace, which we will use to reconstruct sub-shapes + GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId()); + + // Reconstruct arguments and tree of sub-shapes of the arguments + CORBA::String_var anIOR; + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + for (Standard_Integer i = 0; i < aLength; i++) + { + GEOM::GEOM_Object_var anArgO = aList[i]; + if (!CORBA::is_nil(anArgO)) { + anIOR = _orb->object_to_string(anArgO); + SALOMEDS::SObject_var anArgSO = theStudy->FindObjectIOR(anIOR.in()); + TCollection_AsciiString anArgName; + if (CORBA::is_nil(anArgSO)) { + anArgName = "arg_"; + anArgName += TCollection_AsciiString(i); + } + else { + anArgName = anArgSO->GetName(); + } + + // Find a sub-shape of theObject in place of the argument + GEOM::GEOM_Object_var aSubO = aShapesOp->GetInPlace(theObject, anArgO); + if (!CORBA::is_nil(aSubO)) { + // Publish the sub-shape + TCollection_AsciiString aSubName ("from_"); + aSubName += anArgName; + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject); + aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); + // Restore color + aSubO->SetColor(anArgO->GetColor()); + + if (!CORBA::is_nil(anArgSO)) { + // Restore published sub-shapes of the argument + RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, aSubO, isTrsf); + } + } + else { // GetInPlace failed, try to build from published parts + if (!CORBA::is_nil(anArgSO)) { + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(theSObject); + + // Restore published sub-shapes of the argument + GEOM::ListOfGO_var aParts = + RestoreSubShapesOneLevel(theStudy, anArgSO, aSubSO, theObject, isTrsf); + + if (aParts->length() > 0) { + // try to build an argument from a set of its sub-shapes, + // that published and will be reconstructed + if (aParts->length() > 1) { + aSubO = aShapesOp->MakeCompound(aParts); + } + else { + aSubO = aParts[0]; + } + if (!CORBA::is_nil(aSubO)) { + // Publish the sub-shape + TCollection_AsciiString aSubName ("from_parts_of_"); + aSubName += anArgName; + aSubSO = PublishInStudy(theStudy, aSubSO, aSubO, aSubName.ToCString()); + // Restore color + aSubO->SetColor(anArgO->GetColor()); + } + } + else { + // remove created aSubSO, because no parts have been found + aStudyBuilder->RemoveObject(aSubSO); + } + } + } // try to build from published parts + } + } // process arguments + + return true; +} + +//============================================================================ +// function : RestoreSubShapesOneLevel +// purpose : Private method +//============================================================================ +GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theOldSO, + SALOMEDS::SObject_ptr theNewSO, + GEOM::GEOM_Object_ptr theNewO, + CORBA::Boolean isTrsf) +{ + int i = 0; + GEOM::ListOfGO_var aParts = new GEOM::ListOfGO; + if (CORBA::is_nil(theStudy) || CORBA::is_nil(theOldSO) || + CORBA::is_nil(theNewO) || CORBA::is_nil(theNewSO)) + return aParts._retn(); + + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + + // Get interface, containing method GetInPlace, which we will use to reconstruct sub-shapes + GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId()); + GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); + + // Reconstruct published sub-shapes + SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO); + + int aLen = 0; + for (it->Init(); it->More(); it->Next()) { + aLen++; + } + aParts->length(aLen); + + for (it->Init(); it->More(); it->Next()) { + SALOMEDS::SObject_var anOldSubSO = it->Value(); + + TCollection_AsciiString anArgName = anOldSubSO->GetName(); + + SALOMEDS::GenericAttribute_var anAttr; + if (anOldSubSO->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anAttrIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Object_var anOldSubO = + GEOM::GEOM_Object::_narrow(_orb->string_to_object(anAttrIOR->Value())); + if (!CORBA::is_nil(anOldSubO)) { + // Find a sub-shape of theNewO in place of anOldSubO + GEOM::GEOM_Object_var aNewSubO; + if (isTrsf) { + // transformation, cannot use GetInPlace, operate with indices + GEOM::ListOfLong_var anIDs = anOldSubO->GetSubShapeIndices(); + if (anIDs->length() > 1) { + // group + aNewSubO = aGroupOp->CreateGroup(theNewO, aGroupOp->GetType(anOldSubO)); + if (!CORBA::is_nil(aNewSubO)) + aGroupOp->UnionIDs(aNewSubO, anIDs); + } + else { + // single sub-shape + aNewSubO = aShapesOp->GetSubShape(theNewO, anIDs[0]); + } + } + else { + // not a transformation, so use GetInPlace + aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO); + } + + if (!CORBA::is_nil(aNewSubO)) { + // add the part to the list + aParts[i] = aNewSubO; + i++; + + // Publish the sub-shape + TCollection_AsciiString aSubName ("from_"); + aSubName += anArgName; + SALOMEDS::SObject_var aNewSubSO = aStudyBuilder->NewObject(theNewSO); + aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); + // Restore color + aNewSubO->SetColor(anOldSubO->GetColor()); + + // Restore published sub-shapes of the argument + RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, aNewSubO, isTrsf); + } + else { // GetInPlace failed, try to build from published parts + SALOMEDS::SObject_var aNewSubSO = aStudyBuilder->NewObject(theNewSO); + + // Restore published sub-shapes of the argument + GEOM::ListOfGO_var aParts = + RestoreSubShapesOneLevel(theStudy, anOldSubSO, aNewSubSO, theNewO, isTrsf); + + if (aParts->length() > 0) { + // try to build an object from a set of its sub-shapes, + // that published and will be reconstructed + if (aParts->length() > 1) { + aNewSubO = aShapesOp->MakeCompound(aParts); + } + else { + aNewSubO = aParts[0]; + } + + if (!CORBA::is_nil(aNewSubO)) { + // add the part to the list + aParts[i] = aNewSubO; + i++; + + // Publish the sub-shape + TCollection_AsciiString aSubName = "from_parts_of_"; + aSubName += anArgName; + aNewSubSO = PublishInStudy(theStudy, aNewSubSO, aNewSubO, aSubName.ToCString()); + // Restore color + aNewSubO->SetColor(anOldSubO->GetColor()); + } + } + else { + // remove created aSubSO, because no parts have been found + aStudyBuilder->RemoveObject(aNewSubSO); + } + } // try to build from published parts + } + } + } // iterate on published sub-shapes + + aParts->length(i); + return aParts._retn(); +} + //============================================================================ // function : register() // purpose : register 'name' in 'name_service' diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh index 30188801f..b1a9ef48e 100644 --- a/src/GEOM_I/GEOM_Gen_i.hh +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -133,6 +133,22 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi const char* theName, GEOM::GEOM_Object_ptr theFather); + /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments. + * To be used from python scripts out of geompy.addToStudy (non-default usage) + */ + CORBA::Boolean RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + const GEOM::ListOfGO& theArgs, + CORBA::Boolean isTrsf); + + /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments. + * To be used from GUI and from geompy.addToStudy + */ + CORBA::Boolean RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + const GEOM::ListOfGO& theArgs, + CORBA::Boolean isTrsf); + //-----------------------------------------------------------------------// // Transaction methods // //-----------------------------------------------------------------------// @@ -219,6 +235,19 @@ class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual publi virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry); + private: + GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theOldSO, + SALOMEDS::SObject_ptr theNewSO, + GEOM::GEOM_Object_ptr theNewO, + CORBA::Boolean isTrsf); + + CORBA::Boolean RestoreSubShapes (SALOMEDS::Study_ptr theStudy, + GEOM::GEOM_Object_ptr theObject, + SALOMEDS::SObject_ptr theSObject, + const GEOM::ListOfGO& theArgs, + CORBA::Boolean isTrsf); + private: ::GEOMImpl_Gen* _impl; diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index d9160b6b7..4b0a0c8e4 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -123,29 +123,57 @@ class geompyDC(GEOM._objref_GEOM_Gen): index = self.ShapesOp.GetTopologyIndex(aMainObj, aSubObj) name = self.ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index) return name - + ## Publish in study aShape with name aName # + # \param aShape the shape to be published + # \param aName the name for the shape + # \param doRestoreSubShapes if True, finds and publishes also + # sub-shapes of \a aShape, corresponding to its arguments + # and published sub-shapes of arguments + # \param theArgs,isTrsf see geompy.RestoreSubShapes for these arguments description + # \return study entry of the published shape in form of string + # # Example: see GEOM_TestAll.py - def addToStudy(self,aShape, aName): + def addToStudy(self, aShape, aName, + doRestoreSubShapes=False, theArgs=[], isTrsf=False): try: aSObject = self.AddInStudy(self.myStudy, aShape, aName, None) + if doRestoreSubShapes: + self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs, isTrsf) except: print "addToStudy() failed" return "" return aShape.GetStudyEntry() - + ## Publish in study aShape with name aName as sub-object of previously published aFather # # Example: see GEOM_TestAll.py - def addToStudyInFather(self,aFather, aShape, aName): + def addToStudyInFather(self, aFather, aShape, aName): try: aSObject = self.AddInStudy(myStudy, aShape, aName, aFather) except: print "addToStudyInFather() failed" return "" return aShape.GetStudyEntry() - + + ## Publish sub-shapes, standing for arguments and sub-shapes of arguments + # To be used from python scripts out of geompy.addToStudy (non-default usage) + # \param theStudy the study, in which theObject is published already, + # and in which the arguments will be published + # \param theObject published GEOM object, arguments of which will be published + # \param theArgs list of GEOM_Object, operation arguments to be published. + # If this list is empty, all operation arguments will be published + # \param isTrsf If True, search sub-shapes by indices, as in case of + # transformation they cannot be found by GetInPlace. + # The argument itself is not published in this case, + # because the whole shape corresponds to the argument. + # \return True in case of success, False otherwise. + # + # Example: see GEOM_TestAll.py + def RestoreSubShapes (self, theObject, theArgs=[], isTrsf=False): + return self.RestoreSubShapesO(self.myStudy, theObject, theArgs, isTrsf) + # ----------------------------------------------------------------------------- # Basic primitives # ----------------------------------------------------------------------------- diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index 2c736f5b7..a65e88de1 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -1,22 +1,22 @@ // GEOM GEOMGUI : GUI for Geometry component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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 -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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 // // @@ -36,6 +36,7 @@ #include "LightApp_SelectionMgr.h" #include +#include #include #include @@ -43,7 +44,7 @@ //================================================================================= // class : OperationGUI_PartitionDlg() -// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the +// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -111,24 +112,24 @@ void OperationGUI_PartitionDlg::Init() GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX")); GroupPoints->radioButton4->setChecked(FALSE); + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); - - connect(GroupPoints->radioButton4, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int))); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + initName( tr( "GEOM_PARTITION" ) ); ConstructorsClicked( 0 ); } @@ -142,7 +143,7 @@ void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); globalSelection(); - + myListShapes.length(0); myListTools.length(0); myListKeepInside.length(0); @@ -203,9 +204,9 @@ void OperationGUI_PartitionDlg::ClickOnOk() //================================================================================= bool OperationGUI_PartitionDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; - + initName(); ConstructorsClicked( getConstructorId() ); return true; @@ -220,7 +221,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() { myEditCurrentArgument->setText( "" ); QString aString = ""; - + int nbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aString, true ); if ( nbSel < 1 ) @@ -233,15 +234,15 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myListTools.length( 0 ); } - + // One and only one plane can be selected - + if ( getConstructorId() == 1 && myEditCurrentArgument == GroupPoints->LineEdit2 && nbSel != 1 ) { myListTools.length( 0 ); return; } - + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myListShapes, true ); @@ -255,7 +256,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() if ( !myListTools.length() ) return; } - + myEditCurrentArgument->setText( aString ); } @@ -267,7 +268,7 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() void OperationGUI_PartitionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - + if(send == GroupPoints->PushButton1) myEditCurrentArgument = GroupPoints->LineEdit1; else if(send == GroupPoints->PushButton2) @@ -276,7 +277,7 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument() if( getConstructorId()==1 ) globalSelection( GEOM_PLANE ); } - + globalSelection( GEOM_ALLSHAPES ); myEditCurrentArgument->setFocus(); @@ -389,20 +390,22 @@ bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) return res; } - //================================================================================= -// function : closeEvent +// function : restoreSubShapes // purpose : //================================================================================= -void OperationGUI_PartitionDlg::closeEvent( QCloseEvent* e ) +void OperationGUI_PartitionDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - GEOMBase_Skeleton::closeEvent( e ); + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/false); + } } - //======================================================================= //function : ComboTextChanged -//purpose : +//purpose : //======================================================================= void OperationGUI_PartitionDlg::ComboTextChanged() { @@ -415,10 +418,9 @@ void OperationGUI_PartitionDlg::ComboTextChanged() //GroupPoints->PushButton4->setEnabled(IsEnabled); } - //================================================================================= // function : GetLimit() -// purpose : +// purpose : //================================================================================= int OperationGUI_PartitionDlg::GetLimit() const { diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h index ba321be37..32f55999c 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.h +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -36,7 +36,7 @@ // purpose : //================================================================================= class OperationGUI_PartitionDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -54,8 +54,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - - virtual void closeEvent( QCloseEvent* e ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index 345ce98fe..ec455e172 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -1,23 +1,23 @@ // GEOM GEOMGUI : GUI for Geometry component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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 +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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 // // // @@ -51,7 +51,7 @@ using namespace std; //================================================================================= // class : TransformationGUI_MirrorDlg() -// purpose : Constructs a TransformationGUI_MirrorDlg which is a child of 'parent', with the +// purpose : Constructs a TransformationGUI_MirrorDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -73,7 +73,7 @@ TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg(GeometryGUI* theGeometr RadioButton1->setPixmap(image0); RadioButton2->setPixmap(image1); RadioButton3->setPixmap(image2); - + GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); GroupPoints->SpinBox_DX->hide(); GroupPoints->TextLabel3->hide(); @@ -88,8 +88,8 @@ TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg(GeometryGUI* theGeometr Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ - setHelpFileName("mirror_operation_page.html"); - + setHelpFileName("mirror_operation_page.html"); + Init(); } @@ -99,7 +99,7 @@ TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg(GeometryGUI* theGeometr // purpose : Destroys the object and frees any allocated resources //================================================================================= TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg() -{ +{ /* no need to delete child widgets, Qt does it all for us */ } @@ -109,18 +109,20 @@ TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg() // purpose : //================================================================================= void TransformationGUI_MirrorDlg::Init() -{ +{ /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit2->setReadOnly(true); - + myArgument = GEOM::GEOM_Object::_nil(); - + // Activate Create a Copy mode GroupPoints->CheckButton1->setChecked(true); CreateCopyModeChanged(true); + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -131,10 +133,10 @@ void TransformationGUI_MirrorDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); - - connect(myGeomGUI->getApp()->selectionMgr(), + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_MIRROR" ) ); @@ -149,16 +151,16 @@ void TransformationGUI_MirrorDlg::Init() void TransformationGUI_MirrorDlg::ConstructorsClicked(int constructorId) { disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); - + globalSelection(); myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit2->clear(); myArgument = GEOM::GEOM_Object::_nil(); - + switch (constructorId) { case 0: /* mirror an object by point */ - { + { GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR")); break; } @@ -166,14 +168,14 @@ void TransformationGUI_MirrorDlg::ConstructorsClicked(int constructorId) { GroupPoints->TextLabel2->setText(tr("GEOM_AXE_MIRROR")); break; - } + } case 2: /* mirror an object by plane */ { GroupPoints->TextLabel2->setText(tr("GEOM_PLANE_MIRROR")); break; } } - connect(myGeomGUI->getApp()->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } @@ -198,7 +200,7 @@ bool TransformationGUI_MirrorDlg::ClickOnApply() { if ( !onAccept(GroupPoints->CheckButton1->isChecked()) ) return false; - + initName(); ConstructorsClicked( getConstructorId() ); return true; @@ -253,7 +255,7 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() aNeedType = TopAbs_EDGE; else if (getConstructorId() == 2) aNeedType = TopAbs_FACE; - + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes( firstIObject(), aMap ); @@ -264,10 +266,10 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() aName += QString(":vertex_%1").arg(anIndex); else aName += QString(":edge_%1").arg(anIndex); - + //Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); - + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); @@ -286,8 +288,8 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() } } myEditCurrentArgument->setText( aName ); - - displayPreview(); + + displayPreview(); } @@ -315,7 +317,7 @@ void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); globalSelection(); - + if(send == GroupPoints->PushButton1){ myEditCurrentArgument = GroupPoints->LineEdit1; } @@ -353,7 +355,7 @@ void TransformationGUI_MirrorDlg::SetEditCurrentArgument() void TransformationGUI_MirrorDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(myGeomGUI->getApp()->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); } @@ -398,24 +400,26 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects ) { bool res = false; bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); - + GEOM::GEOM_Object_var anObj; - - switch ( getConstructorId() ) + + switch ( getConstructorId() ) { case 0 : { if (toCreateCopy) for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPointCopy( myObjects[i], myArgument ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + MirrorPointCopy( myObjects[i], myArgument ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } else for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPoint( myObjects[i], myArgument ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + MirrorPoint( myObjects[i], myArgument ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } @@ -427,14 +431,16 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects ) if (toCreateCopy) for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorAxisCopy( myObjects[i], myArgument ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + MirrorAxisCopy( myObjects[i], myArgument ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } else for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorAxis( myObjects[i], myArgument ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + MirrorAxis( myObjects[i], myArgument ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } @@ -446,14 +452,16 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects ) if (toCreateCopy) for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlaneCopy( myObjects[i], myArgument ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + MirrorPlaneCopy( myObjects[i], myArgument ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } else for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlane( myObjects[i], myArgument ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + MirrorPlane( myObjects[i], myArgument ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } @@ -461,20 +469,23 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects ) break; } } - + return res; } //================================================================================= -// function : closeEvent +// function : restoreSubShapes // purpose : //================================================================================= -void TransformationGUI_MirrorDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_MirrorDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - GEOMBase_Skeleton::closeEvent( e ); + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true); + } } - //================================================================================= // function : CreateCopyModeChanged() // purpose : diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.h b/src/TransformationGUI/TransformationGUI_MirrorDlg.h index 25f576739..da101f7cb 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.h +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -32,14 +32,14 @@ #include "DlgRef_2Sel1Spin2Check.h" #include "TransformationGUI.h" - + //================================================================================= // class : TransformationGUI_MirrorDlg // purpose : //================================================================================= class TransformationGUI_MirrorDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -53,18 +53,18 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); virtual void addSubshapesToStudy(); - virtual void closeEvent( QCloseEvent* e ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); void enterEvent(QEvent* e); - + GEOM::GEOM_Object_var myArgument; GEOM::ListOfGO myObjects; - + DlgRef_2Sel1Spin2Check* GroupPoints; - -private slots : + +private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx index 862faabe7..724381ac0 100644 --- a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -115,6 +115,8 @@ void TransformationGUI_OffsetDlg::Init() GroupPoints->CheckButton1->setChecked(true); CreateCopyModeChanged(true); + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -281,7 +283,6 @@ bool TransformationGUI_OffsetDlg::isValid( QString& msg ) return true; } - //================================================================================= // function : execute // purpose : @@ -315,16 +316,18 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects ) } //================================================================================= -// function : closeEvent +// function : restoreSubShapes // purpose : //================================================================================= -void TransformationGUI_OffsetDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_OffsetDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - // myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::closeEvent( e ); + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true); + } } - //================================================================================= // function : GetOffset() // purpose : @@ -334,7 +337,6 @@ double TransformationGUI_OffsetDlg::GetOffset() const return GroupPoints->SpinBox_DX->GetValue(); } - //================================================================================= // function : CreateCopyModeChanged() // purpose : diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.h b/src/TransformationGUI/TransformationGUI_OffsetDlg.h index a49cdd87f..d034cc1b9 100644 --- a/src/TransformationGUI/TransformationGUI_OffsetDlg.h +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -30,14 +30,14 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel1Spin1Check.h" - - + + //================================================================================= // class : TransformationGUI_OffsetDlg // purpose : //================================================================================= class TransformationGUI_OffsetDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -50,18 +50,17 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - - virtual void closeEvent( QCloseEvent* e ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); void enterEvent(QEvent* e); double GetOffset() const; - + GEOM::ListOfGO myObjects; - + DlgRef_1Sel1Spin1Check* GroupPoints; - + private slots: void ClickOnOk(); bool ClickOnApply(); diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx index 721f5b9d7..14c4df459 100644 --- a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx @@ -1,8 +1,8 @@ // GEOM GEOMGUI : GUI for Geometry component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// // 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 @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -46,7 +46,7 @@ using namespace std; //================================================================================= // class : TransformationGUI_PositionDlg() -// purpose : Constructs a TransformationGUI_PositionDlg which is a child of 'parent', with the +// purpose : Constructs a TransformationGUI_PositionDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. @@ -68,7 +68,7 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg RadioButton1->setPixmap(image0); RadioButton2->setPixmap(image1); RadioButton3->close(TRUE); - + Group1 = new DlgRef_3Sel3Spin1Check(this, "Group1"); Group1->SpinBox1->hide(); Group1->SpinBox2->hide(); @@ -86,11 +86,11 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg Group1->CheckBox1->setText(tr("GEOM_CREATE_COPY")); Layout1->addWidget(Group1, 2, 0); - + /***************************************************************/ - setHelpFileName("modify_location_operation_page.html"); - + setHelpFileName("modify_location_operation_page.html"); + Init(); } @@ -100,7 +100,7 @@ TransformationGUI_PositionDlg::TransformationGUI_PositionDlg // purpose : Destroys the object and frees any allocated resources //================================================================================= TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg() -{ +{ /* no need to delete child widgets, Qt does it all for us */ } @@ -110,19 +110,21 @@ TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg() // purpose : //================================================================================= void TransformationGUI_PositionDlg::Init() -{ +{ /* init variables */ Group1->LineEdit1->setReadOnly(true); Group1->LineEdit2->setReadOnly(true); Group1->LineEdit3->setReadOnly(true); - + myStartLCS = GEOM::GEOM_Object::_nil(); myEndLCS = GEOM::GEOM_Object::_nil(); - + // Activate Create a Copy mode Group1->CheckBox1->setChecked(true); CreateCopyModeChanged(true); + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -135,10 +137,10 @@ void TransformationGUI_PositionDlg::Init() connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(Group1->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + connect(Group1->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); - - connect(myGeomGUI->getApp()->selectionMgr(), + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_POSITION" ) ); @@ -154,14 +156,14 @@ void TransformationGUI_PositionDlg::Init() void TransformationGUI_PositionDlg::ConstructorsClicked(int constructorId) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - + globalSelection(); myEditCurrentArgument = Group1->LineEdit1; Group1->LineEdit2->clear(); Group1->LineEdit3->clear(); myStartLCS = GEOM::GEOM_Object::_nil(); myEndLCS = GEOM::GEOM_Object::_nil(); - + switch (constructorId) { case 0: @@ -179,7 +181,7 @@ void TransformationGUI_PositionDlg::ConstructorsClicked(int constructorId) break; } } - connect(myGeomGUI->getApp()->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); SelectionIntoArgument(); } @@ -204,7 +206,7 @@ bool TransformationGUI_PositionDlg::ClickOnApply() { if ( !onAccept(Group1->CheckBox1->isChecked()) ) return false; - + initName(); ConstructorsClicked( getConstructorId() ); return true; @@ -254,7 +256,7 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument() displayPreview(); return; } - + Standard_Boolean testResult = Standard_False; myEndLCS = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); if(!testResult || CORBA::is_nil( myEndLCS )) { @@ -265,7 +267,7 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument() } myEditCurrentArgument->setText( aName ); - displayPreview(); + displayPreview(); } @@ -290,7 +292,7 @@ void TransformationGUI_PositionDlg::LineEditReturnPressed() void TransformationGUI_PositionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - + if(send == Group1->PushButton1){ myEditCurrentArgument = Group1->LineEdit1; globalSelection(); @@ -322,7 +324,7 @@ void TransformationGUI_PositionDlg::SetEditCurrentArgument() void TransformationGUI_PositionDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(myGeomGUI->getApp()->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); } @@ -374,16 +376,18 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects ) bool res = false; bool toCreateCopy = IsPreview() || Group1->CheckBox1->isChecked(); GEOM::GEOM_Object_var anObj; - + switch ( getConstructorId() ) { case 0 : { for (int i = 0; i < myObjects.length(); i++) { if (toCreateCopy) - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS ); else - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShape( myObjects[i], myObjects[i], myEndLCS ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + PositionShape( myObjects[i], myObjects[i], myEndLCS ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); @@ -395,9 +399,11 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects ) { for (int i = 0; i < myObjects.length(); i++) { if (toCreateCopy) - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS ); else - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShape( myObjects[i], myStartLCS, myEndLCS ); + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> + PositionShape( myObjects[i], myStartLCS, myEndLCS ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } @@ -405,20 +411,23 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects ) break; } } - + return res; } //================================================================================= -// function : closeEvent +// function : restoreSubShapes // purpose : //================================================================================= -void TransformationGUI_PositionDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - GEOMBase_Skeleton::closeEvent( e ); + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true); + } } - //================================================================================= // function : CreateCopyModeChanged() // purpose : diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.h b/src/TransformationGUI/TransformationGUI_PositionDlg.h index 9ecfb2809..3b6fd161a 100644 --- a/src/TransformationGUI/TransformationGUI_PositionDlg.h +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -32,14 +32,14 @@ #include "DlgRef_3Sel3Spin1Check.h" #include "TransformationGUI.h" - + //================================================================================= // class : TransformationGUI_PositionDlg // purpose : //================================================================================= class TransformationGUI_PositionDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -52,19 +52,18 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); - - virtual void closeEvent( QCloseEvent* e ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); void enterEvent(QEvent* e); - + GEOM::GEOM_Object_var myStartLCS; GEOM::GEOM_Object_var myEndLCS; GEOM::ListOfGO myObjects; - + DlgRef_3Sel3Spin1Check* Group1; - + private slots: void ClickOnOk(); bool ClickOnApply(); diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index f0cca0130..ee3e34ed2 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -106,6 +106,8 @@ TransformationGUI_RotationDlg::TransformationGUI_RotationDlg GroupPoints->CheckButton1->setChecked(true); CreateCopyModeChanged(true); + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -306,7 +308,7 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() } } } - + if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) myAxis = aSelectedObject; else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) @@ -502,17 +504,19 @@ bool TransformationGUI_RotationDlg::execute( ObjectList& objects ) return res; } - //================================================================================= -// function : closeEvent +// function : restoreSubShapes // purpose : //================================================================================= -void TransformationGUI_RotationDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - GEOMBase_Skeleton::closeEvent( e ); + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true); + } } - //================================================================================= // function : GetAngle() // purpose : diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h index 4ea6ea9e5..80fd4aad0 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -30,13 +30,13 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_4Sel1Spin2Check.h" - + //================================================================================= // class : TransformationGUI_RotationDlg // purpose : //================================================================================= class TransformationGUI_RotationDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -50,16 +50,16 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); virtual void addSubshapesToStudy(); - virtual void closeEvent( QCloseEvent* e ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); void enterEvent(QEvent* e); double GetAngle() const; - + GEOM::ListOfGO myObjects; GEOM::GEOM_Object_var myAxis, myCentPoint, myPoint1, myPoint2; - + DlgRef_4Sel1Spin2Check* GroupPoints; private slots: diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index 7a992b2ae..5177f4455 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -98,6 +98,8 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(GeometryGUI* theGeometryG GroupPoints->CheckButton1->setChecked(true); CreateCopyModeChanged(true); + GroupBoxPublish->show(); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -202,7 +204,7 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument() Standard_Boolean testResult = Standard_False; GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult ); aName = GEOMBase::GetName( aSelectedObject ); - + TopoDS_Shape aShape; if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { @@ -216,7 +218,7 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument() //Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); - + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); @@ -370,17 +372,19 @@ bool TransformationGUI_ScaleDlg::execute( ObjectList& objects ) return res; } - //================================================================================= -// function : closeEvent +// function : restoreSubShapes // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_ScaleDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) { - GEOMBase_Skeleton::closeEvent( e ); + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true); + } } - //================================================================================= // function : GetFactor() // purpose : diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h index 7f77c6b42..ac700aac4 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.h +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -30,14 +30,14 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_2Sel1Spin2Check.h" - - + + //================================================================================= // class : TransformationGUI_ScaleDlg // purpose : //================================================================================= class TransformationGUI_ScaleDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -51,7 +51,7 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); virtual void addSubshapesToStudy(); - virtual void closeEvent( QCloseEvent* e ); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private : void Init(); @@ -60,7 +60,7 @@ private : GEOM::ListOfGO myObjects; GEOM::GEOM_Object_var myPoint; /* Central Point */ - + DlgRef_2Sel1Spin2Check* GroupPoints; private slots: diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index 86b57cb84..f197f92d4 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -128,6 +128,8 @@ void TransformationGUI_TranslationDlg::Init() GroupPoints->CheckBox2->setChecked(true); CreateCopyModeChanged(true); + GroupBoxPublish->show(); + /* Get setting of step value from file configuration */ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100); @@ -307,41 +309,42 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() TopoDS_Shape aShape; aName = GEOMBase::GetName( aSelectedObject ); if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) + aNeedType = TopAbs_EDGE; + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) { - TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; - if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) - aNeedType = TopAbs_EDGE; - - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes( firstIObject(), aMap ); - if ( aMap.Extent() == 1 ) - { - int anIndex = aMap( 1 ); - if (aNeedType == TopAbs_EDGE) - aName += QString(":edge_%1").arg(anIndex); - else - aName += QString(":vertex_%1").arg(anIndex); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); - - if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study - GEOM::GEOM_IShapesOperations_var aShapesOp = - getGeomEngine()->GetIShapesOperations( getStudyId() ); - aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); - } - else - aSelectedObject = aFindedObject; - } else // Global Selection - { - if (aShape.ShapeType() != aNeedType) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } - } + int anIndex = aMap( 1 ); + if (aNeedType == TopAbs_EDGE) + aName += QString(":edge_%1").arg(anIndex); + else + aName += QString(":vertex_%1").arg(anIndex); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); + } + else + aSelectedObject = aFindedObject; + } + else // Global Selection + { + if (aShape.ShapeType() != aNeedType) { + aSelectedObject = GEOM::GEOM_Object::_nil(); + aName = ""; + } } - + } + if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) myPoint1 = aSelectedObject; else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) @@ -386,7 +389,7 @@ void TransformationGUI_TranslationDlg::SetEditCurrentArgument() myEditCurrentArgument = GroupPoints->LineEdit2; if (getConstructorId() == 1) localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - else + else localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); } else if (send == GroupPoints->PushButton3) { @@ -578,6 +581,18 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects ) return res; } +//================================================================================= +// function : restoreSubShapes +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject) +{ + if (CheckBoxRestoreSS->isChecked()) { + // empty list of arguments means that all arguments should be restored + getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(), /*isTrsf=*/true); + } +} //================================================================================= // function : CreateCopyModeChanged() diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h index ea612c6be..9aefe3c76 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -37,7 +37,7 @@ // purpose : //================================================================================= class TransformationGUI_TranslationDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: @@ -51,6 +51,7 @@ protected: virtual bool isValid( QString& ); virtual bool execute( ObjectList& objects ); virtual void addSubshapesToStudy(); + virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr); private: void Init(); -- 2.39.2