DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
src
graphical
GraphView.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
6
#include "
dbe/config_ui_info.hpp
"
7
#include "
dbe/ObjectCreator.hpp
"
8
#include "
dbe/GraphView.hpp
"
9
#include "
dbe/MainWindow.hpp
"
10
#include "
dbe/config_api_info.hpp
"
11
#include "
dbe/config_api_commands.hpp
"
12
#include "
dbe/treenode.hpp
"
13
14
#include <QLabel>
15
#include <QDialog>
16
#include <QComboBox>
17
#include <QMenu>
18
#include <QContextMenuEvent>
19
20
21
//------------------------------------------------------------------------------------------
22
dbe::GraphView::~GraphView
() =
default
;
23
24
dbe::GraphView::GraphView
( QWidget * parent )
25
: QWidget ( parent ),
26
ContextMenu
( nullptr ),
27
ClickedItem
( nullptr ),
28
uuid
( QUuid::createUuid() )
29
{
30
setupUi (
this
);
32
ConnectActions
();
34
setWindowTitle (
"Graphical View"
);
36
QGraphicsScene * scene =
new
QGraphicsScene (
this
);
37
scene->setItemIndexMethod ( QGraphicsScene::NoIndex );
38
scene->setSceneRect ( 0, 0, 10000, 10000 );
39
GraphicalView->setScene ( scene );
40
GraphicalView->setCacheMode ( QGraphicsView::CacheBackground );
41
GraphicalView->setViewportUpdateMode ( QGraphicsView::BoundingRectViewportUpdate );
42
GraphicalView->setRenderHint ( QPainter::Antialiasing );
43
GraphicalView->setTransformationAnchor ( QGraphicsView::AnchorUnderMouse );
44
GraphicalView->setMinimumSize ( 400, 400 );
45
GraphicalView->centerOn ( scene->sceneRect().topLeft() );
46
GraphicalView->setAcceptDrops (
true
);
47
}
48
//------------------------------------------------------------------------------------------
49
50
//------------------------------------------------------------------------------------------
51
void
dbe::GraphView::ConnectActions
()
52
{
53
connect ( LoadButton, SIGNAL ( clicked() ),
this
, SLOT (
GetWindowConfiguration
() ),
54
Qt::UniqueConnection );
55
}
56
//------------------------------------------------------------------------------------------
57
58
//------------------------------------------------------------------------------------------
59
void
dbe::GraphView::SetupView
()
60
{
62
GraphicalView->scene()->clear();
63
65
double
dy = 0;
66
setWindowTitle (
WindowConfiguration
.Title +
" View"
);
67
69
for
( QString & ClassName :
WindowConfiguration
.GraphicalClassesList )
70
{
71
GraphicalClass
GraphicalClassInfo =
confaccessor::guiconfig
()->graphical (
72
ClassName.toStdString() );
74
// QStringList ClassesToInitialize = GraphicalClassInfo.DerivedClasses;
75
// ClassesToInitialize.append(GraphicalClassInfo.DatabaseClassName);
76
77
// for(QString& InitializeClass : ClassesToInitialize)
78
// {
79
double
dx = 0;
80
double
ChildNodeHeight = 0;
81
82
// Node* ClassNode = ConfigWrapper::GetInstance().GetDataHandler()->GetClassNode(InitializeClass);
83
treenode
*
ClassNode
=
confaccessor::gethandler
()->getnode (
84
GraphicalClassInfo.
DatabaseClassName
);
85
86
if
(
ClassNode
)
87
{
89
confaccessor::gethandler
()->FetchMore (
ClassNode
);
90
91
for
(
treenode
* Object :
ClassNode
->
GetChildren
() )
92
{
93
bool
Used =
true
;
94
GraphicalObject
* ObjectNodeGraphical =
new
GraphicalObject
(
95
Used, Object->GetData ( 0 ).toString(), GraphicalClassInfo );
96
GraphicalView->scene()->addItem ( ObjectNodeGraphical );
97
ObjectNodeGraphical->setPos (
98
GraphicalView->scene()->sceneRect().topLeft() + QPointF ( dx, dy ) );
99
dx += ObjectNodeGraphical->
boundingRect
().width() + 30;
100
101
if
( ( dx + ObjectNodeGraphical->
boundingRect
().width() ) > GraphicalView->scene()
102
->sceneRect().width() )
103
{
104
dx = 0;
105
dy += ChildNodeHeight + 30;
106
}
107
108
ChildNodeHeight = ObjectNodeGraphical->
boundingRect
().height();
109
}
110
111
dy += ChildNodeHeight + 30;
112
}
113
114
// }
115
}
116
}
117
//------------------------------------------------------------------------------------------
118
119
//------------------------------------------------------------------------------------------
120
void
dbe::GraphView::contextMenuEvent
( QContextMenuEvent * Event )
121
{
122
if
(
ContextMenu
==
nullptr
)
123
{
124
ContextMenu
=
new
QMenu ( GraphicalView );
126
CreateActions
();
127
}
128
129
QGraphicsItem * Index = GraphicalView->itemAt ( Event->pos() );
130
131
if
( Index )
132
{
133
ClickedItem
=
dynamic_cast<
GraphicalObject
*
>
( Index );
134
135
if
(
ClickedItem
)
136
{
137
ContextMenu
->exec ( Event->globalPos() );
138
}
139
}
140
}
141
//------------------------------------------------------------------------------------------
142
143
//------------------------------------------------------------------------------------------
144
void
dbe::GraphView::CreateActions
()
145
{
146
editObject
=
new
QAction ( tr (
"&Edit Object"
),
this
);
147
editObject
->setShortcut ( tr (
"Ctrl+E"
) );
148
editObject
->setShortcutContext ( Qt::WidgetShortcut );
149
connect (
editObject
, SIGNAL ( triggered() ),
this
, SLOT (
editThisObject
() ),
150
Qt::UniqueConnection );
151
ContextMenu
->addAction (
editObject
);
152
153
deleteObjectAc
=
new
QAction ( tr (
"&Delete Object"
),
this
);
154
deleteObjectAc
->setShortcut ( tr (
"Ctrl+D"
) );
155
deleteObjectAc
->setShortcutContext ( Qt::WidgetShortcut );
156
connect (
deleteObjectAc
, SIGNAL ( triggered() ),
this
, SLOT (
deleteThisObject
() ),
157
Qt::UniqueConnection );
158
ContextMenu
->addAction (
deleteObjectAc
);
159
160
refByAc
=
new
QAction ( tr (
"Referenced B&y (All objects)"
),
this
);
161
refByAc
->setShortcut ( tr (
"Ctrl+Y"
) );
162
refByAc
->setShortcutContext ( Qt::WidgetShortcut );
163
refByAc
->setToolTip (
"Find all objects which reference the selecetd object"
);
164
refByAc
->setStatusTip (
refByAc
->toolTip() );
165
connect (
refByAc
, SIGNAL ( triggered() ),
this
, SLOT (
referencedBy_All
() ),
166
Qt::UniqueConnection );
167
ContextMenu
->addAction (
refByAc
);
168
169
refByAcOnlyComp
=
new
QAction ( tr (
"Referenced B&y (Only Composite)"
),
this
);
170
refByAcOnlyComp
->setShortcut ( tr (
"Ctrl+Shift+Y"
) );
171
refByAcOnlyComp
->setShortcutContext ( Qt::WidgetShortcut );
172
refByAcOnlyComp
->setToolTip (
173
"Find objects (ONLY Composite ones) which reference the selecetd object"
);
174
refByAcOnlyComp
->setStatusTip (
refByAcOnlyComp
->toolTip() );
175
connect (
refByAcOnlyComp
, SIGNAL ( triggered() ),
this
,
176
SLOT (
referencedBy_OnlyComposite
() ),
177
Qt::UniqueConnection );
178
ContextMenu
->addAction (
refByAcOnlyComp
);
179
180
copyObjectAc
=
new
QAction ( tr (
"Copy This Object Into A &New One"
),
this
);
181
copyObjectAc
->setShortcut ( tr (
"Ctrl+Shift+N"
) );
182
copyObjectAc
->setShortcutContext ( Qt::WidgetShortcut );
183
connect (
copyObjectAc
, SIGNAL ( triggered() ),
this
, SLOT (
copyObject
() ),
184
Qt::UniqueConnection );
185
ContextMenu
->addAction (
copyObjectAc
);
186
}
187
//------------------------------------------------------------------------------------------
188
189
//------------------------------------------------------------------------------------------
190
void
dbe::GraphView::editThisObject
()
191
{
192
tref
Object =
inner::dbcontroller::get
(
193
{
194
ClickedItem
->GetDatabaseUidName().toStdString(),
ClickedItem
->GetDatabaseClassName()
195
.toStdString()
196
} );
197
198
bool
WidgetFound =
false
;
199
QString ObjectEditorName = QString (
"%1@%2"
).arg ( Object.
UID
().c_str() ).arg (
200
Object.
class_name
().c_str() );
201
202
for
( QWidget * Editor : QApplication::allWidgets() )
203
{
204
ObjectEditor
* Widget =
dynamic_cast<
ObjectEditor
*
>
( Editor );
205
206
if
( Widget !=
nullptr
)
207
{
208
if
( ( Widget->objectName() ).compare ( ObjectEditorName ) == 0 )
209
{
210
Widget->raise();
211
Widget->setVisible (
true
);
212
WidgetFound =
true
;
213
}
214
}
215
}
216
217
if
( !WidgetFound )
218
{
219
(
new
ObjectEditor
( Object ) )->show();
220
}
221
}
222
223
void
dbe::GraphView::deleteThisObject
()
224
{
225
226
try
227
{
228
tref
obj =
inner::dbcontroller::get
(
229
{
230
ClickedItem
->GetDatabaseUidName().toStdString(),
231
ClickedItem
->GetDatabaseClassName().toStdString()
232
} );
233
234
dbe::config::api::commands::delobj
( obj,
uuid
);
235
}
236
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
237
{
238
// Nothing needed to do here , if the lookup failed that is ok
239
}
240
241
}
242
//------------------------------------------------------------------------------------------
243
244
//------------------------------------------------------------------------------------------
245
void
dbe::GraphView::copyObject
()
246
{
247
248
try
249
{
250
tref
obj =
inner::dbcontroller::get
(
251
{
252
ClickedItem
->GetDatabaseUidName().toStdString(),
253
ClickedItem
->GetDatabaseClassName().toStdString()
254
} );
255
256
(
new
ObjectCreator
( obj ) )->show();
257
}
258
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& e )
259
{
260
261
}
262
263
}
264
//------------------------------------------------------------------------------------------
265
266
//------------------------------------------------------------------------------------------
267
void
dbe::GraphView::referencedBy_All
()
268
{
269
270
try
271
{
272
tref
obj =
inner::dbcontroller::get
(
273
{
274
ClickedItem
->GetDatabaseUidName().toStdString(),
275
ClickedItem
->GetDatabaseClassName().toStdString()
276
} );
277
278
MainWindow::findthis
()->
get_view
()->referencedBy (
false
, obj );
279
}
280
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
281
{
282
// Nothing needed to do here , it seems that the object has not been found ,
283
}
284
285
}
286
//------------------------------------------------------------------------------------------
287
288
//------------------------------------------------------------------------------------------
289
void
dbe::GraphView::referencedBy_OnlyComposite
()
290
{
291
try
292
{
293
tref
obj =
inner::dbcontroller::get
(
294
{
295
ClickedItem
->GetDatabaseUidName().toStdString(),
296
ClickedItem
->GetDatabaseClassName().toStdString()
297
} );
298
299
MainWindow::findthis
()->
get_view
()->referencedBy (
true
, obj );
300
}
301
catch
( daq::dbe::config_object_retrieval_result_is_null
const
& ex )
302
{
303
// Nothing needed to do here , it seems that the object has not been found ,
304
// which is weird in this case
305
}
306
}
307
//------------------------------------------------------------------------------------------
308
309
//------------------------------------------------------------------------------------------
310
void
dbe::GraphView::GetWindowConfiguration
()
311
{
312
QString ChoosenWindow;
313
314
QDialog * ChooseDialog =
new
QDialog (
this
);
315
QComboBox * Combo =
new
QComboBox ( ChooseDialog );
316
QPushButton * GoButton =
new
QPushButton (
"Choose"
);
317
QHBoxLayout * Layout =
new
QHBoxLayout ( ChooseDialog );
318
QLabel * Label =
new
QLabel (
"Window Configuration : "
, ChooseDialog );
319
320
connect ( GoButton, SIGNAL ( clicked() ), ChooseDialog, SLOT ( accept() ),
321
Qt::UniqueConnection );
322
323
std::vector<Window> Configurations =
confaccessor::guiconfig
()->windows();
324
325
for
(
Window
const
& WindowConfig : Configurations )
326
{
327
Combo->addItem ( WindowConfig.Title );
328
}
329
330
Layout->addWidget ( Label );
331
Layout->addWidget ( Combo );
332
Layout->addWidget ( GoButton );
333
334
ChooseDialog->setLayout ( Layout );
335
ChooseDialog->setWindowTitle (
"Choose window configuration"
);
336
337
if
( ChooseDialog->exec() )
338
{
339
ChoosenWindow = Combo->currentText();
340
}
341
342
for
(
Window
& Setting : Configurations )
343
{
344
if
( ChoosenWindow == Setting.Title )
345
{
346
WindowConfiguration
= Setting;
347
SetupView
();
348
break
;
349
}
350
}
351
}
352
//------------------------------------------------------------------------------------------
353
354
//------------------------------------------------------------------------------------------
355
void
dbe::GraphView::RedrawObject
(
tref
Object )
356
{
357
Q_UNUSED ( Object )
358
SetupView
();
359
}
360
//------------------------------------------------------------------------------------------
361
362
//------------------------------------------------------------------------------------------
363
void
dbe::GraphView::RedrawObject
()
364
{
365
SetupView
();
366
}
367
//------------------------------------------------------------------------------------------
GraphView.hpp
MainWindow.hpp
ObjectCreator.hpp
dbe::ClassNode
Definition
treenode.hpp:63
dbe::GraphView::refByAc
QAction * refByAc
Definition
GraphView.hpp:55
dbe::GraphView::ConnectActions
void ConnectActions()
Definition
GraphView.cpp:51
dbe::GraphView::copyObject
void copyObject()
Definition
GraphView.cpp:245
dbe::GraphView::~GraphView
~GraphView()
dbe::GraphView::GraphView
GraphView(QWidget *parent=nullptr)
Definition
GraphView.cpp:24
dbe::GraphView::editThisObject
void editThisObject()
Definition
GraphView.cpp:190
dbe::GraphView::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *Event)
Definition
GraphView.cpp:120
dbe::GraphView::referencedBy_OnlyComposite
void referencedBy_OnlyComposite()
Definition
GraphView.cpp:289
dbe::GraphView::refByAcOnlyComp
QAction * refByAcOnlyComp
Definition
GraphView.hpp:56
dbe::GraphView::uuid
QUuid const uuid
Definition
GraphView.hpp:59
dbe::GraphView::GetWindowConfiguration
void GetWindowConfiguration()
Definition
GraphView.cpp:310
dbe::GraphView::ContextMenu
QMenu * ContextMenu
Definition
GraphView.hpp:52
dbe::GraphView::deleteThisObject
void deleteThisObject()
Definition
GraphView.cpp:223
dbe::GraphView::editObject
QAction * editObject
Definition
GraphView.hpp:53
dbe::GraphView::deleteObjectAc
QAction * deleteObjectAc
Definition
GraphView.hpp:54
dbe::GraphView::SetupView
void SetupView()
Definition
GraphView.cpp:59
dbe::GraphView::WindowConfiguration
Window WindowConfiguration
Definition
GraphView.hpp:50
dbe::GraphView::referencedBy_All
void referencedBy_All()
Definition
GraphView.cpp:267
dbe::GraphView::CreateActions
void CreateActions()
Definition
GraphView.cpp:144
dbe::GraphView::RedrawObject
void RedrawObject()
Definition
GraphView.cpp:363
dbe::GraphView::ClickedItem
GraphicalObject * ClickedItem
Definition
GraphView.hpp:58
dbe::GraphView::copyObjectAc
QAction * copyObjectAc
Definition
GraphView.hpp:57
dbe::GraphicalObject
Definition
GraphicalClass.hpp:56
dbe::GraphicalObject::boundingRect
QRectF boundingRect() const
Definition
GraphicalClass.cpp:76
dbe::MainWindow::get_view
cptr< dbe::CustomTreeView > get_view() const
Definition
MainWindow.cpp:1847
dbe::MainWindow::findthis
static MainWindow * findthis()
Definition
MainWindow.cpp:1667
dbe::ObjectCreator
Definition
ObjectCreator.hpp:30
dbe::ObjectEditor
Definition
ObjectEditor.hpp:34
dbe::confaccessor::gethandler
static cptr< datahandler > gethandler()
Definition
confaccessor.cpp:138
dbe::confaccessor::guiconfig
static cptr< ui::config::info > guiconfig()
Definition
confaccessor.cpp:144
dbe::inner::configobject::ref_interface::class_name
std::string class_name() const
Definition
config_reference.hpp:201
dbe::inner::configobject::ref_interface::UID
std::string UID() const
Definition
config_reference.hpp:196
dbe::inner::dbcontroller::get
static configobject::tref get(dbe::cokey const &desc)
Definition
dbcontroller.cpp:388
dbe::treenode
Definition
treenode.hpp:20
dbe::treenode::GetChildren
QList< treenode * > GetChildren() const
Definition
treenode.cpp:111
config_api_commands.hpp
config_api_info.hpp
config_ui_info.hpp
dbe::config::api::commands::delobj
bool delobj(inner::configobject::tref obj, QUuid const &src)
Definition
config_api_commands.cpp:79
dbe::tref
inner::configobject::tref tref
Definition
tref.hpp:35
dbe::GraphicalClass
Definition
GraphicalClass.hpp:30
dbe::GraphicalClass::DatabaseClassName
QString DatabaseClassName
Definition
GraphicalClass.hpp:32
dbe::Window
Definition
GraphicalClass.hpp:49
treenode.hpp
Generated on
for DUNE-DAQ by
1.17.0