DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbse::SchemaGraphicsScene Class Reference

#include <SchemaGraphicsScene.hpp>

Inheritance diagram for dbse::SchemaGraphicsScene:
[legend]
Collaboration diagram for dbse::SchemaGraphicsScene:
[legend]

Signals

void sceneModified (bool)
void saveRequested ()

Public Member Functions

 SchemaGraphicsScene (QObject *parent=nullptr)
 ~SchemaGraphicsScene ()
void CreateActions ()
void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 Drag & Drop.
void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
void dropEvent (QGraphicsSceneDragDropEvent *event)
void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
QStringList AddItemsToScene (QStringList SchemaClasses, QList< QPointF > Positions)
void CleanItemMap ()
void RemoveClassObject (SchemaGraphicObject *Object)
void add_notes (QStringList notes, QList< QPointF > positions)
void remove_note_object (SchemaGraphicNote *obj)
bool highlight_abstract () const
bool highlight_active () const
bool inherited_properties_visible () const
bool show_defaults () const
bool IsModified () const
void ClearModified ()

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent)
void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent)
void RemoveItemFromScene (QGraphicsItem *item)
void modified (bool state)

Private Slots

void new_class_slot ()
void add_class_slot (QString)
void new_note_slot ()
void add_note_slot (SchemaGraphicNote *)
void cancel_note_slot (SchemaGraphicNote *)
void edit_note_slot ()
void remove_note_slot ()
void modified_slot ()
void EditClassSlot ()
void ToggleIndirectInfos ()
void ToggleHighlightAbstract ()
void ToggleHighlightActive ()
void ToggleHighlightClass ()
void ToggleDefault ()
void AddDirectSuperClassesSlot ()
void AddAllSuperClassesSlot ()
void AddAllSubClassesSlot ()
void AddDirectRelationshipClassesSlot ()
void AddAllRelationshipClassesSlot ()
void RemoveClassSlot ()
void RemoveArrowSlot ()
void DrawArrow (QString ClassName, QString RelationshipType, QString RelationshipName)
void requestSave ()
void moveScene ()

Private Attributes

QMap< QString, SchemaGraphicObject * > ItemMap
std::set< SchemaGraphicNote * > m_notes
QGraphicsLineItem * m_line
QMenu * m_context_menu
int m_seperator_pos
int m_class_pos
int m_arrow_pos
int m_note_pos
int m_save_pos
QAction * m_add_class
QAction * m_edit_class
QAction * m_toggle_indirect_infos
QAction * m_toggle_highlight_abstract
QAction * m_toggle_highlight_active
QAction * m_toggle_highlight_class
QAction * m_toggle_default
QAction * m_add_direct_super_classes
QAction * m_add_direct_relationship_classes
QAction * m_add_all_super_classes
QAction * m_add_all_sub_classes
QAction * m_add_all_relationship_classes
QAction * m_add_note
QAction * m_edit_note
QAction * m_remove_note
QAction * m_remove_class
QAction * m_remove_arrow
QAction * m_save
QAction * m_move
QMetaObject::Connection m_addclass_connection
SchemaGraphicObject * CurrentObject
SchemaGraphicSegmentedArrow * m_current_arrow
SchemaGraphicNote * m_current_note
QPointF m_current_pos
QPointF m_mouse_item_pos
int m_next_note { 0 }
bool m_inherited_properties_visible
bool m_highlight_abstract
bool m_highlight_active
bool m_show_defaults
bool m_modified

Detailed Description

Definition at line 14 of file SchemaGraphicsScene.hpp.

Constructor & Destructor Documentation

◆ SchemaGraphicsScene()

dbse::SchemaGraphicsScene::SchemaGraphicsScene ( QObject * parent = nullptr)
explicit

Definition at line 23 of file SchemaGraphicsScene.cpp.

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}
SchemaGraphicSegmentedArrow * m_current_arrow
SchemaGraphicObject * CurrentObject

◆ ~SchemaGraphicsScene()

dbse::SchemaGraphicsScene::~SchemaGraphicsScene ( )

