X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MakeNodeAtPointDlg.cxx;h=d9ed467f174fb78f704893c8fce2cfabef1acd2c;hp=c31fc078a4d89f6ef1c9659a030d9292e448c6ff;hb=333415e6c9f744a167d1779d9e74e073f122e88c;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813 diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx index c31fc078a..d9ed467f1 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.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,76 +17,70 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : SMESHGUI_MakeNodeAtPointDlg.cxx +// Author : Edward AGAPOV, Open CASCADE S.A.S. +// SMESH includes // -// -// File : SMESHGUI_MakeNodeAtPointDlg.cxx -// Author : Edward AGAPOV -// Module : SMESH - #include "SMESHGUI_MakeNodeAtPointDlg.h" #include "SMESHGUI.h" -#include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_IdValidator.h" #include "SMESHGUI_MeshUtils.h" -#include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_MeshEditPreview.h" -#include "SMDS_Mesh.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMESH_Actor.h" -#include "SMESH_ActorUtils.h" -#include "SMESH_NumberFilter.hxx" -#include "SMESH_LogicalFilter.hxx" - -#include "GEOMBase.h" -#include "GeometryGUI.h" - -#include "LightApp_DataOwner.h" -#include "LightApp_SelectionMgr.h" -#include "SALOMEDSClient_SObject.hxx" -#include "SALOME_ListIO.hxx" -#include "SUIT_Desktop.h" -#include "SVTK_Selector.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_ViewModel.h" -#include "SalomeApp_Tools.h" -#include "SalomeApp_TypeFilter.h" -#include "SUIT_ResourceMgr.h" -#include "SUIT_OverrideCursor.h" -#include "SUIT_MessageBox.h" - -// OCCT Includes +#include +#include +#include +#include +#include + +// SALOME GEOM includes +#include + +// SALOME GUI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// OCCT includes #include #include #include - -// QT 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 + +// VTK includes #include -// IDL Headers +// IDL includes #include #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_MeshEditor) -#define SPACING 5 -#define MARGIN 10 +#define SPACING 6 +#define MARGIN 11 /*! * \brief Dialog to publish a sub-shape of the mesh main shape @@ -95,11 +89,13 @@ SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg() : SMESHGUI_Dialog( 0, false, true ) { - setCaption(tr("CAPTION")); + setWindowTitle(tr("CAPTION")); - QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame(), MARGIN, SPACING); + QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame()); + aDlgLay->setMargin(MARGIN);; + aDlgLay->setSpacing(SPACING); - QFrame* aMainFrame = createMainFrame (mainFrame()); + QWidget* aMainFrame = createMainFrame (mainFrame()); aDlgLay->addWidget(aMainFrame); @@ -110,9 +106,9 @@ SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg() // function : createMainFrame() // purpose : Create frame containing dialog's input fields //======================================================================= -QFrame* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent) +QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent) { - QFrame* aFrame = new QFrame(theParent); + QWidget* aFrame = new QWidget(theParent); SUIT_ResourceMgr* rm = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() ); QPixmap iconMoveNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); @@ -120,69 +116,85 @@ QFrame* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent) // constructor - QButtonGroup* aPixGrp = new QButtonGroup(1, Qt::Vertical, tr("MESH_PASS_THROUGH_POINT"), aFrame); - aPixGrp->setExclusive(TRUE); + QGroupBox* aPixGrp = new QGroupBox(tr("MESH_PASS_THROUGH_POINT"), aFrame); + QButtonGroup* aBtnGrp = new QButtonGroup(this); + QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp); + aPixGrpLayout->setMargin(MARGIN); + aPixGrpLayout->setSpacing(SPACING); + QRadioButton* aRBut = new QRadioButton(aPixGrp); - aRBut->setPixmap(iconMoveNode); - aRBut->setChecked(TRUE); + aRBut->setIcon(iconMoveNode); + aRBut->setChecked(true); + aPixGrpLayout->addWidget(aRBut); + aBtnGrp->addButton(aRBut, 0); // coordinates - QGroupBox* aCoordGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_COORDINATES"), aFrame); + QGroupBox* aCoordGrp = new QGroupBox(tr("SMESH_COORDINATES"), aFrame); + QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp); + aCoordGrpLayout->setMargin(MARGIN); + aCoordGrpLayout->setSpacing(SPACING); + myCoordBtn = new QPushButton(aCoordGrp); - myCoordBtn->setPixmap(iconSelect); - myCoordBtn->setToggleButton(TRUE); + myCoordBtn->setIcon(iconSelect); + myCoordBtn->setCheckable(true); QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp); - aXLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); myX = new SMESHGUI_SpinBox(aCoordGrp); QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp); - //aYLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs ); - aYLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); myY = new SMESHGUI_SpinBox(aCoordGrp); QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp); - //aZLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs ); - aZLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); myZ = new SMESHGUI_SpinBox(aCoordGrp); myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY); myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY); myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY); + aCoordGrpLayout->addWidget(myCoordBtn); + aCoordGrpLayout->addWidget(aXLabel); + aCoordGrpLayout->addWidget(myX); + aCoordGrpLayout->addWidget(aYLabel); + aCoordGrpLayout->addWidget(myY); + aCoordGrpLayout->addWidget(aZLabel); + aCoordGrpLayout->addWidget(myZ); + // Method selection - QButtonGroup* aMethodGrp = new QButtonGroup(1, Qt::Vertical, tr("METHOD"), aFrame); - aMethodGrp->setExclusive(TRUE); + QGroupBox* aMethodGrp = new QGroupBox(tr("METHOD"), aFrame); + QHBoxLayout* aMethodGrpLayout = new QHBoxLayout(aMethodGrp); + aMethodGrpLayout->setMargin(MARGIN); + aMethodGrpLayout->setSpacing(SPACING); + myMoveRBtn = new QRadioButton(tr("MOVE_EXISTING_METHOD"), aMethodGrp); myCreateRBtn = new QRadioButton(tr("CREATE_NEW_METHOD"), aMethodGrp); + aMethodGrpLayout->addWidget(myMoveRBtn); + aMethodGrpLayout->addWidget(myCreateRBtn); + // node ID - myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame, "anIdGrp"); + myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame); - QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp, "idLabel"); + QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp); myIdBtn = new QPushButton(myNodeToMoveGrp); - myIdBtn->setPixmap(iconSelect); - myIdBtn->setToggleButton(TRUE); - myId = new QLineEdit(myNodeToMoveGrp,"myId"); - myId->setValidator(new SMESHGUI_IdValidator(this, "validator", 1)); - myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp, "myAutoSearchChkBox"); - myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp, "myPreviewChkBox"); - - myNodeToMoveGrp->setColumnLayout(0, Qt::Vertical); - myNodeToMoveGrp->layout()->setSpacing(0); - myNodeToMoveGrp->layout()->setMargin(0); - QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp->layout()); - myNodeToMoveGrpLayout->setAlignment(Qt::AlignTop); + myIdBtn->setIcon(iconSelect); + myIdBtn->setCheckable(true); + myId = new QLineEdit(myNodeToMoveGrp); + myId->setValidator(new SMESHGUI_IdValidator(this, 1)); + myAutoSearchChkBox = new QCheckBox( tr("AUTO_SEARCH"), myNodeToMoveGrp); + myPreviewChkBox = new QCheckBox( tr("PREVIEW"), myNodeToMoveGrp); + + QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp); myNodeToMoveGrpLayout->setSpacing(SPACING); myNodeToMoveGrpLayout->setMargin(MARGIN); + myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 ); myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 ); myNodeToMoveGrpLayout->addWidget( myId, 0, 2 ); - myNodeToMoveGrpLayout->addMultiCellWidget( myAutoSearchChkBox, 1, 1, 0, 2 ); - myNodeToMoveGrpLayout->addMultiCellWidget( myPreviewChkBox, 2, 2, 0, 2 ); + myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 1, 0, 1, 3 ); + myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 2, 0, 1, 3 ); QVBoxLayout* aLay = new QVBoxLayout(aFrame); aLay->addWidget(aPixGrp); @@ -196,9 +208,9 @@ QFrame* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent) connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); - myMoveRBtn->setChecked(TRUE); - myIdBtn->setOn(TRUE); - myAutoSearchChkBox->setChecked(TRUE); + myMoveRBtn->setChecked(true); + myIdBtn->setChecked(true); + myAutoSearchChkBox->setChecked(true); return aFrame; } @@ -217,34 +229,34 @@ void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on) if ( aSender == myCoordBtn ) // button to set coord by node selection { if ( myIdBtn->isEnabled() ) - myIdBtn->setOn( !on ); + myIdBtn->setChecked( !on ); } else if ( aSender == myIdBtn ) // button to select a node to move { - myCoordBtn->setOn( !on ); + myCoordBtn->setChecked( !on ); } else if ( aSender == myMoveRBtn ) // move node method { - myNodeToMoveGrp->setEnabled( TRUE ); + myNodeToMoveGrp->setEnabled( true ); } else if ( aSender == myCreateRBtn ) // create node method { - myNodeToMoveGrp->setEnabled( FALSE ); - myCoordBtn->setOn( TRUE ); + myNodeToMoveGrp->setEnabled( false ); + myCoordBtn->setChecked( true ); } } if ( aSender == myAutoSearchChkBox ) // automatic node search { if ( on ) { myId->setText(""); - myId->setReadOnly ( TRUE ); - myIdBtn->setOn( FALSE ); - myIdBtn->setEnabled( FALSE ); - myCoordBtn->setOn( TRUE ); + myId->setReadOnly ( true ); + myIdBtn->setChecked( false ); + myIdBtn->setEnabled( false ); + myCoordBtn->setChecked( true ); } else { - myId->setReadOnly ( FALSE ); - myIdBtn->setEnabled( TRUE ); + myId->setReadOnly ( false ); + myIdBtn->setEnabled( true ); } } } @@ -256,6 +268,7 @@ void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on) //================================================================================ SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp() + : SMESHGUI_Helper( getSMESHGUI() ) { mySimulation = 0; myDlg = new SMESHGUI_MakeNodeAtPointDlg; @@ -293,18 +306,18 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() mySimulation->GetActor()->SetProperty(aProp); aProp->Delete(); - SMESHGUI_SelectionOp::startOperation(); - // SalomeApp_TypeFilter depends on a current study if ( myFilter ) delete myFilter; - QPtrList filters; + QList filters; filters.append( new SalomeApp_TypeFilter((SalomeApp_Study*)study(), "SMESH" )); TColStd_MapOfInteger vertexType; vertexType.Add( TopAbs_VERTEX ); filters.append( new SMESH_NumberFilter("GEOM", TopAbs_VERTEX, 1, vertexType )); myFilter = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR ); - - activateSelection(); // set filters + + // IPAL19360 + SMESHGUI_SelectionOp::startOperation(); // this method should be called only after filter creation + //activateSelection(); // set filters // called inside of previous statement myDlg->myX->SetValue(0); myDlg->myY->SetValue(0); @@ -355,15 +368,16 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() return false; if ( !myMeshActor ) { - SUIT_MessageBox::warn1( dlg(), tr( "SMESH_WRN_WARNING" ), - tr("INVALID_MESH"), tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), + tr("INVALID_MESH") ); dlg()->show(); return false; } - if ( !isValid() ) { // node id is invalid - SUIT_MessageBox::warn1( dlg(), tr( "SMESH_WRN_WARNING" ), - tr("INVALID_ID"), tr( "SMESH_BUT_OK" ) ); + QString msg; + if ( !isValid( msg ) ) { // node id is invalid + if( !msg.isEmpty() ) + SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), msg ); dlg()->show(); return false; } @@ -372,8 +386,8 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() try { 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(SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("SMESHG_NO_MESH") ); return true; } SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); @@ -381,7 +395,7 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() return true; int aResult = 0; - if ( myDlg->myCreateRBtn->isOn() ) + if ( myDlg->myCreateRBtn->isChecked() ) { aResult = aMeshEditor->AddNode(myDlg->myX->GetValue(), myDlg->myY->GetValue(), @@ -397,6 +411,8 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() } if (aResult) { + getNotebook()->setParameters( aMesh, 3, myDlg->myX, myDlg->myY, myDlg->myZ ); + myDlg->myId->setText(""); SALOME_ListIO aList; @@ -421,12 +437,14 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() */ //================================================================================ -bool SMESHGUI_MakeNodeAtPointOp::isValid() +bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg ) { - bool ok = true; + if( !checkParameters( !myNoPreview, 3, myDlg->myX, myDlg->myY, myDlg->myZ ) ) + return false; + bool ok = true; if ( myMeshActor && - myDlg->myMoveRBtn->isOn() && + myDlg->myMoveRBtn->isChecked() && !myDlg->myAutoSearchChkBox->isChecked() ) { ok = false; @@ -434,6 +452,8 @@ bool SMESHGUI_MakeNodeAtPointOp::isValid() if ( id > 0 ) if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) ok = aMesh->FindNode( id ); + if( !ok ) + msg += tr("INVALID_ID") + "\n"; } return ok; } @@ -446,7 +466,7 @@ bool SMESHGUI_MakeNodeAtPointOp::isValid() void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() { - if ( !myDlg->isShown() || !myDlg->isEnabled() ) + if ( !myDlg->isVisible() || !myDlg->isEnabled() ) return; try { SALOME_ListIO aList; @@ -457,7 +477,7 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry()); if (!aMeshActor) { // coord by geom - if ( myDlg->myCoordBtn->isOn() ) { + if ( myDlg->myCoordBtn->isChecked() ) { GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface(anIO); if ( !geom->_is_nil() ) { TopoDS_Vertex aShape; @@ -485,14 +505,14 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) { if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) { myNoPreview = true; - if ( myDlg->myCoordBtn->isOn() ) { // set coord + if ( myDlg->myCoordBtn->isChecked() ) { // set coord myDlg->myX->SetValue(aNode->X()); myDlg->myY->SetValue(aNode->Y()); myDlg->myZ->SetValue(aNode->Z()); myNoPreview = false; redisplayPreview(); } - else if ( myDlg->myIdBtn->isOn() && + else if ( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) { // set node to move myDlg->myId->setText(aString); myNoPreview = false; @@ -520,14 +540,15 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() SMESH::MeshPreviewStruct_var aMeshPreviewStruct; bool moveShown = false; - if ( myDlg->myMoveRBtn->isOn() && // Move method + if ( myDlg->myMoveRBtn->isChecked() && // Move method myMeshActor) { const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked(); const bool preview = myDlg->myPreviewChkBox->isChecked(); if ( autoSearch ) myDlg->myId->setText(""); - if ( preview && ( autoSearch || isValid() )) + QString msg; + if ( preview && ( autoSearch || isValid( msg ) )) { try { SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO());