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
|
|
|
|
//
|
|
|
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
2003-07-10 19:18:22 +06:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESHGUI_aParameterDlg.cxx
|
|
|
|
// Author : Nicolas REJNERI
|
|
|
|
// Module : SMESH
|
2003-05-19 20:07:00 +06:00
|
|
|
// $Header$
|
|
|
|
|
|
|
|
#include "SMESHGUI_aParameterDlg.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESHGUI_aParameter.h"
|
2003-05-19 20:07:00 +06:00
|
|
|
#include "SMESHGUI.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMESHGUI_SpinBox.h"
|
2005-06-08 16:45:19 +06:00
|
|
|
#include "SMESHGUI_Utils.h"
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
#include "SUIT_Tools.h"
|
|
|
|
#include "SUIT_Desktop.h"
|
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
// QT Includes
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qspinbox.h>
|
|
|
|
#include <qvalidator.h>
|
2005-01-28 13:57:30 +05:00
|
|
|
#include <qtextedit.h>
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
using namespace std;
|
2003-05-19 20:07:00 +06:00
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//======================================================================================
|
2003-05-19 20:07:00 +06:00
|
|
|
// function : SMESHGUI_aParameterDlg()
|
|
|
|
//
|
|
|
|
// The dialog will by default be modal, unless you set 'modal' to
|
|
|
|
// false when constructing dialog
|
2005-06-07 19:22:20 +06:00
|
|
|
//
|
|
|
|
//======================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg
|
2005-06-08 16:45:19 +06:00
|
|
|
( SMESHGUI* theModule,
|
|
|
|
std::list<SMESHGUI_aParameterPtr> params,
|
2004-12-01 15:48:31 +05:00
|
|
|
QString title,
|
2005-06-07 19:22:20 +06:00
|
|
|
bool modal)
|
2005-06-08 16:45:19 +06:00
|
|
|
: QDialog( SMESH::GetDesktop( theModule ), "MyParameterDialog", modal, WStyle_Customize |
|
|
|
|
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
|
|
|
|
myParamList(params),
|
|
|
|
mySMESHGUI(theModule)
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
|
|
|
/* creating widgets */
|
2004-12-01 15:48:31 +05:00
|
|
|
init();
|
2003-05-19 20:07:00 +06:00
|
|
|
/* title */
|
2005-06-07 19:22:20 +06:00
|
|
|
setCaption(title);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
/* Move widget on the botton right corner of main widget */
|
2005-06-08 16:45:19 +06:00
|
|
|
SUIT_Tools::centerWidget(this, SMESH::GetDesktop( theModule ) );
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//======================================================================================
|
2003-05-19 20:07:00 +06:00
|
|
|
// function : SMESHGUI_aParameterDlg::init()
|
|
|
|
// purpose : creates dialog's layout
|
2005-06-07 19:22:20 +06:00
|
|
|
//======================================================================================
|
2004-12-01 15:48:31 +05:00
|
|
|
void SMESHGUI_aParameterDlg::init()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
setSizeGripEnabled(TRUE);
|
|
|
|
|
|
|
|
QGridLayout* topLayout = new QGridLayout(this);
|
|
|
|
topLayout->setMargin(11); topLayout->setSpacing(6);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
/***************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
QGroupBox* GroupC1 = new QGroupBox(this, "GroupC1");
|
|
|
|
GroupC1->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupC1->layout()->setSpacing(0);
|
|
|
|
GroupC1->layout()->setMargin(0);
|
|
|
|
QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout());
|
|
|
|
GroupC1Layout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupC1Layout->setSpacing(6);
|
|
|
|
GroupC1Layout->setMargin(11);
|
2004-12-01 15:48:31 +05:00
|
|
|
/* Spin boxes with labels */
|
|
|
|
list<SMESHGUI_aParameterPtr>::iterator paramIt = myParamList.begin();
|
2005-06-07 19:22:20 +06:00
|
|
|
for (int row = 0; paramIt != myParamList.end(); paramIt++ , row++)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
|
|
|
SMESHGUI_aParameterPtr param = (*paramIt);
|
2005-06-07 19:22:20 +06:00
|
|
|
QLabel * label = new QLabel(GroupC1, "TextLabel");
|
|
|
|
GroupC1Layout->addWidget(label, row, 0);
|
|
|
|
label->setText(param->Label());
|
2005-01-28 13:57:30 +05:00
|
|
|
QWidget* aSpinWidget = 0;
|
2005-06-07 19:22:20 +06:00
|
|
|
switch (param->GetType()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
case SMESHGUI_aParameter::DOUBLE: {
|
2005-06-07 19:22:20 +06:00
|
|
|
SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox(GroupC1);
|
2004-12-01 15:48:31 +05:00
|
|
|
aSpinWidget = spin;
|
2005-06-07 19:22:20 +06:00
|
|
|
spin->setPrecision(12);
|
2004-12-01 15:48:31 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SMESHGUI_aParameter::INT: {
|
2005-06-07 19:22:20 +06:00
|
|
|
QSpinBox* spin = new QSpinBox(GroupC1);
|
2004-12-01 15:48:31 +05:00
|
|
|
aSpinWidget = spin;
|
|
|
|
break;
|
|
|
|
}
|
2005-01-28 13:57:30 +05:00
|
|
|
case SMESHGUI_aParameter::TEXT: {
|
2005-06-07 19:22:20 +06:00
|
|
|
QTextEdit* edit = new QTextEdit(GroupC1);
|
|
|
|
edit->setWordWrap(QTextEdit::NoWrap);
|
|
|
|
edit->setTextFormat(Qt::PlainText);
|
2005-01-28 13:57:30 +05:00
|
|
|
aSpinWidget = edit;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-01 15:48:31 +05:00
|
|
|
default:;
|
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
if (aSpinWidget) {
|
|
|
|
GroupC1Layout->addWidget(aSpinWidget, row, 1);
|
|
|
|
aSpinWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
aSpinWidget->setMinimumSize(150, 0);
|
|
|
|
param->InitializeWidget(aSpinWidget);
|
|
|
|
mySpinList.push_back(aSpinWidget);
|
2005-01-28 13:57:30 +05:00
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
2005-06-07 19:22:20 +06:00
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
/***************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
|
|
|
|
GroupButtons->setColumnLayout(0, Qt::Vertical);
|
|
|
|
GroupButtons->layout()->setSpacing(0);
|
|
|
|
GroupButtons->layout()->setMargin(0);
|
|
|
|
QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
|
|
|
|
GroupButtonsLayout->setAlignment(Qt::AlignTop);
|
|
|
|
GroupButtonsLayout->setSpacing(6);
|
|
|
|
GroupButtonsLayout->setMargin(11);
|
2003-05-19 20:07:00 +06:00
|
|
|
/* Ok button */
|
2005-06-07 19:22:20 +06:00
|
|
|
myButtonOk = new QPushButton(GroupButtons, "buttonOk");
|
|
|
|
myButtonOk->setText(tr("SMESH_BUT_OK"));
|
|
|
|
myButtonOk->setAutoDefault(TRUE);
|
|
|
|
myButtonOk->setDefault(TRUE);
|
|
|
|
GroupButtonsLayout->addWidget(myButtonOk, 0, 0);
|
2003-05-19 20:07:00 +06:00
|
|
|
/* add spacer between buttons */
|
2005-06-07 19:22:20 +06:00
|
|
|
GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
|
2003-05-19 20:07:00 +06:00
|
|
|
/* Cancel button */
|
2005-06-07 19:22:20 +06:00
|
|
|
myButtonCancel = new QPushButton(GroupButtons, "buttonCancel");
|
|
|
|
myButtonCancel->setText(tr("SMESH_BUT_CANCEL"));
|
|
|
|
myButtonCancel->setAutoDefault(TRUE);
|
|
|
|
GroupButtonsLayout->addWidget(myButtonCancel, 0, 2);
|
|
|
|
|
2003-05-19 20:07:00 +06:00
|
|
|
/***************************************************************/
|
2005-06-07 19:22:20 +06:00
|
|
|
topLayout->addWidget(GroupC1, 0, 0);
|
|
|
|
topLayout->addWidget(GroupButtons, 1, 0);
|
2003-05-19 20:07:00 +06:00
|
|
|
|
|
|
|
/* signals and slots connections */
|
2005-06-07 19:22:20 +06:00
|
|
|
connect(myButtonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
|
|
|
connect(myButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2005-06-07 19:22:20 +06:00
|
|
|
//======================================================================================
|
2003-05-19 20:07:00 +06:00
|
|
|
// function : ~SMESHGUI_aParameterDlg()
|
|
|
|
// purpose : Destructor
|
2005-06-07 19:22:20 +06:00
|
|
|
//======================================================================================
|
|
|
|
SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
//function : ClickOnOk
|
2005-06-07 19:22:20 +06:00
|
|
|
//purpose :
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
void SMESHGUI_aParameterDlg::ClickOnOk()
|
2003-05-19 20:07:00 +06:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!mySMESHGUI->isActiveStudyLocked()) {
|
|
|
|
list<SMESHGUI_aParameterPtr>::iterator paramIt = myParamList.begin();
|
|
|
|
list<QWidget*>::iterator widgetIt = mySpinList.begin();
|
|
|
|
for (;
|
2004-12-01 15:48:31 +05:00
|
|
|
paramIt != myParamList.end() && widgetIt != mySpinList.end();
|
2005-06-07 19:22:20 +06:00
|
|
|
paramIt++ , widgetIt++)
|
|
|
|
(*paramIt)->TakeValue(*widgetIt);
|
2004-12-01 15:48:31 +05:00
|
|
|
|
|
|
|
accept();
|
|
|
|
}
|
2003-05-19 20:07:00 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
//=======================================================================
|
|
|
|
// function : Parameters()
|
|
|
|
// purpose : return a list of parameters from a dialog box
|
|
|
|
//=======================================================================
|
2005-06-08 16:45:19 +06:00
|
|
|
bool SMESHGUI_aParameterDlg::Parameters( SMESHGUI* theModule,
|
|
|
|
list<SMESHGUI_aParameterPtr> params,
|
2005-06-07 19:22:20 +06:00
|
|
|
const char *aTitle)
|
2004-12-01 15:48:31 +05:00
|
|
|
{
|
2005-06-07 19:22:20 +06:00
|
|
|
if (!params.empty()) {
|
2004-12-01 15:48:31 +05:00
|
|
|
SMESHGUI_aParameterDlg *Dialog =
|
2005-06-08 16:45:19 +06:00
|
|
|
new SMESHGUI_aParameterDlg( theModule, params, aTitle, TRUE);
|
2004-12-01 15:48:31 +05:00
|
|
|
return (Dialog->exec() == QDialog::Accepted);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|