2005-06-07 19:22:20 +06:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
2006-06-01 17:39:17 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-06-07 19:22:20 +06:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_CreatePolyhedralVolumeDlg.cxx
|
|
|
|
// Author : Michael ZORIN
|
|
|
|
// Module : SMESH
|
|
|
|
// $Header:
|
|
|
|
|
|
|
|
#include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
|
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
#include "SMESHGUI_MeshUtils.h"
|
|
|
|
#include "SMESHGUI_IdValidator.h"
|
|
|
|
#include "SMESH_ActorUtils.h"
|
|
|
|
#include "SMESHGUI_SpinBox.h"
|
|
|
|
#include "SMESH_Actor.h"
|
|
|
|
#include "SMESH_TypeFilter.hxx"
|
|
|
|
#include "SMDS_Mesh.hxx"
|
|
|
|
|
|
|
|
#include "SUIT_ResourceMgr.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SUIT_MessageBox.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
#include "SalomeApp_Application.h"
|
|
|
|
#include "SalomeApp_Study.h"
|
|
|
|
#include "SUIT_Desktop.h"
|
|
|
|
#include "SUIT_MessageBox.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "LightApp_Application.h"
|
2005-11-03 13:38:17 +05:00
|
|
|
#include "LightApp_SelectionMgr.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "utilities.h"
|
|
|
|
|
|
|
|
#include "SVTK_ViewWindow.h"
|
|
|
|
#include "SVTK_Selector.h"
|
|
|
|
|
|
|
|
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
|
|
|
#include <TColStd_ListOfInteger.hxx>
|
|
|
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
|
|
|
|
|
|
|
#include <vtkCell.h>
|
|
|
|
#include <vtkIdList.h>
|
|
|
|
#include <vtkIntArray.h>
|
|
|
|
#include <vtkCellArray.h>
|
|
|
|
#include <vtkUnsignedCharArray.h>
|
|
|
|
#include <vtkUnstructuredGrid.h>
|
|
|
|
#include <vtkDataSetMapper.h>
|
2006-02-07 20:01:11 +05:00
|
|
|
#include <vtkProperty.h>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
// QT Includes
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qbuttongroup.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qspinbox.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qlistbox.h>
|
|
|
|
|
|
|
|
// IDL Headers
|
|
|
|
#include "SALOMEconfig.h"
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Group)
|
2008-03-07 12:47:05 +05:00
|
|
|
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace SMESH{
|
|
|
|
|
|
|
|
class TPolySimulation{
|
|
|
|
SVTK_ViewWindow* myViewWindow;
|
|
|
|
|
|
|
|
SALOME_Actor *myPreviewActor;
|
|
|
|
vtkDataSetMapper* myMapper;
|
|
|
|
vtkUnstructuredGrid* myGrid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
TPolySimulation(SalomeApp_Application* app)
|
|
|
|
{
|
|
|
|
SUIT_ViewManager* mgr = app->activeViewManager();
|
|
|
|
myViewWindow = mgr ? dynamic_cast<SVTK_ViewWindow*>( mgr->getActiveView() ) : NULL;
|
|
|
|
|
|
|
|
myGrid = vtkUnstructuredGrid::New();
|
|
|
|
|
|
|
|
// Create and display actor
|
|
|
|
myMapper = vtkDataSetMapper::New();
|
|
|
|
myMapper->SetInput( myGrid );
|
|
|
|
|
|
|
|
myPreviewActor = SALOME_Actor::New();
|
|
|
|
myPreviewActor->PickableOff();
|
|
|
|
myPreviewActor->VisibilityOff();
|
|
|
|
myPreviewActor->SetMapper( myMapper );
|
2006-02-07 20:01:11 +05:00
|
|
|
myPreviewActor->SetRepresentation( 3 );
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
vtkFloatingPointType anRGB[3];
|
2005-06-27 17:29:58 +06:00
|
|
|
vtkProperty* aProp = vtkProperty::New();
|
2006-03-13 20:29:49 +05:00
|
|
|
GetColor( "SMESH", "selection_element_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
|
2005-06-07 19:22:20 +06:00
|
|
|
aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
|
|
|
|
myPreviewActor->SetProperty( aProp );
|
2006-05-06 14:51:48 +06:00
|
|
|
vtkFloatingPointType aFactor,aUnits;
|
2006-03-13 20:29:49 +05:00
|
|
|
myPreviewActor->SetResolveCoincidentTopology(true);
|
|
|
|
myPreviewActor->GetPolygonOffsetParameters(aFactor,aUnits);
|
|
|
|
myPreviewActor->SetPolygonOffsetParameters(aFactor,0.2*aUnits);
|
2005-06-07 19:22:20 +06:00
|
|
|
aProp->Delete();
|
|
|
|
|
|
|
|
myViewWindow->AddActor( myPreviewActor );
|
2006-03-13 20:29:49 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef std::vector<vtkIdType> TVTKIds;
|
|
|
|
void SetPosition(SMESH_Actor* theActor,
|
|
|
|
vtkIdType theType,
|
|
|
|
const TVTKIds& theIds,
|
|
|
|
bool theReset=true)
|
|
|
|
{
|
|
|
|
vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
|
|
|
|
myGrid->SetPoints(aGrid->GetPoints());
|
|
|
|
|
2006-03-13 20:29:49 +05:00
|
|
|
ResetGrid(theReset);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
vtkIdList *anIds = vtkIdList::New();
|
|
|
|
|
|
|
|
for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
|
|
|
|
anIds->InsertId(i,theIds[i]);
|
|
|
|
|
|
|
|
myGrid->InsertNextCell(theType,anIds);
|
2005-06-24 12:21:49 +06:00
|
|
|
if(theIds.size()!=0){
|
|
|
|
myGrid->InsertNextCell(theType,anIds);
|
|
|
|
myGrid->Modified();
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
anIds->Delete();
|
|
|
|
|
|
|
|
SetVisibility(true);
|
2005-06-24 12:21:49 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetGrid(bool theReset=true){
|
|
|
|
if (theReset) myGrid->Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetVisibility(bool theVisibility){
|
|
|
|
myPreviewActor->SetVisibility(theVisibility);
|
|
|
|
RepaintCurrentView();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~TPolySimulation(){
|
|
|
|
if( myViewWindow )
|
|
|
|
myViewWindow->RemoveActor(myPreviewActor);
|
|
|
|
|
|
|
|
myPreviewActor->Delete();
|
|
|
|
|
|
|
|
myMapper->RemoveAllInputs();
|
|
|
|
myMapper->Delete();
|
|
|
|
|
|
|
|
myGrid->Delete();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : SMESHGUI_CreatePolyhedralVolumeDlgDlg()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI* theModule, const char* name,
|
|
|
|
bool modal, WFlags fl )
|
|
|
|
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
|
|
|
|
mySMESHGUI( theModule ),
|
2005-07-01 16:42:32 +06:00
|
|
|
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
|
2005-06-07 19:22:20 +06:00
|
|
|
{
|
2005-06-09 12:48:48 +06:00
|
|
|
QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH",tr("ICON_SELECT")));
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if ( !name )
|
|
|
|
setName( "SMESHGUI_CreatePolyhedralVolumeDlg" );
|
|
|
|
resize( 300, 185 );
|
|
|
|
setCaption( tr( "SMESH_CREATE_POLYHEDRAL_VOLUME_TITLE" ) );
|
|
|
|
setSizeGripEnabled( TRUE );
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlgLayout = new QGridLayout( this );
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlgLayout->setSpacing( 6 );
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlgLayout->setMargin( 11 );
|
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
|
|
|
|
GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) );
|
|
|
|
GroupConstructors->setTitle( tr( "SMESH_ELEMENTS_TYPE" ) );
|
|
|
|
GroupConstructors->setExclusive( TRUE );
|
|
|
|
GroupConstructors->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupConstructors->layout()->setSpacing( 0 );
|
|
|
|
GroupConstructors->layout()->setMargin( 0 );
|
|
|
|
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
|
|
|
|
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupConstructorsLayout->setSpacing( 6 );
|
|
|
|
GroupConstructorsLayout->setMargin( 11 );
|
|
|
|
RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" );
|
|
|
|
RadioButton1->setText( tr( "MESH_NODE" ) );
|
|
|
|
GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 );
|
|
|
|
RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" );
|
|
|
|
RadioButton2->setText( tr( "SMESH_FACE" ) );
|
|
|
|
GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 );
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 );
|
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
GroupButtons = new QGroupBox( this, "GroupButtons" );
|
|
|
|
GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
|
|
|
|
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
|
|
|
|
GroupButtons->setTitle( tr( "" ) );
|
|
|
|
GroupButtons->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupButtons->layout()->setSpacing( 0 );
|
|
|
|
GroupButtons->layout()->setMargin( 0 );
|
|
|
|
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
|
|
|
|
GroupButtonsLayout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupButtonsLayout->setSpacing( 6 );
|
|
|
|
GroupButtonsLayout->setMargin( 11 );
|
|
|
|
buttonCancel = new QPushButton( GroupButtons, "cancel" );
|
|
|
|
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
|
|
|
|
buttonCancel->setAutoDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
|
|
|
|
buttonApply = new QPushButton( GroupButtons, "apply" );
|
|
|
|
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
|
|
|
|
buttonApply->setAutoDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
|
|
|
|
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
|
|
|
|
buttonOk = new QPushButton( GroupButtons, "ok" );
|
|
|
|
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
|
|
|
|
buttonOk->setAutoDefault( TRUE );
|
|
|
|
buttonOk->setDefault( TRUE );
|
|
|
|
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
|
2006-05-06 14:51:48 +06:00
|
|
|
buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
|
|
|
|
buttonHelp->setText(tr("SMESH_BUT_HELP" ));
|
|
|
|
buttonHelp->setAutoDefault(TRUE);
|
|
|
|
GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupButtons, 2, 0 );
|
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
GroupContent = new QGroupBox( this, "GroupContent" );
|
|
|
|
GroupContent->setTitle( tr( "SMESH_CONTENT" ) );
|
|
|
|
GroupContent->setColumnLayout(0, Qt::Vertical );
|
|
|
|
GroupContent->layout()->setSpacing( 0 );
|
|
|
|
GroupContent->layout()->setMargin( 0 );
|
|
|
|
GroupContentLayout = new QGridLayout( GroupContent->layout() );
|
|
|
|
GroupContentLayout->setAlignment( Qt::AlignTop );
|
|
|
|
GroupContentLayout->setSpacing( 6 );
|
|
|
|
GroupContentLayout->setMargin( 11 );
|
|
|
|
|
|
|
|
QFrame* anIds = new QFrame(GroupContent, "anIds");
|
|
|
|
QGridLayout* aLayout = new QGridLayout(anIds, 1, 3);
|
|
|
|
aLayout->setSpacing(6);
|
|
|
|
aLayout->setAutoAdd(false);
|
|
|
|
|
|
|
|
TextLabelIds = new QLabel( anIds, "TextLabelIds" );
|
|
|
|
TextLabelIds->setText( tr( "SMESH_ID_NODES" ) );
|
|
|
|
TextLabelIds->setFixedWidth(74);
|
|
|
|
aLayout->addWidget( TextLabelIds, 0, 0 );
|
|
|
|
|
|
|
|
SelectElementsButton = new QPushButton( anIds, "SelectElementsButton" );
|
|
|
|
SelectElementsButton->setText( tr( "" ) );
|
|
|
|
SelectElementsButton->setPixmap( image0 );
|
|
|
|
SelectElementsButton->setToggleButton( FALSE );
|
|
|
|
aLayout->addWidget( SelectElementsButton, 0, 1 );
|
|
|
|
|
|
|
|
LineEditElements = new QLineEdit( anIds, "LineEditElements" );
|
|
|
|
LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
|
|
|
|
aLayout->addWidget( LineEditElements, 0, 2 );
|
|
|
|
|
|
|
|
GroupContentLayout->addMultiCellWidget(anIds, 0, 0, 0, 1);
|
|
|
|
|
|
|
|
myFacesByNodesLabel = new QLabel(GroupContent, "faces by nodes label");
|
|
|
|
myFacesByNodesLabel->setText(tr("FACES_BY_NODES"));
|
|
|
|
GroupContentLayout->addWidget( myFacesByNodesLabel, 1, 0 );
|
|
|
|
|
|
|
|
myFacesByNodes = new QListBox(GroupContent, "faces by nodes list");
|
|
|
|
myFacesByNodes->setSelectionMode(QListBox::Extended);
|
|
|
|
myFacesByNodes->setMinimumHeight(150);
|
|
|
|
GroupContentLayout->addMultiCellWidget( myFacesByNodes, 2, 4, 0, 0 );
|
|
|
|
|
|
|
|
AddButton = new QPushButton(GroupContent, "add");
|
|
|
|
AddButton->setText(tr("SMESH_BUT_ADD"));
|
|
|
|
AddButton->setMaximumWidth(85);
|
|
|
|
GroupContentLayout->addWidget( AddButton, 2, 1 );
|
|
|
|
|
|
|
|
RemoveButton = new QPushButton(GroupContent, "remove");
|
|
|
|
RemoveButton->setText(tr("SMESH_BUT_REMOVE"));
|
|
|
|
RemoveButton->setMaximumWidth(85);
|
|
|
|
GroupContentLayout->addWidget( RemoveButton, 3, 1 );
|
|
|
|
|
|
|
|
Preview = new QCheckBox( GroupContent, "Preview" );
|
|
|
|
Preview->setText( tr( "SMESH_POLYEDRE_PREVIEW" ) );
|
|
|
|
GroupContentLayout->addWidget( Preview , 5, 0 );
|
2005-07-01 16:42:32 +06:00
|
|
|
|
|
|
|
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupContent, 1, 0 );
|
|
|
|
|
|
|
|
GroupContent->show();
|
|
|
|
RadioButton1->setChecked( TRUE );
|
|
|
|
|
|
|
|
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
myHelpFileName = "adding_nodes_and_elements_page.html#adding_polyhedrons_anchor";
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~SMESHGUI_CreatePolyhedralVolumeDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
SMESHGUI_CreatePolyhedralVolumeDlg::~SMESHGUI_CreatePolyhedralVolumeDlg()
|
|
|
|
{
|
|
|
|
// no need to delete child widgets, Qt does it all for us
|
|
|
|
delete mySimulation;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool busy = false;
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::Init()
|
|
|
|
{
|
|
|
|
myEditCurrentArgument = LineEditElements;
|
|
|
|
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
|
|
|
|
|
|
|
|
myNbOkElements = 0;
|
|
|
|
myActor = 0;
|
|
|
|
|
|
|
|
mySimulation = new SMESH::TPolySimulation( dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
|
|
|
|
|
|
|
|
/* signals and slots connections */
|
|
|
|
connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) );
|
|
|
|
connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ;
|
|
|
|
connect(buttonApply, SIGNAL( clicked() ), SLOT(ClickOnApply() ) );
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp() ) );
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
|
|
|
|
connect(SelectElementsButton, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ;
|
|
|
|
connect(LineEditElements, SIGNAL( textChanged(const QString&) ), SLOT(onTextChange(const QString&)));
|
|
|
|
|
|
|
|
connect(myFacesByNodes, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
|
|
|
|
connect(AddButton, SIGNAL(clicked()), this, SLOT(onAdd()));
|
|
|
|
connect(RemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
|
|
|
|
|
|
|
|
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
|
|
|
|
connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
|
|
|
connect( Preview, SIGNAL(toggled(bool)), this, SLOT(ClickOnPreview(bool)));
|
|
|
|
/* to close dialog if study change */
|
|
|
|
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
|
|
|
|
|
|
|
|
this->show() ; /* displays Dialog */
|
|
|
|
|
|
|
|
ConstructorsClicked(0);
|
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ConstructorsClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId)
|
|
|
|
{
|
2005-06-24 12:21:49 +06:00
|
|
|
//disconnect(mySelectionMgr, 0, this, 0);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-11-25 19:06:27 +05:00
|
|
|
SALOME_ListIO io;
|
|
|
|
mySelectionMgr->selectedObjects( io );
|
2005-06-07 19:22:20 +06:00
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->setSelectedObjects( aList );
|
|
|
|
myEditCurrentArgument->clear();
|
|
|
|
myNbOkElements = 0;
|
|
|
|
buttonApply->setEnabled(false);
|
|
|
|
buttonOk->setEnabled(false);
|
|
|
|
mySimulation->SetVisibility(false);
|
|
|
|
|
|
|
|
switch(constructorId)
|
|
|
|
{
|
|
|
|
case 0 :
|
|
|
|
{
|
|
|
|
if ( myActor ){
|
|
|
|
myActor->SetPointRepresentation(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SMESH::SetPointRepresentation(true);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(NodeSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
AddButton->setEnabled(false);
|
|
|
|
RemoveButton->setEnabled(false);
|
|
|
|
TextLabelIds->setText( tr( "SMESH_ID_NODES" ) );
|
|
|
|
myFacesByNodesLabel->show();
|
|
|
|
myFacesByNodes->clear();
|
|
|
|
myFacesByNodes->show();
|
|
|
|
AddButton->show();
|
|
|
|
RemoveButton->show();
|
|
|
|
Preview->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1 :
|
|
|
|
{
|
2005-06-24 12:21:49 +06:00
|
|
|
if( myActor ){
|
|
|
|
myActor->SetPointRepresentation(false);
|
|
|
|
} else {
|
|
|
|
SMESH::SetPointRepresentation(false);
|
|
|
|
}
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(FaceSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
TextLabelIds->setText( tr( "SMESH_ID_FACES" ) );
|
|
|
|
myFacesByNodesLabel->hide();
|
|
|
|
myFacesByNodes->hide();
|
|
|
|
AddButton->hide();
|
|
|
|
RemoveButton->hide();
|
|
|
|
Preview->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:21:49 +06:00
|
|
|
//connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2005-11-25 19:06:27 +05:00
|
|
|
mySelectionMgr->setSelectedObjects( io );
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnPreview()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnPreview(bool theToggled){
|
|
|
|
Preview->setChecked(theToggled);
|
|
|
|
displaySimulation();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
|
|
|
|
{
|
|
|
|
if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked())
|
|
|
|
{
|
2006-03-13 20:29:49 +05:00
|
|
|
if(checkEditLine(false) == -1) {return;}
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = true;
|
|
|
|
if (GetConstructorId() == 0)
|
|
|
|
{
|
|
|
|
SMESH::long_array_var anIdsOfNodes = new SMESH::long_array;
|
|
|
|
SMESH::long_array_var aQuantities = new SMESH::long_array;
|
|
|
|
|
|
|
|
aQuantities->length( myFacesByNodes->count() );
|
|
|
|
|
|
|
|
TColStd_ListOfInteger aNodesIds;
|
|
|
|
|
|
|
|
QListBoxItem* anItem;
|
|
|
|
int aNbQuantities = 0;
|
|
|
|
for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) {
|
|
|
|
QStringList anIds = QStringList::split(" ", anItem->text());
|
|
|
|
int aNbNodesInFace = 0;
|
|
|
|
for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it, ++aNbNodesInFace)
|
|
|
|
aNodesIds.Append( (*it).toInt() );
|
|
|
|
|
|
|
|
aQuantities[aNbQuantities++] = aNbNodesInFace;
|
|
|
|
}
|
|
|
|
|
|
|
|
anIdsOfNodes->length(aNodesIds.Extent());
|
|
|
|
|
|
|
|
int aNbIdsOfNodes = 0;
|
|
|
|
TColStd_ListIteratorOfListOfInteger It;
|
|
|
|
It.Initialize(aNodesIds);
|
|
|
|
for(;It.More();It.Next())
|
|
|
|
anIdsOfNodes[aNbIdsOfNodes++] = It.Value();
|
|
|
|
|
|
|
|
try{
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
|
|
aMeshEditor->AddPolyhedralVolume(anIdsOfNodes, aQuantities);
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}catch(SALOME::SALOME_Exception& exc){
|
|
|
|
INFOS("Follow exception was cought:\n\t"<<exc.details.text);
|
|
|
|
}catch(std::exception& exc){
|
|
|
|
INFOS("Follow exception was cought:\n\t"<<exc.what());
|
|
|
|
}catch(...){
|
|
|
|
INFOS("Unknown exception was cought !!!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GetConstructorId() == 1)
|
|
|
|
{
|
|
|
|
SMESH::long_array_var anIdsOfFaces = new SMESH::long_array;
|
|
|
|
|
|
|
|
QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text() );
|
|
|
|
anIdsOfFaces->length(aListId.count());
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ )
|
|
|
|
anIdsOfFaces[i] = aListId[i].toInt();
|
|
|
|
|
|
|
|
try{
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
|
|
aMeshEditor->AddPolyhedralVolumeByFaces(anIdsOfFaces);
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}catch(SALOME::SALOME_Exception& exc){
|
|
|
|
INFOS("Follow exception was cought:\n\t"<<exc.details.text);
|
|
|
|
}catch(std::exception& exc){
|
|
|
|
INFOS("Follow exception was cought:\n\t"<<exc.what());
|
|
|
|
}catch(...){
|
|
|
|
INFOS("Unknown exception was cought !!!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-25 19:06:27 +05:00
|
|
|
//SALOME_ListIO aList;
|
|
|
|
//mySelectionMgr->setSelectedObjects( aList );
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::UpdateView();
|
2006-02-07 20:01:11 +05:00
|
|
|
if( myActor ){
|
|
|
|
unsigned int anEntityMode = myActor->GetEntityMode();
|
|
|
|
myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode);
|
|
|
|
}
|
2006-03-13 20:29:49 +05:00
|
|
|
//ConstructorsClicked( GetConstructorId() );
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnOk()
|
|
|
|
{
|
2006-03-13 20:29:49 +05:00
|
|
|
if(checkEditLine(false) == -1) {return;}
|
2005-06-07 19:22:20 +06:00
|
|
|
ClickOnApply() ;
|
|
|
|
ClickOnCancel() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnCancel()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel()
|
|
|
|
{
|
|
|
|
mySelectionMgr->clearFilters();
|
2005-11-25 19:06:27 +05:00
|
|
|
//SALOME_ListIO aList;
|
|
|
|
//mySelectionMgr->setSelectedObjects( aList );
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SetPointRepresentation(false);
|
|
|
|
mySimulation->SetVisibility(false);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode( ActorSelection );
|
2005-06-07 19:22:20 +06:00
|
|
|
disconnect( mySelectionMgr, 0, this, 0 );
|
|
|
|
mySMESHGUI->ResetState() ;
|
|
|
|
reject() ;
|
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnHelp()
|
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if (app)
|
|
|
|
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
2008-03-07 12:47:05 +05:00
|
|
|
QString platform;
|
|
|
|
#ifdef WIN32
|
|
|
|
platform = "winapplication";
|
|
|
|
#else
|
|
|
|
platform = "application";
|
|
|
|
#endif
|
2006-05-06 14:51:48 +06:00
|
|
|
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
|
|
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
2008-03-07 12:47:05 +05:00
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
|
2006-05-06 14:51:48 +06:00
|
|
|
QObject::tr("BUT_OK"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=======================================================================
|
|
|
|
//function : onTextChange
|
|
|
|
//purpose :
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText)
|
|
|
|
{
|
|
|
|
if ( busy ) return;
|
2006-03-13 20:29:49 +05:00
|
|
|
if (checkEditLine() == -1) return;
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = true;
|
|
|
|
|
|
|
|
mySimulation->SetVisibility(false);
|
|
|
|
|
|
|
|
SMDS_Mesh* aMesh = 0;
|
|
|
|
if ( myActor )
|
|
|
|
aMesh = myActor->GetObject()->GetMesh();
|
|
|
|
|
|
|
|
if (GetConstructorId() == 0)
|
|
|
|
{
|
|
|
|
if ( aMesh ) {
|
|
|
|
TColStd_MapOfInteger newIndices;
|
2005-06-24 19:54:25 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QStringList aListId = QStringList::split( " ", theNewText, false);
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ ) {
|
|
|
|
const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() );
|
|
|
|
if ( n ) {
|
2005-06-24 19:54:25 +06:00
|
|
|
newIndices.Add(n->GetID());
|
2005-06-07 19:22:20 +06:00
|
|
|
myNbOkElements++;
|
|
|
|
}
|
|
|
|
}
|
2005-06-24 12:21:49 +06:00
|
|
|
|
2005-06-24 19:54:25 +06:00
|
|
|
mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
|
2005-07-01 16:42:32 +06:00
|
|
|
|
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->highlight( myActor->getIO(), true, true );
|
2005-06-24 19:54:25 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if ( myNbOkElements>0 && aListId.count()>=3)
|
|
|
|
AddButton->setEnabled(true);
|
2005-06-24 12:21:49 +06:00
|
|
|
else
|
|
|
|
AddButton->setEnabled(false);
|
|
|
|
|
|
|
|
displaySimulation();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
2005-06-24 12:21:49 +06:00
|
|
|
} else if (GetConstructorId() == 1)
|
2005-06-07 19:22:20 +06:00
|
|
|
{
|
|
|
|
myNbOkElements = 0;
|
|
|
|
buttonOk->setEnabled( false );
|
|
|
|
buttonApply->setEnabled( false );
|
|
|
|
|
|
|
|
// check entered ids of faces and hilight them
|
|
|
|
QStringList aListId;
|
|
|
|
if ( aMesh ) {
|
|
|
|
TColStd_MapOfInteger newIndices;
|
2005-06-24 19:54:25 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aListId = QStringList::split( " ", theNewText, false);
|
|
|
|
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ ) {
|
|
|
|
const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
|
|
|
|
if ( e ) {
|
2005-06-24 19:54:25 +06:00
|
|
|
newIndices.Add(e->GetID());
|
2005-06-07 19:22:20 +06:00
|
|
|
myNbOkElements++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 19:54:25 +06:00
|
|
|
mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->highlight( myActor->getIO(), true, true );
|
2005-06-24 19:54:25 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if ( myNbOkElements ) {
|
|
|
|
if (aListId.count()>1){
|
|
|
|
buttonOk->setEnabled( true );
|
|
|
|
buttonApply->setEnabled( true );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
buttonOk->setEnabled( false );
|
|
|
|
buttonApply->setEnabled( false );
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
if(aListId.count()>1)
|
|
|
|
displaySimulation();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
busy = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
|
|
|
|
{
|
|
|
|
if ( busy ) return;
|
|
|
|
|
|
|
|
// clear
|
|
|
|
|
|
|
|
if (GetConstructorId() == 1 || myFacesByNodes->count() <= 1)
|
|
|
|
{
|
|
|
|
myNbOkElements = 0;
|
|
|
|
AddButton->setEnabled(false);
|
|
|
|
buttonOk->setEnabled( false );
|
|
|
|
buttonApply->setEnabled( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
myActor = 0;
|
|
|
|
|
|
|
|
busy = true;
|
|
|
|
myEditCurrentArgument->setText( "" );
|
|
|
|
busy = false;
|
|
|
|
if ( !GroupButtons->isEnabled() ) // inactive
|
|
|
|
return;
|
|
|
|
|
|
|
|
mySimulation->SetVisibility(false);
|
|
|
|
|
|
|
|
// get selected mesh
|
|
|
|
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
mySelectionMgr->selectedObjects( selected );
|
|
|
|
int nbSel = selected.Extent();
|
|
|
|
if(nbSel != 1){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
myMesh = SMESH::GetMeshByIO( selected.First() );
|
|
|
|
if ( myMesh->_is_nil() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
myActor = SMESH::FindActorByObject(myMesh);
|
|
|
|
if ( !myActor )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// get selected nodes/faces
|
|
|
|
QString aString = "";
|
2006-02-07 20:01:11 +05:00
|
|
|
int anbNodes=0,aNbFaces=0;
|
2005-06-07 19:22:20 +06:00
|
|
|
switch(GetConstructorId()){
|
|
|
|
case 0:{
|
2006-02-07 20:01:11 +05:00
|
|
|
anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
|
2005-06-07 19:22:20 +06:00
|
|
|
if (anbNodes >= 3)
|
|
|
|
AddButton->setEnabled(true);
|
2005-06-24 12:21:49 +06:00
|
|
|
else if (anbNodes < 3){
|
|
|
|
AddButton->setEnabled(false);
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = true;
|
|
|
|
myEditCurrentArgument->setText( aString );
|
2006-03-13 20:29:49 +05:00
|
|
|
if (checkEditLine() == -1) {busy = false;return;}
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:{
|
|
|
|
// get selected faces
|
2006-02-07 20:01:11 +05:00
|
|
|
aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
|
2005-06-24 12:21:49 +06:00
|
|
|
if (aNbFaces<=1){
|
|
|
|
buttonOk->setEnabled( false );
|
|
|
|
buttonApply->setEnabled( false );
|
|
|
|
} else {
|
|
|
|
buttonOk->setEnabled( true );
|
|
|
|
buttonApply->setEnabled( true );
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = true;
|
|
|
|
myEditCurrentArgument->setText( aString );
|
2006-03-13 20:29:49 +05:00
|
|
|
if (checkEditLine() == -1) {busy = false;return;}
|
2005-06-07 19:22:20 +06:00
|
|
|
busy = false;
|
|
|
|
|
|
|
|
// OK
|
|
|
|
myNbOkElements = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: return;
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
if(anbNodes>2 || aNbFaces>1)
|
|
|
|
displaySimulation();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
|
2006-03-13 20:29:49 +05:00
|
|
|
/*\brief int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine()
|
|
|
|
* Checking of indices in edit line.
|
|
|
|
* If incorecct indices in edit line warning message appear and myEditCurrentArgument remove last index.
|
|
|
|
* \retval 1 - if all ok(or no indices in edit line), -1 - if there are incorrect indices.
|
|
|
|
*/
|
|
|
|
int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine(bool checkLast)
|
|
|
|
{
|
|
|
|
QString aString = "";
|
|
|
|
SMDS_Mesh* aMesh = 0;
|
|
|
|
|
|
|
|
if(myMesh->_is_nil()) return 1;
|
|
|
|
if(!myActor){
|
|
|
|
myActor = SMESH::FindActorByObject(myMesh);
|
|
|
|
if(!myActor)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
aMesh = myActor->GetObject()->GetMesh();
|
|
|
|
|
|
|
|
// checking for nodes
|
|
|
|
if (checkLast && myEditCurrentArgument->text().right(1) != QString(" ") ) return 1;
|
|
|
|
QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text() );
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ ){
|
|
|
|
switch (GetConstructorId()){
|
|
|
|
case 0:{ // nodes
|
|
|
|
const SMDS_MeshNode * aNode = aMesh->FindNode( aListId[ i ].toInt() );
|
|
|
|
if( !aNode ){
|
|
|
|
std::string aWarning;
|
|
|
|
aWarning = "The incorrect indices of nodes!";
|
|
|
|
SUIT_MessageBox::warn1(SMESHGUI::desktop(),
|
|
|
|
QObject::tr("SMESH_POLYEDRE_CREATE_ERROR"),
|
|
|
|
QObject::tr(aWarning.c_str()),
|
|
|
|
QObject::tr("SMESH_BUT_OK"));
|
|
|
|
|
|
|
|
myEditCurrentArgument->clear();
|
|
|
|
myEditCurrentArgument->setText( aString );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:{ // faces
|
|
|
|
bool aElemIsOK = true;
|
|
|
|
const SMDS_MeshElement * aElem = aMesh->FindElement( aListId[ i ].toInt() );
|
|
|
|
if (!aElem)
|
|
|
|
{
|
|
|
|
aElemIsOK = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SMDSAbs_ElementType aType = aMesh->GetElementType( aElem->GetID(),true );
|
|
|
|
if (aType != SMDSAbs_Face){
|
|
|
|
aElemIsOK = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!aElemIsOK){
|
|
|
|
std::string aWarning;
|
|
|
|
aWarning = "The incorrect indices of faces!";
|
|
|
|
SUIT_MessageBox::warn1(SMESHGUI::desktop(),
|
|
|
|
QObject::tr("SMESH_POLYEDRE_CREATE_ERROR"),
|
|
|
|
QObject::tr(aWarning.c_str()),
|
|
|
|
QObject::tr("SMESH_BUT_OK"));
|
|
|
|
|
|
|
|
myEditCurrentArgument->clear();
|
|
|
|
myEditCurrentArgument->setText( aString );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aString += aListId[ i ] + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=======================================================================
|
|
|
|
//function : displaySimulation
|
|
|
|
//purpose :
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
|
|
|
|
{
|
|
|
|
if ( (myNbOkElements || AddButton->isEnabled()) && GroupButtons->isEnabled() && myActor)
|
|
|
|
{
|
|
|
|
SMESH::TPolySimulation::TVTKIds aVTKIds;
|
|
|
|
vtkIdType aType = VTK_CONVEX_POINT_SET ;
|
2006-03-13 20:29:49 +05:00
|
|
|
SMDS_Mesh* aMesh = 0;
|
|
|
|
if ( myActor ){
|
|
|
|
aMesh = myActor->GetObject()->GetMesh();
|
|
|
|
}
|
|
|
|
if (GetConstructorId() == 0 && aMesh){
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!AddButton->isEnabled()){
|
|
|
|
QListBoxItem* anItem;
|
|
|
|
mySimulation->ResetGrid(true);
|
|
|
|
for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) {
|
|
|
|
QStringList anIds = QStringList::split(" ", anItem->text());
|
|
|
|
SMESH::TPolySimulation::TVTKIds aVTKIds_faces;
|
|
|
|
for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){
|
2006-03-13 20:29:49 +05:00
|
|
|
const SMDS_MeshNode * aNode = aMesh->FindNode( (*it).toInt() );
|
|
|
|
if (!aNode) continue;
|
2005-06-07 19:22:20 +06:00
|
|
|
vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ) ;
|
|
|
|
aVTKIds.push_back(aId);
|
|
|
|
aVTKIds_faces.push_back(aId);
|
|
|
|
}
|
|
|
|
if(!Preview->isChecked()){
|
|
|
|
aType = VTK_POLYGON;
|
|
|
|
mySimulation->SetPosition(myActor, aType, aVTKIds_faces,false);
|
|
|
|
}
|
|
|
|
}
|
2005-06-24 12:21:49 +06:00
|
|
|
if(myFacesByNodes->count() == 0){
|
|
|
|
mySimulation->SetVisibility(false);
|
|
|
|
} else {
|
|
|
|
mySimulation->SetVisibility(true);
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
if(Preview->isChecked()){
|
|
|
|
mySimulation->SetPosition(myActor, aType, aVTKIds);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// add ids from edit line
|
|
|
|
QStringList anEditIds = QStringList::split( " ", myEditCurrentArgument->text(), false);
|
|
|
|
for ( int i = 0; i < anEditIds.count(); i++ )
|
|
|
|
aVTKIds.push_back( myActor->GetObject()->GetNodeVTKId( anEditIds[ i ].toInt() ));
|
|
|
|
aType = VTK_POLYGON;
|
|
|
|
mySimulation->SetPosition(myActor, aType, aVTKIds);
|
|
|
|
}
|
2006-03-13 20:29:49 +05:00
|
|
|
}else if(GetConstructorId() == 1 && aMesh){
|
|
|
|
QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false);
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ )
|
|
|
|
{
|
|
|
|
const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() );
|
|
|
|
if ( !anElem ) continue;
|
|
|
|
SMDSAbs_ElementType aFaceType = aMesh->GetElementType( anElem->GetID(),true );
|
|
|
|
if (aFaceType != SMDSAbs_Face) continue;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2006-03-13 20:29:49 +05:00
|
|
|
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
|
|
|
|
SMESH::TPolySimulation::TVTKIds aVTKIds_faces;
|
|
|
|
while( anIter->more() )
|
2005-06-07 19:22:20 +06:00
|
|
|
if ( const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next() ){
|
|
|
|
vtkIdType aId = myActor->GetObject()->GetNodeVTKId( aNode->GetID() ) ;
|
|
|
|
aVTKIds.push_back(aId);
|
|
|
|
aVTKIds_faces.push_back(aId);
|
|
|
|
}
|
2006-03-13 20:29:49 +05:00
|
|
|
if(!Preview->isChecked()){
|
|
|
|
aType = VTK_POLYGON;
|
|
|
|
mySimulation->SetPosition(myActor, aType, aVTKIds_faces);
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
2006-03-13 20:29:49 +05:00
|
|
|
}
|
|
|
|
if(Preview->isChecked())
|
|
|
|
mySimulation->SetPosition(myActor, aType, aVTKIds);
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
2005-06-24 12:21:49 +06:00
|
|
|
SMESH::UpdateView();
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
QPushButton* send = (QPushButton*)sender();
|
|
|
|
if(send == SelectElementsButton) {
|
|
|
|
LineEditElements->setFocus() ;
|
|
|
|
myEditCurrentArgument = LineEditElements;
|
|
|
|
}
|
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::DeactivateActiveDialog()
|
|
|
|
{
|
|
|
|
if ( GroupConstructors->isEnabled() ) {
|
|
|
|
GroupConstructors->setEnabled(false) ;
|
|
|
|
GroupContent->setEnabled(false) ;
|
|
|
|
GroupButtons->setEnabled(false) ;
|
|
|
|
mySimulation->SetVisibility(false);
|
|
|
|
mySMESHGUI->ResetState() ;
|
|
|
|
mySMESHGUI->SetActiveDialogBox(0) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
/* Emit a signal to deactivate the active dialog */
|
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog() ;
|
|
|
|
GroupConstructors->setEnabled(true) ;
|
|
|
|
GroupContent->setEnabled(true) ;
|
|
|
|
GroupButtons->setEnabled(true) ;
|
|
|
|
|
|
|
|
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
|
|
|
|
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode( FaceSelection );
|
2005-06-07 19:22:20 +06:00
|
|
|
SelectionIntoArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent(QEvent* e)
|
|
|
|
{
|
|
|
|
if ( GroupConstructors->isEnabled() )
|
|
|
|
return ;
|
|
|
|
ActivateThisDialog() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::closeEvent( QCloseEvent* e )
|
|
|
|
{
|
|
|
|
/* same than click on cancel button */
|
|
|
|
this->ClickOnCancel() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : hideEvent
|
|
|
|
//purpose : caused by ESC key
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::hideEvent ( QHideEvent * e )
|
|
|
|
{
|
|
|
|
if ( !isMinimized() )
|
|
|
|
ClickOnCancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : GetConstructorId()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
int SMESHGUI_CreatePolyhedralVolumeDlg::GetConstructorId()
|
|
|
|
{
|
|
|
|
if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL )
|
|
|
|
return GroupConstructors->id( GroupConstructors->selected() );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onAdd()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd()
|
|
|
|
{
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
mySelectionMgr->selectedObjects( selected );
|
|
|
|
int aNbSel = selected.Extent();
|
|
|
|
if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
|
2006-03-13 20:29:49 +05:00
|
|
|
|
|
|
|
if (this->checkEditLine(false) == -1) return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
busy = true;
|
|
|
|
if ( !(myEditCurrentArgument->text().isEmpty()) )
|
|
|
|
{
|
|
|
|
myFacesByNodes->insertItem(myEditCurrentArgument->text());
|
|
|
|
//myFacesByNodes->setSelected(myFacesByNodes->count() - 1, true);
|
|
|
|
myNbOkElements = 1;
|
|
|
|
myEditCurrentArgument->clear();
|
|
|
|
AddButton->setEnabled(false);
|
|
|
|
buttonOk->setEnabled( true );
|
|
|
|
if(myFacesByNodes->count()>1) buttonApply->setEnabled( true );
|
|
|
|
}
|
|
|
|
busy = false;
|
|
|
|
onListSelectionChanged();
|
|
|
|
displaySimulation();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onRemove()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::onRemove()
|
|
|
|
{
|
|
|
|
busy = true;
|
|
|
|
for (int i = myFacesByNodes->count(); i > 0; i--) {
|
|
|
|
if (myFacesByNodes->isSelected(i-1)) {
|
|
|
|
myFacesByNodes->removeItem(i-1);
|
2005-06-24 12:21:49 +06:00
|
|
|
myNbOkElements = 1;
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (myFacesByNodes->count() < 1){
|
|
|
|
RemoveButton->setEnabled(false);
|
|
|
|
buttonOk->setEnabled( false );
|
|
|
|
buttonApply->setEnabled( false );
|
|
|
|
}
|
|
|
|
else if (myFacesByNodes->count() == 1){
|
|
|
|
buttonOk->setEnabled( false );
|
|
|
|
buttonApply->setEnabled( false );
|
|
|
|
}
|
|
|
|
busy = false;
|
2005-06-24 12:21:49 +06:00
|
|
|
displaySimulation();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onListSelectionChanged()
|
|
|
|
// purpose : Called when selection in element list is changed
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::onListSelectionChanged()
|
|
|
|
{
|
|
|
|
if (busy || !myActor) return;
|
|
|
|
busy = true;
|
2005-06-24 12:21:49 +06:00
|
|
|
bool isSelected=false;
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->setSelectedObjects( aList );
|
2005-06-07 19:22:20 +06:00
|
|
|
TColStd_MapOfInteger aIndexes;
|
|
|
|
QListBoxItem* anItem;
|
|
|
|
for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) {
|
|
|
|
if (anItem->isSelected()) {
|
2005-06-24 12:21:49 +06:00
|
|
|
isSelected = true;
|
2005-06-07 19:22:20 +06:00
|
|
|
QStringList anIds = QStringList::split(" ", anItem->text());
|
|
|
|
for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it)
|
|
|
|
aIndexes.Add((*it).toInt());
|
|
|
|
}
|
|
|
|
}
|
2005-06-24 12:21:49 +06:00
|
|
|
if(isSelected) RemoveButton->setEnabled(true);
|
|
|
|
else RemoveButton->setEnabled(false);
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, true );
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->highlight( myActor->getIO(), true, true );
|
2005-06-24 12:21:49 +06:00
|
|
|
mySelectionMgr->clearFilters();
|
|
|
|
aList.Append( myActor->getIO() );
|
|
|
|
mySelectionMgr->setSelectedObjects( aList );
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
busy = false;
|
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : keyPressEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_CreatePolyhedralVolumeDlg::keyPressEvent( QKeyEvent* e )
|
|
|
|
{
|
|
|
|
QDialog::keyPressEvent( e );
|
|
|
|
if ( e->isAccepted() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( e->key() == Key_F1 )
|
|
|
|
{
|
|
|
|
e->accept();
|
|
|
|
ClickOnHelp();
|
|
|
|
}
|
|
|
|
}
|