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

45{
46}

Member Function Documentation

◆ add_class_slot

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

Updating item list

Definition at line 589 of file SchemaGraphicsScene.cpp.

589 {
590 disconnect(m_addclass_connection);
591
592 auto object = new SchemaGraphicObject(class_name, this);
593 object->setPos(m_current_pos);
594 addItem (object);
596 ItemMap.insert(class_name, object);
597}
QMetaObject::Connection m_addclass_connection
QMap< QString, SchemaGraphicObject * > ItemMap

◆ add_note_slot

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

Definition at line 569 of file SchemaGraphicsScene.cpp.

569 {
570 m_notes.insert(note);
571 addItem(note);
572 modified(true);
573}
std::set< SchemaGraphicNote * > m_notes

◆ add_notes()

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

Definition at line 375 of file SchemaGraphicsScene.cpp.

376 {
377 for ( int index = 0; index<notes.size(); index++) {
378 auto note = new SchemaGraphicNote (
379 QString("#" + QString::number(m_next_note++)),
380 notes.at(index) );
381 note->setPos ( positions.at ( index ) );
382 m_notes.insert(note);
383 addItem(note);
384 }
385
386}

◆ AddAllRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddAllRelationshipClassesSlot ( )
privateslot

Definition at line 725 of file SchemaGraphicsScene.cpp.

725 {
726
727 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
728 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
729
730 QStringList relationship_classes;
731 QList<QPointF> positions;
732
733 const std::list<OksRelationship *> * all_relationship_list = class_info->all_relationships();
734 if ( all_relationship_list != nullptr ) {
735 for(const OksRelationship* rl : *all_relationship_list) {
736 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
737 positions.push_back({0,0});
738 }
739
740 }
741
742 this->AddItemsToScene ( relationship_classes, positions );
743}
static KernelWrapper & GetInstance()
dunedaq::oks::OksClass * FindClass(std::string ClassName) const
QStringList AddItemsToScene(QStringList SchemaClasses, QList< QPointF > Positions)
const std::list< OksRelationship * > * all_relationships() const noexcept
Definition class.hpp:590

◆ AddAllSubClassesSlot

void dbse::SchemaGraphicsScene::AddAllSubClassesSlot ( )
privateslot

Definition at line 684 of file SchemaGraphicsScene.cpp.

684 {
685
686 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
687 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
688
689 QStringList sub_class_list;
690 QList<QPointF> positions;
691
692 const OksClass::FList* all_classes = class_info->all_sub_classes();
693 if(all_classes != nullptr) {
694 for(const OksClass* cl : *all_classes) {
695 sub_class_list.push_back(QString::fromStdString(cl->get_name()));
696 positions.push_back({0,0});
697 }
698 }
699
700 this->AddItemsToScene ( sub_class_list, positions );
701
702}
const FList * all_sub_classes() const noexcept
Definition class.hpp:471
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:240

◆ AddAllSuperClassesSlot

void dbse::SchemaGraphicsScene::AddAllSuperClassesSlot ( )
privateslot

Definition at line 663 of file SchemaGraphicsScene.cpp.

663 {
664
665 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
666 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
667
668 QStringList super_class_list;
669 QList<QPointF> positions;
670
671 const OksClass::FList* all_classes = class_info->all_super_classes();
672 if(all_classes != nullptr) {
673 for(const OksClass* cl : *all_classes) {
674 super_class_list.push_back(QString::fromStdString(cl->get_name()));
675 positions.push_back({0,0});
676 }
677 }
678
679
680 this->AddItemsToScene ( super_class_list, positions );
681
682}
const FList * all_super_classes() const noexcept
Definition class.hpp:413

◆ AddDirectRelationshipClassesSlot

void dbse::SchemaGraphicsScene::AddDirectRelationshipClassesSlot ( )
privateslot

Definition at line 704 of file SchemaGraphicsScene.cpp.

