X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_CopyMeshDlg.cxx;h=0fc5aef49ba59fd75f94e995ff9e4a20ef7ee09d;hp=7c3d1d62c74519145ddec26d54b877f7df059c40;hb=7eda9ca931ed2a11cb5e4637e4ffe19f5c061115;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx index 7c3d1d62c..0fc5aef49 100644 --- a/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CopyMeshDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -98,10 +98,6 @@ namespace #define SPACING 6 #define MARGIN 11 -//To disable automatic genericobj management, the following line should be commented. -//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx -#define WITHGENERICOBJ - //================================================================================ /*! @@ -113,8 +109,8 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0), mySelectedObject(SMESH::SMESH_IDSource::_nil()), + myFilterDlg(0), myIsApplyAndClose( false ) { QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH"))); @@ -170,9 +166,10 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) myCopyGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); myCopyGroupsCheck->setChecked(false); - // CheckBox for keeping ids + // CheckBox for keeping ids ( OBSOLETE ) myKeepIdsCheck = new QCheckBox(tr("SMESH_KEEP_IDS"), GroupArguments); myKeepIdsCheck->setChecked(true); + myKeepIdsCheck->hide(); // layout GroupArgumentsLayout->addWidget(myTextLabelElements, 0, 0); @@ -182,7 +179,7 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) GroupArgumentsLayout->addWidget(meshNameLabel, 2, 0); GroupArgumentsLayout->addWidget(myMeshNameEdit, 2, 1, 1, 5); GroupArgumentsLayout->addWidget(myCopyGroupsCheck, 3, 0, 1, 6); - GroupArgumentsLayout->addWidget(myKeepIdsCheck, 4, 0, 1, 6); + // GroupArgumentsLayout->addWidget(myKeepIdsCheck, 4, 0, 1, 6); /***************************************************************/ GroupButtons = new QGroupBox(this); @@ -219,7 +216,7 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) mySMESHGUI->SetActiveDialogBox((QDialog*)this); // Selection filter - myIdSourceFilter = new SMESH_TypeFilter( IDSOURCE ); + myIdSourceFilter = new SMESH_TypeFilter( SMESH::IDSOURCE ); myHelpFileName = "copy_mesh_page.html"; @@ -227,7 +224,7 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); @@ -236,7 +233,11 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule ) connect(mySelectionMgr, SIGNAL (currentSelectionChanged()), this, SLOT (SelectionIntoArgument())); connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()),/* to close dialog if study change */ - this, SLOT (ClickOnCancel())); + this, SLOT (reject())); + connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), + this, SLOT (onOpenView())); + connect(mySMESHGUI, SIGNAL (SignalCloseView()), + this, SLOT (onCloseView())); connect(myLineEditElements, SIGNAL(textChanged(const QString&)), this, SLOT (onTextChange(const QString&))); @@ -312,10 +313,12 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply() try { SUIT_OverrideCursor aWaitCursor; - SMESH::SMESH_IDSource_var aPartToCopy; + + SMESH::IDSource_wrap aPartToCopy; if ( myIdSourceCheck->isChecked()) { aPartToCopy = mySelectedObject; + aPartToCopy->Register(); } else { @@ -338,13 +341,8 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply() if( !newMesh->_is_nil() ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) ) anEntryList.append( aSObject->GetID().c_str() ); -#ifdef WITHGENERICOBJ - // obj has been published in study. Its refcount has been incremented. - // It is safe to decrement its refcount - // so that it will be destroyed when the entry in study will be removed - newMesh->UnRegister(); -#endif - } catch (...) { + } + catch (...) { } mySMESHGUI->updateObjBrowser(true); @@ -369,14 +367,14 @@ void SMESHGUI_CopyMeshDlg::ClickOnOk() { setIsApplyAndClose( true ); if( ClickOnApply() ) - ClickOnCancel(); + reject(); } //================================================================================= -// function : ClickOnCancel() +// function : reject() // purpose : //================================================================================= -void SMESHGUI_CopyMeshDlg::ClickOnCancel() +void SMESHGUI_CopyMeshDlg::reject() { disconnect(mySelectionMgr, 0, this, 0); if ( mySelectionMgr ) @@ -384,7 +382,32 @@ void SMESHGUI_CopyMeshDlg::ClickOnCancel() if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode( ActorSelection ); mySMESHGUI->ResetState(); - reject(); + QDialog::reject(); +} + +//================================================================================= +// function : onOpenView() +// purpose : +//================================================================================= +void SMESHGUI_CopyMeshDlg::onOpenView() +{ + if ( mySelector ) { + SMESH::SetPointRepresentation(false); + } + else { + mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector(); + ActivateThisDialog(); + } +} + +//================================================================================= +// function : onCloseView() +// purpose : +//================================================================================= +void SMESHGUI_CopyMeshDlg::onCloseView() +{ + DeactivateActiveDialog(); + mySelector = 0; } //================================================================================= @@ -471,6 +494,9 @@ void SMESHGUI_CopyMeshDlg::onTextChange (const QString& theNewText) void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() { if (myBusy) return; + if (myFilterDlg && myFilterDlg->isVisible()) return; // filter dlg active + if (!GroupButtons->isEnabled()) return; // inactive + BusyLocker lock( myBusy ); // clear @@ -485,7 +511,7 @@ void SMESHGUI_CopyMeshDlg::SelectionIntoArgument() // get selected mesh SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + mySelectionMgr->selectedObjects(aList); int nbSel = aList.Extent(); if (nbSel != 1) return; @@ -608,36 +634,21 @@ void SMESHGUI_CopyMeshDlg::ActivateThisDialog() SelectionIntoArgument(); } + //================================================================================= // function : enterEvent() // purpose : //================================================================================= void SMESHGUI_CopyMeshDlg::enterEvent (QEvent*) { - if (!ConstructorsBox->isEnabled()) + if ( !ConstructorsBox->isEnabled() ) { + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if ( aViewWindow && !mySelector ) { + mySelector = aViewWindow->GetSelector(); + } ActivateThisDialog(); + } } - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_CopyMeshDlg::closeEvent (QCloseEvent*) -{ - /* same than click on cancel button */ - ClickOnCancel(); -} - -//======================================================================= -//function : hideEvent -//purpose : caused by ESC key -//======================================================================= -void SMESHGUI_CopyMeshDlg::hideEvent (QHideEvent*) -{ - if (!isMinimized()) - ClickOnCancel(); -} - //================================================================================= // function : keyPressEvent() // purpose : @@ -669,6 +680,15 @@ void SMESHGUI_CopyMeshDlg::setFilters() if ( !myFilterDlg ) myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL ); + QList types; + if ( myMesh->NbEdges() ) types << SMESH::EDGE; + if ( myMesh->NbFaces() ) types << SMESH::FACE; + if ( myMesh->NbVolumes() ) types << SMESH::VOLUME; + if ( myMesh->NbBalls() ) types << SMESH::BALL; + if ( myMesh->Nb0DElements()) types << SMESH::ELEM0D; + if ( types.count() > 1 ) types << SMESH::ALL; + + myFilterDlg->Init( types ); myFilterDlg->SetSelection(); myFilterDlg->SetMesh( myMesh ); myFilterDlg->SetSourceWg( myLineEditElements );