smesh/src/SMESHGUI/SMESHGUI_GroupDlg.cxx

2734 lines
93 KiB
C++
Raw Normal View History

2015-02-13 13:38:35 +05:00
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
2004-06-18 14:34:31 +06:00
//
2012-08-09 16:03:55 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
2012-08-09 16:03:55 +06:00
// 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
2014-02-20 18:25:37 +06:00
// version 2.1 of the License, or (at your option) any later version.
//
2012-08-09 16:03:55 +06:00
// 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.
//
2012-08-09 16:03:55 +06:00
// 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
//
2012-08-09 16:03:55 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-06-18 14:34:31 +06:00
//
2012-08-09 16:03:55 +06:00
// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_GroupDlg.cxx
// Author : Natalia KOPNOVA, Open CASCADE S.A.S.
// SMESH includes
2004-06-18 14:34:31 +06:00
//
#include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_GEOMGenUtils.h"
2009-02-17 10:27:49 +05:00
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_ShapeByMeshDlg.h"
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
#include <SMESH_TypeFilter.hxx>
#include <SMESH_Actor.h>
//#include <SMESH_ActorUtils.h>
2012-08-09 16:03:55 +06:00
#include <SMESH_LogicalFilter.hxx>
2009-02-17 10:27:49 +05:00
// SALOME GEOM includes
#include <GEOMBase.h>
#include <GEOM_SelectionFilter.h>
2013-02-12 20:37:44 +06:00
#include <GEOM_wrap.hxx>
2009-02-17 10:27:49 +05:00
// SALOME GUI includes
#include <QtxColorButton.h>
2009-02-17 10:27:49 +05:00
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
2004-06-18 14:34:31 +06:00
2009-02-17 10:27:49 +05:00
#include <SalomeApp_Tools.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <LightApp_SelectionMgr.h>
2004-06-18 14:34:31 +06:00
2009-02-17 10:27:49 +05:00
#include <SALOME_ListIO.hxx>
2009-02-17 10:27:49 +05:00
#include <SVTK_ViewWindow.h>
2012-08-09 16:03:55 +06:00
#include <VTKViewer_Algorithm.h>
2009-02-17 10:27:49 +05:00
// SALOME KERNEL includes
#include <SALOMEDSClient_Study.hxx>
// VTK Includes
#include <vtkRenderer.h>
#include <vtkActorCollection.h>
// OCCT includes
#include <TColStd_MapOfInteger.hxx>
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
// Qt includes
#include <QButtonGroup>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QToolButton>
#include <QRadioButton>
#include <QCheckBox>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QListWidget>
#include <QStackedWidget>
#include <QKeyEvent>
#include <QMenu>
2004-06-18 14:34:31 +06:00
// STL includes
#include <vector>
#include <algorithm>
#include <set>
2004-06-18 14:34:31 +06:00
2009-02-17 10:27:49 +05:00
#define SPACING 6
#define MARGIN 11
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
enum grpSelectionMode {
grpNoSelection = -1,
grpNodeSelection = 0,
2012-12-13 17:41:29 +06:00
grp0DSelection = 1,
grpBallSelection = 2,
grpEdgeSelection = 3,
grpFaceSelection = 4,
grpVolumeSelection = 5,
grpSubMeshSelection = 6,
grpGroupSelection = 7,
grpMeshSelection = 8,
grpGeomSelection = 9,
grpAllSelection = 10,
2012-08-09 16:03:55 +06:00
};
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : SMESHGUI_GroupDlg()
// purpose :
2004-06-18 14:34:31 +06:00
//=================================================================================
2009-02-17 10:27:49 +05:00
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
2012-08-09 16:03:55 +06:00
SMESH::SMESH_Mesh_ptr theMesh )
2009-02-17 10:27:49 +05:00
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myStoredShownEntity(0),
2009-02-17 10:27:49 +05:00
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ),
myNameChanged( false ),
2012-08-09 16:03:55 +06:00
myIsApplyAndClose( false ),
myNbChangesOfContents(0)
2004-06-18 14:34:31 +06:00
{
2009-02-17 10:27:49 +05:00
initDialog( true );
if ( !theMesh->_is_nil() )
init( theMesh );
else
{
mySelectSubMesh->setEnabled( false );
mySelectGroup->setEnabled( false );
myGeomGroupBtn->setEnabled( false );
myGeomGroupLine->setEnabled( false );
2004-12-01 15:48:31 +05:00
}
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : SMESHGUI_GroupDlg()
// purpose :
//=================================================================================
2009-02-17 10:27:49 +05:00
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
2012-08-09 16:03:55 +06:00
SMESH::SMESH_GroupBase_ptr theGroup,
2009-02-17 10:27:49 +05:00
const bool theIsConvert )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myStoredShownEntity(0),
2009-02-17 10:27:49 +05:00
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ),
2012-08-09 16:03:55 +06:00
myNameChanged( false ),
myNbChangesOfContents(0) // just not to use uninitialized variable
2004-06-18 14:34:31 +06:00
{
2009-02-17 10:27:49 +05:00
initDialog( false );
if ( !theGroup->_is_nil() )
init( theGroup, theIsConvert );
else
{
mySelectSubMesh->setEnabled( false );
mySelectGroup->setEnabled( false );
myCurrentLineEdit = myMeshGroupLine;
2012-08-09 16:03:55 +06:00
setSelectionMode( grpGroupSelection );
2004-12-01 15:48:31 +05:00
}
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : SMESHGUI_GroupDlg()
// purpose :
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_GroupDlg::initDialog( bool create)
2004-06-18 14:34:31 +06:00
{
2009-02-17 10:27:49 +05:00
setModal( false );
setAttribute( Qt::WA_DeleteOnClose, true );
2004-06-18 14:34:31 +06:00
myFilterDlg = 0;
2004-12-01 15:48:31 +05:00
myCreate = create;
myCurrentLineEdit = 0;
myShapeByMeshOp = 0;
myGeomPopup = 0;
myGeomObjects = new GEOM::ListOfGO();
2009-02-17 10:27:49 +05:00
myGeomObjects->length( 0 );
2009-02-17 10:27:49 +05:00
QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
2004-06-18 14:34:31 +06:00
2009-02-17 10:27:49 +05:00
setWindowTitle( create ? tr( "SMESH_CREATE_GROUP_TITLE" ) : tr( "SMESH_EDIT_GROUP_TITLE" ) );
myHelpFileName = create ? "creating_groups_page.html" : "editing_groups_page.html";
2009-02-17 10:27:49 +05:00
setSizeGripEnabled( true);
2004-06-18 14:34:31 +06:00
2009-02-17 10:27:49 +05:00
QGridLayout* aMainLayout = new QGridLayout( this );
aMainLayout->setMargin( MARGIN );
aMainLayout->setSpacing( SPACING );
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QLabel* meshGroupLab = new QLabel( create ? tr( "SMESH_MESH" ) : tr( "SMESH_GROUP" ), this );
myMeshGroupBtn = new QPushButton( this );
myMeshGroupBtn->setIcon( image0 );
myMeshGroupLine = new QLineEdit( this );
myMeshGroupLine->setReadOnly( true );
2004-06-18 14:34:31 +06:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QGroupBox* aTypeBox = new QGroupBox( tr( "SMESH_ELEMENTS_TYPE" ), this );
myTypeGroup = new QButtonGroup( this );
QHBoxLayout* aTypeBoxLayout = new QHBoxLayout( aTypeBox );
aTypeBoxLayout->setMargin( MARGIN );
aTypeBoxLayout->setSpacing( SPACING );
2004-06-18 14:34:31 +06:00
QStringList types;
2009-02-17 10:27:49 +05:00
types.append( tr( "MESH_NODE" ) );
2012-12-13 17:41:29 +06:00
types.append( tr( "SMESH_ELEM0D" ) );
2012-08-09 16:03:55 +06:00
types.append( tr( "SMESH_BALL_ELEM" ) );
2009-02-17 10:27:49 +05:00
types.append( tr( "SMESH_EDGE" ) );
types.append( tr( "SMESH_FACE" ) );
types.append( tr( "SMESH_VOLUME" ) );
2004-06-18 14:34:31 +06:00
QRadioButton* rb;
2009-02-17 10:27:49 +05:00
for ( int i = 0; i < types.count(); i++ )
{
rb = new QRadioButton( types[i], aTypeBox );
myTypeGroup->addButton( rb, i );
aTypeBoxLayout->addWidget( rb );
2004-06-18 14:34:31 +06:00
}
2009-02-17 10:27:49 +05:00
aTypeBox->setEnabled( create );
2004-06-18 14:34:31 +06:00
myTypeId = -1;
2004-06-18 14:34:31 +06:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QLabel* aName = new QLabel( tr( "SMESH_NAME" ), this );
aName->setMinimumWidth( 50 );
myName = new QLineEdit( this );
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QGroupBox* aGrpTypeBox = new QGroupBox( tr( "SMESH_GROUP_TYPE" ), this );
myGrpTypeGroup = new QButtonGroup( this );
QHBoxLayout* aGrpTypeBoxLayout = new QHBoxLayout( aGrpTypeBox );
aGrpTypeBoxLayout->setMargin( MARGIN );
aGrpTypeBoxLayout->setSpacing( SPACING );
QRadioButton* rb1 = new QRadioButton( tr( "SMESH_GROUP_STANDALONE" ), aGrpTypeBox );
QRadioButton* rb2 = new QRadioButton( tr( "SMESH_GROUP_GEOMETRY" ), aGrpTypeBox );
2012-08-09 16:03:55 +06:00
QRadioButton* rb3 = new QRadioButton( tr( "SMESH_GROUP_FILTER" ), aGrpTypeBox );
2009-02-17 10:27:49 +05:00
myGrpTypeGroup->addButton( rb1, 0 );
myGrpTypeGroup->addButton( rb2, 1 );
2012-08-09 16:03:55 +06:00
myGrpTypeGroup->addButton( rb3, 2 );
2009-02-17 10:27:49 +05:00
aGrpTypeBoxLayout->addWidget( rb1 );
aGrpTypeBoxLayout->addWidget( rb2 );
2012-08-09 16:03:55 +06:00
aGrpTypeBoxLayout->addWidget( rb3 );
2009-02-17 10:27:49 +05:00
aGrpTypeBox->setEnabled( create );
2004-12-01 15:48:31 +05:00
myGrpTypeId = -1;
/***************************************************************/
2009-02-17 10:27:49 +05:00
myWGStack = new QStackedWidget( this );
QWidget* wg1 = new QWidget( myWGStack );
QWidget* wg2 = new QWidget( myWGStack );
2012-08-09 16:03:55 +06:00
QWidget* wg3 = new QWidget( myWGStack );
2004-06-18 14:34:31 +06:00
/***************************************************************/
2012-08-09 16:03:55 +06:00
QGroupBox* aContentBox = new QGroupBox( tr( "SMESH_CONTENT" ), wg1 );
2009-02-17 10:27:49 +05:00
QGridLayout* aContentBoxLayout = new QGridLayout( aContentBox );
aContentBoxLayout->setMargin( MARGIN );
aContentBoxLayout->setSpacing( SPACING );
2012-08-09 16:03:55 +06:00
mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), aContentBox );
myAllowElemsModif = new QCheckBox( tr( "ALLOW_ELEM_LIST_MODIF" ), aContentBox );
myElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox );
myElements = new QListWidget( aContentBox );
2009-02-17 10:27:49 +05:00
myElements->setSelectionMode( QListWidget::ExtendedSelection );
2012-08-09 16:03:55 +06:00
myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), aContentBox );
myAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox );
myRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox );
mySortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox );
2009-02-17 10:27:49 +05:00
2012-08-09 16:03:55 +06:00
aContentBoxLayout->addWidget( mySelectAll, 0, 0 );
aContentBoxLayout->addWidget( myAllowElemsModif, 1, 0 );
aContentBoxLayout->addWidget( myFilterBtn, 1, 1 );
aContentBoxLayout->addWidget( myElementsLab, 2, 0 );
aContentBoxLayout->addWidget( myElements, 3, 0, 6, 1 );
aContentBoxLayout->addWidget( myAddBtn, 3, 1 );
aContentBoxLayout->addWidget( myRemoveBtn, 4, 1 );
aContentBoxLayout->addWidget( mySortBtn, 8, 1 );
2009-02-17 10:27:49 +05:00
aContentBoxLayout->setColumnStretch( 0, 1 );
2012-08-09 16:03:55 +06:00
aContentBoxLayout->setRowStretch( 3, 1 );
aContentBoxLayout->setRowStretch( 6, 1 );
2004-06-18 14:34:31 +06:00
/***************************************************************/
2012-08-09 16:03:55 +06:00
mySelectBox = new QGroupBox( tr( "SMESH_SELECT_FROM" ), wg1 );
QGridLayout* mySelectBoxLayout = new QGridLayout( mySelectBox );
mySelectBoxLayout->setMargin( MARGIN );
mySelectBoxLayout->setSpacing( SPACING );
2009-02-17 10:27:49 +05:00
2012-08-09 16:03:55 +06:00
mySelectSubMesh = new QCheckBox( tr( "SMESH_SUBMESH" ), mySelectBox );
mySubMeshBtn = new QPushButton( mySelectBox );
2009-02-17 10:27:49 +05:00
mySubMeshBtn->setIcon( image0 );
2012-08-09 16:03:55 +06:00
mySubMeshLine = new QLineEdit( mySelectBox );
2009-02-17 10:27:49 +05:00
mySubMeshLine->setReadOnly( true );
onSelectSubMesh( false );
2012-08-09 16:03:55 +06:00
mySelectGroup = new QCheckBox( tr( "SMESH_GROUP" ), mySelectBox );
myGroupBtn = new QPushButton( mySelectBox );
2009-02-17 10:27:49 +05:00
myGroupBtn->setIcon( image0 );
2012-08-09 16:03:55 +06:00
myGroupLine = new QLineEdit( mySelectBox );
2009-02-17 10:27:49 +05:00
myGroupLine->setReadOnly( true );
onSelectGroup( false );
2012-08-09 16:03:55 +06:00
mySelectBoxLayout->addWidget( mySelectSubMesh, 0, 0 );
mySelectBoxLayout->addWidget( mySubMeshBtn, 0, 1 );
mySelectBoxLayout->addWidget( mySubMeshLine, 0, 2 );
mySelectBoxLayout->addWidget( mySelectGroup, 1, 0 );
mySelectBoxLayout->addWidget( myGroupBtn, 1, 1 );
mySelectBoxLayout->addWidget( myGroupLine, 1, 2 );
2009-02-17 10:27:49 +05:00
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QVBoxLayout* wg1Layout = new QVBoxLayout( wg1 );
wg1Layout->setMargin( 0 );
wg1Layout->setSpacing( SPACING );
wg1Layout->addWidget( aContentBox );
2012-08-09 16:03:55 +06:00
wg1Layout->addWidget( mySelectBox );
2009-02-17 10:27:49 +05:00
wg1Layout->setStretchFactor( aContentBox, 10 );
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QLabel* geomObject = new QLabel( tr( "SMESH_OBJECT_GEOM" ), wg2 );
myGeomGroupBtn = new QToolButton( wg2 );
myGeomGroupBtn->setIcon( image0 );
myGeomGroupBtn->setCheckable( true );
myGeomGroupLine = new QLineEdit( wg2 );
myGeomGroupLine->setReadOnly( true ); //VSR ???
onSelectGeomGroup( false );
myGeomGroupBtn->setEnabled( create );
myGeomGroupLine->setEnabled( create );
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QGridLayout* wg2Layout = new QGridLayout( wg2 );
wg2Layout->setMargin( 0 );
2012-08-09 16:03:55 +06:00
wg2Layout->setSpacing( SPACING );
2009-02-17 10:27:49 +05:00
wg2Layout->addWidget( geomObject, 0, 0 );
wg2Layout->addWidget( myGeomGroupBtn, 0, 1 );
wg2Layout->addWidget( myGeomGroupLine,0, 2 );
wg2Layout->setRowStretch( 1, 5 );
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
/***************************************************************/
QPushButton * aFilter2 = new QPushButton( tr( "SMESH_BUT_FILTER" ), wg3 );
QGridLayout* wg3Layout = new QGridLayout( wg3 );
wg3Layout->setMargin( 0 );
wg3Layout->setSpacing( SPACING );
wg3Layout->addWidget( aFilter2, 0, 0 );
wg3Layout->setRowStretch( 1, 5 );
2004-12-01 15:48:31 +05:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
myWGStack->insertWidget( 0, wg1 );
myWGStack->insertWidget( 1, wg2 );
2012-08-09 16:03:55 +06:00
myWGStack->insertWidget( 2, wg3 );
2004-06-18 14:34:31 +06:00
/***************************************************************/
2009-02-17 10:27:49 +05:00
QGroupBox* aColorBox = new QGroupBox(tr( "SMESH_SET_COLOR" ), this);
QHBoxLayout* aColorBoxLayout = new QHBoxLayout(aColorBox);
aColorBoxLayout->setMargin(MARGIN);
aColorBoxLayout->setSpacing(SPACING);
2009-02-17 10:27:49 +05:00
QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox );
myColorBtn = new QtxColorButton(aColorBox);
myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding,
2012-08-09 16:03:55 +06:00
myColorBtn->sizePolicy().verticalPolicy() );
2009-02-17 10:27:49 +05:00
aColorBoxLayout->addWidget(aColorLab);
aColorBoxLayout->addWidget(myColorBtn);
/***************************************************************/
2009-02-17 10:27:49 +05:00
QFrame* aButtons = new QFrame(this);
aButtons->setFrameStyle( QFrame::Box | QFrame::Sunken );
QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons);
aBtnLayout->setMargin(MARGIN);
aBtnLayout->setSpacing(SPACING);
myOKBtn = new QPushButton(tr( "SMESH_BUT_APPLY_AND_CLOSE" ), aButtons);
myOKBtn->setAutoDefault(true);
myOKBtn->setDefault(true);
myApplyBtn = new QPushButton(tr( "SMESH_BUT_APPLY" ), aButtons);
myApplyBtn->setAutoDefault(true);
myCloseBtn = new QPushButton(tr( "SMESH_BUT_CLOSE" ), aButtons);
myCloseBtn->setAutoDefault(true);
myHelpBtn = new QPushButton(tr( "SMESH_BUT_HELP" ), aButtons);
myHelpBtn->setAutoDefault(true);
aBtnLayout->addWidget(myOKBtn);
aBtnLayout->addSpacing(10);
aBtnLayout->addWidget(myApplyBtn);
aBtnLayout->addSpacing(10);
2004-06-18 14:34:31 +06:00
aBtnLayout->addStretch();
2009-02-17 10:27:49 +05:00
aBtnLayout->addWidget(myCloseBtn);
aBtnLayout->addWidget(myHelpBtn);
2004-06-18 14:34:31 +06:00
/***************************************************************/
2004-12-01 15:48:31 +05:00
aMainLayout->addWidget(meshGroupLab, 0, 0);
aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
aMainLayout->addWidget(myMeshGroupLine, 0, 2);
2009-02-17 10:27:49 +05:00
aMainLayout->addWidget(aTypeBox, 1, 0, 1, 3);
aMainLayout->addWidget(aName, 2, 0);
aMainLayout->addWidget(myName, 2, 2);
aMainLayout->addWidget(aGrpTypeBox, 3, 0, 1, 3);
aMainLayout->addWidget(myWGStack, 4, 0, 1, 3);
aMainLayout->addWidget(aColorBox, 5, 0, 1, 3);
aMainLayout->addWidget(aButtons, 6, 0, 1, 3);
2004-06-18 14:34:31 +06:00
/* signals and slots connections */
2012-08-09 16:03:55 +06:00
connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGrpTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onGrpTypeChanged(int)));
connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int)));
2004-12-01 15:48:31 +05:00
2012-08-09 16:03:55 +06:00
connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
2004-06-18 14:34:31 +06:00
2012-08-09 16:03:55 +06:00
connect(myFilterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
connect(aFilter2, SIGNAL(clicked()), this, SLOT(setFilters()));
connect(mySelectAll, SIGNAL(toggled(bool)), this, SLOT(onSelectAll()));
connect(myAllowElemsModif,SIGNAL(toggled(bool)), this, SLOT(onSelectAll()));
connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
connect(mySortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
2004-06-18 14:34:31 +06:00
connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
2009-02-17 10:27:49 +05:00
connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
2012-08-09 16:03:55 +06:00
connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
2009-02-17 10:27:49 +05:00
connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
2012-08-09 16:03:55 +06:00
connect(myColorBtn, SIGNAL(changed( QColor )), this, SLOT(onColorChanged( QColor )));
2009-02-17 10:27:49 +05:00
2012-08-09 16:03:55 +06:00
connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
2013-02-28 21:07:35 +06:00
connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
2012-08-09 16:03:55 +06:00
connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
2004-06-18 14:34:31 +06:00
/* Init selection */
mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800);
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
2012-08-09 16:03:55 +06:00
mySelectionMode = grpNoSelection;
myMeshFilter = new SMESH_TypeFilter(SMESH::MESH);
2012-08-09 16:03:55 +06:00
mySubMeshFilter = new SMESH_LogicalFilter(QList<SUIT_SelectionFilter*>(),
SMESH_LogicalFilter::LO_OR,
/*takeOwnership=*/true);
myGroupFilter = new SMESH_LogicalFilter(QList<SUIT_SelectionFilter*>(),
SMESH_LogicalFilter::LO_OR,
/*takeOwnership=*/true);
myGeomFilter = new GEOM_SelectionFilter( aStudy, true );
2009-02-17 10:27:49 +05:00
2004-12-01 15:48:31 +05:00
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
2013-02-28 21:07:35 +06:00
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(reject()));
2009-02-17 10:27:49 +05:00
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
2012-08-09 16:03:55 +06:00
connect(mySMESHGUI, SIGNAL(SignalVisibilityChanged()), this, SLOT(onVisibilityChanged()));
connect(mySMESHGUI, SIGNAL(SignalActivatedViewManager()), this, SLOT(onOpenView()));
connect(mySMESHGUI, SIGNAL(SignalCloseView()), this, SLOT(onCloseView()));
2009-02-17 10:27:49 +05:00
rb1->setChecked(true); // VSR !!!
onGrpTypeChanged(0); // VSR!!!
2004-12-01 15:48:31 +05:00
if (myMesh->_is_nil() )
2009-02-17 10:27:49 +05:00
myTypeGroup->button(0)->setChecked(true);
2012-08-09 16:03:55 +06:00
onSelectAll(); //updateButtons();
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : ~SMESHGUI_GroupDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
{
2004-12-01 15:48:31 +05:00
// no need to delete child widgets, Qt does it all for us
2009-02-17 10:27:49 +05:00
if ( myFilterDlg != 0 ) {
myFilterDlg->setParent( 0 );
2004-12-01 15:48:31 +05:00
delete myFilterDlg;
}
2012-08-09 16:03:55 +06:00
if ( myMeshFilter ) delete myMeshFilter;
if ( mySubMeshFilter ) delete mySubMeshFilter;
if ( myGroupFilter ) delete myGroupFilter;
if ( myGeomFilter ) delete myGeomFilter;
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : GetDefaultName()
// purpose : Get the Group Name if Create new Group
//=================================================================================
QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation)
{
2009-02-17 10:27:49 +05:00
QString aName = "";
// collect all object names of SMESH component
SalomeApp_Study* appStudy =
dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( !appStudy ) return aName;
_PTR(Study) aStudy = appStudy->studyDS();
std::set<std::string> aSet;
_PTR(SComponent) aMeshCompo (aStudy->FindComponent( "SMESH" ));
if (aMeshCompo) {
_PTR(ChildIterator) it (aStudy->NewChildIterator(aMeshCompo));
_PTR(SObject) obj;
for (it->InitEx(true); it->More(); it->Next()) {
obj = it->Value();
aSet.insert(obj->GetName());
}
2009-02-17 10:27:49 +05:00
}
2009-02-17 10:27:49 +05:00
// build a unique name
int aNumber = 0;
bool isUnique = false;
while (!isUnique) {
aName = theOperation + "_" + QString::number(++aNumber);
isUnique = (aSet.count(std::string(SMESH::toUtf8(aName))) == 0);
2009-02-17 10:27:49 +05:00
}
2009-02-17 10:27:49 +05:00
return aName;
}
2012-12-13 17:41:29 +06:00
void SMESHGUI_GroupDlg::setDefaultName() const
{
QString aResName;
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
int i=1;
QString aPrefix ="Group_";
_PTR(SObject) anObj;
do
{
aResName = aPrefix + QString::number( i++ );
anObj = aStudy->FindObject( SMESH::toUtf8(aResName) );
2012-12-13 17:41:29 +06:00
}
while ( anObj );
myName->setText(aResName);
}
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
2004-06-18 14:34:31 +06:00
{
2005-06-08 12:18:53 +06:00
mySelectionMgr->installFilter(myMeshFilter);
2004-06-18 14:34:31 +06:00
/* init data from current selection */
2009-02-17 10:27:49 +05:00
restoreShowEntityMode();
2004-06-18 14:34:31 +06:00
myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
2009-02-17 10:27:49 +05:00
setShowEntityMode();
2004-06-18 14:34:31 +06:00
myGroup = SMESH::SMESH_Group::_nil();
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
2012-08-09 16:03:55 +06:00
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
2009-02-17 10:27:49 +05:00
// NPAL19389: create a group with a selection in another group
// set actor of myMesh, if it is visible, else try
// any visible actor of group or submesh of myMesh
SetAppropriateActor();
setDefaultGroupColor();
2012-12-13 17:41:29 +06:00
setDefaultName();
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
if( !aList.IsEmpty() )
{
QString aName = aList.First()->getName();
2014-06-18 14:36:56 +06:00
myMeshGroupLine->setText(aName);//??????
2005-06-08 12:18:53 +06:00
myMeshGroupLine->home( false );
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
myCurrentLineEdit = 0;
2004-06-18 14:34:31 +06:00
2009-02-17 10:27:49 +05:00
myTypeGroup->button(0)->setChecked(true);
2004-06-18 14:34:31 +06:00
onTypeChanged(0);
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
2012-08-09 16:03:55 +06:00
const bool theIsConvert)
2004-06-18 14:34:31 +06:00
{
2009-02-17 10:27:49 +05:00
restoreShowEntityMode();
2004-06-18 14:34:31 +06:00
myMesh = theGroup->GetMesh();
2009-02-17 10:27:49 +05:00
setShowEntityMode();
myNameChanged = true;
myName->blockSignals(true);
myName->setText(SMESH::fromUtf8(theGroup->GetName()));
2009-02-17 10:27:49 +05:00
myName->blockSignals(false);
myName->home(false);
SALOMEDS::Color aColor = theGroup->GetColor();
setGroupColor( aColor );
2009-02-17 10:27:49 +05:00
myMeshGroupLine->setText(SMESH::fromUtf8(theGroup->GetName()));
2004-06-18 14:34:31 +06:00
int aType = 0;
switch(theGroup->GetType()) {
2012-12-13 17:41:29 +06:00
case SMESH::NODE: aType = grpNodeSelection; break;
case SMESH::ELEM0D: aType = grp0DSelection; break;
case SMESH::BALL: aType = grpBallSelection; break;
case SMESH::EDGE: aType = grpEdgeSelection; break;
case SMESH::FACE: aType = grpFaceSelection; break;
case SMESH::VOLUME: aType = grpVolumeSelection; break;
}
2009-02-17 10:27:49 +05:00
myTypeGroup->button(aType)->setChecked(true);
2012-08-09 16:03:55 +06:00
myGroup = SMESH::SMESH_Group::_narrow( theGroup );
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_narrow( theGroup );
myFilter = SMESH::Filter::_nil();
2012-08-09 16:03:55 +06:00
if (myGroup->_is_nil() && myGroupOnGeom->_is_nil() && myGroupOnFilter->_is_nil() )
2009-02-17 10:27:49 +05:00
return;
2009-02-17 10:27:49 +05:00
// NPAL19389: create a group with a selection in another group
// set actor of myMesh, if it is visible, else set
// actor of theGroup, if it is visible, else try
// any visible actor of group or submesh of myMesh
// commented, because an attempt to set selection on not displayed cells leads to error
2012-08-09 16:03:55 +06:00
SetAppropriateActor();
2009-02-17 10:27:49 +05:00
2012-08-09 16:03:55 +06:00
/* SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
if ( !anActor )
anActor = SMESH::FindActorByObject(theGroup);
SMESH::SetPickable(anActor);*/
int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : myGroupOnGeom->_is_nil() ? 2 : 1));
2009-02-17 10:27:49 +05:00
myGrpTypeGroup->button(grpType)->setChecked(true);
onGrpTypeChanged(grpType);
2012-08-09 16:03:55 +06:00
myTypeId = aType;
if ( grpType == 0 ) { // standalone group
2009-02-17 10:27:49 +05:00
myCurrentLineEdit = 0;
myElements->clear();
2012-08-09 16:03:55 +06:00
myAllowElemsModif->setChecked( true );
2009-02-17 10:27:49 +05:00
setSelectionMode(aType);
setShowEntityMode(); // depends on myTypeId
myIdList.clear();
if (!theGroup->IsEmpty()) {
SMESH::long_array_var anElements = theGroup->GetListOfID();
int k = anElements->length();
for (int i = 0; i < k; i++) {
myIdList.append(anElements[i]);
myElements->addItem(QString::number(anElements[i]));
}
2009-02-17 10:27:49 +05:00
myElements->selectAll();
}
2009-02-17 10:27:49 +05:00
}
2012-08-09 16:03:55 +06:00
else if ( grpType == 1 ) // group on geom
2009-02-17 10:27:49 +05:00
{
QString aShapeName( "" );
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
if (!aGroupShape->_is_nil())
{
2009-02-17 10:27:49 +05:00
_PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
2012-08-09 16:03:55 +06:00
if ( aGroupShapeSO )
aShapeName = aGroupShapeSO->GetName().c_str();
2004-06-18 14:34:31 +06:00
}
2009-02-17 10:27:49 +05:00
myGeomGroupLine->setText( aShapeName );
2012-08-09 16:03:55 +06:00
}
else // group on filter
{
myFilter = myGroupOnFilter->GetFilter();
if ( !myFilter->_is_nil() ) {
SMESH::Predicate_var perdicate = myFilter->GetPredicate();
if ( perdicate->_is_nil() )
myFilter = SMESH::Filter::_nil();
}
}
if ( grpType != 0 )
{
2009-02-17 10:27:49 +05:00
myNameChanged = true;
myName->blockSignals(true);
myName->setText(SMESH::fromUtf8(theGroup->GetName()));
2009-02-17 10:27:49 +05:00
myName->blockSignals(false);
}
2012-08-09 16:03:55 +06:00
onSelectAll(); //updateButtons();
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : updateButtons()
// purpose :
2004-06-18 14:34:31 +06:00
//=================================================================================
void SMESHGUI_GroupDlg::updateButtons()
{
2009-02-17 10:27:49 +05:00
bool enable = !myName->text().trimmed().isEmpty();
2012-08-09 16:03:55 +06:00
if ( enable )
{
if (myGrpTypeId == 0) { // standalone
if ( !mySelectAll->isChecked() )
{
if ( myAllowElemsModif->isChecked() )
{
enable = ( myElements->count() > 0 );
}
else if ((enable = !myFilter->_is_nil() ))
{
SMESH::array_of_ElementType_var types = myFilter->GetTypes();
enable = types->length();
}
}
enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil());
}
else if (myGrpTypeId == 1) // on geom
{
if (CORBA::is_nil(myGroupOnGeom)) // creation mode
enable = ( myGeomObjects->length() > 0 && !myMesh->_is_nil() );
}
else if (myGrpTypeId == 2) // on filter
{
if (( enable = !myFilter->_is_nil() ))
if (CORBA::is_nil(myGroupOnFilter) ) // creation mode
enable = !myMesh->_is_nil();
}
}
bool meshHasGeom = ( myMesh->_is_nil() || myMesh->HasShapeToMesh() );
if ( myGrpTypeId != 1 )
{
myGrpTypeGroup->button(1)->setEnabled( meshHasGeom );
}
else
{
myGeomGroupBtn->setEnabled( meshHasGeom );
myGeomGroupLine->setEnabled( meshHasGeom );
}
2009-02-17 10:27:49 +05:00
myOKBtn->setEnabled(enable);
myApplyBtn->setEnabled(enable);
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : onNameChanged()
// purpose :
2004-06-18 14:34:31 +06:00
//=================================================================================
void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
2004-06-18 14:34:31 +06:00
{
2009-02-17 10:27:49 +05:00
myOldName = myName->text();
2004-06-18 14:34:31 +06:00
updateButtons();
2009-02-17 10:27:49 +05:00
myNameChanged = !myName->text().trimmed().isEmpty();
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : onTypeChanged()
2004-12-01 15:48:31 +05:00
// purpose : Group elements type radio button management
2004-06-18 14:34:31 +06:00
//=================================================================================
void SMESHGUI_GroupDlg::onTypeChanged (int id)
2004-06-18 14:34:31 +06:00
{
if (myTypeId != id) {
myElements->clear();
2009-02-17 10:27:49 +05:00
myTypeId = id;
2012-08-09 16:03:55 +06:00
if ( myGrpTypeId == 0 && myCurrentLineEdit == 0)
setSelectionMode(id);
else
setSelectionMode( mySelectionMode++ ); // update according to mySelectionMode
onObjectSelectionChanged();
2009-02-17 10:27:49 +05:00
setShowEntityMode();
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
//=================================================================================
// function : onGrpTypeChanged()
// purpose : Group type radio button management
//=================================================================================
void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
2004-12-01 15:48:31 +05:00
{
if (myGrpTypeId != id) {
2012-08-09 16:03:55 +06:00
myGrpTypeId = id;
2009-02-17 10:27:49 +05:00
myWGStack->setCurrentIndex( id );
myName->blockSignals(true);
myName->setText(myOldName);
myName->blockSignals(false);
2012-08-09 16:03:55 +06:00
onSelectGeomGroup(id != 0);
2004-12-01 15:48:31 +05:00
}
2012-08-09 16:03:55 +06:00
updateButtons();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
2009-02-17 10:27:49 +05:00
// function : onColorChanged()
// purpose : Color button management
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_GroupDlg::onColorChanged(QColor theColor)
{
updateButtons();
}
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : setSelectionMode()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
2004-06-18 14:34:31 +06:00
{
2005-01-20 11:25:54 +05:00
// PAL7314
if (myMesh->_is_nil())
return;
2012-08-09 16:03:55 +06:00
SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
bool isSelectAll = mySelectAll->isChecked() || !myAllowElemsModif->isChecked() || myGrpTypeId != 0;
2004-06-18 14:34:31 +06:00
if (mySelectionMode != theMode) {
// [PAL10408] mySelectionMgr->clearSelected();
mySelectionMgr->clearFilters();
2012-08-09 16:03:55 +06:00
SMESH::RemoveFilters();
if (myActorsList.count() > 0)
for (QListIterator<SMESH_Actor*> it( myActorsList ); it.hasNext(); )
it.next()->SetPointRepresentation(false);
else
SMESH::SetPointRepresentation(false);
2012-08-09 16:03:55 +06:00
switch (theMode) {
case grpNodeSelection:
if ( myGrpTypeId == 0 ) // standalone
{
if (myActorsList.count() > 0)
for (QListIterator<SMESH_Actor*> it( myActorsList ); it.hasNext(); )
it.next()->SetPointRepresentation(true);
else
SMESH::SetPointRepresentation(true);
}
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : NodeSelection);
break;
case grpEdgeSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection);
break;
case grpBallSelection:
2012-10-08 17:56:59 +06:00
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection);
2012-08-09 16:03:55 +06:00
break;
2012-12-13 17:41:29 +06:00
case grp0DSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : Elem0DSelection);
break;
2012-08-09 16:03:55 +06:00
case grpFaceSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection);
break;
case grpVolumeSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : VolumeSelection);
break;
case grpSubMeshSelection: {
SMESH_TypeFilter* f = 0;
switch (myTypeId) {
2012-12-13 17:41:29 +06:00
case grpNodeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH); break;
case grpEdgeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_EDGE); break;
case grpFaceSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_FACE); break;
case grpVolumeSelection: f = new SMESH_TypeFilter(SMESH::SUBMESH_SOLID); break;
default: f = new SMESH_TypeFilter(SMESH::SUBMESH);
2012-08-09 16:03:55 +06:00
}
QList<SUIT_SelectionFilter*> filtList;
filtList.append( f );
2012-12-13 17:41:29 +06:00
filtList.append( new SMESH_TypeFilter(SMESH::SUBMESH_COMPOUND));
2012-08-09 16:03:55 +06:00
mySubMeshFilter->setFilters( filtList );
mySelectionMgr->installFilter( mySubMeshFilter );
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
}
case grpGroupSelection: {
SMESH_TypeFilter* f = 0;
switch (myTypeId) {
2012-12-13 17:41:29 +06:00
case grpNodeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_NODE); break;
case grp0DSelection: f = new SMESH_TypeFilter(SMESH::GROUP_0D); break;
case grpBallSelection: f = new SMESH_TypeFilter(SMESH::GROUP_BALL); break;
case grpEdgeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_EDGE); break;
case grpFaceSelection: f = new SMESH_TypeFilter(SMESH::GROUP_FACE); break;
case grpVolumeSelection: f = new SMESH_TypeFilter(SMESH::GROUP_VOLUME); break;
default: f = new SMESH_TypeFilter(SMESH::GROUP);
2004-06-18 14:34:31 +06:00
}
2012-08-09 16:03:55 +06:00
QList<SUIT_SelectionFilter*> filtList;
filtList.append( f );
myGroupFilter->setFilters( filtList );
mySelectionMgr->installFilter(myGroupFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
}
case grpMeshSelection:
mySelectionMgr->installFilter(myMeshFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
case grpGeomSelection:
mySelectionMgr->installFilter(myGeomFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
default:
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
2004-06-18 14:34:31 +06:00
}
2012-08-09 16:03:55 +06:00
if ( aViewWindow ) aViewWindow->Repaint();
2004-06-18 14:34:31 +06:00
mySelectionMode = theMode;
2009-02-17 10:27:49 +05:00
}
}
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : onApply()
// purpose :
//=================================================================================
bool SMESHGUI_GroupDlg::onApply()
{
if (mySMESHGUI->isActiveStudyLocked())
2004-12-01 15:48:31 +05:00
return false;
2009-02-17 10:27:49 +05:00
if (myName->text().trimmed().isEmpty())
return false;
2012-08-09 16:03:55 +06:00
SMESH::ElementType aType = SMESH::ALL;
switch (myTypeId) {
2012-12-13 17:41:29 +06:00
case grpNodeSelection: aType = SMESH::NODE; break;
case grp0DSelection: aType = SMESH::ELEM0D; break;
case grpBallSelection: aType = SMESH::BALL; break;
case grpEdgeSelection: aType = SMESH::EDGE; break;
case grpFaceSelection: aType = SMESH::FACE; break;
2012-08-09 16:03:55 +06:00
case grpVolumeSelection: aType = SMESH::VOLUME; break;
}
bool anIsOk = false;
QStringList anEntryList;
SMESH::SMESH_GroupBase_var resultGroup;
bool isCreation, isConversion = false;
2012-08-09 16:03:55 +06:00
SUIT_OverrideCursor wc;
2012-08-09 16:03:55 +06:00
if (myGrpTypeId == 0) // standalone
{
if (!mySelectAll->isChecked() && !myElements->count() && myAllowElemsModif->isChecked())
return false;
mySelectionMgr->clearSelected();
2009-02-17 10:27:49 +05:00
if (myGroup->_is_nil()) { // creation or conversion
// check if group on geometry is not null
2012-08-09 16:03:55 +06:00
if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) {
2009-02-17 10:27:49 +05:00
if (myMesh->_is_nil())
return false;
2012-08-09 16:03:55 +06:00
if ( myGroupOnGeom->_is_nil() )
myGroup = myMesh->ConvertToStandalone( myGroupOnFilter );
else
myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
2012-08-09 16:03:55 +06:00
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
isConversion = true;
2009-02-17 10:27:49 +05:00
}
}
if (myGroup->_is_nil()) { // creation
if (myMesh->_is_nil())
return false;
2004-12-01 15:48:31 +05:00
myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
2012-08-09 16:03:55 +06:00
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup );
isCreation = true;
2012-08-09 16:03:55 +06:00
if ( mySelectAll->isChecked() ) {
// select all
myGroup->AddFrom(myMesh.in());
}
else {
// select manually
2012-08-09 16:03:55 +06:00
if ( !myFilter->_is_nil() &&
( myNbChangesOfContents == 1 || !myAllowElemsModif->isChecked()))
{
myGroup->AddFrom( myFilter );
}
else
{
SMESH::long_array_var anIdList = new SMESH::long_array;
int i, k = myElements->count();
anIdList->length(k);
for (i = 0; i < k; i++) {
anIdList[i] = myElements->item(i)->text().toInt();
}
myGroup->Add(anIdList.inout());
}
}
} else { // edition
2004-06-18 14:34:31 +06:00
2012-08-09 16:03:55 +06:00
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup );
isCreation = false;
2012-08-09 16:03:55 +06:00
if ( mySelectAll->isChecked() ) {
// select all
myGroup->Clear();
myGroup->AddFrom(myMesh.in());
2004-06-18 14:34:31 +06:00
}
2012-08-09 16:03:55 +06:00
else {
QList<int> aAddList;
int i, total = myElements->count();
for (i = 0; i < total; i++) {
int anId = myElements->item(i)->text().toInt();
int idx = myIdList.indexOf(anId);
if ( idx == -1 )
aAddList.append(anId);
else
myIdList.removeAt(idx);
}
if (!aAddList.empty()) {
SMESH::long_array_var anIdList = new SMESH::long_array;
int added = aAddList.count();
anIdList->length(added);
for (i = 0; i < added; i++)
anIdList[i] = aAddList[i];
myGroup->Add(anIdList.inout());
}
if (!myIdList.empty()) {
SMESH::long_array_var anIdList = new SMESH::long_array;
int removed = myIdList.count();
anIdList->length(removed);
for (i = 0; i < removed; i++)
anIdList[i] = myIdList[i];
myGroup->Remove(anIdList.inout());
}
/* init for next operation */
myIdList.clear();
for (i = 0; i < total; i++) {
myIdList.append(myElements->item(i)->text().toInt());
}
2009-02-17 10:27:49 +05:00
}
2004-06-18 14:34:31 +06:00
}
2012-08-09 16:03:55 +06:00
anIsOk = true;
}
2012-08-09 16:03:55 +06:00
else if (myGrpTypeId == 1) // on geom object
{
if (CORBA::is_nil(myGroupOnGeom)) { // creation
if (myMesh->_is_nil() || !myGeomObjects->length())
return false;
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if (myGeomObjects->length() == 1) {
2012-08-09 16:03:55 +06:00
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
SMESH::toUtf8(myName->text()),
2012-08-09 16:03:55 +06:00
myGeomObjects[0]);
}
else {
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
if ( aSMESHGen->_is_nil() )
return false;
// create a geometry group
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if (geomGen->_is_nil() || !aStudy)
return false;
2013-02-12 20:37:44 +06:00
GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId());
if (op->_is_nil())
return false;
// check and add all selected GEOM objects: they must be
// a sub-shapes of the main GEOM and must be of one type
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
for ( int i =0; i < myGeomObjects->length(); i++) {
TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
if (i == 0)
aGroupType = aSubShapeType;
else if (aSubShapeType != aGroupType) {
aGroupType = TopAbs_SHAPE;
break;
}
}
2013-02-12 20:37:44 +06:00
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
op->UnionList(aGroupVar, myGeomObjects);
if (op->IsDone()) {
// publish the GEOM group in study
2009-02-17 10:27:49 +05:00
QString aNewGeomGroupName ( "Auto_group_for_" );
aNewGeomGroupName += myName->text();
SALOMEDS::SObject_var aNewGroupSO =
2009-02-17 10:27:49 +05:00
geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar,
SMESH::toUtf8(aNewGeomGroupName), aMeshShape);
}
2009-02-17 10:27:49 +05:00
myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType,
SMESH::toUtf8(myName->text()),
2012-08-09 16:03:55 +06:00
aGroupVar);
}
2012-08-09 16:03:55 +06:00
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom );
isCreation = true;
}
else { // edition
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom );
isCreation = false;
}
anIsOk = true;
}
if (myGrpTypeId == 2) // group on filter
{
if ( myFilter->_is_nil() ) return false;
2012-08-09 16:03:55 +06:00
if (CORBA::is_nil(myGroupOnFilter)) { // creation
if (myMesh->_is_nil())
return false;
2012-08-09 16:03:55 +06:00
myGroupOnFilter = myMesh->CreateGroupFromFilter(aType,
SMESH::toUtf8(myName->text()),
2012-08-09 16:03:55 +06:00
myFilter);
2012-08-09 16:03:55 +06:00
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter );
isCreation = true;
}
else
{
myGroupOnFilter->SetFilter( myFilter );
2012-08-09 16:03:55 +06:00
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnFilter );
isCreation = false;
2004-12-01 15:48:31 +05:00
}
2012-08-09 16:03:55 +06:00
anIsOk = true;
}
if( anIsOk )
{
SALOMEDS::Color aColor = getGroupColor();
resultGroup->SetColor(aColor);
2012-08-09 16:03:55 +06:00
_PTR(SObject) aMeshGroupSO = SMESH::FindSObject( resultGroup );
if( aMeshGroupSO )
anEntryList.append( aMeshGroupSO->GetID().c_str() );
resultGroup->SetName(SMESH::toUtf8(myName->text().trimmed()));
2012-08-09 16:03:55 +06:00
if ( isCreation )
{
SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
2012-08-09 16:03:55 +06:00
/* init for the next operation */
2012-12-13 17:41:29 +06:00
setDefaultName();
2012-08-09 16:03:55 +06:00
myElements->clear();
myGroup = SMESH::SMESH_Group::_nil();
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
myFilter = SMESH::Filter::_nil();
setDefaultGroupColor(); // reset color for case if 'auto-color' feature is enabled.
2012-08-09 16:03:55 +06:00
}
else
{
if ( aMeshGroupSO )
{
if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str()))
{
Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
if ( isConversion ) { // need to reset TVisualObj and actor
SMESH::RemoveVisualObjectWithActors( anIO->getEntry(), true );
SMESH::Update( anIO,true);
myActorsList.clear();
anActor = SMESH::FindActorByEntry( anIO->getEntry() );
if ( !anActor ) return false;
myActorsList.append( anActor );
}
anActor->setName(SMESH::toUtf8(myName->text()));
2012-12-13 17:41:29 +06:00
QColor c;
int delta;
2012-08-09 16:03:55 +06:00
switch ( myTypeId ) {
case grpNodeSelection: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
2012-12-13 17:41:29 +06:00
case grp0DSelection: anActor->Set0DColor ( aColor.R, aColor.G, aColor.B ); break;
2012-08-09 16:03:55 +06:00
case grpBallSelection: anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
case grpEdgeSelection: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
case grpVolumeSelection:
SMESH::GetColor("SMESH", "volume_color", c , delta, "255,0,170|-100");
anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
break;
2012-10-08 17:56:59 +06:00
case grpFaceSelection:
2012-08-09 16:03:55 +06:00
default:
SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100");
anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break;
break;
2012-08-09 16:03:55 +06:00
}
// update a visible group accoding to a changed contents
if ( !isConversion && anActor->GetVisibility() )
{
SMESH::Update( anIO, true );
SMESH::RepaintCurrentView();
}
2012-08-09 16:03:55 +06:00
}
}
2012-08-09 16:03:55 +06:00
}
SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
mySelectionMgr->clearSelected();
2012-08-09 16:03:55 +06:00
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
myObjectToSelect = anApp->browseObjects( anEntryList, isApplyAndClose() );
}
return anIsOk;
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : onOK()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onOK()
{
2012-08-09 16:03:55 +06:00
setIsApplyAndClose( true );
2004-06-18 14:34:31 +06:00
if ( onApply() )
2013-02-28 21:07:35 +06:00
reject();
2012-08-09 16:03:55 +06:00
setIsApplyAndClose( false );
if ( myFilterDlg ) myFilterDlg->UnRegisterFilters();
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : onListSelectionChanged()
// purpose : Called when selection in element list is changed
//=================================================================================
void SMESHGUI_GroupDlg::onListSelectionChanged()
{
2012-08-09 16:03:55 +06:00
//MESSAGE( "SMESHGUI_GroupDlg::onListSelectionChanged(); myActorsList.count() = " << myActorsList.count());
if( myIsBusy || myActorsList.count() == 0 ) return;
myIsBusy = true;
2004-06-18 14:34:31 +06:00
if (myCurrentLineEdit == 0) {
mySelectionMgr->clearSelected();
2004-06-18 14:34:31 +06:00
TColStd_MapOfInteger aIndexes;
2009-02-17 10:27:49 +05:00
QList<QListWidgetItem*> selItems = myElements->selectedItems();
QListWidgetItem* anItem;
foreach(anItem, selItems) aIndexes.Add(anItem->text().toInt());
2012-08-09 16:03:55 +06:00
mySelector->AddOrRemoveIndex(myActorsList.first()->getIO(), aIndexes, false);
SALOME_ListIO aList;
2012-08-09 16:03:55 +06:00
aList.Append(myActorsList.first()->getIO());
mySelectionMgr->setSelectedObjects(aList,false);
2004-06-18 14:34:31 +06:00
}
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : onObjectSelectionChanged()
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onObjectSelectionChanged()
{
2005-06-08 12:18:53 +06:00
if ( myIsBusy || !isEnabled()) return;
2009-02-17 10:27:49 +05:00
if (myCurrentLineEdit == myGeomGroupLine && !myGeomGroupBtn->isChecked()) return;
myIsBusy = true;
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
2009-02-17 10:27:49 +05:00
int aNbSel = aList.Extent();
2004-06-18 14:34:31 +06:00
myElements->clearSelection();
2009-02-17 10:27:49 +05:00
if (myCurrentLineEdit)
{
myCurrentLineEdit->setText( "" );
2004-06-18 14:34:31 +06:00
QString aString = "";
2004-12-01 15:48:31 +05:00
2009-02-17 10:27:49 +05:00
if (myCurrentLineEdit == myMeshGroupLine)
{
mySelectSubMesh->setEnabled(false);
mySelectGroup->setEnabled(false);
2009-02-17 10:27:49 +05:00
myGroupLine->setText( "" );
mySubMeshLine->setText( "" );
myGeomGroupBtn->setEnabled(false);
myGeomGroupLine->setEnabled(false);
2009-02-17 10:27:49 +05:00
myGeomGroupLine->setText( "" );
myGeomObjects = new GEOM::ListOfGO();
myGeomObjects->length(0);
2009-02-17 10:27:49 +05:00
if (myGeomGroupBtn->isChecked())
2012-08-09 16:03:55 +06:00
myGeomGroupBtn->setChecked(false);
if (!myCreate)
2009-02-17 10:27:49 +05:00
myName->setText( "" );
myElements->clear();
2005-06-08 16:45:19 +06:00
if (aNbSel != 1 ) {
myGroup = SMESH::SMESH_Group::_nil();
2009-02-17 10:27:49 +05:00
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
restoreShowEntityMode();
myMesh = SMESH::SMESH_Mesh::_nil();
2009-02-17 10:27:49 +05:00
updateGeomPopup();
updateButtons();
2005-06-08 12:18:53 +06:00
myIsBusy = false;
return;
2004-12-01 15:48:31 +05:00
}
Handle(SALOME_InteractiveObject) IO = aList.First();
if (myCreate) {
2012-08-09 16:03:55 +06:00
restoreShowEntityMode();
myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
2009-02-17 10:27:49 +05:00
setShowEntityMode();
updateGeomPopup();
if (myMesh->_is_nil())
2012-08-09 16:03:55 +06:00
{
updateButtons();
2012-08-09 16:03:55 +06:00
myIsBusy = false;
return;
}
if ( myFilterDlg && !myMesh->_is_nil()){
myFilterDlg->SetMesh( myMesh );
}
myGroup = SMESH::SMESH_Group::_nil();
2009-02-17 10:27:49 +05:00
// NPAL19389: create a group with a selection in another group
// set actor of myMesh, if it is visible, else try
// any visible actor of group or submesh of myMesh
SetAppropriateActor();
setDefaultGroupColor();
if (myName->text().isEmpty())
setDefaultName();
aString = aList.First()->getName();
2009-02-17 10:27:49 +05:00
myMeshGroupLine->setText(aString);
myMeshGroupLine->home( false );
mySelectSubMesh->setEnabled(true);
mySelectGroup->setEnabled(true);
myGeomGroupBtn->setEnabled(true);
myGeomGroupLine->setEnabled(true);
updateButtons();
2009-02-17 10:27:49 +05:00
}
else {
SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
if (aGroup->_is_nil())
2012-08-09 16:03:55 +06:00
{
myIsBusy = false;
return;
2012-08-09 16:03:55 +06:00
}
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2012-08-09 16:03:55 +06:00
myGroup = SMESH::SMESH_Group::_nil();
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
2009-02-17 10:27:49 +05:00
init(aGroup);
2005-06-08 12:18:53 +06:00
myIsBusy = true;
mySelectSubMesh->setEnabled(true);
mySelectGroup->setEnabled(true);
}
myCurrentLineEdit = 0;
2005-06-08 12:18:53 +06:00
myIsBusy = false;
if (!myCreate)
return;
if (myGrpTypeId == 0)
2009-02-17 10:27:49 +05:00
{
2012-08-09 16:03:55 +06:00
if (myTypeId == -1)
onTypeChanged(0);
else
{
myElements->clear();
setSelectionMode(myTypeId);
}
2009-02-17 10:27:49 +05:00
}
2005-06-08 12:18:53 +06:00
myIsBusy = false;
return;
2009-02-17 10:27:49 +05:00
}
else if (myCurrentLineEdit == myGeomGroupLine)
{
myGeomObjects = new GEOM::ListOfGO();
// The mesh SObject
_PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
if (aNbSel == 0 || !aMeshSO)
2009-02-17 10:27:49 +05:00
{
2012-08-09 16:03:55 +06:00
myGeomObjects->length(0);
updateButtons();
myIsBusy = false;
return;
2009-02-17 10:27:49 +05:00
}
myGeomObjects->length(aNbSel);
GEOM::GEOM_Object_var aGeomGroup;
int i = 0;
2009-02-17 10:27:49 +05:00
SALOME_ListIteratorOfListIO anIt (aList);
2009-02-17 10:27:49 +05:00
for (; anIt.More(); anIt.Next())
{
2012-08-09 16:03:55 +06:00
aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value());
2009-02-17 10:27:49 +05:00
// Check if the object is a geometry group
2012-08-09 16:03:55 +06:00
if (CORBA::is_nil(aGeomGroup))
2009-02-17 10:27:49 +05:00
continue;
// Check if group constructed on the same shape as a mesh or on its child
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
// The main shape of the group
GEOM::GEOM_Object_var aGroupMainShape;
2013-02-12 20:37:44 +06:00
if (aGeomGroup->GetType() == 37) {
GEOM::GEOM_IGroupOperations_wrap anOp =
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
2009-02-17 10:27:49 +05:00
aGroupMainShape = anOp->GetMainShape(aGeomGroup);
2013-02-12 20:37:44 +06:00
// aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
}
else {
aGroupMainShape = aGeomGroup;
aGroupMainShape->Register();
}
2009-02-17 10:27:49 +05:00
_PTR(SObject) aGroupMainShapeSO =
aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
_PTR(SObject) anObj, aRef;
bool isRefOrSubShape = false;
if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
isRefOrSubShape = true;
} else {
_PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
_PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
if (aRef->GetID() == aFather->GetID())
isRefOrSubShape = true;
else
aFather = aFather->GetFather();
}
}
}
if (isRefOrSubShape)
myGeomObjects[i++] = aGeomGroup;
}
2009-02-17 10:27:49 +05:00
myGeomObjects->length(i);
if ( i == 0 )
2012-08-09 16:03:55 +06:00
{
myIsBusy = false;
return;
}
2009-02-17 10:27:49 +05:00
aNbSel = i;
}
2009-02-17 10:27:49 +05:00
if (aNbSel >= 1) {
if (aNbSel > 1) {
if (myCurrentLineEdit == mySubMeshLine)
aString = tr( "SMESH_SUBMESH_SELECTED" ).arg(aNbSel);
else if (myCurrentLineEdit == myGroupLine)
aString = tr( "SMESH_GROUP_SELECTED" ).arg(aNbSel);
else if (myCurrentLineEdit == myGeomGroupLine)
aString = tr( "%1 Objects" ).arg(aNbSel);
}
else {
aString = aList.First()->getName();
2004-06-18 14:34:31 +06:00
}
}
myCurrentLineEdit->setText(aString);
myCurrentLineEdit->home(false);
2009-02-17 10:27:49 +05:00
// 07.06.2008 skl for IPAL19574:
// change name of group only if it is empty
if( myName->text().trimmed().isEmpty() || !myNameChanged ) {
myOldName = myName->text();
myName->blockSignals(true);
myName->setText(aString);
myName->blockSignals(false);
}
2004-12-01 15:48:31 +05:00
updateButtons();
2009-02-17 10:27:49 +05:00
}
else // !myCurrentLineEdit: local selection of nodes or elements
{
2012-08-09 16:03:55 +06:00
if (aNbSel == 1 && myActorsList.count() > 0 )
2009-02-17 10:27:49 +05:00
{
// NPAL19389: create a group with a selection in another group
// Switch myActor to the newly selected one, if the last
// is visible and belongs to group or submesh of myMesh
2012-08-09 16:03:55 +06:00
/* Handle(SALOME_InteractiveObject) curIO = myActor->getIO();
2009-02-17 10:27:49 +05:00
Handle(SALOME_InteractiveObject) selIO = aList.First();
if (curIO->hasEntry() && selIO->hasEntry()) {
const char* selEntry = selIO->getEntry();
if (strcmp(curIO->getEntry(), selEntry) != 0) {
// different objects: selected and myActor
SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
if (aViewWindow && aViewWindow->isVisible(selIO)) {
// newly selected actor is visible
// mesh entry
_PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
if (aSObject) {
CORBA::String_var meshEntry = aSObject->GetID().c_str();
int len = strlen(meshEntry);
if (strncmp(selEntry, meshEntry, len) == 0) {
// selected object is myMesh or a part of it
SMESH_Actor* anActor = SMESH::FindActorByEntry(selEntry);
if (anActor) {
myActor = anActor;
SMESH::SetPickable(myActor);
}
}
}
}
}
2012-08-09 16:03:55 +06:00
}*/
2009-02-17 10:27:49 +05:00
// NPAL19389 END
2004-06-18 14:34:31 +06:00
QString aListStr = "";
int aNbItems = 0;
if (myTypeId == 0) {
2012-08-09 16:03:55 +06:00
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedNodes(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
} else {
2012-08-09 16:03:55 +06:00
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedElements(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
2004-06-18 14:34:31 +06:00
}
if (aNbItems > 0) {
2012-08-09 16:03:55 +06:00
QListWidgetItem* anItem;
QList<QListWidgetItem*> listItemsToSel;
QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts);
for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
QList<QListWidgetItem*> found = myElements->findItems(*it, Qt::MatchExactly);
foreach(anItem, found)
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
myElements->blockSignals(blocked);
onListSelectionChanged();
listItemsToSel.clear();
2004-06-18 14:34:31 +06:00
}
}
}
2012-08-09 16:03:55 +06:00
if (myActorsList.count() == 0) {
if (!myGroup->_is_nil()) {
SMESH_Actor* anActor = SMESH::FindActorByObject(myGroup);
if ( anActor )
myActorsList.append( anActor );
}
else if(!myGroupOnGeom->_is_nil()) {
SMESH_Actor* anActor = SMESH::FindActorByObject(myGroupOnGeom);
if ( anActor )
myActorsList.append( anActor );
}
else {
SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh );
if ( anActor )
myActorsList.append( anActor );
}
2004-12-01 15:48:31 +05:00
}
2009-02-17 10:27:49 +05:00
// somehow, if we display the mesh, while selecting from another actor,
// the mesh becomes pickable, and there is no way to select any element
2012-08-09 16:03:55 +06:00
if (myActorsList.count() > 0) {
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
SMESH_Actor* anActor = it.next();
if ( IsActorVisible(anActor) )
anActor->SetPickable(true);
}
}
2009-02-17 10:27:49 +05:00
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2004-06-18 14:34:31 +06:00
}
2012-08-09 16:03:55 +06:00
//=================================================================================
// function : onSelectAll()
// purpose : Called when "Select all" is checked
//=================================================================================
void SMESHGUI_GroupDlg::onSelectAll()
{
bool noElemsModif = ( mySelectAll->isChecked() || !myAllowElemsModif->isChecked() );
myElementsLab->setEnabled( !noElemsModif );
myElements->setEnabled ( !noElemsModif );
2013-04-01 19:05:47 +06:00
myFilterBtn->setEnabled ( !noElemsModif );
2012-08-09 16:03:55 +06:00
myAddBtn->setEnabled ( !noElemsModif );
myRemoveBtn->setEnabled ( !noElemsModif );
mySortBtn->setEnabled ( !noElemsModif );
mySelectBox->setEnabled ( !noElemsModif );
myAllowElemsModif->setEnabled( !mySelectAll->isChecked() );
int selMode = mySelectionMode;
mySelectionMode = grpNoSelection;
setSelectionMode( selMode );
updateButtons();
}
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : onSelectSubMesh()
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
{
if (on) {
if (mySelectGroup->isChecked()) {
mySelectGroup->setChecked(false);
}
2004-12-01 15:48:31 +05:00
//VSR: else if (mySelectGeomGroup->isChecked()) {
//VSR: mySelectGeomGroup->setChecked(false);
//VSR: }
2004-06-18 14:34:31 +06:00
myCurrentLineEdit = mySubMeshLine;
2012-08-09 16:03:55 +06:00
setSelectionMode(grpSubMeshSelection);
2004-06-18 14:34:31 +06:00
}
else {
2009-02-17 10:27:49 +05:00
mySubMeshLine->setText( "" );
2004-06-18 14:34:31 +06:00
myCurrentLineEdit = 0;
if (myTypeId != -1)
setSelectionMode(myTypeId);
}
mySubMeshBtn->setEnabled(on);
mySubMeshLine->setEnabled(on);
}
2004-12-01 15:48:31 +05:00
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : (onSelectGroup)
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onSelectGroup(bool on)
{
if (on) {
if (mySelectSubMesh->isChecked()) {
mySelectSubMesh->setChecked(false);
}
myCurrentLineEdit = myGroupLine;
2012-08-09 16:03:55 +06:00
setSelectionMode(grpGroupSelection);
2004-06-18 14:34:31 +06:00
}
else {
2009-02-17 10:27:49 +05:00
myGroupLine->setText( "" );
2004-06-18 14:34:31 +06:00
myCurrentLineEdit = 0;
if (myTypeId != -1)
setSelectionMode(myTypeId);
}
myGroupBtn->setEnabled(on);
myGroupLine->setEnabled(on);
}
2004-12-01 15:48:31 +05:00
//=================================================================================
// function : (onSelectGeomGroup)
// purpose : Called when group type changed. on == "on geometry" or "on filter"
2004-12-01 15:48:31 +05:00
//=================================================================================
void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
{
if (on) {
if (mySelectSubMesh->isChecked()) {
mySelectSubMesh->setChecked(false);
}
else if (mySelectGroup->isChecked()) {
mySelectGroup->setChecked(false);
}
if ( myGrpTypeId == 1 ) { // on geometry
2012-08-09 16:03:55 +06:00
myCurrentLineEdit = myGeomGroupLine;
updateGeomPopup();
}
else { // on filter
myCurrentLineEdit = 0;
}
setSelectionMode(grpAllSelection);
2004-12-01 15:48:31 +05:00
}
else {
2009-02-17 10:27:49 +05:00
myGeomGroupBtn->setChecked(false);
myGeomObjects->length(0);
2009-02-17 10:27:49 +05:00
myGeomGroupLine->setText( "" );
2004-12-01 15:48:31 +05:00
myCurrentLineEdit = 0;
if (myTypeId != -1)
2012-08-09 16:03:55 +06:00
setSelectionMode( myTypeId );
2004-12-01 15:48:31 +05:00
}
}
2004-06-18 14:34:31 +06:00
//=================================================================================
// function : setCurrentSelection()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::setCurrentSelection()
{
QPushButton* send = (QPushButton*)sender();
myCurrentLineEdit = 0;
2004-12-01 15:48:31 +05:00
if (send == myMeshGroupBtn) {
2012-08-09 16:03:55 +06:00
disconnect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
mySelectionMgr->clearSelected();
2004-12-01 15:48:31 +05:00
if (myCreate)
2012-08-09 16:03:55 +06:00
setSelectionMode(grpMeshSelection);
2004-12-01 15:48:31 +05:00
else
2012-08-09 16:03:55 +06:00
setSelectionMode(grpGroupSelection);
connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
myCurrentLineEdit = myMeshGroupLine;
2004-12-01 15:48:31 +05:00
onObjectSelectionChanged();
}
else if (send == mySubMeshBtn) {
2004-06-18 14:34:31 +06:00
myCurrentLineEdit = mySubMeshLine;
onObjectSelectionChanged();
}
else if (send == myGroupBtn) {
myCurrentLineEdit = myGroupLine;
onObjectSelectionChanged();
}
}
//=================================================================================
// function : setFilters()
// purpose : SLOT. Called when "Filter" button pressed.
2004-06-18 14:34:31 +06:00
//=================================================================================
void SMESHGUI_GroupDlg::setFilters()
{
2012-08-09 16:03:55 +06:00
if(myMesh->_is_nil()) {
SUIT_MessageBox::critical(this,
tr("SMESH_ERROR"),
tr("NO_MESH_SELECTED"));
return;
}
2004-06-18 14:34:31 +06:00
SMESH::ElementType aType = SMESH::ALL;
switch ( myTypeId )
{
2012-12-13 17:41:29 +06:00
case grpNodeSelection: aType = SMESH::NODE; break;
case grp0DSelection: aType = SMESH::ELEM0D; break;
case grpBallSelection: aType = SMESH::BALL; break;
case grpEdgeSelection: aType = SMESH::EDGE; break;
case grpFaceSelection: aType = SMESH::FACE; break;
2012-08-09 16:03:55 +06:00
case grpVolumeSelection: aType = SMESH::VOLUME; break;
default: return;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
2004-06-18 14:34:31 +06:00
if ( myFilterDlg == 0 )
2004-12-01 15:48:31 +05:00
{
myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
2004-12-01 15:48:31 +05:00
connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
}
2004-06-18 14:34:31 +06:00
else
myFilterDlg->Init( aType );
2012-08-09 16:03:55 +06:00
if ( !myGroupOnFilter->_is_nil() )
{
myFilterDlg->SetFilter( myFilter, aType );
myFilterDlg->Init( aType );
}
bool isStandalone = ( sender() == myFilterBtn );
myFilterDlg->SetEnabled( /*setInViewer=*/isStandalone,
/*diffSources=*/isStandalone );
2004-06-18 14:34:31 +06:00
myFilterDlg->SetMesh( myMesh );
myFilterDlg->SetGroup( myGroupOnFilter );
myFilterDlg->SetSelection();
2012-08-09 16:03:55 +06:00
myFilterDlg->SetSourceWg( myElements, false );
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
myFilterDlg->show();
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
//=================================================================================
// function : onFilterAccepted()
// purpose : SLOT. Called when Filter dlg closed with OK button.
// Uncheck "Select submesh" and "Select group" checkboxes
//=================================================================================
void SMESHGUI_GroupDlg::onFilterAccepted()
{
2004-06-18 14:34:31 +06:00
if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
{
mySelectionMode = myTypeId;
mySelectSubMesh->setChecked( false );
mySelectGroup->setChecked( false );
}
2012-08-09 16:03:55 +06:00
// get a filter from myFilterDlg
myFilter = myFilterDlg->GetFilter();
if ( !myFilter->_is_nil() ) {
SMESH::Predicate_var perdicate = myFilter->GetPredicate();
if ( perdicate->_is_nil() )
myFilter = SMESH::Filter::_nil();
}
// set mesh to myFilter
if ( !myFilter->_is_nil() ) {
SMESH::SMESH_Mesh_var mesh = myMesh;
if ( mesh->_is_nil() ) {
if ( !myGroup->_is_nil() )
mesh = myGroup->GetMesh();
else if ( !myGroupOnGeom->_is_nil() )
mesh = myGroupOnGeom->GetMesh();
else if ( !myGroupOnFilter->_is_nil() )
mesh = myGroupOnFilter->GetMesh();
}
myFilter->SetMesh( mesh );
}
updateButtons();
2004-06-18 14:34:31 +06:00
}
//=================================================================================
// function : onAdd()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onAdd()
{
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
int aNbSel = aList.Extent();
2012-08-09 16:03:55 +06:00
if (aNbSel == 0 || myActorsList.count() == 0 || myMesh->_is_nil()) return;
2004-06-18 14:34:31 +06:00
2005-06-08 12:18:53 +06:00
myIsBusy = true;
2012-08-09 16:03:55 +06:00
int sizeBefore = myElements->count();
2004-06-18 14:34:31 +06:00
SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) {
2012-08-09 16:03:55 +06:00
case grpNodeSelection:
2009-02-17 10:27:49 +05:00
aType = SMESH::NODE;
mySelector->SetSelectionMode(NodeSelection);
break;
2012-08-09 16:03:55 +06:00
case grpBallSelection:
aType = SMESH::BALL;
2012-10-08 17:56:59 +06:00
mySelector->SetSelectionMode(BallSelection);
2012-08-09 16:03:55 +06:00
break;
2012-12-13 17:41:29 +06:00
case grp0DSelection:
aType = SMESH::ELEM0D;
mySelector->SetSelectionMode(Elem0DSelection);
break;
2012-08-09 16:03:55 +06:00
case grpEdgeSelection:
2009-02-17 10:27:49 +05:00
aType = SMESH::EDGE;
mySelector->SetSelectionMode(EdgeSelection);
break;
2012-08-09 16:03:55 +06:00
case grpFaceSelection:
2009-02-17 10:27:49 +05:00
aType = SMESH::FACE;
mySelector->SetSelectionMode(FaceSelection);
break;
2012-08-09 16:03:55 +06:00
case grpVolumeSelection:
2009-02-17 10:27:49 +05:00
aType = SMESH::VOLUME;
mySelector->SetSelectionMode(VolumeSelection);
break;
default:
mySelector->SetSelectionMode(ActorSelection);
2004-06-18 14:34:31 +06:00
}
2009-02-17 10:27:49 +05:00
QListWidgetItem* anItem = 0;
QList<QListWidgetItem*> listItemsToSel;
2004-06-18 14:34:31 +06:00
if (myCurrentLineEdit == 0) {
2005-06-08 12:18:53 +06:00
//if (aNbSel != 1) { myIsBusy = false; return; }
2004-06-18 14:34:31 +06:00
QString aListStr = "";
int aNbItems = 0;
if (myTypeId == 0) {
2012-08-09 16:03:55 +06:00
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedNodes(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
2004-06-18 14:34:31 +06:00
}
else {
2012-08-09 16:03:55 +06:00
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
QString tmpStr;
aNbItems += SMESH::GetNameOfSelectedElements(mySelector, it.next()->getIO(), tmpStr);
aListStr += tmpStr;
}
2004-06-18 14:34:31 +06:00
}
if (aNbItems > 0) {
2009-02-17 10:27:49 +05:00
QStringList anElements = aListStr.split( " ", QString::SkipEmptyParts);
2004-06-18 14:34:31 +06:00
for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
2012-08-09 16:03:55 +06:00
QList<QListWidgetItem*> found = myElements->findItems(*it, Qt::MatchExactly);
if (found.count() == 0) {
anItem = new QListWidgetItem(*it);
myElements->addItem(anItem);
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
else {
foreach(anItem, found)
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
2004-06-18 14:34:31 +06:00
}
2009-02-17 10:27:49 +05:00
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
myElements->blockSignals(blocked);
onListSelectionChanged();
listItemsToSel.clear();
2004-06-18 14:34:31 +06:00
}
} else if (myCurrentLineEdit == mySubMeshLine) {
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
2009-02-17 10:27:49 +05:00
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
SALOME_ListIteratorOfListIO anIt (aList);
2009-02-17 10:27:49 +05:00
for ( ; anIt.More(); anIt.Next()) {
SMESH::SMESH_subMesh_var aSubMesh =
SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
2004-12-01 15:48:31 +05:00
if (!aSubMesh->_is_nil()) {
2012-08-09 16:03:55 +06:00
// check if mesh is the same
if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
2004-12-01 15:48:31 +05:00
try {
SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
2004-12-01 15:48:31 +05:00
int k = anElements->length();
for (int i = 0; i < k; i++) {
QString aText = QString::number(anElements[i]);
2009-02-17 10:27:49 +05:00
QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
if (found.count() == 0) {
anItem = new QListWidgetItem(aText);
myElements->addItem(anItem);
2012-08-09 16:03:55 +06:00
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
else {
foreach(anItem, found)
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
2004-12-01 15:48:31 +05:00
}
}
2012-08-09 16:03:55 +06:00
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
myElements->blockSignals(blocked);
onListSelectionChanged();
listItemsToSel.clear();
2004-12-01 15:48:31 +05:00
}
catch (const SALOME::SALOME_Exception& ex) {
SalomeApp_Tools::QtCatchCorbaException(ex);
2004-12-01 15:48:31 +05:00
}
}
2004-06-18 14:34:31 +06:00
}
}
mySelectSubMesh->setChecked(false);
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2004-06-18 14:34:31 +06:00
onListSelectionChanged();
} else if (myCurrentLineEdit == myGroupLine) {
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
2009-02-17 10:27:49 +05:00
SALOME_ListIteratorOfListIO anIt (aList);
2009-02-17 10:27:49 +05:00
for ( ; anIt.More(); anIt.Next()) {
SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIt.Value());
2004-12-01 15:48:31 +05:00
if (!aGroup->_is_nil()) {
2012-08-09 16:03:55 +06:00
// check if mesh is the same
if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
SMESH::long_array_var anElements = aGroup->GetListOfID();
int k = anElements->length();
for (int i = 0; i < k; i++) {
QString aText = QString::number(anElements[i]);
QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
if (found.count() == 0) {
anItem = new QListWidgetItem(aText);
myElements->addItem(anItem);
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
else {
foreach(anItem, found)
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
}
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
myElements->blockSignals(blocked);
onListSelectionChanged();
listItemsToSel.clear();
}
2004-06-18 14:34:31 +06:00
}
}
mySelectGroup->setChecked(false);
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2004-06-18 14:34:31 +06:00
onListSelectionChanged();
} else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
2013-02-12 20:37:44 +06:00
GEOM::GEOM_IGroupOperations_wrap aGroupOp =
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
2004-12-01 15:48:31 +05:00
SMESH::ElementType aGroupType = SMESH::ALL;
switch(aGroupOp->GetType(myGeomObjects[0])) {
2012-08-09 16:03:55 +06:00
case TopAbs_VERTEX: aGroupType = SMESH::NODE; break;
case TopAbs_EDGE: aGroupType = SMESH::EDGE; break;
case TopAbs_FACE: aGroupType = SMESH::FACE; break;
case TopAbs_SOLID: aGroupType = SMESH::VOLUME; break;
2005-06-08 12:18:53 +06:00
default: myIsBusy = false; return;
2004-12-01 15:48:31 +05:00
}
2004-12-01 15:48:31 +05:00
if (aGroupType == aType) {
_PTR(SObject) aGroupSO =
//aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry());
2004-12-01 15:48:31 +05:00
// Construct filter
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
2012-08-09 16:03:55 +06:00
SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();
aBelongToGeom->SetGeom(myGeomObjects[0]);
aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
2004-12-01 15:48:31 +05:00
aBelongToGeom->SetElementType(aType);
aFilter->SetPredicate(aBelongToGeom);
SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
2004-12-01 15:48:31 +05:00
int k = anElements->length();
for (int i = 0; i < k; i++) {
2012-08-09 16:03:55 +06:00
QString aText = QString::number(anElements[i]);
QList<QListWidgetItem*> found = myElements->findItems(aText, Qt::MatchExactly);
if (found.count() == 0) {
anItem = new QListWidgetItem(aText);
myElements->addItem(anItem);
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
else {
foreach(anItem, found)
if (!anItem->isSelected())
listItemsToSel.push_back(anItem);
}
2004-12-01 15:48:31 +05:00
}
2009-02-17 10:27:49 +05:00
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
myElements->blockSignals(blocked);
onListSelectionChanged();
listItemsToSel.clear();
2004-12-01 15:48:31 +05:00
}
2004-12-01 15:48:31 +05:00
//VSR: mySelectGeomGroup->setChecked(false);
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2004-12-01 15:48:31 +05:00
onListSelectionChanged();
}
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2012-08-09 16:03:55 +06:00
if ( sizeBefore < myElements->count() )
++myNbChangesOfContents;
// mySelectionMgr->clearSelected();
2004-06-18 14:34:31 +06:00
updateButtons();
}
//=================================================================================
// function : onRemove()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onRemove()
{
2005-06-08 12:18:53 +06:00
myIsBusy = true;
2012-08-09 16:03:55 +06:00
int sizeBefore = myElements->count();
2004-06-18 14:34:31 +06:00
if (myCurrentLineEdit == 0) {
2009-02-17 10:27:49 +05:00
QList<QListWidgetItem*> selItems = myElements->selectedItems();
QListWidgetItem* item;
foreach(item, selItems) delete item;
} else {
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
int aNbSel = aList.Extent();
2005-06-08 12:18:53 +06:00
if (aNbSel == 0) { myIsBusy = false; return; }
2004-06-18 14:34:31 +06:00
SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) {
2012-12-13 17:41:29 +06:00
case grpNodeSelection: aType = SMESH::NODE; break;
case grp0DSelection: aType = SMESH::ELEM0D; break;
case grpBallSelection: aType = SMESH::BALL; break;
case grpEdgeSelection: aType = SMESH::EDGE; break;
case grpFaceSelection: aType = SMESH::FACE; break;
2012-08-09 16:03:55 +06:00
case grpVolumeSelection: aType = SMESH::VOLUME; break;
2004-06-18 14:34:31 +06:00
}
if (myCurrentLineEdit == mySubMeshLine) {
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
SALOME_ListIteratorOfListIO anIt (aList);
2009-02-17 10:27:49 +05:00
for ( ; anIt.More(); anIt.Next()) {
2012-08-09 16:03:55 +06:00
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
if (!aSubMesh->_is_nil()) {
// check if mesh is the same
if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
if (aType == SMESH::NODE) {
try {
SMESH::long_array_var anElements = aSubMesh->GetNodesId();
int k = anElements->length();
for (int i = 0; i < k; i++) {
QList<QListWidgetItem*> found =
myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
QListWidgetItem* anItem;
foreach(anItem, found) delete anItem;
}
}
catch (const SALOME::SALOME_Exception& ex) {
SalomeApp_Tools::QtCatchCorbaException(ex);
}
}
else {
try {
SMESH::long_array_var anElements = aSubMesh->GetElementsId();
int k = anElements->length();
for (int i = 0; i < k; i++) {
QList<QListWidgetItem*> found =
myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
QListWidgetItem* anItem;
foreach(anItem, found) delete anItem;
}
}
catch (const SALOME::SALOME_Exception& ex) {
SalomeApp_Tools::QtCatchCorbaException(ex);
}
}
}
}
2004-06-18 14:34:31 +06:00
}
}
else if (myCurrentLineEdit == myGroupLine) {
Standard_Boolean aRes;
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
2005-06-08 12:18:53 +06:00
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
SALOME_ListIteratorOfListIO anIt (aList);
2009-02-17 10:27:49 +05:00
for ( ; anIt.More(); anIt.Next()) {
2012-08-09 16:03:55 +06:00
SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
if (aRes && !aGroup->_is_nil()) {
// check if mesh is the same
if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
SMESH::long_array_var anElements = aGroup->GetListOfID();
int k = anElements->length();
for (int i = 0; i < k; i++) {
QList<QListWidgetItem*> found =
myElements->findItems(QString::number(anElements[i]), Qt::MatchExactly);
QListWidgetItem* anItem;
foreach(anItem, found) delete anItem;
}
}
}
2004-06-18 14:34:31 +06:00
}
}
}
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2012-08-09 16:03:55 +06:00
if ( sizeBefore > myElements->count() )
myNbChangesOfContents += 2; // it's used to detect that "Add" was only once
2004-06-18 14:34:31 +06:00
updateButtons();
}
//=================================================================================
// function : onSort()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onSort()
{
// PAL5412: sorts items in ascending by "string" value
// myElements->sort(true);
// myElements->update();
int i, k = myElements->count();
if (k > 0) {
2005-06-08 12:18:53 +06:00
myIsBusy = true;
2009-02-17 10:27:49 +05:00
QList<int> aSelected;
2004-06-18 14:34:31 +06:00
std::vector<int> anArray(k);
// QMemArray<int> anArray(k);
// fill the array
2009-02-17 10:27:49 +05:00
for (i = 0; i < k; i++) {
int id = myElements->item(i)->text().toInt();
anArray[i] = id;
if (myElements->item(i)->isSelected())
2012-08-09 16:03:55 +06:00
aSelected.append(id);
2004-06-18 14:34:31 +06:00
}
// sort & update list
std::sort(anArray.begin(), anArray.end());
// anArray.sort();
myElements->clear();
2009-02-17 10:27:49 +05:00
QListWidgetItem* anItem;
QList<QListWidgetItem*> listItemsToSel;
2004-06-18 14:34:31 +06:00
for (i = 0; i < k; i++) {
2009-02-17 10:27:49 +05:00
anItem = new QListWidgetItem(QString::number(anArray[i]));
myElements->addItem(anItem);
if (aSelected.contains(anArray[i]))
2012-08-09 16:03:55 +06:00
listItemsToSel.push_back(anItem);
2004-06-18 14:34:31 +06:00
}
2009-02-17 10:27:49 +05:00
bool blocked = myElements->signalsBlocked();
myElements->blockSignals(true);
foreach(anItem, listItemsToSel) anItem->setSelected(true);
myElements->blockSignals(blocked);
listItemsToSel.clear();
2005-06-08 12:18:53 +06:00
myIsBusy = false;
2004-06-18 14:34:31 +06:00
}
}
2012-08-09 16:03:55 +06:00
//=================================================================================
// function : onVisibilityChanged()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onVisibilityChanged()
{
SetAppropriateActor();
}
//=================================================================================
2013-02-28 21:07:35 +06:00
// function : SMESHGUI_GroupDlg::reject
// purpose : SLOT called when "Close" button pressed. Close dialog
//=================================================================================
2013-02-28 21:07:35 +06:00
void SMESHGUI_GroupDlg::reject()
2004-06-18 14:34:31 +06:00
{
if (SMESH::GetCurrentVtkView()) {
2005-02-03 13:34:23 +05:00
SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
2004-12-01 15:48:31 +05:00
SMESH::SetPointRepresentation(false);
SMESH::SetPickable();
2009-02-17 10:27:49 +05:00
restoreShowEntityMode();
2004-06-18 14:34:31 +06:00
}
2012-08-09 16:03:55 +06:00
if( isApplyAndClose() && !myObjectToSelect.isEmpty() ) {
SUIT_DataOwnerPtrList aList;
aList.append( new LightApp_DataOwner( myObjectToSelect ) );
mySelectionMgr->setSelected( aList );
}
else
mySelectionMgr->clearSelected();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySelectionMgr->clearFilters();
2004-06-18 14:34:31 +06:00
mySMESHGUI->ResetState();
2013-02-28 21:07:35 +06:00
QDialog::reject();
if ( myFilterDlg ) myFilterDlg->UnRegisterFilters();
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : onOpenView()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onOpenView()
{
if ( mySelector ) {
SMESH::SetPointRepresentation(false);
}
else {
mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true);
}
}
//=================================================================================
// function : onCloseView()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onCloseView()
{
onDeactivate();
mySelector = 0;
}
//=================================================================================
// function : onHelp()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onHelp()
{
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
2009-02-17 10:27:49 +05:00
if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString( "" ), myHelpFileName);
else {
2009-02-17 10:27:49 +05:00
QString platform;
#ifdef WIN32
2009-02-17 10:27:49 +05:00
platform = "winapplication";
#else
2009-02-17 10:27:49 +05:00
platform = "application";
#endif
2009-02-17 10:27:49 +05:00
SUIT_MessageBox::warning(this, tr( "WRN_WARNING" ),
2012-08-09 16:03:55 +06:00
tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
arg(app->resourceMgr()->stringValue( "ExternalBrowser",
platform)).
arg(myHelpFileName));
}
}
//=================================================================================
// function : SMESHGUI_GroupDlg::onDeactivate
// purpose : SLOT called when dialog must be deativated
//=================================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI_GroupDlg::onDeactivate()
{
mySMESHGUI->ResetState();
setEnabled(false);
2004-12-01 15:48:31 +05:00
}
//=================================================================================
// function : SMESHGUI_GroupDlg::enterEvent
// purpose : Event filter
//=================================================================================
void SMESHGUI_GroupDlg::enterEvent (QEvent*)
2004-12-01 15:48:31 +05:00
{
if (!isEnabled()) {
SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
if ( aViewWindow && !mySelector) {
mySelector = aViewWindow->GetSelector();
}
mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true);
2012-08-09 16:03:55 +06:00
mySelectionMode = grpNoSelection;
setSelectionMode(myTypeId);
//mySMESHGUI->SetActiveDialogBox((QDialog*)this);
mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800);
2004-12-01 15:48:31 +05:00
}
}
//=================================================================================
// function : keyPressEvent()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e )
{
QDialog::keyPressEvent( e );
if ( e->isAccepted() )
return;
2009-02-17 10:27:49 +05:00
if ( e->key() == Qt::Key_F1 )
{
e->accept();
onHelp();
}
}
//================================================================================
/*!
* \brief Enable showing of the popup when Geometry selection btn is clicked
* \param enable - true to enable
*/
//================================================================================
enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
void SMESHGUI_GroupDlg::updateGeomPopup()
{
bool enable = false;
if ( !myMesh->_is_nil() )
enable = myMesh->NbEdges() > 0;
if ( myGeomGroupBtn )
{
disconnect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
if ( enable ) {
if ( !myGeomPopup ) {
2009-02-17 10:27:49 +05:00
myGeomPopup = new QMenu(this);
myActions[myGeomPopup->addAction( tr( "DIRECT_GEOM_SELECTION" ) )] = DIRECT_GEOM_INDEX;
myActions[myGeomPopup->addAction( tr( "GEOM_BY_MESH_ELEM_SELECTION" ) )] = GEOM_BY_MESH_INDEX;
connect( myGeomPopup, SIGNAL( triggered( QAction* ) ), SLOT( onGeomPopup( QAction* ) ) );
}
connect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
}
}
}
//=================================================================================
// function : onGeomSelectionButton()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn)
{
if ( myGeomPopup && isBtnOn )
{
myCurrentLineEdit = myGeomGroupLine;
2009-02-17 10:27:49 +05:00
QAction* a = myGeomPopup->exec( QCursor::pos() );
if (!a || myActions[a] == DIRECT_GEOM_INDEX)
2012-08-09 16:03:55 +06:00
setSelectionMode(grpGeomSelection);
}
else if (!isBtnOn)
{
myCurrentLineEdit = 0;
2012-08-09 16:03:55 +06:00
setSelectionMode(grpAllSelection);
}
}
//=================================================================================
// function : onGeomPopup()
// purpose :
//=================================================================================
2009-02-17 10:27:49 +05:00
void SMESHGUI_GroupDlg::onGeomPopup( QAction* a )
{
2009-02-17 10:27:49 +05:00
int index = myActions[a];
if ( index == GEOM_BY_MESH_INDEX )
{
2012-08-09 16:03:55 +06:00
mySelectionMode = grpNoSelection;
if ( !myShapeByMeshOp ) {
2012-08-09 16:03:55 +06:00
myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
}
// set mesh object to SMESHGUI_ShapeByMeshOp and start it
if ( !myMesh->_is_nil() ) {
2012-08-09 16:03:55 +06:00
myIsBusy = true;
hide(); // stop processing selection
2012-08-09 16:03:55 +06:00
myIsBusy = false;
myShapeByMeshOp->setModule( mySMESHGUI );
myShapeByMeshOp->setStudy( 0 ); // it's really necessary
myShapeByMeshOp->SetMesh( myMesh );
myShapeByMeshOp->start();
}
}
}
//================================================================================
/*!
* \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
*/
//================================================================================
void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op)
{
if ( myShapeByMeshOp == op ) {
mySMESHGUI->getApp()->updateObjectBrowser();
show();
// Select a found geometry object
GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
if ( !aGeomVar->_is_nil() )
{
QString ID = aGeomVar->GetStudyEntry();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
2009-02-17 10:27:49 +05:00
if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.toLatin1().data() )) {
2012-08-09 16:03:55 +06:00
SALOME_ListIO anIOList;
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
anIOList.Append( anIO );
mySelectionMgr->setSelectedObjects( anIOList, false );
onObjectSelectionChanged();
}
}
}
}
//================================================================================
/*!
* \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
*/
//================================================================================
void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op)
{
if ( myShapeByMeshOp == op )
{
show();
2012-08-09 16:03:55 +06:00
setSelectionMode(grpGeomSelection);
}
}
//=================================================================================
// function : setGroupColor()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::setGroupColor( const SALOMEDS::Color& theColor )
{
QColor aQColor( (int)( theColor.R * 255.0 ),
2012-08-09 16:03:55 +06:00
(int)( theColor.G * 255.0 ),
(int)( theColor.B * 255.0 ) );
setGroupQColor( aQColor );
}
//=================================================================================
// function : getGroupColor()
// purpose :
//=================================================================================
SALOMEDS::Color SMESHGUI_GroupDlg::getGroupColor() const
{
QColor aQColor = getGroupQColor();
SALOMEDS::Color aColor;
aColor.R = (float)aQColor.red() / 255.0;
aColor.G = (float)aQColor.green() / 255.0;
aColor.B = (float)aQColor.blue() / 255.0;
return aColor;
}
//=================================================================================
// function : setGroupQColor()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::setGroupQColor( const QColor& theColor )
{
if( theColor.isValid() )
2009-02-17 10:27:49 +05:00
myColorBtn->setColor( theColor );
}
//=================================================================================
// function : getGroupQColor()
// purpose :
//=================================================================================
QColor SMESHGUI_GroupDlg::getGroupQColor() const
{
2009-02-17 10:27:49 +05:00
return myColorBtn->color();
}
//=================================================================================
// function : setDefaultGroupColor()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::setDefaultGroupColor()
{
if( myMesh->_is_nil() )
return;
bool isAutoColor = myMesh->GetAutoColor();
QColor aQColor = myColorBtn->color();
if( !isAutoColor )
{
if ( !aQColor.isValid() ) {
int r = 0, g = 0, b = 0;
SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) );
aQColor.setRgb( r, g, b );
}
}
else
{
#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
#else // old algorithm for auto-colors
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
2009-02-17 10:27:49 +05:00
QList<SALOMEDS::Color> aReservedColors;
for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
{
SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
SALOMEDS::Color aReservedColor = aGroupObject->GetColor();
aReservedColors.append( aReservedColor );
}
SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
#endif // SIMPLE_AUTOCOLOR
aQColor.setRgb( (int)( aColor.R * 255.0 ),
2012-08-09 16:03:55 +06:00
(int)( aColor.G * 255.0 ),
(int)( aColor.B * 255.0 ) );
}
setGroupQColor( aQColor );
}
2009-02-17 10:27:49 +05:00
//=================================================================================
// function : SetAppropriateActor()
// purpose : Find more appropriate of visible actors, set it to myActor, allow picking
// NPAL19389: create a group with a selection in another group.
// if mesh actor is not visible - find any first visible group or sub-mesh
2009-02-17 10:27:49 +05:00
//=================================================================================
bool SMESHGUI_GroupDlg::SetAppropriateActor()
{
bool isActor = false;
2012-08-09 16:03:55 +06:00
myActorsList.clear();
2009-02-17 10:27:49 +05:00
if (myMesh->_is_nil()) return false;
SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
if (myGrpTypeGroup->checkedId() > 0) { // try current group on geometry actor
SMESH_Actor* anActor = 0;
if (!myGroupOnGeom->_is_nil())
anActor = SMESH::FindActorByObject(myGroupOnGeom);
if (!myGroupOnFilter->_is_nil())
anActor = SMESH::FindActorByObject(myGroupOnFilter);
if (anActor && anActor->hasIO())
{
isActor = true;
if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
isActor = false;
else
myActorsList.append(anActor);
2009-02-17 10:27:49 +05:00
}
return anActor;
}
else {
2012-08-09 16:03:55 +06:00
// try mesh actor
SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
if (anActor && anActor->hasIO()) {
isActor = true;
if (aViewWindow && !aViewWindow->isVisible(anActor->getIO()))
isActor = false;
else
myActorsList.append(anActor);
2009-02-17 10:27:49 +05:00
}
2012-08-09 16:03:55 +06:00
// try group actor
SMESH_Actor* aGroupActor = 0;
2012-08-09 16:03:55 +06:00
if (!isActor && !myGroup->_is_nil()) {
aGroupActor = SMESH::FindActorByObject(myGroup);
if (aGroupActor && aGroupActor->hasIO())
myActorsList.append(aGroupActor);
2012-08-09 16:03:55 +06:00
}
// try any visible actor of group or sub-mesh of current mesh
2012-08-09 16:03:55 +06:00
if (aViewWindow) {
// mesh entry
_PTR(SObject) aSObject = SMESH::FindSObject(myMesh);
if (aSObject) {
CORBA::String_var meshEntry = aSObject->GetID().c_str();
int len = strlen(meshEntry);
2012-08-09 16:03:55 +06:00
// iterate on all actors in current view window, search for
// any visible actor, that belongs to group or submesh of current mesh
VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
vtkActorCollection *aCollection = aCopy.GetActors();
int nbItems = aCollection->GetNumberOfItems();
for (int i=0; i<nbItems && !isActor; i++)
{
SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(aCollection->GetItemAsObject(i));
if (anActor && anActor->hasIO()) {
Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
if (aViewWindow->isVisible(anIO)) {
if (anIO->hasEntry() && strncmp(anIO->getEntry(), meshEntry, len) == 0 && !myActorsList.contains(anActor) )
myActorsList.append(anActor);
2009-02-17 10:27:49 +05:00
}
}
}
2009-02-17 10:27:49 +05:00
}
}
// Show a standalone group if nothing else is visible (IPAL52227)
if ( myActorsList.count() == 1 &&
myActorsList[0] == aGroupActor &&
aViewWindow && !aViewWindow->isVisible(aGroupActor->getIO()))
SMESH::UpdateView( aViewWindow, SMESH::eDisplay, aGroupActor->getIO()->getEntry() );
2009-02-17 10:27:49 +05:00
}
2012-08-09 16:03:55 +06:00
if (myActorsList.count() > 0) {
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() ) {
SMESH_Actor* anActor = it.next();
if ( IsActorVisible(anActor) )
anActor->SetPickable(true);
}
}
2012-08-09 16:03:55 +06:00
return ( isActor || (myActorsList.count() > 0) );
2009-02-17 10:27:49 +05:00
}
2009-02-17 10:27:49 +05:00
//=======================================================================
//function : setShowEntityMode
//purpose : make shown only entity corresponding to my type
//=======================================================================
void SMESHGUI_GroupDlg::setShowEntityMode()
{
if ( !myMesh->_is_nil() ) {
if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
if (!myStoredShownEntity)
myStoredShownEntity = actor->GetEntityMode();
switch ( myTypeId ) {
2012-12-13 17:41:29 +06:00
case grpNodeSelection: restoreShowEntityMode(); break;
case grp0DSelection: actor->SetEntityMode( SMESH_Actor::e0DElements ); break;
case grpBallSelection: actor->SetEntityMode( SMESH_Actor::eBallElem ); break;
case grpEdgeSelection: actor->SetEntityMode( SMESH_Actor::eEdges ); break;
case grpFaceSelection: actor->SetEntityMode( SMESH_Actor::eFaces ); break;
case grpVolumeSelection: actor->SetEntityMode( SMESH_Actor::eVolumes ); break;
2009-02-17 10:27:49 +05:00
}
}
}
}
//=======================================================================
//function : restoreShowEntityMode
//purpose : restore ShowEntity mode of myActor
//=======================================================================
void SMESHGUI_GroupDlg::restoreShowEntityMode()
{
if ( myStoredShownEntity && !myMesh->_is_nil() ) {
if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) ) {
actor->SetEntityMode(myStoredShownEntity);
}
}
myStoredShownEntity = 0;
}
2012-08-09 16:03:55 +06:00
//=======================================================================
//function : IsActorVisible
//purpose : return visibility of the actor
//=======================================================================
bool SMESHGUI_GroupDlg::IsActorVisible( SMESH_Actor* theActor )
{
SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView();
if (theActor && aViewWindow)
return aViewWindow->isVisible(theActor->getIO());
return false;
}
//================================================================
//function : setIsApplyAndClose
//purpose : Set value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
void SMESHGUI_GroupDlg::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
//================================================================
//function : isApplyAndClose
//purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
bool SMESHGUI_GroupDlg::isApplyAndClose() const
{
return myIsApplyAndClose;
}