704 {
705
706 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
707 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
708
709 QStringList relationship_classes;
710 QList<QPointF> positions;
711
712 const std::list<OksRelationship *> * direct_relationship_list = class_info->direct_relationships();
713 if ( direct_relationship_list != nullptr ) {
714 for(const OksRelationship* rl : *direct_relationship_list) {
715 relationship_classes.push_back(QString::fromStdString(rl->get_type()));
716 positions.push_back({0,0});
717 }
718
719 }
720
721 this->AddItemsToScene ( relationship_classes, positions );
722
723}
const std::list< OksRelationship * > * direct_relationships() const noexcept
Definition class.hpp:595

◆ AddDirectSuperClassesSlot

void dbse::SchemaGraphicsScene::AddDirectSuperClassesSlot ( )
privateslot

Definition at line 643 of file SchemaGraphicsScene.cpp.

643 {
644
645 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
646 OksClass * class_info = KernelWrapper::GetInstance().FindClass ( class_name.toStdString() );
647
648 QStringList super_class_list;
649 QList<QPointF> positions;
650
651 const std::list<std::string *>* direct_classes = class_info->direct_super_classes();
652 if(direct_classes != nullptr) {
653 for(std::string * cl_name : *direct_classes) {
654 super_class_list.push_back(QString::fromStdString(*cl_name));
655 positions.push_back({0,0});
656 }
657 }
658
659 this->AddItemsToScene ( super_class_list, positions );
660
661}
const std::list< std::string * > * direct_super_classes() const noexcept
Definition class.hpp:418

◆ AddItemsToScene()

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

Updating item list

Plotting the superclasses

Definition at line 274 of file SchemaGraphicsScene.cpp.

277{
278 QStringList missingItems{};
279
280 for ( QString & ClassName : SchemaClasses )
281 {
282 if ( !ItemMap.contains ( ClassName ) )
283 {
284
285 if ( !KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() ) ) {
286 std::cout << "ERROR: class " << ClassName.toStdString() << " not found" << std::endl;
287 missingItems.append(ClassName);
288 continue;
289 }
290
291 SchemaGraphicObject * Object = new SchemaGraphicObject ( ClassName, this );
292 Object->setPos ( Positions.at ( SchemaClasses.indexOf ( ClassName ) ) );
293 addItem ( Object );
295 ItemMap.insert ( ClassName, Object );
296 }
297 }
298
299 for ( QString & ClassName : ItemMap.keys() )
300 {
301 OksClass * ClassInfo = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
302
303 const std::list<OksRelationship *> * DirectRelationshipList =
304 ClassInfo->direct_relationships();
305 const std::list<std::string *> * DirectSuperClassesList = ClassInfo->direct_super_classes();
306
307 std::map<std::string, unsigned int> arrow_count;
308
310 if ( DirectRelationshipList != nullptr )
311 {
312 for ( OksRelationship * ClassRelationship : * ( DirectRelationshipList ) )
313 {
314 auto rct = ClassRelationship->get_class_type()->get_name();
315 QString RelationshipClassType = QString::fromStdString (rct);
316
317 if ( ItemMap.contains ( RelationshipClassType ) ) //&& !ItemMap[ClassName]->HasArrow (
318 //ItemMap[RelationshipClassType] ) )
319 {
320 QString SchemaCardinality =
322 SchemaGraphicSegmentedArrow * NewArrow = new SchemaGraphicSegmentedArrow (
323 ItemMap[ClassName], ItemMap[RelationshipClassType],
324 arrow_count[rct],
325 false,
326 ClassRelationship->get_is_composite(),
327 QString::fromStdString ( ClassRelationship->get_name() ), SchemaCardinality );
328 ItemMap[ClassName]->AddArrow ( NewArrow );
329 ItemMap[RelationshipClassType]->AddArrow ( NewArrow );
330 addItem ( NewArrow );
331 //NewArrow->SetLabelScene(this);
332 NewArrow->setZValue ( -1000.0 );
333 NewArrow->UpdatePosition();
334 arrow_count[rct]++;
335 }
336 }
337 }
338
340 if ( DirectSuperClassesList != nullptr )
341 {
342 for ( std::string * SuperClassNameStd : * ( DirectSuperClassesList ) )
343 {
344 QString SuperClassName = QString::fromStdString ( *SuperClassNameStd );
345
346 if ( ItemMap.contains ( SuperClassName ) ) // && !ItemMap[ClassName]->HasArrow (
347 // ItemMap[SuperClassName] ) )
348 {
349 SchemaGraphicSegmentedArrow * NewArrow = new SchemaGraphicSegmentedArrow (
350 ItemMap[ClassName],
351 ItemMap[SuperClassName],
352 arrow_count[*SuperClassNameStd],
353 true,
354 false, "", "" );
355 ItemMap[ClassName]->AddArrow ( NewArrow );
356 ItemMap[SuperClassName]->AddArrow ( NewArrow );
357 addItem ( NewArrow );
358 //NewArrow->SetLabelScene(this);
359 NewArrow->setZValue ( -1000.0 );
360 NewArrow->UpdatePosition();
361 arrow_count[*SuperClassNameStd]++;
362 }
363 }
364 }
365 }
366 modified(true);
367 return missingItems;
368}
QString GetCardinalityStringRelationship(dunedaq::oks::OksRelationship *SchemaRelationship) const

