DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
GraphicalClass.cpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
3// Fork baseline commit: dbe-02-12-17 (2022-05-12).
4// Renamed since fork: no.
5
10#include "dbe/treenode.hpp"
11
12#include <QGraphicsSceneMouseEvent>
13#include <QPainter>
14#include <QBitmap>
15#include <QGraphicsScene>
16#include <QGraphicsObject>
17#include <QMimeData>
18#include <QComboBox>
19#include <QHBoxLayout>
20#include <QPushButton>
21#include <QMessageBox>
22#include <QApplication>
23#include <QLabel>
24#include <QDrag>
25
26//------------------------------------------------------------------------------------------
27dbe::GraphicalObject::GraphicalObject ( bool Used, QString ObjectName,
28 GraphicalClass GraphInfo, QGraphicsObject * parent )
29 : QGraphicsObject ( parent ),
30 GraphicalInfo ( GraphInfo ),
31 IconItem ( nullptr ),
32 TextItem ( nullptr ),
34 DatabaseUidName ( ObjectName ),
35 IsExpanded ( false ),
36 IsFetched ( false ),
37 expandedX ( 0 ),
38 expandedY ( 0 )
39{
40 setAcceptDrops ( true );
41 setFlag ( ItemIsMovable );
42
43 QPixmap Icon;
44
45 if ( Used )
46 {
47 if ( !GraphInfo.UsedPixmapFile.isEmpty() ) Icon = QPixmap (
48 ":/Images/" + GraphInfo.UsedPixmapFile );
49 else
50 {
51 Icon = QPixmap ( ":/Images/" + GraphInfo.GenericPixmapFile );
52 }
53 }
54 else
55 {
56 Icon = QPixmap ( ":/Images/" + GraphInfo.GenericPixmapFile );
57 }
58
59 QBitmap IconMask = Icon.createHeuristicMask();
60 Icon.setMask ( IconMask );
61
62 IconItem = new QGraphicsPixmapItem ( Icon );
63 TextItem = new QGraphicsTextItem ( ObjectName );
64}
65//------------------------------------------------------------------------------------------
66
67//------------------------------------------------------------------------------------------
73//------------------------------------------------------------------------------------------
74
75//------------------------------------------------------------------------------------------
77{
78 QRectF Boundarie;
79 Boundarie.setHeight (
80 IconItem->boundingRect().height() + TextItem->boundingRect().height() );
81
82 if ( IconItem->boundingRect().width() > TextItem->boundingRect().width() ) Boundarie
83 .setWidth ( IconItem->boundingRect().width() );
84 else
85 {
86 Boundarie.setWidth ( TextItem->boundingRect().width() );
87 }
88
89 return Boundarie;
90}
91//------------------------------------------------------------------------------------------
92
93//------------------------------------------------------------------------------------------
94void dbe::GraphicalObject::paint ( QPainter * painter,
95 const QStyleOptionGraphicsItem * option,
96 QWidget * widget )
97{
98 Q_UNUSED ( option )
99 Q_UNUSED ( widget )
100
101 QFontMetrics Metric ( QFont ( "Helvetica", 10 ) );
102 painter->setFont ( QFont ( "Helvetica", 10 ) );
103 painter->drawPixmap ( IconItem->boundingRect(), IconItem->pixmap(),
104 IconItem->boundingRect() );
105 painter->drawText (
106 IconItem->boundingRect().bottomLeft() + QPointF (
107 0, Metric.boundingRect ( DatabaseUidName ).height() ),
109}
110//------------------------------------------------------------------------------------------
111
112//------------------------------------------------------------------------------------------
113QPainterPath dbe::GraphicalObject::shape() const
114{
115 QPainterPath Path;
116 Path.addRect ( IconItem->boundingRect() );
117 return Path;
118}
119//------------------------------------------------------------------------------------------
120
121//------------------------------------------------------------------------------------------
122void dbe::GraphicalObject::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event )
123{
124 if ( !IsFetched )
125 {
127 }
128
129 if ( !IsExpanded )
130 {
132 }
133 else
134 {
136 }
137
138 update();
139 QGraphicsItem::mouseDoubleClickEvent ( event );
140}
141//------------------------------------------------------------------------------------------
142
143//------------------------------------------------------------------------------------------
144void dbe::GraphicalObject::mousePressEvent ( QGraphicsSceneMouseEvent * event )
145{
146 if ( event->button() == Qt::LeftButton )
147 {
148 StartDrag = event->pos();
149 }
150}
151//------------------------------------------------------------------------------------------
152
153//------------------------------------------------------------------------------------------
154void dbe::GraphicalObject::mouseMoveEvent ( QGraphicsSceneMouseEvent * event )
155{
156 if ( ! ( event->buttons() & Qt::LeftButton ) )
157 {
158 return;
159 }
160
161 if ( ( event->pos() - StartDrag ).manhattanLength() < QApplication::startDragDistance() )
162 {
163 return;
164 }
165
166 QDrag * drag = new QDrag ( event->widget() );
167 QPixmap Icon = IconItem->pixmap();
168
169 QStringList DataList;
170 QMimeData * mimeData = new QMimeData;
171 QByteArray ItemData;
172 QDataStream DataStream ( &ItemData, QIODevice::WriteOnly );
173
174 DataList.append ( QString ( DatabaseUidName ) );
175 DataList.append ( QString ( DatabaseClassName ) );
176 DataStream << DataList;
177 mimeData->setData ( "application/vnd.text.list", ItemData );
178
179 drag->setMimeData ( mimeData );
180 drag->setPixmap ( Icon );
181
182 Qt::DropAction dropAction = drag->exec();
183 Q_UNUSED ( dropAction )
184}
185//------------------------------------------------------------------------------------------
186
187//------------------------------------------------------------------------------------------
188void dbe::GraphicalObject::dropEvent ( QGraphicsSceneDragDropEvent * event )
189{
190 QByteArray encodedData = event->mimeData()->data ( "application/vnd.text.list" );
191 QDataStream stream ( &encodedData, QIODevice::ReadOnly );
192 QList<QStringList> NewItems;
193
194 while ( !stream.atEnd() )
195 {
196 QStringList Text;
197 stream >> Text;
198 NewItems << Text;
199 }
200
201 QStringList ObjectList;
202
203 for ( QStringList & i : NewItems )
204 {
205 ObjectList.append ( i.at ( 0 ) );
206 }
207
208 for ( int i = 0; i < NewItems.size(); ++i )
209 {
210 if ( NewItems.at ( 0 ).at ( 1 ) != NewItems.at ( i ).at ( 1 ) )
211 {
212 return;
213 }
214 }
215
216 QStringList PossibleRelationships;
217 QString ClassName = NewItems.at ( 0 ).at ( 1 );
218
219 dunedaq::conffwk::class_t ClassInfoReceiverObject =
221 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfoReceiverObject
223
224 for ( dunedaq::conffwk::relationship_t & i : RelationshipList )
225 {
226 if ( i.p_type == ClassName.toStdString() ) PossibleRelationships.append (
227 QString::fromStdString ( i.p_name ) );
228
229 dunedaq::conffwk::class_t ClassInfoDroppedObject =
231 false );
232 std::vector<std::string> RelationshipListDropped = ClassInfoDroppedObject.p_subclasses;
233
234 for ( std::string & j : RelationshipListDropped )
235 {
236 if ( j == ClassName.toStdString() ) PossibleRelationships.append (
237 QString::fromStdString ( i.p_name ) );
238 }
239 }
240
241 QString SelectedRelationship;
242
243 if ( PossibleRelationships.size() == 0 )
244 {
245 return;
246 }
247 else if ( PossibleRelationships.size() == 1 ) SelectedRelationship = PossibleRelationships
248 .at ( 0 );
249 else
250 {
251 QDialog * NewDialog = new QDialog();
252 QHBoxLayout * NewLayout = new QHBoxLayout();
253 QPushButton * OkButton = new QPushButton ( "Ok" );
254 QComboBox * NewCombo = new QComboBox();
255 QLabel * NewLabel = new QLabel ( "Choose relationship : " );
256 NewCombo->addItems ( PossibleRelationships );
257 NewLayout->addWidget ( NewLabel );
258 NewLayout->addWidget ( NewCombo );
259 NewLayout->addWidget ( OkButton );
260 NewDialog->setLayout ( NewLayout );
261 NewDialog->adjustSize();
262 connect ( OkButton, SIGNAL ( clicked() ), NewDialog, SLOT ( accept() ),
263 Qt::UniqueConnection );
264
265 int Status = NewDialog->exec();
266
267 if ( Status == QDialog::Accepted )
268 {
269 SelectedRelationship = NewCombo->currentText();
270 }
271 }
272
273 treenode * NodeObject = confaccessor::gethandler()->getnode ( DatabaseClassName,
275
276 if ( NodeObject )
277 {
278 for ( treenode * Child : NodeObject->GetChildren() )
279 {
280 if ( dynamic_cast<RelationshipNode *> ( Child ) )
281 {
282 RelationshipNode * NodeRelationship = dynamic_cast<RelationshipNode *> ( Child );
283 dunedaq::conffwk::relationship_t RelationshipData =
284 NodeRelationship->relation_t();
285
286 if ( RelationshipData.p_name == SelectedRelationship.toStdString() )
287 {
288 if ( ( RelationshipData.p_cardinality == dunedaq::conffwk::zero_or_many ) || ( RelationshipData
291 {
292 std::vector<std::string> RelationshipValues;
293
294 for ( treenode * RelationshipChildren : NodeRelationship->GetChildren() )
295 RelationshipValues.push_back (
296 RelationshipChildren->GetData ( 0 ).toString().toStdString() );
297
298 for ( QStringList & Item : NewItems )
299 if ( std::find ( RelationshipValues.begin(), RelationshipValues.end(),
300 Item.at ( 0 ).toStdString() )
301 == RelationshipValues.end() ) RelationshipValues.push_back (
302 Item.at ( 0 ).toStdString() );
303
304 tref Object = NodeObject->GetObject();
305 dbe::config::api::commands::modobj ( Object, RelationshipData,
306 RelationshipValues );
307 }
308 else
309 {
310 QString SelectedObject;
311
312 if ( NewItems.size() > 1 )
313 {
314 QDialog * NewDialog = new QDialog();
315 QHBoxLayout * NewLayout = new QHBoxLayout();
316 QPushButton * OkButton = new QPushButton ( "Ok" );
317 QComboBox * NewCombo = new QComboBox();
318 QLabel * NewLabel = new QLabel ( "Choose Object : " );
319 NewCombo->addItems ( ObjectList );
320 NewLayout->addWidget ( NewLabel );
321 NewLayout->addWidget ( NewCombo );
322 NewLayout->addWidget ( OkButton );
323 NewDialog->setLayout ( NewLayout );
324 NewDialog->adjustSize();
325 connect ( OkButton, SIGNAL ( clicked() ), NewDialog, SLOT ( accept() ),
326 Qt::UniqueConnection );
327
328 int Status = NewDialog->exec();
329
330 if ( Status == QDialog::Accepted )
331 {
332 SelectedObject = NewCombo->currentText();
333 }
334 }
335 else
336 {
337 SelectedObject = NewItems.at ( 0 ).at ( 0 );
338 }
339
340 tref Object = NodeObject->GetObject();
341 dbe::config::api::commands::modobj ( Object, RelationshipData,
342 { SelectedObject.toStdString() } );
343
344 }
345 }
346 }
347 }
348 }
349}
350//------------------------------------------------------------------------------------------
351
352//------------------------------------------------------------------------------------------
354{
355 double dx = 0;
356 double dy = 0;
357
358 treenode * NodeObject = confaccessor::gethandler()->getnode ( DatabaseClassName,
360
361 if ( NodeObject )
362 {
363 for ( treenode * ChildNode : NodeObject->GetChildren() )
364 {
365 RelationshipNode * NodeRelationship = dynamic_cast<RelationshipNode *> ( ChildNode );
366
367 if ( NodeRelationship && NodeRelationship->GetHasStructure() )
368 {
369 dunedaq::conffwk::relationship_t RelationshipData =
370 NodeRelationship->relation_t();
371 GraphicalRelationship * RelationshipChildNode = new GraphicalRelationship (
372 DatabaseUidName, DatabaseClassName, RelationshipData );
373 RelationshipChildNode->setParentItem ( this );
374 RelationshipChildNode->AddGraphicChildren();
375
376 QPointF coord = RelationshipChildNode->mapFromParent ( boundingRect().bottomRight() );
377 RelationshipChildNode->setX ( coord.x() + dx );
378 RelationshipChildNode->setY ( coord.y() + dy );
379
380 for ( QGraphicsItem * GraphicItem : RelationshipChildNode->childItems() )
381 {
382 dy += GraphicItem->boundingRect().height();
383 }
384 }
385 }
386 }
387
388 IsFetched = true;
389}
390//------------------------------------------------------------------------------------------
391
392//------------------------------------------------------------------------------------------
394{
395 for ( QGraphicsItem * i : this->childItems() )
396 {
397 i->show();
398 }
399
400 double ThisOffsetX = 0;
401 double ThisOffsetY = 0;
402 GetOffsetX ( this, ThisOffsetX );
403 GetOffsetY ( this, ThisOffsetY );
404 QPointF ThisItemBottom = this->mapToScene ( this->boundingRect().bottomRight() );
405
406 if ( !this->childItems().isEmpty() )
407 {
408 ThisOffsetX -= ThisItemBottom.x();
409 ThisOffsetY -= ThisItemBottom.y();
410 }
411
413 QGraphicsItem * AuxiliaryItem = this;
414
415 while ( AuxiliaryItem->parentItem() != nullptr )
416 {
417 for ( int i = AuxiliaryItem->parentItem()->childItems().indexOf ( AuxiliaryItem ) + 1;
418 i < AuxiliaryItem->parentItem()->childItems().size(); ++i )
419 {
420 QGraphicsItem * Child = AuxiliaryItem->parentItem()->childItems().at ( i );
421 Child->setY ( Child->y() + ThisOffsetY );
422 }
423
424 AuxiliaryItem = AuxiliaryItem->parentItem();
425 }
426
429 double ThisTopLevelOffsetX = 0;
430 double ThisTopLevelOffsetY = 0;
431 GetOffsetX ( this->topLevelItem(), ThisTopLevelOffsetX );
432 GetOffsetY ( this->topLevelItem(), ThisTopLevelOffsetY );
433 QPointF ThisTopLevelItemBottom = this->topLevelItem()->mapToScene (
434 this->topLevelItem()->boundingRect().bottomRight() );
435
436 if ( !this->topLevelItem()->childItems().isEmpty() )
437 {
438 ThisTopLevelOffsetX -= ThisTopLevelItemBottom.x();
439 ThisTopLevelOffsetY -= ThisTopLevelItemBottom.y();
440 }
441
443 QList<QGraphicsItem *> TopLevelItems = scene()->items();
445 GraphicalObject * ThisTopLevelItem = dynamic_cast<GraphicalObject *>
446 ( this->topLevelItem() );
447 double LineHighestOffsetY = 0;
448
449 for ( QGraphicsItem * Item : TopLevelItems )
450 {
453 if ( Item->parentItem() == nullptr && ThisTopLevelItem->y() == Item->y()
454 && ThisTopLevelItem != Item )
455 {
456 GraphicalObject * ItemObject = dynamic_cast<GraphicalObject *> ( Item );
457
458 if ( ItemObject && LineHighestOffsetY < ItemObject->GetExpandedY() ) LineHighestOffsetY =
459 ItemObject->GetExpandedY();
460 }
461 }
462
465 for ( QGraphicsItem * Item : TopLevelItems )
466 {
467 if ( ThisTopLevelItem != Item && Item->parentItem() == nullptr )
468 {
469 if ( ThisTopLevelItem->y() < Item->y() && ThisTopLevelOffsetY > LineHighestOffsetY )
470 {
471 if ( LineHighestOffsetY == 0 )
472 {
473 Item->setY ( Item->y() + ThisOffsetY );
474 }
475 else
476 {
477 if ( ThisTopLevelOffsetY - LineHighestOffsetY < ThisTopLevelOffsetY
478 - ThisTopLevelItem->GetExpandedY() ) Item->setY (
479 Item->y() + ThisTopLevelOffsetY - LineHighestOffsetY );
480 else Item->setY (
481 Item->y() + ThisTopLevelOffsetY - ThisTopLevelItem->GetExpandedY() );
482 }
483 }
484 }
485
486 if ( ThisTopLevelItem->y() == Item->y() && ThisTopLevelItem->x() < Item->x()
487 && Item->parentItem() == nullptr )
488 {
489 if ( ThisTopLevelOffsetX > ThisTopLevelItem->GetExpandedX() )
490 {
491 if ( ThisTopLevelItem->GetExpandedX() == 0 )
492 {
493 Item->setX ( Item->x() + ThisOffsetX );
494 }
495 else
496 {
497 Item->setX ( Item->x() + ThisTopLevelOffsetX - ThisTopLevelItem->GetExpandedX() );
498 }
499 }
500 }
501 }
502
503 ThisTopLevelItem->SetExpandedX ( ThisTopLevelOffsetX );
504 ThisTopLevelItem->SetExpandedY ( ThisTopLevelOffsetY );
505 IsExpanded = true;
506}
507//------------------------------------------------------------------------------------------
508
509//------------------------------------------------------------------------------------------
511{
512 double ThisOffsetX = 0;
513 double ThisOffsetY = 0;
514 GetOffsetX ( this, ThisOffsetX );
515 GetOffsetY ( this, ThisOffsetY );
516 QPointF ThisItemBottom = this->mapToScene ( this->boundingRect().bottomRight() );
517
518 if ( !this->childItems().isEmpty() )
519 {
520 ThisOffsetX -= ThisItemBottom.x();
521 ThisOffsetY -= ThisItemBottom.y();
522 }
523
525 QGraphicsItem * AuxiliaryItem = this;
526
527 while ( AuxiliaryItem->parentItem() != nullptr )
528 {
529 for ( int i = AuxiliaryItem->parentItem()->childItems().indexOf ( AuxiliaryItem ) + 1;
530 i < AuxiliaryItem->parentItem()->childItems().size(); ++i )
531 {
532 QGraphicsItem * Child = AuxiliaryItem->parentItem()->childItems().at ( i );
533 Child->setY ( Child->y() - ThisOffsetY );
534 }
535
536 AuxiliaryItem = AuxiliaryItem->parentItem();
537 }
538
543 for ( QGraphicsItem * i : this->childItems() )
544 {
545 i->hide();
546 }
547
548 double ThisTopLevelOffsetX = 0;
549 double ThisTopLevelOffsetY = 0;
550 GetOffsetX ( this->topLevelItem(), ThisTopLevelOffsetX );
551 GetOffsetY ( this->topLevelItem(), ThisTopLevelOffsetY );
552 QPointF ThisTopLevelItemBottom = this->topLevelItem()->mapToScene (
553 this->topLevelItem()->boundingRect().bottomRight() );
554
555 if ( !this->topLevelItem()->childItems().isEmpty()
556 && this->topLevelItem()->childItems().at (
557 0 )->isVisible() )
558 {
559 ThisTopLevelOffsetX -= ThisTopLevelItemBottom.x();
560 ThisTopLevelOffsetY -= ThisTopLevelItemBottom.y();
561 }
562
564 QList<QGraphicsItem *> TopLevelItems = scene()->items();
566 GraphicalObject * ThisTopLevelItem = dynamic_cast<GraphicalObject *>
567 ( this->topLevelItem() );
568 double LineHighestOffsetY = 0;
569
570 for ( QGraphicsItem * Item : TopLevelItems )
571 {
574 if ( Item->parentItem() == nullptr && ThisTopLevelItem->y() == Item->y()
575 && ThisTopLevelItem != Item )
576 {
577 GraphicalObject * ItemObject = dynamic_cast<GraphicalObject *> ( Item );
578
579 if ( ItemObject && LineHighestOffsetY < ItemObject->GetExpandedY() ) LineHighestOffsetY =
580 ItemObject->GetExpandedY();
581 }
582 }
583
586 for ( QGraphicsItem * Item : TopLevelItems )
587 {
588 if ( ThisTopLevelItem != Item && Item->parentItem() == nullptr )
589 {
590 if ( ThisTopLevelItem->y() < Item->y() && ThisTopLevelItem->GetExpandedY()
591 > LineHighestOffsetY )
592 {
593 if ( LineHighestOffsetY == 0 )
594 {
595 Item->setY ( Item->y() - ThisOffsetY );
596 }
597 else
598 {
599 if ( ThisTopLevelOffsetY >= LineHighestOffsetY && ThisTopLevelOffsetY
600 < ThisTopLevelItem->GetExpandedY() ) Item->setY (
601 Item->y() - abs ( ThisTopLevelOffsetY - ThisTopLevelItem->GetExpandedY() ) );
602
603 if ( ThisTopLevelItem->GetExpandedY() > LineHighestOffsetY && ThisTopLevelOffsetY
604 < LineHighestOffsetY ) Item->setY (
605 Item->y() - abs ( ThisTopLevelItem->GetExpandedY() - LineHighestOffsetY ) );
606 }
607 }
608 }
609
610 if ( ThisTopLevelItem->y() == Item->y() && ThisTopLevelItem->x() < Item->x()
611 && Item->parentItem() == nullptr )
612 {
613 if ( ThisTopLevelOffsetX < ThisTopLevelItem->GetExpandedX() )
614 {
615 Item->setX ( Item->x() - abs ( ThisTopLevelOffsetX - ThisTopLevelItem->GetExpandedX() ) );
616 }
617 }
618 }
619
620 ThisTopLevelItem->SetExpandedX ( ThisTopLevelOffsetX );
621 ThisTopLevelItem->SetExpandedY ( ThisTopLevelOffsetY );
622 IsExpanded = false;
623}
624//------------------------------------------------------------------------------------------
625
626//------------------------------------------------------------------------------------------
627void dbe::GraphicalObject::GetOffsetX ( QGraphicsItem * Item, double & Offset )
628{
629 for ( QGraphicsItem * ChildItem : Item->childItems() )
630 {
631 if ( ChildItem->isVisible() )
632 {
633 QPointF ChildItemBottom = ChildItem->mapToScene (
634 ChildItem->boundingRect().bottomRight() );
635
636 if ( Offset < ChildItemBottom.x() )
637 {
638 Offset = ChildItemBottom.x();
639 }
640 }
641
642 GetOffsetX ( ChildItem, Offset );
643 }
644}
645//------------------------------------------------------------------------------------------
646
647//------------------------------------------------------------------------------------------
648void dbe::GraphicalObject::GetOffsetY ( QGraphicsItem * Item, double & Offset )
649{
650 for ( QGraphicsItem * ChildItem : Item->childItems() )
651 {
652 if ( ChildItem->isVisible() )
653 {
654 QPointF ChildItemBottom = ChildItem->mapToScene (
655 ChildItem->boundingRect().bottomRight() );
656
657 if ( Offset < ChildItemBottom.y() )
658 {
659 Offset = ChildItemBottom.y();
660 }
661 }
662
663 GetOffsetY ( ChildItem, Offset );
664 }
665}
666//------------------------------------------------------------------------------------------
667
668//------------------------------------------------------------------------------------------
669void dbe::GraphicalObject::LocateTopMostItem ( QGraphicsItem * Auxiliary )
670{
671 while ( Auxiliary->parentItem() != nullptr )
672 {
673 Auxiliary = Auxiliary->parentItem();
674 }
675}
676//------------------------------------------------------------------------------------------
677
678//------------------------------------------------------------------------------------------
683//------------------------------------------------------------------------------------------
684
685//------------------------------------------------------------------------------------------
687{
688 return DatabaseUidName;
689}
690//------------------------------------------------------------------------------------------
691
692//------------------------------------------------------------------------------------------
694{
695 return expandedX;
696}
697//------------------------------------------------------------------------------------------
698
699//------------------------------------------------------------------------------------------
701{
702 return expandedY;
703}
704//------------------------------------------------------------------------------------------
705
706//------------------------------------------------------------------------------------------
708{
709 expandedX = dx;
710}
711//------------------------------------------------------------------------------------------
712
713//------------------------------------------------------------------------------------------
715{
716 expandedY = dy;
717}
718//------------------------------------------------------------------------------------------
719
720//------------------------------------------------------------------------------------------
721dbe::GraphicalRelationship::GraphicalRelationship ( QString ObjectName, QString ClassName,
723 QGraphicsObject * parent )
724 : QGraphicsObject ( parent ),
725 DatabaseClassName ( ClassName ),
726 DatabaseUidName ( ObjectName ),
727 RelationshipData ( Data ),
728 TextItem ( nullptr )
729{
730 TextItem = new QGraphicsTextItem ( QString ( Data.p_name.c_str() ) );
731}
732//------------------------------------------------------------------------------------------
733
734//------------------------------------------------------------------------------------------
739//------------------------------------------------------------------------------------------
740
741//------------------------------------------------------------------------------------------
743{
744 return TextItem->boundingRect();
745}
746//------------------------------------------------------------------------------------------
747
748//------------------------------------------------------------------------------------------
749void dbe::GraphicalRelationship::paint ( QPainter * painter,
750 const QStyleOptionGraphicsItem * option,
751 QWidget * widget )
752{
753 painter->setFont ( QFont ( "Helvetica", 10 ) );
754 TextItem->paint ( painter, option, widget );
755}
756//------------------------------------------------------------------------------------------
757
758//------------------------------------------------------------------------------------------
760{
761 QPainterPath path;
762 path.addRect ( TextItem->boundingRect() );
763 return path;
764}
765//------------------------------------------------------------------------------------------
766
767//------------------------------------------------------------------------------------------
768void dbe::GraphicalRelationship::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event )
769{
770 Q_UNUSED ( event )
771}
772//------------------------------------------------------------------------------------------
773
774//------------------------------------------------------------------------------------------
775void dbe::GraphicalRelationship::mousePressEvent ( QGraphicsSceneMouseEvent * event )
776{
777 Q_UNUSED ( event )
778}
779//------------------------------------------------------------------------------------------
780
781//------------------------------------------------------------------------------------------
782void dbe::GraphicalRelationship::mouseMoveEvent ( QGraphicsSceneMouseEvent * event )
783{
784 Q_UNUSED ( event )
785}
786//------------------------------------------------------------------------------------------
787
788//------------------------------------------------------------------------------------------
790{
791 double OffsetY = 0;
792 double OffsetX = 10;
793
794 treenode * NodeObject = confaccessor::gethandler()->getnode ( DatabaseClassName,
796
797 if ( NodeObject )
798 {
799 for ( treenode * ChildNode : NodeObject->GetChildren() )
800 {
801 if ( ChildNode->GetData ( 0 ).toString() == QString ( RelationshipData.p_name.c_str() ) )
802 {
803 for ( treenode * ChildChildNode : ChildNode->GetChildren() )
804 {
805 ObjectNode * ChildChildNodeObject = dynamic_cast<ObjectNode *> ( ChildChildNode );
806
807 if ( ChildChildNodeObject )
808 {
809 std::string cname = ChildChildNodeObject->GetObject().class_name();
810 GraphicalClass Dummy = confaccessor::guiconfig()->graphical ( cname );
811 GraphicalObject * ObjectNodeGraphical = new GraphicalObject (
812 true, ChildChildNode->GetData ( 0 ).toString(), Dummy );
813 ObjectNodeGraphical->setParentItem ( this );
814
815 QPointF coord = ObjectNodeGraphical->mapFromParent ( boundingRect().topRight() );
816 ObjectNodeGraphical->setX ( coord.x() + OffsetX );
817 ObjectNodeGraphical->setY ( coord.y() + OffsetY );
818 OffsetY += ObjectNodeGraphical->boundingRect().height();
819 }
820 }
821
822 break;
823 }
824 }
825 }
826}
827//------------------------------------------------------------------------------------------
QGraphicsTextItem * TextItem
void AddGraphicChildren()
Graphics.
void GetOffsetY(QGraphicsItem *Item, double &Offset)
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
double GetExpandedX() const
void GetOffsetX(QGraphicsItem *Item, double &Offset)
Some Api.
GraphicalClass GraphicalInfo
QPainterPath shape() const
double GetExpandedY() const
void mousePressEvent(QGraphicsSceneMouseEvent *event)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void dropEvent(QGraphicsSceneDragDropEvent *event)
GraphicalObject(bool Used, QString ObjectName, GraphicalClass GraphInfo, QGraphicsObject *parent=0)
QString GetDatabaseUidName() const
QRectF boundingRect() const
void LocateTopMostItem(QGraphicsItem *Auxiliary)
void SetExpandedX(double dx)
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Event Handler.
QGraphicsPixmapItem * IconItem
void SetExpandedY(double dy)
QString GetDatabaseClassName() const
dunedaq::conffwk::relationship_t RelationshipData
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
QGraphicsTextItem * TextItem
QPainterPath shape() const
void mousePressEvent(QGraphicsSceneMouseEvent *event)
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
GraphicalRelationship(QString ObjectName, QString ClassName, dunedaq::conffwk::relationship_t &Data, QGraphicsObject *parent=0)
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Event Handler.
tref GetObject() const
Definition treenode.cpp:279
dunedaq::conffwk::relationship_t relation_t() const
Definition treenode.cpp:411
static cptr< datahandler > gethandler()
static cptr< ui::config::info > guiconfig()
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
bool GetHasStructure() const
Definition treenode.cpp:136
virtual tref GetObject() const
Definition treenode.cpp:81
QList< treenode * > GetChildren() const
Definition treenode.cpp:111
void modobj(tref Object, dunedaq::conffwk::attribute_t const &AttributeData, T Value)
inner::configobject::tref tref
Definition tref.hpp:35
const std::vector< relationship_t > p_relationships
Definition Schema.hpp:171
const std::vector< std::string > p_subclasses
Definition Schema.hpp:169