-// SMESH SMESHGUI : GUI for SMESH component
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 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.
//
-// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-//
-//
-// File : SMESHGUI_MeshPatternDlg.cxx
-// Author : Sergey LITONIN
-// Module : SMESH
+// SMESH SMESHGUI : GUI for SMESH component
+// File : SMESHGUI_MeshPatternDlg.cxx
+// Author : Sergey LITONIN, Open CASCADE S.A.S.
+// SMESH includes
+//
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI.h"
-#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_CreatePatternDlg.h"
#include "SMESHGUI_PatternWidget.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_PatternUtils.h"
#include "SMESHGUI_GEOMGenUtils.h"
-#include "SMESH_Actor.h"
-#include "SMESH_ActorUtils.h"
-#include "SMESH_NumberFilter.hxx"
+#include <SMESH_Actor.h>
+#include <SMESH_ActorUtils.h>
+#include <SMESH_NumberFilter.hxx>
-#include "SMDS_Mesh.hxx"
-#include "SMDS_MeshElement.hxx"
+#include <SMDS_Mesh.hxx>
+#include <SMDS_MeshElement.hxx>
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_Desktop.h"
-#include "SUIT_FileDlg.h"
+// SALOME GUI includes
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+#include <SUIT_Session.h>
+#include <SUIT_MessageBox.h>
-#include "SalomeApp_SelectionMgr.h"
-#include "SalomeApp_Tools.h"
-#include "SalomeApp_Study.h"
+#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Tools.h>
+#include <LightApp_Application.h>
+#include <SalomeApp_IntSpinBox.h>
-#include "SALOMEDS_SObject.hxx"
+#include <SALOME_ListIO.hxx>
-#include "SALOME_ListIO.hxx"
-#include "SVTK_Selection.h"
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+#include <VTKViewer_CellLocationsArray.h>
-#include "SVTK_ViewModel.h"
-#include "SVTK_Selector.h"
-#include "SVTK_ViewWindow.h"
+// SALOME KERNEL includes
+#include <SALOMEDS_SObject.hxx>
-// OCCT Includes
+// OCCT includes
#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_IndexedMapOfInteger.hxx>
-
-// QT Includes
-#include <qframe.h>
-#include <qlayout.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qradiobutton.h>
-#include <qcheckbox.h>
-#include <qbuttongroup.h>
-#include <qmessagebox.h>
-#include <qcstring.h>
-#include <qspinbox.h>
-#include <qvaluelist.h>
-#include <qdir.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qfiledialog.h>
-
-// VTK Includes
-#include <vtkCell.h>
+
+// Qt includes
+#include <QFrame>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QGridLayout>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QGroupBox>
+#include <QLabel>
+#include <QRadioButton>
+#include <QCheckBox>
+#include <QButtonGroup>
+#include <QList>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileInfo>
+#include <QFile>
+#include <QKeyEvent>
+
+// VTK includes
#include <vtkIdList.h>
-#include <vtkIntArray.h>
#include <vtkCellArray.h>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
-#define SPACING 5
-#define MARGIN 10
+#define SPACING 6
+#define MARGIN 11
/*!
* Class : SMESHGUI_MeshPatternDlg
// name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg
// Purpose : Constructor
//=======================================================================
-SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule,
- const char* theName )
- : QDialog( SMESH::GetDesktop( theModule ), theName, false, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myBusy(false),
- mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule )
+ : QDialog( SMESH::GetDesktop( theModule ) ),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myBusy( false ),
+ myCreationDlg( 0 )
{
- setCaption(tr("CAPTION"));
-
- QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING);
+ setModal( false );
+ setWindowTitle( tr( "CAPTION" ) );
- QFrame* aMainFrame = createMainFrame (this);
- QFrame* aBtnFrame = createButtonFrame(this);
+ QVBoxLayout* aDlgLay = new QVBoxLayout( this );
+ aDlgLay->setMargin( MARGIN );
+ aDlgLay->setSpacing( SPACING );
- aDlgLay->addWidget(aMainFrame);
- aDlgLay->addWidget(aBtnFrame);
+ QWidget* aMainFrame = createMainFrame ( this );
+ QWidget* aBtnFrame = createButtonFrame( this );
- aDlgLay->setStretchFactor(aMainFrame, 1);
+ aDlgLay->addWidget( aMainFrame );
+ aDlgLay->addWidget( aBtnFrame );
- myCreationDlg = 0;
+ aDlgLay->setStretchFactor( aMainFrame, 1 );
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
-
+
+ myHelpFileName = "pattern_mapping_page.html";
+
Init();
}
// name : SMESHGUI_MeshPatternDlg::createMainFrame
// Purpose : Create frame containing dialog's input fields
//=======================================================================
-QFrame* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent)
+QWidget* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent)
{
SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
- QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
- QPixmap icon2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_2d")));
- QPixmap icon3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_3d")));
- QPixmap iconOpen ( mgr->loadPixmap("STD", tr("ICON_FILE_OPEN")));
+ QPixmap iconSlct ( mgr->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
+ QPixmap icon2d ( mgr->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) );
+ QPixmap icon3d ( mgr->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) );
+ QPixmap iconOpen ( mgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ) );
+
+ QPixmap iconSample2d ( mgr->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );
+ QPixmap iconSample3d ( mgr->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_3D" ) ) );
- QPixmap iconSample2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D")));
- QPixmap iconSample3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_3D")));
+ QWidget* aMainGrp = new QWidget( theParent );
- QGroupBox* aMainGrp = new QGroupBox (1, Qt::Horizontal, theParent);
- aMainGrp->setFrameStyle(QFrame::NoFrame);
- aMainGrp->setInsideMargin(0);
+ QVBoxLayout* aMainGrpLayout = new QVBoxLayout( aMainGrp );
+ aMainGrpLayout->setMargin( 0 );
+ aMainGrpLayout->setSpacing( SPACING );
// Pattern type group
- myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp);
- mySwitch2d = new QRadioButton (myTypeGrp);
- mySwitch3d = new QRadioButton (myTypeGrp);
- mySwitch2d->setPixmap(icon2d);
- mySwitch3d->setPixmap(icon3d);
- myTypeGrp->insert(mySwitch2d, Type_2d);
- myTypeGrp->insert(mySwitch3d, Type_3d);
+ QGroupBox* aTypeGrp = new QGroupBox( tr( "PATTERN_TYPE" ), aMainGrp );
+ QHBoxLayout* aTypeGrpLayout = new QHBoxLayout( aTypeGrp );
+ aTypeGrpLayout->setMargin( MARGIN );
+ aTypeGrpLayout->setSpacing( SPACING );
+
+ mySwitch2d = new QRadioButton( aTypeGrp );
+ mySwitch3d = new QRadioButton( aTypeGrp );
+ mySwitch2d->setIcon( icon2d );
+ mySwitch3d->setIcon( icon3d );
+
+ myTypeGrp = new QButtonGroup( aMainGrp );
+ myTypeGrp->addButton( mySwitch2d, Type_2d );
+ myTypeGrp->addButton( mySwitch3d, Type_3d );
+
+ // ... layout widgets
+
+ aTypeGrpLayout->addWidget( mySwitch2d );
+ aTypeGrpLayout->addWidget( mySwitch3d );
// Mesh group
- QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, tr("SMESH_MESH"), aMainGrp);
- new QLabel(tr("SMESH_MESH"), aMeshGrp);
- mySelBtn[ Mesh ] = new QPushButton(aMeshGrp);
- mySelBtn[ Mesh ]->setPixmap(iconSlct);
- mySelEdit[ Mesh ] = new QLineEdit(aMeshGrp);
- mySelEdit[ Mesh ]->setReadOnly(true);
+ QGroupBox* aMeshGrp = new QGroupBox( tr( "SMESH_MESH" ), aMainGrp );
+ QHBoxLayout* aMeshGrpLayout = new QHBoxLayout( aMeshGrp );
+ aMeshGrpLayout->setMargin( MARGIN );
+ aMeshGrpLayout->setSpacing( SPACING );
+
+ QLabel* aMeshLab = new QLabel( tr( "SMESH_MESH" ), aMeshGrp );
+ mySelBtn[ Mesh ] = new QPushButton( aMeshGrp );
+ mySelBtn[ Mesh ]->setIcon( iconSlct );
+ mySelEdit[ Mesh ] = new QLineEdit( aMeshGrp );
+ mySelEdit[ Mesh ]->setReadOnly( true );
+
+ // ... layout widgets
+
+ aMeshGrpLayout->addWidget( aMeshLab );
+ aMeshGrpLayout->addWidget( mySelBtn[ Mesh ] );
+ aMeshGrpLayout->addWidget( mySelEdit[ Mesh ] );
// Pattern group
- QGroupBox* aPatGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp);
+ QGroupBox* aPatGrp = new QGroupBox( tr( "PATTERN" ), aMainGrp );
+ QGridLayout* aPatGrpLayout = new QGridLayout( aPatGrp );
+ aPatGrpLayout->setMargin( MARGIN );
+ aPatGrpLayout->setSpacing( SPACING );
+
+ // ... Pattern name
+
+ QLabel* aNameLab = new QLabel( tr( "PATTERN" ), aPatGrp );
+ myName = new QLineEdit( aPatGrp );
+ myName->setReadOnly( true );
+ myOpenBtn = new QPushButton( aPatGrp );
+ myOpenBtn->setIcon( iconOpen );
+ myNewBtn = new QPushButton( tr( "NEW" ), aPatGrp );
+
+ // ... Mode selection check box
+ myRefine = new QCheckBox( tr( "REFINE" ), aPatGrp );
+
+ // ... selection widgets for Apply to geom mode
+ myGeomGrp = new QFrame( aPatGrp );
+ myGeomGrp->setFrameStyle( QFrame::NoFrame );
+ QGridLayout* myGeomGrpLayout = new QGridLayout( myGeomGrp );
+ myGeomGrpLayout->setMargin( 0 );
+ myGeomGrpLayout->setSpacing( SPACING );
+
+ for ( int i = Object; i <= Vertex2; i++ ) {
+ mySelLbl[ i ] = new QLabel( myGeomGrp );
+ mySelBtn[ i ] = new QPushButton( myGeomGrp );
+ mySelBtn[ i ]->setIcon( iconSlct );
+ mySelEdit[ i ] = new QLineEdit( myGeomGrp );
+ mySelEdit[ i ]->setReadOnly( true );
+ myGeomGrpLayout->addWidget( mySelLbl[ i ], i - Object, 0 );
+ myGeomGrpLayout->addWidget( mySelBtn[ i ], i - Object, 1 );
+ myGeomGrpLayout->addWidget( mySelEdit[ i ], i - Object, 2 );
+ }
- // pattern name
- QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, aPatGrp);
- aNameGrp->setFrameStyle(QFrame::NoFrame);
- aNameGrp->setInsideMargin(0);
- new QLabel(tr("PATTERN"), aNameGrp);
- myName = new QLineEdit(aNameGrp);
- myName->setReadOnly(true);
- myOpenBtn = new QPushButton(aNameGrp);
- myOpenBtn->setPixmap(iconOpen);
- myNewBtn = new QPushButton(tr("NEW"), aNameGrp);
+ // ... Widgets for refinement of existing mesh elements
- // Mode selection check box
- myRefine = new QCheckBox(tr("REFINE"), aPatGrp);
+ myRefineGrp = new QFrame( aPatGrp );
+ myRefineGrp->setFrameStyle( QFrame::NoFrame );
- // selection widgets for Apply to geom mode
- myGeomGrp = new QGroupBox(3, Qt::Horizontal, aPatGrp);
- myGeomGrp->setFrameStyle(QFrame::NoFrame);
- myGeomGrp->setInsideMargin(0);
+ QGridLayout* myRefineGrpLayout = new QGridLayout( myRefineGrp );
+ myRefineGrpLayout->setMargin( 0 );
+ myRefineGrpLayout->setSpacing( SPACING );
- for (int i = Object; i <= Vertex2; i++)
- {
- mySelLbl[ i ] = new QLabel(myGeomGrp);
- mySelBtn[ i ] = new QPushButton(myGeomGrp);
- mySelBtn[ i ]->setPixmap(iconSlct);
- mySelEdit[ i ] = new QLineEdit(myGeomGrp);
- mySelEdit[ i ]->setReadOnly(true);
- }
+ mySelLbl[ Ids ] = new QLabel( myRefineGrp );
+ mySelBtn[ Ids ] = new QPushButton( myRefineGrp );
+ mySelBtn[ Ids ]->setIcon( iconSlct );
+ mySelEdit[ Ids ] = new QLineEdit( myRefineGrp );
+
+ QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp );
+ myNode1 = new SalomeApp_IntSpinBox( myRefineGrp );
+ myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp );
+ myNode2 = new SalomeApp_IntSpinBox( myRefineGrp );
+
+ myRefineGrpLayout->addWidget( mySelLbl[ Ids ], 0, 0 );
+ myRefineGrpLayout->addWidget( mySelBtn[ Ids ], 0, 1 );
+ myRefineGrpLayout->addWidget( mySelEdit[ Ids ], 0, 2 );
+ myRefineGrpLayout->addWidget( aNodeLbl, 1, 0 );
+ myRefineGrpLayout->addWidget( myNode1, 1, 1, 1, 2 );
+ myRefineGrpLayout->addWidget( myNode2Lbl, 2, 0 );
+ myRefineGrpLayout->addWidget( myNode2, 2, 1, 1, 2 );
- // Widgets for refinement of existing mesh elements
- myRefineGrp = new QFrame(aPatGrp);
- myRefineGrp->setFrameStyle(QFrame::NoFrame);
- QGridLayout* aRefGrid = new QGridLayout(myRefineGrp, 3, 3, 0, 5);
-
- mySelLbl[ Ids ] = new QLabel(myRefineGrp);
- mySelBtn[ Ids ] = new QPushButton(myRefineGrp);
- mySelBtn[ Ids ]->setPixmap(iconSlct);
- mySelEdit[ Ids ] = new QLineEdit(myRefineGrp);
-
- QLabel* aNodeLbl = new QLabel(tr("NODE_1"), myRefineGrp);
- myNode1 = new QSpinBox(myRefineGrp);
- myNode2Lbl = new QLabel(tr("NODE_2"), myRefineGrp);
- myNode2 = new QSpinBox(myRefineGrp);
-
- aRefGrid->addWidget(mySelLbl [ Ids ], 0, 0);
- aRefGrid->addWidget(mySelBtn [ Ids ], 0, 1);
- aRefGrid->addWidget(mySelEdit[ Ids ], 0, 2);
- aRefGrid->addWidget(aNodeLbl, 1, 0);
- aRefGrid->addMultiCellWidget(myNode1, 1, 1, 1, 2);
- aRefGrid->addWidget(myNode2Lbl, 2, 0);
- aRefGrid->addMultiCellWidget(myNode2, 2, 2, 1, 2);
-
- // reverse check box
- myReverseChk = new QCheckBox(tr("REVERSE"), aPatGrp);
-
- // CreatePoly check box
+ // ... reverse check box
+ myReverseChk = new QCheckBox( tr( "REVERSE" ), aPatGrp );
+
+ // ... CreatePoly check box
myCreatePolygonsChk = new QCheckBox( tr( "CREATE_POLYGONS_NEAR_BOUNDARY" ), aPatGrp );
myCreatePolyedrsChk = new QCheckBox( tr( "CREATE_POLYEDRS_NEAR_BOUNDARY" ), aPatGrp );
- // Pictures 2d and 3d
- for (int i = 0; i < 2; i++) {
- if (i == 0) {
- myPicture2d = new SMESHGUI_PatternWidget(aPatGrp),
- myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
- } else {
- myPicture3d = new QFrame(aPatGrp),
- myPreview3d = new QLabel(myPicture3d);
- myPreview3d->setPixmap(iconSample3d);
- QGridLayout* aLay = new QGridLayout(myPicture3d, 3, 3, 0, 0);
- QSpacerItem* aSpacerH1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
- QSpacerItem* aSpacerH2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
- QSpacerItem* aSpacerV1 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
- QSpacerItem* aSpacerV2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
- aLay->addItem(aSpacerH1, 1, 0);
- aLay->addItem(aSpacerH2, 1, 2);
- aLay->addItem(aSpacerV1, 0, 1);
- aLay->addItem(aSpacerV2, 2, 1);
- aLay->addWidget(myPreview3d, 1, 1);
- }
- }
+ // ... Pictures 2d and 3d
+
+ myPicture2d = new SMESHGUI_PatternWidget( aPatGrp );
+ myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+
+ myPicture3d = new QLabel( aPatGrp );
+ myPicture3d->setPixmap( iconSample3d );
+ myPicture3d->setScaledContents( false );
+ myPicture3d->setAlignment( Qt::AlignCenter );
+ myPicture3d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
- myPreviewChk = new QCheckBox(tr("PREVIEW"), aPatGrp);
+ // ... preview check box
+
+ myPreviewChk = new QCheckBox( tr( "PREVIEW" ), aPatGrp );
+
+ // ... layout widgets
+
+ aPatGrpLayout->addWidget( aNameLab, 0, 0 );
+ aPatGrpLayout->addWidget( myName, 0, 1 );
+ aPatGrpLayout->addWidget( myOpenBtn, 0, 2 );
+ aPatGrpLayout->addWidget( myNewBtn, 0, 3 );
+ aPatGrpLayout->addWidget( myRefine, 1, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myRefine, 1, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myGeomGrp, 2, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myRefineGrp, 3, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myReverseChk, 4, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myCreatePolygonsChk, 5, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myCreatePolyedrsChk, 6, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myPicture2d, 7, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myPicture3d, 8, 0, 1, 4 );
+ aPatGrpLayout->addWidget( myPreviewChk, 9, 0, 1, 4 );
+
+ // main layout
+
+ aMainGrpLayout->addWidget( aTypeGrp );
+ aMainGrpLayout->addWidget( aMeshGrp );
+ aMainGrpLayout->addWidget( aPatGrp );
// Connect signals and slots
- connect(myTypeGrp, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
+ connect(myTypeGrp, SIGNAL(buttonClicked(int)), SLOT(onTypeChanged(int)));
connect(myOpenBtn, SIGNAL(clicked()), SLOT(onOpen()));
connect(myNewBtn, SIGNAL(clicked()), SLOT(onNew()));
// name : SMESHGUI_MeshPatternDlg::createButtonFrame
// Purpose : Create frame containing buttons
//=======================================================================
-QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent)
+QWidget* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent)
{
QFrame* aFrame = new QFrame(theParent);
aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
- myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
+ myOkBtn = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
+ myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame);
- QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
-
- QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
+ QHBoxLayout* aLay = new QHBoxLayout( aFrame );
+ aLay->setMargin( MARGIN );
+ aLay->setSpacing( SPACING );
aLay->addWidget(myOkBtn);
aLay->addWidget(myApplyBtn);
- aLay->addItem(aSpacer);
+ aLay->addSpacing( 10 );
+ aLay->addStretch();
aLay->addWidget(myCloseBtn);
+ aLay->addWidget(myHelpBtn);
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
- connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
+ connect(myCloseBtn, SIGNAL(clicked()), SLOT(reject()));
connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
+ connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp()));
return aFrame;
}
// selection and SMESHGUI
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
- connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
+ connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(reject()));
- myTypeGrp->setButton(Type_2d);
+ myTypeGrp->button(Type_2d)->setChecked(true);
onTypeChanged(Type_2d);
onModeToggled(isRefine());
updateGeometry();
- resize(minimumSize());
+ resize(100,100);
activateSelection();
onSelectionDone();
- int x, y;
- mySMESHGUI->DefineDlgPosition(this, x, y);
- this->move(x, y);
this->show();
}
//=======================================================================
bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess)
{
- QValueList<int> ids;
+ if (isRefine())
+ {
+ QString msg;
+ bool ok = true;
+ ok = myNode1->isValid( msg, theMess ) && ok;
+ if (myType == Type_3d)
+ ok = myNode2->isValid( msg, theMess ) && ok;
+ if( !ok ) {
+ if( theMess ) {
+ QString str( tr( "SMESH_INCORRECT_INPUT" ) );
+ if ( !msg.isEmpty() )
+ str += "\n" + msg;
+ SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
+ }
+ return false;
+ }
+ }
+
+ QList<int> ids;
if ((isRefine() &&
(myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 ||
- myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true))))
+ (myType == Type_3d && (getNode(true) < 0 || getNode(false) == getNode(true)))))
||
(!isRefine() &&
(myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() ||
- myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil())))
+ myGeomObj[ Vertex1 ]->_is_nil() || (myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil()))))
{
if (theMess)
- QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok);
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ tr("SMESHGUI_INVALID_PARAMETERS"));
+ return false;
+ }
+
+ if ( myName->text().isEmpty() ) {
+ if (theMess)
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ tr("SMESHGUI_INVALID_PARAMETERS"));
return false;
}
erasePreview();
if (isRefine()) { // Refining existing mesh elements
- QValueList<int> ids;
+ {
+ QStringList aParameters;
+ aParameters << myNode1->text();
+ if(myType == Type_3d )
+ aParameters << myNode2->text();
+ myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
+ }
+ QList<int> ids;
getIds(ids);
SMESH::long_array_var varIds = new SMESH::long_array();
varIds->length(ids.count());
int i = 0;
- for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
- varIds[i++] = *it;
+ for (QList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
+ varIds[i++] = *it;
myType == Type_2d
- ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
- : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
+ ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
+ : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
} else { // Applying a pattern to geometrical object
if (myType == Type_2d)
bool toCreatePolygons = myCreatePolygonsChk->isChecked();
bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked();
if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) {
- mySelectionMgr->clearSelected();
- SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
+ //mySelectionMgr->clearSelected();
bool autoUpdate = SMESHGUI::automaticUpdate();
if (!isRefine() && autoUpdate) {
- _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
- SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str());
- if (!anActor) {
- anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str());
- if (anActor) {
- SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
- SMESH::FitAll();
- }
- }
+ _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
+ SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str());
+ if (!anActor) {
+ anActor = SMESH::CreateActor(aSO->GetStudy(), aSO->GetID().c_str());
+ if (anActor) {
+ SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
+ SMESH::FitAll();
+ }
+ }
}
+ mySelectionMgr->clearSelected();
SMESH::UpdateView();
-
+ SMESHGUI::Modified();
+
mySMESHGUI->updateObjBrowser(true);
+
+ mySelEdit[ Ids ]->setText("");
+
return true;
} else {
- QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
- tr("SMESH_OPERATION_FAILED"), QMessageBox::Ok);
+ SUIT_MessageBox::information(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
return false;
}
} catch (const SALOME::SALOME_Exception& S_ex) {
void SMESHGUI_MeshPatternDlg::onOk()
{
if (onApply())
- onClose();
+ reject();
}
//=======================================================================
-// name : SMESHGUI_MeshPatternDlg::onClose
+// name : SMESHGUI_MeshPatternDlg::reject
// Purpose : SLOT called when "Close" button pressed. Close dialog
//=======================================================================
-void SMESHGUI_MeshPatternDlg::onClose()
+void SMESHGUI_MeshPatternDlg::reject()
{
mySelectionMgr->clearFilters();
SMESH::SetPickable();
disconnect(mySMESHGUI, 0, this, 0);
mySMESHGUI->ResetState();
erasePreview();
- reject();
+ QDialog::reject();
+}
+
+//=================================================================================
+// function : onHelp()
+// purpose :
+//=================================================================================
+void SMESHGUI_MeshPatternDlg::onHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
+ tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ platform)).
+ arg(myHelpFileName));
+ }
}
//=======================================================================
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
if (aList.Extent() != 1)
- return;
+ return;
// Retrieve mesh from selection
Handle(SALOME_InteractiveObject) anIO = aList.First();
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
if (aList.Extent() != 1)
- return;
+ return;
QString anIds;
if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds))
- anIds = "";
+ anIds = "";
myBusy = true;
mySelEdit[ Ids ]->setText(anIds);
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
if (aList.Extent() != 1)
- return;
+ return;
// Get geom object from selection
Handle(SALOME_InteractiveObject) anIO = aList.First();
onTextChanged(mySelEdit[Ids]->text());
}
-//=======================================================================
-// name : SMESHGUI_MeshPatternDlg::closeEvent
-// Purpose :
-//=======================================================================
-void SMESHGUI_MeshPatternDlg::closeEvent (QCloseEvent*)
-{
- onClose();
-}
-
//=======================================================================
// name : SMESHGUI_MeshPatternDlg::onSelInputChanged
// Purpose : SLOT. Called when -> button clicked.
void SMESHGUI_MeshPatternDlg::onOpen()
{
SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, true);
- aDlg->setCaption(tr("LOAD_PATTERN"));
- aDlg->setMode(QFileDialog::ExistingFile);
+ aDlg->setWindowTitle(tr("LOAD_PATTERN"));
+ aDlg->setFileMode(QFileDialog::ExistingFile);
aDlg->setFilters(prepareFilters());
- if (myName->text() != "")
- aDlg->setSelection(myName->text() + ".smp");
- QPushButton* anOkBtn = (QPushButton*)aDlg->child("OK", "QPushButton");
+ if (!myName->text().isEmpty())
+ aDlg->selectFile(myName->text() + ".smp");
+ QPushButton* anOkBtn = qFindChild<QPushButton*>( aDlg, "OK" );
if (anOkBtn != 0)
anOkBtn->setText(tr("SMESH_BUT_OK"));
if (fName.isEmpty())
return;
- if (QFileInfo(fName).extension().isEmpty())
+ if (QFileInfo(fName).suffix().isEmpty())
fName = autoExtension(fName);
fName = QDir::convertSeparators(fName);
// Read string from file
QFile aFile(fName);
- if (!aFile.open(IO_ReadOnly)) {
- QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
- tr("ERROR_OF_OPENING"), QMessageBox::Ok);
+ if (!aFile.open(QIODevice::ReadOnly)) {
+ SUIT_MessageBox::information(this, tr("SMESH_ERROR"),
+ tr("ERROR_OF_OPENING"));
return;
}
QByteArray aDataArray = aFile.readAll();
- const char* aData = aDataArray.data();
- if (aData == 0) {
- QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
- tr("ERROR_OF_READING"), QMessageBox::Ok);
+ if (aDataArray.isEmpty()) {
+ SUIT_MessageBox::information(this, tr("SMESH_ERROR"),
+ tr("ERROR_OF_READING"));
return;
}
- if (loadFromFile(aData))
- myName->setText(QFileInfo(fName).baseName());
+ if (loadFromFile(aDataArray))
+ myName->setText(QFileInfo(fName).completeBaseName());
updateWgState();
displayPreview();
{
myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern());
myName->setText(myCreationDlg->GetPatternName());
+
+ updateWgState();
displayPreview();
+
setEnabled(true);
myIsCreateDlgOpen = false;
}
return;
} else {
PointVector aPoints(pnts->length());
- QValueVector<int> aKeyPoints(keyPoints->length());
+ QVector<int> aKeyPoints(keyPoints->length());
ConnectivityVector anElemPoints(elemPoints->length());
for (int i = 0, n = pnts->length(); i < n; i++)
aKeyPoints[ i2 ] = keyPoints[ i2 ];
for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
- QValueVector<int> aVec(elemPoints[ i3 ].length());
+ QVector<int> aVec(elemPoints[ i3 ].length());
for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
// Create and display actor
vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
- aMapper->SetInput(aGrid);
+ aMapper->SetInputData(aGrid);
myPreviewActor = SALOME_Actor::New();
myPreviewActor->PickableOff();
void SMESHGUI_MeshPatternDlg::erasePreview()
{
// Erase preview in 2D viewer
- myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector());
+ myPicture2d->SetPoints(PointVector(), QVector<int>(), ConnectivityVector());
// Erase preview in 3D viewer
if (myPreviewActor == 0)
}
}
- QValueList<int> ids;
- if (!CORBA::is_nil(myPattern) && getIds(ids)) {
+ QList<int> ids;
+ if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) {
SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
if (keyPoints->length()) {
- myNode1->setEnabled(true);
- myNode2->setEnabled(true);
- myNode1->setRange(1, keyPoints->length());
- myNode2->setRange(1, keyPoints->length());
- return;
+ myNode1->setEnabled(true);
+ myNode2->setEnabled(true);
+ myNode1->setRange(1, keyPoints->length());
+ myNode2->setRange(1, keyPoints->length());
+ return;
}
}
if (myType == Type_2d)
{
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(FaceSelection);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(FaceSelection);
}
else
{
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(CellSelection);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(CellSelection);
}
}
else {
try {
SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern();
- if (!aPattern->LoadFromFile(theName.latin1()) ||
- myType == Type_2d && !aPattern->Is2D()) {
+ if (!aPattern->LoadFromFile(theName.toLatin1().data()) ||
+ (myType == Type_2d && !aPattern->Is2D())) {
SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode();
QString aMess;
if (aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr("ERR_READ_NB_POINTS");
else if (aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr("ERR_READ_BAD_KEY_POINT");
else aMess = tr("ERROR_OF_LOADING");
- QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), aMess, QMessageBox::Ok);
+ SUIT_MessageBox::information(this, tr("SMESH_ERROR"), aMess);
return false;
} else {
myPattern = aPattern;
}
} catch (const SALOME::SALOME_Exception& S_ex) {
SalomeApp_Tools::QtCatchCorbaException(S_ex);
- QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
- tr("ERROR_OF_LOADING"), QMessageBox::Ok);
- return false;
+ SUIT_MessageBox::information(this, tr("SMESH_ERROR"),
+ tr("ERROR_OF_LOADING") );
+ return false;
}
}
try {
// Get points from pattern
SMESH::point_array_var pnts;
- QValueList<int> ids;
+ QList<int> ids;
if (isRefine() && getIds(ids)) {
SMESH::long_array_var varIds = new SMESH::long_array();
varIds->length(ids.count());
int i = 0;
- for (QValueList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
- varIds[i++] = *it;
+ for (QList<int>::iterator it = ids.begin(); it != ids.end(); ++it)
+ varIds[i++] = *it;
pnts = myType == Type_2d
- ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
- : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
+ ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked())
+ : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true));
} else {
pnts = myType == Type_2d
- ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked())
+ ? myPattern->ApplyToFace (myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked())
: myPattern->ApplyTo3DBlock(myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ]);
}
else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL);
}
- vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(aNbCells);
aMesh = anActor->GetObject()->GetMesh();
if (aMesh) {
- QStringList aListId = QStringList::split(" ", theNewText, false);
-
+ QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
+
TColStd_MapOfInteger newIndices;
-
+
for (int i = 0; i < aListId.count(); i++) {
const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume))
- newIndices.Add(e->GetID());
+ newIndices.Add(e->GetID());
}
mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
}
myBusy = false;
+
+ displayPreview();
}
//=======================================================================
void SMESHGUI_MeshPatternDlg::onNodeChanged (int value)
{
if (myType == Type_3d) {
- QSpinBox* first = (QSpinBox*)sender();
- QSpinBox* second = first == myNode1 ? myNode2 : myNode1;
+ SalomeApp_IntSpinBox* first = (SalomeApp_IntSpinBox*)sender();
+ SalomeApp_IntSpinBox* second = first == myNode1 ? myNode2 : myNode1;
int secondVal = second->value();
if (secondVal == value) {
- secondVal = value == second->maxValue() ? second->minValue() : value + 1;
+ secondVal = value == second->maximum() ? second->minimum() : value + 1;
bool blocked = second->signalsBlocked();
second->blockSignals(true);
second->setValue(secondVal);
// name : getIds
// Purpose :
//=======================================================================
-bool SMESHGUI_MeshPatternDlg::getIds (QValueList<int>& ids) const
+bool SMESHGUI_MeshPatternDlg::getIds (QList<int>& ids) const
{
ids.clear();
- QStringList strIds = QStringList::split(" ", mySelEdit[Ids]->text());
+ QStringList strIds = mySelEdit[Ids]->text().split(" ", QString::SkipEmptyParts );
bool isOk;
int val;
for (QStringList::iterator it = strIds.begin(); it != strIds.end(); ++it) {
{
return second ? myNode2->value() - 1 : myNode1->value() - 1;
}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_MeshPatternDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onHelp();
+ }
+}