X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MoveNodesDlg.cxx;h=6243255afc44a7b7a51c87d35e5b30785cae6869;hp=fba4f187f6718e2bb6dc3948a18232e7b27192d8;hb=f31477795020e2cfc50d5b625579285c644a6a96;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx index fba4f187f..6243255af 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -1,6 +1,6 @@ -// 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, +// 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 @@ -17,15 +17,13 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_MoveNodesDlg.cxx +// Author : Nicolas REJNERI, Open CASCADE S.A.S. +// SMESH includes // -// -// File : SMESHGUI_MoveNodesDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - #include "SMESHGUI_MoveNodesDlg.h" #include "SMESHGUI.h" @@ -35,83 +33,81 @@ #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_MeshUtils.h" -#include "SMESH_Actor.h" -#include "SMDS_Mesh.hxx" -#include "SMDS_MeshNode.hxx" - -#include "SalomeApp_SelectionMgr.h" -#include "SUIT_ResourceMgr.h" -#include "SUIT_Desktop.h" +#include +#include -#include "SVTK_Selector.h" -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" -#include "SALOME_ListIO.hxx" +// SALOME GUI includes +#include +#include +#include +#include +#include +#include -#include "SVTK_ViewWindow.h" +#include +#include +#include -#include "utilities.h" +#include // OCCT includes #include // VTK includes -#include #include -#include #include #include #include #include - -// QT includes -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// IDL Headers +#include + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// IDL includes #include #include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_MeshEditor) -#define MARGIN 10 -#define SPACING 5 - +#define SPACING 6 +#define MARGIN 11 //================================================================================= // name : SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg // Purpose : //================================================================================= -SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg (SMESHGUI* theModule, - const char* theName): - QDialog(SMESH::GetDesktop(theModule), - theName, - false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), +SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg(SMESHGUI* theModule): + QDialog(SMESH::GetDesktop(theModule)), mySelectionMgr(SMESH::GetSelectionMgr(theModule)), - myViewWindow(SMESH::GetViewWindow(theModule)), mySMESHGUI(theModule) { myPreviewActor = 0; myBusy = false; - setCaption(tr("CAPTION")); + setModal(false); + setWindowTitle(tr("CAPTION")); - QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); + QVBoxLayout* aDlgLay = new QVBoxLayout(this); + aDlgLay->setSpacing(SPACING); + aDlgLay->setMargin(MARGIN); - 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); + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + + myHelpFileName = "moving_nodes_page.html"; Init(); } @@ -120,27 +116,32 @@ SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg (SMESHGUI* theModule, // name : SMESHGUI_MoveNodesDlg::createButtonFrame // Purpose : Create frame containing buttons //======================================================================= -QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent) +QWidget* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent) { QFrame* aFrame = new QFrame(theParent); aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), 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); - - QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + QHBoxLayout* aLay = new QHBoxLayout(aFrame); + aLay->setSpacing(SPACING); + aLay->setMargin(MARGIN); aLay->addWidget(myOkBtn); + aLay->addSpacing(10); aLay->addWidget(myApplyBtn); - aLay->addItem(aSpacer); + aLay->addSpacing(10); + aLay->addStretch(); aLay->addWidget(myCloseBtn); + aLay->addWidget(myHelpBtn); connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); + connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp())); return aFrame; } @@ -149,42 +150,79 @@ QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent) // name : SMESHGUI_MoveNodesDlg::createMainFrame // Purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent) +QWidget* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame(theParent); + QWidget* aFrame = new QWidget(theParent); - QPixmap iconMoveNode (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); - QPixmap iconSelect (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap iconMoveNode (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); + QPixmap iconSelect (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); + + //------------------------------------------------------------ + QGroupBox* aPixGrp = new QGroupBox(tr("MESH_NODE"), aFrame); + QButtonGroup* aBtnGrp = new QButtonGroup(this); + QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp); + aPixGrpLayout->setSpacing(SPACING); + aPixGrpLayout->setMargin(MARGIN); - QButtonGroup* aPixGrp = new QButtonGroup(1, Qt::Vertical, tr("MESH_NODE"), aFrame); - aPixGrp->setExclusive(TRUE); QRadioButton* aRBut = new QRadioButton(aPixGrp); - aRBut->setPixmap(iconMoveNode); - aRBut->setChecked(TRUE); + aRBut->setIcon(iconMoveNode); + aRBut->setChecked(true); + + aPixGrpLayout->addWidget(aRBut); + aBtnGrp->addButton(aRBut, 0); - QGroupBox* anIdGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MOVE"), aFrame); - new QLabel(tr("NODE_ID"), anIdGrp); - (new QPushButton(anIdGrp))->setPixmap(iconSelect); + //------------------------------------------------------------ + QGroupBox* anIdGrp = new QGroupBox(tr("SMESH_MOVE"), aFrame); + QHBoxLayout* anIdGrpLayout = new QHBoxLayout(anIdGrp); + anIdGrpLayout->setSpacing(SPACING); + anIdGrpLayout->setMargin(MARGIN); + + QLabel* idLabl = new QLabel(tr("NODE_ID"), anIdGrp); + QPushButton* idBtn = new QPushButton(anIdGrp); + idBtn->setIcon(iconSelect); myId = new QLineEdit(anIdGrp); - myId->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); + myId->setValidator(new SMESHGUI_IdValidator(this, 1)); + + anIdGrpLayout->addWidget(idLabl); + anIdGrpLayout->addWidget(idBtn); + anIdGrpLayout->addWidget(myId); + + //------------------------------------------------------------ + QGroupBox* aCoordGrp = new QGroupBox(tr("SMESH_COORDINATES"), aFrame); + QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp); + aCoordGrpLayout->setSpacing(SPACING); + aCoordGrpLayout->setMargin(MARGIN); - QGroupBox* aCoordGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_COORDINATES"), aFrame); - new QLabel(tr("SMESH_X"), aCoordGrp); + QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp); myX = new SMESHGUI_SpinBox(aCoordGrp); - new QLabel(tr("SMESH_Y"), aCoordGrp); + + QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp); myY = new SMESHGUI_SpinBox(aCoordGrp); - new QLabel(tr("SMESH_Z"), aCoordGrp); + + QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp); myZ = new SMESHGUI_SpinBox(aCoordGrp); - myX->RangeStepAndValidator(-999999.999, +999999.999, 25.0, 3); - myY->RangeStepAndValidator(-999999.999, +999999.999, 25.0, 3); - myZ->RangeStepAndValidator(-999999.999, +999999.999, 25.0, 3); + aCoordGrpLayout->addWidget(aXLabel); + aCoordGrpLayout->addWidget(myX); + aCoordGrpLayout->addWidget(aYLabel); + aCoordGrpLayout->addWidget(myY); + aCoordGrpLayout->addWidget(aZLabel); + aCoordGrpLayout->addWidget(myZ); + //------------------------------------------------------------ + myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, DBL_DIGITS_DISPLAY); + myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, DBL_DIGITS_DISPLAY); + myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 25.0, DBL_DIGITS_DISPLAY); + + //------------------------------------------------------------ QVBoxLayout* aLay = new QVBoxLayout(aFrame); + aLay->setMargin(0); + aLay->setMargin(SPACING); aLay->addWidget(aPixGrp); aLay->addWidget(anIdGrp); aLay->addWidget(aCoordGrp); + //------------------------------------------------------------ // connect signale and slots connect(myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); connect(myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); @@ -223,14 +261,10 @@ void SMESHGUI_MoveNodesDlg::Init() reset(); setEnabled(true); - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); - // set selection mode SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); onSelectionDone(); } @@ -239,14 +273,30 @@ void SMESHGUI_MoveNodesDlg::Init() // name : SMESHGUI_MoveNodesDlg::isValid // Purpose : Verify validity of entry information //======================================================================= -bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) const +bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) { if (myId->text().isEmpty()) { if (theMess) - QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"), - tr("NODE_ID_IS_NOT_DEFINED"), QMessageBox::Ok); + SUIT_MessageBox::information(this, tr("SMESH_WARNING"), + tr("NODE_ID_IS_NOT_DEFINED")); return false; } + + QString msg; + bool ok = true; + ok = myX->isValid( msg, theMess ) && ok; + ok = myY->isValid( msg, theMess ) && ok; + ok = myZ->isValid( msg, theMess ) && ok; + if( !ok ) { + if( theMess ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + } + return false; + } + return true; } @@ -270,7 +320,7 @@ void SMESHGUI_MoveNodesDlg::reset() //======================================================================= bool SMESHGUI_MoveNodesDlg::onApply() { - if (SMESHGUI::GetSMESHGUI()->isActiveStudyLocked()) + if (mySMESHGUI->isActiveStudyLocked()) return false; if (!isValid(true)) @@ -278,8 +328,8 @@ bool SMESHGUI_MoveNodesDlg::onApply() SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); if (aMesh->_is_nil()) { - QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), - tr("SMESHG_NO_MESH"), QMessageBox::Ok); + SUIT_MessageBox::information(this, tr("SMESH_ERROR"), + tr("SMESHG_NO_MESH")); return false; } @@ -291,6 +341,12 @@ bool SMESHGUI_MoveNodesDlg::onApply() bool aResult = false; try { aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue()); + + QStringList aParameters; + aParameters << myX->text(); + aParameters << myY->text(); + aParameters << myZ->text(); + aMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); } catch (...) { } @@ -321,15 +377,41 @@ void SMESHGUI_MoveNodesDlg::onOk() //======================================================================= void SMESHGUI_MoveNodesDlg::onClose() { - mySelectionMgr->clearSelected(); + //mySelectionMgr->clearSelected(); SMESH::SetPointRepresentation(false); - mySelector->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr, 0, this, 0); disconnect(mySMESHGUI, 0, this, 0); + erasePreview(); mySMESHGUI->ResetState(); reject(); } +//================================================================================= +// function : onHelp() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::onHelp() +{ + 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)); + } +} + //======================================================================= // name : SMESHGUI_MoveNodesDlg::onTextChange // Purpose : @@ -353,10 +435,13 @@ void SMESHGUI_MoveNodesDlg::onTextChange (const QString& theNewText) myBusy = false; if(const SMDS_MeshElement *anElem = aMesh->FindElement(theNewText.toInt())) { - TColStd_MapOfInteger aListInd; - aListInd.Add(anElem->GetID()); - mySelector->AddOrRemoveIndex(anIO,aListInd, true); - myViewWindow->highlight(anIO,true,true); + TColStd_MapOfInteger aListInd; + aListInd.Add(anElem->GetID()); + mySelector->AddOrRemoveIndex(anIO,aListInd, false); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight(anIO,true,true); + + onSelectionDone(); } } } @@ -417,11 +502,12 @@ void SMESHGUI_MoveNodesDlg::onDeactivate() void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*) { if (!isEnabled()) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + mySMESHGUI->EmitSignalDeactivateDialog(); // set selection mode SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(NodeSelection); redisplayPreview(); @@ -436,7 +522,8 @@ void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*) void SMESHGUI_MoveNodesDlg::closeEvent (QCloseEvent*) { onClose(); - myViewWindow->Repaint(); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->Repaint(); } //======================================================================= @@ -469,10 +556,13 @@ void SMESHGUI_MoveNodesDlg::erasePreview() if (myPreviewActor == 0) return; - myViewWindow->RemoveActor(myPreviewActor); + SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ); + if (aViewWindow) + aViewWindow->RemoveActor(myPreviewActor); myPreviewActor->Delete(); myPreviewActor = 0; - myViewWindow->Repaint(); + if (aViewWindow) + aViewWindow->Repaint(); } //======================================================================= @@ -513,7 +603,7 @@ void SMESHGUI_MoveNodesDlg::redisplayPreview() aCellTypesArray->InsertNextValue(VTK_VERTEX); anIdList->Delete(); - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents(1); aCellLocationsArray->SetNumberOfTuples(1); @@ -546,6 +636,25 @@ void SMESHGUI_MoveNodesDlg::redisplayPreview() myPreviewActor->SetProperty(aProp); aProp->Delete(); - myViewWindow->AddActor(myPreviewActor); - myViewWindow->Repaint(); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + { + aViewWindow->AddActor(myPreviewActor); + aViewWindow->Repaint(); + } +} + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + onHelp(); + } }