X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_CreatePolyhedralVolumeDlg.cxx;h=a9736fd6155595fc73581cdee274357465eee728;hp=6e7223ed498b92dcdc626a1a863cc3ddaea45abb;hb=879dbf686e7b6feb320b55d3e7b250394645f4cb;hpb=8d1d4432434b779f5337b9df202ff1c3339d7180 diff --git a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx index 6e7223ed4..a9736fd61 100644 --- a/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx @@ -1,31 +1,29 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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 -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// Copyright (C) 2003-2007 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_CreatePolyhedralVolumeDlg.cxx +// Author : Michael ZORIN, Open CASCADE S.A.S. +// SMESH includes // -// File : SMESHGUI_CreatePolyhedralVolumeDlg.cxx -// Author : Michael ZORIN -// Module : SMESH -// $Header: - #include "SMESHGUI_CreatePolyhedralVolumeDlg.h" #include "SMESHGUI.h" @@ -33,61 +31,61 @@ #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 "VTKViewer_ViewWindow.h" +#include +#include +#include -#include "SUIT_ResourceMgr.h" +// SALOME GUI includes +#include +#include +#include +#include +#include +#include -#include "SalomeApp_Application.h" -#include "SalomeApp_Study.h" -#include "SUIT_Desktop.h" -#include "SUIT_MessageBox.h" -#include "SalomeApp_SelectionMgr.h" -#include "utilities.h" +#include +#include -#include "SVTK_ViewWindow.h" -#include "SVTK_Selector.h" +#include -#include +// OCCT includes #include #include +// VTK includes #include #include -#include -#include -#include #include #include - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// IDL Headers -#include "SALOMEconfig.h" -#include CORBA_SERVER_HEADER(SMESH_Group) - -using namespace std; - -namespace SMESH{ - -class TPolySimulation{ +#include + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// IDL includes +#include +#include CORBA_SERVER_HEADER(SMESH_MeshEditor) + +#define SPACING 6 +#define MARGIN 11 + +namespace SMESH +{ + class TPolySimulation + { SVTK_ViewWindow* myViewWindow; SALOME_Actor *myPreviewActor; @@ -111,26 +109,21 @@ class TPolySimulation{ myPreviewActor->PickableOff(); myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper( myMapper ); + myPreviewActor->SetRepresentation( 3 ); + vtkFloatingPointType anRGB[3]; vtkProperty* aProp = vtkProperty::New(); - float anRGB[3]; - anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + GetColor( "SMESH", "selection_element_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreviewActor->SetProperty( aProp ); + vtkFloatingPointType aFactor,aUnits; + myPreviewActor->SetResolveCoincidentTopology(true); + myPreviewActor->GetPolygonOffsetParameters(aFactor,aUnits); + myPreviewActor->SetPolygonOffsetParameters(aFactor,0.2*aUnits); aProp->Delete(); - vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; - aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetBackfaceProperty( aBackProp ); - aBackProp->Delete(); - myViewWindow->AddActor( myPreviewActor ); - + } @@ -143,7 +136,7 @@ class TPolySimulation{ vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); myGrid->SetPoints(aGrid->GetPoints()); - if (theReset) ResetGrid(theReset); + ResetGrid(theReset); vtkIdList *anIds = vtkIdList::New(); @@ -173,8 +166,8 @@ class TPolySimulation{ ~TPolySimulation(){ - if( myViewWindow ) - myViewWindow->RemoveActor(myPreviewActor); + if( myViewWindow ) + myViewWindow->RemoveActor(myPreviewActor); myPreviewActor->Delete(); @@ -191,136 +184,104 @@ class TPolySimulation{ // 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), +SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI* theModule ) + : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH",tr("ICON_SELECT"))); - 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 ); + setModal(false); + setAttribute(Qt::WA_DeleteOnClose, true); + setWindowTitle( tr( "SMESH_CREATE_POLYHEDRAL_VOLUME_TITLE" ) ); + setSizeGripEnabled( true ); + + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setSpacing( SPACING ); + topLayout->setMargin( MARGIN ); /***************************************************************/ - 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 ); + ConstructorsBox = new QGroupBox(tr( "SMESH_ELEMENTS_TYPE" ), this); + GroupConstructors = new QButtonGroup(this); + QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout( ConstructorsBox ); + ConstructorsBoxLayout->setSpacing( SPACING ); + ConstructorsBoxLayout->setMargin( MARGIN ); + + RadioButton1 = new QRadioButton( tr( "MESH_NODE" ), ConstructorsBox ); + RadioButton2 = new QRadioButton( tr( "SMESH_FACE" ), ConstructorsBox ); + + ConstructorsBoxLayout->addWidget( RadioButton1 ); + ConstructorsBoxLayout->addWidget( RadioButton2 ); + GroupConstructors->addButton(RadioButton1, 0); + GroupConstructors->addButton(RadioButton2, 1); /***************************************************************/ - 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 ); - SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupContent = new QGroupBox( tr( "SMESH_CONTENT" ), this ); + QGridLayout* GroupContentLayout = new QGridLayout( GroupContent ); + GroupContentLayout->setSpacing( SPACING ); + GroupContentLayout->setMargin( MARGIN ); + + TextLabelIds = new QLabel( tr( "SMESH_ID_NODES" ), GroupContent ); + SelectElementsButton = new QPushButton( GroupContent ); + SelectElementsButton->setIcon( image0 ); + LineEditElements = new QLineEdit( GroupContent ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this ) ); + + myFacesByNodesLabel = new QLabel( tr( "FACES_BY_NODES" ), GroupContent ); + myFacesByNodes = new QListWidget( GroupContent); + myFacesByNodes->setSelectionMode( QListWidget::ExtendedSelection ); + myFacesByNodes->setMinimumHeight( 150); + + AddButton = new QPushButton( tr( "SMESH_BUT_ADD" ), GroupContent ); + RemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), GroupContent ); + + Preview = new QCheckBox( tr( "SMESH_POLYEDRE_PREVIEW" ), GroupContent ); + + GroupContentLayout->addWidget( TextLabelIds, 0, 0 ); + GroupContentLayout->addWidget( SelectElementsButton, 0, 1 ); + GroupContentLayout->addWidget( LineEditElements, 0, 2, 1, 2 ); + GroupContentLayout->addWidget( myFacesByNodesLabel, 1, 0 ); + GroupContentLayout->addWidget( myFacesByNodes, 2, 0, 3, 3 ); + GroupContentLayout->addWidget( AddButton, 2, 3 ); + GroupContentLayout->addWidget( RemoveButton, 3, 3 ); + GroupContentLayout->addWidget( Preview, 5, 0, 1, 4 ); /***************************************************************/ - 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 ); + 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); + + /***************************************************************/ + topLayout->addWidget( ConstructorsBox ); + topLayout->addWidget( GroupContent ); + topLayout->addWidget( GroupButtons ); - SMESHGUI_CreatePolyhedralVolumeDlgLayout->addWidget( GroupContent, 1, 0 ); + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); - GroupContent->show(); - RadioButton1->setChecked( TRUE ); + RadioButton1->setChecked( true ); - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); + + myHelpFileName = "adding_nodes_and_elements_page.html#adding_polyhedrons_anchor"; Init(); } @@ -331,11 +292,11 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI //================================================================================= 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 : @@ -343,7 +304,7 @@ static bool busy = false; void SMESHGUI_CreatePolyhedralVolumeDlg::Init() { myEditCurrentArgument = LineEditElements; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); myNbOkElements = 0; myActor = 0; @@ -351,30 +312,25 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::Init() mySimulation = new SMESH::TPolySimulation( dynamic_cast( mySMESHGUI->application() ) ); /* signals and slots connections */ - connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) ); - connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ; - connect(buttonApply, SIGNAL( clicked() ), SLOT(ClickOnApply() ) ); + connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) ); + connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ); + connect(buttonApply, SIGNAL( clicked() ), SLOT( ClickOnApply() ) ); + connect(buttonHelp, SIGNAL( clicked() ), SLOT( ClickOnHelp() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect(SelectElementsButton, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ; + connect(GroupConstructors, SIGNAL(buttonClicked(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( 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() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - ConstructorsClicked(0); SelectionIntoArgument(); } @@ -388,6 +344,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) { //disconnect(mySelectionMgr, 0, this, 0); + SALOME_ListIO io; + mySelectionMgr->selectedObjects( io ); SALOME_ListIO aList; mySelectionMgr->setSelectedObjects( aList ); myEditCurrentArgument->clear(); @@ -402,12 +360,11 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) { if ( myActor ){ myActor->SetPointRepresentation(true); - myActor->SetEntityMode(SMESH_Actor::eVolumes); - myActor->SetRepresentation(SMESH_Actor::eSurface); } else SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); AddButton->setEnabled(false); RemoveButton->setEnabled(false); @@ -424,13 +381,11 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) { if( myActor ){ myActor->SetPointRepresentation(false); - myActor->SetEntityMode(SMESH_Actor::eFaces); - myActor->SetEntityMode(SMESH_Actor::eVolumes); - myActor->SetRepresentation(SMESH_Actor::eSurface); } else { SMESH::SetPointRepresentation(false); } - myViewWindow->SetSelectionMode(FaceSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); TextLabelIds->setText( tr( "SMESH_ID_FACES" ) ); myFacesByNodesLabel->hide(); @@ -443,6 +398,11 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked(int constructorId) } //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + mySelectionMgr->setSelectedObjects( io ); + + QApplication::instance()->processEvents(); + updateGeometry(); + resize(100,100); } //================================================================================= @@ -462,6 +422,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() { if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked()) { + if(checkEditLine(false) == -1) {return;} busy = true; if (GetConstructorId() == 0) { @@ -472,15 +433,13 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() 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) + for (int i = 0; i < myFacesByNodes->count(); i++ ) { + QStringList anIds = myFacesByNodes->item(i)->text().split( " ", QString::SkipEmptyParts ); + for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it) aNodesIds.Append( (*it).toInt() ); - aQuantities[aNbQuantities++] = aNbNodesInFace; + aQuantities[aNbQuantities++] = anIds.count(); } anIdsOfNodes->length(aNodesIds.Extent()); @@ -488,14 +447,13 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() int aNbIdsOfNodes = 0; TColStd_ListIteratorOfListOfInteger It; It.Initialize(aNodesIds); - for(;It.More();It.Next()) + for( ;It.More();It.Next()) anIdsOfNodes[aNbIdsOfNodes++] = It.Value(); try{ + SUIT_OverrideCursor aWaitCursor; 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"<text() ); + QStringList aListId = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts ); anIdsOfFaces->length(aListId.count()); for ( int i = 0; i < aListId.count(); i++ ) anIdsOfFaces[i] = aListId[i].toInt(); try{ + SUIT_OverrideCursor aWaitCursor; 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"<setSelectedObjects( aList ); - mySimulation->SetVisibility(false); + //SALOME_ListIO aList; + //mySelectionMgr->setSelectedObjects( aList ); SMESH::UpdateView(); - ConstructorsClicked( GetConstructorId() ); + if( myActor ){ + unsigned int anEntityMode = myActor->GetEntityMode(); + myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode); + } + //ConstructorsClicked( GetConstructorId() ); busy = false; } } @@ -542,8 +502,9 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply() //================================================================================= void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnOk() { - ClickOnApply() ; - ClickOnCancel() ; + if(checkEditLine(false) == -1) {return;} + ClickOnApply(); + ClickOnCancel(); } @@ -554,14 +515,39 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnOk() void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel() { mySelectionMgr->clearFilters(); - SALOME_ListIO aList; - mySelectionMgr->setSelectedObjects( aList ); + //SALOME_ListIO aList; + //mySelectionMgr->setSelectedObjects( aList ); SMESH::SetPointRepresentation(false); mySimulation->SetVisibility(false); - myViewWindow->SetSelectionMode( ActorSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( ActorSelection ); disconnect( mySelectionMgr, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; + mySMESHGUI->ResetState(); + reject(); +} + +//================================================================================= +// 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 { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(this, tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); + } } //======================================================================= @@ -572,6 +558,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel() void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) { if ( busy ) return; + if (checkEditLine() == -1) return; busy = true; mySimulation->SetVisibility(false); @@ -581,82 +568,70 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) aMesh = myActor->GetObject()->GetMesh(); if (GetConstructorId() == 0) - { - if ( aMesh ) { - SALOME_ListIO aList; aList.Append( myActor->getIO() ); - mySelectionMgr->setSelectedObjects( aList ); - - TColStd_IndexedMapOfInteger selectedIndices; - TColStd_MapOfInteger newIndices; - mySelector->GetIndex( myActor->getIO(), selectedIndices); - - 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 ) { - if (selectedIndices.Add(n->GetID())) + { + if ( aMesh ) { + TColStd_MapOfInteger newIndices; + + QStringList aListId = theNewText.split( " ", QString::SkipEmptyParts ); + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); + if ( n ) { newIndices.Add(n->GetID()); - myNbOkElements++; - } - } + myNbOkElements++; + } + } - if (newIndices.Extent() > 0){ - mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); - } - - if ( myNbOkElements>0 && aListId.count()>=3) - AddButton->setEnabled(true); - else - AddButton->setEnabled(false); + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false ); - displaySimulation(); - } - } else if (GetConstructorId() == 1) - { - myNbOkElements = 0; - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); - // check entered ids of faces and hilight them - QStringList aListId; - if ( aMesh ) { - SALOME_ListIO aList; aList.Append( myActor->getIO() ); - mySelectionMgr->setSelectedObjects( aList ); - - TColStd_IndexedMapOfInteger selectedIndices; - TColStd_MapOfInteger newIndices; - mySelector->GetIndex( myActor->getIO(), selectedIndices); - - aListId = QStringList::split( " ", theNewText, false); - - for ( int i = 0; i < aListId.count(); i++ ) { - const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); - if ( e ) { - if (selectedIndices.Add(e->GetID())) - newIndices.Add(e->GetID()); - myNbOkElements++; - } + if ( myNbOkElements>0 && aListId.count()>=3) + AddButton->setEnabled(true); + else + AddButton->setEnabled(false); + + displaySimulation(); } + } else if (GetConstructorId() == 1) + { + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // check entered ids of faces and hilight them + QStringList aListId; + if ( aMesh ) { + TColStd_MapOfInteger newIndices; + + aListId = theNewText.split( " ", QString::SkipEmptyParts ); - if (newIndices.Extent() > 0){ - mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); - } + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + newIndices.Add(e->GetID()); + myNbOkElements++; + } + } - if ( myNbOkElements ) { - if (aListId.count()>1){ - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } - else{ - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); + + if ( myNbOkElements ) { + if (aListId.count()>1){ + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + else{ + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + if(aListId.count()>1) + displaySimulation(); + } } - displaySimulation(); } - } - } busy = false; } @@ -707,9 +682,10 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument() // get selected nodes/faces QString aString = ""; + int anbNodes=0,aNbFaces=0; switch(GetConstructorId()){ case 0:{ - int anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); + anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString); if (anbNodes >= 3) AddButton->setEnabled(true); else if (anbNodes < 3){ @@ -717,12 +693,13 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument() } busy = true; myEditCurrentArgument->setText( aString ); + if (checkEditLine() == -1) {busy = false;return;} busy = false; break; } case 1:{ // get selected faces - int aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); + aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString); if (aNbFaces<=1){ buttonOk->setEnabled( false ); buttonApply->setEnabled( false ); @@ -732,6 +709,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument() } busy = true; myEditCurrentArgument->setText( aString ); + if (checkEditLine() == -1) {busy = false;return;} busy = false; // OK @@ -740,8 +718,78 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument() } default: return; } + if(anbNodes>2 || aNbFaces>1) + displaySimulation(); +} + +/*\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; - displaySimulation(); + 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 = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts ); + for ( int i = 0; i < aListId.count(); i++ ){ + switch (GetConstructorId()){ + case 0:{ // nodes + const SMDS_MeshNode * aNode = aMesh->FindNode( aListId[ i ].toInt() ); + if( !aNode ){ + SUIT_MessageBox::warning(this, + tr("SMESH_POLYEDRE_CREATE_ERROR"), + tr("The incorrect indices of nodes!")); + + 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){ + SUIT_MessageBox::warning(this, + tr("SMESH_POLYEDRE_CREATE_ERROR"), + tr("The incorrect indices of faces!")); + + myEditCurrentArgument->clear(); + myEditCurrentArgument->setText( aString ); + return -1; + } + break; + } + } + aString += aListId[ i ] + " "; + } + + return 1; } //======================================================================= @@ -753,18 +801,21 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation() if ( (myNbOkElements || AddButton->isEnabled()) && GroupButtons->isEnabled() && myActor) { SMESH::TPolySimulation::TVTKIds aVTKIds; - vtkIdType aType = VTK_CONVEX_POINT_SET ; - if (GetConstructorId() == 0){ - if(!Preview->isChecked()) myActor->SetEntityMode(SMESH_Actor::eFaces); - else myActor->SetEntityMode(SMESH_Actor::eVolumes); + vtkIdType aType = VTK_CONVEX_POINT_SET; + SMDS_Mesh* aMesh = 0; + if ( myActor ){ + aMesh = myActor->GetObject()->GetMesh(); + } + if (GetConstructorId() == 0 && aMesh){ if (!AddButton->isEnabled()){ - QListBoxItem* anItem; mySimulation->ResetGrid(true); - for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) { - QStringList anIds = QStringList::split(" ", anItem->text()); + for (int i = 0; i < myFacesByNodes->count(); i++) { + QStringList anIds = myFacesByNodes->item(i)->text().split( " ", QString::SkipEmptyParts ); SMESH::TPolySimulation::TVTKIds aVTKIds_faces; for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){ - vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ) ; + const SMDS_MeshNode* aNode = aMesh->FindNode( (*it).toInt() ); + if (!aNode) continue; + vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ); aVTKIds.push_back(aId); aVTKIds_faces.push_back(aId); } @@ -783,46 +834,36 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation() } } else { // add ids from edit line - QStringList anEditIds = QStringList::split( " ", myEditCurrentArgument->text(), false); - myActor->SetEntityMode(SMESH_Actor::eFaces); + QStringList anEditIds = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts ); 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); } - }else if(GetConstructorId() == 1){ - SMDS_Mesh* aMesh = 0; - if ( myActor ){ - aMesh = myActor->GetObject()->GetMesh(); - if (Preview->isChecked()) - myActor->SetEntityMode(SMESH_Actor::eVolumes); - else - myActor->SetEntityMode(SMESH_Actor::eFaces); - } - if ( 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 ) - return; + }else if(GetConstructorId() == 1 && aMesh){ + QStringList aListId = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts ); + 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; - SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); - SMESH::TPolySimulation::TVTKIds aVTKIds_faces; - while( anIter->more() ) - 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); - } - if(!Preview->isChecked()){ - aType = VTK_POLYGON; - mySimulation->SetPosition(myActor, aType, aVTKIds_faces); + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + SMESH::TPolySimulation::TVTKIds aVTKIds_faces; + while( anIter->more() ) + 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); } + if(!Preview->isChecked()){ + aType = VTK_POLYGON; + mySimulation->SetPosition(myActor, aType, aVTKIds_faces); } - if(Preview->isChecked()) - mySimulation->SetPosition(myActor, aType, aVTKIds); - } + } + if(Preview->isChecked()) + mySimulation->SetPosition(myActor, aType, aVTKIds); } SMESH::UpdateView(); } @@ -836,7 +877,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); if(send == SelectElementsButton) { - LineEditElements->setFocus() ; + LineEditElements->setFocus(); myEditCurrentArgument = LineEditElements; } SelectionIntoArgument(); @@ -848,13 +889,13 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SetEditCurrentArgument() //================================================================================= void SMESHGUI_CreatePolyhedralVolumeDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupContent->setEnabled(false) ; - GroupButtons->setEnabled(false) ; + if ( ConstructorsBox->isEnabled() ) { + ConstructorsBox->setEnabled(false); + GroupContent->setEnabled(false); + GroupButtons->setEnabled(false); mySimulation->SetVisibility(false); - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; + mySMESHGUI->ResetState(); + mySMESHGUI->SetActiveDialogBox(0); } } @@ -866,14 +907,15 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::DeactivateActiveDialog() void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupContent->setEnabled(true) ; - GroupButtons->setEnabled(true) ; + mySMESHGUI->EmitSignalDeactivateDialog(); + ConstructorsBox->setEnabled(true); + GroupContent->setEnabled(true); + GroupButtons->setEnabled(true); - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); - myViewWindow->SetSelectionMode( FaceSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( FaceSelection ); SelectionIntoArgument(); } @@ -884,9 +926,9 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog() //================================================================================= void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if ( ConstructorsBox->isEnabled() ) + return; + ActivateThisDialog(); } @@ -897,7 +939,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent(QEvent* e) void SMESHGUI_CreatePolyhedralVolumeDlg::closeEvent( QCloseEvent* e ) { /* same than click on cancel button */ - this->ClickOnCancel() ; + ClickOnCancel(); } @@ -919,9 +961,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::hideEvent ( QHideEvent * e ) //================================================================================= int SMESHGUI_CreatePolyhedralVolumeDlg::GetConstructorId() { - if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) - return GroupConstructors->id( GroupConstructors->selected() ); - return -1; + return GroupConstructors->checkedId(); } //================================================================================= @@ -934,12 +974,13 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd() mySelectionMgr->selectedObjects( selected ); int aNbSel = selected.Extent(); if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; + + if (checkEditLine(false) == -1) return; busy = true; - if ( !(myEditCurrentArgument->text().isEmpty()) ) { - myFacesByNodes->insertItem(myEditCurrentArgument->text()); + myFacesByNodes->addItem(myEditCurrentArgument->text()); //myFacesByNodes->setSelected(myFacesByNodes->count() - 1, true); myNbOkElements = 1; myEditCurrentArgument->clear(); @@ -959,21 +1000,18 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd() void SMESHGUI_CreatePolyhedralVolumeDlg::onRemove() { busy = true; - for (int i = myFacesByNodes->count(); i > 0; i--) { - if (myFacesByNodes->isSelected(i-1)) { - myFacesByNodes->removeItem(i-1); - myNbOkElements = 1; - } - } - if (myFacesByNodes->count() < 1){ - RemoveButton->setEnabled(false); - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } - else if (myFacesByNodes->count() == 1){ - buttonOk->setEnabled( false ); - buttonApply->setEnabled( false ); - } + QList selItems = myFacesByNodes->selectedItems(); + QListWidgetItem* anItem; + + if ( selItems.count() > 0 ) myNbOkElements = 1; + + foreach( anItem, selItems ) + delete anItem; + + RemoveButton->setEnabled( myFacesByNodes->count() > 0 ); + buttonOk->setEnabled( myFacesByNodes->count() > 1 ); + buttonApply->setEnabled( myFacesByNodes->count() > 1 ); + busy = false; displaySimulation(); } @@ -986,26 +1024,41 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onListSelectionChanged() { if (busy || !myActor) return; busy = true; - bool isSelected=false; + SALOME_ListIO aList; mySelectionMgr->setSelectedObjects( aList ); TColStd_MapOfInteger aIndexes; - QListBoxItem* anItem; - for (anItem = myFacesByNodes->firstItem(); anItem != 0; anItem = anItem->next()) { - if (anItem->isSelected()) { - isSelected = true; - QStringList anIds = QStringList::split(" ", anItem->text()); - for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it) - aIndexes.Add((*it).toInt()); - } + + QList selItems = myFacesByNodes->selectedItems(); + QListWidgetItem* anItem; + foreach( anItem, selItems ) { + QStringList anIds = anItem->text().split( " ", QString::SkipEmptyParts ); + for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it) + aIndexes.Add((*it).toInt()); } - if(isSelected) RemoveButton->setEnabled(true); - else RemoveButton->setEnabled(false); + RemoveButton->setEnabled(selItems.count() > 0); mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); mySelectionMgr->clearFilters(); aList.Append( myActor->getIO() ); mySelectionMgr->setSelectedObjects( aList ); busy = false; } + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_CreatePolyhedralVolumeDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); + } +}