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 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)
 

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_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
 
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_abstract
 
bool m_highlight_active
 
bool m_show_defaults
 
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 ),
29 m_highlight_active(false),
30 m_modified(false)
31{
33 setSceneRect ( QRectF ( 0, 0, 10000, 10000 ) );
34}
SchemaGraphicSegmentedArrow * m_current_arrow
SchemaGraphicObject * CurrentObject

◆ ~SchemaGraphicsScene()

dbse::SchemaGraphicsScene::~SchemaGraphicsScene ( )

Definition at line 36 of file SchemaGraphicsScene.cpp.

37{
38}

Member Function Documentation

◆ add_class_slot

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

Updating item list

Definition at line 516 of file SchemaGraphicsScene.cpp.

516 {
517 disconnect(m_addclass_connection);
518
519 auto object = new SchemaGraphicObject(class_name, this);
520 object->setPos(m_current_pos);
521 addItem (object);
523 ItemMap.insert(class_name, object);
524}
QMetaObject::Connection m_addclass_connection
QMap< QString, SchemaGraphicObject * > ItemMap

◆ add_note_slot

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

Definition at line 498 of file SchemaGraphicsScene.cpp.

498 {
499 addItem(note);
500 modified(true);
501}

◆ add_notes()

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

Definition at line 335 of file SchemaGraphicsScene.cpp.

336 {
337 for ( int index = 0; index<notes.size(); index++) {
338 auto note = new SchemaGraphicNote (
339 QString("#" + QString::number(m_next_note++)),
340 notes.at(index) );
341 note->setPos ( positions.at ( index ) );
342 addItem(note);
343 }
344
345}

◆ AddAllRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddAllRelationshipClassesSlot ( )
privateslot

Definition at line 652 of file SchemaGraphicsScene.cpp.

652 {
653
654 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
655 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
656
657 QStringList relationship_classes;
658 QList<QPointF> positions;
659
660 const std::list<OksRelationship *> * all_relationship_list = class_info->all_relationships();
661 if ( all_relationship_list != nullptr ) {
662 for(const OksRelationship* rl : *all_relationship_list) {
663 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
664 positions.push_back({0,0});
665 }
666
667 }
668
669 this->AddItemsToScene ( relationship_classes, positions );
670}
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 611 of file SchemaGraphicsScene.cpp.

611 {
612
613 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
614 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
615
616 QStringList sub_class_list;
617 QList<QPointF> positions;
618
619 const OksClass::FList* all_classes = class_info->all_sub_classes();
620 if(all_classes != nullptr) {
621 for(const OksClass* cl : *all_classes) {
622 sub_class_list.push_back(QString::fromStdString(cl->get_name()));
623 positions.push_back({0,0});
624 }
625 }
626
627 this->AddItemsToScene ( sub_class_list, positions );
628
629}
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 590 of file SchemaGraphicsScene.cpp.

590 {
591
592 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
593 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
594
595 QStringList super_class_list;
596 QList<QPointF> positions;
597
598 const OksClass::FList* all_classes = class_info->all_super_classes();
599 if(all_classes != nullptr) {
600 for(const OksClass* cl : *all_classes) {
601 super_class_list.push_back(QString::fromStdString(cl->get_name()));
602 positions.push_back({0,0});
603 }
604 }
605
606
607 this->AddItemsToScene ( super_class_list, positions );
608
609}
const FList * all_super_classes() const noexcept
Definition class.hpp:408

◆ AddDirectRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddDirectRelationshipClassesSlot ( )
privateslot

Definition at line 631 of file SchemaGraphicsScene.cpp.

631 {
632
633 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
634 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
635
636 QStringList relationship_classes;
637 QList<QPointF> positions;
638
639 const std::list<OksRelationship *> * direct_relationship_list = class_info->direct_relationships();
640 if ( direct_relationship_list != nullptr ) {
641 for(const OksRelationship* rl : *direct_relationship_list) {
642 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
643 positions.push_back({0,0});
644 }
645
646 }
647
648 this->AddItemsToScene ( relationship_classes, positions );
649
650}
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:590

◆ AddDirectSuperClassesSlot

void dbse::SchemaGraphicsScene::AddDirectSuperClassesSlot ( )
privateslot

Definition at line 570 of file SchemaGraphicsScene.cpp.

570 {
571
572 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
573 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
574
575 QStringList super_class_list;
576 QList<QPointF> positions;
577
578 const std::list<std::string *>* direct_classes = class_info->direct_super_classes();
579 if(direct_classes != nullptr) {
580 for(std::string * cl_name : *direct_classes) {
581 super_class_list.push_back(QString::fromStdString(*cl_name));
582 positions.push_back({0,0});
583 }
584 }
585
586 this->AddItemsToScene ( super_class_list, positions );
587
588}
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 234 of file SchemaGraphicsScene.cpp.

237{
238 QStringList missingItems{};
239
240 for ( QString & ClassName : SchemaClasses )
241 {
242 if ( !ItemMap.contains ( ClassName ) )
243 {
244
245 if ( !KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() ) ) {
246 std::cout << "ERROR: class " << ClassName.toStdString() << " not found" << std::endl;
247 missingItems.append(ClassName);
248 continue;
249 }
250
251 SchemaGraphicObject * Object = new SchemaGraphicObject ( ClassName, this );
252 Object->setPos ( Positions.at ( SchemaClasses.indexOf ( ClassName ) ) );
253 addItem ( Object );
255 ItemMap.insert ( ClassName, Object );
256 }
257 }
258
259 for ( QString & ClassName : ItemMap.keys() )
260 {
261 OksClass * ClassInfo = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
262
263 const std::list<OksRelationship *> * DirectRelationshipList =
264 ClassInfo->direct_relationships();
265 const std::list<std::string *> * DirectSuperClassesList = ClassInfo->direct_super_classes();
266
267 std::map<std::string, unsigned int> arrow_count;
268
270 if ( DirectRelationshipList != nullptr )
271 {
272 for ( OksRelationship * ClassRelationship : * ( DirectRelationshipList ) )
273 {
274 auto rct = ClassRelationship->get_class_type()->get_name();
275 QString RelationshipClassType = QString::fromStdString (rct);
276
277 if ( ItemMap.contains ( RelationshipClassType ) ) //&& !ItemMap[ClassName]->HasArrow (
278 //ItemMap[RelationshipClassType] ) )
279 {
280 QString SchemaCardinality =
282 SchemaGraphicSegmentedArrow * NewArrow = new SchemaGraphicSegmentedArrow (
283 ItemMap[ClassName], ItemMap[RelationshipClassType],
284 arrow_count[rct],
285 false,
286 ClassRelationship->get_is_composite(),
287 QString::fromStdString ( ClassRelationship->get_name() ), SchemaCardinality );
288 ItemMap[ClassName]->AddArrow ( NewArrow );
289 ItemMap[RelationshipClassType]->AddArrow ( NewArrow );
290 addItem ( NewArrow );
291 //NewArrow->SetLabelScene(this);
292 NewArrow->setZValue ( -1000.0 );
293 NewArrow->UpdatePosition();
294 arrow_count[rct]++;
295 }
296 }
297 }
298
300 if ( DirectSuperClassesList != nullptr )
301 {
302 for ( std::string * SuperClassNameStd : * ( DirectSuperClassesList ) )
303 {
304 QString SuperClassName = QString::fromStdString ( *SuperClassNameStd );
305
306 if ( ItemMap.contains ( SuperClassName ) ) // && !ItemMap[ClassName]->HasArrow (
307 // ItemMap[SuperClassName] ) )
308 {
309 SchemaGraphicSegmentedArrow * NewArrow = new SchemaGraphicSegmentedArrow (
310 ItemMap[ClassName],
311 ItemMap[SuperClassName],
312 arrow_count[*SuperClassNameStd],
313 true,
314 false, "", "" );
315 ItemMap[ClassName]->AddArrow ( NewArrow );
316 ItemMap[SuperClassName]->AddArrow ( NewArrow );
317 addItem ( NewArrow );
318 //NewArrow->SetLabelScene(this);
319 NewArrow->setZValue ( -1000.0 );
320 NewArrow->UpdatePosition();
321 arrow_count[*SuperClassNameStd]++;
322 }
323 }
324 }
325 }
326 modified(true);
327 return missingItems;
328}
QString GetCardinalityStringRelationship(dunedaq::oks::OksRelationship *SchemaRelationship) const

◆ cancel_note_slot

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

Definition at line 502 of file SchemaGraphicsScene.cpp.

502 {
503 delete note;
504}

◆ CleanItemMap()

void dbse::SchemaGraphicsScene::CleanItemMap ( )

Definition at line 365 of file SchemaGraphicsScene.cpp.

366{
367 ItemMap.clear();
368}

◆ ClearModified()

void dbse::SchemaGraphicsScene::ClearModified ( )

Definition at line 407 of file SchemaGraphicsScene.cpp.

407 {
408 modified(false);
409}

◆ contextMenuEvent()

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

Definition at line 150 of file SchemaGraphicsScene.cpp.

151{
152 if ( m_context_menu == nullptr ) {
153 m_context_menu = new QMenu();
154 m_context_menu->addAction ( m_add_class );
155 m_context_menu->addAction ( m_add_note );
159 m_context_menu->addAction ( m_toggle_default );
160
161 m_seperator_pos = m_context_menu->actions().size();
162 m_context_menu->addSeparator();
163
164 m_class_pos = m_context_menu->actions().size();
165 m_context_menu->addAction ( m_edit_class );
166 m_context_menu->addAction ( m_remove_class );
174
175 m_arrow_pos = m_context_menu->actions().size();
176 m_context_menu->addAction ( m_remove_arrow );
177
178 m_note_pos = m_context_menu->actions().size();
179 m_context_menu->addAction ( m_edit_note );
180 m_context_menu->addAction ( m_remove_note );
181 }
182
183 bool active = KernelWrapper::GetInstance().IsActive ( );
184 m_context_menu->actions().at ( 0 )->setVisible ( active );
185
186 for (int item=1; item<m_seperator_pos; item++) {
187 m_context_menu->actions().at ( item )->setVisible ( true );
188 }
189
190 // Set all other items invisible
191 const auto nitems = m_context_menu->actions().size();
192 for (int item=m_seperator_pos; item<nitems; item++) {
193 m_context_menu->actions().at ( item )->setVisible ( false );
194 }
195
196 if ( itemAt ( event->scenePos(), QTransform() ) ) {
197 // Something under mouse pointer, set additional items visible
198 // depending on what it is
199 m_context_menu->actions().at ( m_seperator_pos )->setVisible ( true );
200
201 auto object = dynamic_cast<SchemaGraphicObject *> (
202 itemAt ( event->scenePos(), QTransform() ) );
203 auto arrow = dynamic_cast<SchemaGraphicSegmentedArrow *> (
204 itemAt ( event->scenePos(), QTransform() ) );
205 auto note = dynamic_cast<SchemaGraphicNote *> (
206 itemAt ( event->scenePos(), QTransform() ) );
207
208 if ( object != nullptr) {
209 CurrentObject = object;
210 auto filename =
213 m_context_menu->actions().at ( m_class_pos )->setVisible ( writable );
214
215 for (int item=m_class_pos+1; item<m_arrow_pos; item++) {
216 m_context_menu->actions().at ( item )->setVisible ( true );
217 }
218 }
219 else if ( arrow != nullptr ) {
220 m_context_menu->actions().at ( m_arrow_pos )->setVisible ( true );
221 m_current_arrow = arrow;
222 }
223 else if ( note != nullptr) {
224 for (int item=m_note_pos; item<nitems; item++) {
225 m_context_menu->actions().at ( item )->setVisible ( true );
226 }
227 m_current_note = note;
228 }
229 }
230 m_current_pos = event->scenePos();
231 m_context_menu->exec ( event->screenPos() );
232}
bool IsFileWritable(const std::string &FileName) const
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 40 of file SchemaGraphicsScene.cpp.

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

◆ dragEnterEvent()

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

Drag & Drop.

Definition at line 108 of file SchemaGraphicsScene.cpp.

109{
110 if ( event->mimeData()->hasFormat ( "application/vnd.text.list" ) )
111 {
112 event->accept();
113 }
114}

◆ dragMoveEvent()

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

Definition at line 116 of file SchemaGraphicsScene.cpp.

117{
118 if ( event->mimeData()->hasFormat ( "application/vnd.text.list" ) )
119 {
120 event->accept();
121 }
122}

◆ DrawArrow

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

Definition at line 692 of file SchemaGraphicsScene.cpp.

