Skip to content

Commit 172b7dd

Browse files
authored
Merge pull request #1610 from SCIInstitute/subnets
Subnets, part 1
2 parents 7b4c320 + 189f384 commit 172b7dd

29 files changed

+1137
-479
lines changed

src/Core/Algorithms/BrainStimulator/Tests/GenerateROIStatisticsAlgorithmTests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace
7575
(*expected_result)(0, 1) = 0.2023192248404992; (*expected_result)(1, 1) = std::numeric_limits<double>::quiet_NaN(); (*expected_result)(2, 1) = 0.270036948169627; (*expected_result)(3, 1) = 0.2819928747450936; (*expected_result)(4, 1) = 0.2464919130115238; (*expected_result)(5, 1) = 0.348358459345021; (*expected_result)(6, 1) = 0.3382031144990396; (*expected_result)(7, 1) = 0.1699586184078796;
7676
(*expected_result)(0, 2) = 0.1868726045543786; (*expected_result)(1, 2) = 0.7546866819823609; (*expected_result)(2, 2) = 0.1189976815583766; (*expected_result)(3, 2) = 0.223811939491137; (*expected_result)(4, 2) = 0.2550951154592691; (*expected_result)(5, 2) = 0.1386244428286791; (*expected_result)(6, 2) = 0.2435249687249893; (*expected_result)(7, 2) = 0.1965952504312082;
7777
(*expected_result)(0, 3) = 0.7951999011370632; (*expected_result)(1, 3) = 0.7546866819823609; (*expected_result)(2, 3) = 0.6797026768536748; (*expected_result)(3, 3) = 0.9597439585160811; (*expected_result)(4, 3) = 0.8909032525357985; (*expected_result)(5, 3) = 0.9592914252054443; (*expected_result)(6, 3) = 0.9292636231872278; (*expected_result)(7, 3) = 0.6160446761466392;
78-
(*expected_result)(0, 4) = 9; (*expected_result)(1, 4) = 1; (*expected_result)(2, 4) = 5; (*expected_result)(3, 4) = 5; (*expected_result)(4, 4) = 5; (*expected_result)(5, 4) = 5; (*expected_result)(6, 4) = 5; (*expected_result)(7, 4) = 5;
78+
(*expected_result)(0, 4) = 9; (*expected_result)(1, 4) = 1; (*expected_result)(2, 4) = 5; (*expected_result)(3, 4) = 5; (*expected_result)(4, 4) = 5; (*expected_result)(5, 4) = 5; (*expected_result)(6, 4) = 5; (*expected_result)(7, 4) = 5;
7979

8080
return expected_result;
8181
}
@@ -153,7 +153,7 @@ TEST(GenerateROIStatisticsAlgorithm, ValidInput_TestCoordinateSpace)
153153
FieldHandle atlas = CreateAtlas();
154154
FieldHandle createcoordcubesshiftby10 = CreateCoordinatesCubesShiftedBy10();
155155
FieldHandle createmeshsolution = CreateGetMeshSolution();
156-
const std::string& atlasMeshLabelsStr = std::string("Region1;Region2;Region3;Region4;Region5;Region6;Region7;Region8");
156+
std::string atlasMeshLabelsStr("Region1;Region2;Region3;Region4;Region5;Region6;Region7;Region8");
157157
DenseMatrixHandle specROI(new DenseMatrix(5, 1));
158158
(*specROI)(0, 0) = 10.5;
159159
(*specROI)(1, 0) = 10.5;

