]> SALOME platform Git repositories - tools/ydefx.git/blob - src/gui/QuickConfig.cxx
Salome HOME
Add resource widget.
[tools/ydefx.git] / src / gui / QuickConfig.cxx
1 // Copyright (C) 2019  EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "QuickConfig.hxx"
20
21 QuickConfigWidget::QuickConfigWidget(ydefx::JobParametersProxy& model,
22                                      QWidget* parent)
23 : QScrollArea(parent)
24 , _model(model)
25 {
26   QWidget* mainWidget = new QWidget();
27   QVBoxLayout *mainLayout = new QVBoxLayout();
28   mainWidget->setLayout(mainLayout);
29   
30   QHBoxLayout *hLayout = new QHBoxLayout();
31   QComboBox* resourcesComboBox = new QComboBox;
32   std::list<std::string> resources = _model.AvailableResources();
33   for(const std::string& it : resources)
34     resourcesComboBox->addItem(QString(it.c_str()));
35   resourcesComboBox->setCurrentIndex(
36                     resourcesComboBox->findText(model.resource_name().c_str()));
37   connect(resourcesComboBox, SIGNAL(currentIndexChanged( const QString &)),
38           this, SLOT(updateResource( const QString &)));
39
40   QLabel * resourcesLabel = new QLabel(tr("Computing resource:"));
41   hLayout->addWidget(resourcesLabel);
42   hLayout->addWidget(resourcesComboBox);
43   mainLayout->addLayout(hLayout);
44   
45   QLabel *nb_branchesLabel = new QLabel(tr("Number of parallel evaluations:"));
46   QSpinBox *nb_branchesEdit = new QSpinBox();
47   nb_branchesEdit->setRange(1, 10000);
48   nb_branchesEdit->setValue(_model.nb_branches());
49   hLayout = new QHBoxLayout();
50   hLayout->addWidget(nb_branchesLabel);
51   hLayout->addWidget(nb_branchesEdit);
52   mainLayout->addLayout(hLayout);
53   connect(this, SIGNAL(defaultNbBranches(int)),
54           nb_branchesEdit, SLOT(setValue(int)));
55   connect(nb_branchesEdit, SIGNAL(valueChanged(int)),
56           this, SLOT(updateNbBranches(int)));
57
58   mainLayout->addStretch();
59   setWidget(mainWidget);
60   setWidgetResizable (true);
61 }
62
63 QuickConfigWidget::~QuickConfigWidget()
64 {
65 }
66
67 void QuickConfigWidget::updateResource(const QString& value)
68 {
69   _model.configureResource(value.toStdString());
70   emit defaultNbBranches(_model.nb_branches());
71   emit defaultWorkingDir(_model.work_directory().c_str());
72   emit defaultWcKey(_model.wckey().c_str());
73 }
74
75 void QuickConfigWidget::updateNbBranches(int value)
76 {
77   _model.nb_branches(value);
78   emit defaultNbBranches(value);
79 }