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 27 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 24 of file GraphView.cpp.

25 : QWidget ( parent ),
26 ContextMenu ( nullptr ),
27 ClickedItem ( nullptr ),
28 uuid ( QUuid::createUuid() )
29{
30 setupUi ( this );
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}
void ConnectActions()
Definition GraphView.cpp:51
QUuid const uuid
Definition GraphView.hpp:59
QMenu * ContextMenu
Definition GraphView.hpp:52
GraphicalObject * ClickedItem
Definition GraphView.hpp:58

Member Function Documentation

◆ ConnectActions()

void dbe::GraphView::ConnectActions ( )

Definition at line 51 of file GraphView.cpp.

52{
53 connect ( LoadButton, SIGNAL ( clicked() ), this, SLOT ( GetWindowConfiguration() ),
54 Qt::UniqueConnection );
55}
void GetWindowConfiguration()

◆ contextMenuEvent()

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

CreaContextMenu(nullptr)ting Actions

Definition at line 120 of file GraphView.cpp.

121{
122 if ( ContextMenu == nullptr )
123 {
124 ContextMenu = new QMenu ( GraphicalView );
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}
void CreateActions()

◆ copyObject

void dbe::GraphView::copyObject ( )
privateslot

Definition at line 245 of file GraphView.cpp.

246{
247
248 try
249 {
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}
static configobject::tref get(dbe::cokey const &desc)
inner::configobject::tref tref
Definition tref.hpp:35

◆ CreateActions

void dbe::GraphView::CreateActions ( )
privateslot

Definition at line 144 of file GraphView.cpp.

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,
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}
QAction * refByAc
Definition GraphView.hpp:55
void editThisObject()
void referencedBy_OnlyComposite()
QAction * refByAcOnlyComp
Definition GraphView.hpp:56
void deleteThisObject()
QAction * editObject
Definition GraphView.hpp:53
QAction * deleteObjectAc
Definition GraphView.hpp:54
void referencedBy_All()
QAction * copyObjectAc
Definition GraphView.hpp:57

◆ deleteThisObject

void dbe::GraphView::deleteThisObject ( )
privateslot

Definition at line 223 of file GraphView.cpp.

224{
225
226 try
227 {
229 {
230 ClickedItem->GetDatabaseUidName().toStdString(),
231 ClickedItem->GetDatabaseClassName().toStdString()
232 } );
233
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}
bool delobj(inner::configobject::tref obj, QUuid const &src)

◆ editThisObject

void dbe::GraphView::editThisObject ( )
privateslot

Definition at line 190 of file GraphView.cpp.

191{
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}

◆ GetWindowConfiguration

void dbe::GraphView::GetWindowConfiguration ( )
privateslot

Definition at line 310 of file GraphView.cpp.

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}
Window WindowConfiguration
Definition GraphView.hpp:50
static cptr< ui::config::info > guiconfig()

◆ RedrawObject [1/2]

void dbe::GraphView::RedrawObject ( )
privateslot

Definition at line 363 of file GraphView.cpp.

364{
365 SetupView();
366}

◆ RedrawObject [2/2]

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

Definition at line 355 of file GraphView.cpp.

356{
357 Q_UNUSED ( Object )
358 SetupView();
359}

◆ referencedBy_All

void dbe::GraphView::referencedBy_All ( )
privateslot

Definition at line 267 of file GraphView.cpp.

268{
269
270 try
271 {
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}
cptr< dbe::CustomTreeView > get_view() const
static MainWindow * findthis()

◆ referencedBy_OnlyComposite

void dbe::GraphView::referencedBy_OnlyComposite ( )
privateslot

Definition at line 289 of file GraphView.cpp.

290{
291 try
292 {
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}

◆ 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 59 of file GraphView.cpp.

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}
static cptr< datahandler > gethandler()

Member Data Documentation

◆ ClickedItem

GraphicalObject* dbe::GraphView::ClickedItem
private

Definition at line 58 of file GraphView.hpp.

◆ ContextMenu

QMenu* dbe::GraphView::ContextMenu
private

Definition at line 52 of file GraphView.hpp.

◆ copyObjectAc

QAction* dbe::GraphView::copyObjectAc
private

Definition at line 57 of file GraphView.hpp.

◆ deleteObjectAc

QAction* dbe::GraphView::deleteObjectAc
private

Definition at line 54 of file GraphView.hpp.

◆ editObject

QAction* dbe::GraphView::editObject
private

Definition at line 53 of file GraphView.hpp.

◆ refByAc

QAction* dbe::GraphView::refByAc
private

Definition at line 55 of file GraphView.hpp.

◆ refByAcOnlyComp

QAction* dbe::GraphView::refByAcOnlyComp
private

Definition at line 56 of file GraphView.hpp.

◆ uuid

QUuid const dbe::GraphView::uuid
private

Definition at line 59 of file GraphView.hpp.

◆ WindowConfiguration

Window dbe::GraphView::WindowConfiguration
private

Definition at line 50 of file GraphView.hpp.


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