v2.0.0
Loading...
Searching...
No Matches
control3dview.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
19#include "ui_control3dview.h"
20#include "control3dview.h"
21
22//=============================================================================================================
23// QT INCLUDES
24//=============================================================================================================
25
26#include <QMenu>
27#include <QSettings>
28#include <QMessageBox>
29
30//=============================================================================================================
31// EIGEN INCLUDES
32//=============================================================================================================
33
34//=============================================================================================================
35// QT INCLUDES
36//=============================================================================================================
37
38#include <QStyledItemDelegate>
39#include <QStandardItemModel>
40#include <QColorDialog>
41
42//=============================================================================================================
43// USED NAMESPACES
44//=============================================================================================================
45
46using namespace DISPLIB;
47
48//=============================================================================================================
49// DEFINE MEMBER METHODS
50//=============================================================================================================
51
52Control3DView::Control3DView(const QString& sSettingsPath,
53 QWidget* parent,
54 const QStringList& slFlags,
55 Qt::WindowType type)
56: AbstractView(parent, type)
57, m_pUi(std::make_unique<Ui::Control3DViewWidget>())
58, m_colCurrentSceneColor(QColor(0, 0, 0))
59, m_colCurrentLightColor(QColor(255, 255, 255))
60{
61 m_sSettingsPath = sSettingsPath;
62 m_pUi->setupUi(this);
63
64 setFlags(slFlags);
65
66 //Init's
67 m_pUi->m_pushButton_sceneColorPicker->setStyleSheet(QString("background-color: rgb(0, 0, 0);"));
68 m_pUi->m_pushButton_lightColorPicker->setStyleSheet(QString("background-color: rgb(255, 255, 255);"));
69
70 this->adjustSize();
71
72 //set context menu
73 m_pUi->m_treeView_loadedData->setContextMenuPolicy(Qt::CustomContextMenu);
74 connect(m_pUi->m_treeView_loadedData, &QWidget::customContextMenuRequested,
76
78}
79
80//=============================================================================================================
81
86
87//=============================================================================================================
88
89void Control3DView::setFlags(const QStringList& slFlags)
90{
91 //Parse flags
92 if (slFlags.contains("Data")) {
93 m_pUi->m_treeView_loadedData->show();
94 } else {
95 m_pUi->m_treeView_loadedData->hide();
96 }
97
98 if (slFlags.contains("View")) {
99 m_pUi->m_groupBox_viewOptions->show();
100
101 connect(m_pUi->m_pushButton_sceneColorPicker, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
102 this, &Control3DView::onSceneColorPicker, Qt::UniqueConnection);
103 connect(m_pUi->m_checkBox_showFullScreen, &QCheckBox::clicked,
104 this, &Control3DView::onShowFullScreen, Qt::UniqueConnection);
105
106 connect(m_pUi->m_checkBox_rotate, &QCheckBox::clicked,
107 this, &Control3DView::onRotationClicked, Qt::UniqueConnection);
108
109 connect(m_pUi->m_checkBox_coordAxis, &QCheckBox::clicked,
110 this, &Control3DView::onCoordAxisClicked, Qt::UniqueConnection);
111
112 connect(m_pUi->m_pushButton_takeScreenshot, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
113 this, &Control3DView::takeScreenshotChanged, Qt::UniqueConnection);
114
115 connect(m_pUi->m_radioButton_single, &QRadioButton::pressed,
116 this, &Control3DView::toggleSingleView, Qt::UniqueConnection);
117
118 connect(m_pUi->m_radioButton_multi, &QRadioButton::pressed,
119 this, &Control3DView::toggleMutiview, Qt::UniqueConnection);
120 } else {
121 m_pUi->m_groupBox_viewOptions->hide();
122 }
123
124 if (slFlags.contains("Light")) {
125 m_pUi->m_groupBox_lightOptions->show();
126
127 connect(m_pUi->m_pushButton_lightColorPicker, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
128 this, &Control3DView::onLightColorPicker, Qt::UniqueConnection);
129 connect(m_pUi->m_doubleSpinBox_colorIntensity, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
130 this, &Control3DView::onLightIntensityChanged, Qt::UniqueConnection);
131 } else {
132 m_pUi->m_groupBox_lightOptions->hide();
133 }
134}
135
136//=============================================================================================================
137
138void Control3DView::setDelegate(QStyledItemDelegate* pItemDelegate)
139{
140 //Init tree view properties
141 m_pUi->m_treeView_loadedData->setItemDelegate(pItemDelegate);
142 m_pUi->m_treeView_loadedData->setHeaderHidden(false);
143 m_pUi->m_treeView_loadedData->setEditTriggers(QAbstractItemView::CurrentChanged);
144}
145
146//=============================================================================================================
147
148void Control3DView::setModel(QStandardItemModel* pDataTreeModel)
149{
150 //Do the connects from this control widget to the View3D
151 m_pUi->m_treeView_loadedData->setModel(pDataTreeModel);
152
153 //Set description hidden as default
154 //m_pUi->m_treeView_loadedData->setColumnHidden(1, true);
155}
156
157//=============================================================================================================
158
160{
161 if (!m_pUi->m_treeView_loadedData->isHeaderHidden()) {
162 m_pUi->m_treeView_loadedData->setHeaderHidden(true);
163 } else {
164 m_pUi->m_treeView_loadedData->setHeaderHidden(false);
165 }
166}
167
168//=============================================================================================================
169
170void Control3DView::onTreeViewRemoveItem(const QModelIndex& index)
171{
172 if (index.isValid()) {
173 m_pUi->m_treeView_loadedData->model()->removeRow(index.row(), index.parent());
174 }
175}
176
177//=============================================================================================================
178
180{
181 if (m_pUi->m_treeView_loadedData->isColumnHidden(1)) {
182 m_pUi->m_treeView_loadedData->setColumnHidden(1, false);
183 } else {
184 m_pUi->m_treeView_loadedData->setColumnHidden(1, true);
185 }
186}
187
188//=============================================================================================================
189
191{
192 if (m_sSettingsPath.isEmpty()) {
193 return;
194 }
195
196 // Save Settings
197 QSettings settings("MNECPP");
198}
199
200//=============================================================================================================
201
203{
204 if (m_sSettingsPath.isEmpty()) {
205 return;
206 }
207
208 // Load Settings
209 QSettings settings("MNECPP");
210}
211
212//=============================================================================================================
213
215{
216 switch (mode) {
218 break;
219 default: // default is research mode
220 break;
221 }
222}
223
224//=============================================================================================================
225
227{
228 switch (mode) {
230 break;
231 default: // default is realtime mode
232 break;
233 }
234}
235
236//=============================================================================================================
237
239{
240 this->setWindowOpacity(1 / (100.0 / value));
241}
242
243//=============================================================================================================
244
246{
247 QColorDialog dialog(m_colCurrentSceneColor, this);
248
249 //Update all connected View3D's scene colors
250 connect(&dialog, &QColorDialog::currentColorChanged,
252
253 if (dialog.exec() == QDialog::Accepted) {
254 m_colCurrentSceneColor = dialog.currentColor();
255 } else {
257 }
258
259 //Set color of button new new scene color
260 m_pUi->m_pushButton_sceneColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentSceneColor.red()).arg(m_colCurrentSceneColor.green()).arg(m_colCurrentSceneColor.blue()));
261}
262
263//=============================================================================================================
264
266{
267 //create custom context menu and actions
268 QMenu* menu = new QMenu(this);
269 menu->setAttribute(Qt::WA_DeleteOnClose);
270
271 // Hide header
272 QAction* pHideHeader = menu->addAction(tr("Toggle header"));
273 connect(pHideHeader, &QAction::triggered,
275
276 // Remove item
277 QAction* pRemoveItem = menu->addAction(tr("Remove"));
278 connect(pRemoveItem, &QAction::triggered, [=, this]() {
279 if (QMessageBox::question(this,
280 tr("Remove item"),
281 tr("Are you sure you want to delete the item?")) == QMessageBox::Yes) {
282 onTreeViewRemoveItem(m_pUi->m_treeView_loadedData->indexAt(pos));
283 }
284 });
285
286 // QAction* pHideDesc = menu->addAction(tr("Toggle description"));
287 // connect(pHideDesc, &QAction::triggered,
288 // this, &Control3DView::onTreeViewDescriptionHide);
289
290 //show context menu
291 menu->popup(m_pUi->m_treeView_loadedData->viewport()->mapToGlobal(pos));
292}
293
294//=============================================================================================================
295
297{
298 if (state) {
299 this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
300 this->show();
301 } else {
302 this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
303 this->show();
304 }
305}
306
307//=============================================================================================================
308
309void Control3DView::onSceneColorChanged(const QColor& color)
310{
311 emit sceneColorChanged(color);
312}
313
314//=============================================================================================================
315
317{
318 emit showFullScreen(checked);
319}
320
321//=============================================================================================================
322
324{
325 emit rotationChanged(checked);
326}
327
328//=============================================================================================================
329
331{
332 emit showCoordAxis(checked);
333}
334
335//=============================================================================================================
336
338{
339 QColorDialog dialog(m_colCurrentLightColor, this);
340
341 //Update all connected View3D's light colors
342 connect(&dialog, &QColorDialog::currentColorChanged,
344
345 if (dialog.exec() == QDialog::Accepted) {
346 m_colCurrentLightColor = dialog.currentColor();
347 } else {
349 }
350
351 //Set color of button new new scene color
352 m_pUi->m_pushButton_lightColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentLightColor.red()).arg(m_colCurrentLightColor.green()).arg(m_colCurrentLightColor.blue()));
353}
354
355//=============================================================================================================
356
357void Control3DView::onLightColorChanged(const QColor& color)
358{
359 emit lightColorChanged(color);
360}
361
362//=============================================================================================================
363
365{
366 emit lightIntensityChanged(value);
367}
368
369//=============================================================================================================
370
Tree-based control panel for the 3-D scene (visibility, colour, alpha, threshold per tree item).
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
std::unique_ptr< Ui::Control3DViewWidget > m_pUi
void setDelegate(QStyledItemDelegate *pItemDelegate)
void sceneColorChanged(const QColor &color)
Control3DView(const QString &sSettingsPath="", QWidget *parent=0, const QStringList &slFlags=QStringList()<< "Data"<< "View"<< "Light", Qt::WindowType type=Qt::Widget)
void showFullScreen(bool bShowFullScreen)
void onSceneColorChanged(const QColor &color)
void setFlags(const QStringList &slFlags)
void onOpacityChange(qint32 value)
void rotationChanged(bool bRotationChanged)
void updateGuiMode(GuiMode mode)
void onCoordAxisClicked(bool checked)
void onCustomContextMenuRequested(QPoint pos)
customContextMenuRequested
void updateProcessingMode(ProcessingMode mode)
void onTreeViewRemoveItem(const QModelIndex &index)
void lightIntensityChanged(double value)
void onRotationClicked(bool checked)
void onShowFullScreen(bool checked)
void showCoordAxis(bool bShowCoordAxis)
void onAlwaysOnTop(bool state)
void lightColorChanged(const QColor &color)
void onLightColorChanged(const QColor &color)
void setModel(QStandardItemModel *pDataTreeModel)
void onLightIntensityChanged(double value)