src/Dataflow/Engine/Controller/ProvenanceManager.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ namespace Engine {
4444
class ProvenanceManager : boost::noncopyable
4545
{
4646
public:
47-
typedef ProvenanceItem<Memento> Item;
48-
typedef typename Item::Handle ItemHandle;
49-
typedef std::stack<ItemHandle> Stack;
50-
typedef typename Stack::container_type List;
51-
typedef Engine::NetworkIOInterface<Memento> IOType;
47+
using Item = ProvenanceItem<Memento>;
48+
using ItemHandle = typename Item::Handle;
49+
using Stack = std::stack<ItemHandle>;
50+
using List = typename Stack::container_type;
51+
using IOType = Engine::NetworkIOInterface<Memento>;
5252

5353
explicit ProvenanceManager(IOType* networkIO);
5454
void setInitialState(const Memento& initialState);

src/Dataflow/Engine/Scheduler/GraphNetworkAnalyzer.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ bool ExecuteSingleModule::operator()(SCIRun::Dataflow::Networks::ModuleHandle mo
154154
THROW_INVALID_ARGUMENT("Module not found in component map");
155155

156156
auto rootId = module_->get_id();
157+
if (rootId.name_ == "Subnet")
158+
return false;
157159
auto rootIdIter = components_.find(rootId);
158160
if (rootIdIter == components_.end())
159161
THROW_INVALID_ARGUMENT("Current module not found in component map");
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<!DOCTYPE boost_serialization>
3+
<boost_serialization signature="serialization::archive" version="12">
4+
<networkFile class_id="0" tracking_level="0" version="5">
5+
<networkInfo class_id="1" tracking_level="0" version="0">
6+
<modules class_id="2" tracking_level="0" version="0">
7+
<count>1</count>
8+
<item_version>0</item_version>
9+
<item class_id="3" tracking_level="0" version="0">
10+
<first>ReadField:0</first>
11+
<second class_id="4" tracking_level="0" version="0">
12+
<module class_id="5" tracking_level="0" version="0">
13+
<package_name_>SCIRun</package_name_>
14+
<category_name_>DataIO</category_name_>
15+
<module_name_>ReadField</module_name_>
16+
</module>
17+
<state class_id="6" tracking_level="0" version="0">
18+
<stateMap class_id="7" tracking_level="0" version="0">
19+
<count>3</count>
20+
<item_version>0</item_version>
21+
<item class_id="8" tracking_level="0" version="0">
22+
<first class_id="9" tracking_level="0" version="0">
23+
<name>FileTypeName</name>
24+
</first>
25+
<second class_id="10" tracking_level="0" version="0">
26+
<name>FileTypeName</name>
27+
<value class_id="11" tracking_level="0" version="0">
28+
<which>2</which>
29+
<value>SCIRun Field File (*.fld)</value>
30+
</value>
31+
</second>
32+
</item>
33+
<item>
34+
<first>
35+
<name>Filename</name>
36+
</first>
37+
<second>
38+
<name>Filename</name>
39+
<value>
40+
<which>2</which>
41+
<value></value>
42+
</value>
43+
</second>
44+
</item>
45+
<item>
46+
<first>
47+
<name>ScriptEnvironmentVariable</name>
48+
</first>
49+
<second>
50+
<name>ScriptEnvironmentVariable</name>
51+
<value>
52+
<which>2</which>
53+
<value></value>
54+
</value>
55+
</second>
56+
</item>
57+
</stateMap>
58+
</state>
59+
</second>
60+
</item>
61+
</modules>
62+
<connections class_id="12" tracking_level="0" version="0">
63+
<count>0</count>
64+
<item_version>0</item_version>
65+
</connections>
66+
</networkInfo>
67+
<modulePositions class_id="13" tracking_level="0" version="0">
68+
<count>2</count>
69+
<item_version>0</item_version>
70+
<item class_id="14" tracking_level="0" version="0">
71+
<first>ReadField:0</first>
72+
<second class_id="15" tracking_level="0" version="0">
73+
<first>4.90000000000000000e+01</first>
74+
<second>1.40000000000000000e+01</second>
75+
</second>
76+
</item>
77+
<item>
78+
<first>Subnet:0</first>
79+
<second>
80+
<first>1.29000000000000000e+02</first>
81+
<second>9.40000000000000000e+01</second>
82+
</second>
83+
</item>
84+
</modulePositions>
85+
<moduleNotes class_id="16" tracking_level="0" version="0">
86+
<count>0</count>
87+
<item_version>0</item_version>
88+
</moduleNotes>
89+
<connectionNotes>
90+
<count>0</count>
91+
<item_version>0</item_version>
92+
</connectionNotes>
93+
<moduleTags class_id="17" tracking_level="0" version="0">
94+
<count>2</count>
95+
<item_version>0</item_version>
96+
<item class_id="18" tracking_level="0" version="0">
97+
<first>ReadField:0</first>
98+
<second>-1</second>
99+
</item>
100+
<item>
101+
<first>Subnet:0</first>
102+
<second>-1</second>
103+
</item>
104+
</moduleTags>
105+
<disabledModules class_id="19" tracking_level="0" version="0">
106+
<count>0</count>
107+
<item_version>0</item_version>
108+
</disabledModules>
109+
<disabledConnections>
110+
<count>0</count>
111+
<item_version>0</item_version>
112+
</disabledConnections>
113+
<moduleTagLabels class_id="20" tracking_level="0" version="0">
114+
<count>0</count>
115+
<item_version>0</item_version>
116+
</moduleTagLabels>
117+
<loadTagGroups>0</loadTagGroups>
118+
</networkFile>
119+
</boost_serialization>
120+

src/Interface/Application/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ SET(Interface_Application_SOURCES
6262
TreeViewCollaborators.cc
6363
ModuleWizard/ModuleWizard.cc
6464
TriggeredEventsWindow.cc
65+
Subnetworks.cc
6566
)
6667

6768
SET(Interface_Application_HEADERS
@@ -95,6 +96,7 @@ SET(Interface_Application_HEADERS
9596
NetworkEditorControllerGuiProxy.h
9697
TreeViewCollaborators.h
9798
Utility.h
99+
Subnetworks.h
98100
ModuleWizard/ModuleWizard.h
99101
TriggeredEventsWindow.h
100102
)
@@ -111,6 +113,7 @@ SET(Interface_Application_FORMS
111113
ProvenanceWindow.ui
112114
SCIRunMainWindow.ui
113115
ShortcutsInterface.ui
116+
SubnetEditor.ui
114117
RenderWindow.ui
115118
TagManager.ui
116119
TriggeredEventsWindow.ui

src/Interface/Application/ClosestPortFinder.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535

3636
using namespace SCIRun::Gui;
3737

38-
ClosestPortFinder::ClosestPortFinder(QGraphicsScene* scene) : scene_(scene) {}
38+
ClosestPortFinder::ClosestPortFinder(QGraphicsProxyWidget* module) : module_(module) {}
3939

4040
PortWidget* ClosestPortFinder::closestPort(const QPointF& pos)
4141
{
42-
Q_FOREACH (QGraphicsItem* item, scene_->items(pos))
42+
Q_FOREACH(QGraphicsItem* item, module_->scene()->items(pos))
4343
{
4444
if (auto mpw = dynamic_cast<ModuleProxyWidget*>(item))
4545
{
@@ -49,7 +49,7 @@ PortWidget* ClosestPortFinder::closestPort(const QPointF& pos)
4949
return *std::min_element(ports.begin(), ports.end(), [=](PortWidget* lhs, PortWidget* rhs) {return lessPort(pos, lhs, rhs); });
5050
}
5151
}
52-
return 0;
52+
return nullptr;
5353
}
5454

5555
int ClosestPortFinder::distance(const QPointF& pos, PortWidget* port) const

src/Interface/Application/ClosestPortFinder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ namespace Gui {
4040
class ClosestPortFinder
4141
{
4242
public:
43-
explicit ClosestPortFinder(QGraphicsScene* scene);
43+
explicit ClosestPortFinder(QGraphicsProxyWidget* module);
4444
PortWidget* closestPort(const QPointF& pos);
4545
private:
46-
QGraphicsScene* scene_;
46+
QGraphicsProxyWidget* module_;
4747
int distance(const QPointF& pos, PortWidget* port) const;
4848
bool lessPort(const QPointF& pos, PortWidget* lhs, PortWidget* rhs) const;
4949
};

src/Interface/Application/Connection.cc

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -583,32 +583,33 @@ QPointF MidpointPositionerFromPorts::currentPosition() const
583583
return (p1_->getPositionObject()->currentPosition() + p2_->getPositionObject()->currentPosition()) / 2;
584584
}
585585

586-
ConnectionFactory::ConnectionFactory(QGraphicsScene* scene) :
587-
currentType_(EUCLIDEAN),
588-
visible_(true),
589-
scene_(scene),
590-
euclidean_(new EuclideanDrawStrategy),
591-
cubic_(new CubicBezierDrawStrategy),
592-
manhattan_(new ManhattanDrawStrategy)
586+
ConnectionFactory::ConnectionFactory(QGraphicsProxyWidget* module) :
587+
module_(module)
593588
{}
589+
590+
bool ConnectionFactory::visible_(true);
591+
ConnectionDrawType ConnectionFactory::currentType_(ConnectionDrawType::EUCLIDEAN);
592+
ConnectionDrawStrategyPtr ConnectionFactory::euclidean_(new EuclideanDrawStrategy);
593+
ConnectionDrawStrategyPtr ConnectionFactory::cubic_(new CubicBezierDrawStrategy);
594+
ConnectionDrawStrategyPtr ConnectionFactory::manhattan_(new ManhattanDrawStrategy);
594595

595596
ConnectionInProgress* ConnectionFactory::makeConnectionInProgress(PortWidget* port) const
596597
{
597598
switch (currentType_)
598599
{
599-
case EUCLIDEAN:
600+
case ConnectionDrawType::EUCLIDEAN:
600601
{
601602
auto c = new ConnectionInProgressStraight(port, getCurrentDrawer());
602603
activate(c);
603604
return c;
604605
}
605-
case CUBIC:
606+
case ConnectionDrawType::CUBIC:
606607
{
607608
auto c = new ConnectionInProgressCurved(port, getCurrentDrawer());
608609
activate(c);
609610
return c;
610611
}
611-
case MANHATTAN:
612+
case ConnectionDrawType::MANHATTAN:
612613
{
613614
auto c = new ConnectionInProgressManhattan(port, getCurrentDrawer());
614615
activate(c);
@@ -632,8 +633,8 @@ void ConnectionFactory::activate(QGraphicsItem* item) const
632633
{
633634
if (item)
634635
{
635-
if (scene_)
636-
scene_->addItem(item);
636+
if (module_)
637+
module_->scene()->addItem(item);
637638
item->setVisible(visible_);
638639
}
639640
}
@@ -643,35 +644,33 @@ void ConnectionFactory::setType(ConnectionDrawType type)
643644
if (type != currentType_)
644645
{
645646
currentType_ = type;
646-
Q_EMIT typeChanged(getCurrentDrawer());
647647
}
648648
}
649649

650-
ConnectionDrawType ConnectionFactory::getType() const
650+
ConnectionDrawType ConnectionFactory::getType()
651651
{
652652
return currentType_;
653653
}
654654

655-
ConnectionDrawStrategyPtr ConnectionFactory::getCurrentDrawer() const
655+
ConnectionDrawStrategyPtr ConnectionFactory::getCurrentDrawer()
656656
{
657657
switch (currentType_)
658658
{
659-
case EUCLIDEAN:
659+
case ConnectionDrawType::EUCLIDEAN:
660660
return euclidean_;
661-
case CUBIC:
661+
case ConnectionDrawType::CUBIC:
662662
return cubic_;
663-
case MANHATTAN:
663+
case ConnectionDrawType::MANHATTAN:
664664
return manhattan_;
665665
default:
666666
std::cerr << "Unknown connection type." << std::endl;
667-
return ConnectionDrawStrategyPtr();
667+
return nullptr;
668668
}
669669
}
670670

671671
ConnectionLine* ConnectionFactory::makeFinishedConnection(PortWidget* fromPort, PortWidget* toPort, const ConnectionId& id) const
672672
{
673673
auto c = new ConnectionLine(fromPort, toPort, id, getCurrentDrawer());
674674
activate(c);
675-
connect(this, SIGNAL(typeChanged(ConnectionDrawStrategyPtr)), c, SLOT(setDrawStrategy(ConnectionDrawStrategyPtr)));
676675
return c;
677676
}

src/Interface/Application/Connection.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ConnectionDrawStrategy
5353

5454
typedef boost::shared_ptr<ConnectionDrawStrategy> ConnectionDrawStrategyPtr;
5555

56-
enum ConnectionDrawType
56+
enum class ConnectionDrawType
5757
{
5858
MANHATTAN, EUCLIDEAN, CUBIC
5959
};
@@ -225,28 +225,29 @@ class ConnectionInProgressManhattan : public ConnectionInProgressGraphicsItem<QG
225225
virtual void update(const QPointF& end);
226226
};
227227

228-
class ConnectionFactory : public QObject
228+
class ConnectionFactory
229229
{
230-
Q_OBJECT
231230
public:
232-
explicit ConnectionFactory(QGraphicsScene* scene);
231+
explicit ConnectionFactory(QGraphicsProxyWidget* module);
232+
233233
ConnectionInProgress* makeConnectionInProgress(PortWidget* port) const;
234234
ConnectionInProgress* makePotentialConnection(PortWidget* port) const;
235235
ConnectionLine* makeFinishedConnection(PortWidget* fromPort, PortWidget* toPort, const SCIRun::Dataflow::Networks::ConnectionId& id) const;
236-
void setType(ConnectionDrawType type);
237-
ConnectionDrawType getType() const;
238-
void setVisibility(bool visible) { visible_ = visible; }
239236
void activate(QGraphicsItem* item) const;
240-
Q_SIGNALS:
241-
void typeChanged(ConnectionDrawStrategyPtr drawerMaker);
237+
238+
static void setType(ConnectionDrawType type);
239+
static ConnectionDrawType getType();
240+
static ConnectionDrawStrategyPtr getCurrentDrawer();
241+
static void setVisibility(bool visible) { visible_ = visible; }
242+
242243
private:
243-
ConnectionDrawType currentType_;
244-
bool visible_;
245-
QGraphicsScene* scene_;
246-
ConnectionDrawStrategyPtr euclidean_;
247-
ConnectionDrawStrategyPtr cubic_;
248-
ConnectionDrawStrategyPtr manhattan_;
249-
ConnectionDrawStrategyPtr getCurrentDrawer() const;
244+
static ConnectionDrawType currentType_;
245+
static bool visible_;
246+
static ConnectionDrawStrategyPtr euclidean_;
247+
static ConnectionDrawStrategyPtr cubic_;
248+
static ConnectionDrawStrategyPtr manhattan_;
249+
250+
QGraphicsProxyWidget* module_;
250251
};
251252

252253
}

0 commit comments

Comments
 (0)