Back to index

salome-smesh  6.5.0
SMESHGUI_CopyMeshDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : SMESHGUI_CopyMeshDlg.cxx
00023 
00024 #include "SMESHGUI_CopyMeshDlg.h"
00025 
00026 #include "SMESHGUI.h"
00027 #include "SMESHGUI_SpinBox.h"
00028 #include "SMESHGUI_Utils.h"
00029 #include "SMESHGUI_VTKUtils.h"
00030 #include "SMESHGUI_MeshUtils.h"
00031 #include "SMESHGUI_IdValidator.h"
00032 #include "SMESHGUI_FilterDlg.h"
00033 
00034 #include <SMESH_Actor.h>
00035 #include <SMESH_TypeFilter.hxx>
00036 #include <SMDS_Mesh.hxx>
00037 
00038 // SALOME GUI includes
00039 #include <SUIT_Desktop.h>
00040 #include <SUIT_ResourceMgr.h>
00041 #include <SUIT_Session.h>
00042 #include <SUIT_MessageBox.h>
00043 #include <SUIT_OverrideCursor.h>
00044 
00045 #include <LightApp_Application.h>
00046 #include <LightApp_SelectionMgr.h>
00047 
00048 #include <SVTK_ViewModel.h>
00049 #include <SVTK_ViewWindow.h>
00050 #include <SALOME_ListIO.hxx>
00051 
00052 // SALOME KERNEL includes
00053 #include <SALOMEDSClient_SObject.hxx>
00054 
00055 // OCCT includes
00056 #include <TColStd_MapOfInteger.hxx>
00057 
00058 // Qt includes
00059 #include <QApplication>
00060 #include <QButtonGroup>
00061 #include <QGroupBox>
00062 #include <QLabel>
00063 #include <QLineEdit>
00064 #include <QPushButton>
00065 #include <QRadioButton>
00066 #include <QCheckBox>
00067 #include <QHBoxLayout>
00068 #include <QVBoxLayout>
00069 #include <QGridLayout>
00070 #include <QSpinBox>
00071 #include <QKeyEvent>
00072 
00073 // IDL includes
00074 #include <SALOMEconfig.h>
00075 #include CORBA_SERVER_HEADER(SMESH_Group)
00076 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
00077 
00084 namespace
00085 {
00086   class BusyLocker
00087   {
00088   public:
00090     BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
00092     ~BusyLocker() { myBusy = false; }
00093   private:
00094     bool& myBusy; 
00095   };
00096 }
00097 
00098 #define SPACING 6
00099 #define MARGIN  11
00100 
00101 //To disable automatic genericobj management, the following line should be commented.
00102 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
00103 #define WITHGENERICOBJ
00104 
00105 
00106 //================================================================================
00110 //================================================================================
00111 
00112 SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
00113   : QDialog( SMESH::GetDesktop( theModule ) ),
00114     mySMESHGUI( theModule ),
00115     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
00116     myFilterDlg(0),
00117     mySelectedObject(SMESH::SMESH_IDSource::_nil()),
00118     myIsApplyAndClose( false )
00119 {
00120   QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH")));
00121 
00122   setModal(false);
00123   setAttribute(Qt::WA_DeleteOnClose, true);
00124   setWindowTitle(tr("SMESH_COPY_MESH_TITLE"));
00125   setSizeGripEnabled(true);
00126 
00127   QVBoxLayout* SMESHGUI_CopyMeshDlgLayout = new QVBoxLayout(this);
00128   SMESHGUI_CopyMeshDlgLayout->setSpacing(SPACING);
00129   SMESHGUI_CopyMeshDlgLayout->setMargin(MARGIN);
00130 
00131   /***************************************************************/
00132   ConstructorsBox = new QGroupBox(tr("SMESH_COPY_MESH_TITLE"), this);
00133   QButtonGroup* GroupConstructors = new QButtonGroup(this);
00134   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
00135   ConstructorsBoxLayout->setSpacing(SPACING);
00136   ConstructorsBoxLayout->setMargin(MARGIN);
00137 
00138   QRadioButton* RadioButton1= new QRadioButton(ConstructorsBox);
00139   RadioButton1->setIcon(image);
00140   GroupConstructors->addButton(RadioButton1, 0);
00141 
00142   ConstructorsBoxLayout->addWidget(RadioButton1);
00143   RadioButton1->setChecked(true);
00144   GroupConstructors->addButton(RadioButton1, 0);
00145 
00146   /***************************************************************/
00147   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
00148   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
00149   GroupArgumentsLayout->setSpacing(SPACING);
00150   GroupArgumentsLayout->setMargin(MARGIN);
00151 
00152   myIdValidator = new SMESHGUI_IdValidator(this);
00153 
00154   // Controls for idSource/elements selection
00155   myTextLabelElements = new QLabel(tr("OBJECT_NAME"), GroupArguments);
00156   myLineEditElements = new QLineEdit(GroupArguments);
00157   myLineEditElements->setValidator(myIdValidator);
00158   myLineEditElements->setMaxLength(-1);
00159   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
00160   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
00161 
00162   // Control for the mesh objects selection
00163   myIdSourceCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
00164 
00165   // Name of a mesh to create
00166   QLabel* meshNameLabel = new QLabel(tr("NEW_NAME"), GroupArguments);
00167   myMeshNameEdit = new QLineEdit(GroupArguments);
00168 
00169   // CheckBox for copying groups
00170   myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
00171   myCopyGroupsCheck->setChecked(false);
00172 
00173   // CheckBox for keeping ids
00174   myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments);
00175   myKeepIdsCheck->setChecked(true);
00176 
00177   // layout
00178   GroupArgumentsLayout->addWidget(myTextLabelElements,  0, 0);
00179   GroupArgumentsLayout->addWidget(myLineEditElements,   0, 1, 1, 5);
00180   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 6);
00181   GroupArgumentsLayout->addWidget(myIdSourceCheck,      1, 0, 1, 6);
00182   GroupArgumentsLayout->addWidget(meshNameLabel,        2, 0);
00183   GroupArgumentsLayout->addWidget(myMeshNameEdit,       2, 1, 1, 5);
00184   GroupArgumentsLayout->addWidget(myCopyGroupsCheck,    3, 0, 1, 6);
00185   GroupArgumentsLayout->addWidget(myKeepIdsCheck,       4, 0, 1, 6);
00186 
00187   /***************************************************************/
00188   GroupButtons = new QGroupBox(this);
00189   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
00190   GroupButtonsLayout->setSpacing(SPACING);
00191   GroupButtonsLayout->setMargin(MARGIN);
00192 
00193   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
00194   buttonOk->setAutoDefault(true);
00195   buttonOk->setDefault(true);
00196   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
00197   buttonApply->setAutoDefault(true);
00198   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
00199   buttonCancel->setAutoDefault(true);
00200   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
00201   buttonHelp->setAutoDefault(true);
00202 
00203   GroupButtonsLayout->addWidget(buttonOk);
00204   GroupButtonsLayout->addSpacing(10);
00205   GroupButtonsLayout->addWidget(buttonApply);
00206   GroupButtonsLayout->addSpacing(10);
00207   GroupButtonsLayout->addStretch();
00208   GroupButtonsLayout->addWidget(buttonCancel);
00209   GroupButtonsLayout->addWidget(buttonHelp);
00210 
00211   /***************************************************************/
00212   SMESHGUI_CopyMeshDlgLayout->addWidget(ConstructorsBox);
00213   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupArguments);
00214   SMESHGUI_CopyMeshDlgLayout->addWidget(GroupButtons);
00215 
00216   /* Initialisations */
00217   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
00218 
00219   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00220 
00221   // Selection filter
00222   myIdSourceFilter = new SMESH_TypeFilter( IDSOURCE );
00223 
00224   myHelpFileName = "copy_mesh_page.html";
00225 
00226   Init();
00227 
00228   /* signals and slots connections */
00229   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
00230   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
00231   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
00232   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
00233 
00234   connect(mySMESHGUI,     SIGNAL (SignalDeactivateActiveDialog()),
00235           this,           SLOT   (DeactivateActiveDialog()));
00236   connect(mySelectionMgr, SIGNAL (currentSelectionChanged()),
00237           this,           SLOT   (SelectionIntoArgument()));
00238   connect(mySMESHGUI,     SIGNAL (SignalCloseAllDialogs()),/* to close dialog if study change */
00239           this,           SLOT   (ClickOnCancel()));
00240 
00241   connect(myLineEditElements, SIGNAL(textChanged(const QString&)),
00242           this,               SLOT  (onTextChange(const QString&)));
00243   connect(myIdSourceCheck,    SIGNAL(toggled(bool)),
00244           this,               SLOT  (onSelectIdSource(bool)));
00245 
00246   SelectionIntoArgument();
00247 }
00248 
00249 //=================================================================================
00250 // function : ~SMESHGUI_CopyMeshDlg()
00251 // purpose  : Destroys the object and frees any allocated resources
00252 //=================================================================================
00253 
00254 SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
00255 {
00256   if ( myFilterDlg )
00257   {
00258     myFilterDlg->setParent( 0 );
00259     delete myFilterDlg; myFilterDlg = 0;
00260   }
00261   if ( myIdSourceFilter )
00262   {
00263     if ( mySelectionMgr )
00264       mySelectionMgr->removeFilter( myIdSourceFilter );
00265     delete myIdSourceFilter; myIdSourceFilter=0;
00266   }
00267 }
00268 
00269 //=================================================================================
00270 // function : Init()
00271 // purpose  :
00272 //=================================================================================
00273 void SMESHGUI_CopyMeshDlg::Init (bool ResetControls)
00274 {
00275   myBusy = false;
00276 
00277   myMeshNameEdit->setText( SMESH::UniqueMeshName("Mesh"));
00278   if ( ResetControls )
00279   {
00280     myLineEditElements->clear();
00281     //myElementsId = "";
00282     myNbOkElements = 0;
00283 
00284     buttonOk->setEnabled(false);
00285     buttonApply->setEnabled(false);
00286 
00287     myActor = 0;
00288     myMesh = SMESH::SMESH_Mesh::_nil();
00289 
00290     myIdSourceCheck->setChecked(true);
00291     myCopyGroupsCheck->setChecked(false);
00292     myKeepIdsCheck->setChecked(false);
00293 
00294     onSelectIdSource( myIdSourceCheck->isChecked() );
00295   }
00296 }
00297 
00298 //=================================================================================
00299 // function : ClickOnApply()
00300 // purpose  :
00301 //=================================================================================
00302 
00303 bool SMESHGUI_CopyMeshDlg::ClickOnApply()
00304 {
00305   if (mySMESHGUI->isActiveStudyLocked())
00306     return false;
00307 
00308   if( !isValid() )
00309     return false;
00310 
00311   QStringList anEntryList;
00312   try
00313   {
00314     SUIT_OverrideCursor aWaitCursor;
00315     SMESH::SMESH_IDSource_var aPartToCopy;
00316     if ( myIdSourceCheck->isChecked())
00317     {
00318       aPartToCopy = mySelectedObject;
00319     }
00320     else
00321     {
00322       QStringList aListElementsId = myLineEditElements->text().split(" ", QString::SkipEmptyParts);
00323       SMESH::long_array_var anElementsId = new SMESH::long_array;
00324       anElementsId->length(aListElementsId.count());
00325       for (int i = 0; i < aListElementsId.count(); i++)
00326         anElementsId[i] = aListElementsId[i].toInt();
00327 
00328       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
00329       aPartToCopy = aMeshEditor->MakeIDSource( anElementsId, SMESH::ALL );
00330     }
00331     QByteArray meshName = myMeshNameEdit->text().toLatin1();
00332     bool toCopyGroups = ( myCopyGroupsCheck->isChecked() );
00333     bool toKeepIDs    = ( myKeepIdsCheck->isChecked() );
00334 
00335     SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
00336     SMESH::SMESH_Mesh_var newMesh =
00337       gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
00338     if( !newMesh->_is_nil() )
00339       if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
00340         anEntryList.append( aSObject->GetID().c_str() );
00341 #ifdef WITHGENERICOBJ
00342     // obj has been published in study. Its refcount has been incremented.
00343     // It is safe to decrement its refcount
00344     // so that it will be destroyed when the entry in study will be removed
00345     newMesh->UnRegister();
00346 #endif
00347   } catch (...) {
00348   }
00349 
00350   mySMESHGUI->updateObjBrowser(true);
00351   SMESHGUI::Modified();
00352 
00353   if( LightApp_Application* anApp =
00354       dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
00355     anApp->browseObjects( anEntryList, isApplyAndClose() );
00356 
00357   Init(false);
00358   mySelectedObject = SMESH::SMESH_IDSource::_nil();
00359   SelectionIntoArgument();
00360 
00361   return true;
00362 }
00363 
00364 //=================================================================================
00365 // function : ClickOnOk()
00366 // purpose  :
00367 //=================================================================================
00368 void SMESHGUI_CopyMeshDlg::ClickOnOk()
00369 {
00370   setIsApplyAndClose( true );
00371   if( ClickOnApply() )
00372     ClickOnCancel();
00373 }
00374 
00375 //=================================================================================
00376 // function : ClickOnCancel()
00377 // purpose  :
00378 //=================================================================================
00379 void SMESHGUI_CopyMeshDlg::ClickOnCancel()
00380 {
00381   disconnect(mySelectionMgr, 0, this, 0);
00382   if ( mySelectionMgr )
00383     mySelectionMgr->removeFilter( myIdSourceFilter );
00384   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00385     aViewWindow->SetSelectionMode( ActorSelection );
00386   mySMESHGUI->ResetState();
00387   reject();
00388 }
00389 
00390 //=================================================================================
00391 // function : ClickOnHelp()
00392 // purpose  :
00393 //=================================================================================
00394 void SMESHGUI_CopyMeshDlg::ClickOnHelp()
00395 {
00396   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
00397   if (app)
00398     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
00399   else {
00400     QString platform;
00401 #ifdef WIN32
00402     platform = "winapplication";
00403 #else
00404     platform = "application";
00405 #endif
00406     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00407                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00408                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
00409                                                                  platform)).
00410                              arg(myHelpFileName));
00411   }
00412 }
00413 
00414 //=======================================================================
00415 // function : onTextChange()
00416 // purpose  :
00417 //=======================================================================
00418 
00419 void SMESHGUI_CopyMeshDlg::onTextChange (const QString& theNewText)
00420 {
00421   QLineEdit* send = (QLineEdit*)sender();
00422 
00423   if (myBusy) return;
00424   BusyLocker lock( myBusy );
00425 
00426   //if (send == myLineEditElements)
00427   myNbOkElements = 0;
00428 
00429   buttonOk->setEnabled(false);
00430   buttonApply->setEnabled(false);
00431 
00432   // hilight entered elements
00433   SMDS_Mesh* aMesh = 0;
00434   if (myActor)
00435     aMesh = myActor->GetObject()->GetMesh();
00436 
00437   QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
00438   if (myActor && aMesh)
00439   {
00440     TColStd_MapOfInteger newIndices;
00441     if (send == myLineEditElements) {
00442       for (int i = 0; i < aListId.count(); i++)
00443         if ( const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()))
00444         {
00445           newIndices.Add(e->GetID());
00446         }
00447     }
00448     myNbOkElements = newIndices.Extent();
00449 
00450     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
00451     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
00452     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00453       aViewWindow->highlight( anIO, true, true );
00454   }
00455   else
00456   {
00457     myNbOkElements = aListId.count();
00458   }
00459 
00460   if (myNbOkElements) {
00461     buttonOk->setEnabled(true);
00462     buttonApply->setEnabled(true);
00463   }
00464 }
00465 
00466 //=================================================================================
00467 // function : SelectionIntoArgument()
00468 // purpose  : Called when selection as changed or other case
00469 //=================================================================================
00470 
00471 void SMESHGUI_CopyMeshDlg::SelectionIntoArgument()
00472 {
00473   if (myBusy) return;
00474   BusyLocker lock( myBusy );
00475 
00476   // clear
00477   myActor = 0;
00478   QString aString = "";
00479 
00480   myLineEditElements->setText(aString);
00481   myNbOkElements = 0;
00482   buttonOk->setEnabled(false);
00483   buttonApply->setEnabled(false);
00484   myFilterBtn->setEnabled(false);
00485 
00486   // get selected mesh
00487   SALOME_ListIO aList;
00488   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
00489   int nbSel = aList.Extent();
00490   if (nbSel != 1)
00491     return;
00492 
00493   Handle(SALOME_InteractiveObject) IO = aList.First();
00494   mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
00495   if ( mySelectedObject->_is_nil() )
00496     return;
00497 
00498   myMesh = SMESH::GetMeshByIO(IO);
00499   if (myMesh->_is_nil())
00500     return;
00501 
00502   myActor = SMESH::FindActorByEntry(IO->getEntry());
00503   if (!myActor)
00504     myActor = SMESH::FindActorByObject(myMesh);
00505 
00506   if (myIdSourceCheck->isChecked())
00507   {
00508     SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
00509     if ( aString.isEmpty() ) aString = " ";
00510     else                     aString = aString.trimmed(); // issue 0021327
00511   }
00512   else
00513   {
00514     SMESH::GetNameOfSelectedElements( mySelector, IO, aString );
00515     myNbOkElements = aString.size();
00516     myFilterBtn->setEnabled(true);
00517   }
00518   myLineEditElements->setText( aString );
00519   bool ok = !aString.isEmpty();
00520 
00521   buttonOk->setEnabled(ok);
00522   buttonApply->setEnabled(ok);
00523 }
00524 
00525 //=======================================================================
00526 //function : onSelectIdSource
00527 //purpose  :
00528 //=======================================================================
00529 void SMESHGUI_CopyMeshDlg::onSelectIdSource (bool toSelectMesh)
00530 {
00531   if (toSelectMesh)
00532     myTextLabelElements->setText(tr("OBJECT_NAME"));
00533   else
00534     myTextLabelElements->setText(tr("ELEM_IDS"));
00535 
00536   if (toSelectMesh) {
00537     myLineEditElements->clear();
00538   }
00539 
00540   mySelectionMgr->clearFilters();
00541   mySelectionMgr->installFilter(myIdSourceFilter);
00542   SMESH::SetPointRepresentation(false);
00543 
00544   if (toSelectMesh) {
00545     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00546       aViewWindow->SetSelectionMode( ActorSelection );
00547     myLineEditElements->setReadOnly(true);
00548     myLineEditElements->setValidator(0);
00549   }
00550   else
00551   {
00552     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
00553       aViewWindow->SetSelectionMode( CellSelection );
00554     myLineEditElements->setReadOnly(false);
00555     myLineEditElements->setValidator(myIdValidator);
00556     onTextChange(myLineEditElements->text());
00557   }
00558 
00559   SelectionIntoArgument();
00560 }
00561 
00562 //=================================================================================
00563 // function : isValid
00564 // purpose  :
00565 //=================================================================================
00566 
00567 bool SMESHGUI_CopyMeshDlg::isValid()
00568 {
00569   if ( myIdSourceCheck->isChecked() )
00570     return !mySelectedObject->_is_nil();
00571 
00572   return myNbOkElements > 0;
00573 }
00574 
00575 //=================================================================================
00576 // function : DeactivateActiveDialog()
00577 // purpose  :
00578 //=================================================================================
00579 void SMESHGUI_CopyMeshDlg::DeactivateActiveDialog()
00580 {
00581   if (ConstructorsBox->isEnabled()) {
00582     ConstructorsBox->setEnabled(false);
00583     GroupArguments->setEnabled(false);
00584     GroupButtons->setEnabled(false);
00585     mySMESHGUI->ResetState();
00586     mySMESHGUI->SetActiveDialogBox(0);
00587     if ( mySelectionMgr )
00588       mySelectionMgr->removeFilter( myIdSourceFilter );
00589   }
00590 }
00591 
00592 //=================================================================================
00593 // function : ActivateThisDialog()
00594 // purpose  :
00595 //=================================================================================
00596 void SMESHGUI_CopyMeshDlg::ActivateThisDialog()
00597 {
00598   /* Emit a signal to deactivate the active dialog */
00599   mySMESHGUI->EmitSignalDeactivateDialog();
00600   ConstructorsBox->setEnabled(true);
00601   GroupArguments->setEnabled(true);
00602   GroupButtons->setEnabled(true);
00603 
00604   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
00605 
00606   onSelectIdSource( myIdSourceCheck->isChecked() );
00607 
00608   SelectionIntoArgument();
00609 }
00610 
00611 //=================================================================================
00612 // function : enterEvent()
00613 // purpose  :
00614 //=================================================================================
00615 void SMESHGUI_CopyMeshDlg::enterEvent (QEvent*)
00616 {
00617   if (!ConstructorsBox->isEnabled())
00618     ActivateThisDialog();
00619 }
00620 
00621 //=================================================================================
00622 // function : closeEvent()
00623 // purpose  :
00624 //=================================================================================
00625 void SMESHGUI_CopyMeshDlg::closeEvent (QCloseEvent*)
00626 {
00627   /* same than click on cancel button */
00628   ClickOnCancel();
00629 }
00630 
00631 //=======================================================================
00632 //function : hideEvent
00633 //purpose  : caused by ESC key
00634 //=======================================================================
00635 void SMESHGUI_CopyMeshDlg::hideEvent (QHideEvent*)
00636 {
00637   if (!isMinimized())
00638     ClickOnCancel();
00639 }
00640 
00641 //=================================================================================
00642 // function : keyPressEvent()
00643 // purpose  :
00644 //=================================================================================
00645 void SMESHGUI_CopyMeshDlg::keyPressEvent( QKeyEvent* e )
00646 {
00647   QDialog::keyPressEvent( e );
00648   if ( e->isAccepted() )
00649     return;
00650 
00651   if ( e->key() == Qt::Key_F1 ) {
00652     e->accept();
00653     ClickOnHelp();
00654   }
00655 }
00656 
00657 //=================================================================================
00658 // function : setFilters()
00659 // purpose  : SLOT. Called when "Filter" button pressed.
00660 //=================================================================================
00661 void SMESHGUI_CopyMeshDlg::setFilters()
00662 {
00663   if(myMesh->_is_nil()) {
00664     SUIT_MessageBox::critical(this,
00665                               tr("SMESH_ERROR"),
00666                               tr("NO_MESH_SELECTED"));
00667    return;
00668   }
00669   if ( !myFilterDlg )
00670     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
00671 
00672   myFilterDlg->SetSelection();
00673   myFilterDlg->SetMesh( myMesh );
00674   myFilterDlg->SetSourceWg( myLineEditElements );
00675 
00676   myFilterDlg->show();
00677 }
00678 
00679 //================================================================
00680 // function : setIsApplyAndClose
00681 // Purpose  : Set value of the flag indicating that the dialog is
00682 //            accepted by Apply & Close button
00683 //================================================================
00684 void SMESHGUI_CopyMeshDlg::setIsApplyAndClose( const bool theFlag )
00685 {
00686   myIsApplyAndClose = theFlag;
00687 }
00688 
00689 //================================================================
00690 // function : isApplyAndClose
00691 // Purpose  : Get value of the flag indicating that the dialog is
00692 //            accepted by Apply & Close button
00693 //================================================================
00694 bool SMESHGUI_CopyMeshDlg::isApplyAndClose() const
00695 {
00696   return myIsApplyAndClose;
00697 }