2013-04-01 19:05:47 +06:00
|
|
|
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2005-12-05 21:31:55 +05: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
|
2005-12-05 21:31:55 +05:00
|
|
|
//
|
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
|
|
|
|
// version 2.1 of the License.
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
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.
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
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
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
2012-08-09 16:03:55 +06:00
|
|
|
// File : SMESHGUI_MergeDlg.cxx
|
2009-02-17 10:27:49 +05:00
|
|
|
// Author : Open CASCADE S.A.S.
|
|
|
|
// SMESH includes
|
2005-12-05 21:31:55 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
#include "SMESHGUI_MergeDlg.h"
|
2005-08-09 17:31:29 +06:00
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
2008-03-07 12:47:05 +05:00
|
|
|
#include "SMESHGUI_MeshUtils.h"
|
2009-02-17 10:27:49 +05:00
|
|
|
#include "SMESHGUI_SpinBox.h"
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SMESH_Actor.h>
|
|
|
|
#include <SMESH_TypeFilter.hxx>
|
|
|
|
#include <SMESH_LogicalFilter.hxx>
|
|
|
|
#include <SMDS_Mesh.hxx>
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SALOME GUI includes
|
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_MessageBox.h>
|
|
|
|
#include <SUIT_OverrideCursor.h>
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <LightApp_Application.h>
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SVTK_ViewModel.h>
|
|
|
|
#include <SVTK_ViewWindow.h>
|
|
|
|
#include <SALOME_ListIO.hxx>
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// OCCT includes
|
2008-03-07 12:47:05 +05:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// IDL includes
|
|
|
|
#include <SALOMEconfig.h>
|
2008-03-07 12:47:05 +05:00
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Group)
|
2009-02-17 10:27:49 +05:00
|
|
|
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// VTK includes
|
2008-03-07 12:47:05 +05:00
|
|
|
#include <vtkUnstructuredGrid.h>
|
|
|
|
#include <vtkRenderer.h>
|
|
|
|
#include <vtkActor2D.h>
|
|
|
|
#include <vtkPoints.h>
|
|
|
|
#include <vtkDataSetMapper.h>
|
|
|
|
#include <vtkMaskPoints.h>
|
|
|
|
#include <vtkSelectVisiblePoints.h>
|
|
|
|
#include <vtkLabeledDataMapper.h>
|
|
|
|
#include <vtkTextProperty.h>
|
|
|
|
#include <vtkIntArray.h>
|
|
|
|
#include <vtkProperty2D.h>
|
|
|
|
#include <vtkPointData.h>
|
2012-08-09 16:03:55 +06:00
|
|
|
#include <vtkConfigure.h>
|
|
|
|
#if !defined(VTK_XVERSION)
|
|
|
|
#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
|
|
|
|
#endif
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// Qt includes
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QButtonGroup>
|
|
|
|
|
|
|
|
#define SPACING 6
|
|
|
|
#define MARGIN 11
|
|
|
|
|
|
|
|
namespace SMESH
|
|
|
|
{
|
|
|
|
class TIdPreview
|
|
|
|
{ // to display in the viewer IDs of the selected elements
|
2008-03-07 12:47:05 +05:00
|
|
|
SVTK_ViewWindow* myViewWindow;
|
|
|
|
|
|
|
|
vtkUnstructuredGrid* myIdGrid;
|
|
|
|
SALOME_Actor* myIdActor;
|
|
|
|
|
|
|
|
vtkUnstructuredGrid* myPointsNumDataSet;
|
|
|
|
vtkMaskPoints* myPtsMaskPoints;
|
|
|
|
vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
|
|
|
|
vtkLabeledDataMapper* myPtsLabeledDataMapper;
|
|
|
|
vtkTextProperty* aPtsTextProp;
|
|
|
|
bool myIsPointsLabeled;
|
|
|
|
vtkActor2D* myPointLabels;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
std::vector<int> myIDs;
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
public:
|
|
|
|
TIdPreview(SVTK_ViewWindow* theViewWindow):
|
|
|
|
myViewWindow(theViewWindow)
|
|
|
|
{
|
|
|
|
myIdGrid = vtkUnstructuredGrid::New();
|
|
|
|
|
|
|
|
// Create and display actor
|
|
|
|
vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
|
2013-03-01 19:13:25 +06:00
|
|
|
aMapper->SetInputData( myIdGrid );
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
myIdActor = SALOME_Actor::New();
|
|
|
|
myIdActor->SetInfinitive(true);
|
|
|
|
myIdActor->VisibilityOff();
|
|
|
|
myIdActor->PickableOff();
|
|
|
|
|
|
|
|
myIdActor->SetMapper( aMapper );
|
|
|
|
aMapper->Delete();
|
|
|
|
|
|
|
|
myViewWindow->AddActor(myIdActor);
|
|
|
|
|
|
|
|
//Definition of points numbering pipeline
|
|
|
|
myPointsNumDataSet = vtkUnstructuredGrid::New();
|
|
|
|
|
|
|
|
myPtsMaskPoints = vtkMaskPoints::New();
|
2013-03-01 19:13:25 +06:00
|
|
|
myPtsMaskPoints->SetInputData(myPointsNumDataSet);
|
2008-03-07 12:47:05 +05:00
|
|
|
myPtsMaskPoints->SetOnRatio(1);
|
|
|
|
|
|
|
|
myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
|
2013-03-01 19:13:25 +06:00
|
|
|
myPtsSelectVisiblePoints->SetInputConnection(myPtsMaskPoints->GetOutputPort());
|
2008-03-07 12:47:05 +05:00
|
|
|
myPtsSelectVisiblePoints->SelectInvisibleOff();
|
|
|
|
myPtsSelectVisiblePoints->SetTolerance(0.1);
|
|
|
|
|
|
|
|
myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
|
2013-03-01 19:13:25 +06:00
|
|
|
myPtsLabeledDataMapper->SetInputConnection(myPtsSelectVisiblePoints->GetOutputPort());
|
2012-08-09 16:03:55 +06:00
|
|
|
#if (VTK_XVERSION < 0x050200)
|
2008-03-07 12:47:05 +05:00
|
|
|
myPtsLabeledDataMapper->SetLabelFormat("%g");
|
2012-08-09 16:03:55 +06:00
|
|
|
#endif
|
2008-03-07 12:47:05 +05:00
|
|
|
myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
|
|
|
|
|
|
|
|
vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
|
|
|
|
aPtsTextProp->SetFontFamilyToTimes();
|
|
|
|
static int aPointsFontSize = 12;
|
|
|
|
aPtsTextProp->SetFontSize(aPointsFontSize);
|
|
|
|
aPtsTextProp->SetBold(1);
|
|
|
|
aPtsTextProp->SetItalic(0);
|
|
|
|
aPtsTextProp->SetShadow(0);
|
|
|
|
myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
|
|
|
|
aPtsTextProp->Delete();
|
|
|
|
|
|
|
|
myIsPointsLabeled = false;
|
|
|
|
|
|
|
|
myPointLabels = vtkActor2D::New();
|
|
|
|
myPointLabels->SetMapper(myPtsLabeledDataMapper);
|
|
|
|
myPointLabels->GetProperty()->SetColor(1,1,1);
|
|
|
|
myPointLabels->SetVisibility(myIsPointsLabeled);
|
|
|
|
|
|
|
|
AddToRender(myViewWindow->getRenderer());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPointsData ( SMDS_Mesh* theMesh,
|
2012-08-09 16:03:55 +06:00
|
|
|
TColStd_MapOfInteger & theNodesIdMap )
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
vtkPoints* aPoints = vtkPoints::New();
|
|
|
|
aPoints->SetNumberOfPoints(theNodesIdMap.Extent());
|
|
|
|
myIDs.clear();
|
|
|
|
|
|
|
|
TColStd_MapIteratorOfMapOfInteger idIter( theNodesIdMap );
|
|
|
|
for( int i = 0; idIter.More(); idIter.Next(), i++ ) {
|
2012-08-09 16:03:55 +06:00
|
|
|
const SMDS_MeshNode* aNode = theMesh->FindNode(idIter.Key());
|
|
|
|
aPoints->SetPoint( i, aNode->X(), aNode->Y(), aNode->Z() );
|
|
|
|
myIDs.push_back(idIter.Key());
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
myIdGrid->SetPoints(aPoints);
|
|
|
|
|
|
|
|
aPoints->Delete();
|
|
|
|
|
|
|
|
myIdActor->GetMapper()->Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetElemsData( TColStd_MapOfInteger & theElemsIdMap,
|
2012-08-09 16:03:55 +06:00
|
|
|
std::list<gp_XYZ> & aGrCentersXYZ )
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
vtkPoints* aPoints = vtkPoints::New();
|
|
|
|
aPoints->SetNumberOfPoints(theElemsIdMap.Extent());
|
|
|
|
myIDs.clear();
|
|
|
|
|
|
|
|
TColStd_MapIteratorOfMapOfInteger idIter( theElemsIdMap );
|
|
|
|
for( ; idIter.More(); idIter.Next() ) {
|
2012-08-09 16:03:55 +06:00
|
|
|
myIDs.push_back(idIter.Key());
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
gp_XYZ aXYZ;
|
2009-02-17 10:27:49 +05:00
|
|
|
std::list<gp_XYZ>::iterator coordIt = aGrCentersXYZ.begin();
|
2008-03-07 12:47:05 +05:00
|
|
|
for( int i = 0; coordIt != aGrCentersXYZ.end(); coordIt++, i++ ) {
|
2012-08-09 16:03:55 +06:00
|
|
|
aXYZ = *coordIt;
|
|
|
|
aPoints->SetPoint( i, aXYZ.X(), aXYZ.Y(), aXYZ.Z() );
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
myIdGrid->SetPoints(aPoints);
|
|
|
|
aPoints->Delete();
|
|
|
|
|
|
|
|
myIdActor->GetMapper()->Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddToRender(vtkRenderer* theRenderer)
|
|
|
|
{
|
|
|
|
myIdActor->AddToRender(theRenderer);
|
|
|
|
|
|
|
|
myPtsSelectVisiblePoints->SetRenderer(theRenderer);
|
|
|
|
theRenderer->AddActor2D(myPointLabels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveFromRender(vtkRenderer* theRenderer)
|
|
|
|
{
|
|
|
|
myIdActor->RemoveFromRender(theRenderer);
|
|
|
|
|
|
|
|
myPtsSelectVisiblePoints->SetRenderer(theRenderer);
|
|
|
|
theRenderer->RemoveActor(myPointLabels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPointsLabeled( bool theIsPointsLabeled, bool theIsActorVisible = true )
|
|
|
|
{
|
|
|
|
myIsPointsLabeled = theIsPointsLabeled && myIdGrid->GetNumberOfPoints();
|
|
|
|
|
|
|
|
if ( myIsPointsLabeled ) {
|
2012-08-09 16:03:55 +06:00
|
|
|
myPointsNumDataSet->ShallowCopy(myIdGrid);
|
|
|
|
vtkDataSet *aDataSet = myPointsNumDataSet;
|
|
|
|
int aNbElem = myIDs.size();
|
|
|
|
vtkIntArray *anArray = vtkIntArray::New();
|
|
|
|
anArray->SetNumberOfValues( aNbElem );
|
|
|
|
for ( int i = 0; i < aNbElem; i++ )
|
|
|
|
anArray->SetValue( i, myIDs[i] );
|
|
|
|
aDataSet->GetPointData()->SetScalars( anArray );
|
|
|
|
anArray->Delete();
|
2013-03-01 19:13:25 +06:00
|
|
|
myPtsMaskPoints->SetInputData( aDataSet );
|
2012-08-09 16:03:55 +06:00
|
|
|
myPointLabels->SetVisibility( theIsActorVisible );
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
else {
|
2012-08-09 16:03:55 +06:00
|
|
|
myPointLabels->SetVisibility( false );
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~TIdPreview()
|
|
|
|
{
|
|
|
|
RemoveFromRender(myViewWindow->getRenderer());
|
|
|
|
|
|
|
|
myIdGrid->Delete();
|
|
|
|
|
|
|
|
myViewWindow->RemoveActor(myIdActor);
|
|
|
|
myIdActor->Delete();
|
|
|
|
|
|
|
|
//Deleting of points numbering pipeline
|
|
|
|
//---------------------------------------
|
|
|
|
myPointsNumDataSet->Delete();
|
|
|
|
|
|
|
|
//myPtsLabeledDataMapper->RemoveAllInputs(); //vtk 5.0 porting
|
|
|
|
myPtsLabeledDataMapper->Delete();
|
|
|
|
|
|
|
|
//myPtsSelectVisiblePoints->UnRegisterAllOutputs(); //vtk 5.0 porting
|
|
|
|
myPtsSelectVisiblePoints->Delete();
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
//myPtsMaskPoints->UnRegisterAllOutputs(); //vtk 5.0 porting
|
2008-03-07 12:47:05 +05:00
|
|
|
myPtsMaskPoints->Delete();
|
|
|
|
|
|
|
|
myPointLabels->Delete();
|
|
|
|
|
|
|
|
// myTimeStamp->Delete();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char * IconFirst[] = {
|
|
|
|
"18 10 2 1",
|
2012-08-09 16:03:55 +06:00
|
|
|
" g None",
|
|
|
|
". g #000000",
|
2008-03-07 12:47:05 +05:00
|
|
|
" . . ",
|
|
|
|
" .. .. .. ",
|
|
|
|
" .. ... ... ",
|
|
|
|
" .. .... .... ",
|
|
|
|
" .. ..... ..... ",
|
|
|
|
" .. ..... ..... ",
|
|
|
|
" .. .... .... ",
|
|
|
|
" .. ... ... ",
|
|
|
|
" .. .. .. ",
|
|
|
|
" . . "};
|
2005-08-09 17:31:29 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
// class : SMESHGUI_MergeDlg()
|
2005-08-09 17:31:29 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESHGUI_MergeDlg::SMESHGUI_MergeDlg (SMESHGUI* theModule, int theAction)
|
2009-02-17 10:27:49 +05:00
|
|
|
: QDialog(SMESH::GetDesktop(theModule)),
|
2005-08-09 17:31:29 +06:00
|
|
|
mySMESHGUI(theModule),
|
|
|
|
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
|
|
|
myAction(theAction)
|
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setModal(false);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
setWindowTitle(myAction == 1 ? tr("SMESH_MERGE_ELEMENTS") : tr("SMESH_MERGE_NODES"));
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
myIdPreview = new SMESH::TIdPreview(SMESH::GetViewWindow( mySMESHGUI ));
|
|
|
|
|
|
|
|
SUIT_ResourceMgr* aResMgr = SMESH::GetResourceMgr( mySMESHGUI );
|
|
|
|
QPixmap IconMergeNodes (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES")));
|
|
|
|
QPixmap IconMergeElems (aResMgr->loadPixmap("SMESH", tr("ICON_DLG_MERGE_ELEMENTS")));
|
|
|
|
QPixmap IconSelect (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT")));
|
|
|
|
QPixmap IconAdd (aResMgr->loadPixmap("SMESH", tr("ICON_APPEND")));
|
|
|
|
QPixmap IconRemove (aResMgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
setSizeGripEnabled(true);
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QVBoxLayout* DlgLayout = new QVBoxLayout(this);
|
|
|
|
DlgLayout->setSpacing(SPACING);
|
|
|
|
DlgLayout->setMargin(MARGIN);
|
2005-08-09 17:31:29 +06:00
|
|
|
|
|
|
|
/***************************************************************/
|
2009-02-17 10:27:49 +05:00
|
|
|
GroupConstructors = new QGroupBox(myAction == 1 ?
|
2012-08-09 16:03:55 +06:00
|
|
|
tr("SMESH_MERGE_ELEMENTS") :
|
|
|
|
tr("SMESH_MERGE_NODES"),
|
|
|
|
this);
|
2009-02-17 10:27:49 +05:00
|
|
|
|
|
|
|
QButtonGroup* ButtonGroup = new QButtonGroup(this);
|
|
|
|
QHBoxLayout* GroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
|
|
|
|
GroupConstructorsLayout->setSpacing(SPACING);
|
|
|
|
GroupConstructorsLayout->setMargin(MARGIN);
|
|
|
|
|
|
|
|
RadioButton = new QRadioButton(GroupConstructors);
|
|
|
|
RadioButton->setIcon(myAction == 1 ? IconMergeElems : IconMergeNodes);
|
|
|
|
RadioButton->setChecked(true);
|
|
|
|
GroupConstructorsLayout->addWidget(RadioButton);
|
|
|
|
ButtonGroup->addButton(RadioButton, 0);
|
2005-08-09 17:31:29 +06:00
|
|
|
|
|
|
|
/***************************************************************/
|
2008-03-07 12:47:05 +05:00
|
|
|
// Controls for mesh defining
|
2009-02-17 10:27:49 +05:00
|
|
|
GroupMesh = new QGroupBox(tr("SMESH_SELECT_WHOLE_MESH"), this);
|
|
|
|
QHBoxLayout* GroupMeshLayout = new QHBoxLayout(GroupMesh);
|
|
|
|
GroupMeshLayout->setSpacing(SPACING);
|
|
|
|
GroupMeshLayout->setMargin(MARGIN);
|
|
|
|
|
|
|
|
TextLabelName = new QLabel(tr("SMESH_NAME"), GroupMesh);
|
|
|
|
SelectMeshButton = new QPushButton(GroupMesh);
|
|
|
|
SelectMeshButton->setIcon(IconSelect);
|
|
|
|
LineEditMesh = new QLineEdit(GroupMesh);
|
2005-08-09 17:31:29 +06:00
|
|
|
LineEditMesh->setReadOnly(true);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
GroupMeshLayout->addWidget(TextLabelName);
|
|
|
|
GroupMeshLayout->addWidget(SelectMeshButton);
|
|
|
|
GroupMeshLayout->addWidget(LineEditMesh);
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
/***************************************************************/
|
|
|
|
// Controls for switch dialog behaviour
|
|
|
|
|
|
|
|
TypeBox = new QGroupBox( tr( "SMESH_MODE" ), this );
|
|
|
|
GroupType = new QButtonGroup( this );
|
|
|
|
QHBoxLayout* aTypeBoxLayout = new QHBoxLayout( TypeBox );
|
|
|
|
aTypeBoxLayout->setMargin( MARGIN );
|
|
|
|
aTypeBoxLayout->setSpacing( SPACING );
|
|
|
|
|
|
|
|
QRadioButton* rb1 = new QRadioButton( tr( "SMESH_AUTOMATIC" ), TypeBox );
|
|
|
|
QRadioButton* rb2 = new QRadioButton( tr( "SMESH_MANUAL" ), TypeBox );
|
|
|
|
GroupType->addButton( rb1, 0 );
|
|
|
|
GroupType->addButton( rb2, 1 );
|
|
|
|
aTypeBoxLayout->addWidget( rb1 );
|
|
|
|
aTypeBoxLayout->addWidget( rb2 );
|
|
|
|
|
|
|
|
myTypeId = 0;
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
/***************************************************************/
|
|
|
|
// Controls for coincident elements detecting
|
2009-02-17 10:27:49 +05:00
|
|
|
GroupCoincident = new QGroupBox(myAction == 1 ?
|
2012-08-09 16:03:55 +06:00
|
|
|
tr("COINCIDENT_ELEMENTS") :
|
|
|
|
tr("COINCIDENT_NODES"),
|
|
|
|
this);
|
|
|
|
|
|
|
|
QVBoxLayout* aCoincidentLayout = new QVBoxLayout(GroupCoincident);
|
|
|
|
aCoincidentLayout->setSpacing(SPACING);
|
|
|
|
aCoincidentLayout->setMargin(MARGIN);
|
2009-02-17 10:27:49 +05:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
if (myAction == 0) { // case merge nodes
|
2012-08-09 16:03:55 +06:00
|
|
|
QWidget* foo = new QWidget(GroupCoincident);
|
|
|
|
TextLabelTolerance = new QLabel(tr("SMESH_TOLERANCE"), foo);
|
|
|
|
SpinBoxTolerance = new SMESHGUI_SpinBox(foo);
|
2009-02-17 10:27:49 +05:00
|
|
|
SpinBoxTolerance->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
GroupExclude = new QGroupBox(tr("EXCLUDE_GROUPS"), foo);
|
|
|
|
GroupExclude->setCheckable( true );
|
|
|
|
GroupExclude->setChecked( false );
|
|
|
|
ListExclude = new QListWidget( GroupExclude );
|
|
|
|
QVBoxLayout* GroupExcludeLayout = new QVBoxLayout(GroupExclude);
|
|
|
|
GroupExcludeLayout->setSpacing(SPACING);
|
|
|
|
GroupExcludeLayout->setMargin(MARGIN);
|
|
|
|
GroupExcludeLayout->addWidget(ListExclude);
|
|
|
|
|
|
|
|
QGridLayout* fooLayout = new QGridLayout( foo );
|
|
|
|
fooLayout->setSpacing(SPACING);
|
|
|
|
fooLayout->setMargin(0);
|
|
|
|
fooLayout->addWidget(TextLabelTolerance, 0, 0 );
|
|
|
|
fooLayout->addWidget(SpinBoxTolerance, 0, 1 );
|
|
|
|
fooLayout->addWidget(GroupExclude, 1, 0, 1, 2 );
|
|
|
|
aCoincidentLayout->addWidget(foo);
|
2009-02-17 10:27:49 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
TextLabelTolerance = 0;
|
|
|
|
SpinBoxTolerance = 0;
|
2012-08-09 16:03:55 +06:00
|
|
|
GroupExclude = 0;
|
|
|
|
ListExclude = 0;
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
GroupCoincidentWidget = new QWidget(GroupCoincident);
|
|
|
|
QGridLayout* GroupCoincidentLayout = new QGridLayout(GroupCoincidentWidget);
|
|
|
|
GroupCoincidentLayout->setSpacing(SPACING);
|
|
|
|
GroupCoincidentLayout->setMargin(0);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
ListCoincident = new QListWidget(GroupCoincidentWidget);
|
2009-02-17 10:27:49 +05:00
|
|
|
ListCoincident->setSelectionMode(QListWidget::ExtendedSelection);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
DetectButton = new QPushButton(tr("DETECT"), GroupCoincidentWidget);
|
|
|
|
AddGroupButton = new QPushButton(tr("SMESH_BUT_ADD"), GroupCoincidentWidget);
|
|
|
|
RemoveGroupButton = new QPushButton(tr("SMESH_BUT_REMOVE"), GroupCoincidentWidget);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
SelectAllCB = new QCheckBox(tr("SELECT_ALL"), GroupCoincidentWidget);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
GroupCoincidentLayout->addWidget(ListCoincident, 0, 0, 4, 2);
|
|
|
|
GroupCoincidentLayout->addWidget(DetectButton, 0, 2);
|
|
|
|
GroupCoincidentLayout->addWidget(AddGroupButton, 2, 2);
|
|
|
|
GroupCoincidentLayout->addWidget(RemoveGroupButton, 3, 2);
|
|
|
|
GroupCoincidentLayout->addWidget(SelectAllCB, 4, 0, 1, 3);
|
|
|
|
GroupCoincidentLayout->setRowMinimumHeight(1, 10);
|
|
|
|
GroupCoincidentLayout->setRowStretch(1, 5);
|
|
|
|
|
|
|
|
aCoincidentLayout->addWidget(GroupCoincidentWidget);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
// Controls for editing the selected group
|
2009-02-17 10:27:49 +05:00
|
|
|
GroupEdit = new QGroupBox(tr("EDIT_SELECTED_GROUP"), this);
|
|
|
|
QGridLayout* GroupEditLayout = new QGridLayout(GroupEdit);
|
|
|
|
GroupEditLayout->setSpacing(SPACING);
|
|
|
|
GroupEditLayout->setMargin(MARGIN);
|
|
|
|
|
|
|
|
ListEdit = new QListWidget(GroupEdit);
|
|
|
|
//ListEdit->setRowMode(QListBox::FixedNumber);
|
|
|
|
//ListEdit->setHScrollBarMode(QScrollView::AlwaysOn);
|
|
|
|
//ListEdit->setVScrollBarMode(QScrollView::AlwaysOff);
|
|
|
|
ListEdit->setFlow( QListView::LeftToRight );
|
|
|
|
ListEdit->setSelectionMode(QListWidget::ExtendedSelection);
|
|
|
|
|
|
|
|
AddElemButton = new QPushButton(GroupEdit);
|
|
|
|
AddElemButton->setIcon(IconAdd);
|
|
|
|
RemoveElemButton = new QPushButton(GroupEdit);
|
|
|
|
RemoveElemButton->setIcon(IconRemove);
|
|
|
|
SetFirstButton = new QPushButton(GroupEdit);
|
|
|
|
SetFirstButton->setIcon(QPixmap(IconFirst));
|
|
|
|
|
|
|
|
GroupEditLayout->addWidget(ListEdit, 0, 0, 2, 1);
|
|
|
|
GroupEditLayout->addWidget(AddElemButton, 0, 1);
|
2008-03-07 12:47:05 +05:00
|
|
|
GroupEditLayout->addWidget(RemoveElemButton, 0, 2);
|
2009-02-17 10:27:49 +05:00
|
|
|
GroupEditLayout->addWidget(SetFirstButton, 1, 1, 1, 2);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
/***************************************************************/
|
|
|
|
GroupButtons = new QGroupBox(this);
|
|
|
|
QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
|
|
|
|
GroupButtonsLayout->setSpacing(SPACING);
|
|
|
|
GroupButtonsLayout->setMargin(MARGIN);
|
|
|
|
|
|
|
|
buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
|
|
|
|
buttonOk->setAutoDefault(true);
|
|
|
|
buttonOk->setDefault(true);
|
|
|
|
buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
|
|
|
|
buttonApply->setAutoDefault(true);
|
|
|
|
buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
|
|
|
|
buttonCancel->setAutoDefault(true);
|
|
|
|
buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
|
|
|
|
buttonHelp->setAutoDefault(true);
|
|
|
|
|
|
|
|
GroupButtonsLayout->addWidget(buttonOk);
|
|
|
|
GroupButtonsLayout->addSpacing(10);
|
|
|
|
GroupButtonsLayout->addWidget(buttonApply);
|
|
|
|
GroupButtonsLayout->addSpacing(10);
|
|
|
|
GroupButtonsLayout->addStretch();
|
|
|
|
GroupButtonsLayout->addWidget(buttonCancel);
|
|
|
|
GroupButtonsLayout->addWidget(buttonHelp);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
/***************************************************************/
|
|
|
|
DlgLayout->addWidget(GroupConstructors);
|
|
|
|
DlgLayout->addWidget(GroupMesh);
|
2012-08-09 16:03:55 +06:00
|
|
|
DlgLayout->addWidget(TypeBox);
|
2009-02-17 10:27:49 +05:00
|
|
|
DlgLayout->addWidget(GroupCoincident);
|
|
|
|
DlgLayout->addWidget(GroupEdit);
|
|
|
|
DlgLayout->addWidget(GroupButtons);
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
GroupCoincidentWidget->setVisible( myAction != 0 );
|
|
|
|
GroupCoincident->setVisible( myAction == 0 );
|
|
|
|
//if GroupExclude->setVisible( myAction == 0 );
|
|
|
|
GroupEdit->hide();
|
|
|
|
|
|
|
|
this->resize(10,10);
|
|
|
|
|
2005-08-09 17:31:29 +06:00
|
|
|
Init(); // Initialisations
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
// function : ~SMESHGUI_MergeDlg()
|
2005-08-09 17:31:29 +06:00
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESHGUI_MergeDlg::~SMESHGUI_MergeDlg()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
delete myIdPreview;
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::Init()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
if (myAction == 0) {
|
2012-08-09 16:03:55 +06:00
|
|
|
SpinBoxTolerance->RangeStepAndValidator(0.0, COORD_MAX, 0.00001, "len_tol_precision");
|
2008-03-07 12:47:05 +05:00
|
|
|
SpinBoxTolerance->SetValue(1e-05);
|
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
RadioButton->setChecked(true);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
GroupType->button(0)->setChecked(true);
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
myEditCurrentArgument = (QWidget*)LineEditMesh;
|
|
|
|
|
|
|
|
myActor = 0;
|
|
|
|
mySubMeshOrGroup = SMESH::SMESH_subMesh::_nil();
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
|
|
|
myIsBusy = false;
|
|
|
|
|
|
|
|
/* signals and slots connections */
|
|
|
|
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
2013-02-28 21:07:35 +06:00
|
|
|
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
|
2008-03-07 12:47:05 +05:00
|
|
|
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
connect(SelectMeshButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
|
|
|
|
connect(DetectButton, SIGNAL (clicked()), this, SLOT(onDetect()));
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(ListCoincident, SIGNAL (itemSelectionChanged()), this, SLOT(onSelectGroup()));
|
2008-03-07 12:47:05 +05:00
|
|
|
connect(AddGroupButton, SIGNAL (clicked()), this, SLOT(onAddGroup()));
|
|
|
|
connect(RemoveGroupButton, SIGNAL (clicked()), this, SLOT(onRemoveGroup()));
|
|
|
|
connect(SelectAllCB, SIGNAL(toggled(bool)), this, SLOT(onSelectAll(bool)));
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(ListEdit, SIGNAL (itemSelectionChanged()), this, SLOT(onSelectElementFromGroup()));
|
2008-03-07 12:47:05 +05:00
|
|
|
connect(AddElemButton, SIGNAL (clicked()), this, SLOT(onAddElement()));
|
|
|
|
connect(RemoveElemButton, SIGNAL (clicked()), this, SLOT(onRemoveElement()));
|
|
|
|
connect(SetFirstButton, SIGNAL( clicked() ), this, SLOT( onSetFirst() ) );
|
2012-08-09 16:03:55 +06:00
|
|
|
connect(GroupType, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int)));
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
|
2005-08-09 17:31:29 +06:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2008-03-07 12:47:05 +05:00
|
|
|
/* to close dialog if study change */
|
2013-02-28 21:07:35 +06:00
|
|
|
connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(reject()));
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
// Init Mesh field from selection
|
|
|
|
SelectionIntoArgument();
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
// Update Buttons
|
|
|
|
updateControls();
|
|
|
|
|
|
|
|
if (myAction == 0)
|
|
|
|
myHelpFileName = "merging_nodes_page.html";
|
|
|
|
else
|
|
|
|
myHelpFileName = "merging_elements_page.html";
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : FindGravityCenter()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::FindGravityCenter(TColStd_MapOfInteger & theElemsIdMap,
|
|
|
|
std::list< gp_XYZ > & theGrCentersXYZ)
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (!myActor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SMDS_Mesh* aMesh = 0;
|
|
|
|
aMesh = myActor->GetObject()->GetMesh();
|
|
|
|
if (!aMesh)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int nbNodes;
|
|
|
|
|
|
|
|
TColStd_MapIteratorOfMapOfInteger idIter( theElemsIdMap );
|
|
|
|
for( ; idIter.More(); idIter.Next() ) {
|
|
|
|
const SMDS_MeshElement* anElem = aMesh->FindElement(idIter.Key());
|
|
|
|
if ( !anElem )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gp_XYZ anXYZ(0., 0., 0.);
|
|
|
|
SMDS_ElemIteratorPtr nodeIt = anElem->nodesIterator();
|
|
|
|
for ( nbNodes = 0; nodeIt->more(); nbNodes++ ) {
|
|
|
|
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
|
|
|
|
anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
|
|
|
|
}
|
|
|
|
anXYZ.Divide( nbNodes );
|
|
|
|
|
|
|
|
theGrCentersXYZ.push_back( anXYZ );
|
|
|
|
}
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
bool SMESHGUI_MergeDlg::ClickOnApply()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
if (mySMESHGUI->isActiveStudyLocked() || myMesh->_is_nil())
|
|
|
|
return false;
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
try {
|
2012-08-09 16:03:55 +06:00
|
|
|
if (myTypeId == 0)
|
|
|
|
onDetect();
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
SUIT_OverrideCursor aWaitCursor;
|
2008-03-07 12:47:05 +05:00
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
|
|
|
|
SMESH::long_array_var anIds = new SMESH::long_array;
|
|
|
|
SMESH::array_of_long_array_var aGroupsOfElements = new SMESH::array_of_long_array;
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
if ( ListCoincident->count() == 0) {
|
|
|
|
if (myAction == 0)
|
|
|
|
SUIT_MessageBox::warning(this,
|
|
|
|
tr("SMESH_WARNING"),
|
|
|
|
tr("SMESH_NO_NODES_DETECTED"));
|
|
|
|
else
|
|
|
|
SUIT_MessageBox::warning(this,
|
|
|
|
tr("SMESH_WARNING"),
|
|
|
|
tr("SMESH_NO_ELEMENTS_DETECTED"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
aGroupsOfElements->length(ListCoincident->count());
|
|
|
|
|
|
|
|
int anArrayNum = 0;
|
2009-02-17 10:27:49 +05:00
|
|
|
for (int i = 0; i < ListCoincident->count(); i++) {
|
|
|
|
QStringList aListIds = ListCoincident->item(i)->text().split(" ", QString::SkipEmptyParts);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
anIds->length(aListIds.count());
|
|
|
|
for (int i = 0; i < aListIds.count(); i++)
|
|
|
|
anIds[i] = aListIds[i].toInt();
|
|
|
|
|
|
|
|
aGroupsOfElements[anArrayNum++] = anIds.inout();
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
if( myAction == 0 )
|
|
|
|
aMeshEditor->MergeNodes (aGroupsOfElements.inout());
|
|
|
|
else
|
|
|
|
aMeshEditor->MergeElements (aGroupsOfElements.inout());
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
if ( myTypeId == 0 ) {
|
2013-02-12 20:37:44 +06:00
|
|
|
if (myAction == 0 )
|
2012-08-09 16:03:55 +06:00
|
|
|
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INFORMATION"),
|
|
|
|
tr("SMESH_MERGED_NODES").arg(QString::number(ListCoincident->count()).toLatin1().data()));
|
|
|
|
else
|
|
|
|
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INFORMATION"),
|
|
|
|
tr("SMESH_MERGED_ELEMENTS").arg(QString::number(ListCoincident->count()).toLatin1().data()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
} catch(...) {
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
ListCoincident->clear();
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
SMESH::UpdateView();
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESHGUI::Modified();
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
return true;
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::ClickOnOk()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
if (ClickOnApply())
|
2013-02-28 21:07:35 +06:00
|
|
|
reject();
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2013-02-28 21:07:35 +06:00
|
|
|
// function : reject()
|
2005-08-09 17:31:29 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2013-02-28 21:07:35 +06:00
|
|
|
void SMESHGUI_MergeDlg::reject()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
myIdPreview->SetPointsLabeled(false);
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESH::SetPointRepresentation(false);
|
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
|
|
|
disconnect(mySMESHGUI, 0, this, 0);
|
|
|
|
mySMESHGUI->ResetState();
|
|
|
|
|
2005-08-09 17:31:29 +06:00
|
|
|
mySelectionMgr->clearFilters();
|
2008-03-07 12:47:05 +05:00
|
|
|
//mySelectionMgr->clearSelected();
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2013-02-28 21:07:35 +06:00
|
|
|
QDialog::reject();
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::ClickOnHelp()
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if (app)
|
|
|
|
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
2009-02-17 10:27:49 +05:00
|
|
|
QString platform;
|
2008-03-07 12:47:05 +05:00
|
|
|
#ifdef WIN32
|
2009-02-17 10:27:49 +05:00
|
|
|
platform = "winapplication";
|
2008-03-07 12:47:05 +05:00
|
|
|
#else
|
2009-02-17 10:27:49 +05:00
|
|
|
platform = "application";
|
2008-03-07 12:47:05 +05:00
|
|
|
#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));
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-09 17:31:29 +06:00
|
|
|
//=================================================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
// function : onEditGroup()
|
|
|
|
// purpose :
|
2005-08-09 17:31:29 +06:00
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onEditGroup()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
|
|
|
|
if ( selItems.count() != 1 ) {
|
2008-03-07 12:47:05 +05:00
|
|
|
ListEdit->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QStringList aNewIds;
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
for (int i = 0; i < ListEdit->count(); i++ )
|
|
|
|
aNewIds.append(ListEdit->item(i)->text());
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
ListCoincident->clearSelection();
|
|
|
|
selItems.first()->setText(aNewIds.join(" "));
|
|
|
|
selItems.first()->setSelected(true);
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : updateControls()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::updateControls()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
if (ListEdit->count() == 0)
|
|
|
|
SetFirstButton->setEnabled(false);
|
2012-08-09 16:03:55 +06:00
|
|
|
bool enable = !(myMesh->_is_nil()) && (ListCoincident->count() || (myTypeId == 0));
|
2008-03-07 12:47:05 +05:00
|
|
|
buttonOk->setEnabled(enable);
|
|
|
|
buttonApply->setEnabled(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onDetect()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onDetect()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if ( myMesh->_is_nil() || LineEditMesh->text().isEmpty() )
|
2005-08-09 17:31:29 +06:00
|
|
|
return;
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
try {
|
2009-02-17 10:27:49 +05:00
|
|
|
SUIT_OverrideCursor aWaitCursor;
|
2008-03-07 12:47:05 +05:00
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
|
|
|
|
ListCoincident->clear();
|
|
|
|
ListEdit->clear();
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
SMESH::array_of_long_array_var aGroupsArray;
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESH::ListOfIDSources_var aExcludeGroups = new SMESH::ListOfIDSources;
|
|
|
|
|
|
|
|
SMESH::SMESH_IDSource_var src;
|
|
|
|
if ( mySubMeshOrGroup->_is_nil() ) src = SMESH::SMESH_IDSource::_duplicate( myMesh );
|
|
|
|
else src = SMESH::SMESH_IDSource::_duplicate( mySubMeshOrGroup );
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
switch (myAction) {
|
|
|
|
case 0 :
|
2012-08-09 16:03:55 +06:00
|
|
|
for ( int i = 0; GroupExclude->isChecked() && i < ListExclude->count(); i++ ) {
|
|
|
|
if ( ListExclude->item( i )->checkState() == Qt::Checked ) {
|
|
|
|
aExcludeGroups->length( aExcludeGroups->length()+1 );
|
|
|
|
aExcludeGroups[ aExcludeGroups->length()-1 ] = SMESH::SMESH_IDSource::_duplicate( myGroups[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aMeshEditor->FindCoincidentNodesOnPartBut(src.in(),
|
|
|
|
SpinBoxTolerance->GetValue(),
|
|
|
|
aGroupsArray.out(),
|
|
|
|
aExcludeGroups.in());
|
2008-03-07 12:47:05 +05:00
|
|
|
break;
|
|
|
|
case 1 :
|
2012-08-09 16:03:55 +06:00
|
|
|
aMeshEditor->FindEqualElements(src.in(), aGroupsArray.out());
|
2008-03-07 12:47:05 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < aGroupsArray->length(); i++) {
|
|
|
|
SMESH::long_array& aGroup = aGroupsArray[i];
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QStringList anIDs;
|
2008-03-07 12:47:05 +05:00
|
|
|
for (int j = 0; j < aGroup.length(); j++)
|
2012-08-09 16:03:55 +06:00
|
|
|
anIDs.append(QString::number(aGroup[j]));
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
ListCoincident->addItem(anIDs.join(" "));
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
} catch(...) {
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
ListCoincident->selectAll();
|
2008-03-07 12:47:05 +05:00
|
|
|
updateControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectGroup()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onSelectGroup()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (myIsBusy || !myActor)
|
|
|
|
return;
|
|
|
|
myEditCurrentArgument = (QWidget*)ListCoincident;
|
|
|
|
|
|
|
|
ListEdit->clear();
|
|
|
|
|
|
|
|
TColStd_MapOfInteger anIndices;
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
|
|
|
|
QListWidgetItem* anItem;
|
|
|
|
QStringList aListIds;
|
|
|
|
|
|
|
|
ListEdit->clear();
|
|
|
|
|
|
|
|
foreach(anItem, selItems) {
|
|
|
|
aListIds = anItem->text().split(" ", QString::SkipEmptyParts);
|
|
|
|
for (int i = 0; i < aListIds.count(); i++)
|
|
|
|
anIndices.Add(aListIds[i].toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selItems.count() == 1) {
|
|
|
|
ListEdit->addItems(aListIds);
|
|
|
|
ListEdit->selectAll();
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
mySelector->AddOrRemoveIndex(myActor->getIO(), anIndices, false);
|
2005-08-09 17:31:29 +06:00
|
|
|
SALOME_ListIO aList;
|
2008-03-07 12:47:05 +05:00
|
|
|
aList.Append(myActor->getIO());
|
|
|
|
mySelectionMgr->setSelectedObjects(aList,false);
|
|
|
|
|
|
|
|
if (myAction == 0) {
|
|
|
|
myIdPreview->SetPointsData(myActor->GetObject()->GetMesh(), anIndices);
|
|
|
|
myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility());
|
|
|
|
}
|
|
|
|
else {
|
2009-02-17 10:27:49 +05:00
|
|
|
std::list< gp_XYZ > aGrCentersXYZ;
|
2008-03-07 12:47:05 +05:00
|
|
|
FindGravityCenter(anIndices, aGrCentersXYZ);
|
|
|
|
myIdPreview->SetElemsData( anIndices, aGrCentersXYZ);
|
|
|
|
myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility());
|
|
|
|
}
|
|
|
|
|
|
|
|
updateControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectAll()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onSelectAll (bool isToggled)
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
if ( isToggled )
|
|
|
|
ListCoincident->selectAll();
|
|
|
|
else
|
|
|
|
ListCoincident->clearSelection();
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectElementFromGroup()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onSelectElementFromGroup()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (myIsBusy || !myActor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TColStd_MapOfInteger anIndices;
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
|
|
|
|
QListWidgetItem* anItem;
|
|
|
|
|
|
|
|
foreach(anItem, selItems)
|
|
|
|
anIndices.Add(anItem->text().toInt());
|
|
|
|
|
|
|
|
SetFirstButton->setEnabled(selItems.count() == 1);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
mySelector->AddOrRemoveIndex(myActor->getIO(), anIndices, false);
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aList.Append(myActor->getIO());
|
|
|
|
mySelectionMgr->setSelectedObjects(aList);
|
|
|
|
|
|
|
|
if (myAction == 0) {
|
|
|
|
myIdPreview->SetPointsData(myActor->GetObject()->GetMesh(), anIndices);
|
|
|
|
myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility());
|
|
|
|
}
|
|
|
|
else {
|
2009-02-17 10:27:49 +05:00
|
|
|
std::list< gp_XYZ > aGrCentersXYZ;
|
2008-03-07 12:47:05 +05:00
|
|
|
FindGravityCenter(anIndices, aGrCentersXYZ);
|
|
|
|
myIdPreview->SetElemsData(anIndices, aGrCentersXYZ);
|
|
|
|
myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onAddGroup()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onAddGroup()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if ( myMesh->_is_nil() || LineEditMesh->text().isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString anIDs = "";
|
2012-08-09 16:03:55 +06:00
|
|
|
int aNbElements = 0;
|
|
|
|
aNbElements = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), anIDs);
|
|
|
|
|
|
|
|
if (aNbElements < 1)
|
|
|
|
return;
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
ListCoincident->clearSelection();
|
2009-02-17 10:27:49 +05:00
|
|
|
ListCoincident->addItem(anIDs);
|
2008-03-07 12:47:05 +05:00
|
|
|
int nbGroups = ListCoincident->count();
|
|
|
|
if (nbGroups) {
|
2009-02-17 10:27:49 +05:00
|
|
|
ListCoincident->setCurrentRow(nbGroups-1);
|
|
|
|
ListCoincident->item(nbGroups-1)->setSelected(true);
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
else {
|
2009-02-17 10:27:49 +05:00
|
|
|
// VSR ? this code seems to be never executed!!!
|
|
|
|
ListCoincident->setCurrentRow(0);
|
|
|
|
//ListCoincident->setSelected(0, true); // VSR: no items - no selection
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
updateControls();
|
|
|
|
}
|
2005-08-09 17:31:29 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : onRemoveGroup()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onRemoveGroup()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (myEditCurrentArgument != (QWidget*)ListCoincident)
|
|
|
|
return;
|
|
|
|
myIsBusy = true;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
|
|
|
|
QListWidgetItem* anItem;
|
|
|
|
|
|
|
|
foreach(anItem, selItems)
|
|
|
|
delete anItem;
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
ListEdit->clear();
|
|
|
|
updateControls();
|
|
|
|
|
|
|
|
myIsBusy = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onAddElement()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onAddElement()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (!myActor)
|
|
|
|
return;
|
|
|
|
myIsBusy = true;
|
|
|
|
|
|
|
|
QString aListStr = "";
|
|
|
|
int aNbNnodes = 0;
|
|
|
|
|
|
|
|
aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
|
|
|
|
if (aNbNnodes < 1)
|
|
|
|
return;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QStringList aNodes = aListStr.split(" ", QString::SkipEmptyParts);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) {
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> found = ListEdit->findItems(*it, Qt::MatchExactly);
|
|
|
|
if ( found.count() == 0 ) {
|
|
|
|
QListWidgetItem* anItem = new QListWidgetItem(*it);
|
|
|
|
ListEdit->addItem(anItem);
|
|
|
|
anItem->setSelected(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QListWidgetItem* anItem;
|
|
|
|
foreach(anItem, found) anItem->setSelected(true);
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
myIsBusy = false;
|
|
|
|
onEditGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onRemoveElement()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onRemoveElement()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (myEditCurrentArgument != (QWidget*)ListCoincident)
|
|
|
|
return;
|
|
|
|
myIsBusy = true;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
|
|
|
|
QListWidgetItem* anItem;
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
foreach(anItem, selItems)
|
|
|
|
delete anItem;
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
myIsBusy = false;
|
|
|
|
onEditGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSetFirst()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::onSetFirst()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (myEditCurrentArgument != (QWidget*)ListCoincident)
|
|
|
|
return;
|
|
|
|
myIsBusy = true;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
|
|
|
|
QListWidgetItem* anItem;
|
|
|
|
|
|
|
|
foreach(anItem, selItems) {
|
|
|
|
ListEdit->takeItem(ListEdit->row(anItem));
|
|
|
|
ListEdit->insertItem(0, anItem);
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
myIsBusy = false;
|
|
|
|
onEditGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::SetEditCurrentArgument()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
QPushButton* send = (QPushButton*)sender();
|
|
|
|
|
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
|
|
|
mySelectionMgr->clearSelected();
|
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
|
|
|
|
if (send == SelectMeshButton) {
|
|
|
|
myEditCurrentArgument = (QWidget*)LineEditMesh;
|
|
|
|
SMESH::SetPointRepresentation(false);
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2012-08-09 16:03:55 +06:00
|
|
|
if (myTypeId == 1)
|
|
|
|
mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
myEditCurrentArgument->setFocus();
|
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::SelectionIntoArgument()
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
if (myEditCurrentArgument == (QWidget*)LineEditMesh) {
|
|
|
|
QString aString = "";
|
|
|
|
LineEditMesh->setText(aString);
|
|
|
|
|
|
|
|
ListCoincident->clear();
|
|
|
|
ListEdit->clear();
|
|
|
|
myActor = 0;
|
2012-08-09 16:03:55 +06:00
|
|
|
QString aCurrentEntry = myEntry;
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
|
2012-08-09 16:03:55 +06:00
|
|
|
if (nbSel != 1) {
|
|
|
|
myIdPreview->SetPointsLabeled(false);
|
|
|
|
SMESH::SetPointRepresentation(false);
|
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2008-03-07 12:47:05 +05:00
|
|
|
return;
|
2012-08-09 16:03:55 +06:00
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
2012-08-09 16:03:55 +06:00
|
|
|
mySelectionMgr->selectedObjects(aList);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
Handle(SALOME_InteractiveObject) IO = aList.First();
|
2012-08-09 16:03:55 +06:00
|
|
|
myEntry = IO->getEntry();
|
2008-03-07 12:47:05 +05:00
|
|
|
myMesh = SMESH::GetMeshByIO(IO);
|
|
|
|
|
|
|
|
if (myMesh->_is_nil())
|
|
|
|
return;
|
2012-08-09 16:03:55 +06:00
|
|
|
|
|
|
|
LineEditMesh->setText(aString);
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
myActor = SMESH::FindActorByEntry(IO->getEntry());
|
|
|
|
if (!myActor)
|
|
|
|
myActor = SMESH::FindActorByObject(myMesh);
|
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
if ( myActor && myTypeId ==1 ) {
|
|
|
|
mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
|
|
|
|
mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
|
|
|
|
|
|
|
|
if ((!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil() || //SUBMESH OR GROUP
|
|
|
|
!SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) &&
|
|
|
|
!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
|
|
|
|
mySubMeshOrGroup = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
|
|
|
|
|
|
|
|
if (myAction == 0) {
|
|
|
|
SMESH::SetPointRepresentation(true);
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(NodeSelection);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(CellSelection);
|
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
// process groups
|
|
|
|
if ( myAction == 0 && !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
|
|
|
|
myGroups.clear();
|
|
|
|
ListExclude->clear();
|
|
|
|
SMESH::ListOfGroups_var aListOfGroups = myMesh->GetGroups();
|
|
|
|
for( int i = 0, n = aListOfGroups->length(); i < n; i++ ) {
|
|
|
|
SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
|
|
|
|
if ( !aGroup->_is_nil() ) { // && aGroup->GetType() == SMESH::NODE
|
|
|
|
QString aGroupName( aGroup->GetName() );
|
|
|
|
if ( !aGroupName.isEmpty() ) {
|
|
|
|
myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
|
|
|
|
QListWidgetItem* item = new QListWidgetItem( aGroupName );
|
|
|
|
item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
|
|
|
|
item->setCheckState( Qt::Unchecked );
|
|
|
|
ListExclude->addItem( item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2012-08-09 16:03:55 +06:00
|
|
|
|
|
|
|
updateControls();
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::DeactivateActiveDialog()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
|
|
|
if (GroupConstructors->isEnabled()) {
|
|
|
|
GroupConstructors->setEnabled(false);
|
2012-08-09 16:03:55 +06:00
|
|
|
TypeBox->setEnabled(false);
|
2005-08-09 17:31:29 +06:00
|
|
|
GroupMesh->setEnabled(false);
|
2008-03-07 12:47:05 +05:00
|
|
|
GroupCoincident->setEnabled(false);
|
|
|
|
GroupEdit->setEnabled(false);
|
2005-08-09 17:31:29 +06:00
|
|
|
GroupButtons->setEnabled(false);
|
|
|
|
mySMESHGUI->ResetState();
|
|
|
|
mySMESHGUI->SetActiveDialogBox(0);
|
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
|
|
|
|
mySelectionMgr->clearSelected();
|
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::ActivateThisDialog()
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
|
|
|
/* Emit a signal to deactivate the active dialog */
|
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog();
|
|
|
|
GroupConstructors->setEnabled(true);
|
2012-08-09 16:03:55 +06:00
|
|
|
TypeBox->setEnabled(true);
|
2005-08-09 17:31:29 +06:00
|
|
|
GroupMesh->setEnabled(true);
|
2008-03-07 12:47:05 +05:00
|
|
|
GroupCoincident->setEnabled(true);
|
|
|
|
GroupEdit->setEnabled(true);
|
2005-08-09 17:31:29 +06:00
|
|
|
GroupButtons->setEnabled(true);
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2005-08-09 17:31:29 +06:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::enterEvent(QEvent*)
|
2005-08-09 17:31:29 +06:00
|
|
|
{
|
2008-03-07 12:47:05 +05:00
|
|
|
if (!GroupConstructors->isEnabled())
|
|
|
|
ActivateThisDialog();
|
2005-08-09 17:31:29 +06:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : keyPressEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2012-08-09 16:03:55 +06:00
|
|
|
void SMESHGUI_MergeDlg::keyPressEvent( QKeyEvent* e)
|
2008-03-07 12:47:05 +05:00
|
|
|
{
|
|
|
|
QDialog::keyPressEvent( e );
|
|
|
|
if ( e->isAccepted() )
|
|
|
|
return;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
if ( e->key() == Qt::Key_F1 ) {
|
|
|
|
e->accept();
|
|
|
|
ClickOnHelp();
|
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2012-08-09 16:03:55 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onTypeChanged()
|
|
|
|
// purpose : the type radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_MergeDlg::onTypeChanged (int id)
|
|
|
|
{
|
|
|
|
if (myTypeId == id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
myTypeId = id;
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case 0: // automatic
|
|
|
|
myIdPreview->SetPointsLabeled(false);
|
|
|
|
SMESH::SetPointRepresentation(false);
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
if (myAction == 0)
|
|
|
|
GroupCoincidentWidget->hide();
|
|
|
|
else
|
|
|
|
GroupCoincident->hide();
|
|
|
|
GroupEdit->hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // manual
|
|
|
|
SMESH::UpdateView();
|
|
|
|
|
|
|
|
// Costruction of the logical filter
|
2012-12-13 17:41:29 +06:00
|
|
|
SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (SMESH::MESHorSUBMESH);
|
|
|
|
SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (SMESH::GROUP);
|
2012-08-09 16:03:55 +06:00
|
|
|
|
|
|
|
QList<SUIT_SelectionFilter*> aListOfFilters;
|
|
|
|
if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
|
|
|
|
if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
|
|
|
|
|
|
|
|
myMeshOrSubMeshOrGroupFilter =
|
|
|
|
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
|
|
|
|
|
|
|
|
if (myAction == 0) {
|
|
|
|
GroupCoincidentWidget->show();
|
|
|
|
SMESH::SetPointRepresentation(true);
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(NodeSelection);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GroupCoincident->show();
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(CellSelection);
|
|
|
|
}
|
|
|
|
GroupEdit->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
updateControls();
|
|
|
|
|
|
|
|
qApp->processEvents();
|
|
|
|
updateGeometry();
|
|
|
|
resize(10,10);
|
|
|
|
|
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|