◆ cancel_note_slot

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

Definition at line 574 of file SchemaGraphicsScene.cpp.

574 {
575 m_notes.erase(note);
576 delete note;
577}

◆ CleanItemMap()

void dbse::SchemaGraphicsScene::CleanItemMap ( )

Definition at line 406 of file SchemaGraphicsScene.cpp.

407{
408 ItemMap.clear();
409}

◆ ClearModified()

void dbse::SchemaGraphicsScene::ClearModified ( )

Definition at line 448 of file SchemaGraphicsScene.cpp.

448 {
449 modified(false);
450}

◆ contextMenuEvent()

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

Definition at line 173 of file SchemaGraphicsScene.cpp.

174{
175 if ( m_context_menu == nullptr ) {
176 m_context_menu = new QMenu();
177 m_context_menu->addAction ( m_add_class );
178 m_context_menu->addAction ( m_add_note );
182 m_context_menu->addAction ( m_toggle_default );
183
184 m_seperator_pos = m_context_menu->actions().size();
185 m_context_menu->addSeparator();
186
187 m_class_pos = m_context_menu->actions().size();
188 m_context_menu->addAction ( m_edit_class );
189 m_context_menu->addAction ( m_remove_class );
191 m_context_menu->addSeparator();
192
199
200 m_arrow_pos = m_context_menu->actions().size();
201 m_context_menu->addAction ( m_remove_arrow );
202
203 m_note_pos = m_context_menu->actions().size();
204 m_context_menu->addAction ( m_edit_note );
205 m_context_menu->addAction ( m_remove_note );
206
207 m_context_menu->addSeparator();
208 m_save_pos = m_context_menu->actions().size();
209 m_context_menu->addAction(m_save);
210 m_context_menu->addAction(m_move);
211 }
212
213 bool active = KernelWrapper::GetInstance().IsActive ( );
214 m_context_menu->actions().at ( 0 )->setVisible ( active );
215
216 for (int item=1; item<m_seperator_pos; item++) {
217 m_context_menu->actions().at ( item )->setVisible ( true );
218 }
219
220 // Set all other items invisible
221 const auto nitems = m_context_menu->actions().size();
222 for (int item=m_seperator_pos; item<nitems; item++) {
223 m_context_menu->actions().at ( item )->setVisible ( false );
224 }
225
226 if (ItemMap.size()>0) {
227 m_context_menu->actions().at(m_save_pos-1)->setVisible(true);
228 m_context_menu->actions().at(m_save_pos+1)->setVisible(true);
229 }
230 if (m_modified && ItemMap.size()>0) {
231 m_context_menu->actions().at(m_save_pos)->setVisible(true);
232 }
233
234 if ( itemAt ( event->scenePos(), QTransform() ) ) {
235 // Something under mouse pointer, set additional items visible
236 // depending on what it is
237 m_context_menu->actions().at ( m_seperator_pos )->setVisible ( true );
238
239 auto object = dynamic_cast<SchemaGraphicObject *> (
240 itemAt ( event->scenePos(), QTransform() ) );
241 auto arrow = dynamic_cast<SchemaGraphicSegmentedArrow *> (
242 itemAt ( event->scenePos(), QTransform() ) );
243 auto note = dynamic_cast<SchemaGraphicNote *> (
244 itemAt ( event->scenePos(), QTransform() ) );
245
246 if ( object != nullptr) {
248 m_toggle_highlight_class->setChecked(CurrentObject->highlighted());
249
250 auto filename =
251 CurrentObject->GetClass()->get_file()->get_full_file_name();
253 m_context_menu->actions().at ( m_class_pos )->setVisible ( writable );
254
255 for (int item=m_class_pos+1; item<m_arrow_pos; item++) {
256 m_context_menu->actions().at ( item )->setVisible ( true );
257 }
258 }
259 else if ( arrow != nullptr ) {
260 m_context_menu->actions().at ( m_arrow_pos )->setVisible ( true );
261 m_current_arrow = arrow;
262 }
263 else if ( note != nullptr) {
264 for (int item=m_note_pos; item<nitems; item++) {
265 m_context_menu->actions().at ( item )->setVisible ( true );
266 }
267 m_current_note = note;
268 }
269 }
270 m_current_pos = event->scenePos();
271 m_context_menu->exec ( event->screenPos() );
272}
bool IsFileWritable(const std::string &FileName) const
std::vector< T > object(tref const &)

◆ CreateActions()

void dbse::SchemaGraphicsScene::CreateActions ( )

Definition at line 48 of file SchemaGraphicsScene.cpp.

49{
50 // Add new class
51 m_add_class = new QAction ( "&Add new class", this );
52 connect ( m_add_class, SIGNAL ( triggered() ), this, SLOT ( new_class_slot() ) );
53
54 // Edit current class
55 m_edit_class = new QAction ( "&Edit class", this );
56 connect ( m_edit_class, SIGNAL ( triggered() ), this, SLOT ( EditClassSlot() ) );
57
58 // Toggle inherited properties of all classes in view
59 m_toggle_indirect_infos = new QAction ( "Show &inherited properties", this );
60 m_toggle_indirect_infos->setCheckable(true);
62 connect ( m_toggle_indirect_infos, SIGNAL ( triggered() ), this, SLOT ( ToggleIndirectInfos() ) );
63
64 // Toggle highlighting of all classes in active schema
65 m_toggle_highlight_active = new QAction ( "&Highlight classes in active schema", this );
66 m_toggle_highlight_active->setCheckable(true);
68 connect ( m_toggle_highlight_active, SIGNAL ( triggered() ), this, SLOT ( ToggleHighlightActive() ) );
69
70 // Toggle highlighting of all abstract classes in view
71 m_toggle_highlight_abstract = new QAction ( "&Highlight abstract classes in view", this );
72 m_toggle_highlight_abstract->setCheckable(true);
74 connect ( m_toggle_highlight_abstract, SIGNAL ( triggered() ), this, SLOT ( ToggleHighlightAbstract() ) );
75
76 // Toggle displaying default values of attributes
77 m_toggle_default = new QAction ( "Show &default values of attributes", this );
78 m_toggle_default->setCheckable(true);
80 connect ( m_toggle_default, SIGNAL ( triggered() ), this, SLOT ( ToggleDefault() ) );
81
82 // Toggle highlighting of current class
83 m_toggle_highlight_class = new QAction ( "&Highlight this class", this );
84 m_toggle_highlight_class->setCheckable(true);
85 connect ( m_toggle_highlight_class, SIGNAL ( triggered() ), this, SLOT ( ToggleHighlightClass() ) );
86
87 m_add_note = new QAction ( "&Add note to view", this );
88 connect ( m_add_note, SIGNAL ( triggered() ), this, SLOT ( new_note_slot() ) );
89
90 m_edit_note = new QAction ( "&Edit note", this );
91 connect ( m_edit_note, SIGNAL ( triggered() ), this, SLOT ( edit_note_slot() ) );
92
93 m_remove_note = new QAction ( "&Remove note", this );
94 connect ( m_remove_note, SIGNAL ( triggered() ), this, SLOT ( remove_note_slot() ) );
95
96 // Show superclasses of the current class
97 m_add_direct_super_classes = new QAction ( "Add direct &superclasses to view", this );
98 connect ( m_add_direct_super_classes, SIGNAL ( triggered() ), this, SLOT ( AddDirectSuperClassesSlot() ) );
99
100 // Show relationship classes of the current clas
101 m_add_direct_relationship_classes = new QAction ( "Add direct &relationship classes to view", this );
102 connect ( m_add_direct_relationship_classes, SIGNAL ( triggered() ), this, SLOT ( AddDirectRelationshipClassesSlot() ) );
103
104 // Show superclasses of the current class
105 m_add_all_super_classes = new QAction ( "Add all &superclasses to view", this );
106 connect ( m_add_all_super_classes, SIGNAL ( triggered() ), this, SLOT ( AddAllSuperClassesSlot() ) );
107
108 // Show subclasses of the current clas
109 m_add_all_sub_classes = new QAction ( "Add all s&ubclasses to view", this );
110 connect ( m_add_all_sub_classes, SIGNAL ( triggered() ), this, SLOT ( AddAllSubClassesSlot() ) );
111
112 // Show indirect relationship classes of the current class
113 m_add_all_relationship_classes = new QAction ( "Add all &relationship classes to view", this );
114 connect ( m_add_all_relationship_classes, SIGNAL ( triggered() ), this, SLOT ( AddAllRelationshipClassesSlot() ) );
115
116 // Remove class
117 m_remove_class = new QAction ( "&Remove Class from view", this );
118 connect ( m_remove_class, SIGNAL ( triggered() ), this, SLOT ( RemoveClassSlot() ) );
119
120 // Remove arrow
121 m_remove_arrow = new QAction ( "&Remove Arrow", this );
122 connect ( m_remove_arrow, SIGNAL ( triggered() ), this, SLOT ( RemoveArrowSlot() ) );
123
124 m_save = new QAction("&Save view", this);
125 connect(m_save, SIGNAL(triggered()), this, SLOT(requestSave()));
126
127 m_move = new QAction("&Move scene", this);
128 connect(m_move, SIGNAL(triggered()), this, SLOT(moveScene()));
129}

◆ 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 {
135 event->accept();
136 }
137}

◆ 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 {
143 event->accept();
144 }
145}

◆ DrawArrow

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

Definition at line 765 of file SchemaGraphicsScene.cpp.

767{
768 if ( !ItemMap.contains ( ClassName ) || !ItemMap.contains ( RelationshipType ) )
769 {
770 return;
771 }
772
773 SchemaGraphicObject * startItem = ItemMap[ClassName];
774 SchemaGraphicObject * endItem = ItemMap[RelationshipType];
775
776 OksClass * SchemaClass = KernelWrapper::GetInstance().FindClass ( ClassName.toStdString() );
777 OksRelationship * SchemaRelationship = SchemaClass->find_direct_relationship (
778 RelationshipName.toStdString() );
779
780 if ( SchemaRelationship != nullptr )
781 {
782 QString RelationshipCardinality =
784 SchemaGraphicSegmentedArrow * newArrow = new SchemaGraphicSegmentedArrow (
785 startItem, endItem,
786 0,
787 false, SchemaRelationship->get_is_composite(),
788 QString::fromStdString ( SchemaRelationship->get_name() ), RelationshipCardinality );
789 startItem->AddArrow ( newArrow );
790 endItem->AddArrow ( newArrow );
791 newArrow->setZValue ( -1000.0 );
792 addItem ( newArrow );
793 //newArrow->SetLabelScene(this);
794 newArrow->UpdatePosition();
795 }
796}
OksRelationship * find_direct_relationship(const std::string &name) const noexcept
Find direct relationship.
Definition class.cpp:1178
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 {
159 QString class_name;
160 stream >> class_name;
161 schema_classes.append ( class_name );
162 }
163
164 QList<QPointF> positions;
165 for ( int i = 0; i < schema_classes.size(); ++i )
166 {
167 positions.push_back ( event->scenePos() );
168 }
169
170 AddItemsToScene ( schema_classes, positions );
171}

