2013-04-01 19:05:47 +06:00
|
|
|
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2005-06-07 19:22:20 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// 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.
|
2005-06-07 19:22:20 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// 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.
|
2005-06-07 19:22:20 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// 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
|
2005-06-07 19:22:20 +06:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// File : SMESHGUI_SingleEditDlg.cxx
|
|
|
|
// Author : Sergey LITONIN, Open CASCADE S.A.S.
|
|
|
|
// SMESH includes
|
2004-12-01 15:48:31 +05:00
|
|
|
//
|
|
|
|
#include "SMESHGUI_SingleEditDlg.h"
|
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
#include "SMESHGUI_MeshUtils.h"
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SMESH_Actor.h>
|
|
|
|
#include <SMDS_Mesh.hxx>
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SALOME GUI includes
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
|
|
|
#include <LightApp_Application.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_MessageBox.h>
|
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_Session.h>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SVTK_Selector.h>
|
|
|
|
#include <SVTK_ViewWindow.h>
|
|
|
|
#include <SALOME_ListIO.hxx>
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// OCCT includes
|
2005-06-07 19:22:20 +06:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// Qt includes
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QValidator>
|
|
|
|
#include <QKeyEvent>
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#define SPACING 6
|
|
|
|
#define MARGIN 11
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
2009-02-17 10:27:49 +05:00
|
|
|
\class BusyLocker
|
|
|
|
\brief Simple 'busy state' flag locker.
|
|
|
|
\internal
|
|
|
|
*/
|
|
|
|
|
|
|
|
class BusyLocker
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
public:
|
|
|
|
//! Constructor. Sets passed boolean flag to \c true.
|
|
|
|
BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
|
|
|
|
//! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
|
|
|
|
~BusyLocker() { myBusy = false; }
|
|
|
|
private:
|
|
|
|
bool& myBusy; //! External 'busy state' boolean flag
|
2004-12-01 15:48:31 +05:00
|
|
|
};
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_SingleEditDlg
|
|
|
|
* Description : Inversion of the diagonal of a pseudo-quadrangle formed by
|
|
|
|
* 2 neighboring triangles with 1 common edge
|
|
|
|
*/
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : SMESHGUI_SingleEditDlg()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Constructor
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_SingleEditDlg
|
2009-02-17 10:27:49 +05:00
|
|
|
::SMESHGUI_SingleEditDlg(SMESHGUI* theModule)
|
|
|
|
: QDialog(SMESH::GetDesktop(theModule)),
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
|
|
|
|
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
|
|
|
mySMESHGUI(theModule)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setModal(false);
|
|
|
|
|
|
|
|
QVBoxLayout* aDlgLay = new QVBoxLayout(this);
|
|
|
|
aDlgLay->setMargin(MARGIN);
|
|
|
|
aDlgLay->setSpacing(SPACING);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* aMainFrame = createMainFrame (this);
|
|
|
|
QWidget* aBtnFrame = createButtonFrame(this);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aDlgLay->addWidget(aMainFrame);
|
|
|
|
aDlgLay->addWidget(aBtnFrame);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
Init();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : createMainFrame()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Create frame containing dialog's input fields
|
|
|
|
//=======================================================================
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* SMESHGUI_SingleEditDlg::createMainFrame (QWidget* theParent)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QGroupBox* aMainGrp = new QGroupBox(tr("EDGE_BETWEEN"), theParent);
|
|
|
|
QHBoxLayout* aLay = new QHBoxLayout(aMainGrp);
|
|
|
|
aLay->setMargin(MARGIN);
|
|
|
|
aLay->setSpacing(SPACING);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-08 16:45:19 +06:00
|
|
|
QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QLabel* aLab = new QLabel(tr("SMESH_EDGE"), aMainGrp);
|
|
|
|
QPushButton* aBtn = new QPushButton(aMainGrp);
|
|
|
|
aBtn->setIcon(aPix);
|
2005-06-07 19:22:20 +06:00
|
|
|
myEdge = new QLineEdit(aMainGrp);
|
2009-02-17 10:27:49 +05:00
|
|
|
myEdge->setValidator(new QRegExpValidator(QRegExp("[\\d]*-[\\d]*"), this));
|
|
|
|
|
|
|
|
aLay->addWidget(aLab);
|
|
|
|
aLay->addWidget(aBtn);
|
|
|
|
aLay->addWidget(myEdge);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
return aMainGrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : createButtonFrame()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Create frame containing buttons
|
|
|
|
//=======================================================================
|
2009-02-17 10:27:49 +05:00
|
|
|
QWidget* SMESHGUI_SingleEditDlg::createButtonFrame (QWidget* theParent)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QGroupBox* aFrame = new QGroupBox(theParent);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
|
2005-06-07 19:22:20 +06:00
|
|
|
myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
|
|
|
|
myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
|
2009-02-17 10:27:49 +05:00
|
|
|
myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QHBoxLayout* aLay = new QHBoxLayout(aFrame);
|
|
|
|
aLay->setMargin(MARGIN);
|
|
|
|
aLay->setSpacing(SPACING);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myOkBtn);
|
2009-02-17 10:27:49 +05:00
|
|
|
aLay->addSpacing(10);
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myApplyBtn);
|
2009-02-17 10:27:49 +05:00
|
|
|
aLay->addSpacing(10);
|
|
|
|
aLay->addStretch();
|
2005-06-07 19:22:20 +06:00
|
|
|
aLay->addWidget(myCloseBtn);
|
2006-05-06 14:51:48 +06:00
|
|
|
aLay->addWidget(myHelpBtn);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : isValid()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Verify validity of input data
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_SingleEditDlg::isValid (const bool theMess) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
int id1, id2;
|
2005-06-07 19:22:20 +06:00
|
|
|
return getNodeIds(myEdge->text(), id1, id2);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : getNodeIds()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Retrieve node ids from string
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_SingleEditDlg::getNodeIds (const QString& theStr,
|
|
|
|
int& theId1, int& theId2) const
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!theStr.contains('-'))
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
|
|
|
bool ok1, ok2;
|
2005-06-07 19:22:20 +06:00
|
|
|
QString str1 = theStr.section('-', 0, 0, QString::SectionSkipEmpty);
|
|
|
|
QString str2 = theStr.section('-', 1, 1, QString::SectionSkipEmpty);
|
|
|
|
theId1 = str1.toInt(&ok1);
|
|
|
|
theId2 = str2.toInt(&ok2);
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
return ok1 & ok2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : ~SMESHGUI_SingleEditDlg()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Destructor
|
|
|
|
//=======================================================================
|
|
|
|
SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : Init()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Init dialog fields, connect signals and slots, show dialog
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_SingleEditDlg::Init()
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
2004-12-01 15:48:31 +05:00
|
|
|
myBusy = false;
|
|
|
|
myActor = 0;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
// main buttons
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
|
2013-02-28 21:07:35 +06:00
|
|
|
connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject()));
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
|
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()));
|
2013-02-28 21:07:35 +06:00
|
|
|
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myEdge, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myOkBtn->setEnabled(false);
|
|
|
|
myApplyBtn->setEnabled(false);
|
|
|
|
setEnabled(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// set selection mode
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(EdgeOfCellSelection);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
onSelectionDone();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : onOk()
|
|
|
|
// Purpose : SLOT called when "Ok" button pressed.
|
2004-12-01 15:48:31 +05:00
|
|
|
// Assign filters VTK viewer and close dialog
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_SingleEditDlg::onOk()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (onApply())
|
2013-02-28 21:07:35 +06:00
|
|
|
reject();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2013-02-28 21:07:35 +06:00
|
|
|
// name : reject()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : SLOT called when "Close" button pressed. Close dialog
|
|
|
|
//=======================================================================
|
2013-02-28 21:07:35 +06:00
|
|
|
void SMESHGUI_SingleEditDlg::reject()
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(ActorSelection);
|
2005-11-23 17:08:49 +05:00
|
|
|
//mySelectionMgr->clearSelected();
|
2005-06-07 19:22:20 +06:00
|
|
|
disconnect(mySelectionMgr, 0, this, 0);
|
|
|
|
disconnect(mySMESHGUI, 0, this, 0);
|
|
|
|
mySMESHGUI->ResetState();
|
2013-02-28 21:07:35 +06:00
|
|
|
QDialog::reject();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : onHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_SingleEditDlg::onHelp()
|
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
|
|
|
if (app)
|
|
|
|
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
2009-02-17 10:27:49 +05:00
|
|
|
QString platform;
|
2008-03-07 12:47:05 +05:00
|
|
|
#ifdef WIN32
|
2009-02-17 10:27:49 +05:00
|
|
|
platform = "winapplication";
|
2008-03-07 12:47:05 +05:00
|
|
|
#else
|
2009-02-17 10:27:49 +05:00
|
|
|
platform = "application";
|
2008-03-07 12:47:05 +05:00
|
|
|
#endif
|
2009-02-17 10:27:49 +05:00
|
|
|
SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
|
2012-08-09 16:03:55 +06:00
|
|
|
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser",
|
|
|
|
platform)).
|
|
|
|
arg(myHelpFileName));
|
2006-05-06 14:51:48 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
//function : findTriangles()
|
2004-12-01 15:48:31 +05:00
|
|
|
//purpose : find triangles sharing theNode1-theNode2 link
|
2005-06-07 19:22:20 +06:00
|
|
|
// THIS IS A PIECE OF SMESH_MeshEditor.cxx
|
|
|
|
// TO DO: make it available in SMDS for ex.
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
static bool findTriangles (const SMDS_MeshNode * theNode1,
|
|
|
|
const SMDS_MeshNode * theNode2,
|
|
|
|
const SMDS_MeshElement*& theTria1,
|
|
|
|
const SMDS_MeshElement*& theTria2)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!theNode1 || !theNode2) return false;
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
theTria1 = theTria2 = 0;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
std::set< const SMDS_MeshElement* > emap;
|
2004-12-01 15:48:31 +05:00
|
|
|
SMDS_ElemIteratorPtr it = theNode1->GetInverseElementIterator();
|
|
|
|
while (it->more()) {
|
|
|
|
const SMDS_MeshElement* elem = it->next();
|
2013-05-17 18:26:06 +06:00
|
|
|
if (elem->GetType() == SMDSAbs_Face && elem->NbCornerNodes() == 3)
|
2005-06-07 19:22:20 +06:00
|
|
|
emap.insert(elem);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
it = theNode2->GetInverseElementIterator();
|
|
|
|
while (it->more()) {
|
|
|
|
const SMDS_MeshElement* elem = it->next();
|
2005-06-07 19:22:20 +06:00
|
|
|
if (elem->GetType() == SMDSAbs_Face &&
|
|
|
|
emap.find(elem) != emap.end())
|
2012-08-09 16:03:55 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (theTria1) {
|
2004-12-01 15:48:31 +05:00
|
|
|
theTria2 = elem;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
theTria1 = elem;
|
|
|
|
}
|
2012-08-09 16:03:55 +06:00
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
return (theTria1 && theTria2);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
//function : onTextChange()
|
|
|
|
//purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_SingleEditDlg::onTextChange (const QString& theNewText)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBusy) return;
|
2009-02-17 10:27:49 +05:00
|
|
|
BusyLocker lock(myBusy);
|
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
|
|
|
|
|
|
|
// hilight entered edge
|
2005-06-07 19:22:20 +06:00
|
|
|
if(myActor){
|
|
|
|
if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aList.Append(anIO);
|
|
|
|
mySelectionMgr->setSelectedObjects(aList,false);
|
|
|
|
|
|
|
|
TColStd_IndexedMapOfInteger selectedIndices;
|
|
|
|
TColStd_MapOfInteger newIndices;
|
|
|
|
mySelector->GetIndex(anIO,selectedIndices);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
int id1, id2;
|
|
|
|
if ( !getNodeIds(myEdge->text(), id1, id2) )
|
2012-08-09 16:03:55 +06:00
|
|
|
return;
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
const SMDS_MeshNode* aNode1 = aMesh->FindNode( id1 );
|
|
|
|
const SMDS_MeshNode* aNode2 = aMesh->FindNode( id2 );
|
|
|
|
|
|
|
|
if ( !aNode1 || !aNode2 || aNode1 == aNode2 )
|
2012-08-09 16:03:55 +06:00
|
|
|
return;
|
2009-02-17 10:27:49 +05:00
|
|
|
|
|
|
|
// find a triangle and an edge index
|
|
|
|
const SMDS_MeshElement* tria1;
|
|
|
|
const SMDS_MeshElement* tria2;
|
|
|
|
|
|
|
|
if ( findTriangles(aNode1,aNode2,tria1,tria2) )
|
2005-10-05 13:43:58 +06:00
|
|
|
{
|
2012-08-09 16:03:55 +06:00
|
|
|
newIndices.Add(tria1->GetID());
|
|
|
|
|
|
|
|
const SMDS_MeshNode* a3Nodes[3];
|
|
|
|
SMDS_ElemIteratorPtr it;
|
|
|
|
int edgeInd = 2, i;
|
|
|
|
for (i = 0, it = tria1->nodesIterator(); it->more(); i++) {
|
|
|
|
a3Nodes[ i ] = static_cast<const SMDS_MeshNode*>(it->next());
|
|
|
|
if (i > 0 && ( (a3Nodes[ i ] == aNode1 && a3Nodes[ i - 1] == aNode2) ||
|
|
|
|
(a3Nodes[ i ] == aNode2 && a3Nodes[ i - 1] == aNode1) ) ) {
|
|
|
|
edgeInd = i - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
newIndices.Add(-edgeInd-1);
|
|
|
|
|
|
|
|
myOkBtn->setEnabled(true);
|
|
|
|
myApplyBtn->setEnabled(true);
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
2005-10-05 13:43:58 +06:00
|
|
|
mySelector->AddOrRemoveIndex(anIO,newIndices, false);
|
2005-10-05 12:32:47 +06:00
|
|
|
SMESH::GetViewWindow(mySMESHGUI)->highlight( anIO, true, true );
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : onSelectionDone()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : SLOT called when selection changed
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_SingleEditDlg::onSelectionDone()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (myBusy) return;
|
2009-02-17 10:27:49 +05:00
|
|
|
BusyLocker lock(myBusy);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
int anId1 = 0, anId2 = 0;
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
myOkBtn->setEnabled(false);
|
|
|
|
myApplyBtn->setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->selectedObjects(aList);
|
|
|
|
|
|
|
|
if (aList.Extent() != 1) {
|
2004-12-01 15:48:31 +05:00
|
|
|
myEdge->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
Handle(SALOME_InteractiveObject) anIO = aList.First();
|
|
|
|
myActor = SMESH::FindActorByEntry(anIO->getEntry());
|
|
|
|
if(myActor){
|
|
|
|
TVisualObjPtr aVisualObj = myActor->GetObject();
|
2005-10-05 12:32:47 +06:00
|
|
|
if(SMDS_Mesh* aMesh = aVisualObj->GetMesh())
|
|
|
|
{
|
|
|
|
const SMDS_MeshElement* tria[2];
|
|
|
|
if( SMESH::GetEdgeNodes( mySelector, aVisualObj, anId1, anId2 ) >= 1 &&
|
2012-08-09 16:03:55 +06:00
|
|
|
findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1] ) )
|
2005-10-05 12:32:47 +06:00
|
|
|
{
|
2012-08-09 16:03:55 +06:00
|
|
|
QString aText = QString("%1-%2").arg(anId1).arg(anId2);
|
|
|
|
myEdge->setText(aText);
|
|
|
|
|
|
|
|
myOkBtn->setEnabled(true);
|
|
|
|
myApplyBtn->setEnabled(true);
|
2005-10-05 12:32:47 +06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-09 16:03:55 +06:00
|
|
|
myEdge->clear();
|
2005-06-07 19:22:20 +06:00
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : onDeactivate()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : SLOT called when dialog must be deativated
|
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_SingleEditDlg::onDeactivate()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
setEnabled(false);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// name : enterEvent()
|
2004-12-01 15:48:31 +05:00
|
|
|
// Purpose : Event filter
|
|
|
|
//=======================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
void SMESHGUI_SingleEditDlg::enterEvent (QEvent*)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!isEnabled()) {
|
|
|
|
mySMESHGUI->EmitSignalDeactivateDialog();
|
2005-07-01 16:42:32 +06:00
|
|
|
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
|
|
|
|
aViewWindow->SetSelectionMode(EdgeOfCellSelection);
|
2005-06-07 19:22:20 +06:00
|
|
|
setEnabled(true);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2005-06-07 19:22:20 +06:00
|
|
|
// function : onApply()
|
2004-12-01 15:48:31 +05:00
|
|
|
// purpose : SLOT. Called when apply button is pressed
|
|
|
|
//=================================================================================
|
|
|
|
bool SMESHGUI_SingleEditDlg::onApply()
|
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (mySMESHGUI->isActiveStudyLocked())
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
// verify validity of input data
|
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
|
|
|
// get mesh, actor and nodes
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
mySelectionMgr->selectedObjects(aList);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());
|
|
|
|
|
|
|
|
if (aMesh->_is_nil()) {
|
2009-02-17 10:27:49 +05:00
|
|
|
SUIT_MessageBox::information(SMESH::GetDesktop(mySMESHGUI),
|
2012-08-09 16:03:55 +06:00
|
|
|
tr("SMESH_ERROR"),
|
|
|
|
tr("SMESHG_NO_MESH"));
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
|
|
|
|
int anId1= 0, anId2 = 0;
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aMeshEditor->_is_nil() || !getNodeIds(myEdge->text(), anId1, anId2))
|
2004-12-01 15:48:31 +05:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// perform operation
|
2005-06-07 19:22:20 +06:00
|
|
|
bool aResult = process(aMeshEditor.in(), anId1, anId2);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
// update actor
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aResult) {
|
2005-10-07 11:15:29 +06:00
|
|
|
mySelector->ClearIndex();
|
2005-06-07 19:22:20 +06:00
|
|
|
mySelectionMgr->setSelectedObjects(aList, false);
|
2005-10-12 13:44:47 +06:00
|
|
|
onSelectionDone();
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESH::UpdateView();
|
2012-08-09 16:03:55 +06:00
|
|
|
SMESHGUI::Modified();
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : keyPressEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void SMESHGUI_SingleEditDlg::keyPressEvent( QKeyEvent* e )
|
|
|
|
{
|
|
|
|
QDialog::keyPressEvent( e );
|
|
|
|
if ( e->isAccepted() )
|
|
|
|
return;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
if ( e->key() == Qt::Key_F1 ) {
|
|
|
|
e->accept();
|
|
|
|
onHelp();
|
|
|
|
}
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_TrianglesInversionDlg
|
|
|
|
* Description : Inversion of the diagonal of a pseudo-quadrangle formed by
|
|
|
|
* 2 neighboring triangles with 1 common edge
|
|
|
|
*/
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_TrianglesInversionDlg
|
2009-02-17 10:27:49 +05:00
|
|
|
::SMESHGUI_TrianglesInversionDlg(SMESHGUI* theModule)
|
|
|
|
: SMESHGUI_SingleEditDlg(theModule)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setWindowTitle(tr("CAPTION"));
|
2008-03-07 12:47:05 +05:00
|
|
|
myHelpFileName = "diagonal_inversion_of_elements_page.html";
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
SMESHGUI_TrianglesInversionDlg::~SMESHGUI_TrianglesInversionDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_TrianglesInversionDlg::process (SMESH::SMESH_MeshEditor_ptr theMeshEditor,
|
|
|
|
const int theId1, const int theId2)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
return theMeshEditor->InverseDiag(theId1, theId2);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
/*!
|
|
|
|
* Class : SMESHGUI_UnionOfTwoTrianglesDlg
|
|
|
|
* Description : Construction of a quadrangle by deletion of the
|
|
|
|
* common border of 2 neighboring triangles
|
|
|
|
*/
|
2004-12-01 15:48:31 +05:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_UnionOfTwoTrianglesDlg
|
2009-02-17 10:27:49 +05:00
|
|
|
::SMESHGUI_UnionOfTwoTrianglesDlg(SMESHGUI* theModule)
|
|
|
|
: SMESHGUI_SingleEditDlg(theModule)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setWindowTitle(tr("CAPTION"));
|
2008-03-07 12:47:05 +05:00
|
|
|
myHelpFileName = "uniting_two_triangles_page.html";
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
SMESHGUI_UnionOfTwoTrianglesDlg::~SMESHGUI_UnionOfTwoTrianglesDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
bool SMESHGUI_UnionOfTwoTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theMeshEditor,
|
|
|
|
const int theId1, const int theId2)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
return theMeshEditor->DeleteDiag(theId1, theId2);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|