Definition at line 44 of file SchemaGraphicsScene.cpp.

44{}

Member Function Documentation

◆ add_class_slot

void dbse::SchemaGraphicsScene::add_class_slot ( QString class_name)
privateslot

Updating item list

Definition at line 580 of file SchemaGraphicsScene.cpp.

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}
SchemaGraphicObject(QString &ClassName, SchemaGraphicsScene *scene, QGraphicsObject *parent=nullptr)
QMap< QString, SchemaGraphicObject * > ItemMap
QMetaObject::Connection m_addclass_connection

◆ add_note_slot

void dbse::SchemaGraphicsScene::add_note_slot ( SchemaGraphicNote * note)
privateslot

Definition at line 555 of file SchemaGraphicsScene.cpp.

556{
557 m_notes.insert(note);
558 addItem(note);
559 modified(true);
560}
std::set< SchemaGraphicNote * > m_notes

◆ add_notes()

void dbse::SchemaGraphicsScene::add_notes ( QStringList notes,
QList< QPointF > positions )

Definition at line 360 of file SchemaGraphicsScene.cpp.

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}
SchemaGraphicNote(const QString &name, const QString &text, QGraphicsObject *parent=nullptr)

◆ AddAllRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddAllRelationshipClassesSlot ( )
privateslot

Definition at line 732 of file SchemaGraphicsScene.cpp.

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}
static KernelWrapper & GetInstance()
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
dunedaq::oks::OksClass * GetClass() const
QStringList AddItemsToScene(QStringList SchemaClasses, QList< QPointF > Positions)
const std::string & get_name() const noexcept
Definition class.hpp:374
const std::list< OksRelationship * > * all_relationships() const noexcept
Definition class.hpp:568

◆ AddAllSubClassesSlot

void dbse::SchemaGraphicsScene::AddAllSubClassesSlot ( )
privateslot

Definition at line 690 of file SchemaGraphicsScene.cpp.

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}
const FList * all_sub_classes() const noexcept
Definition class.hpp:463
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:254

◆ AddAllSuperClassesSlot

void dbse::SchemaGraphicsScene::AddAllSuperClassesSlot ( )
privateslot

Definition at line 669 of file SchemaGraphicsScene.cpp.

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}
const FList * all_super_classes() const noexcept
Definition class.hpp:413

◆ AddDirectRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddDirectRelationshipClassesSlot ( )
privateslot

Definition at line 711 of file SchemaGraphicsScene.cpp.

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}
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:572

◆ AddDirectSuperClassesSlot

void dbse::SchemaGraphicsScene::AddDirectSuperClassesSlot ( )
privateslot

Definition at line 648 of file SchemaGraphicsScene.cpp.

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}
const std::list< std::string * > * direct_super_classes() const noexcept
Definition class.hpp:417

◆ AddItemsToScene()

QStringList dbse::SchemaGraphicsScene::AddItemsToScene ( QStringList SchemaClasses,
QList< QPointF > Positions )

Updating item list

Plotting the superclasses

Definition at line 268 of file SchemaGraphicsScene.cpp.

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 =
308 SchemaGraphicSegmentedArrow* NewArrow =
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 {
335 SchemaGraphicSegmentedArrow* NewArrow = new SchemaGraphicSegmentedArrow(
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}
QString GetCardinalityStringRelationship(dunedaq::oks::OksRelationship *SchemaRelationship) const
SchemaGraphicSegmentedArrow(SchemaGraphicObject *StartItem, SchemaGraphicObject *EndItem, int connection_count, bool IsInheritance, bool IsComposite, QString ArrowName, QString ArrowCardinality, QGraphicsItem *parent=nullptr)

◆ cancel_note_slot

void dbse::SchemaGraphicsScene::cancel_note_slot ( SchemaGraphicNote * note)
privateslot

Definition at line 562 of file SchemaGraphicsScene.cpp.

563{
564 m_notes.erase(note);
565 delete note;
566}

◆ CleanItemMap()

void dbse::SchemaGraphicsScene::CleanItemMap ( )

Definition at line 391 of file SchemaGraphicsScene.cpp.

392{
393 ItemMap.clear();
394}

◆ ClearModified()

void dbse::SchemaGraphicsScene::ClearModified ( )

Definition at line 431 of file SchemaGraphicsScene.cpp.

432{
433 modified(false);
434}

◆ contextMenuEvent()

void dbse::SchemaGraphicsScene::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event)

Definition at line 172 of file SchemaGraphicsScene.cpp.

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) {
245
247 bool writable = KernelWrapper::GetInstance().IsFileWritable(filename);
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}
bool IsFileWritable(const std::string &FileName) const
OksFile * get_file() const noexcept
Definition class.hpp:352
const std::string & get_full_file_name() const
Definition file.hpp:528
Changes could not be no object was Database change was not no object was not An invalid qmodel index has been Config layer returned null reference for object

◆ CreateActions()

void dbse::SchemaGraphicsScene::CreateActions ( )

Definition at line 47 of file SchemaGraphicsScene.cpp.

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}

◆ dragEnterEvent()

void dbse::SchemaGraphicsScene::dragEnterEvent ( QGraphicsSceneDragDropEvent * event)

Drag & Drop.

Definition at line 131 of file SchemaGraphicsScene.cpp.

132{
133 if (event->mimeData()->hasFormat("application/vnd.text.list")) {
134 event->accept();
135 }
136}

◆ dragMoveEvent()

void dbse::SchemaGraphicsScene::dragMoveEvent ( QGraphicsSceneDragDropEvent * event)

Definition at line 139 of file SchemaGraphicsScene.cpp.

140{
141 if (event->mimeData()->hasFormat("application/vnd.text.list")) {
142 event->accept();
143 }
144}

◆ DrawArrow

void dbse::SchemaGraphicsScene::DrawArrow ( QString ClassName,
QString RelationshipType,
QString RelationshipName )
privateslot

Definition at line 774 of file SchemaGraphicsScene.cpp.

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);
788 SchemaGraphicSegmentedArrow* newArrow =
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}
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1130
bool get_is_composite() const noexcept
const std::string & get_name() const noexcept

◆ dropEvent()

void dbse::SchemaGraphicsScene::dropEvent ( QGraphicsSceneDragDropEvent * event)

Definition at line 147 of file SchemaGraphicsScene.cpp.

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}

◆ edit_note_slot

void dbse::SchemaGraphicsScene::edit_note_slot ( )
privateslot

Definition at line 543 of file SchemaGraphicsScene.cpp.

◆ EditClassSlot

void dbse::SchemaGraphicsScene::EditClassSlot ( )
privateslot

Definition at line 599 of file SchemaGraphicsScene.cpp.

600{
601 QString class_name = QString::fromStdString(CurrentObject->GetClass()->get_name());
602 SchemaClassEditor::launch(class_name);
603}
static void launch(QString class_name)

◆ highlight_abstract()

bool dbse::SchemaGraphicsScene::highlight_abstract ( ) const
inlinenodiscard

Definition at line 33 of file SchemaGraphicsScene.hpp.

33{ return m_highlight_abstract; }

◆ highlight_active()

bool dbse::SchemaGraphicsScene::highlight_active ( ) const
inlinenodiscard

Definition at line 34 of file SchemaGraphicsScene.hpp.

34{ return m_highlight_active; }

◆ inherited_properties_visible()

bool dbse::SchemaGraphicsScene::inherited_properties_visible ( ) const
inlinenodiscard

Definition at line 35 of file SchemaGraphicsScene.hpp.

◆ IsModified()

bool dbse::SchemaGraphicsScene::IsModified ( ) const
inlinenodiscard

Definition at line 38 of file SchemaGraphicsScene.hpp.

38{ return m_modified; };

◆ modified()

void dbse::SchemaGraphicsScene::modified ( bool state)
protected

Definition at line 437 of file SchemaGraphicsScene.cpp.

438{
439 m_modified = state;
440 emit sceneModified(state);
441}

◆ modified_slot

void dbse::SchemaGraphicsScene::modified_slot ( )
privateslot

Definition at line 478 of file SchemaGraphicsScene.cpp.

479{
480 modified(true);
481}

◆ mouseMoveEvent()

void dbse::SchemaGraphicsScene::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent)
protected

Definition at line 420 of file SchemaGraphicsScene.cpp.

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}

◆ mousePressEvent()

void dbse::SchemaGraphicsScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent)
protected

Definition at line 397 of file SchemaGraphicsScene.cpp.

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}

◆ mouseReleaseEvent()

void dbse::SchemaGraphicsScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent)
protected

Create arrow

Definition at line 483 of file SchemaGraphicsScene.cpp.

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());
519 SchemaGraphicSegmentedArrow* newArrow =
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}
void DrawArrow(QString ClassName, QString RelationshipType, QString RelationshipName)
void RemoveItemFromScene(QGraphicsItem *item)
SchemaRelationshipEditor(dunedaq::oks::OksClass *Class, dunedaq::oks::OksRelationship *Relationship, QWidget *parent=nullptr)

◆ moveScene

void dbse::SchemaGraphicsScene::moveScene ( )
privateslot

Definition at line 444 of file SchemaGraphicsScene.cpp.

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}

◆ new_class_slot

void dbse::SchemaGraphicsScene::new_class_slot ( )
privateslot

Definition at line 591 of file SchemaGraphicsScene.cpp.

592{
594 connect(&KernelWrapper::GetInstance(), SIGNAL(ClassCreated(QString)), this, SLOT(add_class_slot(QString)));
596}

◆ new_note_slot

void dbse::SchemaGraphicsScene::new_note_slot ( )
privateslot

Definition at line 569 of file SchemaGraphicsScene.cpp.

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}
void add_note_slot(SchemaGraphicNote *)
void cancel_note_slot(SchemaGraphicNote *)
SchemaNoteEditor(SchemaGraphicNote *note, QWidget *parent=0)

◆ remove_note_object()

void dbse::SchemaGraphicsScene::remove_note_object ( SchemaGraphicNote * obj)

Definition at line 370 of file SchemaGraphicsScene.cpp.

371{
372 if (note == nullptr) {
373 return;
374 }
376}

◆ remove_note_slot

void dbse::SchemaGraphicsScene::remove_note_slot ( )
privateslot

Definition at line 549 of file SchemaGraphicsScene.cpp.

550{
552}
void remove_note_object(SchemaGraphicNote *obj)

◆ RemoveArrowSlot

void dbse::SchemaGraphicsScene::RemoveArrowSlot ( )
privateslot

◆ RemoveClassObject()

void dbse::SchemaGraphicsScene::RemoveClassObject ( SchemaGraphicObject * Object)

Definition at line 379 of file SchemaGraphicsScene.cpp.

380{
381 if (Object == nullptr) {
382 return;
383 }
384
385 Object->RemoveArrows();
386 RemoveItemFromScene(Object);
387 ItemMap.remove(Object->GetClassName());
388}

◆ RemoveClassSlot

void dbse::SchemaGraphicsScene::RemoveClassSlot ( )
privateslot

Definition at line 753 of file SchemaGraphicsScene.cpp.

754{
755 if (CurrentObject == nullptr) {
756 return;
757 }
758
762}

◆ RemoveItemFromScene()

void dbse::SchemaGraphicsScene::RemoveItemFromScene ( QGraphicsItem * item)
protected

Definition at line 353 of file SchemaGraphicsScene.cpp.

354{
355 removeItem(item);
356 modified(true);
357}

◆ requestSave

void dbse::SchemaGraphicsScene::requestSave ( )
privateslot

Definition at line 473 of file SchemaGraphicsScene.cpp.

474{
475 emit saveRequested();
476}

◆ saveRequested

void dbse::SchemaGraphicsScene::saveRequested ( )
signal

◆ sceneModified

void dbse::SchemaGraphicsScene::sceneModified ( bool )
signal

◆ show_defaults()