◆ edit_note_slot

void dbse::SchemaGraphicsScene::edit_note_slot ( )
privateslot

Definition at line 561 of file SchemaGraphicsScene.cpp.

561 {
562 m_current_note->open_editor();
563}

◆ EditClassSlot

void dbse::SchemaGraphicsScene::EditClassSlot ( )
privateslot

Definition at line 605 of file SchemaGraphicsScene.cpp.

606{
607 QString class_name = QString::fromStdString ( CurrentObject->GetClass()->get_name() );
608 SchemaClassEditor::launch(class_name);
609}
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 452 of file SchemaGraphicsScene.cpp.

452 {
453 m_modified = state;
454 emit sceneModified(state);
455}

◆ modified_slot

void dbse::SchemaGraphicsScene::modified_slot ( )
privateslot

Definition at line 487 of file SchemaGraphicsScene.cpp.

487 {
488 modified(true);
489}

◆ mouseMoveEvent()

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

Definition at line 435 of file SchemaGraphicsScene.cpp.

436{
437 if ( m_line != nullptr )
438 {
439 QLineF newLine ( m_line->line().p1(), mouseEvent->scenePos() );
440 m_line->setLine ( newLine );
441 }
442 else
443 {
444 QGraphicsScene::mouseMoveEvent ( mouseEvent );
445 }
446}

◆ mousePressEvent()

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

Definition at line 411 of file SchemaGraphicsScene.cpp.

412{
413 if ( itemAt ( mouseEvent->scenePos(), QTransform() ) ) {
414 // Save position of item under mouse so we can see if it has been
415 // moved in mouseReleaseEvent
416 m_mouse_item_pos = itemAt(mouseEvent->scenePos(), QTransform())->pos();
417 }
418 if ( mouseEvent->button() != Qt::LeftButton )
419 {
420 return;
421 }
422
423 if ( mouseEvent->widget()->cursor().shape() == Qt::CrossCursor )
424 {
425 m_line = new QGraphicsLineItem ( QLineF ( mouseEvent->scenePos(), mouseEvent->scenePos() ) );
426 m_line->setPen ( QPen ( Qt::black, 2 ) );
427 addItem ( m_line );
428 modified(true);
429 return;
430 }
431
432 QGraphicsScene::mousePressEvent ( mouseEvent );
433}

◆ mouseReleaseEvent()

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

Create arrow

Definition at line 490 of file SchemaGraphicsScene.cpp.

