DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SchemaGraphicsScene.cpp
Go to the documentation of this file.
1
2#include <QEvent>
3#include <QGraphicsSceneDragDropEvent>
4#include <QMimeData>
5#include <QSettings>
6
7#include <QWidget>
8
9#include <QApplication>
10#include <QMenu>
20
21using namespace dunedaq::oks;
22
24 : QGraphicsScene(parent)
25 , m_line(nullptr)
26 , m_context_menu(nullptr)
27 , CurrentObject(nullptr)
28 , m_current_arrow(nullptr)
29 , m_modified(false)
30{
31 setSceneRect(QRectF(0, 0, 10000, 10000));
32
33 QSettings settings;
34 settings.beginGroup("view defaults");
35
36 m_inherited_properties_visible = settings.value("show_inherited", false).toBool();
37 m_highlight_abstract = settings.value("highlight_abstract", false).toBool();
38 m_highlight_active = settings.value("highlight_active", false).toBool();
39 m_show_defaults = settings.value("show_default", false).toBool();
40
42}
43
45
46void
48{
49 // Add new class
50 m_add_class = new QAction("&Add new class", this);
51 connect(m_add_class, SIGNAL(triggered()), this, SLOT(new_class_slot()));
52
53 // Edit current class
54 m_edit_class = new QAction("&Edit class", this);
55 connect(m_edit_class, SIGNAL(triggered()), this, SLOT(EditClassSlot()));
56
57 // Toggle inherited properties of all classes in view
58 m_toggle_indirect_infos = new QAction("Show &inherited properties", this);
59 m_toggle_indirect_infos->setCheckable(true);
61 connect(m_toggle_indirect_infos, SIGNAL(triggered()), this, SLOT(ToggleIndirectInfos()));
62
63 // Toggle highlighting of all classes in active schema
64 m_toggle_highlight_active = new QAction("&Highlight classes in active schema", this);
65 m_toggle_highlight_active->setCheckable(true);
67 connect(m_toggle_highlight_active, SIGNAL(triggered()), this, SLOT(ToggleHighlightActive()));
68
69 // Toggle highlighting of all abstract classes in view
70 m_toggle_highlight_abstract = new QAction("&Highlight abstract classes in view", this);
71 m_toggle_highlight_abstract->setCheckable(true);
73 connect(m_toggle_highlight_abstract, SIGNAL(triggered()), this, SLOT(ToggleHighlightAbstract()));
74
75 // Toggle displaying default values of attributes
76 m_toggle_default = new QAction("Show &default values of attributes", this);
77 m_toggle_default->setCheckable(true);
79 connect(m_toggle_default, SIGNAL(triggered()), this, SLOT(ToggleDefault()));
80
81 // Toggle highlighting of current class
82 m_toggle_highlight_class = new QAction("&Highlight this class", this);
83 m_toggle_highlight_class->setCheckable(true);
84 connect(m_toggle_highlight_class, SIGNAL(triggered()), this, SLOT(ToggleHighlightClass()));
85
86 m_add_note = new QAction("&Add note to view", this);
87 connect(m_add_note, SIGNAL(triggered()), this, SLOT(new_note_slot()));
88
89 m_edit_note = new QAction("&Edit note", this);
90 connect(m_edit_note, SIGNAL(triggered()), this, SLOT(edit_note_slot()));
91
92 m_remove_note = new QAction("&Remove note", this);
93 connect(m_remove_note, SIGNAL(triggered()), this, SLOT(remove_note_slot()));
94
95 // Show superclasses of the current class
96 m_add_direct_super_classes = new QAction("Add direct &superclasses to view", this);
97 connect(m_add_direct_super_classes, SIGNAL(triggered()), this, SLOT(AddDirectSuperClassesSlot()));
98
99 // Show relationship classes of the current clas
100 m_add_direct_relationship_classes = new QAction("Add direct &relationship classes to view", this);
101 connect(m_add_direct_relationship_classes, SIGNAL(triggered()), this, SLOT(AddDirectRelationshipClassesSlot()));
102
103 // Show superclasses of the current class
104 m_add_all_super_classes = new QAction("Add all &superclasses to view", this);
105 connect(m_add_all_super_classes, SIGNAL(triggered()), this, SLOT(AddAllSuperClassesSlot()));
106
107 // Show subclasses of the current clas
108 m_add_all_sub_classes = new QAction("Add all s&ubclasses to view", this);
109 connect(m_add_all_sub_classes, SIGNAL(triggered()), this, SLOT(AddAllSubClassesSlot()));
110
111 // Show indirect relationship classes of the current class
112 m_add_all_relationship_classes = new QAction("Add all &relationship classes to view", this);
113 connect(m_add_all_relationship_classes, SIGNAL(triggered()), this, SLOT(AddAllRelationshipClassesSlot()));
114
115 // Remove class
116 m_remove_class = new QAction("&Remove Class from view", this);
117 connect(m_remove_class, SIGNAL(triggered()), this, SLOT(RemoveClassSlot()));
118
119 // Remove arrow
120 m_remove_arrow = new QAction("&Remove Arrow", this);
121 connect(m_remove_arrow, SIGNAL(triggered()), this, SLOT(RemoveArrowSlot()));
122
123 m_save = new QAction("&Save view", this);
124 connect(m_save, SIGNAL(triggered()), this, SLOT(requestSave()));
125
126 m_move = new QAction("&Move scene", this);
127 connect(m_move, SIGNAL(triggered()), this, SLOT(moveScene()));
128}
129
130void
131dbse::SchemaGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent* event)
132{
133 if (event->mimeData()->hasFormat("application/vnd.text.list")) {
134 event->accept();
135 }
136}
137
138void
139dbse::SchemaGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent* event)
140{
141 if (event->mimeData()->hasFormat("application/vnd.text.list")) {
142 event->accept();
143 }
144}
145
146void
147dbse::SchemaGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent* event)
148{
149 QByteArray encodedData = event->mimeData()->data("application/vnd.text.list");
150 QDataStream stream(&encodedData, QIODevice::ReadOnly);
151
152 if (stream.atEnd()) {
153 return;
154 }
155
156 QStringList schema_classes;
157 while (!stream.atEnd()) {
158 QString class_name;
159 stream >> class_name;
160 schema_classes.append(class_name);
161 }
162
163 QList<QPointF> positions;
164 for (int i = 0; i < schema_classes.size(); ++i) {
165 positions.push_back(event->scenePos());
166 }
167
168 AddItemsToScene(schema_classes, positions);
169}
170
171void
172dbse::SchemaGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
173{
174 if (m_context_menu == nullptr) {
175 m_context_menu = new QMenu();
176 m_context_menu->addAction(m_add_class);
177 m_context_menu->addAction(m_add_note);
182
183 m_seperator_pos = m_context_menu->actions().size();
184 m_context_menu->addSeparator();
185
186 m_class_pos = m_context_menu->actions().size();
187 m_context_menu->addAction(m_edit_class);
188 m_context_menu->addAction(m_remove_class);
190 m_context_menu->addSeparator();
191
198
199 m_arrow_pos = m_context_menu->actions().size();
200 m_context_menu->addAction(m_remove_arrow);
201
202 m_note_pos = m_context_menu->actions().size();
203 m_context_menu->addAction(m_edit_note);
204 m_context_menu->addAction(m_remove_note);
205
206 m_context_menu->addSeparator();
207 m_save_pos = m_context_menu->actions().size();
208 m_context_menu->addAction(m_save);
209 m_context_menu->addAction(m_move);
210 }
211
212 bool active = KernelWrapper::GetInstance().IsActive();
213 m_context_menu->actions().at(0)->setVisible(active);
214
215 for (int item = 1; item < m_seperator_pos; item++) {
216 m_context_menu->actions().at(item)->setVisible(true);
217 }
218
219 // Set all other items invisible
220 const auto nitems = m_context_menu->actions().size();
221 for (int item = m_seperator_pos; item < nitems; item++) {
222 m_context_menu->actions().at(item)->setVisible(false);
223 }
224
225 if (ItemMap.size() > 0) {
226 m_context_menu->actions().at(m_save_pos - 1)->setVisible(true);
227 m_context_menu->actions().at(m_save_pos + 1)->setVisible(true);
228 }
229 if (m_modified && ItemMap.size() > 0) {
230 m_context_menu->actions().at(m_save_pos)->setVisible(true);
231 }
232
233 if (itemAt(event->scenePos(), QTransform())) {
234 // Something under mouse pointer, set additional items visible
235 // depending on what it is
236 m_context_menu->actions().at(m_seperator_pos)->setVisible(true);
237
238 auto object = dynamic_cast<SchemaGraphicObject*>(itemAt(event->scenePos(), QTransform()));
239 auto arrow = dynamic_cast<SchemaGraphicSegmentedArrow*>(itemAt(event->scenePos(), QTransform()));
240 auto note = dynamic_cast<SchemaGraphicNote*>(itemAt(event->scenePos(), QTransform()));
241
242 if (object != nullptr) {
243 CurrentObject = object;
244 m_toggle_highlight_class->setChecked(CurrentObject->highlighted());
245
246 auto filename = CurrentObject->GetClass()->get_file()->get_full_file_name();
248 m_context_menu->actions().at(m_class_pos)->setVisible(writable);
249
250 for (int item = m_class_pos + 1; item < m_arrow_pos; item++) {
251 m_context_menu->actions().at(item)->setVisible(true);
252 }
253 } else if (arrow != nullptr) {
254 m_context_menu->actions().at(m_arrow_pos)->setVisible(true);
255 m_current_arrow = arrow;
256 } else if (note != nullptr) {
257 for (int item = m_note_pos; item < nitems; item++) {
258 m_context_menu->actions().at(item)->setVisible(true);
259 }
260 m_current_note = note;
261 }
262 }
263 m_current_pos = event->scenePos();
264 m_context_menu->exec(event->screenPos());
265}
266
267QStringList
268dbse::SchemaGraphicsScene::AddItemsToScene(QStringList SchemaClasses, QList<QPointF> Positions)
269{
270 QStringList missingItems{};
271
272 for (QString& ClassName : SchemaClasses) {
273 if (!ItemMap.contains(ClassName)) {
274
275 if (!KernelWrapper::GetInstance().FindClass(ClassName.toStdString())) {
276 std::cout << "ERROR: class " << ClassName.toStdString() << " not found" << std::endl;
277 missingItems.append(ClassName);
278 continue;
279 }
280
281 SchemaGraphicObject* Object = new SchemaGraphicObject(ClassName, this);
282 Object->setPos(Positions.at(SchemaClasses.indexOf(ClassName)));
283 addItem(Object);
285 ItemMap.insert(ClassName, Object);
286 }
287 }
288
289 for (QString& ClassName : ItemMap.keys()) {
290 OksClass* ClassInfo = KernelWrapper::GetInstance().FindClass(ClassName.toStdString());
291
292 const std::list<OksRelationship*>* DirectRelationshipList = ClassInfo->direct_relationships();
293 const std::list<std::string*>* DirectSuperClassesList = ClassInfo->direct_super_classes();
294
295 std::map<std::string, unsigned int> arrow_count;
296
298 if (DirectRelationshipList != nullptr) {
299 for (OksRelationship* ClassRelationship : *(DirectRelationshipList)) {
300 auto rct = ClassRelationship->get_class_type()->get_name();
301 QString RelationshipClassType = QString::fromStdString(rct);
302
303 if (ItemMap.contains(RelationshipClassType)) //&& !ItemMap[ClassName]->HasArrow (
304 // ItemMap[RelationshipClassType] ) )
305 {
306 QString SchemaCardinality =
310 ItemMap[RelationshipClassType],
311 arrow_count[rct],
312 false,
313 ClassRelationship->get_is_composite(),
314 QString::fromStdString(ClassRelationship->get_name()),
315 SchemaCardinality);
316 ItemMap[ClassName]->AddArrow(NewArrow);
317 ItemMap[RelationshipClassType]->AddArrow(NewArrow);
318 addItem(NewArrow);
319 // NewArrow->SetLabelScene(this);
320 NewArrow->setZValue(-1000.0);
321 NewArrow->UpdatePosition();
322 arrow_count[rct]++;
323 }
324 }
325 }
326
328 if (DirectSuperClassesList != nullptr) {
329 for (std::string* SuperClassNameStd : *(DirectSuperClassesList)) {
330 QString SuperClassName = QString::fromStdString(*SuperClassNameStd);
331
332 if (ItemMap.contains(SuperClassName)) // && !ItemMap[ClassName]->HasArrow (
333 // ItemMap[SuperClassName] ) )
334 {
336 ItemMap[ClassName], ItemMap[SuperClassName], arrow_count[*SuperClassNameStd], true, false, "", "");
337 ItemMap[ClassName]->AddArrow(NewArrow);
338 ItemMap[SuperClassName]->AddArrow(NewArrow);
339 addItem(NewArrow);
340 // NewArrow->SetLabelScene(this);
341 NewArrow->setZValue(-1000.0);
342 NewArrow->UpdatePosition();
343 arrow_count[*SuperClassNameStd]++;
344 }
345 }
346 }
347 }
348 modified(true);
349 return missingItems;
350}
351
352void
354{
355 removeItem(item);
356 modified(true);
357}
358
359void
360dbse::SchemaGraphicsScene::add_notes(QStringList notes, QList<QPointF> positions)
361{
362 for (int index = 0; index < notes.size(); index++) {
363 auto note = new SchemaGraphicNote(QString("#" + QString::number(m_next_note++)), notes.at(index));
364 note->setPos(positions.at(index));
365 m_notes.insert(note);
366 addItem(note);
367 }
368}
369void
371{
372 if (note == nullptr) {
373 return;
374 }
376}
377
378void
380{
381 if (Object == nullptr) {
382 return;
383 }
384
385 Object->RemoveArrows();
386 RemoveItemFromScene(Object);
387 ItemMap.remove(Object->GetClassName());
388}
389
390void
395
396void
397dbse::SchemaGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent)
398{
399 if (itemAt(mouseEvent->scenePos(), QTransform())) {
400 // Save position of item under mouse so we can see if it has been
401 // moved in mouseReleaseEvent
402 m_mouse_item_pos = itemAt(mouseEvent->scenePos(), QTransform())->pos();
403 }
404 if (mouseEvent->button() != Qt::LeftButton) {
405 return;
406 }
407
408 if (mouseEvent->widget()->cursor().shape() == Qt::CrossCursor) {
409 m_line = new QGraphicsLineItem(QLineF(mouseEvent->scenePos(), mouseEvent->scenePos()));
410 m_line->setPen(QPen(Qt::black, 2));
411 addItem(m_line);
412 modified(true);
413 return;
414 }
415
416 QGraphicsScene::mousePressEvent(mouseEvent);
417}
418
419void
420dbse::SchemaGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent)
421{
422 if (m_line != nullptr) {
423 QLineF newLine(m_line->line().p1(), mouseEvent->scenePos());
424 m_line->setLine(newLine);
425 } else {
426 QGraphicsScene::mouseMoveEvent(mouseEvent);
427 }
428}
429
430void
435
436void
438{
439 m_modified = state;
440 emit sceneModified(state);
441}
442
443void
445{
446 qreal minx = 1e6;
447 qreal miny = 1e6;
448 for (auto obj : ItemMap) {
449 auto pos = obj->pos();
450 if (pos.x() < minx) {
451 minx = pos.x();
452 }
453 if (pos.y() < miny) {
454 miny = pos.y();
455 }
456 }
457 qreal xoffset = m_current_pos.x() - minx;
458 qreal yoffset = m_current_pos.y() - miny;
459 for (auto obj : ItemMap) {
460 obj->setX(obj->x() + xoffset);
461 obj->setY(obj->y() + yoffset);
462 obj->update_arrows();
463 }
464 for (auto obj : m_notes) {
465 obj->setX(obj->x() + xoffset);
466 obj->setY(obj->y() + yoffset);
467 }
468 update();
469 modified(true);
470}
471
472void
477void
482void
483dbse::SchemaGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent)
484{
485 if (itemAt(mouseEvent->scenePos(), QTransform())) {
486 auto item = itemAt(mouseEvent->scenePos(), QTransform());
487 if (!m_mouse_item_pos.isNull()) {
488 if (m_mouse_item_pos != item->pos()) {
489 modified(true);
490 }
491 m_mouse_item_pos = QPointF();
492 }
493 }
494 if (m_line != nullptr) {
495 QList<QGraphicsItem*> startItems = items(m_line->line().p1());
496
497 if (startItems.count() && startItems.first() == m_line) {
498 startItems.removeFirst();
499 }
500
501 QList<QGraphicsItem*> endItems = items(m_line->line().p2());
502
503 if (endItems.count() && endItems.first() == m_line) {
504 endItems.removeFirst();
505 }
506
508 delete m_line;
509
510 if (startItems.count() > 0 && endItems.count() > 0 && startItems.first() != endItems.first()) {
511
512 bool Inheritance = KernelWrapper::GetInstance().GetInheritanceMode();
513 SchemaGraphicObject* startItem = qgraphicsitem_cast<SchemaGraphicObject*>(startItems.first());
514 SchemaGraphicObject* endItem = qgraphicsitem_cast<SchemaGraphicObject*>(endItems.first());
515
516 if (Inheritance) {
517 startItem->GetClass()->add_super_class(endItem->GetClassName().toStdString());
520 new SchemaGraphicSegmentedArrow(startItem, endItem, 0, Inheritance, true, "", "");
521 startItem->AddArrow(newArrow);
522 endItem->AddArrow(newArrow);
523 newArrow->setZValue(-1000.0);
524 addItem(newArrow);
525 // newArrow->SetLabelScene(this);
526 newArrow->UpdatePosition();
527 } else {
528 SchemaRelationshipEditor* Editor = new SchemaRelationshipEditor(startItem->GetClass(), endItem->GetClassName());
529 connect(Editor,
530 SIGNAL(MakeGraphConnection(QString, QString, QString)),
531 this,
532 SLOT(DrawArrow(QString, QString, QString)));
533 Editor->show();
534 }
535 }
536 }
537
538 m_line = nullptr;
539 QGraphicsScene::mouseReleaseEvent(mouseEvent);
540}
541
542void
547
548void
553
554void
556{
557 m_notes.insert(note);
558 addItem(note);
559 modified(true);
560}
561void
563{
564 m_notes.erase(note);
565 delete note;
566}
567
568void
570{
571 auto note = new SchemaGraphicNote(QString("#") + QString::number(m_next_note++), QString());
572 note->setPos(m_current_pos);
573 auto editor = new SchemaNoteEditor(note);
574 connect(editor, SIGNAL(note_accepted(SchemaGraphicNote*)), this, SLOT(add_note_slot(SchemaGraphicNote*)));
575 connect(editor, SIGNAL(cancelled(SchemaGraphicNote*)), this, SLOT(cancel_note_slot(SchemaGraphicNote*)));
576 editor->show();
577}
578
579void
581{
582 disconnect(m_addclass_connection);
583
584 auto object = new SchemaGraphicObject(class_name, this);
585 object->setPos(m_current_pos);
586 addItem(object);
588 ItemMap.insert(class_name, object);
589}
590void
592{
594 connect(&KernelWrapper::GetInstance(), SIGNAL(ClassCreated(QString)), this, SLOT(add_class_slot(QString)));
596}
597
598void
600{
601 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
602 SchemaClassEditor::launch(class_name);
603}
604
605void
607{
608 CurrentObject->toggle_highlight_class();
609 this->update();
610}
611
612void
618
619void
625
626void
628{
630 for (SchemaGraphicObject* item : ItemMap.values()) {
631 item->update_arrows();
632 }
633 this->update();
634}
635
636void
638{
640
641 for (SchemaGraphicObject* item : ItemMap.values()) {
642 item->update_arrows();
643 }
644 this->update();
645}
646
647void
649{
650
651 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
652 OksClass* class_info = KernelWrapper::GetInstance().FindClass(class_name.toStdString());
653
654 QStringList super_class_list;
655 QList<QPointF> positions;
656
657 const std::list<std::string*>* direct_classes = class_info->direct_super_classes();
658 if (direct_classes != nullptr) {
659 for (std::string* cl_name : *direct_classes) {
660 super_class_list.push_back(QString::fromStdString(*cl_name));
661 positions.push_back({ 0, 0 });
662 }
663 }
664
665 this->AddItemsToScene(super_class_list, positions);
666}
667
668void
670{
671
672 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
673 OksClass* class_info = KernelWrapper::GetInstance().FindClass(class_name.toStdString());
674
675 QStringList super_class_list;
676 QList<QPointF> positions;
677
678 const OksClass::FList* all_classes = class_info->all_super_classes();
679 if (all_classes != nullptr) {
680 for (const OksClass* cl : *all_classes) {
681 super_class_list.push_back(QString::fromStdString(cl->get_name()));
682 positions.push_back({ 0, 0 });
683 }
684 }
685
686 this->AddItemsToScene(super_class_list, positions);
687}
688
689void
691{
692
693 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
694 OksClass* class_info = KernelWrapper::GetInstance().FindClass(class_name.toStdString());
695
696 QStringList sub_class_list;
697 QList<QPointF> positions;
698
699 const OksClass::FList* all_classes = class_info->all_sub_classes();
700 if (all_classes != nullptr) {
701 for (const OksClass* cl : *all_classes) {
702 sub_class_list.push_back(QString::fromStdString(cl->get_name()));
703 positions.push_back({ 0, 0 });
704 }
705 }
706
707 this->AddItemsToScene(sub_class_list, positions);
708}
709
710void
712{
713
714 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
715 OksClass* class_info = KernelWrapper::GetInstance().FindClass(class_name.toStdString());
716
717 QStringList relationship_classes;
718 QList<QPointF> positions;
719
720 const std::list<OksRelationship*>* direct_relationship_list = class_info->direct_relationships();
721 if (direct_relationship_list != nullptr) {
722 for (const OksRelationship* rl : *direct_relationship_list) {
723 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
724 positions.push_back({ 0, 0 });
725 }
726 }
727
728 this->AddItemsToScene(relationship_classes, positions);
729}
730
731void
733{
734
735 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
736 OksClass* class_info = KernelWrapper::GetInstance().FindClass(class_name.toStdString());
737
738 QStringList relationship_classes;
739 QList<QPointF> positions;
740
741 const std::list<OksRelationship*>* all_relationship_list = class_info->all_relationships();
742 if (all_relationship_list != nullptr) {
743 for (const OksRelationship* rl : *all_relationship_list) {
744 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
745 positions.push_back({ 0, 0 });
746 }
747 }
748
749 this->AddItemsToScene(relationship_classes, positions);
750}
751
752void
754{
755 if (CurrentObject == nullptr) {
756 return;
757 }
758
759 CurrentObject->RemoveArrows();
761 ItemMap.remove(CurrentObject->GetClassName());
762}
763
764void
766{
768 m_current_arrow->GetStartItem()->RemoveArrow(m_current_arrow);
769 m_current_arrow->GetEndItem()->RemoveArrow(m_current_arrow);
770 m_current_arrow->RemoveArrow();
771}
772
773void
774dbse::SchemaGraphicsScene::DrawArrow(QString ClassName, QString RelationshipType, QString RelationshipName)
775{
776 if (!ItemMap.contains(ClassName) || !ItemMap.contains(RelationshipType)) {
777 return;
778 }
779
780 SchemaGraphicObject* startItem = ItemMap[ClassName];
781 SchemaGraphicObject* endItem = ItemMap[RelationshipType];
782
783 OksClass* SchemaClass = KernelWrapper::GetInstance().FindClass(ClassName.toStdString());
784 OksRelationship* SchemaRelationship = SchemaClass->find_direct_relationship(RelationshipName.toStdString());
785
786 if (SchemaRelationship != nullptr) {
787 QString RelationshipCardinality = KernelWrapper::GetInstance().GetCardinalityStringRelationship(SchemaRelationship);
789 new SchemaGraphicSegmentedArrow(startItem,
790 endItem,
791 0,
792 false,
793 SchemaRelationship->get_is_composite(),
794 QString::fromStdString(SchemaRelationship->get_name()),
795 RelationshipCardinality);
796 startItem->AddArrow(newArrow);
797 endItem->AddArrow(newArrow);
798 newArrow->setZValue(-1000.0);
799 addItem(newArrow);
800 // newArrow->SetLabelScene(this);
801 newArrow->UpdatePosition();
802 }
803}
static KernelWrapper & GetInstance()
QString GetCardinalityStringRelationship(dunedaq::oks::OksRelationship *SchemaRelationship) const
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
bool IsFileWritable(const std::string &FileName) const
static void launch(QString class_name)
SchemaGraphicNote(const QString &name, const QString &text, QGraphicsObject *parent=nullptr)
void AddArrow(SchemaGraphicSegmentedArrow *Arrow)
Arrow API.
SchemaGraphicObject(QString &ClassName, SchemaGraphicsScene *scene, QGraphicsObject *parent=nullptr)
dunedaq::oks::OksClass * GetClass() const
SchemaGraphicSegmentedArrow(SchemaGraphicObject *StartItem, SchemaGraphicObject *EndItem, int connection_count, bool IsInheritance, bool IsComposite, QString ArrowName, QString ArrowCardinality, QGraphicsItem *parent=nullptr)
QStringList AddItemsToScene(QStringList SchemaClasses, QList< QPointF > Positions)
SchemaGraphicsScene(QObject *parent=nullptr)
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
Drag & Drop.
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
std::set< SchemaGraphicNote * > m_notes
void add_note_slot(SchemaGraphicNote *)
SchemaGraphicSegmentedArrow * m_current_arrow
void dropEvent(QGraphicsSceneDragDropEvent *event)
void add_notes(QStringList notes, QList< QPointF > positions)
QMap< QString, SchemaGraphicObject * > ItemMap
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
void DrawArrow(QString ClassName, QString RelationshipType, QString RelationshipName)
void remove_note_object(SchemaGraphicNote *obj)
QMetaObject::Connection m_addclass_connection
SchemaGraphicObject * CurrentObject
void RemoveItemFromScene(QGraphicsItem *item)
void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
void RemoveClassObject(SchemaGraphicObject *Object)
void cancel_note_slot(SchemaGraphicNote *)
SchemaNoteEditor(SchemaGraphicNote *note, QWidget *parent=0)
SchemaRelationshipEditor(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, QWidget *parent=nullptr)
The OKS class.
Definition class.hpp:223
const FList * all_sub_classes() const noexcept
Definition class.hpp:463
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1130
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:254
void add_super_class(const std::string &name)
Definition class.cpp:840
const FList * all_super_classes() const noexcept
Definition class.hpp:413
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:572
const std::list< std::string * > * direct_super_classes() const noexcept
Definition class.hpp:417
const std::list< OksRelationship * > * all_relationships() const noexcept
Definition class.hpp:568
bool get_is_composite() const noexcept
const std::string & get_name() const noexcept
msgpack::object obj