From: jfa Date: Fri, 21 Dec 2012 13:13:33 +0000 (+0000) Subject: Mantis issue 0021852: EDF 1680 GEOM: Publish 'Check free boundaries' results in the... X-Git-Tag: V6_main_FINAL~82 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d45b760938e98b786a297c3c35f737ec3e674946;p=modules%2Fgeom.git Mantis issue 0021852: EDF 1680 GEOM: Publish 'Check free boundaries' results in the Object Browser --- diff --git a/doc/salome/gui/GEOM/images/repair9.png b/doc/salome/gui/GEOM/images/repair9.png index 72b7d32af..04c3035f2 100755 Binary files a/doc/salome/gui/GEOM/images/repair9.png and b/doc/salome/gui/GEOM/images/repair9.png differ diff --git a/doc/salome/gui/GEOM/input/boudaries.doc b/doc/salome/gui/GEOM/input/boudaries.doc index 65acdc06a..de1e84a73 100644 --- a/doc/salome/gui/GEOM/input/boudaries.doc +++ b/doc/salome/gui/GEOM/input/boudaries.doc @@ -2,8 +2,10 @@ \page boundaries_page Check Free Boundaries -Detects and highlights wires and edges that are not shared between +Detects and highlights wires and edges that are not shared between two faces and are considered a shape's boundary. +
Creates corresponding objects and publishes them into the study on +"Apply" or "Apply and Close". TUI Command: (NoError, ClosedWires, OpenWires) = geompy.GetFreeBoundary(Shape), where \em Shape is a shape to be @@ -15,4 +17,4 @@ See also a \ref tui_free_boundaries_page "TUI example". \image html repair9.png -*/ \ No newline at end of file +*/ diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx index a03687eab..c50811b82 100644 --- a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx @@ -509,7 +509,7 @@ GEOM::GEOM_Object_ptr BlocksGUI_ExplodeDlg::getFather( GEOM::GEOM_Object_ptr ) // Function : getNewObjectName // Purpose : Redefine this method to return proper name for a new object //================================================================ -QString BlocksGUI_ExplodeDlg::getNewObjectName() const +QString BlocksGUI_ExplodeDlg::getNewObjectName (int) const { return QString::null; } diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.h b/src/BlocksGUI/BlocksGUI_ExplodeDlg.h index 6be87bef4..1f396ccc5 100644 --- a/src/BlocksGUI/BlocksGUI_ExplodeDlg.h +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.h @@ -50,7 +50,7 @@ protected: virtual bool execute( ObjectList& ); virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr ); - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; private: void Init(); diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index 5facd0411..3de5f8e89 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -831,7 +831,7 @@ GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather(GEOM::GEOM_Object_ptr) // Function : getNewObjectName // Purpose : //================================================================ -QString EntityGUI_SubShapeDlg::getNewObjectName() const +QString EntityGUI_SubShapeDlg::getNewObjectName (int) const { return QString::null; } diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.h b/src/EntityGUI/EntityGUI_SubShapeDlg.h index d9bf30a3f..816059e86 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.h +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.h @@ -51,7 +51,7 @@ protected: virtual bool isValid (QString&); virtual bool execute (ObjectList&); virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; void closeEvent (QCloseEvent*); diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 53d2c0ecc..912dd15f6 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Helper.cxx // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) -// + #include "GEOMBase_Helper.h" #include "GEOMBase.h" #include "GEOM_Operation.h" @@ -858,11 +857,11 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b addSubshapesToStudy(); // add Sub-shapes if local selection const int nbObjs = objects.size(); QStringList anEntryList; - int aNumber = 1; - for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { + int currObj = 1, aNumber = 1; + for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it, currObj++ ) { GEOM::GEOM_Object_var obj=*it; if ( publish ) { - QString aName = getNewObjectName(); + QString aName = getNewObjectName(currObj); if ( nbObjs > 1 ) { if (aName.isEmpty()) aName = getPrefix(obj); @@ -1006,7 +1005,7 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj ) // Function : getNewObjectName // Purpose : Redefine this method to return proper name for a new object //================================================================ -QString GEOMBase_Helper::getNewObjectName() const +QString GEOMBase_Helper::getNewObjectName (int) const { return QString::null; } diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 5d32fd268..87d96cfd4 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Helper.h // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) -// + #ifndef GEOMBASE_HELPER_H #define GEOMBASE_HELPER_H @@ -51,7 +50,7 @@ class TColStd_MapOfInteger; //================================================================ // Class : GEOMBase_Helper -// Description : Helper class for dialog box development, can be used as +// Description : Helper class for dialog box development, can be used as // the second base class for dialog boxes. Contains convenient methods // performing common operations (display/erase, selection activation, // publication in a study, transaction management) @@ -73,24 +72,24 @@ protected: void redisplay ( GEOM::GEOM_Object_ptr, const bool = true, const bool = true ); virtual void displayPreview ( const bool display, - const bool activate = false, + const bool activate = false, const bool update = true, const bool toRemoveFromEngine = true, - const double lineWidth = -1, + const double lineWidth = -1, const int displayMode = -1, const int color = -1 ); // This is the easiest way to show preview. It is based on execute() method. // It removes temporary GEOM::GEOM_Objects automatically. - virtual void displayPreview ( GEOM::GEOM_Object_ptr obj, - const bool append = false, - const bool activate = false, + virtual void displayPreview ( GEOM::GEOM_Object_ptr obj, + const bool append = false, + const bool activate = false, const bool update = true, - const double lineWidth = -1, + const double lineWidth = -1, const int displayMode = -1, const int color = -1 ); - void displayPreview ( const SALOME_Prs* prs, - const bool append = false, + void displayPreview ( const SALOME_Prs* prs, + const bool append = false, const bool = true ); void erasePreview ( const bool = true ); @@ -105,7 +104,7 @@ protected: void prepareSelection( const ObjectList&, const int ); void prepareSelection( GEOM::GEOM_Object_ptr, const int ); - QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); + QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); bool openCommand (); bool abortCommand (); @@ -119,7 +118,7 @@ protected: bool onAccept( const bool publish = true, const bool useTransaction = true, bool erasePreviewFlag = true); // This method should be called from "OK" button handler. - // == true means that objects returned by execute() + // == true means that objects returned by execute() // should be published in a study. void showError(); @@ -134,16 +133,16 @@ protected: inline void setPrefix( const QString& prefix ) { myPrefix = prefix; } QString getPrefix( GEOM::GEOM_Object_ptr = GEOM::GEOM_Object::_nil() ) const; - + bool selectObjects( ObjectList& objects ); - // Selects list of objects + // Selects list of objects //////////////////////////////////////////////////////////////////////////// // Virtual methods, to be redefined in dialog classes //////////////////////////////////////////////////////////////////////////// virtual GEOM::GEOM_IOperations_ptr createOperation(); - // This method should be redefined in dialog boxes so as to return + // This method should be redefined in dialog boxes so as to return // proper GEOM_IOperation interface. // Returns nil reference by default @@ -151,9 +150,9 @@ protected: // Called by onAccept(). Redefine this method to check validity of user input in dialog boxes. virtual bool execute( ObjectList& objects ); - // This method is called by onAccept(). - // It should perform the required operation and put all new or modified objects into - // argument.Should return if some error occurs during its execution. + // This method is called by onAccept(). + // 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(). @@ -163,7 +162,7 @@ protected: // for or a nil reference if should be published // as a top-level object. - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; virtual bool extractPrefix() const; virtual void addSubshapesToStudy(); @@ -187,12 +186,11 @@ protected: virtual void setIsOptimizedBrowsing( const bool theFlag ); virtual bool isOptimizedBrowsing() const; - + virtual void setIsWaitCursorEnabled( const bool theFlag ) {myIsWaitCursorEnabled = theFlag;} virtual bool isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;} virtual void setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; } virtual bool isDisableBrowsing() const { return myIsDisableBrowsing; } - private: QString getEntry( GEOM::GEOM_Object_ptr ) const; @@ -213,9 +211,8 @@ private: bool myIsApplyAndClose; bool myIsOptimizedBrowsing; bool myIsWaitCursorEnabled; - bool myIsDisableBrowsing; //This flag enable/disable selection + bool myIsDisableBrowsing; //This flag enable/disable selection //in the Object Browser newly created objects. - }; #endif // GEOMBASE_HELPER_H diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx index 57be34955..d6f286425 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.cxx +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Skeleton.cxx // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #include "GEOMBase_Skeleton.h" #include "GEOMBase.h" @@ -293,7 +292,7 @@ void GEOMBase_Skeleton::initName( const QString& thePrefix ) // function : getNewObjectName() // purpose : returns contents of Name field //================================================================================= -QString GEOMBase_Skeleton::getNewObjectName() const +QString GEOMBase_Skeleton::getNewObjectName (int) const { return myMainFrame->ResultName->text(); } diff --git a/src/GEOMBase/GEOMBase_Skeleton.h b/src/GEOMBase/GEOMBase_Skeleton.h index bb6d75434..73bf0d2a2 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.h +++ b/src/GEOMBase/GEOMBase_Skeleton.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Skeleton.h // Author : Damine COQUERET, Open CASCADE S.A.S. -// + #ifndef GEOMBASE_SKELETON_H #define GEOMBASE_SKELETON_H @@ -74,7 +73,7 @@ protected: /*! returns contents of "Name" field */ - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; /*! returns id of a selected "constructor" radio button or '-1' in case of error */ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 9cd7e615e..e375fc5d5 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -259,6 +259,10 @@ ICON_DLG_FREE_FACES free_faces.png + + ICON_DLG_FREE_BOUNDS + free_bound.png + ICON_DLG_FUSE fuse.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 9abe92cbc..064abaa7f 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -5414,6 +5414,14 @@ Number of sketch points too small NUMBER_OPEN Number of open free boundaries: + + NAME_CLOSED + Closed_Free_Boundary_%1 + + + NAME_OPEN + Open_Free_Boundary_%1 + RepairGUI_GlueDlg diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx index 3ef492fcc..6f76359f6 100644 --- a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx @@ -18,15 +18,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : RepairGUI_FreeBoundDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com) -// + #include "RepairGUI_FreeBoundDlg.h" #include +#include + #include #include #include @@ -51,7 +52,7 @@ #include #define SPACING 6 -#define MARGIN 9 +#define MARGIN 0 /*! Class : RepairGUI_FreeBoundDlg @@ -62,59 +63,55 @@ // function : RepairGUI_FreeBoundDlg // purpose : Constructor //================================================================================= -RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( GeometryGUI* theGUI, QWidget* theParent ) - : QDialog( theParent, 0 ), - GEOMBase_Helper( dynamic_cast( theParent ) ), - myGeomGUI( theGUI ) +RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg (GeometryGUI* theGUI, QWidget* theParent) + : GEOMBase_Skeleton(theGUI, theParent) { - setAttribute( Qt::WA_DeleteOnClose ); - - setWindowTitle( tr( "CAPTION" ) ); - - QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - - QGroupBox* aMainGrp = new QGroupBox( tr( "FREE_BOUND" ), this ); - - QLabel* lab = new QLabel( tr( "GEOM_OBJECT" ), aMainGrp ); - QPushButton* btn = new QPushButton( aMainGrp ); - btn->setIcon( iconSelect ); - myEdit = new QLineEdit( aMainGrp ); - myEdit->setReadOnly( true ); - myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - myClosedLbl = new QLabel( tr( "NUMBER_CLOSED" ), aMainGrp ); - myOpenLbl = new QLabel( tr( "NUMBER_OPEN" ), aMainGrp ); - myClosedLbl->setMinimumWidth( 150 ); - myOpenLbl->setMinimumWidth( 150 ); - - QGridLayout* aMainGrpLayout = new QGridLayout( aMainGrp ); - aMainGrpLayout->setMargin( MARGIN ); aMainGrpLayout->setSpacing( SPACING ); - aMainGrpLayout->addWidget( lab, 0, 0 ); - aMainGrpLayout->addWidget( btn, 0, 1 ); - aMainGrpLayout->addWidget( myEdit, 0, 2 ); - aMainGrpLayout->addWidget( myClosedLbl, 1, 0, 1, 3 ); - aMainGrpLayout->addWidget( myOpenLbl, 2, 0, 1, 3 ); - - QFrame* aFrame = new QFrame( this ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); - QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame ); - QPushButton* aHelpBtn = new QPushButton( tr( "GEOM_BUT_HELP" ), aFrame ); - QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame ); - aBtnLay->setMargin( MARGIN ); aBtnLay->setSpacing( SPACING ); - aBtnLay->addWidget( aCloseBtn ); - aBtnLay->addSpacing( SPACING ); aBtnLay->addStretch(); - aBtnLay->addWidget( aHelpBtn ); - - QVBoxLayout* aLay = new QVBoxLayout( this ); - aLay->setSpacing( SPACING ); - aLay->setMargin( MARGIN ); - aLay->addWidget( aMainGrp ); - aLay->addWidget( aFrame ); - - myHelpFileName = "using_measurement_tools_page.html#boundaries_anchor"; - - connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); - connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) ); + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FREE_BOUNDS"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("CAPTION")); + + /***************************************************************/ + + mainFrame()->GroupConstructors->setTitle(tr("FREE_BOUND")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + mainFrame()->GroupBoxName->hide(); + + QGroupBox* aMainGrp = new QGroupBox (tr("FREE_BOUND"), this); + + QLabel* lab = new QLabel (tr("GEOM_OBJECT"), aMainGrp); + QPushButton* btn = new QPushButton (aMainGrp); + btn->setIcon(image1); + myEdit = new QLineEdit (aMainGrp); + myEdit->setReadOnly(true); + myEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + + myClosedLbl = new QLabel (tr("NUMBER_CLOSED"), aMainGrp); + myOpenLbl = new QLabel (tr("NUMBER_OPEN"), aMainGrp); + myClosedLbl->setMinimumWidth(150); + myOpenLbl->setMinimumWidth(150); + + QGridLayout* aMainGrpLayout = new QGridLayout (aMainGrp); + aMainGrpLayout->addWidget(lab, 0, 0); + aMainGrpLayout->addWidget(btn, 0, 1); + aMainGrpLayout->addWidget(myEdit, 0, 2); + aMainGrpLayout->addWidget(myClosedLbl, 1, 0, 1, 3); + aMainGrpLayout->addWidget(myOpenLbl, 2, 0, 1, 3); + + QVBoxLayout* aLay = new QVBoxLayout (centralWidget()); + aLay->setSpacing(SPACING); + aLay->setMargin(MARGIN); + aLay->addWidget(aMainGrp); + + resize(minimumSizeHint()); + /***************************************************************/ + + myHelpFileName = "boundaries_page.html"; Init(); } @@ -128,126 +125,99 @@ RepairGUI_FreeBoundDlg::~RepairGUI_FreeBoundDlg() } //================================================================================= -// function : onClose -// purpose : SLOT. Called when "close" button pressed. Close dialog +// function : Init +// purpose : Initialize dialog fields //================================================================================= -void RepairGUI_FreeBoundDlg::onClose() +void RepairGUI_FreeBoundDlg::Init() { - globalSelection(); - disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 ); - myGeomGUI->SetActiveDialogBox( 0 ); - reject(); - erasePreview(); + myNbClosed = myNbOpen = 0; + myObj = GEOM::GEOM_Object::_nil(); + + myEditCurrentArgument = myEdit; + + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + activateSelection(); + SelectionIntoArgument(); } //================================================================================= -// function : onHelp() +// function : ClickOnOk() // purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onHelp() +void RepairGUI_FreeBoundDlg::ClickOnOk() { - LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() ); - if ( app ) - app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName ); - else { - QString platform; -#ifdef WIN32 - platform = "winapplication"; -#else - platform = "application"; -#endif - SUIT_MessageBox::warning( this, - tr( "WRN_WARNING" ), - tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg( app->resourceMgr()->stringValue( "ExternalBrowser", - platform ) ).arg( myHelpFileName ) ); - } + if (ClickOnApply()) + ClickOnCancel(); } //================================================================================= -// function : onDeactivate -// purpose : Deactivate this dialog +// function : ClickOnApply() +// purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onDeactivate() +bool RepairGUI_FreeBoundDlg::ClickOnApply() { - setEnabled( false ); - globalSelection(); - disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); - myGeomGUI->SetActiveDialogBox( 0 ); + if (!onAccept()) + return false; + return true; } //================================================================================= -// function : onActivate -// purpose : Activate this dialog +// function : ActivateThisDialog() +// purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onActivate() +void RepairGUI_FreeBoundDlg::ActivateThisDialog() { - myGeomGUI->EmitSignalDeactivateDialog(); - setEnabled( true ); - myGeomGUI->SetActiveDialogBox( this ); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + activateSelection(); - onSelectionDone(); + displayPreview(true); } //================================================================================= -// function : onSelectionDone -// purpose : SLOT. Called when selection changed. +// function : enterEvent() +// purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onSelectionDone() +void RepairGUI_FreeBoundDlg::enterEvent(QEvent*) { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if ( aSelList.Extent() != 1 ) - return; - - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( !GEOMBase::IsShape( anObj ) ) - return; - else { - myObj = anObj; - displayPreview( true, false, true, true, 3 ); - } + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); } //================================================================================= -// function : Init -// purpose : Initialize dialog fields +// function : SelectionIntoArgument +// purpose : SLOT. Called when selection changed. //================================================================================= -void RepairGUI_FreeBoundDlg::Init() +void RepairGUI_FreeBoundDlg::SelectionIntoArgument() { - myNbClosed = myNbOpen = 0; + myEditCurrentArgument->setText(""); + myClosedLbl->setText(tr("NUMBER_CLOSED")); + myOpenLbl->setText(tr("NUMBER_OPEN")); myObj = GEOM::GEOM_Object::_nil(); + erasePreview(); - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) ); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); - activateSelection(); - onSelectionDone(); -} + if (aSelList.Extent() != 1) + return; -//================================================================================= -// function : enterEvent -// purpose : Activate dialog -//================================================================================= -void RepairGUI_FreeBoundDlg::enterEvent( QEvent* ) -{ - onActivate(); -} + GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); -//================================================================================= -// function : closeEvent -// purpose : Close dialog -//================================================================================= -void RepairGUI_FreeBoundDlg::closeEvent( QCloseEvent* ) -{ - onClose(); + if (!GEOMBase::IsShape(anObj)) + return; + + myObj = anObj; + myEditCurrentArgument->setText(GEOMBase::GetName(myObj)); + displayPreview(true, false, true, true, 3); } //================================================================================= @@ -257,11 +227,11 @@ void RepairGUI_FreeBoundDlg::closeEvent( QCloseEvent* ) void RepairGUI_FreeBoundDlg::activateSelection() { TColStd_MapOfInteger aMap; - aMap.Add( GEOM_FACE ); - aMap.Add( GEOM_SHELL ); - aMap.Add( GEOM_SOLID ); - aMap.Add( GEOM_COMPOUND ); - globalSelection( aMap ); + aMap.Add(GEOM_FACE); + aMap.Add(GEOM_SHELL); + aMap.Add(GEOM_SOLID); + aMap.Add(GEOM_COMPOUND); + globalSelection(aMap); } //================================================================================= @@ -270,14 +240,14 @@ void RepairGUI_FreeBoundDlg::activateSelection() //================================================================================= GEOM::GEOM_IOperations_ptr RepairGUI_FreeBoundDlg::createOperation() { - return getGeomEngine()->GetIHealingOperations( getStudyId() ); + return getGeomEngine()->GetIHealingOperations(getStudyId()); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool RepairGUI_FreeBoundDlg::isValid( QString& ) +bool RepairGUI_FreeBoundDlg::isValid (QString&) { return !myObj->_is_nil(); } @@ -286,52 +256,50 @@ bool RepairGUI_FreeBoundDlg::isValid( QString& ) // function : execute // purpose : Get free boundaries //================================================================================= -bool RepairGUI_FreeBoundDlg::execute( ObjectList& objects ) +bool RepairGUI_FreeBoundDlg::execute (ObjectList& objects) { - if ( !IsPreview() || myObj->_is_nil() ) - return false; - GEOM::ListOfGO_var aClosed, anOpen; - GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() ); - bool result = anOper->GetFreeBoundary( myObj, aClosed, anOpen ); + GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation()); + bool result = anOper->GetFreeBoundary(myObj, aClosed, anOpen); - if ( result ) { + if (result) { myNbClosed = aClosed->length(); myNbOpen = anOpen->length(); int i; - for ( i = 0; i < myNbClosed; i++ ) - objects.push_back( aClosed[i]._retn() ); - for ( i = 0; i < myNbOpen; i++ ) - objects.push_back( anOpen[i]._retn() ); - - myEdit->setText( GEOMBase::GetName( myObj ) ); - QString aLabelText = tr( "NUMBER_CLOSED" ) + QString( "%1" ).arg( myNbClosed ); - myClosedLbl->setText( aLabelText ); - aLabelText = tr( "NUMBER_OPEN" ) + QString( "%1" ).arg( myNbOpen ); - myOpenLbl->setText( aLabelText ); - } - else { - myEdit->setText( GEOMBase::GetName( myObj ) ); - myClosedLbl->setText( tr( "NUMBER_CLOSED" ) ); - myOpenLbl->setText( tr( "NUMBER_OPEN" ) ); + for (i = 0; i < myNbClosed; i++) + objects.push_back(aClosed[i]._retn()); + for (i = 0; i < myNbOpen; i++) + objects.push_back(anOpen[i]._retn()); + + QString aLabelText = tr("NUMBER_CLOSED") + QString("%1").arg(myNbClosed); + myClosedLbl->setText(aLabelText); + aLabelText = tr("NUMBER_OPEN") + QString("%1").arg(myNbOpen); + myOpenLbl->setText(aLabelText); } + myCurrObj = 1; return result; } -//================================================================================= -// function : keyPressEvent() -// purpose : -//================================================================================= -void RepairGUI_FreeBoundDlg::keyPressEvent( QKeyEvent* e ) +//================================================================ +// Function : getNewObjectName +// Purpose : Redefine this method to return proper name for a new object +//================================================================ +QString RepairGUI_FreeBoundDlg::getNewObjectName (int currObj) const { - QDialog::keyPressEvent( e ); - if ( e->isAccepted() ) - return; + QString aName = tr("NAME_CLOSED").arg(currObj); + if (currObj > myNbClosed) + aName = tr("NAME_OPEN").arg(currObj); + return aName; +} - if ( e->key() == Qt::Key_F1 ) { - e->accept(); - onHelp(); - } +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// (called with addInStudy method) +//================================================================ +GEOM::GEOM_Object_ptr RepairGUI_FreeBoundDlg::getFather (GEOM::GEOM_Object_ptr) +{ + return myObj; } diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.h b/src/RepairGUI/RepairGUI_FreeBoundDlg.h index af65e1602..f9ac7bc7c 100644 --- a/src/RepairGUI/RepairGUI_FreeBoundDlg.h +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.h @@ -18,17 +18,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : RepairGUI_FreeBoundDlg.h // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com) -// + #ifndef REPAIRGUI_FREEBOUNDDLG_H #define REPAIRGUI_FREEBOUNDDLG_H #include -#include +#include class QLineEdit; class QLabel; @@ -38,42 +37,42 @@ class GeometryGUI; // class : RepairGUI_FreeBoundDlg // purpose : Dialog for displaying free boundaries of selected face, shell or solid //================================================================================= -class RepairGUI_FreeBoundDlg : public QDialog, - public GEOMBase_Helper +class RepairGUI_FreeBoundDlg : public GEOMBase_Skeleton { Q_OBJECT public: - RepairGUI_FreeBoundDlg( GeometryGUI*, QWidget* ); + RepairGUI_FreeBoundDlg (GeometryGUI*, QWidget*); ~RepairGUI_FreeBoundDlg(); -private slots: - void onClose(); - void onHelp(); - void onDeactivate(); - void onActivate(); - void onSelectionDone(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); + virtual QString getNewObjectName (int CurrObj = -1) const; private: void Init(); - void enterEvent( QEvent* ); - void closeEvent( QCloseEvent* ); - void keyPressEvent( QKeyEvent* ); + void enterEvent (QEvent*); void activateSelection(); - - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool execute( ObjectList& ); - virtual bool isValid( QString& ); private: QLineEdit* myEdit; QLabel* myClosedLbl; QLabel* myOpenLbl; + GEOM::GEOM_Object_var myObj; - GeometryGUI* myGeomGUI; int myNbClosed; int myNbOpen; - QString myHelpFileName; + int myCurrObj; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void SelectionIntoArgument(); + void ActivateThisDialog(); }; #endif // REPAIRGUI_FREEBOUNDDLG_H