491{
492 if ( itemAt ( mouseEvent->scenePos(), QTransform() ) ) {
493 auto item = itemAt(mouseEvent->scenePos(), QTransform() );
494 if (!m_mouse_item_pos.isNull()) {
495 if (m_mouse_item_pos != item->pos()) {
496 modified(true);
497 }
498 m_mouse_item_pos = QPointF();
499 }
500 }
501 if ( m_line != nullptr )
502 {
503 QList<QGraphicsItem *> startItems = items ( m_line->line().p1() );
504
505 if ( startItems.count() && startItems.first() == m_line )
506 {
507 startItems.removeFirst();
508 }
509
510 QList<QGraphicsItem *> endItems = items ( m_line->line().p2() );
511
512 if ( endItems.count() && endItems.first() == m_line )
513 {
514 endItems.removeFirst();
515 }
516
518 delete m_line;
519
520 if ( startItems.count() > 0 && endItems.count() > 0
521 && startItems.first() != endItems.first() )
522 {
523
524 bool Inheritance = KernelWrapper::GetInstance().GetInheritanceMode();
525 SchemaGraphicObject * startItem = qgraphicsitem_cast<SchemaGraphicObject *> (
526 startItems.first() );
527 SchemaGraphicObject * endItem = qgraphicsitem_cast<SchemaGraphicObject *> (
528 endItems.first() );
529
530 if ( Inheritance )
531 {
532 startItem->GetClass()->add_super_class ( endItem->GetClassName().toStdString() );
534 SchemaGraphicSegmentedArrow * newArrow = new SchemaGraphicSegmentedArrow (
535 startItem, endItem,
536 0,
537 Inheritance,
538 true, "", "" );
539 startItem->AddArrow ( newArrow );
540 endItem->AddArrow ( newArrow );
541 newArrow->setZValue ( -1000.0 );
542 addItem ( newArrow );
543 //newArrow->SetLabelScene(this);
544 newArrow->UpdatePosition();
545 }
546 else
547 {
548 SchemaRelationshipEditor * Editor = new SchemaRelationshipEditor (
549 startItem->GetClass(), endItem->GetClassName() );
550 connect ( Editor, SIGNAL ( MakeGraphConnection ( QString, QString, QString ) ), this,
551 SLOT ( DrawArrow ( QString, QString, QString ) ) );
552 Editor->show();
553 }
554 }
555 }
556
557 m_line = nullptr;
558 QGraphicsScene::mouseReleaseEvent ( mouseEvent );
559}
void DrawArrow(QString ClassName, QString RelationshipType, QString RelationshipName)
void RemoveItemFromScene(QGraphicsItem *item)

◆ moveScene

void dbse::SchemaGraphicsScene::moveScene ( )
privateslot

Definition at line 457 of file SchemaGraphicsScene.cpp.

457 {
458 qreal minx = 1e6;
459 qreal miny = 1e6;
460 for (auto obj : ItemMap) {
461 auto pos = obj->pos();
462 if (pos.x() < minx) {
463 minx = pos.x();
464 }
465 if (pos.y() < miny) {
466 miny = pos.y();
467 }
468 }
469 qreal xoffset = m_current_pos.x() - minx;
470 qreal yoffset = m_current_pos.y() - miny;
471 for (auto obj : ItemMap) {
472 obj->setX(obj->x()+xoffset);
473 obj->setY(obj->y()+yoffset);
474 obj->update_arrows();
475 }
476 for (auto obj : m_notes) {
477 obj->setX(obj->x()+xoffset);
478 obj->setY(obj->y()+yoffset);
479 }
480 update();
481 modified(true);
482}

◆ new_class_slot

void dbse::SchemaGraphicsScene::new_class_slot ( )
privateslot

Definition at line 598 of file SchemaGraphicsScene.cpp.

598 {
599 m_addclass_connection = connect (
600 &KernelWrapper::GetInstance(), SIGNAL ( ClassCreated(QString) ),
601 this, SLOT ( add_class_slot(QString) ) );
603}

◆ new_note_slot

void dbse::SchemaGraphicsScene::new_note_slot ( )
privateslot

Definition at line 579 of file SchemaGraphicsScene.cpp.

