Skip to content

Commit 9d856e3

Browse files
committed
Merge branch 'master' into ConvertMatricesToMesh
2 parents 0834f39 + 16074e0 commit 9d856e3

22 files changed

+1789
-72
lines changed

src/Core/Python/PythonInterpreter.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,11 @@ void PythonInterpreter::initialize(bool needProgramName, const std::string& comm
421421
initialize_eventhandler(commandLine, libPath);
422422

423423
{
424-
auto out = [](const std::string& s) { std::cout << "[PYTHON] " << s << std::endl; };
424+
auto out = [](const std::string& s)
425+
{
426+
if (!std::all_of(s.begin(), s.end(), isspace))
427+
std::cout << "[PYTHON] " << s << std::endl;
428+
};
425429
auto error = [](const std::string& s) { std::cerr << "[PYTHON ERROR] " << s << std::endl; };
426430
output_signal_.connect(out);
427431
error_signal_.connect(error);
@@ -556,7 +560,7 @@ void PythonInterpreter::run_script( const std::string& script )
556560
//}
557561

558562
// Output the script to the console
559-
this->output_signal_( "Running script ...\n" );
563+
//this->output_signal_( "Running script ...\n" );
560564

561565
// Clear any previous Python errors.
562566
PyErr_Clear();

src/Dataflow/Engine/Controller/PythonImpl.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ namespace
190190
return port_ ? port_->get_portname() : "<Null>";
191191
}
192192

193+
virtual std::string id() const override
194+
{
195+
return port_ ? port_->id().toString() : "<Null>";
196+
}
197+
193198
virtual std::string type() const override
194199
{
195200
return port_ ? port_->get_typename() : "<Null>";
@@ -287,6 +292,10 @@ namespace
287292
if (port != ports_.end())
288293
return *port;
289294

295+
port = std::find_if(ports_.begin(), ports_.end(), [&](boost::shared_ptr<PyPortImpl> p) { return name == p->id(); });
296+
if (port != ports_.end())
297+
return *port;
298+
290299
std::cerr << "Could not find port with name " << name << " on module " << modId_.id_ << std::endl;
291300
PyErr_SetObject(PyExc_KeyError, boost::python::object(name).ptr());
292301
throw boost::python::error_already_set();

src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace SCIRun
7979
public:
8080
virtual ~PyPort() {}
8181
virtual std::string name() const = 0;
82+
virtual std::string id() const = 0;
8283
virtual std::string type() const = 0;
8384
virtual bool isInput() const = 0;
8485
virtual void connect(const PyPort& other) const = 0;

src/Dataflow/Engine/Python/SCIRunPythonModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ BOOST_PYTHON_MODULE(SCIRunPythonAPI)
102102
boost::python::def("scirun_get_module_input_object_by_index", &NetworkEditorPythonAPI::scirun_get_module_input_object_index);
103103
boost::python::def("scirun_get_module_input_value_by_index", &NetworkEditorPythonAPI::scirun_get_module_input_value_index);
104104

105-
//boost::python::def("scirun_set_module_input_value", &NetworkEditorPythonAPI::scirun_set_module_input_value);
106-
//boost::python::def("scirun_set_module_input_value_by_index", &NetworkEditorPythonAPI::scirun_set_module_input_value_by_index);
107-
108105
boost::python::def("scirun_save_network", &NetworkEditorPythonAPI::saveNetwork);
109106
boost::python::def("scirun_load_network", &NetworkEditorPythonAPI::loadNetwork);
110107
boost::python::def("scirun_import_network", &NetworkEditorPythonAPI::importNetwork);

insertVoltagSource.srn5 renamed to src/ExampleNets/developer/insertVoltagSource.srn5

File renamed without changes.

src/ExampleNets/pythonScripts/firstPythonInterfaceTest.srn5

Lines changed: 169 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</second>
3636
</item>
3737
<item>
38-
<first>InterfaceWithPython:0</first>
38+
<first>InterfaceWithPython:1</first>
3939
<second>
4040
<module>
4141
<package_name_>SCIRun</package_name_>
@@ -44,8 +44,44 @@
4444
</module>
4545
<state>
4646
<stateMap>
47-
<count>1</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>
61+
<item>
62+
<first>
63+
<name>NumberOfRetries</name>
64+
</first>
65+
<second>
66+
<name>NumberOfRetries</name>
67+
<value>
68+
<which>0</which>
69+
<value>50</value>
70+
</value>
71+
</second>
72+
</item>
73+
<item>
74+
<first>
75+
<name>PollingIntervalMilliseconds</name>
76+
</first>
77+
<second>
78+
<name>PollingIntervalMilliseconds</name>
79+
<value>
80+
<which>0</which>
81+
<value>200</value>
82+
</value>
83+
</second>
84+
</item>
4985
<item>
5086
<first>
5187
<name>PythonCode</name>
@@ -54,9 +90,130 @@
5490
<name>PythonCode</name>
5591
<value>
5692
<which>2</which>
57-
<value>s = scirun_get_module_input_value_by_index(&quot;InterfaceWithPython:0&quot;, 2)
58-
s2 = s + &quot; from python!&quot;
59-
scirun_set_module_transient_state(&quot;InterfaceWithPython:0&quot;, &quot;PythonObject&quot;, s2)</value>
93+
<value>s = scirun_get_module_input_value_by_index(&quot;InterfaceWithPython:1&quot;, 2)
94+
str2 = s + &quot; from python!&quot;
95+
s1 = str2
96+
</value>
97+
</value>
98+
</second>
99+
</item>
100+
<item>
101+
<first>
102+
<name>PythonField1Name</name>
103+
</first>
104+
<second>
105+
<name>PythonField1Name</name>
106+
<value>
107+
<which>2</which>
108+
<value>f1</value>
109+
</value>
110+
</second>
111+
</item>
112+
<item>
113+
<first>
114+
<name>PythonField2Name</name>
115+
</first>
116+
<second>
117+
<name>PythonField2Name</name>
118+
<value>
119+
<which>2</which>
120+
<value>f2</value>
121+
</value>
122+
</second>
123+
</item>
124+
<item>
125+
<first>
126+
<name>PythonField3Name</name>
127+
</first>
128+
<second>
129+
<name>PythonField3Name</name>
130+
<value>
131+
<which>2</which>
132+
<value>f3</value>
133+
</value>
134+
</second>
135+
</item>
136+
<item>
137+
<first>
138+
<name>PythonMatrix1Name</name>
139+
</first>
140+
<second>
141+
<name>PythonMatrix1Name</name>
142+
<value>
143+
<which>2</which>
144+
<value>m1</value>
145+
</value>
146+
</second>
147+
</item>
148+
<item>
149+
<first>
150+
<name>PythonMatrix2Name</name>
151+
</first>
152+
<second>
153+
<name>PythonMatrix2Name</name>
154+
<value>
155+
<which>2</which>
156+
<value>m2</value>
157+
</value>
158+
</second>
159+
</item>
160+
<item>
161+
<first>
162+
<name>PythonMatrix3Name</name>
163+
</first>
164+
<second>
165+
<name>PythonMatrix3Name</name>
166+
<value>
167+
<which>2</which>
168+
<value>m3</value>
169+
</value>
170+
</second>
171+
</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>
184+
<item>
185+
<first>
186+
<name>PythonString1Name</name>
187+
</first>
188+
<second>
189+
<name>PythonString1Name</name>
190+
<value>
191+
<which>2</which>
192+
<value>s1</value>
193+
</value>
194+
</second>
195+
</item>
196+
<item>
197+
<first>
198+
<name>PythonString2Name</name>
199+
</first>
200+
<second>
201+
<name>PythonString2Name</name>
202+
<value>
203+
<which>2</which>
204+
<value>s2</value>
205+
</value>
206+
</second>
207+
</item>
208+
<item>
209+
<first>
210+
<name>PythonString3Name</name>
211+
</first>
212+
<second>
213+
<name>PythonString3Name</name>
214+
<value>
215+
<which>2</which>
216+
<value>s3</value>
60217
</value>
61218
</second>
62219
</item>
@@ -90,16 +247,16 @@ scirun_set_module_transient_state(&quot;InterfaceWithPython:0&quot;, &quot;Pytho
90247
<name>NewString</name>
91248
<id>0</id>
92249
</port1_>
93-
<moduleId2_>InterfaceWithPython:0</moduleId2_>
250+
<moduleId2_>InterfaceWithPython:1</moduleId2_>
94251
<port2_>
95252
<name>InputString</name>
96253
<id>0</id>
97254
</port2_>
98255
</item>
99256
<item>
100-
<moduleId1_>InterfaceWithPython:0</moduleId1_>
257+
<moduleId1_>InterfaceWithPython:1</moduleId1_>
101258
<port1_>
102-
<name>PythonString</name>
259+
<name>PythonString1</name>
103260
<id>0</id>
104261
</port1_>
105262
<moduleId2_>ReportStringInfo:0</moduleId2_>
@@ -121,10 +278,10 @@ scirun_set_module_transient_state(&quot;InterfaceWithPython:0&quot;, &quot;Pytho
121278
</second>
122279
</item>
123280
<item>
124-
<first>InterfaceWithPython:0</first>
281+
<first>InterfaceWithPython:1</first>
125282
<second>
126-
<first>-2.43000000000000000e+002</first>
127-
<second>-3.57000000000000000e+002</second>
283+
<first>-1.52000000000000000e+002</first>
284+
<second>-3.80000000000000000e+002</second>
128285
</second>
129286
</item>
130287
<item>
@@ -151,7 +308,7 @@ scirun_set_module_transient_state(&quot;InterfaceWithPython:0&quot;, &quot;Pytho
151308
<second>0</second>
152309
</item>
153310
<item>
154-
<first>InterfaceWithPython:0</first>
311+
<first>InterfaceWithPython:1</first>
155312
<second>0</second>
156313
</item>
157314
<item>

0 commit comments

Comments
 (0)