2003-07-10 19:18:22 +06:00
|
|
|
// SMESH SMESHGUI : GUI for SMESH component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2005-06-07 19:22:20 +06:00
|
|
|
// 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
|
|
|
|
//
|
2006-06-01 17:39:17 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_MoveNodesDlg.cxx
|
|
|
|
// Author : Nicolas REJNERI
|
|
|
|
// Module : SMESH
|
2003-05-19 20:07:00 +06:00
|
|
|
// $Header$
|
|
|
|
|
|
|
|
#include "SMESHGUI_MoveNodesDlg.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
2003-05-19 20:07:00 +06:00
|
|
|
#include "SMESHGUI_SpinBox.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESHGUI_IdValidator.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
#include "SMESHGUI_MeshUtils.h"
|
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
#include "SMESH_Actor.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMDS_Mesh.hxx"
|
|
|
|
#include "SMDS_MeshNode.hxx"
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-11-03 13:38:17 +05:00
|
|
|
#include "LightApp_SelectionMgr.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "LightApp_Application.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SUIT_ResourceMgr.h"
|
|
|
|
#include "SUIT_Desktop.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SUIT_MessageBox.h"
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
#include "SVTK_Selector.h"
|
|
|
|
#include "SVTK_ViewModel.h"
|
|
|
|
#include "SVTK_ViewWindow.h"
|
|
|
|
#include "SALOME_ListIO.hxx"
|
|
|
|
|
|
|
|
#include "SVTK_ViewWindow.h"
|
2006-05-06 14:51:48 +06:00
|
|
|
#include "VTKViewer_CellLocationsArray.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
#include "utilities.h"
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
// OCCT includes
|
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
|
|
|
|
// VTK includes
|
2004-12-01 15:48:31 +05:00
|
|
|
#include <vtkCell.h>
|
|
|
|
#include <vtkIdList.h>
|
|
|
|
#include <vtkCellArray.h>
|
|
|
|
#include <vtkUnsignedCharArray.h>
|
|
|
|
#include <vtkUnstructuredGrid.h>
|
|
|
|
#include <vtkDataSetMapper.h>
|
2006-02-07 20:01:11 +05:00
|
|
|
#include <vtkProperty.h>
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
// QT includes
|
2003-05-19 20:07:00 +06:00
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpixmap.h>
|
2004-12-01 15:48:31 +05:00
|
|
|
#include <qmessagebox.h>
|
|
|
|
#include <qbuttongroup.h>
|
|
|
|
|
|
|
|
// IDL Headers
|
|
|
|
#include <SALOMEconfig.h>
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
#define MARGIN 10
|
|
|
|
#define SPACING 5
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg
|
|
|
|
// Purpose :
|
2003-05-19 20:07:00 +06:00
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg (SMESHGUI* theModule,
|
|
|
|
const char* theName):
|
|
|
|
QDialog(SMESH::GetDesktop(theModule),
|
|
|
|
theName,
|
|
|
|
false,
|
|
|
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
|
|
|
|
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
|
|
|
mySMESHGUI(theModule)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2004-12-01 15:48:31 +05:00
|
|
|
myPreviewActor = 0;
|
|
|
|
myBusy = false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
setCaption(tr("CAPTION"));
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* aMainFrame = createMainFrame (this);
|
|
|
|
QFrame* aBtnFrame = createButtonFrame(this);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aDlgLay->addWidget(aMainFrame);
|
|
|
|
aDlgLay->addWidget(aBtnFrame);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aDlgLay->setStretchFactor(aMainFrame, 1);
|
|
|
|
|
2005-07-01 16:42:32 +06:00
|
|
|
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
myHelpFileName = "/files/displacing_nodes.htm";
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
Init();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::createButtonFrame
|
|
|
|
// Purpose : Create frame containing buttons
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame (QWidget* theParent)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* aFrame = new QFrame(theParent);
|
|
|
|
aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
|
|
|
|
myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
|
|
|
|
myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
|
2006-05-06 14:51:48 +06:00
|
|
|
myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myOkBtn);
|
|
|
|
aLay->addWidget(myApplyBtn);
|
|
|
|
aLay->addItem(aSpacer);
|
|
|
|
aLay->addWidget(myCloseBtn);
|
2006-05-06 14:51:48 +06:00
|
|
|
aLay->addWidget(myHelpBtn);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
|
|
|
|
connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
|
|
|
|
connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
return aFrame;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::createMainFrame
|
|
|
|
// Purpose : Create frame containing dialog's input fields
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
QFrame* aFrame = new QFrame(theParent);
|
|
|
|
|
2005-06-08 16:45:19 +06:00
|
|
|
QPixmap iconMoveNode (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE")));
|
|
|
|
QPixmap iconSelect (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
QGroupBox* anIdGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MOVE"), aFrame);
|
|
|
|
new QLabel(tr("NODE_ID"), anIdGrp);
|
|
|
|
(new QPushButton(anIdGrp))->setPixmap(iconSelect);
|
|
|
|
myId = new QLineEdit(anIdGrp);
|
|
|
|
myId->setValidator(new SMESHGUI_IdValidator(this, "validator", 1));
|
|
|
|
|
|
|
|
QGroupBox* aCoordGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_COORDINATES"), aFrame);
|
|
|
|
new QLabel(tr("SMESH_X"), aCoordGrp);
|
|
|
|
myX = new SMESHGUI_SpinBox(aCoordGrp);
|
|
|
|
new QLabel(tr("SMESH_Y"), aCoordGrp);
|
|
|
|
myY = new SMESHGUI_SpinBox(aCoordGrp);
|
|
|
|
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);
|
|
|
|
|
|
|
|
QVBoxLayout* aLay = new QVBoxLayout(aFrame);
|
|
|
|
aLay->addWidget(aPixGrp);
|
|
|
|
aLay->addWidget(anIdGrp);
|
|
|
|
aLay->addWidget(aCoordGrp);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// connect signale and slots
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
|
|
|
|
connect(myY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
|
|
|
|
connect(myZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
|
|
|
|
connect(myId, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
return aFrame;
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg
|
|
|
|
// Purpose :
|
|
|
|
//=======================================================================
|
|
|
|
SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2004-12-01 15:48:31 +05:00
|
|
|
erasePreview();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::Init
|
|
|
|
// Purpose : Init dialog fields
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MoveNodesDlg::Init()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2004-12-01 15:48:31 +05:00
|
|
|
myPreviewActor = 0;
|
|
|
|
myMeshActor = 0;
|
|
|
|
myBusy = false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// selection and SMESHGUI
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
|
|
|
|
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
|
|
|
|
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
reset();
|
2005-06-07 19:22:20 +06:00
|
|
|
setEnabled(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
this->show();
|
|
|
|
|
|
|
|
// set selection mode
|
|
|
|
SMESH::SetPointRepresentation(true);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(NodeSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
onSelectionDone();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::isValid
|
|
|
|
// Purpose : Verify validity of entry information
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) const
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myId->text().isEmpty()) {
|
|
|
|
if (theMess)
|
|
|
|
QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"),
|
|
|
|
tr("NODE_ID_IS_NOT_DEFINED"), QMessageBox::Ok);
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::reset
|
|
|
|
// Purpose : Reset the dialog state
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::reset()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2004-12-01 15:48:31 +05:00
|
|
|
myId->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
myX->SetValue(0);
|
|
|
|
myY->SetValue(0);
|
|
|
|
myZ->SetValue(0);
|
2004-12-01 15:48:31 +05:00
|
|
|
redisplayPreview();
|
|
|
|
updateButtons();
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : SMESHGUI_MoveNodesDlg::onApply
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : SLOT called when "Apply" button pressed.
|
|
|
|
//=======================================================================
|
|
|
|
bool SMESHGUI_MoveNodesDlg::onApply()
|
|
|
|
{
|
2005-06-08 12:18:53 +06:00
|
|
|
if (mySMESHGUI->isActiveStudyLocked())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isValid(true))
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
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);
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aMeshEditor->_is_nil())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
int anId = myId->text().toInt();
|
|
|
|
bool aResult = false;
|
2005-06-07 19:22:20 +06:00
|
|
|
try {
|
|
|
|
aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue());
|
|
|
|
} catch (...) {
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aResult) {
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aList.Append(myMeshActor->getIO());
|
|
|
|
mySelectionMgr->setSelectedObjects(aList,false);
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::UpdateView();
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::onOk
|
|
|
|
// Purpose : SLOT called when "Ok" button pressed.
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::onOk()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (onApply())
|
2004-12-01 15:48:31 +05:00
|
|
|
onClose();
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::onClose
|
|
|
|
// Purpose : SLOT called when "Close" button pressed. Close dialog
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::onClose()
|
|
|
|
{
|
2005-11-23 17:08:49 +05:00
|
|
|
//mySelectionMgr->clearSelected();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::SetPointRepresentation(false);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
|
|
|
disconnect(mySMESHGUI, 0, this, 0);
|
2005-09-29 14:19:07 +06:00
|
|
|
erasePreview();
|
2005-06-07 19:22:20 +06:00
|
|
|
mySMESHGUI->ResetState();
|
2004-12-01 15:48:31 +05:00
|
|
|
reject();
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=================================================================================
|
|
|
|
// 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 {
|
|
|
|
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
|
|
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
|
|
|
|
QObject::tr("BUT_OK"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : SMESHGUI_MoveNodesDlg::onTextChange
|
|
|
|
// Purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MoveNodesDlg::onTextChange (const QString& theNewText)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBusy) return;
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myOkBtn->setEnabled(false);
|
|
|
|
myApplyBtn->setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
erasePreview();
|
|
|
|
|
|
|
|
// select entered node
|
2005-06-07 19:22:20 +06:00
|
|
|
if(myMeshActor){
|
|
|
|
if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()){
|
|
|
|
myBusy = true;
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO();
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aList.Append(anIO);
|
|
|
|
mySelectionMgr->setSelectedObjects(aList,false);
|
|
|
|
myBusy = false;
|
|
|
|
|
|
|
|
if(const SMDS_MeshElement *anElem = aMesh->FindElement(theNewText.toInt())) {
|
|
|
|
TColStd_MapOfInteger aListInd;
|
|
|
|
aListInd.Add(anElem->GetID());
|
2005-06-24 19:54:25 +06:00
|
|
|
mySelector->AddOrRemoveIndex(anIO,aListInd, false);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->highlight(anIO,true,true);
|
2005-06-24 19:54:25 +06:00
|
|
|
|
|
|
|
onSelectionDone();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::onSelectionDone
|
|
|
|
// Purpose : SLOT called when selection changed
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::onSelectionDone()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBusy) return;
|
2004-12-01 15:48:31 +05:00
|
|
|
myMeshActor = 0;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
|
|
|
|
|
|
|
|
if (aList.Extent() == 1) {
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = aList.First();
|
|
|
|
myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
|
|
|
|
if(myMeshActor){
|
2004-12-01 15:48:31 +05:00
|
|
|
QString aText;
|
2005-06-07 19:22:20 +06:00
|
|
|
if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
|
2004-12-01 15:48:31 +05:00
|
|
|
if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
|
|
|
|
if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
|
|
|
|
myBusy = true;
|
2005-06-07 19:22:20 +06:00
|
|
|
myId->setText(aText);
|
|
|
|
myX->SetValue(aNode->X());
|
|
|
|
myY->SetValue(aNode->Y());
|
|
|
|
myZ->SetValue(aNode->Z());
|
2004-12-01 15:48:31 +05:00
|
|
|
myBusy = false;
|
|
|
|
erasePreview(); // avoid overlapping of a selection and a preview
|
|
|
|
updateButtons();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
reset();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::onDeactivate
|
|
|
|
// Purpose : SLOT called when dialog must be deativated
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::onDeactivate()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
erasePreview();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::enterEvent
|
|
|
|
// Purpose : Event filter
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MoveNodesDlg::enterEvent (QEvent*)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isEnabled()) {
|
2005-06-08 12:18:53 +06:00
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// set selection mode
|
|
|
|
SMESH::SetPointRepresentation(true);
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(NodeSelection);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
redisplayPreview();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
setEnabled(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::closeEvent
|
|
|
|
// Purpose :
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::closeEvent (QCloseEvent*)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
onClose();
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->Repaint();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : SMESHGUI_MoveNodesDlg::hideEvent
|
|
|
|
// Purpose : may be caused by ESC key
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_MoveNodesDlg::hideEvent (QHideEvent*)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isMinimized())
|
2004-12-01 15:48:31 +05:00
|
|
|
onClose();
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::updateButtons
|
|
|
|
// Purpose : Update buttons state
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::updateButtons()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
bool isEnabled = isValid(false);
|
|
|
|
myOkBtn->setEnabled(isEnabled);
|
|
|
|
myApplyBtn->setEnabled(isEnabled);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::erasePreview
|
|
|
|
// Purpose : Erase preview
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::erasePreview()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myPreviewActor == 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
2005-07-01 16:42:32 +06:00
|
|
|
SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
|
|
|
|
if (aViewWindow)
|
|
|
|
aViewWindow->RemoveActor(myPreviewActor);
|
2004-12-01 15:48:31 +05:00
|
|
|
myPreviewActor->Delete();
|
|
|
|
myPreviewActor = 0;
|
2005-07-01 16:42:32 +06:00
|
|
|
if (aViewWindow)
|
|
|
|
aViewWindow->Repaint();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// name : SMESHGUI_MoveNodesDlg::redisplayPreview
|
|
|
|
// Purpose : Redisplay preview
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_MoveNodesDlg::redisplayPreview()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBusy)
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (myPreviewActor != 0)
|
2004-12-01 15:48:31 +05:00
|
|
|
erasePreview();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
|
|
|
if (!isValid(false))
|
2004-12-01 15:48:31 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
vtkPoints* aPoints = vtkPoints::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aPoints->SetNumberOfPoints(1);
|
|
|
|
aPoints->SetPoint(0, myX->GetValue(), myY->GetValue(), myZ->GetValue());
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// Create cells
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
vtkIdList *anIdList = vtkIdList::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
anIdList->SetNumberOfIds(1);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
vtkCellArray *aCells = vtkCellArray::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aCells->Allocate(2, 0);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aCellTypesArray->SetNumberOfComponents(1);
|
|
|
|
aCellTypesArray->Allocate(1);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
anIdList->SetId(0, 0);
|
|
|
|
aCells->InsertNextCell(anIdList);
|
|
|
|
aCellTypesArray->InsertNextValue(VTK_VERTEX);
|
|
|
|
anIdList->Delete();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aCellLocationsArray->SetNumberOfComponents(1);
|
|
|
|
aCellLocationsArray->SetNumberOfTuples(1);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
aCells->InitTraversal();
|
|
|
|
vtkIdType npts;
|
2005-06-07 19:22:20 +06:00
|
|
|
aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aGrid->SetPoints(aPoints);
|
|
|
|
aPoints->Delete();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aGrid->SetCells(aCellTypesArray,aCellLocationsArray,aCells);
|
|
|
|
aCellLocationsArray->Delete();
|
|
|
|
aCellTypesArray->Delete();
|
|
|
|
aCells->Delete();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// Create and display actor
|
|
|
|
vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
|
2005-06-07 19:22:20 +06:00
|
|
|
aMapper->SetInput(aGrid);
|
|
|
|
aGrid->Delete();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
myPreviewActor = SALOME_Actor::New();
|
|
|
|
myPreviewActor->PickableOff();
|
2005-06-07 19:22:20 +06:00
|
|
|
myPreviewActor->SetMapper(aMapper);
|
|
|
|
aMapper->Delete();
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
vtkProperty* aProp = vtkProperty::New();
|
|
|
|
aProp->SetRepresentationToWireframe();
|
2005-06-07 19:22:20 +06:00
|
|
|
aProp->SetColor(250, 0, 250);
|
|
|
|
aProp->SetPointSize(5);
|
|
|
|
myPreviewActor->SetProperty(aProp);
|
2004-12-01 15:48:31 +05:00
|
|
|
aProp->Delete();
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
{
|
|
|
|
aViewWindow->AddActor(myPreviewActor);
|
|
|
|
aViewWindow->Repaint();
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|