Skip to content

Commit 297e3c9

Browse files
committed
Merge branch 'master' into embbWidget
2 parents 07b4b7b + 6135464 commit 297e3c9

16 files changed

+350
-32
lines changed

src/Interface/Application/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ SET(Interface_Application_FORMS
104104
Module.ui
105105
ModuleLogWindow.ui
106106
ConnectionStyleWizardPage.ui
107+
NetworkSearch.ui
107108
NoteEditor.ui
108109
Preferences.ui
109110
ProvenanceWindow.ui

src/Interface/Application/ModuleProxyWidget.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,4 @@ ProxyWidgetPosition::ProxyWidgetPosition(QGraphicsProxyWidget* widget, const QPo
430430
QPointF ProxyWidgetPosition::currentPosition() const
431431
{
432432
return widget_->pos() + offset_;
433-
}
433+
}

src/Interface/Application/NetworkEditor.cc

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,37 @@ void NetworkEditor::mouseReleaseEvent(QMouseEvent *event)
710710
QGraphicsView::mouseReleaseEvent(event);
711711
}
712712

713+
void NetworkEditor::mouseDoubleClickEvent(QMouseEvent* event)
714+
{
715+
#if 0
716+
if (!search_)
717+
{
718+
search_ = scene_->addWidget(new NetworkSearchWidget(this));
719+
search_->setOpacity(0.9);
720+
}
721+
search_->setPos(mapToScene(event->pos()));
722+
search_->setVisible(true);
723+
#endif
724+
QGraphicsView::mouseDoubleClickEvent(event);
725+
}
726+
727+
void NetworkEditor::hideSearchBox()
728+
{
729+
if (search_)
730+
search_->setVisible(false);
731+
}
732+
733+
NetworkSearchWidget::NetworkSearchWidget(NetworkEditor* ned)
734+
{
735+
setupUi(this);
736+
connect(closeButton_, SIGNAL(clicked()), ned, SLOT(hideSearchBox()));
737+
}
738+
739+
NetworkSearchWidgetProxy::NetworkSearchWidgetProxy(NetworkSearchWidget* nsw)
740+
{
741+
setWidget(nsw);
742+
}
743+
713744
ConnectionLine* NetworkEditor::getSingleConnectionSelected()
714745
{
715746
ConnectionLine* connectionSelected = nullptr;
@@ -832,6 +863,7 @@ ModuleTagsHandle NetworkEditor::dumpModuleTags(ModuleFilter filter) const
832863
tags->tags[mod->getModuleWidget()->getModuleId()] = mod->data(TagDataKey).toInt();
833864
}
834865
}
866+
tags->labels = tagLabelOverrides_;
835867
tags->showTagGroupsOnLoad = showTagGroupsOnFileLoad();
836868
return tags;
837869
}
@@ -906,6 +938,7 @@ void NetworkEditor::updateModuleTags(const ModuleTags& moduleTags)
906938
}
907939
}
908940
setShowTagGroupsOnFileLoad(moduleTags.showTagGroupsOnLoad);
941+
tagLabelOverrides_ = moduleTags.labels;
909942
if (showTagGroupsOnFileLoad())
910943
{
911944
tagGroupsActive_ = true;
@@ -1002,6 +1035,7 @@ void NetworkEditor::removeModuleWidget(const ModuleId& id)
10021035

10031036
void NetworkEditor::clear()
10041037
{
1038+
tagLabelOverrides_.clear();
10051039
ModuleWidget::NetworkClearingScope clearing;
10061040
//auto portSwitch = createDynamicPortDisabler();
10071041
scene_->clear();
@@ -1391,7 +1425,9 @@ namespace
13911425
class TagGroupBox : public QGraphicsRectItem
13921426
{
13931427
public:
1394-
explicit TagGroupBox(const QRectF& rect, NetworkEditor* ned) : QGraphicsRectItem(rect), ned_(ned)
1428+
explicit TagGroupBox(int tagNum, const QRectF& rect, NetworkEditor* ned) : QGraphicsRectItem(rect),
1429+
tagNumber_(tagNum),
1430+
ned_(ned)
13951431
{
13961432
setAcceptHoverEvents(true);
13971433
}
@@ -1409,15 +1445,20 @@ namespace
14091445
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override
14101446
{
14111447
QMenu menu;
1412-
auto action = menu.addAction("Display in saved network", ned_, SLOT(saveTagGroupRectInFile()));
1413-
action->setCheckable(true);
1414-
action->setChecked(ned_->showTagGroupsOnFileLoad());
1448+
auto autoDisplay = menu.addAction("Display in saved network", ned_, SLOT(saveTagGroupRectInFile()));
1449+
autoDisplay->setCheckable(true);
1450+
autoDisplay->setChecked(ned_->showTagGroupsOnFileLoad());
1451+
auto rename = menu.addAction("Rename in saved network...", ned_, SLOT(renameTagGroupInFile()));
1452+
rename->setProperty("tag", tagNumber_);
14151453
menu.exec(event->screenPos());
14161454
QGraphicsRectItem::mouseDoubleClickEvent(event);
14171455
}
14181456
private:
1457+
int tagNumber_;
14191458
NetworkEditor* ned_;
14201459
};
1460+
1461+
const int TagTextKey = 123;
14211462
}
14221463

14231464
void NetworkEditor::saveTagGroupRectInFile()
@@ -1427,6 +1468,25 @@ void NetworkEditor::saveTagGroupRectInFile()
14271468
Q_EMIT modified();
14281469
}
14291470

1471+
void NetworkEditor::renameTagGroupInFile()
1472+
{
1473+
auto action = qobject_cast<QAction*>(sender());
1474+
auto tagNum = action->property("tag").toInt();
1475+
1476+
bool ok;
1477+
auto text = QInputDialog::getText(this, tr("Rename tag group"),
1478+
tr("Enter new tag group name for this network file:"), QLineEdit::Normal, checkForOverriddenTagName(tagNum), &ok);
1479+
if (ok && !text.isEmpty())
1480+
{
1481+
bool changed = tagLabelOverrides_[tagNum] != text.toStdString();
1482+
tagLabelOverrides_[tagNum] = text.toStdString();
1483+
if (changed)
1484+
renameTagGroup(tagNum, text);
1485+
}
1486+
1487+
Q_EMIT modified();
1488+
}
1489+
14301490
void NetworkEditor::drawTagGroups()
14311491
{
14321492
if (tagGroupsActive_)
@@ -1458,11 +1518,12 @@ void NetworkEditor::drawTagGroups()
14581518
for (auto rectIter = tagItemRects.constBegin(); rectIter != tagItemRects.constEnd(); ++rectIter)
14591519
{
14601520
auto rectBounds = rectIter.value().adjusted(-10, -10, 10, 10);
1461-
QPen pen(tagColor_(rectIter.key()));
1521+
auto tagNum = rectIter.key();
1522+
QPen pen(tagColor_(tagNum));
14621523
pen.setWidth(3);
14631524
pen.setCapStyle(Qt::RoundCap);
14641525
pen.setJoinStyle(Qt::RoundJoin);
1465-
auto rect = new TagGroupBox(rectBounds, this);
1526+
auto rect = new TagGroupBox(tagNum, rectBounds, this);
14661527
rect->setPen(pen);
14671528
scene_->addItem(rect);
14681529
rect->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable);
@@ -1476,15 +1537,25 @@ void NetworkEditor::drawTagGroups()
14761537
scene_->addItem(fill);
14771538

14781539
static const QFont labelFont("Courier", 20, QFont::Bold);
1479-
auto label = scene_->addSimpleText(tagName_(rectIter.key()), labelFont);
1540+
1541+
auto label = scene_->addSimpleText(checkForOverriddenTagName(tagNum), labelFont);
14801542
label->setBrush(pen.color());
1543+
label->setData(TagTextKey, tagNum);
14811544
static const QFontMetrics fm(labelFont);
14821545
auto textWidthInPixels = fm.width(label->text());
14831546
label->setPos((rect->rect().topLeft() + rect->rect().topRight()) / 2 + QPointF(-textWidthInPixels / 2, -30));
14841547
}
14851548
}
14861549
}
14871550

1551+
QString NetworkEditor::checkForOverriddenTagName(int tag) const
1552+
{
1553+
auto nameOverrideIter = tagLabelOverrides_.find(tag);
1554+
if (nameOverrideIter != tagLabelOverrides_.end() && !nameOverrideIter->second.empty())
1555+
return QString::fromStdString(nameOverrideIter->second);
1556+
return tagName_(tag);
1557+
}
1558+
14881559
void NetworkEditor::removeTagGroups()
14891560
{
14901561
Q_FOREACH(QGraphicsItem* item, scene_->items())
@@ -1496,6 +1567,21 @@ void NetworkEditor::removeTagGroups()
14961567
}
14971568
}
14981569