579 {
580 auto note = new SchemaGraphicNote (
581 QString("#") + QString::number(m_next_note++), QString());
582 note->setPos(m_current_pos);
583 auto editor = new SchemaNoteEditor(note);
584 connect(editor, SIGNAL(note_accepted(SchemaGraphicNote*)), this, SLOT(add_note_slot(SchemaGraphicNote*)));
585 connect(editor, SIGNAL(cancelled(SchemaGraphicNote*)), this, SLOT(cancel_note_slot(SchemaGraphicNote*)));
586 editor->show();
587}
void add_note_slot(SchemaGraphicNote *)
void cancel_note_slot(SchemaGraphicNote *)

◆ remove_note_object()

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

Definition at line 387 of file SchemaGraphicsScene.cpp.

387 {
388 if (note == nullptr) {
389 return;
390 }
391 RemoveItemFromScene (note);
392}

◆ remove_note_slot

void dbse::SchemaGraphicsScene::remove_note_slot ( )
privateslot

Definition at line 565 of file SchemaGraphicsScene.cpp.

565 {
567}
void remove_note_object(SchemaGraphicNote *obj)

◆ RemoveArrowSlot

void dbse::SchemaGraphicsScene::RemoveArrowSlot ( )
privateslot

Definition at line 757 of file SchemaGraphicsScene.cpp.

758{
760 m_current_arrow->GetStartItem()->RemoveArrow ( m_current_arrow );
761 m_current_arrow->GetEndItem()->RemoveArrow ( m_current_arrow );
762 m_current_arrow->RemoveArrow();
763}

◆ RemoveClassObject()

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

Definition at line 394 of file SchemaGraphicsScene.cpp.

395{
396 if ( Object == nullptr )
397 {
398 return;
399 }
400
401 Object->RemoveArrows();
402 RemoveItemFromScene ( Object );
403 ItemMap.remove ( Object->GetClassName() );
404}

◆ RemoveClassSlot

void dbse::SchemaGraphicsScene::RemoveClassSlot ( )
privateslot

Definition at line 745 of file SchemaGraphicsScene.cpp.

746{
747 if ( CurrentObject == nullptr )
748 {
749 return;
750 }
751
752 CurrentObject->RemoveArrows();
754 ItemMap.remove ( CurrentObject->GetClassName() );
755}

◆ RemoveItemFromScene()

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

Definition at line 370 of file SchemaGraphicsScene.cpp.

370 {
371 removeItem ( item );
372 modified(true);
373}

◆ requestSave

void dbse::SchemaGraphicsScene::requestSave ( )
privateslot

Definition at line 484 of file SchemaGraphicsScene.cpp.

484 {
485 emit saveRequested();
486}

◆ 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 39 of file SchemaGraphicsScene.hpp.

39{return m_show_defaults;};

◆ ToggleDefault

void dbse::SchemaGraphicsScene::ToggleDefault ( )
privateslot

Definition at line 626 of file SchemaGraphicsScene.cpp.

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

◆ ToggleHighlightAbstract

void dbse::SchemaGraphicsScene::ToggleHighlightAbstract ( )
privateslot

Definition at line 621 of file SchemaGraphicsScene.cpp.

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

◆ ToggleHighlightActive

void dbse::SchemaGraphicsScene::ToggleHighlightActive ( )
privateslot

Definition at line 616 of file SchemaGraphicsScene.cpp.

616 {
618 this->update();
619}

◆ ToggleHighlightClass

void dbse::SchemaGraphicsScene::ToggleHighlightClass ( )
privateslot

Definition at line 611 of file SchemaGraphicsScene.cpp.

611 {
612 CurrentObject->toggle_highlight_class();
613 this->update();
614}

◆ ToggleIndirectInfos

void dbse::SchemaGraphicsScene::ToggleIndirectInfos ( )
privateslot

Definition at line 634 of file SchemaGraphicsScene.cpp.

634 {
636
637 for ( SchemaGraphicObject * item : ItemMap.values() ) {
638 item->update_arrows();
639 }
640 this->update();
641}

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.

112{0};

◆ 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: