X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_AddQuadraticElementDlg.cxx;h=daa119db5590a1597597afda75ac8672638a1fdb;hp=1f1e5bd1427b7f3bcea6ad5879f0f6f78e2a051c;hb=2c607013a23bd4e7ba07e72e0c04dee2c1209cff;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813 diff --git a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx index 1f1e5bd14..daa119db5 100644 --- a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx @@ -1,4 +1,6 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 @@ -6,7 +8,7 @@ // 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 +// 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. @@ -17,76 +19,81 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_AddMeshElementDlg.cxx +// Author : Nicolas REJNERI, Open CASCADE S.A.S. +// SMESH includes +// #include "SMESHGUI_AddQuadraticElementDlg.h" #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_GroupUtils.h" #include "SMESHGUI_IdValidator.h" -#include "SMESH_ActorUtils.h" -#include "SMDS_Mesh.hxx" -#include "SMESH_Actor.h" +#include +#include +#include +#include -#include "SUIT_Session.h" -#include "SUIT_MessageBox.h" -#include "LightApp_Application.h" +// SALOME GUI includes +#include +#include +#include +#include +#include -#include "SVTK_Selection.h" -#include "SVTK_Selector.h" -#include "SALOME_ListIO.hxx" -#include "SALOME_ListIteratorOfListIO.hxx" +#include -#include "SalomeApp_Study.h" -#include "SalomeApp_Application.h" +#include +#include -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" +#include -#include "utilities.h" +#include +// IDL includes +#include #include CORBA_SERVER_HEADER(SMESH_MeshEditor) -// OCCT Includes +// OCCT includes #include -#include -// VTK Includes -#include +// VTK includes #include -#include -#include -#include #include #include +#include #include - -#include -#include -#include -#include -#include - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // STL includes -#include - -using namespace std; +#include -namespace SMESH { +#define SPACING 6 +#define MARGIN 11 - void ReverseConnectivity( vector & ids, int type ) +namespace SMESH +{ + void ReverseConnectivity( std::vector & ids, int type ) { // for reverse connectivity of other types keeping the first id, see // void SMESH_VisualObjDef::buildElemPrs() in SMESH_Object.cxx:900 @@ -134,7 +141,7 @@ namespace SMESH { reverse( ids.begin(), ids.end() ); } else { - vector aRevIds( ids.size() ); + std::vector aRevIds( ids.size() ); for ( int i = 0; i < ids.size(); i++) aRevIds[ i ] = ids[ conn[ i ]]; ids = aRevIds; @@ -151,7 +158,11 @@ namespace SMESH { vtkUnstructuredGrid* myGrid; //vtkProperty* myBackProp, *myProp; - vtkFloatingPointType myRGB[3], myBackRGB[3]; + //vtkFloatingPointType myRGB[3], myBackRGB[3]; + + SALOME_Actor* myFaceOrientation; + vtkPolyDataMapper* myFaceOrientationDataMapper; + SMESH_FaceOrientationFilter* myFaceOrientationFilter; public: TElementSimulation (SalomeApp_Application* theApplication) @@ -174,25 +185,46 @@ namespace SMESH { myPreviewActor->SetMapper(myMapper); vtkProperty* myProp = vtkProperty::New(); - GetColor( "SMESH", "fill_color", myRGB[0], myRGB[1], myRGB[2], QColor( 0, 170, 255 ) ); - myProp->SetColor( myRGB[0], myRGB[1], myRGB[2] ); + vtkFloatingPointType aRGB[3], aBackRGB[3]; + GetColor( "SMESH", "fill_color", aRGB[0], aRGB[1], aRGB[2], QColor( 0, 170, 255 ) ); + myProp->SetColor( aRGB[0], aRGB[1], aRGB[2] ); myPreviewActor->SetProperty( myProp ); myProp->Delete(); vtkProperty* myBackProp = vtkProperty::New(); - GetColor( "SMESH", "backface_color", myBackRGB[0], myBackRGB[1], myBackRGB[2], QColor( 0, 0, 255 ) ); - myBackProp->SetColor( myBackRGB[0], myBackRGB[1], myBackRGB[2] ); + GetColor( "SMESH", "backface_color", aBackRGB[0], aBackRGB[1], aBackRGB[2], QColor( 0, 0, 255 ) ); + myBackProp->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] ); myPreviewActor->SetBackfaceProperty( myBackProp ); myBackProp->Delete(); myVTKViewWindow->AddActor(myPreviewActor); + + // Orientation of faces + myFaceOrientationFilter = SMESH_FaceOrientationFilter::New(); + myFaceOrientationFilter->SetInput(myGrid); + + myFaceOrientationDataMapper = vtkPolyDataMapper::New(); + myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput()); + + myFaceOrientation = SALOME_Actor::New(); + myFaceOrientation->PickableOff(); + myFaceOrientation->VisibilityOff(); + myFaceOrientation->SetMapper(myFaceOrientationDataMapper); + + vtkProperty* anOrientationProp = vtkProperty::New(); + GetColor( "SMESH", "orientation_color", aRGB[0], aRGB[1], aRGB[2], QColor( 255, 255, 255 ) ); + anOrientationProp->SetColor( aRGB[0], aRGB[1], aRGB[2] ); + myFaceOrientation->SetProperty( anOrientationProp ); + anOrientationProp->Delete(); + + myVTKViewWindow->AddActor(myFaceOrientation); } typedef std::vector TVTKIds; void SetPosition (SMESH_Actor* theActor, const int theType, TVTKIds& theIds, - const int theMode, + const int theMode, const bool theReverse) { vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); @@ -220,8 +252,8 @@ namespace SMESH { aType = VTK_CONVEX_POINT_SET; break; case QUAD_PENTAHEDRON: - //aType = VTK_QUADRATIC_WEDGE; // NOT SUPPORTED IN VTK4.2 - aType = VTK_CONVEX_POINT_SET; + aType = VTK_QUADRATIC_WEDGE; + //aType = VTK_CONVEX_POINT_SET; break; case QUAD_HEXAHEDRON: aType = VTK_QUADRATIC_HEXAHEDRON; @@ -236,9 +268,13 @@ namespace SMESH { } else { // VTK cell connectivity opposites the MED one for volumic elements - if ( theIds.size() > 8 ? !theReverse : theReverse ) { - ReverseConnectivity( theIds, theType ); + if( aType != VTK_QUADRATIC_WEDGE) { + if ( theIds.size() > 8 ? !theReverse : theReverse ) { + ReverseConnectivity( theIds, theType ); + } } + else if(theReverse) + ReverseConnectivity( theIds, theType ); } myGrid->Reset(); @@ -256,7 +292,7 @@ namespace SMESH { myPreviewActor->GetMapper()->Update(); myPreviewActor->SetRepresentation( theMode ); - SetVisibility(true); + SetVisibility(true, theActor->GetFacesOriented()); // restore normal orientation if ( aType == VTK_CONVEX_POINT_SET ) { @@ -267,9 +303,10 @@ namespace SMESH { } - void SetVisibility (bool theVisibility) + void SetVisibility (bool theVisibility, bool theShowOrientation = false) { myPreviewActor->SetVisibility(theVisibility); + myFaceOrientation->SetVisibility(theShowOrientation); RepaintCurrentView(); } @@ -277,13 +314,20 @@ namespace SMESH { ~TElementSimulation() { if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { - myVTKViewWindow->RemoveActor(myPreviewActor); + myVTKViewWindow->RemoveActor(myPreviewActor); + myVTKViewWindow->RemoveActor(myFaceOrientation); } myPreviewActor->Delete(); + myFaceOrientation->Delete(); myMapper->RemoveAllInputs(); myMapper->Delete(); + myFaceOrientationFilter->Delete(); + + myFaceOrientationDataMapper->RemoveAllInputs(); + myFaceOrientationDataMapper->Delete(); + myGrid->Delete(); // myProp->Delete(); @@ -317,20 +361,69 @@ static int LastHexahedronIds[] = {1,2,3,0,5,6,7,4,4,5,6,7}; +/*! + \class BusyLocker + \brief Simple 'busy state' flag locker. + \internal +*/ + +class BusyLocker +{ +public: + //! Constructor. Sets passed boolean flag to \c true. + BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; } + //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false. + ~BusyLocker() { myBusy = false; } +private: + bool& myBusy; //! External 'busy state' boolean flag +}; + +/*! + \class IdEditItem + \brief Simple editable table item. + \internal +*/ + +class IdEditItem: public QTableWidgetItem +{ +public: + IdEditItem(const QString& text ); + ~IdEditItem(); + + QWidget* createEditor() const; +}; + +IdEditItem::IdEditItem(const QString& text ) + : QTableWidgetItem(text, QTableWidgetItem::UserType+100) +{ +} + +IdEditItem::~IdEditItem() +{ +} + +QWidget* IdEditItem::createEditor() const +{ + QLineEdit *aLineEdit = new QLineEdit(text(), tableWidget()); + aLineEdit->setValidator( new SMESHGUI_IdValidator(tableWidget(), 1) ); + return aLineEdit; +} + //================================================================================= // function : SMESHGUI_AddQuadraticElementDlg() // purpose : constructor //================================================================================= SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theModule, - const int theType, - 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 ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myType( theType ) + const int theType ) + : QDialog( SMESH::GetDesktop( theModule ) ), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myType( theType ), + myBusy( false ) { + setModal( false ); + setAttribute( Qt::WA_DeleteOnClose, true ); + SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); @@ -366,105 +459,98 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM anElementName = QString("QUADRATIC_EDGE"); } - QString iconName = tr(QString("ICON_DLG_%1").arg(anElementName)); - QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(anElementName)); - QString argumentsGrTitle = tr(QString("SMESH_ADD_%1").arg(anElementName)); - QString constructorGrTitle = tr(QString("SMESH_%1").arg(anElementName)); + QString iconName = tr(QString("ICON_DLG_%1").arg(anElementName).toLatin1().data()); + QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(anElementName).toLatin1().data()); + QString argumentsGrTitle = tr(QString("SMESH_ADD_%1").arg(anElementName).toLatin1().data()); + QString constructorGrTitle = tr(QString("SMESH_%1").arg(anElementName).toLatin1().data()); QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName)); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); - if (!name) - setName("SMESHGUI_AddQuadraticElementDlg"); - setCaption(caption); + setWindowTitle(caption); - setSizeGripEnabled(TRUE); - QGridLayout* aDialogLayout = new QGridLayout(this); - aDialogLayout->setSpacing(6); - aDialogLayout->setMargin(11); + setSizeGripEnabled(true); + + QVBoxLayout* aDialogLayout = new QVBoxLayout(this); + aDialogLayout->setSpacing(SPACING); + aDialogLayout->setMargin(MARGIN); /***************************************************************/ - GroupConstructors = new QButtonGroup(this, "GroupConstructors"); - GroupConstructors->setTitle(constructorGrTitle); - - GroupConstructors->setExclusive(TRUE); - GroupConstructors->setColumnLayout(0, Qt::Vertical); - GroupConstructors->layout()->setSpacing(0); - GroupConstructors->layout()->setMargin(0); - GroupConstructors->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); - QGridLayout* aGroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); - aGroupConstructorsLayout->setAlignment(Qt::AlignTop); - aGroupConstructorsLayout->setSpacing(6); - aGroupConstructorsLayout->setMargin(11); - myRadioButton1 = new QRadioButton(GroupConstructors, "myRadioButton1"); - myRadioButton1->setText(tr("" )); - myRadioButton1->setPixmap(image0); - myRadioButton1->setChecked(TRUE); - myRadioButton1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, myRadioButton1->sizePolicy().hasHeightForWidth())); - aGroupConstructorsLayout->addWidget(myRadioButton1, 0, 0); - aGroupConstructorsLayout->addItem( new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1); - aDialogLayout->addWidget(GroupConstructors, 0, 0); + GroupConstructors = new QGroupBox(constructorGrTitle, this); + QButtonGroup* ButtonGroup = new QButtonGroup(this); + QHBoxLayout* aGroupConstructorsLayout = new QHBoxLayout(GroupConstructors); + aGroupConstructorsLayout->setSpacing(SPACING); + aGroupConstructorsLayout->setMargin(MARGIN); + + myRadioButton1 = new QRadioButton(GroupConstructors); + myRadioButton1->setIcon(image0); + aGroupConstructorsLayout->addWidget(myRadioButton1); + ButtonGroup->addButton(myRadioButton1, 0); /***************************************************************/ - GroupArguments = new QGroupBox(this, "GroupArguments"); - GroupArguments->setTitle(argumentsGrTitle); - GroupArguments->setColumnLayout(0, Qt::Vertical); - GroupArguments->layout()->setSpacing(0); - GroupArguments->layout()->setMargin(0); - GroupArguments->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding)); - QGridLayout* aGroupArgumentsLayout = new QGridLayout(GroupArguments->layout()); - aGroupArgumentsLayout->setAlignment(Qt::AlignTop); - aGroupArgumentsLayout->setSpacing(6); - aGroupArgumentsLayout->setMargin(11); - QLabel* aCornerNodesLabel = new QLabel(GroupArguments, "aCornerNodesLabel"); - aCornerNodesLabel->setText(tr("SMESH_CORNER_NODES" )); - aGroupArgumentsLayout->addWidget(aCornerNodesLabel, 0, 0); - mySelectButton = new QPushButton(GroupArguments, "mySelectButton"); - mySelectButton->setPixmap(image1); - aGroupArgumentsLayout->addWidget(mySelectButton, 0, 1); - myCornerNodes = new QLineEdit(GroupArguments, "myCornerNodes"); - aGroupArgumentsLayout->addWidget(myCornerNodes, 0, 2); - - myTable = new QTable(GroupArguments); - aGroupArgumentsLayout->addMultiCellWidget(myTable, 1, 1, 0, 2); - - myReverseCB = new QCheckBox(GroupArguments, "myReverseCB"); - myReverseCB->setText(tr("SMESH_REVERSE" )); - aGroupArgumentsLayout->addWidget(myReverseCB, 2, 0); - - aDialogLayout->addWidget(GroupArguments, 1, 0); + GroupArguments = new QGroupBox(argumentsGrTitle, this); + QGridLayout* aGroupArgumentsLayout = new QGridLayout(GroupArguments); + aGroupArgumentsLayout->setSpacing(SPACING); + aGroupArgumentsLayout->setMargin(MARGIN); + QLabel* aCornerNodesLabel = new QLabel(tr("SMESH_CORNER_NODES"), GroupArguments); + mySelectButton = new QPushButton(GroupArguments); + mySelectButton->setIcon(image1); + myCornerNodes = new QLineEdit(GroupArguments); + + myTable = new QTableWidget(GroupArguments); + + myReverseCB = new QCheckBox(tr("SMESH_REVERSE"), GroupArguments); + + aGroupArgumentsLayout->addWidget(aCornerNodesLabel, 0, 0); + aGroupArgumentsLayout->addWidget(mySelectButton, 0, 1); + aGroupArgumentsLayout->addWidget(myCornerNodes, 0, 2); + aGroupArgumentsLayout->addWidget(myTable, 1, 0, 1, 3); + aGroupArgumentsLayout->addWidget(myReverseCB, 2, 0, 1, 3); /***************************************************************/ - GroupButtons = new QGroupBox(this, "GroupButtons"); - GroupButtons->setColumnLayout(0, Qt::Vertical); - GroupButtons->layout()->setSpacing(0); - GroupButtons->layout()->setMargin(0); - GroupButtons->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - QGridLayout* aGroupButtonsLayout = new QGridLayout(GroupButtons->layout()); - aGroupButtonsLayout->setAlignment(Qt::AlignTop); - aGroupButtonsLayout->setSpacing(6); - aGroupButtonsLayout->setMargin(11); - buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); - buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); - buttonCancel->setAutoDefault(TRUE); - aGroupButtonsLayout->addWidget(buttonCancel, 0, 3); - buttonApply = new QPushButton(GroupButtons, "buttonApply"); - buttonApply->setText(tr("SMESH_BUT_APPLY" )); - buttonApply->setAutoDefault(TRUE); - aGroupButtonsLayout->addWidget(buttonApply, 0, 1); - aGroupButtonsLayout->addItem( new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); - buttonOk = new QPushButton(GroupButtons, "buttonOk"); - buttonOk->setText(tr("SMESH_BUT_OK" )); - buttonOk->setAutoDefault(TRUE); - buttonOk->setDefault(TRUE); - aGroupButtonsLayout->addWidget(buttonOk, 0, 0); - buttonHelp = new QPushButton(GroupButtons, "buttonHelp"); - buttonHelp->setText(tr("SMESH_BUT_HELP" )); - buttonHelp->setAutoDefault(TRUE); - aGroupButtonsLayout->addWidget(buttonHelp, 0, 4); - - aDialogLayout->addWidget(GroupButtons, 2, 0); + GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this ); + GroupGroups->setCheckable( true ); + QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups); + GroupGroupsLayout->setSpacing(SPACING); + GroupGroupsLayout->setMargin(MARGIN); + + TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups ); + ComboBox_GroupName = new QComboBox( GroupGroups ); + ComboBox_GroupName->setEditable( true ); + + GroupGroupsLayout->addWidget( TextLabel_GroupName ); + GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 ); + + /***************************************************************/ + GroupButtons = new QGroupBox(this); + QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(GroupButtons); + aGroupButtonsLayout->setSpacing(SPACING); + aGroupButtonsLayout->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); + + aGroupButtonsLayout->addWidget(buttonOk); + aGroupButtonsLayout->addSpacing(10); + aGroupButtonsLayout->addWidget(buttonApply); + aGroupButtonsLayout->addSpacing(10); + aGroupButtonsLayout->addStretch(); + aGroupButtonsLayout->addWidget(buttonCancel); + aGroupButtonsLayout->addWidget(buttonHelp); + + /***************************************************************/ + aDialogLayout->addWidget(GroupConstructors); + aDialogLayout->addWidget(GroupArguments); + aDialogLayout->addWidget(GroupGroups); + aDialogLayout->addWidget(GroupButtons); Init(); /* Initialisations */ } @@ -475,7 +561,6 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM //================================================================================= SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg() { - // no need to delete child widgets, Qt does it all for us delete mySimulation; } @@ -485,11 +570,12 @@ SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg() //================================================================================= void SMESHGUI_AddQuadraticElementDlg::Init() { - GroupArguments->show(); - myRadioButton1->setChecked(TRUE); - myIsEditCorners = true; + myRadioButton1->setChecked(true); mySMESHGUI->SetActiveDialogBox((QDialog*)this); + /* reset "Add to group" control */ + GroupGroups->setChecked( false ); + myActor = 0; int aNumRows; @@ -532,38 +618,44 @@ void SMESHGUI_AddQuadraticElementDlg::Init() break; } - myCornerNodes->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbCorners)); + myCornerNodes->setValidator(new SMESHGUI_IdValidator(this, myNbCorners)); /* initialize table */ - myTable->setNumCols(3); - myTable->setNumRows(aNumRows); + myTable->setColumnCount(3); + myTable->setRowCount(aNumRows); QStringList aColLabels; aColLabels.append(tr("SMESH_FIRST")); aColLabels.append(tr("SMESH_MIDDLE")); aColLabels.append(tr("SMESH_LAST")); - myTable->setColumnLabels(aColLabels); + myTable->setHorizontalHeaderLabels(aColLabels); - for ( int col = 0; col < myTable->numCols(); col++ ) + for ( int col = 0; col < myTable->columnCount(); col++ ) myTable->setColumnWidth(col, 80); - myTable->setColumnReadOnly(0, true); - myTable->setColumnReadOnly(2, true); + //myTable->setColumnReadOnly(0, true); // VSR: TODO + //myTable->setColumnReadOnly(2, true); // VSR: TODO myTable->setEnabled( false ); - for ( int row = 0; row < myTable->numRows(); row++ ) - { - SMESHGUI_IdEditItem* anEditItem = new SMESHGUI_IdEditItem( myTable, QTableItem::OnTyping, "" ); - anEditItem->setReplaceable(false); - myTable->setItem(row, 1, anEditItem); - } + for ( int row = 0; row < myTable->rowCount(); row++ ) + { + myTable->setItem( row, 0, new QTableWidgetItem( "" ) ); + myTable->item( row, 0 )->setFlags(0); + + IdEditItem* anEditItem = new IdEditItem( "" ); + anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + myTable->setItem(row, 1, anEditItem); + + myTable->setItem( row, 2, new QTableWidgetItem( "" ) ); + myTable->item( row, 2 )->setFlags(0); + } /* signals and slots connections */ connect(mySelectButton, SIGNAL(clicked()), SLOT(SetEditCorners())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument())); - connect(myTable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), SLOT(onCellDoubleClicked(int, int, int, const QPoint&))); - connect(myTable, SIGNAL(valueChanged (int, int)), SLOT(onCellTextChange(int, int))); + connect(myTable, SIGNAL(cellDoubleClicked(int, int)), SLOT(onCellDoubleClicked(int, int))); + connect(myTable, SIGNAL(cellChanged (int, int)), SLOT(onCellTextChange(int, int))); connect(myCornerNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); connect(myReverseCB, SIGNAL(stateChanged(int)), SLOT(onReverse(int))); @@ -574,8 +666,7 @@ void SMESHGUI_AddQuadraticElementDlg::Init() connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel())); - - this->show(); // displays Dialog + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(ClickOnCancel())); // set selection mode SMESH::SetPointRepresentation(true); @@ -583,8 +674,6 @@ void SMESHGUI_AddQuadraticElementDlg::Init() if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode( NodeSelection ); - myBusy = false; - SetEditCorners(); } @@ -594,68 +683,132 @@ void SMESHGUI_AddQuadraticElementDlg::Init() //================================================================================= void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() { - if (IsValid() && !mySMESHGUI->isActiveStudyLocked()) { - myBusy = true; - - vector anIds; + if( !isValid() ) + return; - switch (myType) { - case QUAD_EDGE: - anIds.push_back(myTable->text(0, 0).toInt()); - anIds.push_back(myTable->text(0, 2).toInt()); - anIds.push_back(myTable->text(0, 1).toInt()); - break; - case QUAD_TRIANGLE: - case QUAD_QUADRANGLE: - case QUAD_TETRAHEDRON: - case QUAD_PYRAMID: - case QUAD_PENTAHEDRON: - case QUAD_HEXAHEDRON: - for ( int row = 0; row < myNbCorners; row++ ) - anIds.push_back(myTable->text(row, 0).toInt()); - for ( int row = 0; row < myTable->numRows(); row++ ) - anIds.push_back(myTable->text(row, 1).toInt()); - break; - } - if ( myReverseCB->isChecked()) - SMESH::ReverseConnectivity( anIds, myType ); + if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() ) + return; + + BusyLocker lock( myBusy ); + + std::vector anIds; + + switch (myType) { + case QUAD_EDGE: + anIds.push_back(myTable->item(0, 0)->text().toInt()); + anIds.push_back(myTable->item(0, 2)->text().toInt()); + anIds.push_back(myTable->item(0, 1)->text().toInt()); + break; + case QUAD_TRIANGLE: + case QUAD_QUADRANGLE: + case QUAD_TETRAHEDRON: + case QUAD_PYRAMID: + case QUAD_PENTAHEDRON: + case QUAD_HEXAHEDRON: + for ( int row = 0; row < myNbCorners; row++ ) + anIds.push_back(myTable->item(row, 0)->text().toInt()); + for ( int row = 0; row < myTable->rowCount(); row++ ) + anIds.push_back(myTable->item(row, 1)->text().toInt()); + break; + } + if ( myReverseCB->isChecked()) + SMESH::ReverseConnectivity( anIds, myType ); - int aNumberOfIds = anIds.size(); - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length( aNumberOfIds ); + int aNumberOfIds = anIds.size(); + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length( aNumberOfIds ); - for (int i = 0; i < aNumberOfIds; i++) - anArrayOfIdeces[i] = anIds[ i ]; + for (int i = 0; i < aNumberOfIds; i++) + anArrayOfIdeces[i] = anIds[ i ]; - SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - switch (myType) { - case QUAD_EDGE: - aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; - case QUAD_TRIANGLE: - case QUAD_QUADRANGLE: - aMeshEditor->AddFace(anArrayOfIdeces.inout()); break; - case QUAD_TETRAHEDRON: - case QUAD_PYRAMID: - case QUAD_PENTAHEDRON: - case QUAD_HEXAHEDRON: - aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; + bool addToGroup = GroupGroups->isChecked(); + QString aGroupName; + + SMESH::SMESH_GroupBase_var aGroup; + int idx = 0; + if( addToGroup ) { + aGroupName = ComboBox_GroupName->currentText(); + for ( int i = 1; i < ComboBox_GroupName->count(); i++ ) { + QString aName = ComboBox_GroupName->itemText( i ); + if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) ) + idx = i; + } + if ( idx > 0 ) { + SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] ); + if ( !aGeomGroup->_is_nil() ) { + int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ), + tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ), + tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ); + if ( res == 1 ) return; + } + aGroup = myGroups[idx-1]; } + } + + SMESH::ElementType anElementType; + long anElemId = -1; + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + switch (myType) { + case QUAD_EDGE: + anElementType = SMESH::EDGE; + anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; + case QUAD_TRIANGLE: + case QUAD_QUADRANGLE: + anElementType = SMESH::FACE; + anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break; + case QUAD_TETRAHEDRON: + case QUAD_PYRAMID: + case QUAD_PENTAHEDRON: + case QUAD_HEXAHEDRON: + anElementType = SMESH::VOLUME; + anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; + default: break; + } - SALOME_ListIO aList; aList.Append( myActor->getIO() ); - mySelector->ClearIndex(); - mySelectionMgr->setSelectedObjects( aList, false ); + if ( anElemId != -1 && addToGroup && !aGroupName.isEmpty() ) { + SMESH::SMESH_Group_var aGroupUsed; + if ( aGroup->_is_nil() ) { + // create new group + aGroupUsed = SMESH::AddGroup( myMesh, anElementType, aGroupName ); + if ( !aGroupUsed->_is_nil() ) { + myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed)); + ComboBox_GroupName->addItem( aGroupName ); + } + } + else { + SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup ); + if ( !aGeomGroup->_is_nil() ) { + aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup ); + if ( !aGroupUsed->_is_nil() && idx > 0 ) { + myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed); + SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); + } + } + else + aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup ); + } + + if ( !aGroupUsed->_is_nil() ) { + SMESH::long_array_var anIdList = new SMESH::long_array; + anIdList->length( 1 ); + anIdList[0] = anElemId; + aGroupUsed->Add( anIdList.inout() ); + } + } - SMESH::UpdateView(); - mySimulation->SetVisibility(false); + SALOME_ListIO aList; aList.Append( myActor->getIO() ); + mySelector->ClearIndex(); + mySelectionMgr->setSelectedObjects( aList, false ); + + mySimulation->SetVisibility(false); + SMESH::UpdateView(); - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); + UpdateTable(); + SetEditCorners(); - UpdateTable(); - SetEditCorners(); + updateButtons(); - myBusy = false; - } + SMESHGUI::Modified(); } //================================================================================= @@ -666,7 +819,6 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnOk() { ClickOnApply(); ClickOnCancel(); - return; } //================================================================================= @@ -683,7 +835,6 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySMESHGUI->ResetState(); reject(); - return; } //================================================================================= @@ -696,16 +847,17 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp() if (app) app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); else { - QString platform; + QString platform; #ifdef WIN32 - platform = "winapplication"; + platform = "winapplication"; #else - platform = "application"; + platform = "application"; #endif - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName), - QObject::tr("BUT_OK")); + SUIT_MessageBox::warning(this, tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName)); } } @@ -716,11 +868,8 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp() void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) { if (myBusy) return; - myBusy = true; + BusyLocker lock( myBusy ); - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - mySimulation->SetVisibility(false); // hilight entered nodes @@ -731,16 +880,18 @@ void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) if (aMesh) { TColStd_MapOfInteger newIndices; - QStringList aListId = QStringList::split(" ", theNewText, false); + QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts); bool allOk = true; for (int i = 0; i < aListId.count(); i++) { - if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) ) - newIndices.Add( n->GetID() ); + if ( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) ) + { + newIndices.Add( n->GetID() ); + } else - { - allOk = false; - break; - } + { + allOk = false; + break; + } } mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false ); @@ -751,15 +902,8 @@ void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) UpdateTable( allOk ); } - if( IsValid() ) { - buttonOk->setEnabled(true); - buttonApply->setEnabled(true); - } - - if ( sender() == myTable ) - displaySimulation(); - - myBusy = false; + updateButtons(); + displaySimulation(); } //================================================================================= @@ -769,73 +913,99 @@ void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText) void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() { if (myBusy) return; + BusyLocker lock( myBusy ); + QString aCurrentEntry = myEntry; + if ( myIsEditCorners ) - { - // clear - myActor = 0; - - myBusy = true; - myCornerNodes->setText(""); - myBusy = false; - - if (!GroupButtons->isEnabled()) // inactive - return; - - buttonOk->setEnabled(false); - buttonApply->setEnabled(false); - - mySimulation->SetVisibility(false); - - // get selected mesh - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + { + // clear + myActor = 0; + + myCornerNodes->setText(""); + + if (!GroupButtons->isEnabled()) // inactive + return; + + mySimulation->SetVisibility(false); - if (aList.Extent() != 1) - { - UpdateTable(); - return; - } + // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + + if (aList.Extent() != 1) + { + UpdateTable(); + updateButtons(); + return; + } - Handle(SALOME_InteractiveObject) anIO = aList.First(); - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) - return; + Handle(SALOME_InteractiveObject) anIO = aList.First(); + myEntry = anIO->getEntry(); + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) { + updateButtons(); + return; + } - myActor = SMESH::FindActorByEntry(anIO->getEntry()); + myActor = SMESH::FindActorByEntry(anIO->getEntry()); + } + + // process groups + if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) { + SMESH::ElementType anElementType; + switch ( myType ) { + case QUAD_EDGE: + anElementType = SMESH::EDGE; break; + case QUAD_TRIANGLE: + case QUAD_QUADRANGLE: + anElementType = SMESH::FACE; break; + case QUAD_TETRAHEDRON: + case QUAD_PYRAMID: + case QUAD_PENTAHEDRON: + case QUAD_HEXAHEDRON: + anElementType = SMESH::VOLUME; break; } + myGroups.clear(); + ComboBox_GroupName->clear(); + ComboBox_GroupName->addItem( QString() ); + SMESH::ListOfGroups 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() == anElementType ) { + QString aGroupName( aGroup->GetName() ); + if ( !aGroupName.isEmpty() ) { + myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup)); + ComboBox_GroupName->addItem( aGroupName ); + } + } + } + } - if (!myActor) + if (!myActor) { + updateButtons(); return; + } // get selected nodes QString aString = ""; int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString); if ( myIsEditCorners ) - { - myBusy = true; - myCornerNodes->setText(aString); - myBusy = false; - - UpdateTable(); - } + { + myCornerNodes->setText(aString); + + UpdateTable(); + } else if ( myTable->isEnabled() && nbNodes == 1 ) - { - myBusy = true; - int theRow = myTable->currentRow(), theCol = myTable->currentColumn(); - if ( theCol == 1 ) - myTable->setText(theRow, 1, aString); - myBusy = false; - } + { + int theRow = myTable->currentRow(), theCol = myTable->currentColumn(); + if ( theCol == 1 ) + myTable->item(theRow, 1)->setText(aString); + } - if ( IsValid() ) - { - buttonOk->setEnabled( true ); - buttonApply->setEnabled( true ); - } - + updateButtons(); displaySimulation(); } @@ -845,42 +1015,47 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() //================================================================================= void SMESHGUI_AddQuadraticElementDlg::displaySimulation() { - if (!myIsEditCorners) { + if ( IsValid() ) + { SMESH::TElementSimulation::TVTKIds anIds; // Collect ids from the dialog int anID; bool ok; int aDisplayMode = VTK_SURFACE; - + if ( myType == QUAD_EDGE ) - { - anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->text(0, 0).toInt() ) ); - anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->text(0, 2).toInt() ) ); - anID = (myTable->text(0, 1)).toInt(&ok); - if (!ok) anID = (myTable->text(0, 0)).toInt(); - anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); - aDisplayMode = VTK_WIREFRAME; - } + { + anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) ); + anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 2)->text().toInt() ) ); + anID = myTable->item(0, 1)->text().toInt(&ok); + if (!ok) anID = myTable->item(0, 0)->text().toInt(); + anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); + aDisplayMode = VTK_WIREFRAME; + } else + { + for ( int row = 0; row < myNbCorners; row++ ) + anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(row, 0)->text().toInt() ) ); + + for ( int row = 0; row < myTable->rowCount(); row++ ) { - for ( int row = 0; row < myNbCorners; row++ ) - anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->text(row, 0).toInt() ) ); - - for ( int row = 0; row < myTable->numRows(); row++ ) - { - anID = (myTable->text(row, 1)).toInt(&ok); - if (!ok) { - anID = (myTable->text(row, 0)).toInt(); - aDisplayMode = VTK_WIREFRAME; - } - anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); - } + anID = myTable->item(row, 1)->text().toInt(&ok); + if (!ok) { + anID = myTable->item(row, 0)->text().toInt(); + aDisplayMode = VTK_WIREFRAME; + } + anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); } + } mySimulation->SetPosition(myActor,myType,anIds,aDisplayMode,myReverseCB->isChecked()); - SMESH::UpdateView(); } + else + { + mySimulation->SetVisibility(false); + } + SMESH::UpdateView(); } //================================================================================= @@ -891,8 +1066,8 @@ void SMESHGUI_AddQuadraticElementDlg::SetEditCorners() { myCornerNodes->setFocus(); myIsEditCorners = true; - SelectionIntoArgument(); + updateButtons(); } //================================================================================= @@ -940,7 +1115,6 @@ void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*) if (GroupConstructors->isEnabled()) return; ActivateThisDialog(); - return; } //================================================================================= @@ -951,7 +1125,6 @@ void SMESHGUI_AddQuadraticElementDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ ClickOnCancel(); - return; } //================================================================================= @@ -970,13 +1143,9 @@ void SMESHGUI_AddQuadraticElementDlg::hideEvent (QHideEvent*) //================================================================================= void SMESHGUI_AddQuadraticElementDlg::onReverse (int state) { - if (!IsValid()) - return; - - if (state >= 0) { - mySimulation->SetVisibility(false); - displaySimulation(); - } + mySimulation->SetVisibility(false); + displaySimulation(); + updateButtons(); } @@ -994,16 +1163,16 @@ bool SMESHGUI_AddQuadraticElementDlg::IsValid() bool ok; - for ( int row = 0; row < myTable->numRows(); row++ ) - { - int anID = (myTable->text(row, 1)).toInt(&ok); - if ( !ok ) - return false; - - const SMDS_MeshNode * aNode = aMesh->FindNode(anID); - if ( !aNode ) - return false; - } + for ( int row = 0; row < myTable->rowCount(); row++ ) + { + int anID = myTable->item(row, 1)->text().toInt(&ok); + if ( !ok ) + return false; + + const SMDS_MeshNode * aNode = aMesh->FindNode(anID); + if ( !aNode ) + return false; + } return true; } @@ -1014,66 +1183,66 @@ bool SMESHGUI_AddQuadraticElementDlg::IsValid() //================================================================================= void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) { - QStringList aListCorners = QStringList::split(" ", myCornerNodes->text(), false); + QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts); if ( aListCorners.count() == myNbCorners && theConersValidity ) - { - myTable->setEnabled( true ); - - // clear the Middle column - for ( int row = 0; row < myTable->numRows(); row++ ) - myTable->setText( row, 1, ""); - - int* aFirstColIds; - int* aLastColIds; - - switch (myType) { - case QUAD_EDGE: - aFirstColIds = FirstEdgeIds; - aLastColIds = LastEdgeIds; - break; - case QUAD_TRIANGLE: - aFirstColIds = FirstTriangleIds; - aLastColIds = LastTriangleIds; - break; - case QUAD_QUADRANGLE: - aFirstColIds = FirstQuadrangleIds; - aLastColIds = LastQuadrangleIds; - break; - case QUAD_TETRAHEDRON: - aFirstColIds = FirstTetrahedronIds; - aLastColIds = LastTetrahedronIds; - break; - case QUAD_PYRAMID: - aFirstColIds = FirstPyramidIds; - aLastColIds = LastPyramidIds; - break; - case QUAD_PENTAHEDRON: - aFirstColIds = FirstPentahedronIds; - aLastColIds = LastPentahedronIds; - break; - case QUAD_HEXAHEDRON: - aFirstColIds = FirstHexahedronIds; - aLastColIds = LastHexahedronIds; - break; - } - - // fill the First and the Last columns - for (int i = 0, iEnd = myTable->numRows(); i < iEnd; i++) - myTable->setText( i, 0, aListCorners[ aFirstColIds[i] ] ); - - for (int i = 0, iEnd = myTable->numRows(); i < iEnd; i++) - myTable->setText( i, 2, aListCorners[ aLastColIds[i] ] ); + { + myTable->setEnabled( true ); + + // clear the Middle column + for ( int row = 0; row < myTable->rowCount(); row++ ) + myTable->item( row, 1 )->setText(""); + + int* aFirstColIds; + int* aLastColIds; + + switch (myType) { + case QUAD_EDGE: + aFirstColIds = FirstEdgeIds; + aLastColIds = LastEdgeIds; + break; + case QUAD_TRIANGLE: + aFirstColIds = FirstTriangleIds; + aLastColIds = LastTriangleIds; + break; + case QUAD_QUADRANGLE: + aFirstColIds = FirstQuadrangleIds; + aLastColIds = LastQuadrangleIds; + break; + case QUAD_TETRAHEDRON: + aFirstColIds = FirstTetrahedronIds; + aLastColIds = LastTetrahedronIds; + break; + case QUAD_PYRAMID: + aFirstColIds = FirstPyramidIds; + aLastColIds = LastPyramidIds; + break; + case QUAD_PENTAHEDRON: + aFirstColIds = FirstPentahedronIds; + aLastColIds = LastPentahedronIds; + break; + case QUAD_HEXAHEDRON: + aFirstColIds = FirstHexahedronIds; + aLastColIds = LastHexahedronIds; + break; } + + // fill the First and the Last columns + for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++) + myTable->item( i, 0 )->setText( aListCorners[ aFirstColIds[i] ] ); + + for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++) + myTable->item( i, 2 )->setText( aListCorners[ aLastColIds[i] ] ); + } else - { - // clear table - for ( int row = 0; row < myTable->numRows(); row++ ) - for ( int col = 0; col < myTable->numCols(); col++ ) - myTable->setText(row, col, ""); - - myTable->setEnabled( false ); - } + { + // clear table + for ( int row = 0; row < myTable->rowCount(); row++ ) + for ( int col = 0; col < myTable->columnCount(); col++ ) + if ( QTableWidgetItem* aTWI = myTable->item(row, col) ) aTWI->setText(""); + + myTable->setEnabled( false ); + } } @@ -1081,13 +1250,11 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) // function : onTableActivate() // purpose : //================================================================================= -void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol, int theButton, const QPoint& theMousePos ) +void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol ) { - if ( theButton == 1 && theCol == 1 ) - myIsEditCorners = false; - + myIsEditCorners = false; displaySimulation(); - return; + updateButtons(); } @@ -1097,15 +1264,9 @@ void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCo //================================================================================= void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol) { - onTextChange( myTable->text(theRow, theCol) ); -} - - -QWidget* SMESHGUI_IdEditItem::createEditor() const -{ - QLineEdit *aLineEdit = new QLineEdit(text(), table()->viewport()); - aLineEdit->setValidator( new SMESHGUI_IdValidator(table()->viewport(), "validator", 1) ); - return aLineEdit; + myIsEditCorners = false; + displaySimulation(); + updateButtons(); } //================================================================================= @@ -1118,9 +1279,28 @@ void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e ) if ( e->isAccepted() ) return; - if ( e->key() == Key_F1 ) - { - e->accept(); - ClickOnHelp(); - } + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); + } +} + +void SMESHGUI_AddQuadraticElementDlg::updateButtons() +{ + bool valid = IsValid(); + buttonOk->setEnabled( valid ); + buttonApply->setEnabled( valid ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_AddQuadraticElementDlg::isValid() +{ + if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) { + SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) ); + return false; + } + return true; }