1570+
void NetworkEditor::renameTagGroup(int tag, const QString& name)
1571+
{
1572+
Q_FOREACH(QGraphicsItem* item, scene_->items())
1573+
{
1574+
if (auto rectLabel = dynamic_cast<QGraphicsSimpleTextItem*>(item))
1575+
{
1576+
if (rectLabel->data(TagTextKey).toInt() == tag)
1577+
{
1578+
rectLabel->setText(name);
1579+
return;
1580+
}
1581+
}
1582+
}
1583+
}
1584+
14991585
void NetworkEditor::redrawTagGroups()
15001586
{
15011587
removeTagGroups();
@@ -1510,6 +1596,7 @@ void NetworkEditor::highlightTaggedItem(int tagValue)
15101596

15111597
void NetworkEditor::highlightTaggedItem(QGraphicsItem* item, int tagValue)
15121598
{
1599+
qDebug() << "highlightTaggedItem" << tagValue;
15131600
if (tagValue == NoTag)
15141601
{
15151602
item->setGraphicsEffect(blurEffect());

src/Interface/Application/NetworkEditor.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include <QGraphicsView>
3333
#include <QGraphicsTextItem>
34+
#include <QGraphicsProxyWidget>
35+
#include "ui_NetworkSearch.h"
3436
#ifndef Q_MOC_RUN
3537
#include <boost/shared_ptr.hpp>
3638
#include <atomic>
@@ -87,7 +89,7 @@ namespace Gui {
8789
{
8890
Q_OBJECT
8991
public:
90-
explicit ErrorItem(const QString& text, std::function<void()> showModule, QGraphicsItem* parent = 0);
92+
explicit ErrorItem(const QString& text, std::function<void()> showModule, QGraphicsItem* parent = nullptr);
9193
~ErrorItem();
9294
int num() const { return counter_; }
9395
protected:
@@ -104,6 +106,20 @@ namespace Gui {
104106
static std::atomic<int> instanceCounter_;
105107
};
106108

109+
class NetworkSearchWidget : public QWidget, public Ui::NetworkSearch
110+
{
111+
Q_OBJECT
112+
public:
113+
explicit NetworkSearchWidget(class NetworkEditor* ned);
114+
};
115+
116+
class NetworkSearchWidgetProxy : public QGraphicsProxyWidget
117+
{
118+
Q_OBJECT
119+
public:
120+
explicit NetworkSearchWidgetProxy(NetworkSearchWidget* base);
121+
};
122+
107123
class ModuleEventProxy : public QObject
108124
{
109125
Q_OBJECT
@@ -221,6 +237,7 @@ namespace Gui {
221237
virtual void wheelEvent(QWheelEvent* event) override;
222238
virtual void contextMenuEvent(QContextMenuEvent *event) override;
223239
virtual void mousePressEvent(QMouseEvent *event) override;
240+
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
224241

225242
public Q_SLOTS:
226243
void addModuleWidget(const std::string& name, SCIRun::Dataflow::Networks::ModuleHandle module, const SCIRun::Dataflow::Engine::ModuleCounter& count);
@@ -256,6 +273,7 @@ namespace Gui {
256273
void adjustModuleWidth(int delta);
257274
void adjustModuleHeight(int delta);
258275
void saveTagGroupRectInFile();
276+
void renameTagGroupInFile();
259277

260278
Q_SIGNALS:
261279
void addConnection(const SCIRun::Dataflow::Networks::ConnectionDescription&);
@@ -283,6 +301,7 @@ namespace Gui {
283301
void paste();
284302
void bringToFront();
285303
void sendToBack();
304+
void hideSearchBox();
286305

287306
private:
288307
typedef QPair<ModuleWidget*, ModuleWidget*> ModulePair;
@@ -298,6 +317,8 @@ namespace Gui {
298317
void pasteImpl(const QString& xml);
299318
void drawTagGroups();
300319
void removeTagGroups();
320+
QString checkForOverriddenTagName(int tag) const;
321+
void renameTagGroup(int tag, const QString& name);
301322
bool modulesSelectedByCL_;
302323
double currentScale_;
303324
bool tagLayerActive_;
@@ -316,10 +337,12 @@ namespace Gui {
316337
boost::shared_ptr<ModuleEventProxy> moduleEventProxy_;
317338
boost::shared_ptr<ZLevelManager> zLevelManager_;
318339
std::string latestModuleId_;
340+
std::map<int, std::string> tagLabelOverrides_;
319341
bool fileLoading_;
320342
bool insertingNewModuleAlongConnection_ { false };
321343
PreexecuteFunc preexecute_;
322344
bool showTagGroupsOnFileLoad_ { false };
345+
QGraphicsProxyWidget* search_ { nullptr };
323346
};
324347
}
325348
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>NetworkSearch</class>
4+
<widget class="QWidget" name="NetworkSearch">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>432</width>
10+
<height>27</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QHBoxLayout" name="horizontalLayout">
17+
<property name="leftMargin">
18+
<number>2</number>
19+
</property>
20+
<property name="topMargin">
21+
<number>0</number>
22+
</property>
23+
<property name="rightMargin">
24+
<number>2</number>
25+
</property>
26+
<property name="bottomMargin">
27+
<number>0</number>
28+
</property>
29+
<item>
30+
<widget class="QLabel" name="label">
31+
<property name="font">
32+
<font>
33+
<weight>75</weight>
34+
<bold>true</bold>
35+
</font>
36+
</property>
37+
<property name="styleSheet">
38+
<string notr="true"/>
39+
</property>
40+
<property name="text">
41+
<string>Search network:</string>
42+
</property>
43+
</widget>
44+
</item>
45+
<item>
46+
<widget class="QLineEdit" name="searchLineEdit_"/>
47+
</item>
48+
<item>
49+
<widget class="QToolButton" name="closeButton_">
50+
<property name="maximumSize">
51+
<size>
52+
<width>16777215</width>
53+
<height>21</height>
54+
</size>
55+
</property>
56+
<property name="styleSheet">
57+
<string notr="true">QPushButton { color: red }</string>
58+
</property>
59+
<property name="text">
60+
<string>X</string>
61+
</property>
62+
</widget>
63+
</item>
64+
</layout>
65+
</widget>
66+
<resources/>
67+
<connections/>
68+
</ui>

src/Interface/Application/SCIRunMainWindow.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,6 @@ void SCIRunMainWindow::showKeyboardShortcutsDialog()
18661866

18671867
void SCIRunMainWindow::runNewModuleWizard()
18681868
{
1869-
qDebug() << "new module wizard coming soon";
18701869
auto wizard = new ClassWizard(this);
18711870
wizard->show();
18721871
}

src/Interface/Application/TagManagerWindow.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ QColor TagManagerWindow::tagColor(int tag) const
134134

135135
QString TagManagerWindow::tagName(int tag) const
136136
{
137-
if (0 <= tag && tag < NumberOfTags)
138-
return tagNames_[tag];
139-
return "[No tag]";
137+
auto name = (0 <= tag && tag < NumberOfTags) ? tagNames_[tag] : "[No tag]";
138+
qDebug() << "tagName" << tag << name;
139+
return name;
140140
}
141141

142142
void TagManagerWindow::showHelp(QWidget* parent)
@@ -149,8 +149,8 @@ void TagManagerWindow::showHelp(QWidget* parent)
149149
"according to the chosen colors). Or press 0 - 9 keys to see each tag group individually; other modules will be slightly blurred out. While in "
150150
"the single - tag view, you can click a module to toggle it as tagged. There is also a button in the toolbar to view all tagged modules."
151151
"\n\nOnce tags are being used, tag groups can be toggled using Alt-G (show) and Alt-Shift-G (hide). Boxes of the tag color, labelled with the tag's text, will be displayed overlaying the network. "
152-
"To display tag groups on network load, double-click on a tag group box and select the option in the menu. "
153-
"\n\nComing soon: tag names saved in the network file to override application-level names."
152+
"To display tag groups on network load, double-click on a tag group box and select the display option in the menu. "
153+
"\n\nTag names saved in the network file can override application-level names--double-click a displayed tag group box and select the rename option."
154154
);
155155
}
156156

0 commit comments

Comments
 (0)