Skip to content

Commit e4aa56d

Browse files
committed
Closes #1495
1 parent 7cd3a6d commit e4aa56d

File tree

4 files changed

+43
-37
lines changed

4 files changed

+43
-37
lines changed

src/Interface/Modules/Base/ModuleDialogGeneric.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,45 @@ void ModuleDialogGeneric::addLineEditManager(QLineEdit* lineEdit, const Algorith
436436
addWidgetSlotManager(boost::make_shared<LineEditSlotManager>(state_, *this, stateKey, lineEdit));
437437
}
438438

439+
class TabSlotManager : public WidgetSlotManager
440+
{
441+
public:
442+
TabSlotManager(ModuleStateHandle state, ModuleDialogGeneric& dialog, const AlgorithmParameterName& stateKey, QTabWidget* tabWidget) :
443+
WidgetSlotManager(state, dialog, tabWidget, stateKey), stateKey_(stateKey), tabWidget_(tabWidget)
444+
{
445+
connect(tabWidget_, SIGNAL(currentChanged(int)), this, SLOT(push()));
446+
}
447+
virtual void pull() override
448+
{
449+
auto newValue = QString::fromStdString(state_->getValue(stateKey_).toString());
450+
if (newValue != tabWidget_->tabText(tabWidget_->currentIndex()))
451+
{
452+
for (int i = 0; i < tabWidget_->count(); ++i)
453+
{
454+
if (tabWidget_->tabText(i) == newValue)
455+
{
456+
tabWidget_->setCurrentIndex(i);
457+
LOG_DEBUG("In new version of pull code for LineEdit: " << newValue.toStdString());
458+
return;
459+
}
460+
}
461+
}
462+
}
463+
virtual void pushImpl() override
464+
{
465+
LOG_DEBUG("In new version of push code for QTabWidget: " << tabWidget_->tabText(tabWidget_->currentIndex()).toStdString());
466+
state_->setValue(stateKey_, tabWidget_->tabText(tabWidget_->currentIndex()).toStdString());
467+
}
468+
private:
469+
AlgorithmParameterName stateKey_;
470+
QTabWidget* tabWidget_;
471+
};
472+
473+
void ModuleDialogGeneric::addTabManager(QTabWidget* tab, const AlgorithmParameterName& stateKey)
474+
{
475+
addWidgetSlotManager(boost::make_shared<TabSlotManager>(state_, *this, stateKey, tab));
476+
}
477+
439478
class DoubleLineEditSlotManager : public WidgetSlotManager
440479
{
441480
public:

src/Interface/Modules/Base/ModuleDialogGeneric.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ namespace Gui {
141141
void addDynamicLabelManager(QLabel* label, const Core::Algorithms::AlgorithmParameterName& stateKey);
142142
void addRadioButtonGroupManager(std::initializer_list<QRadioButton*> radioButtons, const Core::Algorithms::AlgorithmParameterName& stateKey);
143143
void addSliderManager(QSlider* slider, const Core::Algorithms::AlgorithmParameterName& stateKey);
144+
void addTabManager(QTabWidget* tab, const Core::Algorithms::AlgorithmParameterName& stateKey);
144145
void removeManager(const Core::Algorithms::AlgorithmParameterName& stateKey);
145146

146147
using TableWidgetMaker = std::function<QTableWidgetItem*()>;

src/Interface/Modules/Fields/ExtractSimpleIsosurfaceDialog.cc

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <Interface/Modules/Fields/ExtractSimpleIsosurfaceDialog.h>
3030
#include <Core/Algorithms/Legacy/Fields/MeshDerivatives/ExtractSimpleIsosurfaceAlgo.h>
3131
#include <Dataflow/Network/ModuleStateInterface.h>
32-
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
3332

3433
using namespace SCIRun::Gui;
3534
using namespace SCIRun::Dataflow::Networks;
@@ -47,35 +46,5 @@ ExtractSimpleIsosurfaceDialog::ExtractSimpleIsosurfaceDialog(const std::string&
4746
addSpinBoxManager(quantitySpinBox_, Parameters::QuantityOfIsovalues);
4847
addTextEditManager(isovalListFromQuantityTextEdit_, Parameters::IsovalueListString);
4948
WidgetStyleMixin::tabStyle(tabWidget);
50-
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateIsoMethod(int)));
51-
}
52-
53-
void ExtractSimpleIsosurfaceDialog::pullSpecial()
54-
{
55-
auto method = state_->getValue(Parameters::IsovalueChoice).toString();
56-
if (method == "Single")
57-
tabWidget->setCurrentIndex(0);
58-
else if (method == "List")
59-
tabWidget->setCurrentIndex(1);
60-
else if (method == "Quantity")
61-
tabWidget->setCurrentIndex(2);
62-
}
63-
64-
void ExtractSimpleIsosurfaceDialog::updateIsoMethod(int tab)
65-
{
66-
if (!pulling_)
67-
{
68-
switch (tab)
69-
{
70-
case 0:
71-
state_->setValue(Parameters::IsovalueChoice, std::string("Single"));
72-
break;
73-
case 1:
74-
state_->setValue(Parameters::IsovalueChoice, std::string("List"));
75-
break;
76-
case 2:
77-
state_->setValue(Parameters::IsovalueChoice, std::string("Quantity"));
78-
break;
79-
}
80-
}
49+
addTabManager(tabWidget, Parameters::IsovalueChoice);
8150
}

src/Interface/Modules/Fields/ExtractSimpleIsosurfaceDialog.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ class SCISHARE ExtractSimpleIsosurfaceDialog : public ModuleDialogGeneric,
4343

4444
public:
4545
ExtractSimpleIsosurfaceDialog(const std::string& name,
46-
SCIRun::Dataflow::Networks::ModuleStateHandle state,
47-
QWidget* parent = 0);
48-
virtual void pullSpecial() override;
49-
private Q_SLOTS:
50-
void updateIsoMethod(int tab);
46+
Dataflow::Networks::ModuleStateHandle state,
47+
QWidget* parent = nullptr);
5148
};
5249

5350
}

0 commit comments

Comments
 (0)