Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a63b205
Improvements to I/O modules
dcwhite May 12, 2022
c80e3ba
Convert module
dcwhite May 16, 2022
d4da1de
Add UI
dcwhite May 16, 2022
386f401
UI
dcwhite May 16, 2022
a948426
adjusting
dcwhite May 16, 2022
3c1919a
Filling out impl
dcwhite May 17, 2022
c427630
Histogram works nicely. Closes #2367
dcwhite May 17, 2022
4eb1d89
Update ReportScalarFieldStats.cc
dcwhite May 17, 2022
e07009a
Add enable/disable functions. UI needs updating
dcwhite May 18, 2022
14f8ce5
Update README.md
dcwhite May 18, 2022
4a84387
Merge branch 'file-modification' of https://github.com/SCIInstitute/S…
dcwhite May 18, 2022
b3aa3e1
Fix build
dcwhite May 20, 2022
5ba2162
Add pin feature
dcwhite May 27, 2022
8dcbde2
Reformat
dcwhite May 30, 2022
961d390
All pop-ups pinnable with context menu
dcwhite May 30, 2022
930997a
Working on toolbar positioning
dcwhite May 31, 2022
bbc3557
Update ViewScene.cc
dcwhite May 31, 2022
0668835
Update ViewScene.cc
dcwhite May 31, 2022
5141223
Change to buttons
dcwhite May 31, 2022
72629f4
Buttons working nicely
dcwhite May 31, 2022
54b7089
Continue popup placement
dcwhite Jun 1, 2022
1f58b49
Relative popup positioning works
dcwhite Jun 1, 2022
9e8e5ed
Hotkey for auto-rotate pref
dcwhite Jun 1, 2022
8a1285e
Fix windows package
dcwhite Jun 1, 2022
0774994
enable/disable connections not modules
dcwhite Jun 2, 2022
48d8730
New NEC method
dcwhite Jun 2, 2022
fa0f67f
Update Network.cc
dcwhite Jun 2, 2022
23bfc7a
Working on connection access
dcwhite Jun 3, 2022
8a7b145
Implement
dcwhite Jun 3, 2022
9dff96e
signal/slots almost hooked up
dcwhite Jun 4, 2022
e3fe7ed
Can disable/enable connections from python
dcwhite Jun 4, 2022
b81c827
Closes #2288
dcwhite Jun 4, 2022
70bea70
Closes #2346
dcwhite Jun 5, 2022
b0d0b56
Merge branch 'master' into file-modification
dcwhite Jun 5, 2022
7a455fd
Tiny popup workaround
dcwhite Jun 8, 2022
c204d8e
Fix for full screen viewscene
dcwhite Jun 9, 2022
04f78f6
Fix bar size for DisplayHistogram
dcwhite Jun 10, 2022
bfba146
Fixes #2387
dcwhite Jun 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
BasedOnStyle: Google
AlignAfterOpenBracket: DontAlign
AllowAllConstructorInitializersOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: 'true'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'true'
BinPackParameters: 'true'
Expand All @@ -28,7 +27,7 @@ BraceWrapping:
SplitEmptyNamespace: false
BreakBeforeBraces: Custom
BreakConstructorInitializers: BeforeColon
ColumnLimit: '100'
ColumnLimit: '200'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'true'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ For documentation, please see: https://scirun.readthedocs.io/en/latest/
Please see https://scirun.readthedocs.io/en/latest/start/build.html

#### Python API
Please see https://scirun.readthedocs.io/en/latest/user_doc/python.html
Please see https://scirun.readthedocs.io/en/latest/user_doc/python.html

### Questions and Answers
For help, email the testing mailing list at [email protected].
For help, check out the discussion page: https://github.com/SCIInstitute/SCIRun/discussions.