bool dbse::SchemaGraphicsScene::show_defaults ( ) const
inlinenodiscard

Definition at line 37 of file SchemaGraphicsScene.hpp.

37{ return m_show_defaults; };

◆ ToggleDefault

void dbse::SchemaGraphicsScene::ToggleDefault ( )
privateslot

Definition at line 627 of file SchemaGraphicsScene.cpp.

628{
630 for (SchemaGraphicObject* item : ItemMap.values()) {
631 item->update_arrows();
632 }
633 this->update();
634}

◆ ToggleHighlightAbstract

void dbse::SchemaGraphicsScene::ToggleHighlightAbstract ( )
privateslot

Definition at line 620 of file SchemaGraphicsScene.cpp.

621{
623 this->update();
624}

◆ ToggleHighlightActive

void dbse::SchemaGraphicsScene::ToggleHighlightActive ( )
privateslot

Definition at line 613 of file SchemaGraphicsScene.cpp.

614{
616 this->update();
617}

◆ ToggleHighlightClass

void dbse::SchemaGraphicsScene::ToggleHighlightClass ( )
privateslot

Definition at line 606 of file SchemaGraphicsScene.cpp.

607{
609 this->update();
610}
void toggle_highlight_class()
Graphic API.

◆ ToggleIndirectInfos

void dbse::SchemaGraphicsScene::ToggleIndirectInfos ( )
privateslot

Definition at line 637 of file SchemaGraphicsScene.cpp.

638{
640
641 for (SchemaGraphicObject* item : ItemMap.values()) {
642 item->update_arrows();
643 }
644 this->update();
645}

Member Data Documentation

◆ CurrentObject

SchemaGraphicObject* dbse::SchemaGraphicsScene::CurrentObject
private

Definition at line 107 of file SchemaGraphicsScene.hpp.

◆ ItemMap

QMap<QString, SchemaGraphicObject*> dbse::SchemaGraphicsScene::ItemMap
private

Definition at line 78 of file SchemaGraphicsScene.hpp.

◆ m_add_all_relationship_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_relationship_classes
private

Definition at line 98 of file SchemaGraphicsScene.hpp.

◆ m_add_all_sub_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_sub_classes
private

Definition at line 97 of file SchemaGraphicsScene.hpp.

◆ m_add_all_super_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_super_classes
private

Definition at line 96 of file SchemaGraphicsScene.hpp.

◆ m_add_class

QAction* dbse::SchemaGraphicsScene::m_add_class
private

Definition at line 87 of file SchemaGraphicsScene.hpp.

◆ m_add_direct_relationship_classes

QAction* dbse::SchemaGraphicsScene::m_add_direct_relationship_classes
private

Definition at line 95 of file SchemaGraphicsScene.hpp.

◆ m_add_direct_super_classes

QAction* dbse::SchemaGraphicsScene::m_add_direct_super_classes
private

Definition at line 94 of file SchemaGraphicsScene.hpp.

◆ m_add_note

QAction* dbse::SchemaGraphicsScene::m_add_note
private

Definition at line 99 of file SchemaGraphicsScene.hpp.

◆ m_addclass_connection

QMetaObject::Connection dbse::SchemaGraphicsScene::m_addclass_connection
private

Definition at line 106 of file SchemaGraphicsScene.hpp.

◆ m_arrow_pos

int dbse::SchemaGraphicsScene::m_arrow_pos
private

Definition at line 84 of file SchemaGraphicsScene.hpp.

◆ m_class_pos

int dbse::SchemaGraphicsScene::m_class_pos
private

Definition at line 83 of file SchemaGraphicsScene.hpp.

◆ m_context_menu

QMenu* dbse::SchemaGraphicsScene::m_context_menu
private

Definition at line 81 of file SchemaGraphicsScene.hpp.

◆ m_current_arrow

SchemaGraphicSegmentedArrow* dbse::SchemaGraphicsScene::m_current_arrow
private

Definition at line 108 of file SchemaGraphicsScene.hpp.

◆ m_current_note

