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

#include <GraphView.hpp>

Inheritance diagram for dbe::GraphView:
[legend]
Collaboration diagram for dbe::GraphView:
[legend]

Public Member Functions

 ~GraphView ()
 
 GraphView (QWidget *parent=nullptr)
 
void ConnectActions ()
 
void SetupView ()
 
void contextMenuEvent (QContextMenuEvent *Event)
 

Private Slots

void GetWindowConfiguration ()
 
void RedrawObject (tref Object)
 
void RedrawObject ()
 
void CreateActions ()
 
void editThisObject ()
 
void deleteThisObject ()
 
void copyObject ()
 
void referencedBy_All ()
 
void referencedBy_OnlyComposite ()
 

Private Attributes

Window WindowConfiguration
 
QMenu * ContextMenu
 
QAction * editObject
 
QAction * deleteObjectAc
 
QAction * refByAc
 
QAction * refByAcOnlyComp
 
QAction * copyObjectAc
 
GraphicalObjectClickedItem
 
QUuid const uuid
 

Detailed Description

Definition at line 22 of file GraphView.hpp.

Constructor & Destructor Documentation

◆ ~GraphView()

dbe::GraphView::~GraphView ( )
default

◆ GraphView()

dbe::GraphView::GraphView ( QWidget * parent = nullptr)
explicit

Connecting Actions

Initial Settings

Scene setting

Definition at line 19 of file GraphView.cpp.

20 : QWidget ( parent ),
21 ContextMenu ( nullptr ),
22 ClickedItem ( nullptr ),
23 uuid ( QUuid::createUuid() )
24{
25 setupUi ( this );
29 setWindowTitle ( "Graphical View" );
31 QGraphicsScene * scene = new QGraphicsScene ( this );
32 scene->setItemIndexMethod ( QGraphicsScene::NoIndex );
33 scene->setSceneRect ( 0, 0, 10000, 10000 );
34 GraphicalView->setScene ( scene );
35 GraphicalView->setCacheMode ( QGraphicsView::CacheBackground );
36 GraphicalView->setViewportUpdateMode ( QGraphicsView::BoundingRectViewportUpdate );
37 GraphicalView->setRenderHint ( QPainter::Antialiasing );
38 GraphicalView->setTransformationAnchor ( QGraphicsView::AnchorUnderMouse );
39 GraphicalView->setMinimumSize ( 400, 400 );
40 GraphicalView->centerOn ( scene->sceneRect().topLeft() );
41 GraphicalView->setAcceptDrops ( true );
42}
void ConnectActions()
Definition GraphView.cpp:46
QUuid const uuid
Definition GraphView.hpp:54
QMenu * ContextMenu
Definition GraphView.hpp:47
GraphicalObject * ClickedItem
Definition GraphView.hpp:53

Member Function Documentation

◆ ConnectActions()

void dbe::GraphView::ConnectActions ( )

Definition at line 46 of file GraphView.cpp.

47{
48 connect ( LoadButton, SIGNAL ( clicked() ), this, SLOT ( GetWindowConfiguration() ),
49 Qt::UniqueConnection );
50}
void GetWindowConfiguration()

◆ contextMenuEvent()

void dbe::GraphView::contextMenuEvent ( QContextMenuEvent * Event)

CreaContextMenu(nullptr)ting Actions

Definition at line 115 of file GraphView.cpp.

116{
117 if ( ContextMenu == nullptr )
118 {
119 ContextMenu = new QMenu ( GraphicalView );
122 }
123
124 QGraphicsItem * Index = GraphicalView->itemAt ( Event->pos() );
125
126 if ( Index )
127 {
128 ClickedItem = dynamic_cast<GraphicalObject *> ( Index );
129
130 if ( ClickedItem )
131 {
132 ContextMenu->exec ( Event->globalPos() );
133 }
134 }
135}
void CreateActions()

◆ copyObject

void dbe::GraphView::copyObject ( )
privateslot

Definition at line 240 of file GraphView.cpp.

241{
242
243 try
244 {
246 {
247 ClickedItem->GetDatabaseUidName().toStdString(),
248 ClickedItem->GetDatabaseClassName().toStdString()
249 } );
250
251 ( new ObjectCreator ( obj ) )->show();
252 }
253 catch ( daq::dbe::config_object_retrieval_result_is_null const & e )
254 {
255
256 }
257
258}
QString GetDatabaseUidName() const
QString GetDatabaseClassName() const
static configobject::tref get(dbe::cokey const &desc)
inner::configobject::tref tref
Definition tref.hpp:30

◆ CreateActions

void dbe::GraphView::CreateActions ( )
privateslot

Definition at line 139 of file GraphView.cpp.

140{
141 editObject = new QAction ( tr ( "&Edit Object" ), this );
142 editObject->setShortcut ( tr ( "Ctrl+E" ) );
143 editObject->setShortcutContext ( Qt::WidgetShortcut );
144 connect ( editObject, SIGNAL ( triggered() ), this, SLOT ( editThisObject() ),
145 Qt::UniqueConnection );
146 ContextMenu->addAction ( editObject );
147
148 deleteObjectAc = new QAction ( tr ( "&Delete Object" ), this );
149 deleteObjectAc->setShortcut ( tr ( "Ctrl+D" ) );
150 deleteObjectAc->setShortcutContext ( Qt::WidgetShortcut );
151 connect ( deleteObjectAc, SIGNAL ( triggered() ), this, SLOT ( deleteThisObject() ),
152 Qt::UniqueConnection );
153 ContextMenu->addAction ( deleteObjectAc );
154
155 refByAc = new QAction ( tr ( "Referenced B&y (All objects)" ), this );
156 refByAc->setShortcut ( tr ( "Ctrl+Y" ) );
157 refByAc->setShortcutContext ( Qt::WidgetShortcut );
158 refByAc->setToolTip ( "Find all objects which reference the selecetd object" );
159 refByAc->setStatusTip ( refByAc->toolTip() );
160 connect ( refByAc, SIGNAL ( triggered() ), this, SLOT ( referencedBy_All() ),
161 Qt::UniqueConnection );
162 ContextMenu->addAction ( refByAc );
163
164 refByAcOnlyComp = new QAction ( tr ( "Referenced B&y (Only Composite)" ), this );
165 refByAcOnlyComp->setShortcut ( tr ( "Ctrl+Shift+Y" ) );
166 refByAcOnlyComp->setShortcutContext ( Qt::WidgetShortcut );
167 refByAcOnlyComp->setToolTip (
168 "Find objects (ONLY Composite ones) which reference the selecetd object" );
169 refByAcOnlyComp->setStatusTip ( refByAcOnlyComp->toolTip() );
170 connect ( refByAcOnlyComp, SIGNAL ( triggered() ), this,
172 Qt::UniqueConnection );
173 ContextMenu->addAction ( refByAcOnlyComp );
174
175 copyObjectAc = new QAction ( tr ( "Copy This Object Into A &New One" ), this );
176 copyObjectAc->setShortcut ( tr ( "Ctrl+Shift+N" ) );
177 copyObjectAc->setShortcutContext ( Qt::WidgetShortcut );
178 connect ( copyObjectAc, SIGNAL ( triggered() ), this, SLOT ( copyObject() ),
179 Qt::UniqueConnection );
180 ContextMenu->addAction ( copyObjectAc );
181}
QAction * refByAc
Definition GraphView.hpp:50
void editThisObject()
void referencedBy_OnlyComposite()
QAction * refByAcOnlyComp
Definition GraphView.hpp:51
void deleteThisObject()
QAction * editObject
Definition GraphView.hpp:48
QAction * deleteObjectAc
Definition GraphView.hpp:49
void referencedBy_All()
QAction * copyObjectAc
Definition GraphView.hpp:52

◆ deleteThisObject

void dbe::GraphView::deleteThisObject ( )
privateslot

Definition at line 218 of file GraphView.cpp.

219{
220
221 try
222 {
224 {
225 ClickedItem->GetDatabaseUidName().toStdString(),
226 ClickedItem->GetDatabaseClassName().toStdString()
227 } );
228
230 }
231 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
232 {
233 // Nothing needed to do here , if the lookup failed that is ok
234 }
235
236}
bool delobj(inner::configobject::tref obj, QUuid const &src)

