Skip to content

Commit 4c65037

Browse files
committed
Clean up
1 parent bb60a20 commit 4c65037

File tree

5 files changed

+113
-28
lines changed

5 files changed

+113
-28
lines changed

src/ExampleNets/pythonScripts/firstPythonInterfaceTest.srn5

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,20 @@
4444
</module>
4545
<state>
4646
<stateMap>
47-
<count>12</count>
47+
<count>14</count>
4848
<item_version>0</item_version>
49+
<item>
50+
<first>
51+
<name>InputString:0</name>
52+
</first>
53+
<second>
54+
<name>InputString:0</name>
55+
<value>
56+
<which>2</which>
57+
<value>StringInput1</value>
58+
</value>
59+
</second>
60+
</item>
4961
<item>
5062
<first>
5163
<name>NumberOfRetries</name>
@@ -80,9 +92,8 @@
8092
<which>2</which>
8193
<value>s = scirun_get_module_input_value_by_index(&quot;InterfaceWithPython:1&quot;, 2)
8294
str2 = s + &quot; from python!&quot;
83-
scirun_set_module_state(&quot;InterfaceWithPython:1&quot;, &quot;PythonString1Name&quot;, &quot;s1&quot;)
8495
s1 = str2
85-
#scirun_set_module_transient_state(&quot;InterfaceWithPython:1&quot;, &quot;s1&quot;, str2)</value>
96+
</value>
8697
</value>
8798
</second>
8899
</item>
@@ -158,6 +169,18 @@ s1 = str2
158169
</value>
159170
</second>
160171
</item>
172+
<item>
173+
<first>
174+
<name>PythonOutputString1Name</name>
175+
</first>
176+
<second>
177+
<name>PythonOutputString1Name</name>
178+
<value>
179+
<which>2</which>
180+
<value>s1</value>
181+
</value>
182+
</second>
183+
</item>
161184
<item>
162185
<first>
163186
<name>PythonString1Name</name>

src/ExampleNets/pythonScripts/outputNameTable.srn5

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,67 @@
44
<networkFile class_id="0" tracking_level="0" version="3">
55
<networkInfo class_id="1" tracking_level="0" version="0">
66
<modules class_id="2" tracking_level="0" version="0">
7-
<count>2</count>
7+
<count>3</count>
88
<item_version>0</item_version>
99
<item class_id="3" tracking_level="0" version="0">
10-
<first>InterfaceWithPython:0</first>
10+
<first>CreateString:3</first>
1111
<second class_id="4" tracking_level="0" version="0">
1212
<module class_id="5" tracking_level="0" version="0">
1313
<package_name_>SCIRun</package_name_>
14-
<category_name_>Python</category_name_>
15-
<module_name_>InterfaceWithPython</module_name_>
14+
<category_name_>String</category_name_>
15+
<module_name_>CreateString</module_name_>
1616
</module>
1717
<state class_id="6" tracking_level="0" version="0">
1818
<stateMap class_id="7" tracking_level="0" version="0">
19-
<count>12</count>
19+
<count>1</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">
23-
<name>NumberOfRetries</name>
23+
<name>InputString</name>
2424
</first>
2525
<second class_id="10" tracking_level="0" version="0">
26-
<name>NumberOfRetries</name>
26+
<name>InputString</name>
2727
<value class_id="11" tracking_level="0" version="0">
28+
<which>2</which>
29+
<value></value>
30+
</value>
31+
</second>
32+
</item>
33+
</stateMap>
34+
</state>
35+
</second>
36+
</item>
37+
<item>
38+
<first>InterfaceWithPython:0</first>
39+
<second>
40+
<module>
41+
<package_name_>SCIRun</package_name_>
42+
<category_name_>Python</category_name_>
43+
<module_name_>InterfaceWithPython</module_name_>
44+
</module>
45+
<state>
46+
<stateMap>
47+
<count>13</count>
48+
<item_version>0</item_version>
49+
<item>
50+
<first>
51+
<name>InputString:0</name>
52+
</first>
53+
<second>
54+
<name>InputString:0</name>
55+
<value>
56+
<which>2</which>
57+
<value>StringInput1</value>
58+
</value>
59+
</second>
60+
</item>
61+
<item>
62+
<first>
63+
<name>NumberOfRetries</name>
64+
</first>
65+
<second>
66+
<name>NumberOfRetries</name>
67+
<value>
2868
<which>0</which>
2969
<value>50</value>
3070
</value>
@@ -185,11 +225,23 @@ q = &quot;asd&quot;</value>
185225
</item>
186226
</modules>
187227
<connections class_id="12" tracking_level="0" version="0">
188-
<count>1</count>
228+
<count>2</count>
189229
<item_version>0</item_version>
190230
<item class_id="13" tracking_level="0" version="0">
191-
<moduleId1_>InterfaceWithPython:0</moduleId1_>
231+
<moduleId1_>CreateString:3</moduleId1_>
192232
<port1_ class_id="14" tracking_level="0" version="0">
233+
<name>NewString</name>
234+
<id>0</id>
235+
</port1_>
236+
<moduleId2_>InterfaceWithPython:0</moduleId2_>
237+
<port2_>
238+
<name>InputString</name>
239+
<id>0</id>
240+
</port2_>
241+
</item>
242+
<item>
243+
<moduleId1_>InterfaceWithPython:0</moduleId1_>
244+
<port1_>
193245
<name>PythonString1</name>
194246
<id>0</id>
195247
</port1_>
@@ -202,11 +254,18 @@ q = &quot;asd&quot;</value>
202254
</connections>
203255
</networkInfo>
204256
<modulePositions class_id="15" tracking_level="0" version="0">
205-
<count>2</count>
257+
<count>3</count>
206258
<item_version>0</item_version>
207259
<item class_id="16" tracking_level="0" version="0">
208-
<first>InterfaceWithPython:0</first>
260+
<first>CreateString:3</first>
209261
<second class_id="17" tracking_level="0" version="0">
262+
<first>1.30000000000000000e+001</first>
263+
<second>-1.24000000000000000e+002</second>
264+
</second>
265+
</item>
266+
<item>
267+
<first>InterfaceWithPython:0</first>
268+
<second>
210269
<first>4.95000000000000000e+001</first>
211270
<second>1.40000000000000000e+001</second>
212271
</second>
@@ -228,9 +287,13 @@ q = &quot;asd&quot;</value>
228287
<item_version>0</item_version>
229288
</connectionNotes>
230289
<moduleTags class_id="19" tracking_level="0" version="0">
231-
<count>2</count>
290+
<count>3</count>
232291
<item_version>0</item_version>
233292
<item class_id="20" tracking_level="0" version="0">
293+
<first>CreateString:3</first>
294+
<second>0</second>
295+
</item>
296+
<item>
234297
<first>InterfaceWithPython:0</first>
235298
<second>0</second>
236299
</item>

src/Interface/Application/ModuleWidget.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void ModuleWidget::createInputPorts(const SCIRun::Dataflow::Networks::ModuleInfo
732732
ports_->addPort(w);
733733
++i;
734734
if (dialog_)
735-
dialog_->updateFromPortChange(i, port->id().name);
735+
dialog_->updateFromPortChange(i, port->id().toString());
736736
}
737737
}
738738

@@ -1151,10 +1151,10 @@ void ModuleWidget::updateDockWidgetProperties(bool isFloating)
11511151
}
11521152
}
11531153

1154-
void ModuleWidget::updateDialogWithPortCount(const std::string& portName)
1154+
void ModuleWidget::updateDialogWithPortCount(const std::string& portId)
11551155
{
11561156
if (dialog_)
1157-
dialog_->updateFromPortChange(numInputPorts(), portName);
1157+
dialog_->updateFromPortChange(numInputPorts(), portId);
11581158
}
11591159

11601160
Qt::DockWidgetArea ModuleWidget::allowedDockArea() const

src/Interface/Modules/Python/InterfaceWithPythonDialog.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void InterfaceWithPythonDialog::setupOutputTableCells()
9494

9595
void InterfaceWithPythonDialog::updateFromPortChange(int numPorts, const std::string& portId)
9696
{
97-
// qDebug() << "updateFromPortChange " << numPorts << QString::fromStdString(portId);
97+
//qDebug() << "updateFromPortChange " << numPorts << QString::fromStdString(portId);
9898
inputVariableNamesTableWidget_->blockSignals(true);
9999

100100
handleInputTableWidgetRowChange(numPorts, portId, "Matrix", numMatrixPorts_);
@@ -119,17 +119,14 @@ void InterfaceWithPythonDialog::handleInputTableWidgetRowChange(int numPorts, co
119119
auto newRowCount = portCount - 1;
120120
if (newRowCount > 0)
121121
{
122-
//matrixInputTableWidget_->setRowCount(newRowCount);
123-
//int index = newRowCount - 1;
124122
//note: the incoming portId is the port that was just added, not connected to. we assume the connected port
125123
// is one index less.
126-
// std::cout << "REGEX: " << "Input" + type + "\\:(.+)" << std::endl;
124+
//std::cout << "REGEX: " << "Input" + type + "\\:(.+)" << std::endl;
127125
boost::regex portIdRegex("Input" + type + "\\:(.+)");
128126
boost::smatch what;
127+
//std::cout << "MATCHING WITH: " << portId << std::endl;
129128
regex_match(portId, what, portIdRegex);
130-
//std::cout << "REGEX OUTPUT: " << what[1] << std::endl;
131129
const int connectedPortNumber = boost::lexical_cast<int>(what[1]) - 1;
132-
//std::cout << "AFTER REGEX OUTPUT: " << connectedPortNumber << std::endl;
133130
const std::string connectedPortId = "Input" + type + ":" + boost::lexical_cast<std::string>(connectedPortNumber);
134131

135132
const int rowCount = numPorts - 3;
@@ -138,8 +135,10 @@ void InterfaceWithPythonDialog::handleInputTableWidgetRowChange(int numPorts, co
138135
inputVariableNamesTableWidget_->setItem(rowCount - 1, 1, new QTableWidgetItem(QString::fromStdString(type)));
139136

140137
auto lineEdit = new QLineEdit;
141-
lineEdit->setText("input" + QString::fromStdString(type) + QString::number(connectedPortNumber));
142-
addLineEditManager(lineEdit, Core::Algorithms::Name(connectedPortId));
138+
lineEdit->setText(QString::fromStdString(type) + "Input" + QString::number(connectedPortNumber + 1));
139+
Core::Algorithms::Name name(connectedPortId);
140+
addLineEditManager(lineEdit, name);
141+
state_->setValue(name, lineEdit->text().toStdString());
143142
inputVariableNamesTableWidget_->setCellWidget(rowCount - 1, 2, lineEdit);
144143
}
145144
}

src/Modules/Python/InterfaceWithPython.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ std::vector<AlgorithmParameterName> InterfaceWithPython::outputNameParameters()
101101

102102
std::string InterfaceWithPython::convertInputOutputSyntax(const std::string& code) const
103103
{
104-
auto varsToCheck = outputNameParameters();
104+
auto outputVarsToCheck = outputNameParameters();
105105

106-
for (const auto& var : varsToCheck)
106+
for (const auto& var : outputVarsToCheck)
107107
{
108108
auto varName = get_state()->getValue(var).toString();
109109

0 commit comments

Comments
 (0)