2004-12-01 15:48:31 +05:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2005-06-07 19:22:20 +06:00
|
|
|
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_DeleteGroupDlg.cxx
|
|
|
|
// Author : Sergey LITONIN
|
|
|
|
// Module : SMESH
|
|
|
|
|
|
|
|
#include "SMESHGUI_DeleteGroupDlg.h"
|
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SMESH_TypeFilter.hxx"
|
|
|
|
|
|
|
|
#include "SUIT_Desktop.h"
|
|
|
|
|
|
|
|
#include "SalomeApp_Study.h"
|
|
|
|
#include "SalomeApp_SelectionMgr.h"
|
|
|
|
|
|
|
|
#include "SALOME_ListIO.hxx"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SALOME_ListIteratorOfListIO.hxx"
|
|
|
|
|
2005-06-08 12:18:53 +06:00
|
|
|
#include "SVTK_Selection.h"
|
|
|
|
#include "SVTK_ViewWindow.h"
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
// QT Includes
|
2004-12-01 15:48:31 +05:00
|
|
|
#include <qframe.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlistbox.h>
|
|
|
|
#include <qlist.h>
|
|
|
|
#include <qmessagebox.h>
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
// IDL Headers
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SALOMEconfig.h"
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
|
|
|
|
|
|
|
#define SPACING 5
|
|
|
|
#define MARGIN 10
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_DeleteGroupDlg
|
|
|
|
* Description : Delete groups and their contents
|
|
|
|
*/
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SMESHGUI_DeleteGroupDlg()
|
|
|
|
// purpose : Constructor
|
|
|
|
//=================================================================================
|
2005-06-08 12:18:53 +06:00
|
|
|
SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg (SMESHGUI* theModule):
|
|
|
|
QDialog(SMESH::GetDesktop(theModule),
|
|
|
|
"SMESHGUI_DeleteGroupDlg",
|
|
|
|
false,
|
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
|
|
|
|
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
|
|
|
myViewWindow(SMESH::GetViewWindow(mySMESHGUI)),
|
|
|
|
mySMESHGUI(theModule)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
setCaption(tr("CAPTION"));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* aMainFrame = createMainFrame (this);
|
|
|
|
QFrame* aBtnFrame = createButtonFrame(this);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aDlgLay->addWidget(aMainFrame);
|
|
|
|
aDlgLay->addWidget(aBtnFrame);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aDlgLay->setStretchFactor(aMainFrame, 1);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-08 12:18:53 +06:00
|
|
|
Init();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : createMainFrame()
|
|
|
|
// purpose : Create frame containing dialog's input fields
|
|
|
|
//=================================================================================
|
|
|
|
QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame (QWidget* theParent)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QGroupBox* aMainGrp =
|
|
|
|
new QGroupBox(1, Qt::Horizontal, tr("SELECTED_GROUPS"), theParent);
|
|
|
|
|
|
|
|
myListBox = new QListBox(aMainGrp);
|
|
|
|
myListBox->setMinimumHeight(100);
|
|
|
|
myListBox->setSelectionMode(QListBox::NoSelection);
|
|
|
|
myListBox->setRowMode(QListBox::FitToWidth);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
return aMainGrp;
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : createButtonFrame()
|
|
|
|
// purpose : Create frame containing buttons
|
|
|
|
//=================================================================================
|
|
|
|
QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame (QWidget* theParent)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* aFrame = new QFrame(theParent);
|
|
|
|
aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
|
|
|
|
myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
|
|
|
|
myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
|
|
|
|
|
|
|
|
aLay->addWidget(myOkBtn);
|
|
|
|
aLay->addWidget(myApplyBtn);
|
|
|
|
aLay->addItem(aSpacer);
|
|
|
|
aLay->addWidget(myCloseBtn);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// connect signals and slots
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
|
|
|
|
connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
|
|
|
|
connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// name : ~SMESHGUI_DeleteGroupDlg()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Destructor
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose : Init dialog fields, connect signals and slots, show dialog
|
|
|
|
//=================================================================================
|
2005-06-08 12:18:53 +06:00
|
|
|
void SMESHGUI_DeleteGroupDlg::Init ()
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
myBlockSelection = false;
|
2005-06-08 12:18:53 +06:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// selection and SMESHGUI
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
|
2005-06-08 12:18:53 +06:00
|
|
|
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
|
|
|
|
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
int x, y;
|
2005-06-08 12:18:53 +06:00
|
|
|
mySMESHGUI->DefineDlgPosition(this, x, y);
|
2005-06-07 19:22:20 +06:00
|
|
|
this->move(x, y);
|
|
|
|
this->show();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// set selection mode
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
|
2005-06-08 12:18:53 +06:00
|
|
|
myViewWindow->SetSelectionMode(ActorSelection);
|
2004-12-01 15:48:31 +05:00
|
|
|
onSelectionDone();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : isValid()
|
|
|
|
// purpose : Verify validity of input data
|
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
bool SMESHGUI_DeleteGroupDlg::isValid()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myListBox->count() == 0) {
|
|
|
|
QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
|
|
|
|
tr("NO_SELECTED_GROUPS"), QMessageBox::Ok);
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-06-08 12:18:53 +06:00
|
|
|
return !mySMESHGUI->isActiveStudyLocked();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onApply()
|
|
|
|
// purpose : SLOT called when "Apply" button pressed.
|
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
bool SMESHGUI_DeleteGroupDlg::onApply()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isValid())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
|
|
|
myBlockSelection = true;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
QValueList<SMESH::SMESH_GroupBase_var>::iterator anIter;
|
2005-06-07 19:22:20 +06:00
|
|
|
for (anIter = myListGrp.begin(); anIter != myListGrp.end(); ++anIter) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SMESH_Mesh_ptr aMesh = (*anIter)->GetMesh();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!aMesh->_is_nil())
|
|
|
|
aMesh->RemoveGroupWithContents(*anIter);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
myListBox->clear();
|
|
|
|
myListGrp.clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->clearSelected();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::UpdateView();
|
2005-06-08 12:18:53 +06:00
|
|
|
mySMESHGUI->updateObjBrowser(true);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myBlockSelection = false;
|
2005-02-02 18:22:46 +05:00
|
|
|
return true;
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onOk()
|
|
|
|
// purpose : SLOT called when "Ok" button pressed.
|
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_DeleteGroupDlg::onOk()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (onApply())
|
2004-12-01 15:48:31 +05:00
|
|
|
onClose();
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onClose()
|
|
|
|
// purpose : SLOT called when "Close" button pressed. Close dialog
|
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_DeleteGroupDlg::onClose()
|
|
|
|
{
|
2005-06-08 12:18:53 +06:00
|
|
|
myViewWindow->SetSelectionMode(ActorSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
2005-06-08 12:18:53 +06:00
|
|
|
disconnect(mySMESHGUI, 0, this, 0);
|
|
|
|
mySMESHGUI->ResetState();
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->clearFilters();
|
2004-12-01 15:48:31 +05:00
|
|
|
reject();
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectionDone()
|
|
|
|
// purpose : SLOT called when selection changed
|
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_DeleteGroupDlg::onSelectionDone()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBlockSelection)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myListGrp.clear();
|
|
|
|
QStringList aNames;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
SALOME_ListIO aListIO;
|
|
|
|
mySelectionMgr->selectedObjects(aListIO);
|
|
|
|
SALOME_ListIteratorOfListIO anIter (aListIO);
|
|
|
|
for (; anIter.More(); anIter.Next()) {
|
|
|
|
SMESH::SMESH_GroupBase_var aGroup =
|
|
|
|
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
|
|
|
|
if (!aGroup->_is_nil()) {
|
|
|
|
aNames.append(aGroup->GetName());
|
|
|
|
myListGrp.append(aGroup);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
myListBox->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
myListBox->insertStringList(aNames);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onDeactivate()
|
|
|
|
// purpose : SLOT called when dialog must be deativated
|
|
|
|
//=================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_DeleteGroupDlg::onDeactivate()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose : Event filter
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_DeleteGroupDlg::enterEvent (QEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-08 12:18:53 +06:00
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog();
|
2005-06-07 19:22:20 +06:00
|
|
|
setEnabled(true);
|
2005-06-08 12:18:53 +06:00
|
|
|
myViewWindow->SetSelectionMode(ActorSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_DeleteGroupDlg::closeEvent (QCloseEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
onClose();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|