Skip to content

Commit 7a99680

Browse files
authored
Merge branch 'master' into conditional
2 parents fd17a7f + 79f7fef commit 7a99680

File tree

11 files changed

+163
-30
lines changed

11 files changed

+163
-30
lines changed

src/Dataflow/Engine/Controller/NetworkEditorController.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,17 @@ boost::shared_ptr<boost::thread> NetworkEditorController::executeAll(const Execu
607607

608608
void NetworkEditorController::executeModule(const ModuleHandle& module, const ExecutableLookup* lookup, bool executeUpstream)
609609
{
610-
ExecuteSingleModule filter(module, *theNetwork_, executeUpstream);
611-
executeGeneric(lookup, filter);
610+
try
611+
{
612+
ExecuteSingleModule filter(module, *theNetwork_, executeUpstream);
613+
executeGeneric(lookup, filter);
614+
}
615+
catch (NetworkHasCyclesException&)
616+
{
617+
SCIRun::Core::Logging::Log::get() << SCIRun::Core::Logging::ERROR_LOG << "Cannot schedule execution: network has cycles. Please break all cycles and try again." << std::endl;
618+
ExecutionContext::executionBounds_.executeFinishes_(-1);
619+
return;
620+
}
612621
}
613622

614623
void NetworkEditorController::initExecutor()
@@ -624,6 +633,10 @@ ExecutionContextHandle NetworkEditorController::createExecutionContext(const Exe
624633
boost::shared_ptr<boost::thread> NetworkEditorController::executeGeneric(const ExecutableLookup* lookup, ModuleFilter filter)
625634
{
626635
initExecutor();
636+
637+
638+
639+
627640
auto context = createExecutionContext(lookup, filter);
628641

629642
return executionManager_.enqueueContext(context);

src/Dataflow/Engine/Scheduler/GraphNetworkAnalyzer.cc

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,40 @@ ComponentMap NetworkGraphAnalyzer::connectedComponents()
137137
return componentMap;
138138
}
139139

140+
namespace SCIRun
141+
{
142+
namespace Dataflow
143+
{
144+
namespace Engine
145+
{
146+
class ExecuteSingleModuleImpl
147+
{
148+
public:
149+
ParallelModuleExecutionOrder order_;
150+
bool isDownstreamFrom(const ModuleId& toCheckId, const ModuleId& rootId) const
151+
{
152+
return order_.groupOf(toCheckId) >= order_.groupOf(rootId);
153+
}
154+
};
155+
}
156+
}
157+
}
158+
140159
ExecuteSingleModule::ExecuteSingleModule(SCIRun::Dataflow::Networks::ModuleHandle mod,
141160
const SCIRun::Dataflow::Networks::NetworkInterface& network,
142161
bool executeUpstream) : module_(mod), network_(network), executeUpstream_(executeUpstream)
143162
{
144163
//TODO: composite with which filter?
145164
NetworkGraphAnalyzer analyze(network, ExecuteAllModules::Instance(), false);
146165
components_ = analyze.connectedComponents();
166+
167+
if (!executeUpstream_)
168+
{
169+
orderImpl_.reset(new ExecuteSingleModuleImpl);
170+
auto all = boost::lambda::constant(true);
171+
BoostGraphParallelScheduler scheduleAll(all);
172+
orderImpl_->order_ = scheduleAll.schedule(network_);
173+
}
147174
}
148175

149176
bool ExecuteSingleModule::operator()(SCIRun::Dataflow::Networks::ModuleHandle mod) const
@@ -167,11 +194,8 @@ bool ExecuteSingleModule::operator()(SCIRun::Dataflow::Networks::ModuleHandle mo
167194
}
168195
else
169196
{
170-
auto all = boost::lambda::constant(true);
171-
BoostGraphParallelScheduler scheduleAll(all);
172-
auto order = scheduleAll.schedule(network_);
173-
174197
// should execute if in same connected component, and downstream only
175-
return modIdIter->second == rootIdIter->second && order.groupOf(toCheckId) >= order.groupOf(rootId);
198+
return modIdIter->second == rootIdIter->second
199+
&& orderImpl_->isDownstreamFrom(toCheckId, rootId);
176200
}
177201
}

src/Dataflow/Engine/Scheduler/SchedulerInterfaces.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ namespace Engine {
137137
static const ModuleWaitingFilter& Instance();
138138
};
139139

140+
class ExecuteSingleModuleImpl;
141+
140142
struct SCISHARE ExecuteSingleModule
141143
{
142144
ExecuteSingleModule(SCIRun::Dataflow::Networks::ModuleHandle mod,
@@ -147,6 +149,7 @@ namespace Engine {
147149
const SCIRun::Dataflow::Networks::NetworkInterface& network_;
148150
std::map<std::string, int> components_;
149151
bool executeUpstream_;
152+
boost::shared_ptr<ExecuteSingleModuleImpl> orderImpl_;
150153
};
151154

152155
class SCISHARE WaitsForStartupInitialization

src/Interface/Application/Connection.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ void ConnectionLine::addSubnetCompanion(PortWidget* subnetPort)
386386

387387
subnetCompanion_->isCompanion_ = true;
388388
subnetCompanion_->trackNodes();
389+
subnetCompanion_->setVisible(true);
389390
}
390391

391392
void ConnectionLine::deleteCompanion()
@@ -554,6 +555,7 @@ void ConnectionLine::keyPressEvent(QKeyEvent* event)
554555
{
555556
if (event->key() == Qt::Key_I)
556557
DataInfoDialog::show(fromPort_->getPortDataDescriber(), "Connection", id_.id_);
558+
QGraphicsPathItem::keyPressEvent(event);
557559
}
558560

559561
ConnectionInProgressStraight::ConnectionInProgressStraight(PortWidget* port, ConnectionDrawStrategyPtr drawer)

src/Interface/Application/ModuleWidget.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,12 @@ void ModuleWidget::setupModuleActions()
522522
connect(this, SIGNAL(updateProgressBarSignal(double)), this, SLOT(updateProgressBar(double)));
523523
connect(actionsMenu_->getAction("Help"), SIGNAL(triggered()), this, SLOT(launchDocumentation()));
524524
connect(actionsMenu_->getAction("Duplicate"), SIGNAL(triggered()), this, SLOT(duplicate()));
525-
if (isViewScene_ || theModule_->hasDynamicPorts()) //TODO: buggy combination, will disable for now. Fix is #1035
525+
if (isViewScene_
526+
|| theModule_->hasDynamicPorts() //TODO: buggy combination, will disable for now. Fix is #1035
527+
|| theModule_->get_id().name_ == "Subnet")
526528
actionsMenu_->getMenu()->removeAction(actionsMenu_->getAction("Duplicate"));
529+
if (theModule_->get_id().name_ == "Subnet")
530+
actionsMenu_->getMenu()->removeAction(actionsMenu_->getAction("Replace With"));
527531

528532
connectNoteEditorToAction(actionsMenu_->getAction("Notes"));
529533
connectUpdateNote(this);

src/Interface/Application/NetworkEditor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ void NetworkEditor::clear()
13291329
QList<QGraphicsItem*> deleteTheseFirst;
13301330
Q_FOREACH(QGraphicsItem* item, scene_->items())
13311331
{
1332-
if (auto s = dynamic_cast<SubnetWidget*>(getModule(item)))
1332+
if (dynamic_cast<SubnetWidget*>(getModule(item)))
13331333
{
13341334
deleteTheseFirst.append(item);
13351335
}

src/Interface/Application/NetworkEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ namespace Gui {
323323
void showSubnetChild(const QString& name);
324324
void addSubnetChild(const QString& name, SCIRun::Dataflow::Networks::ModuleHandle mod);
325325
void removeSubnetChild(const QString& name);
326+
void subnetMenuActionTriggered();
326327

327328
Q_SIGNALS:
328329
void connectionDeleted(const SCIRun::Dataflow::Networks::ConnectionId& id);
@@ -425,6 +426,7 @@ namespace Gui {
425426
std::vector<QGraphicsItem*> subnetItemsToMove();
426427
PortRewiringMap portRewiringMap_;
427428
QSet<QString> currentSubnetNames_;
429+
std::map<std::string, QString> subnetNameMap_;
428430

429431
template <typename Func>
430432
void tailRecurse(Func func)

src/Interface/Application/SCIRunMainWindow.cc

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,10 @@ namespace {
10951095
}
10961096

10971097
const QString bullet = "* ";
1098+
const QString hash = "# ";
10981099
const QString favoritesText = bullet + "Favorites";
1099-
const QString clipboardHistoryText = bullet + "Clipboard History";
1100-
const QString savedSubsText = bullet + "Saved Subnetworks";
1100+
const QString clipboardHistoryText = hash + "Clipboard History";
1101+
const QString savedSubsText = hash + "Saved Fragments";
11011102

11021103
void addFavoriteMenu(QTreeWidget* tree)
11031104
{
@@ -1145,16 +1146,16 @@ namespace {
11451146

11461147
void readCustomSnippets(QTreeWidgetItem* snips)
11471148
{
1148-
QFile inputFile("snippets.txt");
1149+
QFile inputFile("patterns.txt");
11491150
if (inputFile.open(QIODevice::ReadOnly))
11501151
{
1151-
GuiLogger::Instance().logInfo("Snippet file opened: " + inputFile.fileName());
1152+
GuiLogger::Instance().logInfo("Pattern file opened: " + inputFile.fileName());
11521153
QTextStream in(&inputFile);
11531154
while (!in.atEnd())
11541155
{
11551156
QString line = in.readLine();
11561157
addSnippet(line, snips);
1157-
GuiLogger::Instance().logInfo("Snippet read: " + line);
1158+
GuiLogger::Instance().logInfo("Pattern read: " + line);
11581159
}
11591160
inputFile.close();
11601161
}
@@ -1163,7 +1164,7 @@ namespace {
11631164
void addSnippetMenu(QTreeWidget* tree)
11641165
{
11651166
auto snips = new QTreeWidgetItem();
1166-
snips->setText(0, bullet + "Snippets");
1167+
snips->setText(0, bullet + "Typical Patterns");
11671168
snips->setForeground(0, favesColor());
11681169

11691170
//hard-code a few popular ones.
@@ -1414,7 +1415,7 @@ void SCIRunMainWindow::renameSavedSubnetwork()
14141415
{
14151416
auto toRename = sender()->property("ID").toString();
14161417
bool ok;
1417-
auto text = QInputDialog::getText(this, tr("Rename subnet"), tr("Enter new subnet name:"), QLineEdit::Normal, savedSubnetworksNames_[toRename].toString(), &ok);
1418+
auto text = QInputDialog::getText(this, tr("Rename fragment"), tr("Enter new fragment name:"), QLineEdit::Normal, savedSubnetworksNames_[toRename].toString(), &ok);
14181419
if (ok && !text.isEmpty())
14191420
{
14201421
savedSubnetworksNames_[toRename] = text;
@@ -1573,8 +1574,7 @@ void SCIRunMainWindow::hideNonfunctioningWidgets()
15731574
nonfunctioningActions <<
15741575
actionInsert_;
15751576
QList<QMenu*> nonfunctioningMenus;
1576-
nonfunctioningMenus <<
1577-
menuSubnets_;
1577+
//nonfunctioningMenus << menuSubnets_;
15781578
QList<QWidget*> nonfunctioningWidgets;
15791579
nonfunctioningWidgets <<
15801580
prefsWindow_->scirunNetsLabel_ <<
@@ -1802,16 +1802,50 @@ void SCIRunMainWindow::addModuleToWindowList(const QString& modId, bool hasUI)
18021802
connect(modAction, SIGNAL(triggered()), networkEditor_, SLOT(moduleWindowAction()));
18031803
currentModuleActions_.insert(modId, modAction);
18041804
menuCurrent_->addAction(modAction);
1805+
1806+
if (modId.contains("Subnet"))
1807+
{
1808+
if (menuCurrentSubnets_->actions().isEmpty())
1809+
menuCurrentSubnets_->setEnabled(true);
1810+
1811+
auto subnetMenu = new QMenu(modId, this);
1812+
auto showAction = new QAction(subnetMenu);
1813+
showAction->setText("Show");
1814+
subnetMenu->addAction(showAction);
1815+
auto renameAction = new QAction(subnetMenu);
1816+
renameAction->setText("Rename...");
1817+
subnetMenu->addAction(renameAction);
1818+
1819+
connect(showAction, SIGNAL(triggered()), networkEditor_, SLOT(subnetMenuActionTriggered()));
1820+
connect(renameAction, SIGNAL(triggered()), networkEditor_, SLOT(subnetMenuActionTriggered()));
1821+
//qDebug() << "add" << modId;
1822+
currentSubnetActions_.insert(modId, subnetMenu);
1823+
menuCurrentSubnets_->addMenu(subnetMenu);
1824+
}
18051825
}
18061826

18071827
void SCIRunMainWindow::removeModuleFromWindowList(const ModuleId& modId)
18081828
{
18091829
auto name = QString::fromStdString(modId.id_);
1830+
//qDebug() << "remove" << name;
18101831
auto action = currentModuleActions_[name];
18111832
menuCurrent_->removeAction(action);
18121833
currentModuleActions_.remove(name);
18131834
if (menuCurrent_->actions().isEmpty())
18141835
menuCurrent_->setEnabled(false);
1836+
1837+
if (modId.id_.find("Subnet") != std::string::npos)
1838+
{
1839+
qDebug() << currentSubnetActions_;
1840+
auto subnet = currentSubnetActions_[name];
1841+
if (subnet)
1842+
subnet->setEnabled(false);
1843+
// //menuCurrentSubnets_->remove(subnet);
1844+
// currentSubnetActions_.remove(name);
1845+
// if (menuCurrentSubnets_->actions().isEmpty())
1846+
// menuCurrentSubnets_->setEnabled(false);
1847+
}
1848+
18151849
}
18161850

18171851
void SCIRunMainWindow::setupTagManagerWindow()
@@ -1912,11 +1946,10 @@ void SCIRunMainWindow::updateClipboardHistory(const QString& xml)
19121946

19131947
void SCIRunMainWindow::showSnippetHelp()
19141948
{
1915-
QMessageBox::information(this, "Snippets",
1916-
"Snippets are strings that encode a linear subnetwork. They can vastly shorten network construction time. They take the form [A->B->...->C] where A, B, C, etc are module names, and the arrow represents a connection between adjacent modules. "
1949+
QMessageBox::information(this, "Patterns",
1950+
"Patterns are strings that encode a linear subnetwork. They can vastly shorten network construction time. They take the form [A->B->...->C] where A, B, C, etc are module names, and the arrow represents a connection between adjacent modules. "
19171951
"\n\nThey are available in the module selector and work just like the single module entries there: double-click or drag onto the "
1918-
"network editor to insert the entire snippet. A '*' at the end of the module name will open the UI for that module.\n\nCustom snippets can be created by editing the file snippets.txt (if not present, create it) in the same folder as the SCIRun executable. Enter one snippet per line in the prescribed format, then restart SCIRun for them to appear."
1919-
"\n\nFeatures coming soon include: hotkeys."
1952+
"network editor to insert the entire snippet. A '*' at the end of the module name will open the UI for that module.\n\nCustom patterns can be created by editing the file patterns.txt (if not present, create it) in the same folder as the SCIRun executable. Enter one pattern per line in the prescribed format, then restart SCIRun for them to appear."
19201953
"\n\nFor feedback, please comment on this issue: https://github.com/SCIInstitute/SCIRun/issues/1263"
19211954
);
19221955
}
@@ -1926,9 +1959,9 @@ void SCIRunMainWindow::showClipboardHelp()
19261959
QMessageBox::information(this, "Clipboard",
19271960
"The network editor clipboard works on arbitrary network selections (modules and connections). A history of five copied items is kept under \"Clipboard History\" in the module selector. "
19281961
"\n\nTo cut/copy/paste, see the Edit menu and the corresponding hotkeys."
1929-
"\n\nClipboard history items can be starred like module favorites. When starred, they are saved as fragments under \"Saved Subnetworks,\" which are preserved in application settings. "
1930-
"\n\nThe user may edit the text of the saved subnetwork items to give them informative names, which are also saved. Hover over them to see a tooltip representation of the saved fragment."
1931-
"\n\nCurrently there is no way to delete a saved subnetwork in the GUI."
1962+
"\n\nClipboard history items can be starred like module favorites. When starred, they are saved as fragments under \"Saved Fragments,\" which are preserved in application settings. "
1963+
"\n\nThe user may edit the text of the saved fragment items to give them informative names, which are also saved. Hover over them to see a tooltip representation of the saved fragment."
1964+
"\n\nRight-click on the fragment item to rename or delete it."
19321965
);
19331966
}
19341967

src/Interface/Application/SCIRunMainWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public Q_SLOTS:
173173
int returnCode_ { 0 };
174174
QMap<QString,QMap<QString,QString>> styleSheetDetails_;
175175
QMap<QString, QAction*> currentModuleActions_;
176+
QMap<QString, QMenu*> currentSubnetActions_;
176177
boost::shared_ptr<class DialogErrorControl> dialogErrorControl_;
177178
boost::shared_ptr<class NetworkExecutionProgressBar> networkProgressBar_;
178179
boost::shared_ptr<class GuiActionProvenanceConverter> commandConverter_;

src/Interface/Application/SCIRunMainWindow.ui

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,26 @@
121121
</widget>
122122
<widget class="QMenu" name="menuSubnets_">
123123
<property name="enabled">
124-
<bool>false</bool>
124+
<bool>true</bool>
125125
</property>
126126
<property name="title">
127127
<string>&amp;Subnets</string>
128128
</property>
129+
<widget class="QMenu" name="menuCurrentSubnets_">
130+
<property name="title">
131+
<string>Current</string>
132+
</property>
133+
</widget>
134+
<widget class="QMenu" name="menuSavedSubnets_">
135+
<property name="enabled">
136+
<bool>false</bool>
137+
</property>
138+
<property name="title">
139+
<string>Saved</string>
140+
</property>
141+
</widget>
142+
<addaction name="menuCurrentSubnets_"/>
143+
<addaction name="menuSavedSubnets_"/>
129144
</widget>
130145
<widget class="QMenu" name="menuToolkits_">
131146
<property name="enabled">
@@ -239,8 +254,8 @@
239254
</widget>
240255
<addaction name="menuFile_"/>
241256
<addaction name="menuEdit"/>
242-
<addaction name="menuModules_"/>
243257
<addaction name="menuNetwork"/>
258+
<addaction name="menuModules_"/>
244259
<addaction name="menuSubnets_"/>
245260
<addaction name="menuToolkits_"/>
246261
<addaction name="menuWindow"/>
@@ -1147,6 +1162,16 @@
11471162
<string>Advanced</string>
11481163
</property>
11491164
</action>
1165+
<action name="actionX">
1166+
<property name="text">
1167+
<string>x</string>
1168+
</property>
1169+
</action>
1170+
<action name="actionA">
1171+
<property name="text">
1172+
<string>a</string>
1173+
</property>
1174+
</action>
11501175
</widget>
11511176
<resources/>
11521177
<connections>

0 commit comments

Comments
 (0)