SchemaGraphicNote* dbse::SchemaGraphicsScene::m_current_note
private

Definition at line 109 of file SchemaGraphicsScene.hpp.

◆ m_current_pos

QPointF dbse::SchemaGraphicsScene::m_current_pos
private

Definition at line 110 of file SchemaGraphicsScene.hpp.

◆ m_edit_class

QAction* dbse::SchemaGraphicsScene::m_edit_class
private

Definition at line 88 of file SchemaGraphicsScene.hpp.

◆ m_edit_note

QAction* dbse::SchemaGraphicsScene::m_edit_note
private

Definition at line 100 of file SchemaGraphicsScene.hpp.

◆ m_highlight_abstract

bool dbse::SchemaGraphicsScene::m_highlight_abstract
private

Definition at line 114 of file SchemaGraphicsScene.hpp.

◆ m_highlight_active

bool dbse::SchemaGraphicsScene::m_highlight_active
private

Definition at line 115 of file SchemaGraphicsScene.hpp.

◆ m_inherited_properties_visible

bool dbse::SchemaGraphicsScene::m_inherited_properties_visible
private

Definition at line 113 of file SchemaGraphicsScene.hpp.

◆ m_line

QGraphicsLineItem* dbse::SchemaGraphicsScene::m_line
private

Definition at line 80 of file SchemaGraphicsScene.hpp.

◆ m_modified

bool dbse::SchemaGraphicsScene::m_modified
private

Definition at line 117 of file SchemaGraphicsScene.hpp.

◆ m_mouse_item_pos

QPointF dbse::SchemaGraphicsScene::m_mouse_item_pos
private

Definition at line 111 of file SchemaGraphicsScene.hpp.

◆ m_move

QAction* dbse::SchemaGraphicsScene::m_move
private

Definition at line 105 of file SchemaGraphicsScene.hpp.

◆ m_next_note

int dbse::SchemaGraphicsScene::m_next_note { 0 }
private

Definition at line 112 of file SchemaGraphicsScene.hpp.

◆ m_note_pos

int dbse::SchemaGraphicsScene::m_note_pos
private

Definition at line 85 of file SchemaGraphicsScene.hpp.

◆ m_notes

std::set<SchemaGraphicNote*> dbse::SchemaGraphicsScene::m_notes
private

Definition at line 79 of file SchemaGraphicsScene.hpp.

◆ m_remove_arrow

QAction* dbse::SchemaGraphicsScene::m_remove_arrow
private

Definition at line 103 of file SchemaGraphicsScene.hpp.

◆ m_remove_class

QAction* dbse::SchemaGraphicsScene::m_remove_class
private

Definition at line 102 of file SchemaGraphicsScene.hpp.

◆ m_remove_note

QAction* dbse::SchemaGraphicsScene::m_remove_note
private

Definition at line 101 of file SchemaGraphicsScene.hpp.

◆ m_save

QAction* dbse::SchemaGraphicsScene::m_save
private

Definition at line 104 of file SchemaGraphicsScene.hpp.

◆ m_save_pos

int dbse::SchemaGraphicsScene::m_save_pos
private

Definition at line 86 of file SchemaGraphicsScene.hpp.

◆ m_seperator_pos

int dbse::SchemaGraphicsScene::m_seperator_pos
private

Definition at line 82 of file SchemaGraphicsScene.hpp.

◆ m_show_defaults

bool dbse::SchemaGraphicsScene::m_show_defaults
private

Definition at line 116 of file SchemaGraphicsScene.hpp.

◆ m_toggle_default

QAction* dbse::SchemaGraphicsScene::m_toggle_default
private

Definition at line 93 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_abstract

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_abstract
private

Definition at line 90 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_active

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_active
private

Definition at line 91 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_class

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_class
private

Definition at line 92 of file SchemaGraphicsScene.hpp.

◆ m_toggle_indirect_infos

QAction* dbse::SchemaGraphicsScene::m_toggle_indirect_infos
private

Definition at line 89 of file SchemaGraphicsScene.hpp.


The documentation for this class was generated from the following files: