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
GraphicalObject * ClickedItem
QUuid const uuid

Detailed Description

Definition at line 25 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 23 of file GraphView.cpp.

24 : QWidget(parent)
25 , ContextMenu(nullptr)
26 , ClickedItem(nullptr)
27 , uuid(QUuid::createUuid())
28{
29 setupUi(this);
33 setWindowTitle("Graphical View");
35 QGraphicsScene* scene = new QGraphicsScene(this);
36 scene->setItemIndexMethod(QGraphicsScene::NoIndex);
37 scene->setSceneRect(0, 0, 10000, 10000);
38 GraphicalView->setScene(scene);
39 GraphicalView->setCacheMode(QGraphicsView::CacheBackground);
40 GraphicalView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
41 GraphicalView->setRenderHint(QPainter::Antialiasing);
42 GraphicalView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
43 GraphicalView->setMinimumSize(400, 400);
44 GraphicalView->centerOn(scene->sceneRect().topLeft());
45 GraphicalView->setAcceptDrops(true);
46}
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()), Qt::UniqueConnection);
54}
void GetWindowConfiguration()

◆ contextMenuEvent()

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

CreaContextMenu(nullptr)ting Actions

Definition at line 113 of file GraphView.cpp.

114{
115 if (ContextMenu == nullptr) {
116 ContextMenu = new QMenu(GraphicalView);
119 }
120
121 QGraphicsItem* Index = GraphicalView->itemAt(Event->pos());
122
123 if (Index) {
124 ClickedItem = dynamic_cast<GraphicalObject*>(Index);
125
126 if (ClickedItem) {
127 ContextMenu->exec(Event->globalPos());
128 }
129 }
130}
void CreateActions()

◆ copyObject

void dbe::GraphView::copyObject ( )
privateslot

Definition at line 217 of file GraphView.cpp.

218{
219
220 try {
222 { ClickedItem->GetDatabaseUidName().toStdString(), ClickedItem->GetDatabaseClassName().toStdString() });
223
224 (new ObjectCreator(obj))->show();
225 } catch (daq::dbe::config_object_retrieval_result_is_null const& e) {
226 }
227}
QString GetDatabaseUidName() const
QString GetDatabaseClassName() const
ObjectCreator(dunedaq::conffwk::class_t const &classinfo, QWidget *parent=0)
static configobject::tref get(dbe::cokey const &desc)
inner::configobject::tref tref
Definition tref.hpp:36

◆ CreateActions

void dbe::GraphView::CreateActions ( )
privateslot

Definition at line 135 of file GraphView.cpp.

136{
137 editObject = new QAction(tr("&Edit Object"), this);
138 editObject->setShortcut(tr("Ctrl+E"));
139 editObject->setShortcutContext(Qt::WidgetShortcut);
140 connect(editObject, SIGNAL(triggered()), this, SLOT(editThisObject()), Qt::UniqueConnection);
141 ContextMenu->addAction(editObject);
142
143 deleteObjectAc = new QAction(tr("&Delete Object"), this);
144 deleteObjectAc->setShortcut(tr("Ctrl+D"));
145 deleteObjectAc->setShortcutContext(Qt::WidgetShortcut);
146 connect(deleteObjectAc, SIGNAL(triggered()), this, SLOT(deleteThisObject()), Qt::UniqueConnection);
147 ContextMenu->addAction(deleteObjectAc);
148
149 refByAc = new QAction(tr("Referenced B&y (All objects)"), this);
150 refByAc->setShortcut(tr("Ctrl+Y"));
151 refByAc->setShortcutContext(Qt::WidgetShortcut);
152 refByAc->setToolTip("Find all objects which reference the selecetd object");
153 refByAc->setStatusTip(refByAc->toolTip());
154 connect(refByAc, SIGNAL(triggered()), this, SLOT(referencedBy_All()), Qt::UniqueConnection);
155 ContextMenu->addAction(refByAc);
156
157 refByAcOnlyComp = new QAction(tr("Referenced B&y (Only Composite)"), this);
158 refByAcOnlyComp->setShortcut(tr("Ctrl+Shift+Y"));
159 refByAcOnlyComp->setShortcutContext(Qt::WidgetShortcut);
160 refByAcOnlyComp->setToolTip("Find objects (ONLY Composite ones) which reference the selecetd object");
161 refByAcOnlyComp->setStatusTip(refByAcOnlyComp->toolTip());
162 connect(refByAcOnlyComp, SIGNAL(triggered()), this, SLOT(referencedBy_OnlyComposite()), Qt::UniqueConnection);
163 ContextMenu->addAction(refByAcOnlyComp);
164
165 copyObjectAc = new QAction(tr("Copy This Object Into A &New One"), this);
166 copyObjectAc->setShortcut(tr("Ctrl+Shift+N"));
167 copyObjectAc->setShortcutContext(Qt::WidgetShortcut);
168 connect(copyObjectAc, SIGNAL(triggered()), this, SLOT(copyObject()), Qt::UniqueConnection);
169 ContextMenu->addAction(copyObjectAc);
170}
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 201 of file GraphView.cpp.

202{
203
204 try {
206 { ClickedItem->GetDatabaseUidName().toStdString(), ClickedItem->GetDatabaseClassName().toStdString() });
207
209 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
210 // Nothing needed to do here , if the lookup failed that is ok
211 }
212}
bool delobj(inner::configobject::tref obj, QUuid const &src)

◆ editThisObject

void dbe::GraphView::editThisObject ( )
privateslot

Definition at line 175 of file GraphView.cpp.

