Skip to content

Commit 3eb04ef

Browse files
committed
Working on VS/python interaction
1 parent 2a2054f commit 3eb04ef

File tree

13 files changed

+80
-23
lines changed

13 files changed

+80
-23
lines changed

src/Dataflow/Engine/Controller/PythonImpl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ boost::shared_ptr<PyModule> PythonImpl::findModule(const std::string& id) const
612612

613613
std::string PythonImpl::executeAll(const ExecutableLookup* lookup)
614614
{
615+
//TODO: if contains view scene, need to disable all connections to it.
615616
nec_.executeAll(lookup);
616617
return "Execution started."; //TODO: attach log for execution ended event.
617618
}

src/Dataflow/Network/Connection.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -38,7 +38,7 @@ Connection::Connection(OutputPortHandle oport, InputPortHandle iport, const Conn
3838
ENSURE_NOT_NULL(oport_, "output port is null");
3939
ENSURE_NOT_NULL(iport_, "input port is null");
4040

41-
/// @todo: this is already checked in the controller layer. Do we need a redundant check here?
41+
/// @todo: this is already checked in the controller layer. Do we need a redundant check here?
4242
//if (oport_->get_colorname() != iport_->get_colorname())
4343
// THROW_INVALID_ARGUMENT("Ports do not have matching type.");
4444

@@ -51,3 +51,16 @@ Connection::~Connection()
5151
oport_->detach(this);
5252
iport_->detach(this);
5353
}
54+
55+
std::string Connection::id() const
56+
{
57+
return id_;
58+
}
59+
60+
void Connection::setDisable(bool disable)
61+
{
62+
std::cout << "setting " << id_ << " to " << disable << std::endl;
63+
disabled_ = disable;
64+
if (!disabled_)
65+
iport_->resendNewDataSignal();
66+
}

src/Dataflow/Network/Connection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ namespace SCIRun {
4848
OutputPortHandle oport_;
4949
InputPortHandle iport_;
5050

51+
std::string id() const;
5152
ConnectionId id_;
5253

5354
bool disabled() const { return disabled_; }
54-
void setDisable(bool disable) { disabled_ = disable; }
55+
void setDisable(bool disable);
5556
private:
5657
bool disabled_ {false};
5758
};

src/Dataflow/Network/DataflowInterfaces.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2015 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -28,7 +28,7 @@
2828
/// @todo Documentation Dataflow/Network/DataflowInterfaces.h
2929

3030
#ifndef DATAFLOW_NETWORK_DATAFLOW_INTERFACES_H
31-
#define DATAFLOW_NETWORK_DATAFLOW_INTERFACES_H
31+
#define DATAFLOW_NETWORK_DATAFLOW_INTERFACES_H
3232

3333
#include <Dataflow/Network/NetworkFwd.h>
3434
#include <Core/Datatypes/Datatype.h>
@@ -51,12 +51,12 @@ namespace Networks {
5151
};
5252

5353
typedef boost::signals2::signal<void(SCIRun::Core::Datatypes::DatatypeHandle)> DataHasChangedSignalType;
54-
54+
5555
class SCISHARE DatatypeSinkInterface
5656
{
5757
public:
5858
virtual ~DatatypeSinkInterface() {}
59-
59+
6060
// "mailbox" interface
6161
//virtual bool hasData() const = 0;
6262
//virtual void setHasData(bool dataPresent) = 0;
@@ -68,6 +68,7 @@ namespace Networks {
6868
virtual bool hasChanged() const = 0;
6969
virtual void invalidateProvider() = 0;
7070
virtual boost::signals2::connection connectDataHasChanged(const DataHasChangedSignalType::slot_type& subscriber) = 0;
71+
virtual void forceFireDataHasChanged() = 0;
7172
};
7273

7374
}}}

src/Dataflow/Network/Port.cc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void Port::detach(Connection* conn)
6868
connections_.erase(pos);
6969
}
7070

71-
const Connection* Port::connection(size_t i) const
71+
Connection* Port::connection(size_t i) const
7272
{
7373
return connections_[i];
7474
}
@@ -154,10 +154,30 @@ boost::signals2::connection InputPort::connectDataOnPortHasChanged(const DataOnP
154154
{
155155
return sink()->connectDataHasChanged([this, subscriber] (DatatypeHandle data)
156156
{
157-
subscriber(this->id(), data);
157+
std::cout << "connectDataHasChanged" << std::endl;
158+
if (!this->connections_.empty())
159+
{
160+
std::cout << "connectDataHasChanged connections not empty" << std::endl;
161+
auto conn = *this->connections_.begin();
162+
if (!conn->disabled())
163+
{
164+
std::cout << "enabled: " << conn->id() << std::endl;
165+
subscriber(this->id(), data);
166+
}
167+
else
168+
{
169+
std::cout << "disabled: " << conn->id() << std::endl;
170+
}
171+
}
172+
std::cout << "connectDataHasChanged connections is empty" << std::endl;
158173
});
159174
}
160175

176+
void InputPort::resendNewDataSignal()
177+
{
178+
sink()->forceFireDataHasChanged();
179+
}
180+
161181
OutputPort::OutputPort(ModuleInterface* module, const ConstructionParams& params, DatatypeSourceInterfaceHandle source)
162182
: Port(module, params), source_(source)
163183
{
@@ -178,8 +198,13 @@ void OutputPort::sendData(DatatypeHandle data)
178198

179199
for (Connection* c : connections_)
180200
{
201+
std::cout << c->id();
181202
if (c && !c->disabled() && c->iport_)
203+
{
182204
source_->send(c->iport_->sink());
205+
std::cout << "\t sent.";
206+
}
207+
std::cout << std::endl;
183208
}
184209
}
185210

src/Dataflow/Network/Port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SCISHARE Port : virtual public PortInterface, boost::noncopyable
5959
virtual ~Port();
6060

6161
size_t nconnections() const override;
62-
const Connection* connection(size_t) const override;
62+
Connection* connection(size_t) const override;
6363

6464
virtual PortId id() const override { return id_; }
6565
virtual void setId(const PortId& id) override { id_ = id; }
@@ -110,6 +110,7 @@ class SCISHARE InputPort : public Port, public InputPortInterface
110110
virtual InputPortInterface* clone() const override;
111111
virtual bool hasChanged() const override;
112112
virtual boost::signals2::connection connectDataOnPortHasChanged(const DataOnPortHasChangedSignalType::slot_type& subscriber) override;
113+
virtual void resendNewDataSignal() override;
113114
private:
114115
DatatypeSinkInterfaceHandle sink_;
115116
bool isDynamic_;

src/Dataflow/Network/PortInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace Networks {
6565
virtual ~PortInterface();
6666
virtual void attach(Connection* conn) = 0;
6767
virtual void detach(Connection* conn) = 0;
68-
virtual const Connection* connection(size_t) const = 0;
68+
virtual Connection* connection(size_t) const = 0;
6969
virtual void setIndex(size_t index) = 0;
7070
void incrementIndex() { setIndex(getIndex() + 1); }
7171
void decrementIndex() { setIndex(getIndex() - 1); }
@@ -84,6 +84,7 @@ namespace Networks {
8484
virtual InputPortInterface* clone() const = 0;
8585
virtual bool hasChanged() const = 0;
8686
virtual boost::signals2::connection connectDataOnPortHasChanged(const DataOnPortHasChangedSignalType::slot_type& subscriber) = 0;
87+
virtual void resendNewDataSignal() = 0;
8788
};
8889

8990
typedef boost::signals2::signal<void(const Core::Datatypes::ModuleFeedback&)> ConnectionFeedbackSignalType;

src/Dataflow/Network/SimpleSourceSink.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ void SimpleSink::setData(DatatypeHandle data)
110110
dataHasChanged_(data);
111111
}
112112

113+
void SimpleSink::forceFireDataHasChanged()
114+
{
115+
dataHasChanged_(weakData_.lock());
116+
}
117+
113118
DatatypeSinkInterface* SimpleSink::clone() const
114119
{
115120
return new SimpleSink;
@@ -170,4 +175,4 @@ std::string SimpleSource::describeData() const
170175
{
171176
DescribeDatatype dd;
172177
return dd.describe(data_);
173-
}
178+
}

src/Dataflow/Network/SimpleSourceSink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ namespace SCIRun
5656
void setData(Core::Datatypes::DatatypeHandle data);
5757
virtual void invalidateProvider() { /*TODO*/ }
5858
virtual boost::signals2::connection connectDataHasChanged(const DataHasChangedSignalType::slot_type& subscriber);
59+
virtual void forceFireDataHasChanged() override;
5960

6061
static bool globalPortCachingFlag();
6162
static void setGlobalPortCachingFlag(bool value);

src/Interface/Application/ModuleWidget.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <Core/Logging/Log.h>
3434
#include <Core/Application/Application.h>
3535
#include <Dataflow/Engine/Controller/NetworkEditorController.h>
36+
#include <Dataflow/Network/Connection.h>
3637

3738
#include <Interface/Application/ModuleWidget.h>
3839
#include <Interface/Application/Connection.h>
@@ -578,7 +579,7 @@ void ModuleWidget::createInputPorts(const ModuleInfoProvider& moduleInfoProvider
578579
this);
579580
hookUpGeneralPortSignals(w);
580581
connect(this, SIGNAL(connectionAdded(const SCIRun::Dataflow::Networks::ConnectionDescription&)), w, SLOT(MakeTheConnection(const SCIRun::Dataflow::Networks::ConnectionDescription&)));
581-
connect(w, SIGNAL(incomingConnectionStateChange(bool)), this, SLOT(incomingConnectionStateChanged(bool)));
582+
connect(w, SIGNAL(incomingConnectionStateChange(bool, int)), this, SLOT(incomingConnectionStateChanged(bool, int)));
582583
ports_->addPort(w);
583584
++i;
584585
if (dialog_ && port->isDynamic())
@@ -1388,8 +1389,15 @@ void ModuleWidget::setExecutionDisabled(bool disabled)
13881389
theModule_->setExecutionDisabled(disabled_);
13891390
}
13901391

1391-
void ModuleWidget::incomingConnectionStateChanged(bool disabled)
1392+
void ModuleWidget::incomingConnectionStateChanged(bool disabled, int index)
13921393
{
1394+
qDebug() << "ModuleWidget::incomingConnectionStateChanged" << disabled << index;
1395+
if (index < theModule_->num_input_ports())
1396+
{
1397+
qDebug() << "\tincomingConnectionStateChanged" << theModule_->inputPorts()[index]->connection(0)->id().c_str() << disabled;
1398+
theModule_->inputPorts()[index]->connection(0)->setDisable(disabled);
1399+
}
1400+
13931401
bool shouldDisable;
13941402
if (disabled)
13951403
{

0 commit comments

Comments
 (0)