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)
 

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 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 ToggleHighlightActive ()
 
void AddDirectSuperClassesSlot ()
 
void AddAllSuperClassesSlot ()
 
void AddAllSubClassesSlot ()
 
void AddDirectRelationshipClassesSlot ()
 
void AddAllRelationshipClassesSlot ()
 
void RemoveClassSlot ()
 
void RemoveArrowSlot ()
 
void DrawArrow (QString ClassName, QString RelationshipType, QString RelationshipName)
 

Private Attributes

QMap< QString, SchemaGraphicObject * > ItemMap
 
QGraphicsLineItem * m_line
 
QMenu * m_context_menu
 
int m_seperator_pos
 
int m_class_pos
 
int m_arrow_pos
 
int m_note_pos
 
QAction * m_add_class
 
QAction * m_edit_class
 
QAction * m_toggle_indirect_infos
 
QAction * m_toggle_highlight_active
 
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
 
QMetaObject::Connection m_addclass_connection
 
SchemaGraphicObjectCurrentObject
 
SchemaGraphicSegmentedArrowm_current_arrow
 
SchemaGraphicNotem_current_note
 
QPointF m_current_pos
 
QPointF m_mouse_item_pos
 
int m_next_note {0}
 
bool m_inherited_properties_visible
 
bool m_highlight_active
 
bool m_modified
 

Detailed Description

Definition at line 15 of file SchemaGraphicsScene.hpp.

Constructor & Destructor Documentation

◆ SchemaGraphicsScene()

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

Definition at line 21 of file SchemaGraphicsScene.cpp.

22 : QGraphicsScene ( parent ),
23 m_line ( nullptr ),
24 m_context_menu ( nullptr ),
25 CurrentObject ( nullptr ),
26 m_current_arrow ( nullptr ),
28 m_highlight_active(false),
29 m_modified(false)
30{
32 setSceneRect ( QRectF ( 0, 0, 10000, 10000 ) );
33}
SchemaGraphicSegmentedArrow * m_current_arrow
SchemaGraphicObject * CurrentObject

◆ ~SchemaGraphicsScene()

dbse::SchemaGraphicsScene::~SchemaGraphicsScene ( )

Definition at line 35 of file SchemaGraphicsScene.cpp.

36{
37}

Member Function Documentation

◆ add_class_slot

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

Updating item list

Definition at line 494 of file SchemaGraphicsScene.cpp.

494 {
495 disconnect(m_addclass_connection);
496
497 auto object = new SchemaGraphicObject(class_name);
498 object->setPos(m_current_pos);
499 object->set_inherited_properties_visibility(m_inherited_properties_visible);
500 object->set_highlight_active(m_highlight_active);
501 addItem (object);
503 ItemMap.insert(class_name, object);
504}
QMetaObject::Connection m_addclass_connection
QMap< QString, SchemaGraphicObject * > ItemMap

◆ add_note_slot

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

Definition at line 476 of file SchemaGraphicsScene.cpp.

476 {
477 addItem(note);
478 modified(true);
479}

◆ add_notes()

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

Definition at line 315 of file SchemaGraphicsScene.cpp.

316 {
317 for ( int index = 0; index<notes.size(); index++) {
318 auto note = new SchemaGraphicNote (
319 QString("#" + QString::number(m_next_note++)),
320 notes.at(index) );
321 note->setPos ( positions.at ( index ) );
322 addItem(note);
323 }
324
325}

◆ AddAllRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddAllRelationshipClassesSlot ( )
privateslot

Definition at line 644 of file SchemaGraphicsScene.cpp.

644 {
645
646 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
647 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
648
649 QStringList relationship_classes;
650 QList<QPointF> positions;
651
652 const std::list<OksRelationship *> * all_relationship_list = class_info->all_relationships();
653 if ( all_relationship_list != nullptr ) {
654 for(const OksRelationship* rl : *all_relationship_list) {
655 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
656 positions.push_back({0,0});
657 }
658
659 }
660
661 this->AddItemsToScene ( relationship_classes, positions );
662}
static KernelWrapper & GetInstance()
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
dunedaq::oks::OksClass * GetClass() const
QStringList AddItemsToScene(QStringList SchemaClasses, QList< QPointF > Positions)
The OKS class.
Definition class.hpp:200
const std::string & get_name() const noexcept
Definition class.hpp:363
const std::list< OksRelationship * > * all_relationships() const noexcept
Definition class.hpp:585