### License and Credits
For more information, please see: http://software.sci.utah.edu
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ SET_PROPERTY(TARGET Modules_Factory PROPERTY FOLDER "Modules")
SET_PROPERTY(TARGET Graphics_Glyphs PROPERTY FOLDER "Graphics")
SET_PROPERTY(TARGET Graphics_Widgets PROPERTY FOLDER "Graphics")
SET_PROPERTY(TARGET Graphics_Datatypes PROPERTY FOLDER "Graphics")
SET_PROPERTY(TARGET spire PROPERTY FOLDER "Graphics")

SET_PROPERTY(TARGET pugixml PROPERTY FOLDER "Externals")

IF(BUILD_TESTING)
SET_PROPERTY(TARGET gmock PROPERTY FOLDER "Testing Support")
Expand Down Expand Up @@ -796,6 +799,7 @@ IF(BUILD_TESTING)
SET_PROPERTY(TARGET Core_ImportExport_Tests PROPERTY FOLDER "Core/Tests")
SET_PROPERTY(TARGET Core_IEPlugin_Tests PROPERTY FOLDER "Core/Tests")
SET_PROPERTY(TARGET Graphics_Widgets_Tests PROPERTY FOLDER "Graphics/Tests")
SET_PROPERTY(TARGET Graphics_Datatypes_Tests PROPERTY FOLDER "Graphics/Tests")

SET_PROPERTY(TARGET Engine_Network_Tests PROPERTY FOLDER "Dataflow/Engine/Tests")
SET_PROPERTY(TARGET Engine_Scheduler_Tests PROPERTY FOLDER "Dataflow/Engine/Tests")
Expand Down
1 change: 1 addition & 0 deletions src/Dataflow/Engine/Controller/ControllerInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace Engine {
typedef boost::signals2::signal<void (const Networks::ConnectionDescription&)> ConnectionAddedSignalType;
typedef boost::signals2::signal<void (const Networks::ConnectionDescription&)> InvalidConnectionSignalType;
typedef boost::signals2::signal<void (const Networks::ConnectionId&)> ConnectionRemovedSignalType;
typedef boost::signals2::signal<void (const Networks::ConnectionId&, bool)> ConnectionStatusChangedSignalType;
typedef boost::signals2::signal<void (const Networks::ModuleId&, const Networks::PortId&)> PortAddedSignalType;
typedef boost::signals2::signal<void (const Networks::ModuleId&, const Networks::PortId&)> PortRemovedSignalType;
typedef boost::signals2::signal<void (int)> NetworkDoneLoadingSignalType;
Expand Down
20 changes: 20 additions & 0 deletions src/Dataflow/Engine/Controller/NetworkEditorController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,26 @@ boost::signals2::connection NetworkEditorController::connectNetworkDoneLoading(c
return signals_.networkDoneLoading_.connect(subscriber);
}

boost::signals2::connection NetworkEditorController::connectConnectionStatusChanged(const ConnectionStatusChangedSignalType::slot_type& subscriber)
{
return signals_.connectionStatusChanged_.connect(subscriber);
}

std::string NetworkEditorController::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable)
{
auto conn = getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex);
if (conn)
{
conn->setDisable(!enable);
signals_.connectionStatusChanged_(conn->id_, enable);
return std::string("Connection status ") + (enable ? "enabled" : "disabled") + ": " + moduleIdFrom + "(" + std::to_string(fromIndex) + ")->" + moduleIdTo + "(" + std::to_string(toIndex) + ")";
}
else
{
return "Connection not found: " + moduleIdFrom + "(" + std::to_string(fromIndex) + ")->" + moduleIdTo + "(" + std::to_string(toIndex) + ")";
}
}

NetworkFileHandle NetworkEditorController::serializeNetworkFragment(ModuleFilter modFilter, ConnectionFilter connFilter) const
{
NetworkToXML conv(collabs_.serializationManager_);
Expand Down
5 changes: 3 additions & 2 deletions src/Dataflow/Engine/Controller/NetworkEditorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ namespace Engine {
ConnectionRemovedSignalType connectionRemoved_;
InvalidConnectionSignalType invalidConnection_;
NetworkDoneLoadingSignalType networkDoneLoading_;

ConnectionStatusChangedSignalType connectionStatusChanged_;

bool signalSwitch_, loadingContext_;


struct LoadingContext
{
explicit LoadingContext(bool& load);
Expand Down Expand Up @@ -121,6 +120,7 @@ namespace Engine {

std::optional<Networks::ConnectionId> requestConnection(const Networks::PortDescriptionInterface* from, const Networks::PortDescriptionInterface* to) override;
void removeConnection(const Networks::ConnectionId& id);
std::string setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable);

std::future<int> executeAll() override;
void executeModule(const Networks::ModuleHandle& module, bool executeUpstream);
Expand All @@ -146,6 +146,7 @@ namespace Engine {
boost::signals2::connection connectInvalidConnection(const InvalidConnectionSignalType::slot_type& subscriber);
boost::signals2::connection connectPortAdded(const PortAddedSignalType::slot_type& subscriber);
boost::signals2::connection connectPortRemoved(const PortRemovedSignalType::slot_type& subscriber);
boost::signals2::connection connectConnectionStatusChanged(const ConnectionStatusChangedSignalType::slot_type& subscriber);

boost::signals2::connection connectStaticNetworkExecutionStarts(const ExecuteAllStartsSignalType::slot_type& subscriber);
boost::signals2::connection connectStaticNetworkExecutionFinished(const ExecuteAllFinishesSignalType::slot_type& subscriber);
Expand Down
41 changes: 18 additions & 23 deletions src/Dataflow/Engine/Controller/PythonImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <Dataflow/Network/NetworkInterface.h>
#include <Dataflow/Network/ModuleDescription.h>
#include <Dataflow/Network/PortInterface.h>
#include <Dataflow/Network/Connection.h>
#include <Dataflow/Serialization/Network/NetworkDescriptionSerialization.h>
#include <Core/Algorithms/Base/AlgorithmBase.h>
#include <Dataflow/Engine/Controller/PythonImpl.h>
Expand Down Expand Up @@ -479,6 +480,11 @@ namespace
return creationTime_;
}

void setEnabled(bool enable) override
{
module_->setExecutionDisabled(!enable);
}

private:
ModuleHandle module_;
NetworkEditorController& nec_;
Expand All @@ -487,19 +493,8 @@ namespace
};
}

namespace SCIRun {
namespace Dataflow {
namespace Engine {
class PythonImplImpl
{
public:
std::map<std::string, std::map<int, std::map<std::string, std::map<int, std::string>>>> connectionIdLookup_;
};
}
}
}

PythonImpl::PythonImpl(NetworkEditorController& nec, GlobalCommandFactoryHandle cmdFactory) : impl_(new PythonImplImpl), nec_(nec), cmdFactory_(cmdFactory)
PythonImpl::PythonImpl(NetworkEditorController& nec, GlobalCommandFactoryHandle cmdFactory) :
nec_(nec), cmdFactory_(cmdFactory)
{
connections_.push_back(nec_.connectStaticNetworkExecutionFinished([this](int) { executionFromPythonFinish(0); }));
connections_.push_back(nec_.connectModuleAdded([this](const std::string& id, ModuleHandle m, ModuleCounter mc) { pythonModuleAddedSlot(id, m, mc); }));
Expand Down Expand Up @@ -595,29 +590,29 @@ std::string PythonImpl::connect(const std::string& moduleIdFrom, int fromIndex,
auto modTo = network->lookupModule(ModuleId(moduleIdTo));
auto inputPort = modTo->inputPorts().at(toIndex);
auto id = nec_.requestConnection(outputPort.get(), inputPort.get());
if (id)
{
impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex] = id->id_;
}

return "PythonImpl::connect success";
return "PythonImpl::connect success: " + id->id_;
}

std::string PythonImpl::disconnect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex)
{
//TODO: doesn't work at all since there is no GUI connection to this network change event. Issue is #...
auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex];
if (!id.empty())
auto conn = nec_.getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex);
if (conn)
{
nec_.removeConnection(id);
return "PythonImpl::disconnect IS NOT IMPLEMENTED";
nec_.removeConnection(conn->id());
return "PythonImpl::disconnect is not connected to GUI";
}
else
{
return "PythonImpl::disconnect: connection not found";
}
}

std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable)
{
return nec_.setConnectionStatus(moduleIdFrom, fromIndex, moduleIdTo, toIndex, enable);
}

std::string PythonImpl::saveNetwork(const std::string& filename)
{
auto save = cmdFactory_->create(GlobalCommands::SaveNetworkFile);
Expand Down
2 changes: 1 addition & 1 deletion src/Dataflow/Engine/Controller/PythonImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace Engine {
std::string importNetwork(const std::string& filename) override;
std::string runScript(const std::string& filename) override;
std::string quit(bool force) override;
std::string setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) override;
void setUnlockFunc(boost::function<void()> unlock) override;
void setModuleContext(bool inModule) override { inModule_ = inModule; }
bool isModuleContext() const override { return inModule_; }
Expand All @@ -72,7 +73,6 @@ namespace Engine {
void pythonModuleRemovedSlot(const Networks::ModuleId&);
void executionFromPythonStart();
void executionFromPythonFinish(int);
SharedPointer<PythonImplImpl> impl_;
std::map<std::string, SharedPointer<PyModule>> modules_;
NetworkEditorController& nec_;
Core::Commands::GlobalCommandFactoryHandle cmdFactory_;
Expand Down
10 changes: 10 additions & 0 deletions src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ boost::python::object NetworkEditorPythonAPI::scirun_get_module_input_value(cons
return {};
}

std::string NetworkEditorPythonAPI::scirun_enable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex)
{
return impl_->setConnectionStatus(moduleIdFrom, fromIndex, moduleIdTo, toIndex, true);
}

std::string NetworkEditorPythonAPI::scirun_disable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex)
{
return impl_->setConnectionStatus(moduleIdFrom, fromIndex, moduleIdTo, toIndex, false);
}

boost::python::object SimplePythonAPI::scirun_module_ids()
{
auto mods = NetworkEditorPythonAPI::modules();
Expand Down
3 changes: 3 additions & 0 deletions src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ namespace SCIRun {
static boost::python::dict get_output_data(const std::string& moduleId);
static std::string set_output_data(const std::string& moduleId, const boost::python::dict& outputMap);

static std::string scirun_enable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex);
static std::string scirun_disable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex);

static std::string executeAll();
static std::string saveNetwork(const std::string& filename);
static std::string loadNetwork(const std::string& filename);
Expand Down
2 changes: 2 additions & 0 deletions src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace SCIRun
//ports
virtual SharedPointer<class PyPorts> output() = 0;
virtual SharedPointer<class PyPorts> input() = 0;
virtual void setEnabled(bool enable) = 0;

//time added to network, for id sorting
virtual boost::posix_time::ptime creationTime() const = 0;
Expand Down Expand Up @@ -130,6 +131,7 @@ namespace SCIRun
virtual SharedPointer<PyModule> findModule(const std::string& id) const = 0;
virtual std::string connect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) = 0;
virtual std::string disconnect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) = 0;
virtual std::string setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) = 0;
virtual std::string executeAll() = 0;
virtual std::string saveNetwork(const std::string& filename) = 0;
virtual std::string loadNetwork(const std::string& filename) = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/Dataflow/Engine/Python/SCIRunPythonModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ BOOST_PYTHON_MODULE(SCIRunPythonAPI)
boost::python::def("get_output_data", &NetworkEditorPythonAPI::get_output_data);
boost::python::def("set_output_data", &NetworkEditorPythonAPI::set_output_data);

boost::python::def("scirun_enable_connection", &NetworkEditorPythonAPI::scirun_enable_connection);
boost::python::def("scirun_disable_connection", &NetworkEditorPythonAPI::scirun_disable_connection);

