X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MakeNodeAtPointDlg.cxx;h=f578c1c2f504ded1d79b6efeaab9f82d2c9c0031;hb=7f46c31f2b6e0073d9235615d6fdfc9c017e74c8;hp=ac654fdd6bb4e5cf5d1bc76f65ab8bd91a25a9c3;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx index ac654fdd6..f578c1c2f 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 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 +// 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 -// 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, or (at your option) any later version. // -// 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 +// 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 @@ -46,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +61,7 @@ #include // Qt includes +#include #include #include #include @@ -81,6 +84,11 @@ #define SPACING 6 #define MARGIN 11 +namespace +{ + enum { MANUAL_MODE = 0, SEARCH_MODE }; // how a node to move is specified +} + /*! * \brief Dialog to publish a sub-shape of the mesh main shape * by selecting mesh elements @@ -91,14 +99,13 @@ SMESHGUI_MakeNodeAtPointDlg::SMESHGUI_MakeNodeAtPointDlg() setWindowTitle(tr("CAPTION")); QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame()); - aDlgLay->setMargin(MARGIN);; + aDlgLay->setMargin(0); aDlgLay->setSpacing(SPACING); + myMainFrame = createMainFrame(mainFrame()); - QWidget* aMainFrame = createMainFrame (mainFrame()); + aDlgLay->addWidget(myMainFrame); - aDlgLay->addWidget(aMainFrame); - - aDlgLay->setStretchFactor(aMainFrame, 1); + aDlgLay->setStretchFactor(myMainFrame, 1); } //======================================================================= @@ -110,80 +117,76 @@ QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent) QWidget* aFrame = new QWidget(theParent); SUIT_ResourceMgr* rm = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() ); - QPixmap iconMoveNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); - QPixmap iconSelect (rm->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap iconMoveNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); + QPixmap iconMoveWithoutNode (rm->loadPixmap("SMESH", tr("ICON_DLG_MOVE_WITHOUT_NODE"))); + QPixmap iconSelect (rm->loadPixmap("SMESH", tr("ICON_SELECT"))); // constructor - - QGroupBox* aPixGrp = new QGroupBox(tr("MESH_PASS_THROUGH_POINT"), aFrame); - QButtonGroup* aBtnGrp = new QButtonGroup(this); + QGroupBox* aPixGrp = new QGroupBox(tr("MOVE_NODE"), this); + aPixGrp->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myButtonGroup = new QButtonGroup(this); QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp); aPixGrpLayout->setMargin(MARGIN); aPixGrpLayout->setSpacing(SPACING); - QRadioButton* aRBut = new QRadioButton(aPixGrp); - aRBut->setIcon(iconMoveNode); - aRBut->setChecked(true); - aPixGrpLayout->addWidget(aRBut); - aBtnGrp->addButton(aRBut, 0); - - // coordinates - - QGroupBox* aCoordGrp = new QGroupBox(tr("SMESH_COORDINATES"), aFrame); - QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp); - aCoordGrpLayout->setMargin(MARGIN); - aCoordGrpLayout->setSpacing(SPACING); - - myCoordBtn = new QPushButton(aCoordGrp); - myCoordBtn->setIcon(iconSelect); - myCoordBtn->setCheckable(true); - - QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp); - myX = new SMESHGUI_SpinBox(aCoordGrp); - - QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp); - myY = new SMESHGUI_SpinBox(aCoordGrp); - - QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp); - 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); + myRButNodeToMove = new QRadioButton(aPixGrp); + myRButMoveWithoutNode = new QRadioButton(aPixGrp); + myRButNodeToMove->setIcon(iconMoveNode); + myRButMoveWithoutNode->setIcon(iconMoveWithoutNode); + myRButNodeToMove->setChecked(true); - aCoordGrpLayout->addWidget(myCoordBtn); - aCoordGrpLayout->addWidget(aXLabel); - aCoordGrpLayout->addWidget(myX); - aCoordGrpLayout->addWidget(aYLabel); - aCoordGrpLayout->addWidget(myY); - aCoordGrpLayout->addWidget(aZLabel); - aCoordGrpLayout->addWidget(myZ); + aPixGrpLayout->addWidget(myRButNodeToMove); + aPixGrpLayout->addWidget(myRButMoveWithoutNode); + myButtonGroup->addButton(myRButNodeToMove, 0); + myButtonGroup->addButton(myRButMoveWithoutNode, 1); - // Method selection - - 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 + // Node to move myNodeToMoveGrp = new QGroupBox(tr("NODE_2MOVE"), aFrame); - + myNodeToMoveGrp->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); QLabel* idLabel = new QLabel(tr("NODE_2MOVE_ID"), myNodeToMoveGrp); myIdBtn = new QPushButton(myNodeToMoveGrp); 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); + + myUpdateBtn = new QPushButton(tr("UPDATE_DESTINATION"), myNodeToMoveGrp); + myUpdateBtn->setAutoDefault(true); + + QWidget* aCoordWidget = new QWidget(myNodeToMoveGrp); + + QLabel* aCurrentXLabel = new QLabel(tr("SMESH_X"), aCoordWidget); + myCurrentX = new SMESHGUI_SpinBox(aCoordWidget); + myCurrentX->setButtonSymbols(QAbstractSpinBox::NoButtons); + myCurrentX->setReadOnly(true); + + QLabel* aCurrentYLabel = new QLabel(tr("SMESH_Y"), aCoordWidget); + myCurrentY = new SMESHGUI_SpinBox(aCoordWidget); + myCurrentY->setButtonSymbols(QAbstractSpinBox::NoButtons); + myCurrentY->setReadOnly(true); + + QLabel* aCurrentZLabel = new QLabel(tr("SMESH_Z"), aCoordWidget); + myCurrentZ = new SMESHGUI_SpinBox(aCoordWidget); + myCurrentZ->setButtonSymbols(QAbstractSpinBox::NoButtons); + myCurrentZ->setReadOnly(true); + + myCurrentX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myCurrentY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myCurrentZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + + QGridLayout* aCoordLayout = new QGridLayout(aCoordWidget); + aCoordLayout->setMargin(0); + aCoordLayout->setSpacing(SPACING); + aCoordLayout->addWidget(aCurrentXLabel, 0, 0); + aCoordLayout->addWidget(myCurrentX, 0, 1); + aCoordLayout->addWidget(aCurrentYLabel, 0, 2); + aCoordLayout->addWidget(myCurrentY, 0, 3); + aCoordLayout->addWidget(aCurrentZLabel, 0, 4); + aCoordLayout->addWidget(myCurrentZ, 0, 5); + aCoordLayout->setColumnStretch(1, 1); + aCoordLayout->setColumnStretch(3, 1); + aCoordLayout->setColumnStretch(5, 1); QGridLayout* myNodeToMoveGrpLayout = new QGridLayout(myNodeToMoveGrp); myNodeToMoveGrpLayout->setSpacing(SPACING); @@ -192,24 +195,81 @@ QWidget* SMESHGUI_MakeNodeAtPointDlg::createMainFrame (QWidget* theParent) myNodeToMoveGrpLayout->addWidget( idLabel, 0, 0 ); myNodeToMoveGrpLayout->addWidget( myIdBtn, 0, 1 ); myNodeToMoveGrpLayout->addWidget( myId, 0, 2 ); - myNodeToMoveGrpLayout->addWidget( myAutoSearchChkBox, 1, 0, 1, 3 ); - myNodeToMoveGrpLayout->addWidget( myPreviewChkBox, 2, 0, 1, 3 ); + myNodeToMoveGrpLayout->addWidget( myUpdateBtn, 0, 3 ); + myNodeToMoveGrpLayout->addWidget( aCoordWidget, 1, 0, 1, 4 ); + + // Destination + + myDestinationGrp = new QGroupBox(tr("DESTINATION"), aFrame); + myDestinationGrp->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myDestBtn = new QPushButton(myDestinationGrp); + myDestBtn->setIcon(iconSelect); + myDestBtn->setCheckable(true); + + QLabel* aDestinationXLabel = new QLabel(tr("SMESH_X"), myDestinationGrp); + myDestinationX = new SMESHGUI_SpinBox(myDestinationGrp); + + QLabel* aDestinationYLabel = new QLabel(tr("SMESH_Y"), myDestinationGrp); + myDestinationY = new SMESHGUI_SpinBox(myDestinationGrp); + + QLabel* aDestinationZLabel = new QLabel(tr("SMESH_Z"), myDestinationGrp); + myDestinationZ = new SMESHGUI_SpinBox(myDestinationGrp); + + myDestDXLabel = new QLabel(tr("SMESH_DX"), myDestinationGrp); + myDestDX = new SMESHGUI_SpinBox(myDestinationGrp); + myDestDX->setReadOnly(true); + + myDestDYLabel = new QLabel(tr("SMESH_DY"), myDestinationGrp); + myDestDY = new SMESHGUI_SpinBox(myDestinationGrp); + myDestDY->setReadOnly(true); + + myDestDZLabel = new QLabel(tr("SMESH_DZ"), myDestinationGrp); + myDestDZ = new SMESHGUI_SpinBox(myDestinationGrp); + myDestDZ->setReadOnly(true); + + myDestinationX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myDestinationY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myDestinationZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myDestDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myDestDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myDestDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + + QGridLayout* aDestLayout = new QGridLayout(myDestinationGrp); + aDestLayout->setMargin(MARGIN); + aDestLayout->setSpacing(SPACING); + aDestLayout->addWidget(myDestBtn, 0, 0); + aDestLayout->addWidget(aDestinationXLabel, 0, 1); + aDestLayout->addWidget(myDestinationX, 0, 2); + aDestLayout->addWidget(aDestinationYLabel, 0, 3); + aDestLayout->addWidget(myDestinationY, 0, 4); + aDestLayout->addWidget(aDestinationZLabel, 0, 5); + aDestLayout->addWidget(myDestinationZ, 0, 6); + aDestLayout->addWidget(myDestDXLabel, 1, 1); + aDestLayout->addWidget(myDestDX, 1, 2); + aDestLayout->addWidget(myDestDYLabel, 1, 3); + aDestLayout->addWidget(myDestDY, 1, 4); + aDestLayout->addWidget(myDestDZLabel, 1, 5); + aDestLayout->addWidget(myDestDZ, 1, 6); + aDestLayout->setColumnStretch(2, 1); + aDestLayout->setColumnStretch(4, 1); + aDestLayout->setColumnStretch(6, 1); + + // Preview + + myPreviewChkBox = new QCheckBox( tr("PREVIEW"), aFrame); QVBoxLayout* aLay = new QVBoxLayout(aFrame); aLay->addWidget(aPixGrp); - aLay->addWidget(aCoordGrp); - aLay->addWidget(aMethodGrp); aLay->addWidget(myNodeToMoveGrp); + aLay->addWidget(myDestinationGrp); + aLay->addWidget(myPreviewChkBox); - connect(myCoordBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); - connect(myMoveRBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); - connect(myCreateRBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); + connect(myDestBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); connect(myIdBtn, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); - connect(myAutoSearchChkBox, SIGNAL (toggled(bool)), this, SLOT(ButtonToggled(bool))); + connect(myButtonGroup, SIGNAL (buttonClicked(int)), SLOT(ConstructorsClicked(int))); - myMoveRBtn->setChecked(true); - myIdBtn->setDown(true); - myAutoSearchChkBox->setChecked(true); + myIdBtn->setChecked(true); return aFrame; } @@ -225,39 +285,62 @@ void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on) { const QObject* aSender = sender(); if ( on ) { - if ( aSender == myCoordBtn ) // button to set coord by node selection + if ( aSender == myDestBtn ) // button to set coord by node selection { if ( myIdBtn->isEnabled() ) - myIdBtn->setDown( !on ); + myIdBtn->setChecked( !on ); } else if ( aSender == myIdBtn ) // button to select a node to move { - myCoordBtn->setDown( !on ); + myDestBtn->setChecked( !on ); } - else if ( aSender == myMoveRBtn ) // move node method + } +} +//================================================================================ +/*! + * \brief SLOT called when clicked radio button + * \param int - number of the button + */ +//================================================================================ +void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId) +{ + switch (constructorId) { + case 0: { - myNodeToMoveGrp->setEnabled( true ); + myDestDXLabel->show(); + myDestDYLabel->show(); + myDestDZLabel->show(); + myDestDX->show(); + myDestDY->show(); + myDestDZ->show(); + myCurrentX->SetValue(0); + myCurrentY->SetValue(0); + myCurrentZ->SetValue(0); + if (!myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->show(); + break; } - else if ( aSender == myCreateRBtn ) // create node method + case 1: { - myNodeToMoveGrp->setEnabled( false ); - myCoordBtn->setDown( true ); - } - } - if ( aSender == myAutoSearchChkBox ) // automatic node search - { - if ( on ) { myId->setText(""); - myId->setReadOnly ( true ); - myIdBtn->setDown( false ); - myIdBtn->setEnabled( false ); - myCoordBtn->setDown( true ); - } - else { - myId->setReadOnly ( false ); - myIdBtn->setEnabled( true ); + myCurrentX->SetValue(0); + myCurrentY->SetValue(0); + myCurrentZ->SetValue(0); + myDestDXLabel->hide(); + myDestDYLabel->hide(); + myDestDZLabel->hide(); + myDestDX->hide(); + myDestDY->hide(); + myDestDZ->hide(); + if (myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->hide(); + myDestBtn->setChecked( true ); + break; } } + QApplication::instance()->processEvents(); + myMainFrame->hide(); + myMainFrame->show(); + updateGeometry(); + resize(minimumSizeHint()); } //================================================================================ @@ -269,19 +352,44 @@ void SMESHGUI_MakeNodeAtPointDlg::ButtonToggled (bool on) SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp() { mySimulation = 0; + mySMESHGUI = 0; myDlg = new SMESHGUI_MakeNodeAtPointDlg; myFilter = 0; myHelpFileName = "mesh_through_point_page.html"; + myNoPreview = false; + myUpdateDestination = false; + myDestCoordChanged = true; + // connect signals and slots - connect(myDlg->myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); - connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview())); - connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),SLOT(redisplayPreview())); - connect(myDlg->myAutoSearchChkBox,SIGNAL (toggled(bool)),SLOT(redisplayPreview())); - connect(myDlg->myMoveRBtn, SIGNAL (toggled(bool)),SLOT(redisplayPreview())); - connect(myDlg->myCreateRBtn, SIGNAL (toggled(bool)),SLOT(redisplayPreview())); + connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview())); + connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged())); + connect(myDlg->myId, SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview())); + connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)), SLOT(redisplayPreview())); + connect(myDlg->myButtonGroup, SIGNAL (buttonClicked(int)), SLOT(redisplayPreview())); + + // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted + // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class + connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(onTextChange(const QString&))); + connect(myDlg->myUpdateBtn, SIGNAL (clicked()), this, SLOT(onUpdateDestination())); +} + +void SMESHGUI_MakeNodeAtPointOp::onUpdateDestination() +{ + myUpdateDestination = true; + redisplayPreview(); + myUpdateDestination = false; +} + +void SMESHGUI_MakeNodeAtPointOp::onDestCoordChanged() +{ + myDestCoordChanged = false; + redisplayPreview(); + myDestCoordChanged = true; } //======================================================================= @@ -295,7 +403,10 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() // init simulation with a current View if ( mySimulation ) delete mySimulation; - mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() )); + mySMESHGUI = getSMESHGUI(); + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ) ); + connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView())); + connect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView())); vtkProperty* aProp = vtkProperty::New(); aProp->SetRepresentationToWireframe(); aProp->SetColor(250, 0, 250); @@ -316,22 +427,35 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() // 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); - myDlg->myZ->SetValue(0); myDlg->myId->setText(""); + myDlg->myDestinationX->SetValue(0); + myDlg->myDestinationY->SetValue(0); + myDlg->myDestinationZ->SetValue(0); + myDlg->myDestDX->SetValue(0); + myDlg->myDestDY->SetValue(0); + myDlg->myDestDZ->SetValue(0); + myDlg->myCurrentX->SetValue(0); + myDlg->myCurrentY->SetValue(0); + myDlg->myCurrentZ->SetValue(0); + myDlg->myDestDX->setReadOnly(true); + myDlg->myDestDY->setReadOnly(true); + myDlg->myDestDZ->setReadOnly(true); + myDlg->myRButNodeToMove->setChecked(true); + + myDlg->ConstructorsClicked( GetConstructorId() ); + myDlg->show(); onSelectionDone(); // init myMeshActor +} - if ( myMeshActor ) { -// myMeshOldDisplayMode = myMeshActor->GetRepresentation(); -// myMeshActor->SetRepresentation( VTK_WIREFRAME ); - myMeshActor->SetPointRepresentation(true); - SMESH::RepaintCurrentView(); - redisplayPreview(); - } +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_MakeNodeAtPointOp::GetConstructorId() +{ + return myDlg->myButtonGroup->checkedId(); } //================================================================================ @@ -343,13 +467,20 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation() void SMESHGUI_MakeNodeAtPointOp::stopOperation() { myNoPreview = true; - mySimulation->SetVisibility(false); + if ( mySimulation ) + { + mySimulation->SetVisibility(false); + delete mySimulation; + mySimulation = 0; + } if ( myMeshActor ) { -// myMeshActor->SetRepresentation( myMeshOldDisplayMode ); - myMeshActor->SetPointRepresentation(false); - SMESH::RepaintCurrentView(); myMeshActor = 0; } + SMESH::SetPointRepresentation( false ); + SMESH::RepaintCurrentView(); + + disconnect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), this, SLOT(onOpenView())); + disconnect(mySMESHGUI, SIGNAL (SignalCloseView()), this, SLOT(onCloseView())); selectionMgr()->removeFilter( myFilter ); SMESHGUI_SelectionOp::stopOperation(); } @@ -367,7 +498,7 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() if ( !myMeshActor ) { SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), - tr("INVALID_MESH") ); + tr("INVALID_MESH") ); dlg()->show(); return false; } @@ -376,53 +507,56 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() if ( !isValid( msg ) ) { // node id is invalid if( !msg.isEmpty() ) SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), - tr("INVALID_ID") ); + tr("INVALID_ID") ); dlg()->show(); return false; } + QStringList aParameters; + aParameters << myDlg->myDestinationX->text(); + aParameters << myDlg->myDestinationY->text(); + aParameters << myDlg->myDestinationZ->text(); try { SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); if (aMesh->_is_nil()) { SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), - tr("SMESHG_NO_MESH") ); + tr("SMESHG_NO_MESH") ); return true; } SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); if (aMeshEditor->_is_nil()) return true; - int aResult = 0; - if ( myDlg->myCreateRBtn->isDown() ) - { - aResult = aMeshEditor->AddNode(myDlg->myX->GetValue(), - myDlg->myY->GetValue(), - myDlg->myZ->GetValue()); - } - else - { - int anId = myDlg->myId->text().toInt(); - aResult = aMeshEditor->MoveClosestNodeToPoint(myDlg->myX->GetValue(), - myDlg->myY->GetValue(), - myDlg->myZ->GetValue(), - anId); - } + aMesh->SetParameters( aParameters.join(":").toLatin1().constData() ); + + bool ok; + int anId = myDlg->myId->text().toInt( &ok ); + if( !ok || anId < 1 ) + anId = aMeshEditor->FindNodeClosestTo(myDlg->myDestinationX->GetValue(), + myDlg->myDestinationY->GetValue(), + myDlg->myDestinationZ->GetValue()); + + int aResult = aMeshEditor->MoveNode(anId, + myDlg->myDestinationX->GetValue(), + myDlg->myDestinationY->GetValue(), + myDlg->myDestinationZ->GetValue() ); + if (aResult) { - QStringList aParameters; - aParameters << myDlg->myX->text(); - aParameters << myDlg->myY->text(); - aParameters << myDlg->myZ->text(); - aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); - - myDlg->myId->setText(""); + myDlg->myCurrentX->SetValue(0); + myDlg->myCurrentY->SetValue(0); + myDlg->myCurrentZ->SetValue(0); + myDlg->myDestDX->SetValue(0); + myDlg->myDestDY->SetValue(0); + myDlg->myDestDZ->SetValue(0); SALOME_ListIO aList; selectionMgr()->setSelectedObjects(aList,false); aList.Append(myMeshActor->getIO()); selectionMgr()->setSelectedObjects(aList,false); SMESH::UpdateView(); + SMESHGUI::Modified(); } } catch (const SALOME::SALOME_Exception& S_ex) { @@ -443,9 +577,7 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg ) { bool ok = true; - if ( myMeshActor && - myDlg->myMoveRBtn->isDown() && - !myDlg->myAutoSearchChkBox->isChecked() ) + if ( myMeshActor && myDlg->myRButNodeToMove->isChecked() ) { ok = false; int id = myDlg->myId->text().toInt(); @@ -456,9 +588,9 @@ bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg ) msg += tr("INVALID_ID") + "\n"; } - ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok; - ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok; - ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myDestinationX->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myDestinationY->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myDestinationZ->isValid( msg, !myNoPreview ) && ok; return ok; } @@ -473,6 +605,8 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() { if ( !myDlg->isVisible() || !myDlg->isEnabled() ) return; + + myNoPreview = true; try { SALOME_ListIO aList; selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type()); @@ -481,53 +615,68 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone() Handle(SALOME_InteractiveObject) anIO = aList.First(); SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry()); + if (( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) || + ( !myDlg->myNodeToMoveGrp->isVisible() )) + myMeshActor = aMeshActor; + if (!aMeshActor) { // coord by geom - if ( myDlg->myCoordBtn->isDown() ) { + if ( myDlg->myDestBtn->isChecked() ) { GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface(anIO); if ( !geom->_is_nil() ) { TopoDS_Vertex aShape; if ( GEOMBase::GetShape(geom, aShape) && aShape.ShapeType() == TopAbs_VERTEX ) { gp_Pnt P = BRep_Tool::Pnt(aShape); - myNoPreview = true; - myDlg->myX->SetValue(P.X()); - myDlg->myY->SetValue(P.Y()); - myDlg->myZ->SetValue(P.Z()); - myNoPreview = false; - redisplayPreview(); + myDlg->myDestinationX->SetValue(P.X()); + myDlg->myDestinationY->SetValue(P.Y()); + myDlg->myDestinationZ->SetValue(P.Z()); } } + myNoPreview = false; + redisplayPreview(); return; } } - if ( !myMeshActor ) - myMeshActor = aMeshActor; - QString aString; int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString); if (nbElems == 1) { if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) { if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) { - myNoPreview = true; - if ( myDlg->myCoordBtn->isDown() ) { // set coord - myDlg->myX->SetValue(aNode->X()); - myDlg->myY->SetValue(aNode->Y()); - myDlg->myZ->SetValue(aNode->Z()); - myNoPreview = false; - redisplayPreview(); + if ( myDlg->myDestBtn->isChecked() ) { // set coord + myDlg->myDestinationX->SetValue(aNode->X()); + myDlg->myDestinationY->SetValue(aNode->Y()); + myDlg->myDestinationZ->SetValue(aNode->Z()); } - else if ( myDlg->myIdBtn->isDown() && + else if ( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) { // set node to move myDlg->myId->setText(aString); - myNoPreview = false; + myDlg->myCurrentX->SetValue( aNode->X() ); + myDlg->myCurrentY->SetValue( aNode->Y() ); + myDlg->myCurrentZ->SetValue( aNode->Z() ); redisplayPreview(); } + + double x = myDlg->myCurrentX->GetValue(); + double y = myDlg->myCurrentY->GetValue(); + double z = myDlg->myCurrentZ->GetValue(); + double dx = myDlg->myDestinationX->GetValue() - x; + double dy = myDlg->myDestinationY->GetValue() - y; + double dz = myDlg->myDestinationZ->GetValue() - z; + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + myDlg->myDestDX->setReadOnly(false); + myDlg->myDestDY->setReadOnly(false); + myDlg->myDestDZ->setReadOnly(false); } } } } catch (...) { } + + myNoPreview = false; + redisplayPreview(); } //================================================================================ @@ -542,18 +691,18 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() return; myNoPreview = true; + if ( !myMeshActor && GetConstructorId() == SEARCH_MODE ) + onSelectionDone(); + SMESH::MeshPreviewStruct_var aMeshPreviewStruct; bool moveShown = false; - if ( myDlg->myMoveRBtn->isDown() && // Move method - myMeshActor) + if ( myMeshActor) { - const bool autoSearch = myDlg->myAutoSearchChkBox->isChecked(); - const bool preview = myDlg->myPreviewChkBox->isChecked(); - if ( autoSearch ) - myDlg->myId->setText(""); + const bool isPreview = myDlg->myPreviewChkBox->isChecked(); + const bool isMoveNode = myDlg->myRButMoveWithoutNode->isChecked(); QString msg; - if ( preview && ( autoSearch || isValid( msg ) )) + if ( isValid( msg ) ) { try { SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); @@ -563,26 +712,81 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() { SUIT_OverrideCursor aWaitCursor; - // find id and/or just compute preview - int anId = aPreviewer->MoveClosestNodeToPoint(myDlg->myX->GetValue(), - myDlg->myY->GetValue(), - myDlg->myZ->GetValue(), - myDlg->myId->text().toInt()); - if ( autoSearch ) { // set found id - QString idTxt("%1"); - if ( anId > 0 ) - idTxt = idTxt.arg( anId ); + int anId = myDlg->myId->text().toInt(); + + SMESH::double_array_var aXYZ = aMesh->GetNodeXYZ( anId ); + if( &aXYZ.in() && aXYZ->length() >= 3 ) + { + double x = aXYZ[0]; + double y = aXYZ[1]; + double z = aXYZ[2]; + double dx = 0; + double dy = 0; + double dz = 0; + + if ( myUpdateDestination ) { + myDlg->myDestinationX->SetValue(x); + myDlg->myDestinationY->SetValue(y); + myDlg->myDestinationZ->SetValue(z); + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + } else - idTxt = ""; - myDlg->myId->setText( idTxt ); + { + if ( myDestCoordChanged ) { + dx = myDlg->myDestinationX->GetValue() - x; + dy = myDlg->myDestinationY->GetValue() - y; + dz = myDlg->myDestinationZ->GetValue() - z; + myDlg->myDestDX->SetValue(dx); + myDlg->myDestDY->SetValue(dy); + myDlg->myDestDZ->SetValue(dz); + } + else { + dx = myDlg->myDestDX->GetValue() + x; + dy = myDlg->myDestDY->GetValue() + y; + dz = myDlg->myDestDZ->GetValue() + z; + myDlg->myDestinationX->SetValue(dx); + myDlg->myDestinationY->SetValue(dy); + myDlg->myDestinationZ->SetValue(dz); + } + } + myDlg->myCurrentX->SetValue(x); + myDlg->myCurrentY->SetValue(y); + myDlg->myCurrentZ->SetValue(z); + myDlg->myDestDX->setReadOnly(false); + myDlg->myDestDY->setReadOnly(false); + myDlg->myDestDZ->setReadOnly(false); } - if ( preview ) { // fill preview data + else { + myDlg->myCurrentX->SetValue(0); + myDlg->myCurrentY->SetValue(0); + myDlg->myCurrentZ->SetValue(0); + myDlg->myDestDX->SetValue(0); + myDlg->myDestDY->SetValue(0); + myDlg->myDestDZ->SetValue(0); + myDlg->myDestDX->setReadOnly(true); + myDlg->myDestDY->setReadOnly(true); + myDlg->myDestDZ->setReadOnly(true); + } + if ( isPreview && isMoveNode && anId == 0 ) + anId = aPreviewer->FindNodeClosestTo(myDlg->myDestinationX->GetValue(), + myDlg->myDestinationY->GetValue(), + myDlg->myDestinationZ->GetValue()); + // find id and/or just compute preview + aPreviewer->MoveNode(anId, + myDlg->myDestinationX->GetValue(), + myDlg->myDestinationY->GetValue(), + myDlg->myDestinationZ->GetValue()); + + if ( isPreview ) { // fill preview data aMeshPreviewStruct = aPreviewer->GetPreviewData(); moveShown = ( anId > 0 ); } } } - }catch (...) { + } + catch (...) { } } } @@ -592,9 +796,9 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() aMeshPreviewStruct = new SMESH::MeshPreviewStruct(); aMeshPreviewStruct->nodesXYZ.length(1); - aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myX->GetValue(); - aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myY->GetValue(); - aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myZ->GetValue(); + aMeshPreviewStruct->nodesXYZ[0].x = myDlg->myDestinationX->GetValue(); + aMeshPreviewStruct->nodesXYZ[0].y = myDlg->myDestinationY->GetValue(); + aMeshPreviewStruct->nodesXYZ[0].z = myDlg->myDestinationZ->GetValue(); aMeshPreviewStruct->elementTypes.length(1); aMeshPreviewStruct->elementTypes[0].SMDS_ElementType = SMESH::NODE; @@ -604,20 +808,77 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() aMeshPreviewStruct->elementConnectivities.length(1); aMeshPreviewStruct->elementConnectivities[0] = 0; } - + if (!mySimulation) + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); // display data if ( aMeshPreviewStruct.operator->() ) { mySimulation->SetData(aMeshPreviewStruct._retn()); } else -{ + { mySimulation->SetVisibility(false); } myNoPreview = false; } +//================================================================================= +/*! + * \brief SLOT called when the viewer opened + */ +//================================================================================= +void SMESHGUI_MakeNodeAtPointOp::onOpenView() +{ + if ( mySimulation ) { + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(false); + } + else { + mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); + } +} + +//================================================================================= +/*! + * \brief SLOT called when the viewer closed + */ +//================================================================================= +void SMESHGUI_MakeNodeAtPointOp::onCloseView() +{ + delete mySimulation; + mySimulation = 0; +} + +//================================================================================ +/*! + * \brief SLOT called when the node id is manually changed + */ +//================================================================================ + +void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText ) +{ + if( myMeshActor ) + { + if( SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh() ) + { + Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO(); + SALOME_ListIO aList; + aList.Append( anIO ); + selectionMgr()->setSelectedObjects( aList, false ); + + if( const SMDS_MeshNode* aNode = aMesh->FindNode( theText.toInt() ) ) + { + TColStd_MapOfInteger aListInd; + aListInd.Add( aNode->GetID() ); + selector()->AddOrRemoveIndex( anIO, aListInd, false ); + if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() ) ) + aViewWindow->highlight( anIO, true, true ); + } + } + } +} + //================================================================================ /*! * \brief Activate Node selection @@ -627,7 +888,7 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() void SMESHGUI_MakeNodeAtPointOp::activateSelection() { selectionMgr()->clearFilters(); - SMESH::SetPointRepresentation(false); + SMESH::SetPointRepresentation( true ); selectionMgr()->installFilter( myFilter ); setSelectionMode( NodeSelection ); }