Skip to content

Commit d5ca275

Browse files
committed
Update networks
1 parent c16e82c commit d5ca275

File tree

4 files changed

+100
-10
lines changed

4 files changed

+100
-10
lines changed

src/ExampleNets/regression/AddKnownstoLinearSystem.srn5

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</module>
3333
<state>
3434
<stateMap>
35-
<count>4</count>
35+
<count>5</count>
3636
<item_version>0</item_version>
3737
<item class_id="8" tracking_level="0" version="0">
3838
<first class_id="9" tracking_level="0" version="0">
@@ -70,6 +70,18 @@
7070
</value>
7171
</second>
7272
</item>
73+
<item>
74+
<first>
75+
<name>OutputMatrixType</name>
76+
</first>
77+
<second>
78+
<name>OutputMatrixType</name>
79+
<value>
80+
<which>2</which>
81+
<value>sparse</value>
82+
</value>
83+
</second>
84+
</item>
7385
<item>
7486
<first>
7587
<name>PassThrough</name>

src/ExampleNets/regression/ConvertMatrixType.srn5

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</module>
1717
<state class_id="6" tracking_level="0" version="0">
1818
<stateMap class_id="7" tracking_level="0" version="0">
19-
<count>4</count>
19+
<count>5</count>
2020
<item_version>0</item_version>
2121
<item class_id="8" tracking_level="0" version="0">
2222
<first class_id="9" tracking_level="0" version="0">
@@ -54,6 +54,18 @@
5454
</value>
5555
</second>
5656
</item>
57+
<item>
58+
<first>
59+
<name>OutputMatrixType</name>
60+
</first>
61+
<second>
62+
<name>OutputMatrixType</name>
63+
<value>
64+
<which>2</which>
65+
<value>sparse</value>
66+
</value>
67+
</second>
68+
</item>
5769
<item>
5870
<first>
5971
<name>PassThrough</name>
@@ -80,7 +92,7 @@
8092
</module>
8193
<state>
8294
<stateMap>
83-
<count>4</count>
95+
<count>5</count>
8496
<item_version>0</item_version>
8597
<item>
8698
<first>
@@ -118,6 +130,18 @@
118130
</value>
119131
</second>
120132
</item>
133+
<item>
134+
<first>
135+
<name>OutputMatrixType</name>
136+
</first>
137+
<second>
138+
<name>OutputMatrixType</name>
139+
<value>
140+
<which>2</which>
141+
<value>passThrough</value>
142+
</value>
143+
</second>
144+
</item>
121145
<item>
122146
<first>
123147
<name>PassThrough</name>
@@ -144,7 +168,7 @@
144168
</module>
145169
<state>
146170
<stateMap>
147-
<count>4</count>
171+
<count>5</count>
148172
<item_version>0</item_version>
149173
<item>
150174
<first>
@@ -182,6 +206,18 @@
182206
</value>
183207
</second>
184208
</item>
209+
<item>
210+
<first>
211+
<name>OutputMatrixType</name>
212+
</first>
213+
<second>
214+
<name>OutputMatrixType</name>
215+
<value>
216+
<which>2</which>
217+
<value>column</value>
218+
</value>
219+
</second>
220+
</item>
185221
<item>
186222
<first>
187223
<name>PassThrough</name>
@@ -208,7 +244,7 @@
208244
</module>
209245
<state>
210246
<stateMap>
211-
<count>4</count>
247+
<count>5</count>
212248
<item_version>0</item_version>
213249
<item>
214250
<first>
@@ -246,6 +282,18 @@
246282
</value>
247283
</second>
248284
</item>
285+
<item>
286+
<first>
287+
<name>OutputMatrixType</name>
288+
</first>
289+
<second>
290+
<name>OutputMatrixType</name>
291+
<value>
292+
<which>2</which>
293+
<value>dense</value>
294+
</value>
295+
</second>
296+
</item>
249297
<item>
250298
<first>
251299
<name>PassThrough</name>
@@ -503,8 +551,8 @@
503551
<item>
504552
<first>ConvertMatrixType:35</first>
505553
<second>
506-
<first>-541</first>
507-
<second>-624</second>
554+
<first>-532</first>
555+
<second>-608</second>
508556
</second>
509557
</item>
510558
<item>

src/ExampleNets/regression/sliceMatrix.srn5

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</module>
1717
<state class_id="6" tracking_level="0" version="0">
1818
<stateMap class_id="7" tracking_level="0" version="0">
19-
<count>4</count>
19+
<count>5</count>
2020
<item_version>0</item_version>
2121
<item class_id="8" tracking_level="0" version="0">
2222
<first class_id="9" tracking_level="0" version="0">
@@ -54,6 +54,18 @@
5454
</value>
5555
</second>
5656
</item>
57+
<item>
58+
<first>
59+
<name>OutputMatrixType</name>
60+
</first>
61+
<second>
62+
<name>OutputMatrixType</name>
63+
<value>
64+
<which>2</which>
65+
<value>sparse</value>
66+
</value>
67+
</second>
68+
</item>
5769
<item>
5870
<first>
5971
<name>PassThrough</name>

src/Interface/Modules/Base/ModuleDialogGeneric.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
using namespace SCIRun::Gui;
3535
using namespace SCIRun::Dataflow::Networks;
3636
using namespace SCIRun::Core::Algorithms;
37+
using namespace SCIRun::Core::Logging;
3738

3839
ModuleDialogGeneric::ModuleDialogGeneric(SCIRun::Dataflow::Networks::ModuleStateHandle state, QWidget* parent) : QDialog(parent),
3940
state_(state),
@@ -177,8 +178,12 @@ class ComboBoxSlotManager : public WidgetSlotManager
177178
const GuiStringTranslationMap& stringMap) :
178179
WidgetSlotManager(state, dialog), stateKey_(stateKey), comboBox_(comboBox), stringMap_(stringMap)
179180
{
180-
fromLabelConverter_ = [this](const QString& qstr) { return stringMap_.left.at(qstr.toStdString()); };
181-
toLabelConverter_ = [this](const std::string& str) { return QString::fromStdString(stringMap_.right.at(str)); };
181+
if (stringMap_.empty())
182+
{
183+
THROW_INVALID_ARGUMENT("empty combo box string mapping");
184+
}
185+
fromLabelConverter_ = [this](const QString& qstr) { return findOrFirst(stringMap_.left, qstr.toStdString()); };
186+
toLabelConverter_ = [this](const std::string& str) { return QString::fromStdString(findOrFirst(stringMap_.right, str)); };
182187
connect(comboBox, SIGNAL(activated(const QString&)), this, SLOT(push()));
183188
}
184189
virtual void pull() override
@@ -206,6 +211,19 @@ class ComboBoxSlotManager : public WidgetSlotManager
206211
FromQStringConverter fromLabelConverter_;
207212
ToQStringConverter toLabelConverter_;
208213
GuiStringTranslationMap stringMap_;
214+
215+
template <class Map>
216+
std::string findOrFirst(const Map& map, const std::string& key) const
217+
{
218+
auto iter = map.find(key);
219+
if (iter == map.end())
220+
{
221+
const std::string& first = map.begin()->second;
222+
Log::get() << NOTICE << "Combo box state error: key not found (" << key << "), replacing with " << first << std::endl;
223+
return first;
224+
}
225+
return iter->second;
226+
}
209227
};
210228

211229
void ModuleDialogGeneric::addComboBoxManager(QComboBox* comboBox, const AlgorithmParameterName& stateKey)

0 commit comments

Comments
 (0)