Skip to content

Commit 48c2acc

Browse files
committed
Fix for file loading/state hookup problem
1 parent 3f6cec2 commit 48c2acc

File tree

7 files changed

+52
-34
lines changed

7 files changed

+52
-34
lines changed

src/Dataflow/Network/Module.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
#include <Core/Thread/Mutex.h>
4747
#include <Core/Thread/Interruptible.h>
4848

49+
//TODO remove once method is extracted below
50+
#include <Dataflow/Network/Connection.h>
51+
4952
using namespace SCIRun::Dataflow::Networks;
5053
using namespace SCIRun::Engine::State;
5154
using namespace SCIRun::Core::Logging;
@@ -292,7 +295,7 @@ bool Module::do_execute() throw()
292295
{
293296
error(std::string("MODULE ERROR: std::exception caught: ") + e.what());
294297
}
295-
catch (const boost::thread_interrupted& e)
298+
catch (const boost::thread_interrupted&)
296299
{
297300
error("MODULE ERROR: execution thread interrupted by user.");
298301
threadStopValue = true;
@@ -337,6 +340,7 @@ void Module::set_state(ModuleStateHandle state)
337340
{
338341
state_ = state;
339342
initStateObserver(state_.get());
343+
postStateChangeInternalSignalHookup();
340344
}
341345

342346
AlgorithmBase& Module::algo()
@@ -509,7 +513,9 @@ Module::Builder& Module::Builder::using_func(ModuleMaker create)
509513
Module::Builder& Module::Builder::setStateDefaults()
510514
{
511515
if (module_)
516+
{
512517
module_->setStateDefaults();
518+
}
513519
return *this;
514520
}
515521

@@ -912,3 +918,17 @@ bool Module::isStoppable() const
912918
{
913919
return dynamic_cast<const Core::Thread::Interruptible*>(this) != nullptr;
914920
}
921+
922+
void Module::sendFeedbackUpstreamAlongIncomingConnections(const Variable::Value& info)
923+
{
924+
for (auto& inputPort : inputPorts())
925+
{
926+
if (inputPort->nconnections() > 0)
927+
{
928+
auto connection = inputPort->connection(0); // only one incoming connection for input ports
929+
VariableHandle info(new Variable(Name(inputPort->id().toString()), info));
930+
//TODO: extract port method
931+
connection->oport_->sendConnectionFeedback(info);
932+
}
933+
}
934+
}

src/Dataflow/Network/Module.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ namespace Networks {
259259
size_t add_output_port(OutputPortHandle);
260260
virtual void removeInputPort(const PortId& id);
261261

262+
//For modules that need to initialize some internal state signal/slots, this needs to be called after set_state to reinitialize.
263+
virtual void postStateChangeInternalSignalHookup() {}
264+
void sendFeedbackUpstreamAlongIncomingConnections(const Core::Algorithms::Variable::Value& info);
265+
262266
private:
263267
template <class T>
264268
boost::shared_ptr<T> getRequiredInputAtIndex(const PortId& id);

src/ExampleNets/regression/widgetFeedbackTest.srn5

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<name>PadPercent</name>
5151
<value>
5252
<which>1</which>
53-
<value>0.00000000000000000e+00</value>
53+
<value>0.00000000000000000e+000</value>
5454
</value>
5555
</second>
5656
</item>
@@ -186,7 +186,7 @@
186186
<name>OutputCenterX</name>
187187
<value>
188188
<which>1</which>
189-
<value>0.00000000000000000e+00</value>
189+
<value>0.00000000000000000e+000</value>
190190
</value>
191191
</second>
192192
</item>
@@ -198,7 +198,7 @@
198198
<name>OutputCenterY</name>
199199
<value>
200200
<which>1</which>
201-
<value>0.00000000000000000e+00</value>
201+
<value>0.00000000000000000e+000</value>
202202
</value>
203203
</second>
204204
</item>
@@ -210,7 +210,7 @@
210210
<name>OutputCenterZ</name>
211211
<value>
212212
<which>1</which>
213-
<value>0.00000000000000000e+00</value>
213+
<value>0.00000000000000000e+000</value>
214214
</value>
215215
</second>
216216
</item>
@@ -222,7 +222,7 @@
222222
<name>OutputSizeX</name>
223223
<value>
224224
<which>1</which>
225-
<value>1.00000000000000000e+00</value>
225+
<value>1.00000000000000000e+000</value>
226226
</value>
227227
</second>
228228
</item>
@@ -234,7 +234,7 @@
234234
<name>OutputSizeY</name>
235235
<value>
236236
<which>1</which>
237-
<value>1.00000000000000000e+00</value>
237+
<value>1.00000000000000000e+000</value>
238238
</value>
239239
</second>
240240
</item>
@@ -246,7 +246,7 @@
246246
<name>OutputSizeZ</name>
247247
<value>
248248
<which>1</which>
249-
<value>1.00000000000000000e+00</value>
249+
<value>1.00000000000000000e+000</value>
250250
</value>
251251
</second>
252252
</item>
@@ -330,7 +330,7 @@
330330
<name>Scale</name>
331331
<value>
332332
<which>1</which>
333-
<value>1.00000000000000006e-01</value>
333+
<value>1.00000000000000010e-001</value>
334334
</value>
335335
</second>
336336
</item>
@@ -426,22 +426,22 @@
426426
<item class_id="16" tracking_level="0" version="0">
427427
<first>CreateLatVol:0</first>
428428
<second class_id="17" tracking_level="0" version="0">
429-
<first>0.00000000000000000e+00</first>
430-
<second>-7.60000000000000000e+01</second>
429+
<first>0.00000000000000000e+000</first>
430+
<second>-7.60000000000000000e+001</second>
431431
</second>
432432
</item>
433433
<item>
434434
<first>EditMeshBoundingBox:0</first>
435435
<second>
436-
<first>1.52000000000000000e+02</first>
437-
<second>1.52000000000000000e+02</second>
436+
<first>1.52000000000000000e+002</first>
437+
<second>1.52000000000000000e+002</second>
438438
</second>
439439
</item>
440440
<item>
441441
<first>ViewScene:0</first>
442442
<second>
443-
<first>3.04000000000000000e+02</first>
444-
<second>3.80000000000000000e+02</second>
443+
<first>3.04000000000000000e+002</first>
444+
<second>3.80000000000000000e+002</second>
445445
</second>
446446
</item>
447447
</modulePositions>

src/Interface/Modules/Render/ViewScene.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ void ViewSceneDialog::saveNewGeometryChanged(int state)
797797

798798
void ViewSceneDialog::sendGeometryFeedbackToState(int x, int y)
799799
{
800-
qDebug() << "in VSD slot: " << x << y;
801800
using namespace SCIRun::Core::Algorithms;
802801
Variable::List coords;
803802
coords.push_back(makeVariable("x", x));

src/Modules/Fields/EditMeshBoundingBox.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ namespace Fields {
9191
OUTPUT_PORT(2, Transformation_Matrix, Matrix);
9292

9393
static const Dataflow::Networks::ModuleLookupInfo staticInfo_;
94-
9594
private:
9695
void executeImpl(FieldHandle f);
9796
void clear_vals();

src/Modules/Render/ViewScene.cc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
#include <Core/Datatypes/Geometry.h>
3232
#include <Core/Logging/Log.h>
3333

34-
//TODO remove once method is extracted below
35-
#include <Dataflow/Network/Connection.h>
36-
3734
// Needed to fix conflict between define in X11 header
3835
// and eigen enum member.
3936
#ifdef Success
@@ -58,14 +55,19 @@ ALGORITHM_PARAMETER_DEF(Render, GeometryFeedbackInfo);
5855
ViewScene::ViewScene() : ModuleWithAsyncDynamicPorts(staticInfo_)
5956
{
6057
INITIALIZE_PORT(GeneralGeom);
61-
62-
get_state()->connect_state_changed([this]() { processViewSceneObjectFeedback(); });
6358
}
6459

6560
void ViewScene::setStateDefaults()
6661
{
6762
auto state = get_state();
6863
state->setValue(BackgroundColor, ColorRGB(0.0, 0.0, 0.0).toString());
64+
postStateChangeInternalSignalHookup();
65+
}
66+
67+
void ViewScene::postStateChangeInternalSignalHookup()
68+
{
69+
std::cout << "view scene hooking up state change slot" << std::endl;
70+
get_state()->connect_state_changed([this]() { processViewSceneObjectFeedback(); });
6971
}
7072

7173
void ViewScene::portRemovedSlotImpl(const PortId& pid)
@@ -134,24 +136,17 @@ void ViewScene::asyncExecute(const PortId& pid, DatatypeHandle data)
134136

135137
void ViewScene::processViewSceneObjectFeedback()
136138
{
137-
std::cout << "slot for state change in VS module" << std::endl;
139+
//TODO: match ID of touched geom object with port id, and send that info back too.
140+
//std::cout << "slot for state change in VS module" << std::endl;
138141
auto state = get_state();
139142
auto newInfo = state->getValue(Parameters::GeometryFeedbackInfo).toVector();
143+
//std::cout << "feedback info: " << newInfo << std::endl;
140144
if (feedbackInfo_ != newInfo)
141145
{
142-
std::cout << "new feedback info: " << newInfo << std::endl;
146+
//std::cout << "new feedback info: " << newInfo << std::endl;
143147
feedbackInfo_ = newInfo;
144148

145-
//TODO: extract method in Module class
146-
for (auto& inputPort : inputPorts())
147-
{
148-
if (inputPort->nconnections() > 0)
149-
{
150-
auto connection = inputPort->connection(0); // only one incoming connection for input ports
151-
VariableHandle info(new Variable(Name(inputPort->id().toString()), feedbackInfo_));
152-
connection->oport_->sendConnectionFeedback(info);
153-
}
154-
}
149+
sendFeedbackUpstreamAlongIncomingConnections(feedbackInfo_);
155150
}
156151
}
157152

src/Modules/Render/ViewScene.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ namespace Render {
8282
typedef std::map<Dataflow::Networks::PortId, Core::Datatypes::GeometryHandle> ActiveGeometryMap;
8383
protected:
8484
virtual void portRemovedSlotImpl(const Dataflow::Networks::PortId& pid) override;
85+
virtual void postStateChangeInternalSignalHookup() override;
8586
private:
8687
void processViewSceneObjectFeedback();
8788
void updateTransientList();

0 commit comments

Comments
 (0)