X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SingleEditDlg.cxx;h=43e14a20394467faa8efb3bc334ad6abfef807f1;hp=201b1c126cffb91d3e43be3480ae5305a4fcbbc7;hb=d303154d91eb916a55ac93a372cbdb918aa18d14;hpb=2672e3aa3d7076a083a9a604a73fa27e3ea28617 diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx index 201b1c126..43e14a203 100755 --- a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx @@ -1,72 +1,65 @@ -// SMESH SMESHGUI : GUI for SMESH component +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// 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 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. // -// 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 +// 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_SingleEditDlg.cxx +// Author : Sergey LITONIN, Open CASCADE S.A.S. // -// -// File : SMESHGUI_SingleEditDlg.cxx -// Author : Sergey LITONIN -// Module : SMESH +// SMESH includes #include "SMESHGUI_SingleEditDlg.h" #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_SpinBox.h" -#include "SMESH_Actor.h" -#include "SMDS_Mesh.hxx" +#include +#include -#include "LightApp_SelectionMgr.h" -#include "LightApp_Application.h" -#include "SUIT_ResourceMgr.h" -#include "SUIT_MessageBox.h" -#include "SUIT_Desktop.h" -#include "SUIT_Session.h" +// SALOME GUI includes +#include +#include +#include +#include +#include +#include -#include "SVTK_Selector.h" -#include "SVTK_ViewWindow.h" -#include "SALOME_ListIO.hxx" +#include +#include +#include -#include "utilities.h" - -// OCCT Includes +// OCCT includes #include #include -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include - - -#define SPACING 5 -#define MARGIN 10 +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#define SPACING 6 +#define MARGIN 11 /*! * Class : SMESHGUI_DiagValidator @@ -74,19 +67,19 @@ */ class SMESHGUI_DiagValidator: public QValidator { - public: - SMESHGUI_DiagValidator (QWidget * parent, const char * name = 0): - QValidator(parent,name) {} +public: + SMESHGUI_DiagValidator (QWidget* parent): + QValidator(parent) {} - State validate (QString & text, int & pos) const + State validate (QString& text, int& pos) const { - text.stripWhiteSpace(); + text = text.trimmed(); text.replace(QRegExp("[^0-9]+"), "-"); if (text == "-") text = ""; - int ind = text.find(QRegExp("-[0-9]+-")); + int ind = text.indexOf(QRegExp("-[0-9]+-")); if (ind > 0) { // leave only two ids - ind = text.find('-', ind + 1); + ind = text.indexOf('-', ind + 1); if (ind > 0) text.truncate(ind); } @@ -107,26 +100,24 @@ class SMESHGUI_DiagValidator: public QValidator // Purpose : Constructor //======================================================================= SMESHGUI_SingleEditDlg -::SMESHGUI_SingleEditDlg(SMESHGUI* theModule, - const char* theName): - QDialog(SMESH::GetDesktop(theModule), - theName, - false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), +::SMESHGUI_SingleEditDlg(SMESHGUI* theModule) + : QDialog(SMESH::GetDesktop(theModule)), mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), mySMESHGUI(theModule) { - QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING); + setModal(false); + + QVBoxLayout* aDlgLay = new QVBoxLayout(this); + aDlgLay->setMargin(MARGIN); + aDlgLay->setSpacing(SPACING); - QFrame* aMainFrame = createMainFrame (this); - QFrame* aBtnFrame = createButtonFrame(this); + QWidget* aMainFrame = createMainFrame (this); + QWidget* aBtnFrame = createButtonFrame(this); aDlgLay->addWidget(aMainFrame); aDlgLay->addWidget(aBtnFrame); - aDlgLay->setStretchFactor(aMainFrame, 1); - Init(); } @@ -134,16 +125,24 @@ SMESHGUI_SingleEditDlg // name : createMainFrame() // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_SingleEditDlg::createMainFrame (QWidget* theParent) +QWidget* SMESHGUI_SingleEditDlg::createMainFrame (QWidget* theParent) { - QGroupBox* aMainGrp = new QGroupBox(1, Qt::Vertical, tr("EDGE_BETWEEN"), theParent); + QGroupBox* aMainGrp = new QGroupBox(tr("EDGE_BETWEEN"), theParent); + QHBoxLayout* aLay = new QHBoxLayout(aMainGrp); + aLay->setMargin(MARGIN); + aLay->setSpacing(SPACING); QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); - new QLabel(tr("SMESH_EDGE"), aMainGrp); - (new QPushButton(aMainGrp))->setPixmap(aPix); + QLabel* aLab = new QLabel(tr("SMESH_EDGE"), aMainGrp); + QPushButton* aBtn = new QPushButton(aMainGrp); + aBtn->setIcon(aPix); myEdge = new QLineEdit(aMainGrp); - myEdge->setValidator(new SMESHGUI_DiagValidator(this, "validator")); + myEdge->setValidator(new SMESHGUI_DiagValidator(this)); + + aLay->addWidget(aLab); + aLay->addWidget(aBtn); + aLay->addWidget(myEdge); return aMainGrp; } @@ -152,23 +151,24 @@ QFrame* SMESHGUI_SingleEditDlg::createMainFrame (QWidget* theParent) // name : createButtonFrame() // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_SingleEditDlg::createButtonFrame (QWidget* theParent) +QWidget* SMESHGUI_SingleEditDlg::createButtonFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame(theParent); - aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); + QGroupBox* aFrame = new QGroupBox(theParent); myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - myHelpBtn = new QPushButton (tr("SMESH_BUT_HELP"), aFrame); - - QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame); - QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + QHBoxLayout* aLay = new QHBoxLayout(aFrame); + aLay->setMargin(MARGIN); + aLay->setSpacing(SPACING); aLay->addWidget(myOkBtn); + aLay->addSpacing(10); aLay->addWidget(myApplyBtn); - aLay->addItem(aSpacer); + aLay->addSpacing(10); + aLay->addStretch(); aLay->addWidget(myCloseBtn); aLay->addWidget(myHelpBtn); @@ -238,8 +238,6 @@ void SMESHGUI_SingleEditDlg::Init() myApplyBtn->setEnabled(false); setEnabled(true); - this->show(); - // set selection mode if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(EdgeOfCellSelection); @@ -283,16 +281,17 @@ void SMESHGUI_SingleEditDlg::onHelp() 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)); } } @@ -358,7 +357,7 @@ void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText) mySelector->GetIndex(anIO,selectedIndices); myBusy = false; - QStringList aListId = QStringList::split("-", theNewText, false); + QStringList aListId = theNewText.split("-", QString::SkipEmptyParts); if (aListId.count() != 2) return; @@ -515,10 +514,9 @@ bool SMESHGUI_SingleEditDlg::onApply() SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First()); if (aMesh->_is_nil()) { - SUIT_MessageBox::info1(SMESH::GetDesktop(mySMESHGUI), - tr("SMESH_ERROR"), - tr("SMESHG_NO_MESH"), - tr("SMESH_BUT_OK")); + SUIT_MessageBox::information(SMESH::GetDesktop(mySMESHGUI), + tr("SMESH_ERROR"), + tr("SMESHG_NO_MESH")); return false; } @@ -551,11 +549,10 @@ void SMESHGUI_SingleEditDlg::keyPressEvent( QKeyEvent* e ) if ( e->isAccepted() ) return; - if ( e->key() == Key_F1 ) - { - e->accept(); - onHelp(); - } + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + onHelp(); + } } /*! @@ -565,11 +562,10 @@ void SMESHGUI_SingleEditDlg::keyPressEvent( QKeyEvent* e ) */ SMESHGUI_TrianglesInversionDlg -::SMESHGUI_TrianglesInversionDlg(SMESHGUI* theModule, - const char* theName) -: SMESHGUI_SingleEditDlg(theModule,theName) +::SMESHGUI_TrianglesInversionDlg(SMESHGUI* theModule) +: SMESHGUI_SingleEditDlg(theModule) { - setCaption(tr("CAPTION")); + setWindowTitle(tr("CAPTION")); myHelpFileName = "diagonal_inversion_of_elements_page.html"; } @@ -590,11 +586,10 @@ bool SMESHGUI_TrianglesInversionDlg::process (SMESH::SMESH_MeshEditor_ptr theMes */ SMESHGUI_UnionOfTwoTrianglesDlg -::SMESHGUI_UnionOfTwoTrianglesDlg(SMESHGUI* theModule, - const char* theName) -: SMESHGUI_SingleEditDlg(theModule,theName) +::SMESHGUI_UnionOfTwoTrianglesDlg(SMESHGUI* theModule) +: SMESHGUI_SingleEditDlg(theModule) { - setCaption(tr("CAPTION")); + setWindowTitle(tr("CAPTION")); myHelpFileName = "uniting_two_triangles_page.html"; }