Skip to content

Commit be76caa

Browse files
authored
Merge pull request #1505 from SCIInstitute/python-VS-restrictions
Python vs restrictions
2 parents 3fa6736 + c2b96ec commit be76caa

File tree

23 files changed

+130
-44
lines changed

23 files changed

+130
-44
lines changed

src/Core/Command/Command.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ namespace SCIRun
8888
ImportNetworkFile,
8989
RunPythonScript,
9090
SetupDataDirectory,
91+
DisableViewScenes,
9192
ExecuteCurrentNetwork,
9293
InteractiveMode,
9394
SetupQuitAfterExecute,

src/Core/ConsoleApplication/ConsoleCommandFactory.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ CommandHandle ConsoleGlobalCommandFactory::create(GlobalCommands type) const
6868
return boost::make_shared<QuitAfterExecuteCommandConsole>();
6969
case GlobalCommands::QuitCommand:
7070
return boost::make_shared<QuitCommandConsole>();
71+
case GlobalCommands::DisableViewScenes:
72+
return boost::make_shared<NothingCommand>();
7173
default:
7274
THROW_INVALID_ARGUMENT("Unknown global command type.");
7375
}

src/Core/ConsoleApplication/ConsoleCommands.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,14 @@ namespace Console {
4141
public:
4242
LoadFileCommandConsole();
4343
virtual bool execute() override;
44-
private:
45-
int index_ = 0;
44+
// private:
45+
// int index_ = 0;
4646
};
4747

4848
class SCISHARE SaveFileCommandConsole : public Core::Commands::ConsoleCommand
4949
{
5050
public:
51-
//LoadFileCommandConsole();
5251
virtual bool execute() override;
53-
//private:
54-
// int index_ = 0;
5552
};
5653

5754
class SCISHARE RunPythonScriptCommandConsole : public Core::Commands::ConsoleCommand

src/Dataflow/Engine/Controller/PythonImpl.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ namespace SCIRun {
524524
class PythonImplImpl
525525
{
526526
public:
527-
std::map<std::string, std::map<int, std::map<std::string, std::map<int, std::string>>>> connectionIdLookup_; //seems silly
527+
std::map<std::string, std::map<int, std::map<std::string, std::map<int, std::string>>>> connectionIdLookup_;
528528
};
529529
}
530530
}
@@ -612,6 +612,8 @@ boost::shared_ptr<PyModule> PythonImpl::findModule(const std::string& id) const
612612

613613
std::string PythonImpl::executeAll(const ExecutableLookup* lookup)
614614
{
615+
cmdFactory_->create(GlobalCommands::DisableViewScenes)->execute();
616+
615617
nec_.executeAll(lookup);
616618
return "Execution started."; //TODO: attach log for execution ended event.
617619
}

src/Dataflow/Network/Connection.cc

Lines changed: 14 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,15 @@ 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+
disabled_ = disable;
63+
if (!disabled_)
64+
iport_->resendNewDataSignal();
65+
}

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: 18 additions & 4 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,22 @@ boost::signals2::connection InputPort::connectDataOnPortHasChanged(const DataOnP
154154
{
155155
return sink()->connectDataHasChanged([this, subscriber] (DatatypeHandle data)
156156
{
157-
subscriber(this->id(), data);
157+
if (!this->connections_.empty())
158+
{
159+
auto conn = *this->connections_.begin();
160+
if (!conn->disabled())
161+
{
162+
subscriber(this->id(), data);
163+
}
164+
}
158165
});
159166
}
160167

168+
void InputPort::resendNewDataSignal()
169+
{
170+
sink()->forceFireDataHasChanged();
171+
}
172+
161173
OutputPort::OutputPort(ModuleInterface* module, const ConstructionParams& params, DatatypeSourceInterfaceHandle source)
162174
: Port(module, params), source_(source)
163175
{
@@ -176,10 +188,12 @@ void OutputPort::sendData(DatatypeHandle data)
176188
if (0 == nconnections())
177189
return;
178190

179-
for (Connection* c : connections_)
191+
for (auto c : connections_)
180192
{
181-
if (c && !c->disabled() && c->iport_)
193+
if (c && c->iport_)
194+
{
182195
source_->send(c->iport_->sink());
196+
}
183197
}
184198
}
185199

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;

0 commit comments

Comments
 (0)