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