◆ AddAllSubClassesSlot

void dbse::SchemaGraphicsScene::AddAllSubClassesSlot ( )
privateslot

Definition at line 603 of file SchemaGraphicsScene.cpp.

603 {
604
605 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
606 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
607
608 QStringList sub_class_list;
609 QList<QPointF> positions;
610
611 const OksClass::FList* all_classes = class_info->all_sub_classes();
612 if(all_classes != nullptr) {
613 for(const OksClass* cl : *all_classes) {
614 sub_class_list.push_back(QString::fromStdString(cl->get_name()));
615 positions.push_back({0,0});
616 }
617 }
618
619 this->AddItemsToScene ( sub_class_list, positions );
620
621}
const FList * all_sub_classes() const noexcept
Definition class.hpp:466
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:235

◆ AddAllSuperClassesSlot

void dbse::SchemaGraphicsScene::AddAllSuperClassesSlot ( )
privateslot

Definition at line 582 of file SchemaGraphicsScene.cpp.

582 {
583
584 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
585 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
586
587 QStringList super_class_list;
588 QList<QPointF> positions;
589
590 const OksClass::FList* all_classes = class_info->all_super_classes();
591 if(all_classes != nullptr) {
592 for(const OksClass* cl : *all_classes) {
593 super_class_list.push_back(QString::fromStdString(cl->get_name()));
594 positions.push_back({0,0});
595 }
596 }
597
598
599 this->AddItemsToScene ( super_class_list, positions );
600
601}
const FList * all_super_classes() const noexcept
Definition class.hpp:408

◆ AddDirectRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddDirectRelationshipClassesSlot ( )
privateslot

Definition at line 623 of file SchemaGraphicsScene.cpp.

623 {
624
625 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
626 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
627
628 QStringList relationship_classes;
629 QList<QPointF> positions;
630
631 const std::list<OksRelationship *> * direct_relationship_list = class_info->direct_relationships();
632 if ( direct_relationship_list != nullptr ) {
633 for(const OksRelationship* rl : *direct_relationship_list) {
634 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
635 positions.push_back({0,0});
636 }
637
638 }
639
640 this->AddItemsToScene ( relationship_classes, positions );
641
642}
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:590

◆ AddDirectSuperClassesSlot

void dbse::SchemaGraphicsScene::AddDirectSuperClassesSlot ( )
privateslot

Definition at line 562 of file SchemaGraphicsScene.cpp.

562 {
563
564 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
565 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
566
567 QStringList super_class_list;
568 QList<QPointF> positions;
569
570 const std::list<std::string *>* direct_classes = class_info->direct_super_classes();
571 if(direct_classes != nullptr) {
572 for(std::string * cl_name : *direct_classes) {
573 super_class_list.push_back(QString::fromStdString(*cl_name));
574 positions.push_back({0,0});
575 }
576 }
577
578 this->AddItemsToScene ( super_class_list, positions );
579
580}
const std::list< std::string * > * direct_super_classes() const noexcept
Definition class.hpp:413

◆ AddItemsToScene()

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

Updating item list

Plotting the superclasses

Definition at line 212 of file SchemaGraphicsScene.cpp.

215{
216 QStringList missingItems{};
217
218 for ( QString & ClassName : SchemaClasses )
219 {
220 if ( !ItemMap.contains ( ClassName ) )
221 {
222
223 if ( !KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() ) ) {
224 std::cout << "ERROR: class " << ClassName.toStdString() << " not found" << std::endl;
225 missingItems.append(ClassName);
226 continue;
227 }
228
229 SchemaGraphicObject * Object = new SchemaGraphicObject ( ClassName );
230 Object->setPos ( Positions.at ( SchemaClasses.indexOf ( ClassName ) ) );
231 Object->set_inherited_properties_visibility(m_inherited_properties_visible);
232 Object->set_highlight_active(m_highlight_active);
233 addItem ( Object );
235 ItemMap.insert ( ClassName, Object );
236 }
237 }
238
239 for ( QString & ClassName : ItemMap.keys() )
240 {
241 OksClass * ClassInfo = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
242
243 const std::list<OksRelationship *> * DirectRelationshipList =
244 ClassInfo->direct_relationships();
245 const std::list<std::string *> * DirectSuperClassesList = ClassInfo->direct_super_classes();
246
247 std::map<std::string, unsigned int> arrow_count;
248
250 if ( DirectRelationshipList != nullptr )
251 {
252 for ( OksRelationship * ClassRelationship : * ( DirectRelationshipList ) )
253 {
254 auto rct = ClassRelationship->get_class_type()->get_name();
255 QString RelationshipClassType = QString::fromStdString (rct);
256
257 if ( ItemMap.contains ( RelationshipClassType ) ) //&& !ItemMap[ClassName]->HasArrow (
258 //ItemMap[RelationshipClassType] ) )
259 {
260 QString SchemaCardinality =
262 SchemaGraphicSegmentedArrow * NewArrow = new SchemaGraphicSegmentedArrow (
263 ItemMap[ClassName], ItemMap[RelationshipClassType],
264 arrow_count[rct],
265 false,
266 ClassRelationship->get_is_composite(),
267 QString::fromStdString ( ClassRelationship->get_name() ), SchemaCardinality );
268 ItemMap[ClassName]->AddArrow ( NewArrow );
269 ItemMap[RelationshipClassType]->AddArrow ( NewArrow );
270 addItem ( NewArrow );
271 //NewArrow->SetLabelScene(this);
272 NewArrow->setZValue ( -1000.0 );
273 NewArrow->UpdatePosition();
274 arrow_count[rct]++;
275 }
276 }
277 }
278
280 if ( DirectSuperClassesList != nullptr )
281 {
282 for ( std::string * SuperClassNameStd : * ( DirectSuperClassesList ) )
283 {
284 QString SuperClassName = QString::fromStdString ( *SuperClassNameStd );
285
286 if ( ItemMap.contains ( SuperClassName ) ) // && !ItemMap[ClassName]->HasArrow (
287 // ItemMap[SuperClassName] ) )
288 {
289 SchemaGraphicSegmentedArrow * NewArrow = new SchemaGraphicSegmentedArrow (
290 ItemMap[ClassName],
291 ItemMap[SuperClassName],
292 arrow_count[*SuperClassNameStd],
293 true,
294 false, "", "" );
295 ItemMap[ClassName]->AddArrow ( NewArrow );
296 ItemMap[SuperClassName]->AddArrow ( NewArrow );
297 addItem ( NewArrow );
298 //NewArrow->SetLabelScene(this);
299 NewArrow->setZValue ( -1000.0 );
300 NewArrow->UpdatePosition();
301 arrow_count[*SuperClassNameStd]++;
302 }
303 }
304 }
305 }
306 modified(true);
307 return missingItems;
308}
QString GetCardinalityStringRelationship(dunedaq::oks::OksRelationship *SchemaRelationship) const

◆ cancel_note_slot

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

Definition at line 480 of file SchemaGraphicsScene.cpp.

480 {
481 delete note;
482}

◆ CleanItemMap()

void dbse::SchemaGraphicsScene::CleanItemMap ( )

Definition at line 345 of file SchemaGraphicsScene.cpp.

346{
347 ItemMap.clear();
348}

◆ ClearModified()

void dbse::SchemaGraphicsScene::ClearModified ( )

Definition at line 387 of file SchemaGraphicsScene.cpp.

387 {
388 modified(false);
389}

◆ contextMenuEvent()

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

Definition at line 134 of file SchemaGraphicsScene.cpp.

135{
136 if ( m_context_menu == nullptr ) {
137 m_context_menu = new QMenu();
138 m_context_menu->addAction ( m_add_class );
139 m_context_menu->addAction ( m_add_note );
142
143 m_seperator_pos = m_context_menu->actions().size();
144 m_context_menu->addSeparator();
145
146 m_class_pos = m_context_menu->actions().size();
147 m_context_menu->addAction ( m_edit_class );
148 m_context_menu->addAction ( m_remove_class );
155
156 m_arrow_pos = m_context_menu->actions().size();
157 m_context_menu->addAction ( m_remove_arrow );
158
159 m_note_pos = m_context_menu->actions().size();
160 m_context_menu->addAction ( m_edit_note );
161 m_context_menu->addAction ( m_remove_note );
162 }
163
164 for (int item=0; item<m_seperator_pos; item++) {
165 m_context_menu->actions().at ( item )->setVisible ( true );
166 }
167
168 // Set all other items invisible
169 int nitems = m_context_menu->actions().size();
170 for (int item=m_seperator_pos; item<nitems; item++) {
171 m_context_menu->actions().at ( item )->setVisible ( false );
172 }
173
174 if ( itemAt ( event->scenePos(), QTransform() ) ) {
175 // Something under mouse pointer, set additional items visible
176 // depending on what it is
177 m_context_menu->actions().at ( m_seperator_pos )->setVisible ( true );
178
179 auto object = dynamic_cast<SchemaGraphicObject *> (
180 itemAt ( event->scenePos(), QTransform() ) );
181 auto arrow = dynamic_cast<SchemaGraphicSegmentedArrow *> (
182 itemAt ( event->scenePos(), QTransform() ) );
183 auto note = dynamic_cast<SchemaGraphicNote *> (
184 itemAt ( event->scenePos(), QTransform() ) );
185
186 if ( object != nullptr) {
187 CurrentObject = object;
188 auto filename =
191 m_context_menu->actions().at ( m_class_pos )->setVisible ( writable );
192 m_context_menu->actions().at ( m_class_pos+1 )->setVisible ( writable );
193 for (int item=m_class_pos+2; item<m_arrow_pos; item++) {
194 m_context_menu->actions().at ( item )->setVisible ( true );
195 }
196 }
197 else if ( arrow != nullptr ) {
198 m_context_menu->actions().at ( m_arrow_pos )->setVisible ( true );
199 m_current_arrow = arrow;
200 }
201 else if ( note != nullptr) {
202 for (int item=m_note_pos; item<nitems; item++) {
203 m_context_menu->actions().at ( item )->setVisible ( true );
204 }
205 m_current_note = note;
206 }
207 }
208 m_current_pos = event->scenePos();
209 m_context_menu->exec ( event->screenPos() );
210}
bool IsFileWritable(const std::string &FileName) const
SchemaGraphicNote * m_current_note
OksFile * get_file() const noexcept
Definition class.hpp:338
const std::string & get_full_file_name() const
Definition file.hpp:523

◆ CreateActions()

void dbse::SchemaGraphicsScene::CreateActions ( )

Definition at line 39 of file SchemaGraphicsScene.cpp.

40{
41 // Add new class
42 m_add_class = new QAction ( "&Add new class", this );
43 connect ( m_add_class, SIGNAL ( triggered() ), this, SLOT ( new_class_slot() ) );
44
45 // Edit current class
46 m_edit_class = new QAction ( "&Edit class", this );
47 connect ( m_edit_class, SIGNAL ( triggered() ), this, SLOT ( EditClassSlot() ) );
48
49 // Toggle inherited properties of all classes in view
50 m_toggle_indirect_infos = new QAction ( "&Toggle inherited properties", this );
51 connect ( m_toggle_indirect_infos, SIGNAL ( triggered() ), this, SLOT ( ToggleIndirectInfos() ) );
52
53 // Toggle highlighting of all classes in active schema
54 m_toggle_highlight_active = new QAction ( "Toggle &highlighting of classes in active schema", this );
55 connect ( m_toggle_highlight_active, SIGNAL ( triggered() ), this, SLOT ( ToggleHighlightActive() ) );
56
57 m_add_note = new QAction ( "Add note to view", this );
58 connect ( m_add_note, SIGNAL ( triggered() ), this, SLOT ( new_note_slot() ) );
59
60 m_edit_note = new QAction ( "Edit note", this );
61 connect ( m_edit_note, SIGNAL ( triggered() ), this, SLOT ( edit_note_slot() ) );
62
63 m_remove_note = new QAction ( "Remove note", this );
64 connect ( m_remove_note, SIGNAL ( triggered() ), this, SLOT ( remove_note_slot() ) );
65
66 // Show superclasses of the current class
67 m_add_direct_super_classes = new QAction ( "Add direct &superclasses to view", this );
68 connect ( m_add_direct_super_classes, SIGNAL ( triggered() ), this, SLOT ( AddDirectSuperClassesSlot() ) );
69
70 // Show relationship classes of the current clas
71 m_add_direct_relationship_classes = new QAction ( "Add &direct relationship classes to view", this );
72 connect ( m_add_direct_relationship_classes, SIGNAL ( triggered() ), this, SLOT ( AddDirectRelationshipClassesSlot() ) );
73
74 // Show superclasses of the current class
75 m_add_all_super_classes = new QAction ( "Add all &superclasses to view", this );
76 connect ( m_add_all_super_classes, SIGNAL ( triggered() ), this, SLOT ( AddAllSuperClassesSlot() ) );
77
78 // Show subclasses of the current clas
79 m_add_all_sub_classes = new QAction ( "Add all s&ubclasses to view", this );
80 connect ( m_add_all_sub_classes, SIGNAL ( triggered() ), this, SLOT ( AddAllSubClassesSlot() ) );
81
82 // Show indirect relationship classes of the current class
83 m_add_all_relationship_classes = new QAction ( "Add a&ll relationship classes to view", this );
84 connect ( m_add_all_relationship_classes, SIGNAL ( triggered() ), this, SLOT ( AddAllRelationshipClassesSlot() ) );
85
86 // Remove class
87 m_remove_class = new QAction ( "&Remove Class from view", this );
88 connect ( m_remove_class, SIGNAL ( triggered() ), this, SLOT ( RemoveClassSlot() ) );
89
90 // Remove arrow
91 m_remove_arrow = new QAction ( "&Remove Arrow", this );
92 connect ( m_remove_arrow, SIGNAL ( triggered() ), this, SLOT ( RemoveArrowSlot() ) );
93}

◆ dragEnterEvent()

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

Drag & Drop.

Definition at line 95 of file SchemaGraphicsScene.cpp.

96{
97 if ( event->mimeData()->hasFormat ( "application/vnd.text.list" ) )
98 {
99 event->accept();
100 }
101}

◆ dragMoveEvent()

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

Definition at line 103 of file SchemaGraphicsScene.cpp.

104{
105 if ( event->mimeData()->hasFormat ( "application/vnd.text.list" ) )
106 {
107 event->accept();
108 }
109}

◆ DrawArrow

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

Definition at line 684 of file SchemaGraphicsScene.cpp.

686{
687 if ( !ItemMap.contains ( ClassName ) || !ItemMap.contains ( RelationshipType ) )
688 {
689 return;
690 }
691
692 SchemaGraphicObject * startItem = ItemMap[ClassName];
693 SchemaGraphicObject * endItem = ItemMap[RelationshipType];
694
695 OksClass * SchemaClass = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
696 OksRelationship * SchemaRelationship = SchemaClass->find_direct_relationship (
697 RelationshipName.toStdString() );
698
699 if ( SchemaRelationship != nullptr )
700 {
701 QString RelationshipCardinality =
703 SchemaGraphicSegmentedArrow * newArrow = new SchemaGraphicSegmentedArrow (
704 startItem, endItem,
705 0,
706 false, SchemaRelationship->get_is_composite(),
707 QString::fromStdString ( SchemaRelationship->get_name() ), RelationshipCardinality );
708 startItem->AddArrow ( newArrow );
709 endItem->AddArrow ( newArrow );
710 newArrow->setZValue ( -1000.0 );
711 addItem ( newArrow );
712 //newArrow->SetLabelScene(this);
713 newArrow->UpdatePosition();
714 }
715}
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1173
bool get_is_composite() const noexcept
const std::string & get_name() const noexcept

◆ dropEvent()

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

Definition at line 111 of file SchemaGraphicsScene.cpp.

112{
113 QByteArray encodedData = event->mimeData()->data ( "application/vnd.text.list" );
114 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
115 QStringList SchemaClasses;
116
117 while ( !stream.atEnd() )
118 {
119 QString ClassName;
120 stream >> ClassName;
121 SchemaClasses.append ( ClassName );
122 }
123
124 QList<QPointF> Positions;
125
126 for ( int i = 0; i < SchemaClasses.size(); ++i )
127 {
128 Positions.push_back ( event->scenePos() );
129 }
130
131 AddItemsToScene ( SchemaClasses, Positions );
132}

◆ edit_note_slot

void dbse::SchemaGraphicsScene::edit_note_slot ( )
privateslot

Definition at line 468 of file SchemaGraphicsScene.cpp.

◆ EditClassSlot

void dbse::SchemaGraphicsScene::EditClassSlot ( )
privateslot

Definition at line 512 of file SchemaGraphicsScene.cpp.

513{
514 bool WidgetFound = false;
515 QString ClassName = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
516
517 for ( QWidget * Editor : QApplication::allWidgets() )
518 {
519 SchemaClassEditor * Widget = dynamic_cast<SchemaClassEditor *> ( Editor );
520
521 if ( Widget != nullptr )
522 {
523 if ( ( Widget->objectName() ).compare ( ClassName ) == 0 )
524 {
525 Widget->raise();
526 Widget->setVisible ( true );
527 Widget->activateWindow();
528 WidgetFound = true;
529 }
530 }
531 }
532
533 if ( !WidgetFound )
534 {
535 SchemaClassEditor * Editor = new SchemaClassEditor ( CurrentObject->GetClass() );
536 Editor->show();
537 }
538}

◆ IsModified()

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

Definition at line 34 of file SchemaGraphicsScene.hpp.

34{return m_modified;};

◆ modified()

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

Definition at line 391 of file SchemaGraphicsScene.cpp.

391 {
392 m_modified = state;
393 emit sceneModified(state);
394}

◆ modified_slot

void dbse::SchemaGraphicsScene::modified_slot ( )
privateslot

Definition at line 396 of file SchemaGraphicsScene.cpp.

396 {
397 modified(true);
398}

◆ mouseMoveEvent()

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

Definition at line 374 of file SchemaGraphicsScene.cpp.

375{
376 if ( m_line != nullptr )
377 {
378 QLineF newLine ( m_line->line().p1(), mouseEvent->scenePos() );
379 m_line->setLine ( newLine );
380 }
381 else
382 {
383 QGraphicsScene::mouseMoveEvent ( mouseEvent );
384 }
385}

◆ mousePressEvent()

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

Definition at line 350 of file SchemaGraphicsScene.cpp.

351{
352 if ( itemAt ( mouseEvent->scenePos(), QTransform() ) ) {
353 // Save position of item under mouse so we can see if it has been
354 // moved in mouseReleaseEvent
355 m_mouse_item_pos = itemAt(mouseEvent->scenePos(), QTransform())->pos();
356 }
357 if ( mouseEvent->button() != Qt::LeftButton )
358 {
359 return;
360 }
361
362 if ( mouseEvent->widget()->cursor().shape() == Qt::CrossCursor )
363 {
364 m_line = new QGraphicsLineItem ( QLineF ( mouseEvent->scenePos(), mouseEvent->scenePos() ) );
365 m_line->setPen ( QPen ( Qt::black, 2 ) );
366 addItem ( m_line );
367 modified(true);
368 return;
369 }
370
371 QGraphicsScene::mousePressEvent ( mouseEvent );
372}

◆ mouseReleaseEvent()

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

Create arrow

Definition at line 399 of file SchemaGraphicsScene.cpp.

400{
401 if ( itemAt ( mouseEvent->scenePos(), QTransform() ) ) {
402 auto item = itemAt(mouseEvent->scenePos(), QTransform() );
403 if (!m_mouse_item_pos.isNull()) {
404 modified(m_mouse_item_pos != item->pos());
405 m_mouse_item_pos = QPointF();
406 }
407 }
408 if ( m_line != nullptr )
409 {
410 QList<QGraphicsItem *> startItems = items ( m_line->line().p1() );
411
412 if ( startItems.count() && startItems.first() == m_line )
413 {
414 startItems.removeFirst();
415 }
416
417 QList<QGraphicsItem *> endItems = items ( m_line->line().p2() );
418
419 if ( endItems.count() && endItems.first() == m_line )
420 {
421 endItems.removeFirst();
422 }
423
425 delete m_line;
426
427 if ( startItems.count() > 0 && endItems.count() > 0
428 && startItems.first() != endItems.first() )
429 {
430
431 bool Inheritance = KernelWrapper::GetInstance().GetInheritanceMode();
432 SchemaGraphicObject * startItem = qgraphicsitem_cast<SchemaGraphicObject *> (
433 startItems.first() );
434 SchemaGraphicObject * endItem = qgraphicsitem_cast<SchemaGraphicObject *> (
435 endItems.first() );
436
437 if ( Inheritance )
438 {
439 startItem->GetClass()->add_super_class ( endItem->GetClassName().toStdString() );
441 SchemaGraphicSegmentedArrow * newArrow = new SchemaGraphicSegmentedArrow (
442 startItem, endItem,
443 0,
444 Inheritance,
445 true, "", "" );
446 startItem->AddArrow ( newArrow );
447 endItem->AddArrow ( newArrow );
448 newArrow->setZValue ( -1000.0 );
449 addItem ( newArrow );
450 //newArrow->SetLabelScene(this);
451 newArrow->UpdatePosition();
452 }
453 else
454 {
455 SchemaRelationshipEditor * Editor = new SchemaRelationshipEditor (
456 startItem->GetClass(), endItem->GetClassName() );
457 connect ( Editor, SIGNAL ( MakeGraphConnection ( QString, QString, QString ) ), this,
458 SLOT ( DrawArrow ( QString, QString, QString ) ) );
459 Editor->show();
460 }
461 }
462 }
463
464 m_line = nullptr;
465 QGraphicsScene::mouseReleaseEvent ( mouseEvent );
466}
void DrawArrow(QString ClassName, QString RelationshipType, QString RelationshipName)
void RemoveItemFromScene(QGraphicsItem *item)

◆ new_class_slot

void dbse::SchemaGraphicsScene::new_class_slot ( )
privateslot

Definition at line 505 of file SchemaGraphicsScene.cpp.

505 {
506 m_addclass_connection = connect (
507 &KernelWrapper::GetInstance(), SIGNAL ( ClassCreated(QString) ),
508 this, SLOT ( add_class_slot(QString) ) );
510}

◆ new_note_slot

void dbse::SchemaGraphicsScene::new_note_slot ( )
privateslot

Definition at line 484 of file SchemaGraphicsScene.cpp.

484 {
485 auto note = new SchemaGraphicNote (
486 QString("#") + QString::number(m_next_note++), QString());
487 note->setPos(m_current_pos);
488 auto editor = new SchemaNoteEditor(note);
489 connect(editor, SIGNAL(note_accepted(SchemaGraphicNote*)), this, SLOT(add_note_slot(SchemaGraphicNote*)));
490 connect(editor, SIGNAL(cancelled(SchemaGraphicNote*)), this, SLOT(cancel_note_slot(SchemaGraphicNote*)));
491 editor->show();
492}
void add_note_slot(SchemaGraphicNote *)
void cancel_note_slot(SchemaGraphicNote *)

◆ remove_note_object()

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

Definition at line 326 of file SchemaGraphicsScene.cpp.

326 {
327 if (note == nullptr) {
328 return;
329 }
330 RemoveItemFromScene (note);
331}

◆ remove_note_slot

void dbse::SchemaGraphicsScene::remove_note_slot ( )
privateslot

Definition at line 472 of file SchemaGraphicsScene.cpp.

472 {
474}
void remove_note_object(SchemaGraphicNote *obj)

◆ RemoveArrowSlot

void dbse::SchemaGraphicsScene::RemoveArrowSlot ( )
privateslot

◆ RemoveClassObject()

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

Definition at line 333 of file SchemaGraphicsScene.cpp.

334{
335 if ( Object == nullptr )
336 {
337 return;
338 }
339
340 Object->RemoveArrows();
341 RemoveItemFromScene ( Object );
342 ItemMap.remove ( Object->GetClassName() );
343}

◆ RemoveClassSlot

void dbse::SchemaGraphicsScene::RemoveClassSlot ( )
privateslot

Definition at line 664 of file SchemaGraphicsScene.cpp.

665{
666 if ( CurrentObject == nullptr )
667 {
668 return;
669 }
670
673 ItemMap.remove ( CurrentObject->GetClassName() );
674}

◆ RemoveItemFromScene()

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

Definition at line 310 of file SchemaGraphicsScene.cpp.

310 {
311 removeItem ( item );
312 modified(true);
313}

◆ sceneModified

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

◆ ToggleHighlightActive

void dbse::SchemaGraphicsScene::ToggleHighlightActive ( )
privateslot

Definition at line 540 of file SchemaGraphicsScene.cpp.

540 {
542
543 for ( SchemaGraphicObject * item : ItemMap.values() ) {
544 item->set_highlight_active(m_highlight_active);
545 }
546
547 this->update();
548
549}

◆ ToggleIndirectInfos

void dbse::SchemaGraphicsScene::ToggleIndirectInfos ( )
privateslot

Definition at line 551 of file SchemaGraphicsScene.cpp.

551 {
553
554 for ( SchemaGraphicObject * item : ItemMap.values() ) {
555 item->set_inherited_properties_visibility(m_inherited_properties_visible);
556 }
557
558 this->update();
559
560}

Member Data Documentation

◆ CurrentObject

SchemaGraphicObject* dbse::SchemaGraphicsScene::CurrentObject
private

Definition at line 88 of file SchemaGraphicsScene.hpp.

◆ ItemMap

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

Definition at line 66 of file SchemaGraphicsScene.hpp.

◆ m_add_all_relationship_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_relationship_classes
private

Definition at line 81 of file SchemaGraphicsScene.hpp.

◆ m_add_all_sub_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_sub_classes
private

Definition at line 80 of file SchemaGraphicsScene.hpp.

◆ m_add_all_super_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_super_classes
private

Definition at line 79 of file SchemaGraphicsScene.hpp.

◆ m_add_class

QAction* dbse::SchemaGraphicsScene::m_add_class
private

Definition at line 73 of file SchemaGraphicsScene.hpp.

◆ m_add_direct_relationship_classes

QAction* dbse::SchemaGraphicsScene::m_add_direct_relationship_classes
private

Definition at line 78 of file SchemaGraphicsScene.hpp.

◆ m_add_direct_super_classes

QAction* dbse::SchemaGraphicsScene::m_add_direct_super_classes
private

Definition at line 77 of file SchemaGraphicsScene.hpp.

◆ m_add_note

QAction* dbse::SchemaGraphicsScene::m_add_note
private

Definition at line 82 of file SchemaGraphicsScene.hpp.

◆ m_addclass_connection

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

Definition at line 87 of file SchemaGraphicsScene.hpp.

◆ m_arrow_pos

int dbse::SchemaGraphicsScene::m_arrow_pos
private

Definition at line 71 of file SchemaGraphicsScene.hpp.

◆ m_class_pos

int dbse::SchemaGraphicsScene::m_class_pos
private

Definition at line 70 of file SchemaGraphicsScene.hpp.

◆ m_context_menu

QMenu* dbse::SchemaGraphicsScene::m_context_menu
private

Definition at line 68 of file SchemaGraphicsScene.hpp.

◆ m_current_arrow

SchemaGraphicSegmentedArrow* dbse::SchemaGraphicsScene::m_current_arrow
private

Definition at line 89 of file SchemaGraphicsScene.hpp.

◆ m_current_note

SchemaGraphicNote* dbse::SchemaGraphicsScene::m_current_note
private

Definition at line 90 of file SchemaGraphicsScene.hpp.

◆ m_current_pos

QPointF dbse::SchemaGraphicsScene::m_current_pos
private

Definition at line 91 of file SchemaGraphicsScene.hpp.

◆ m_edit_class

QAction* dbse::SchemaGraphicsScene::m_edit_class
private

Definition at line 74 of file SchemaGraphicsScene.hpp.

◆ m_edit_note

QAction* dbse::SchemaGraphicsScene::m_edit_note
private

Definition at line 83 of file SchemaGraphicsScene.hpp.

◆ m_highlight_active

bool dbse::SchemaGraphicsScene::m_highlight_active
private

Definition at line 95 of file SchemaGraphicsScene.hpp.

◆ m_inherited_properties_visible

bool dbse::SchemaGraphicsScene::m_inherited_properties_visible
private

Definition at line 94 of file SchemaGraphicsScene.hpp.

◆ m_line

QGraphicsLineItem* dbse::SchemaGraphicsScene::m_line
private

Definition at line 67 of file SchemaGraphicsScene.hpp.

◆ m_modified

bool dbse::SchemaGraphicsScene::m_modified
private

Definition at line 96 of file SchemaGraphicsScene.hpp.

◆ m_mouse_item_pos

QPointF dbse::SchemaGraphicsScene::m_mouse_item_pos
private

Definition at line 92 of file SchemaGraphicsScene.hpp.

◆ m_next_note

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

Definition at line 93 of file SchemaGraphicsScene.hpp.

93{0};

◆ m_note_pos

int dbse::SchemaGraphicsScene::m_note_pos
private

Definition at line 72 of file SchemaGraphicsScene.hpp.

◆ m_remove_arrow

QAction* dbse::SchemaGraphicsScene::m_remove_arrow
private

Definition at line 86 of file SchemaGraphicsScene.hpp.

◆ m_remove_class

QAction* dbse::SchemaGraphicsScene::m_remove_class
private

Definition at line 85 of file SchemaGraphicsScene.hpp.

◆ m_remove_note

QAction* dbse::SchemaGraphicsScene::m_remove_note
private

Definition at line 84 of file SchemaGraphicsScene.hpp.

◆ m_seperator_pos

int dbse::SchemaGraphicsScene::m_seperator_pos
private

Definition at line 69 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_active

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_active
private

Definition at line 76 of file SchemaGraphicsScene.hpp.

◆ m_toggle_indirect_infos

QAction* dbse::SchemaGraphicsScene::m_toggle_indirect_infos
private

Definition at line 75 of file SchemaGraphicsScene.hpp.


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