694{
695 if ( !ItemMap.contains ( ClassName ) || !ItemMap.contains ( RelationshipType ) )
696 {
697 return;
698 }
699
700 SchemaGraphicObject * startItem = ItemMap[ClassName];
701 SchemaGraphicObject * endItem = ItemMap[RelationshipType];
702
703 OksClass * SchemaClass = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
704 OksRelationship * SchemaRelationship = SchemaClass->find_direct_relationship (
705 RelationshipName.toStdString() );
706
707 if ( SchemaRelationship != nullptr )
708 {
709 QString RelationshipCardinality =
711 SchemaGraphicSegmentedArrow * newArrow = new SchemaGraphicSegmentedArrow (
712 startItem, endItem,
713 0,
714 false, SchemaRelationship->get_is_composite(),
715 QString::fromStdString ( SchemaRelationship->get_name() ), RelationshipCardinality );
716 startItem->AddArrow ( newArrow );
717 endItem->AddArrow ( newArrow );
718 newArrow->setZValue ( -1000.0 );
719 addItem ( newArrow );
720 //newArrow->SetLabelScene(this);
721 newArrow->UpdatePosition();
722 }
723}
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 124 of file SchemaGraphicsScene.cpp.

125{
126 QByteArray encodedData = event->mimeData()->data ( "application/vnd.text.list" );
127 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
128
129 if (stream.atEnd()) {
130 return;
131 }
132
133 QStringList schema_classes;
134 while ( !stream.atEnd() )
135 {
136 QString class_name;
137 stream >> class_name;
138 schema_classes.append ( class_name );
139 }
140
141 QList<QPointF> positions;
142 for ( int i = 0; i < schema_classes.size(); ++i )
143 {
144 positions.push_back ( event->scenePos() );
145 }
146
147 AddItemsToScene ( schema_classes, positions );
148}

◆ edit_note_slot

void dbse::SchemaGraphicsScene::edit_note_slot ( )
privateslot

Definition at line 490 of file SchemaGraphicsScene.cpp.

◆ EditClassSlot

void dbse::SchemaGraphicsScene::EditClassSlot ( )
privateslot

Definition at line 532 of file SchemaGraphicsScene.cpp.

533{
534 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
535 SchemaClassEditor::launch(class_name);
536}
static void launch(QString class_name)

◆ highlight_abstract()

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

Definition at line 34 of file SchemaGraphicsScene.hpp.

◆ highlight_active()

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

Definition at line 35 of file SchemaGraphicsScene.hpp.

35{return m_highlight_active;}

◆ inherited_properties_visible()

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

Definition at line 36 of file SchemaGraphicsScene.hpp.

◆ IsModified()

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

Definition at line 40 of file SchemaGraphicsScene.hpp.

40{return m_modified;};

◆ modified()

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

Definition at line 411 of file SchemaGraphicsScene.cpp.

411 {
412 m_modified = state;
413 emit sceneModified(state);
414}

◆ modified_slot

void dbse::SchemaGraphicsScene::modified_slot ( )
privateslot

Definition at line 416 of file SchemaGraphicsScene.cpp.

416 {
417 modified(true);
418}

◆ mouseMoveEvent()

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

Definition at line 394 of file SchemaGraphicsScene.cpp.

395{
396 if ( m_line != nullptr )
397 {
398 QLineF newLine ( m_line->line().p1(), mouseEvent->scenePos() );
399 m_line->setLine ( newLine );
400 }
401 else
402 {
403 QGraphicsScene::mouseMoveEvent ( mouseEvent );
404 }
405}

◆ mousePressEvent()

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

Definition at line 370 of file SchemaGraphicsScene.cpp.

371{
372 if ( itemAt ( mouseEvent->scenePos(), QTransform() ) ) {
373 // Save position of item under mouse so we can see if it has been
374 // moved in mouseReleaseEvent
375 m_mouse_item_pos = itemAt(mouseEvent->scenePos(), QTransform())->pos();
376 }
377 if ( mouseEvent->button() != Qt::LeftButton )
378 {
379 return;
380 }
381
382 if ( mouseEvent->widget()->cursor().shape() == Qt::CrossCursor )
383 {
384 m_line = new QGraphicsLineItem ( QLineF ( mouseEvent->scenePos(), mouseEvent->scenePos() ) );
385 m_line->setPen ( QPen ( Qt::black, 2 ) );
386 addItem ( m_line );
387 modified(true);
388 return;
389 }
390
391 QGraphicsScene::mousePressEvent ( mouseEvent );
392}

◆ mouseReleaseEvent()

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

Create arrow

Definition at line 419 of file SchemaGraphicsScene.cpp.

420{
421 if ( itemAt ( mouseEvent->scenePos(), QTransform() ) ) {
422 auto item = itemAt(mouseEvent->scenePos(), QTransform() );
423 if (!m_mouse_item_pos.isNull()) {
424 if (m_mouse_item_pos != item->pos()) {
425 modified(true);
426 }
427 m_mouse_item_pos = QPointF();
428 }
429 }
430 if ( m_line != nullptr )
431 {
432 QList<QGraphicsItem *> startItems = items ( m_line->line().p1() );
433
434 if ( startItems.count() && startItems.first() == m_line )
435 {
436 startItems.removeFirst();
437 }
438
439 QList<QGraphicsItem *> endItems = items ( m_line->line().p2() );
440
441 if ( endItems.count() && endItems.first() == m_line )
442 {
443 endItems.removeFirst();
444 }
445
447 delete m_line;
448
449 if ( startItems.count() > 0 && endItems.count() > 0
450 && startItems.first() != endItems.first() )
451 {
452
453 bool Inheritance = KernelWrapper::GetInstance().GetInheritanceMode();
454 SchemaGraphicObject * startItem = qgraphicsitem_cast<SchemaGraphicObject *> (
455 startItems.first() );
456 SchemaGraphicObject * endItem = qgraphicsitem_cast<SchemaGraphicObject *> (
457 endItems.first() );
458
459 if ( Inheritance )
460 {
461 startItem->GetClass()->add_super_class ( endItem->GetClassName().toStdString() );
463 SchemaGraphicSegmentedArrow * newArrow = new SchemaGraphicSegmentedArrow (
464 startItem, endItem,
465 0,
466 Inheritance,
467 true, "", "" );
468 startItem->AddArrow ( newArrow );
469 endItem->AddArrow ( newArrow );
470 newArrow->setZValue ( -1000.0 );
471 addItem ( newArrow );
472 //newArrow->SetLabelScene(this);
473 newArrow->UpdatePosition();
474 }
475 else
476 {
477 SchemaRelationshipEditor * Editor = new SchemaRelationshipEditor (
478 startItem->GetClass(), endItem->GetClassName() );
479 connect ( Editor, SIGNAL ( MakeGraphConnection ( QString, QString, QString ) ), this,
480 SLOT ( DrawArrow ( QString, QString, QString ) ) );
481 Editor->show();
482 }
483 }
484 }
485
486 m_line = nullptr;
487 QGraphicsScene::mouseReleaseEvent ( mouseEvent );
488}
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 525 of file SchemaGraphicsScene.cpp.

525 {
526 m_addclass_connection = connect (
527 &KernelWrapper::GetInstance(), SIGNAL ( ClassCreated(QString) ),
528 this, SLOT ( add_class_slot(QString) ) );
530}

◆ new_note_slot

void dbse::SchemaGraphicsScene::new_note_slot ( )
privateslot

Definition at line 506 of file SchemaGraphicsScene.cpp.

506 {
507 auto note = new SchemaGraphicNote (
508 QString("#") + QString::number(m_next_note++), QString());
509 note->setPos(m_current_pos);
510 auto editor = new SchemaNoteEditor(note);
511 connect(editor, SIGNAL(note_accepted(SchemaGraphicNote*)), this, SLOT(add_note_slot(SchemaGraphicNote*)));
512 connect(editor, SIGNAL(cancelled(SchemaGraphicNote*)), this, SLOT(cancel_note_slot(SchemaGraphicNote*)));
513 editor->show();
514}
void add_note_slot(SchemaGraphicNote *)
void cancel_note_slot(SchemaGraphicNote *)

◆ remove_note_object()

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

Definition at line 346 of file SchemaGraphicsScene.cpp.

346 {
347 if (note == nullptr) {
348 return;
349 }
350 RemoveItemFromScene (note);
351}

◆ remove_note_slot

void dbse::SchemaGraphicsScene::remove_note_slot ( )
privateslot

Definition at line 494 of file SchemaGraphicsScene.cpp.

494 {
496}
void remove_note_object(SchemaGraphicNote *obj)

◆ RemoveArrowSlot

void dbse::SchemaGraphicsScene::RemoveArrowSlot ( )
privateslot

◆ RemoveClassObject()

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

Definition at line 353 of file SchemaGraphicsScene.cpp.

354{
355 if ( Object == nullptr )
356 {
357 return;
358 }
359
360 Object->RemoveArrows();
361 RemoveItemFromScene ( Object );
362 ItemMap.remove ( Object->GetClassName() );
363}

◆ RemoveClassSlot

void dbse::SchemaGraphicsScene::RemoveClassSlot ( )
privateslot

Definition at line 672 of file SchemaGraphicsScene.cpp.

673{
674 if ( CurrentObject == nullptr )
675 {
676 return;
677 }
678
681 ItemMap.remove ( CurrentObject->GetClassName() );
682}

◆ RemoveItemFromScene()

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

Definition at line 330 of file SchemaGraphicsScene.cpp.

330 {
331 removeItem ( item );
332 modified(true);
333}

◆ sceneModified

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

◆ show_defaults()

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

Definition at line 39 of file SchemaGraphicsScene.hpp.

◆ ToggleDefault

void dbse::SchemaGraphicsScene::ToggleDefault ( )
privateslot

Definition at line 553 of file SchemaGraphicsScene.cpp.

553 {
555 for ( SchemaGraphicObject * item : ItemMap.values() ) {
556 item->update_arrows();
557 }
558 this->update();
559}

◆ ToggleHighlightAbstract

void dbse::SchemaGraphicsScene::ToggleHighlightAbstract ( )
privateslot

Definition at line 548 of file SchemaGraphicsScene.cpp.

548 {
550 this->update();
551}

◆ ToggleHighlightActive

void dbse::SchemaGraphicsScene::ToggleHighlightActive ( )
privateslot

Definition at line 543 of file SchemaGraphicsScene.cpp.

543 {
545 this->update();
546}

◆ ToggleHighlightClass

void dbse::SchemaGraphicsScene::ToggleHighlightClass ( )
privateslot

Definition at line 538 of file SchemaGraphicsScene.cpp.

538 {
540 this->update();
541}
void toggle_highlight_class()
Graphic API.

◆ ToggleIndirectInfos

void dbse::SchemaGraphicsScene::ToggleIndirectInfos ( )
privateslot

Definition at line 561 of file SchemaGraphicsScene.cpp.

561 {
563
564 for ( SchemaGraphicObject * item : ItemMap.values() ) {
565 item->update_arrows();
566 }
567 this->update();
568}

Member Data Documentation

◆ CurrentObject

SchemaGraphicObject* dbse::SchemaGraphicsScene::CurrentObject
private

Definition at line 100 of file SchemaGraphicsScene.hpp.

◆ ItemMap

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

Definition at line 75 of file SchemaGraphicsScene.hpp.

◆ m_add_all_relationship_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_relationship_classes
private

Definition at line 93 of file SchemaGraphicsScene.hpp.

◆ m_add_all_sub_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_sub_classes
private

Definition at line 92 of file SchemaGraphicsScene.hpp.

◆ m_add_all_super_classes

QAction* dbse::SchemaGraphicsScene::m_add_all_super_classes
private

Definition at line 91 of file SchemaGraphicsScene.hpp.

◆ m_add_class

QAction* dbse::SchemaGraphicsScene::m_add_class
private

Definition at line 82 of file SchemaGraphicsScene.hpp.

◆ m_add_direct_relationship_classes

QAction* dbse::SchemaGraphicsScene::m_add_direct_relationship_classes
private

Definition at line 90 of file SchemaGraphicsScene.hpp.

◆ m_add_direct_super_classes

QAction* dbse::SchemaGraphicsScene::m_add_direct_super_classes
private

Definition at line 89 of file SchemaGraphicsScene.hpp.

◆ m_add_note

QAction* dbse::SchemaGraphicsScene::m_add_note
private

Definition at line 94 of file SchemaGraphicsScene.hpp.

◆ m_addclass_connection

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

Definition at line 99 of file SchemaGraphicsScene.hpp.

◆ m_arrow_pos

int dbse::SchemaGraphicsScene::m_arrow_pos
private

Definition at line 80 of file SchemaGraphicsScene.hpp.

◆ m_class_pos

int dbse::SchemaGraphicsScene::m_class_pos
private

Definition at line 79 of file SchemaGraphicsScene.hpp.

◆ m_context_menu

QMenu* dbse::SchemaGraphicsScene::m_context_menu
private

Definition at line 77 of file SchemaGraphicsScene.hpp.

◆ m_current_arrow

SchemaGraphicSegmentedArrow* dbse::SchemaGraphicsScene::m_current_arrow
private

Definition at line 101 of file SchemaGraphicsScene.hpp.

◆ m_current_note

SchemaGraphicNote* dbse::SchemaGraphicsScene::m_current_note
private

Definition at line 102 of file SchemaGraphicsScene.hpp.

◆ m_current_pos

QPointF dbse::SchemaGraphicsScene::m_current_pos
private

Definition at line 103 of file SchemaGraphicsScene.hpp.

◆ m_edit_class

QAction* dbse::SchemaGraphicsScene::m_edit_class
private

Definition at line 83 of file SchemaGraphicsScene.hpp.

◆ m_edit_note

QAction* dbse::SchemaGraphicsScene::m_edit_note
private

Definition at line 95 of file SchemaGraphicsScene.hpp.

◆ m_highlight_abstract

bool dbse::SchemaGraphicsScene::m_highlight_abstract
private

Definition at line 107 of file SchemaGraphicsScene.hpp.

◆ m_highlight_active

bool dbse::SchemaGraphicsScene::m_highlight_active
private

Definition at line 108 of file SchemaGraphicsScene.hpp.

◆ m_inherited_properties_visible

bool dbse::SchemaGraphicsScene::m_inherited_properties_visible
private

Definition at line 106 of file SchemaGraphicsScene.hpp.

◆ m_line

QGraphicsLineItem* dbse::SchemaGraphicsScene::m_line
private

Definition at line 76 of file SchemaGraphicsScene.hpp.

◆ m_modified

bool dbse::SchemaGraphicsScene::m_modified
private

Definition at line 110 of file SchemaGraphicsScene.hpp.

◆ m_mouse_item_pos

QPointF dbse::SchemaGraphicsScene::m_mouse_item_pos
private

Definition at line 104 of file SchemaGraphicsScene.hpp.

◆ m_next_note

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

Definition at line 105 of file SchemaGraphicsScene.hpp.

105{0};

◆ m_note_pos

int dbse::SchemaGraphicsScene::m_note_pos
private

Definition at line 81 of file SchemaGraphicsScene.hpp.

◆ m_remove_arrow

QAction* dbse::SchemaGraphicsScene::m_remove_arrow
private

Definition at line 98 of file SchemaGraphicsScene.hpp.

◆ m_remove_class

QAction* dbse::SchemaGraphicsScene::m_remove_class
private

Definition at line 97 of file SchemaGraphicsScene.hpp.

◆ m_remove_note

QAction* dbse::SchemaGraphicsScene::m_remove_note
private

Definition at line 96 of file SchemaGraphicsScene.hpp.

◆ m_seperator_pos

int dbse::SchemaGraphicsScene::m_seperator_pos
private

Definition at line 78 of file SchemaGraphicsScene.hpp.

◆ m_show_defaults

bool dbse::SchemaGraphicsScene::m_show_defaults
private

Definition at line 109 of file SchemaGraphicsScene.hpp.

◆ m_toggle_default

QAction* dbse::SchemaGraphicsScene::m_toggle_default
private

Definition at line 88 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_abstract

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_abstract
private

Definition at line 85 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_active

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_active
private

Definition at line 86 of file SchemaGraphicsScene.hpp.

◆ m_toggle_highlight_class

QAction* dbse::SchemaGraphicsScene::m_toggle_highlight_class
private

Definition at line 87 of file SchemaGraphicsScene.hpp.

◆ m_toggle_indirect_infos

QAction* dbse::SchemaGraphicsScene::m_toggle_indirect_infos
private

Definition at line 84 of file SchemaGraphicsScene.hpp.


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