Skip to content

Commit 43807b2

Browse files
committed
Working on save/display tag groups
1 parent b929e40 commit 43807b2

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ namespace Networks {
8282
typedef std::map<std::string, ModuleWithState> ModuleMapXML;
8383
typedef std::map<std::string, NoteXML> NotesMapXML;
8484
typedef std::map<std::string, int> ModuleTagsMapXML;
85+
typedef std::map<int, std::string> ModuleTagLabelOverridesMapXML;
8586
typedef std::vector<std::string> DisabledComponentListXML;
8687

8788
struct SCISHARE ModuleNotes
@@ -97,6 +98,8 @@ namespace Networks {
9798
struct SCISHARE ModuleTags
9899
{
99100
ModuleTagsMapXML tags;
101+
ModuleTagLabelOverridesMapXML labels;
102+
bool showTagGroupsOnLoad;
100103
};
101104

102105
struct SCISHARE DisabledComponents
@@ -146,6 +149,11 @@ namespace Networks {
146149
ar & boost::serialization::make_nvp("disabledModules", disabledComponents.disabledModules);
147150
ar & boost::serialization::make_nvp("disabledConnections", disabledComponents.disabledConnections);
148151
}
152+
if (version > 4)
153+
{
154+
ar & boost::serialization::make_nvp("moduleTagLabels", moduleTags.labels);
155+
ar & boost::serialization::make_nvp("loadTagGroups", moduleTags.showTagGroupsOnLoad);
156+
}
149157
}
150158
};
151159

@@ -164,6 +172,6 @@ namespace Networks {
164172

165173
}}}
166174

167-
BOOST_CLASS_VERSION(SCIRun::Dataflow::Networks::NetworkFile, 4)
175+
BOOST_CLASS_VERSION(SCIRun::Dataflow::Networks::NetworkFile, 5)
168176

169177
#endif

src/Interface/Application/NetworkEditor.cc

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,48 @@ void NetworkEditor::tagLayer(bool active, int tag)
13461346
}
13471347
}
13481348

1349+
namespace
1350+
{
1351+
class TagGroupBox : public QGraphicsRectItem
1352+
{
1353+
public:
1354+
explicit TagGroupBox(const QRectF& rect, NetworkEditor* ned) : QGraphicsRectItem(rect), ned_(ned), displayOnLoad_(false)
1355+
{
1356+
setAcceptHoverEvents(true);
1357+
}
1358+
protected:
1359+
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*) override
1360+
{
1361+
setPen(QPen(pen().color(), 5));
1362+
}
1363+
1364+
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override
1365+
{
1366+
setPen(QPen(pen().color(), 3));
1367+
}
1368+
1369+
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override
1370+
{
1371+
QMenu menu;
1372+
auto action = menu.addAction("Display in saved network", ned_, SLOT(saveTagGroupRectInFile()));
1373+
action->setCheckable(true);
1374+
action->setChecked(displayOnLoad_);
1375+
menu.exec(event->screenPos());
1376+
QGraphicsRectItem::mouseDoubleClickEvent(event);
1377+
}
1378+
private:
1379+
NetworkEditor* ned_;
1380+
bool displayOnLoad_;
1381+
};
1382+
}
1383+
1384+
void NetworkEditor::saveTagGroupRectInFile()
1385+
{
1386+
qDebug() << "saveTagGroupRectInFile" << sender();
1387+
auto action = qobject_cast<QAction*>(sender());
1388+
action->setChecked(!action->isChecked());
1389+
}
1390+
13491391
void NetworkEditor::drawTagGroups()
13501392
{
13511393
QMap<int,QRectF> tagItemRects;
@@ -1379,13 +1421,17 @@ void NetworkEditor::drawTagGroups()
13791421
pen.setWidth(3);
13801422
pen.setCapStyle(Qt::RoundCap);
13811423
pen.setJoinStyle(Qt::RoundJoin);
1382-
auto rect = scene_->addRect(rectBounds, pen);
1424+
auto rect = new TagGroupBox(rectBounds, this);
1425+
rect->setPen(pen);
1426+
scene_->addItem(rect);
13831427
rect->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable);
1428+
rect->setZValue(-100000);
13841429

13851430
auto fill = new QGraphicsRectItem(rectBounds);
13861431
auto c = pen.color();
13871432
c.setAlphaF(0.15);
13881433
fill->setBrush(c);
1434+
fill->setZValue(-100000);
13891435
scene_->addItem(fill);
13901436

13911437
static const QFont labelFont("Courier", 20, QFont::Bold);

src/Interface/Application/NetworkEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ namespace Gui {
252252
void redrawTagGroups();
253253
void adjustModuleWidth(int delta);
254254
void adjustModuleHeight(int delta);
255+
void saveTagGroupRectInFile();
255256

256257
Q_SIGNALS:
257258
void addConnection(const SCIRun::Dataflow::Networks::ConnectionDescription&);

0 commit comments

Comments
 (0)