boost::python::def("scirun_save_network", &NetworkEditorPythonAPI::saveNetwork);
boost::python::def("scirun_load_network", &NetworkEditorPythonAPI::loadNetwork);
boost::python::def("scirun_import_network", &NetworkEditorPythonAPI::importNetwork);
Expand Down
29 changes: 27 additions & 2 deletions src/Dataflow/Network/Network.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,34 @@ bool Network::disconnect(const ConnectionId& id)
return false;
}

void Network::disable_connection(const ConnectionId&)
ConnectionHandle Network::lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const
{
/// @todo
auto fromMod = lookupModule(ModuleId(moduleIdFrom));
if (!fromMod)
return nullptr;
auto fromPorts = fromMod->outputPorts();
if (fromIndex < 0 || fromIndex >= fromPorts.size())
return nullptr;
const auto outputPortId = fromPorts[fromIndex]->externalId();

auto toMod = lookupModule(ModuleId(moduleIdTo));
if (!toMod)
return nullptr;
auto toPorts = toMod->inputPorts();
if (toIndex < 0 || toIndex >= toPorts.size())
return nullptr;
const auto inputPortId = toPorts[toIndex]->externalId();

const ConnectionId id = ConnectionId::create(ConnectionDescription(
OutgoingConnectionDescription(ModuleId(moduleIdFrom), outputPortId),
IncomingConnectionDescription(ModuleId(moduleIdTo), inputPortId)));
const auto connIter = connections_.find(id);
if (connIter != connections_.end())
{
return connIter->second;
}

return nullptr;
}

size_t Network::nmodules() const
Expand Down
2 changes: 1 addition & 1 deletion src/Dataflow/Network/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Networks {
ConnectionId connect(const ConnectionOutputPort&, const ConnectionInputPort&) override;
bool disconnect(const ConnectionId&) override;
size_t nconnections() const override;
void disable_connection(const ConnectionId&) override;
ConnectionHandle lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const override;
ConnectionDescriptionList connections(bool includeVirtual) const override;
int errorCode() const override;
void incrementErrorCode(const ModuleId& moduleId) override;
Expand Down
2 changes: 1 addition & 1 deletion src/Dataflow/Network/NetworkInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace Networks {
virtual ConnectionId connect(const ConnectionOutputPort&, const ConnectionInputPort&) = 0;
virtual bool disconnect(const ConnectionId&) = 0;
virtual size_t nconnections() const = 0;
virtual void disable_connection(const ConnectionId&) = 0;
virtual ConnectionHandle lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const = 0;
virtual ConnectionDescriptionList connections(bool includeVirtual) const = 0;
virtual void incrementErrorCode(const ModuleId& moduleId) = 0;
virtual NetworkGlobalSettings& settings() = 0;
Expand Down
1 change: 0 additions & 1 deletion src/Dataflow/Network/Port.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class SCISHARE Port : virtual public PortInterface, boost::noncopyable
Connection* connection(size_t) const override;
bool hasConnectionCountIncreased() const override;


PortId internalId() const override { return internalId_; }
void setId_DynamicCase(const PortId& id) override { internalId_ = externalId_ = id; }
void setInternalId(const PortId& id) override { internalId_ = id; }
Expand Down
2 changes: 1 addition & 1 deletion src/Dataflow/Network/Tests/MockNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ namespace SCIRun {
MOCK_CONST_METHOD1(lookupExecutable, ExecutableObject*(const ModuleId&));
MOCK_METHOD2(connect, ConnectionId(const ConnectionOutputPort&, const ConnectionInputPort&));
MOCK_METHOD1(disconnect, bool(const ConnectionId&));
MOCK_CONST_METHOD4(lookupConnection, ConnectionHandle(const std::string&, int, const std::string&, int));
MOCK_CONST_METHOD0(nconnections, size_t());
MOCK_METHOD1(disable_connection, void(const ConnectionId&));
MOCK_CONST_METHOD0(toString, std::string());
MOCK_CONST_METHOD1(connections, ConnectionDescriptionList(bool));
MOCK_CONST_METHOD0(errorCode, int());
Expand Down
Loading