◆ editThisObject

void dbe::GraphView::editThisObject ( )
privateslot

Definition at line 185 of file GraphView.cpp.

186{
188 {
190 .toStdString()
191 } );
192
193 bool WidgetFound = false;
194 QString ObjectEditorName = QString ( "%1@%2" ).arg ( Object.UID().c_str() ).arg (
195 Object.class_name().c_str() );
196
197 for ( QWidget * Editor : QApplication::allWidgets() )
198 {
199 ObjectEditor * Widget = dynamic_cast<ObjectEditor *> ( Editor );
200
201 if ( Widget != nullptr )
202 {
203 if ( ( Widget->objectName() ).compare ( ObjectEditorName ) == 0 )
204 {
205 Widget->raise();
206 Widget->setVisible ( true );
207 WidgetFound = true;
208 }
209 }
210 }
211
212 if ( !WidgetFound )
213 {
214 ( new ObjectEditor ( Object ) )->show();
215 }
216}

◆ GetWindowConfiguration

void dbe::GraphView::GetWindowConfiguration ( )
privateslot

Definition at line 305 of file GraphView.cpp.

306{
307 QString ChoosenWindow;
308
309 QDialog * ChooseDialog = new QDialog ( this );
310 QComboBox * Combo = new QComboBox ( ChooseDialog );
311 QPushButton * GoButton = new QPushButton ( "Choose" );
312 QHBoxLayout * Layout = new QHBoxLayout ( ChooseDialog );
313 QLabel * Label = new QLabel ( "Window Configuration : ", ChooseDialog );
314
315 connect ( GoButton, SIGNAL ( clicked() ), ChooseDialog, SLOT ( accept() ),
316 Qt::UniqueConnection );
317
318 std::vector<Window> Configurations = confaccessor::guiconfig()->windows();
319
320 for ( Window const & WindowConfig : Configurations )
321 {
322 Combo->addItem ( WindowConfig.Title );
323 }
324
325 Layout->addWidget ( Label );
326 Layout->addWidget ( Combo );
327 Layout->addWidget ( GoButton );
328
329 ChooseDialog->setLayout ( Layout );
330 ChooseDialog->setWindowTitle ( "Choose window configuration" );
331
332 if ( ChooseDialog->exec() )
333 {
334 ChoosenWindow = Combo->currentText();
335 }
336
337 for ( Window & Setting : Configurations )
338 {
339 if ( ChoosenWindow == Setting.Title )
340 {
341 WindowConfiguration = Setting;
342 SetupView();
343 break;
344 }
345 }
346}
Window WindowConfiguration
Definition GraphView.hpp:45
static cptr< ui::config::info > guiconfig()

◆ RedrawObject [1/2]

void dbe::GraphView::RedrawObject ( )
privateslot

Definition at line 358 of file GraphView.cpp.

359{
360 SetupView();
361}

◆ RedrawObject [2/2]

void dbe::GraphView::RedrawObject ( tref Object)
privateslot

Definition at line 350 of file GraphView.cpp.

351{
352 Q_UNUSED ( Object )
353 SetupView();
354}

◆ referencedBy_All

void dbe::GraphView::referencedBy_All ( )
privateslot

Definition at line 262 of file GraphView.cpp.

263{
264
265 try
266 {
268 {
269 ClickedItem->GetDatabaseUidName().toStdString(),
270 ClickedItem->GetDatabaseClassName().toStdString()
271 } );
272
273 MainWindow::findthis()->get_view()->referencedBy ( false, obj );
274 }
275 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
276 {
277 // Nothing needed to do here , it seems that the object has not been found ,
278 }
279
280}
cptr< dbe::CustomTreeView > get_view() const
static MainWindow * findthis()

◆ referencedBy_OnlyComposite

void dbe::GraphView::referencedBy_OnlyComposite ( )
privateslot

Definition at line 284 of file GraphView.cpp.

285{
286 try
287 {
289 {
290 ClickedItem->GetDatabaseUidName().toStdString(),
291 ClickedItem->GetDatabaseClassName().toStdString()
292 } );
293
294 MainWindow::findthis()->get_view()->referencedBy ( true, obj );
295 }
296 catch ( daq::dbe::config_object_retrieval_result_is_null const & ex )
297 {
298 // Nothing needed to do here , it seems that the object has not been found ,
299 // which is weird in this case
300 }
301}

◆ SetupView()

void dbe::GraphView::SetupView ( )

Cleaning the scene

WindowSettings

Iterating over the classes that have to be displayed

Getting Class and SubClasses to initialize

Loadind Data

Definition at line 54 of file GraphView.cpp.

55{
57 GraphicalView->scene()->clear();
58
60 double dy = 0;
61 setWindowTitle ( WindowConfiguration.Title + " View" );
62
64 for ( QString & ClassName : WindowConfiguration.GraphicalClassesList )
65 {
66 GraphicalClass GraphicalClassInfo = confaccessor::guiconfig()->graphical (
67 ClassName.toStdString() );
69 // QStringList ClassesToInitialize = GraphicalClassInfo.DerivedClasses;
70 // ClassesToInitialize.append(GraphicalClassInfo.DatabaseClassName);
71
72 // for(QString& InitializeClass : ClassesToInitialize)
73 // {
74 double dx = 0;
75 double ChildNodeHeight = 0;
76
77 // Node* ClassNode = ConfigWrapper::GetInstance().GetDataHandler()->GetClassNode(InitializeClass);
78 treenode * ClassNode = confaccessor::gethandler()->getnode (
79 GraphicalClassInfo.DatabaseClassName );
80
81 if ( ClassNode )
82 {
84 confaccessor::gethandler()->FetchMore ( ClassNode );
85
86 for ( treenode * Object : ClassNode->GetChildren() )
87 {
88 bool Used = true;
89 GraphicalObject * ObjectNodeGraphical = new GraphicalObject (
90 Used, Object->GetData ( 0 ).toString(), GraphicalClassInfo );
91 GraphicalView->scene()->addItem ( ObjectNodeGraphical );
92 ObjectNodeGraphical->setPos (
93 GraphicalView->scene()->sceneRect().topLeft() + QPointF ( dx, dy ) );
94 dx += ObjectNodeGraphical->boundingRect().width() + 30;
95
96 if ( ( dx + ObjectNodeGraphical->boundingRect().width() ) > GraphicalView->scene()
97 ->sceneRect().width() )
98 {
99 dx = 0;
100 dy += ChildNodeHeight + 30;
101 }
102
103 ChildNodeHeight = ObjectNodeGraphical->boundingRect().height();
104 }
105
106 dy += ChildNodeHeight + 30;
107 }
108
109 // }
110 }
111}
static cptr< datahandler > gethandler()
QStringList GraphicalClassesList

Member Data Documentation

◆ ClickedItem

GraphicalObject* dbe::GraphView::ClickedItem
private

Definition at line 53 of file GraphView.hpp.

◆ ContextMenu

QMenu* dbe::GraphView::ContextMenu
private

Definition at line 47 of file GraphView.hpp.

◆ copyObjectAc

QAction* dbe::GraphView::copyObjectAc
private

Definition at line 52 of file GraphView.hpp.

◆ deleteObjectAc

QAction* dbe::GraphView::deleteObjectAc
private

Definition at line 49 of file GraphView.hpp.

◆ editObject

QAction* dbe::GraphView::editObject
private

Definition at line 48 of file GraphView.hpp.

◆ refByAc

QAction* dbe::GraphView::refByAc
private

Definition at line 50 of file GraphView.hpp.

◆ refByAcOnlyComp

QAction* dbe::GraphView::refByAcOnlyComp
private

Definition at line 51 of file GraphView.hpp.

◆ uuid

QUuid const dbe::GraphView::uuid
private

Definition at line 54 of file GraphView.hpp.

◆ WindowConfiguration

Window dbe::GraphView::WindowConfiguration
private

Definition at line 45 of file GraphView.hpp.


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