X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_AddQuadraticElementDlg.cxx;h=52458d5354b9ca86ef7f534bae12593d9d7c772c;hb=14f66eecc8123b6f1ace08ba40b1e7059cc9f7af;hp=7d692cfbcb5456a3808f035ec2c300ae269ccafe;hpb=4ff5bd61540272713e48de1eee75625028c32155;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx index 7d692cfbc..52458d535 100644 --- a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx @@ -1,3 +1,29 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2005 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 +// +// File : SMESHGUI_AddMeshElementDlg.cxx +// Author : Nicolas REJNERI, Open CASCADE S.A.S. +// + +// SMESH includes #include "SMESHGUI_AddQuadraticElementDlg.h" #include "SMESHGUI.h" @@ -5,65 +31,64 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_IdValidator.h" -#include "SMESH_ActorUtils.h" -#include "SMDS_Mesh.hxx" -#include "SMESH_Actor.h" +#include +#include +#include -#include "SUIT_Session.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 -// OCCT Includes +// IDL includes +#include +#include CORBA_SERVER_HEADER(SMESH_MeshEditor) + +// OCCT includes #include -#include -// VTK Includes -#include +// VTK includes #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 // STL includes -#include +#include -using namespace std; +#define SPACING 6 +#define MARGIN 11 -namespace SMESH { - - 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 @@ -90,13 +115,28 @@ namespace SMESH { conn = aConn; break; } + case QUAD_EDGE: { + static int aConn[] = {1,0,2}; + conn = aConn; + break; + } + case QUAD_TRIANGLE: { + static int aConn[] = {0,2,1,5,4,3}; + conn = aConn; + break; + } + case QUAD_QUADRANGLE: { + static int aConn[] = {0,3,2,1,7,6,5,4}; + conn = aConn; + break; + } default:; } if ( !conn ) { 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; @@ -113,7 +153,7 @@ namespace SMESH { vtkUnstructuredGrid* myGrid; //vtkProperty* myBackProp, *myProp; - float anRGB[3], aBackRGB[3]; + vtkFloatingPointType myRGB[3], myBackRGB[3]; public: TElementSimulation (SalomeApp_Application* theApplication) @@ -136,14 +176,14 @@ namespace SMESH { myPreviewActor->SetMapper(myMapper); vtkProperty* myProp = vtkProperty::New(); - GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); - myProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + GetColor( "SMESH", "fill_color", myRGB[0], myRGB[1], myRGB[2], QColor( 0, 170, 255 ) ); + myProp->SetColor( myRGB[0], myRGB[1], myRGB[2] ); myPreviewActor->SetProperty( myProp ); myProp->Delete(); vtkProperty* myBackProp = vtkProperty::New(); - GetColor( "SMESH", "backface_color", aBackRGB[0], aBackRGB[1], aBackRGB[2], QColor( 0, 0, 255 ) ); - myBackProp->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] ); + GetColor( "SMESH", "backface_color", myBackRGB[0], myBackRGB[1], myBackRGB[2], QColor( 0, 0, 255 ) ); + myBackProp->SetColor( myBackRGB[0], myBackRGB[1], myBackRGB[2] ); myPreviewActor->SetBackfaceProperty( myBackProp ); myBackProp->Delete(); @@ -193,12 +233,12 @@ namespace SMESH { // take care of orientation if ( aType == VTK_CONVEX_POINT_SET ) { if ( theReverse && theMode == VTK_SURFACE ) { - //myPreviewActor->GetProperty()->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] ); + //myPreviewActor->GetProperty()->SetColor( myBackRGB[0], myBackRGB[1], myBackRGB[2] ); } } else { - // VTK cell connectivity opposites the MED one - if ( !theReverse ) { + // VTK cell connectivity opposites the MED one for volumic elements + if ( theIds.size() > 8 ? !theReverse : theReverse ) { ReverseConnectivity( theIds, theType ); } } @@ -223,7 +263,7 @@ namespace SMESH { // restore normal orientation if ( aType == VTK_CONVEX_POINT_SET ) { if ( theReverse && theMode == VTK_SURFACE ) { - //myPreviewActor->GetProperty()->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + //myPreviewActor->GetProperty()->SetColor( myRGB[0], myRGB[1], myRGB[2] ); } } } @@ -279,20 +319,37 @@ static int LastHexahedronIds[] = {1,2,3,0,5,6,7,4,4,5,6,7}; +class SMESHGUI_IdEditItem: public QTableWidgetItem +{ +public: + SMESHGUI_IdEditItem(const QString& text ): + QTableWidgetItem(text, QTableWidgetItem::UserType+100) {}; + ~SMESHGUI_IdEditItem() {}; + + QWidget* createEditor() const; +}; + +QWidget* SMESHGUI_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 ) { + setModal( false ); + setAttribute( Qt::WA_DeleteOnClose, true ); + SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); @@ -328,101 +385,83 @@ 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); - - aDialogLayout->addWidget(GroupButtons, 2, 0); + GroupButtons = new QGroupBox(this); + QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(GroupButtons); + aGroupButtonsLayout->setSpacing(SPACING); + aGroupButtonsLayout->setMargin(MARGIN); + + buttonOk = new QPushButton(tr("SMESH_BUT_OK"), 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(GroupButtons); Init(); /* Initialisations */ } @@ -433,7 +472,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; } @@ -443,8 +481,7 @@ SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg() //================================================================================= void SMESHGUI_AddQuadraticElementDlg::Init() { - GroupArguments->show(); - myRadioButton1->setChecked(TRUE); + myRadioButton1->setChecked(true); myIsEditCorners = true; mySMESHGUI->SetActiveDialogBox((QDialog*)this); @@ -456,77 +493,83 @@ void SMESHGUI_AddQuadraticElementDlg::Init() case QUAD_EDGE: aNumRows = 1; myNbCorners = 2; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_edges break; case QUAD_TRIANGLE: aNumRows = 3; myNbCorners = 3; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_triangles break; case QUAD_QUADRANGLE: aNumRows = 4; myNbCorners = 4; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_quadrangles break; case QUAD_TETRAHEDRON: aNumRows = 6; myNbCorners = 4; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_tetrahedrons break; case QUAD_PYRAMID: aNumRows = 8; myNbCorners = 5; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pyramids break; case QUAD_PENTAHEDRON: aNumRows = 9; myNbCorners = 6; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pentahedrons break; case QUAD_HEXAHEDRON: aNumRows = 12; myNbCorners = 8; + myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_hexahedrons 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++ ) + { + SMESHGUI_IdEditItem* anEditItem = new SMESHGUI_IdEditItem( "" ); + anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + myTable->setItem(row, 1, anEditItem); + } /* 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))); 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(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel())); - this->show(); // displays Dialog - // set selection mode SMESH::SetPointRepresentation(true); @@ -547,13 +590,13 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() if (IsValid() && !mySMESHGUI->isActiveStudyLocked()) { myBusy = true; - vector anIds; + std::vector anIds; 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()); + 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: @@ -562,9 +605,9 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply() 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()); + 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()) @@ -616,7 +659,6 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnOk() { ClickOnApply(); ClickOnCancel(); - return; } //================================================================================= @@ -633,7 +675,30 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnCancel() disconnect(mySelectionMgr, 0, this, 0); mySMESHGUI->ResetState(); reject(); - return; +} + +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void SMESHGUI_AddQuadraticElementDlg::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)); + } } //================================================================================= @@ -658,7 +723,7 @@ 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() ) ) @@ -753,7 +818,7 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument() myBusy = true; int theRow = myTable->currentRow(), theCol = myTable->currentColumn(); if ( theCol == 1 ) - myTable->setText(theRow, 1, aString); + myTable->item(theRow, 1)->setText(aString); myBusy = false; } @@ -782,23 +847,23 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation() 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( 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->text(row, 0).toInt() ) ); + anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(row, 0)->text().toInt() ) ); - for ( int row = 0; row < myTable->numRows(); row++ ) + for ( int row = 0; row < myTable->rowCount(); row++ ) { - anID = (myTable->text(row, 1)).toInt(&ok); + anID = myTable->item(row, 1)->text().toInt(&ok); if (!ok) { - anID = (myTable->text(row, 0)).toInt(); + anID = myTable->item(row, 0)->text().toInt(); aDisplayMode = VTK_WIREFRAME; } anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); @@ -867,7 +932,6 @@ void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*) if (GroupConstructors->isEnabled()) return; ActivateThisDialog(); - return; } //================================================================================= @@ -878,7 +942,6 @@ void SMESHGUI_AddQuadraticElementDlg::closeEvent (QCloseEvent*) { /* same than click on cancel button */ ClickOnCancel(); - return; } //================================================================================= @@ -921,9 +984,9 @@ bool SMESHGUI_AddQuadraticElementDlg::IsValid() bool ok; - for ( int row = 0; row < myTable->numRows(); row++ ) + for ( int row = 0; row < myTable->rowCount(); row++ ) { - int anID = (myTable->text(row, 1)).toInt(&ok); + int anID = myTable->item(row, 1)->text().toInt(&ok); if ( !ok ) return false; @@ -941,15 +1004,15 @@ 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, ""); + for ( int row = 0; row < myTable->rowCount(); row++ ) + myTable->item( row, 1 )->setText(""); int* aFirstColIds; int* aLastColIds; @@ -986,18 +1049,18 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity ) } // 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->rowCount(); i < iEnd; i++) + myTable->item( i, 0 )->setText( aListCorners[ aFirstColIds[i] ] ); - for (int i = 0, iEnd = myTable->numRows(); i < iEnd; i++) - myTable->setText( i, 2, aListCorners[ aLastColIds[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, ""); + 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 ); } @@ -1008,13 +1071,12 @@ 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 ) + if ( theCol == 1 ) myIsEditCorners = false; displaySimulation(); - return; } @@ -1024,13 +1086,21 @@ void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCo //================================================================================= void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol) { - onTextChange( myTable->text(theRow, theCol) ); + onTextChange( myTable->item(theRow, theCol)->text() ); } - -QWidget* SMESHGUI_IdEditItem::createEditor() const +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e ) { - QLineEdit *aLineEdit = new QLineEdit(text(), table()->viewport()); - aLineEdit->setValidator( new SMESHGUI_IdValidator(table()->viewport(), "validator", 1) ); - return aLineEdit; + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); + } }