176{
178 { ClickedItem->GetDatabaseUidName().toStdString(), ClickedItem->GetDatabaseClassName().toStdString() });
179
180 bool WidgetFound = false;
181 QString ObjectEditorName = QString("%1@%2").arg(Object.UID().c_str()).arg(Object.class_name().c_str());
182
183 for (QWidget* Editor : QApplication::allWidgets()) {
184 ObjectEditor* Widget = dynamic_cast<ObjectEditor*>(Editor);
185
186 if (Widget != nullptr) {
187 if ((Widget->objectName()).compare(ObjectEditorName) == 0) {
188 Widget->raise();
189 Widget->setVisible(true);
190 WidgetFound = true;
191 }
192 }
193 }
194
195 if (!WidgetFound) {
196 (new ObjectEditor(Object))->show();
197 }
198}
ObjectEditor(QWidget *parent=nullptr)

◆ GetWindowConfiguration

void dbe::GraphView::GetWindowConfiguration ( )
privateslot

Definition at line 264 of file GraphView.cpp.

265{
266 QString ChoosenWindow;
267
268 QDialog* ChooseDialog = new QDialog(this);
269 QComboBox* Combo = new QComboBox(ChooseDialog);
270 QPushButton* GoButton = new QPushButton("Choose");
271 QHBoxLayout* Layout = new QHBoxLayout(ChooseDialog);
272 QLabel* Label = new QLabel("Window Configuration : ", ChooseDialog);
273
274 connect(GoButton, SIGNAL(clicked()), ChooseDialog, SLOT(accept()), Qt::UniqueConnection);
275
276 std::vector<Window> Configurations = confaccessor::guiconfig()->windows();
277
278 for (Window const& WindowConfig : Configurations) {
279 Combo->addItem(WindowConfig.Title);
280 }
281
282 Layout->addWidget(Label);
283 Layout->addWidget(Combo);
284 Layout->addWidget(GoButton);
285
286 ChooseDialog->setLayout(Layout);
287 ChooseDialog->setWindowTitle("Choose window configuration");
288
289 if (ChooseDialog->exec()) {
290 ChoosenWindow = Combo->currentText();
291 }
292
293 for (Window& Setting : Configurations) {
294 if (ChoosenWindow == Setting.Title) {
295 WindowConfiguration = Setting;
296 SetupView();
297 break;
298 }
299 }
300}
Window WindowConfiguration
Definition GraphView.hpp:50
static cptr< ui::config::info > guiconfig()

◆ RedrawObject [1/2]

void dbe::GraphView::RedrawObject ( )
privateslot

Definition at line 314 of file GraphView.cpp.

315{
316 SetupView();
317}

◆ RedrawObject [2/2]

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

Definition at line 305 of file GraphView.cpp.

306{
307 Q_UNUSED(Object)
308 SetupView();
309}

◆ referencedBy_All

void dbe::GraphView::referencedBy_All ( )
privateslot

Definition at line 232 of file GraphView.cpp.

233{
234
235 try {
237 { ClickedItem->GetDatabaseUidName().toStdString(), ClickedItem->GetDatabaseClassName().toStdString() });
238
239 MainWindow::findthis()->get_view()->referencedBy(false, obj);
240 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
241 // Nothing needed to do here , it seems that the object has not been found ,
242 }
243}
cptr< dbe::CustomTreeView > get_view() const
static MainWindow * findthis()

◆ referencedBy_OnlyComposite

void dbe::GraphView::referencedBy_OnlyComposite ( )
privateslot

Definition at line 248 of file GraphView.cpp.

249{
250 try {
252 { ClickedItem->GetDatabaseUidName().toStdString(), ClickedItem->GetDatabaseClassName().toStdString() });
253
254 MainWindow::findthis()->get_view()->referencedBy(true, obj);
255 } catch (daq::dbe::config_object_retrieval_result_is_null const& ex) {
256 // Nothing needed to do here , it seems that the object has not been found ,
257 // which is weird in this case
258 }
259}

◆ 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 GraphicalClass GraphicalClassInfo = confaccessor::guiconfig()->graphical(ClassName.toStdString());
72 // QStringList ClassesToInitialize = GraphicalClassInfo.DerivedClasses;
73 // ClassesToInitialize.append(GraphicalClassInfo.DatabaseClassName);
74
75 // for(QString& InitializeClass : ClassesToInitialize)
76 // {
77 double dx = 0;
78 double ChildNodeHeight = 0;
79
80 // Node* ClassNode = ConfigWrapper::GetInstance().GetDataHandler()->GetClassNode(InitializeClass);
81 treenode* ClassNode = confaccessor::gethandler()->getnode(GraphicalClassInfo.DatabaseClassName);
82
83 if (ClassNode) {
85 confaccessor::gethandler()->FetchMore(ClassNode);
86
87 for (treenode* Object : ClassNode->GetChildren()) {
88 bool Used = true;
89 GraphicalObject* ObjectNodeGraphical =
90 new GraphicalObject(Used, Object->GetData(0).toString(), GraphicalClassInfo);
91 GraphicalView->scene()->addItem(ObjectNodeGraphical);
92 ObjectNodeGraphical->setPos(GraphicalView->scene()->sceneRect().topLeft() + QPointF(dx, dy));
93 dx += ObjectNodeGraphical->boundingRect().width() + 30;
94
95 if ((dx + ObjectNodeGraphical->boundingRect().width()) > GraphicalView->scene()->sceneRect().width()) {
96 dx = 0;
97 dy += ChildNodeHeight + 30;
98 }
99
100 ChildNodeHeight = ObjectNodeGraphical->boundingRect().height();
101 }
102
103 dy += ChildNodeHeight + 30;
104 }
105
106 // }
107 }
108}
GraphicalObject(bool Used, QString ObjectName, GraphicalClass GraphInfo, QGraphicsObject *parent=0)
static cptr< datahandler > gethandler()
QStringList GraphicalClassesList

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: