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(new 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
87
88//=============================================================================================================
89
90void Control3DView::setFlags(const QStringList& slFlags)
91{
92 //Parse flags
93 if (slFlags.contains("Data")) {
94 m_pUi->m_treeView_loadedData->show();
95 } else {
96 m_pUi->m_treeView_loadedData->hide();
97 }
98
99 if (slFlags.contains("View")) {
100 m_pUi->m_groupBox_viewOptions->show();
101
102 connect(m_pUi->m_pushButton_sceneColorPicker, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
103 this, &Control3DView::onSceneColorPicker, Qt::UniqueConnection);
104 connect(m_pUi->m_checkBox_showFullScreen, &QCheckBox::clicked,
105 this, &Control3DView::onShowFullScreen, Qt::UniqueConnection);
106
107 connect(m_pUi->m_checkBox_rotate, &QCheckBox::clicked,
108 this, &Control3DView::onRotationClicked, Qt::UniqueConnection);
109
110 connect(m_pUi->m_checkBox_coordAxis, &QCheckBox::clicked,
111 this, &Control3DView::onCoordAxisClicked, Qt::UniqueConnection);
112
113 connect(m_pUi->m_pushButton_takeScreenshot, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
114 this, &Control3DView::takeScreenshotChanged, Qt::UniqueConnection);
115
116 connect(m_pUi->m_radioButton_single, &QRadioButton::pressed,
117 this, &Control3DView::toggleSingleView, Qt::UniqueConnection);
118
119 connect(m_pUi->m_radioButton_multi, &QRadioButton::pressed,
120 this, &Control3DView::toggleMutiview, Qt::UniqueConnection);
121 } else {
122 m_pUi->m_groupBox_viewOptions->hide();
123 }
124
125 if (slFlags.contains("Light")) {
126 m_pUi->m_groupBox_lightOptions->show();
127
128 connect(m_pUi->m_pushButton_lightColorPicker, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
129 this, &Control3DView::onLightColorPicker, Qt::UniqueConnection);
130 connect(m_pUi->m_doubleSpinBox_colorIntensity, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
131 this, &Control3DView::onLightIntensityChanged, Qt::UniqueConnection);
132 } else {
133 m_pUi->m_groupBox_lightOptions->hide();
134 }
135}
136
137//=============================================================================================================
138
139void Control3DView::setDelegate(QStyledItemDelegate* pItemDelegate)
140{
141 //Init tree view properties
142 m_pUi->m_treeView_loadedData->setItemDelegate(pItemDelegate);
143 m_pUi->m_treeView_loadedData->setHeaderHidden(false);
144 m_pUi->m_treeView_loadedData->setEditTriggers(QAbstractItemView::CurrentChanged);
145}
146
147//=============================================================================================================
148
149void Control3DView::setModel(QStandardItemModel* pDataTreeModel)
150{
151 //Do the connects from this control widget to the View3D
152 m_pUi->m_treeView_loadedData->setModel(pDataTreeModel);
153
154 //Set description hidden as default
155 //m_pUi->m_treeView_loadedData->setColumnHidden(1, true);
156}
157
158//=============================================================================================================
159
161{
162 if (!m_pUi->m_treeView_loadedData->isHeaderHidden()) {
163 m_pUi->m_treeView_loadedData->setHeaderHidden(true);
164 } else {
165 m_pUi->m_treeView_loadedData->setHeaderHidden(false);
166 }
167}
168
169//=============================================================================================================
170
171void Control3DView::onTreeViewRemoveItem(const QModelIndex& index)
172{
173 if (index.isValid()) {
174 m_pUi->m_treeView_loadedData->model()->removeRow(index.row(), index.parent());
175 }
176}
177
178//=============================================================================================================
179
181{
182 if (m_pUi->m_treeView_loadedData->isColumnHidden(1)) {
183 m_pUi->m_treeView_loadedData->setColumnHidden(1, false);
184 } else {
185 m_pUi->m_treeView_loadedData->setColumnHidden(1, true);
186 }
187}
188
189//=============================================================================================================
190
192{
193 if (m_sSettingsPath.isEmpty()) {
194 return;
195 }
196
197 // Save Settings
198 QSettings settings("MNECPP");
199}
200
201//=============================================================================================================
202
204{
205 if (m_sSettingsPath.isEmpty()) {
206 return;
207 }
208
209 // Load Settings
210 QSettings settings("MNECPP");
211}
212
213//=============================================================================================================
214
216{
217 switch (mode) {
219 break;
220 default: // default is research mode
221 break;
222 }
223}
224
225//=============================================================================================================
226
228{
229 switch (mode) {
231 break;
232 default: // default is realtime mode
233 break;
234 }
235}
236
237//=============================================================================================================
238
240{
241 this->setWindowOpacity(1 / (100.0 / value));
242}
243
244//=============================================================================================================
245
247{
248 QColorDialog dialog(m_colCurrentSceneColor, this);
249
250 //Update all connected View3D's scene colors
251 connect(&dialog, &QColorDialog::currentColorChanged,
253
254 if (dialog.exec() == QDialog::Accepted) {
255 m_colCurrentSceneColor = dialog.currentColor();
256 } else {
258 }
259
260 //Set color of button new new scene color
261 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()));
262}
263
264//=============================================================================================================
265
267{
268 //create custom context menu and actions
269 QMenu* menu = new QMenu(this);
270 menu->setAttribute(Qt::WA_DeleteOnClose);
271
272 // Hide header
273 QAction* pHideHeader = menu->addAction(tr("Toggle header"));
274 connect(pHideHeader, &QAction::triggered,
276
277 // Remove item
278 QAction* pRemoveItem = menu->addAction(tr("Remove"));
279 connect(pRemoveItem, &QAction::triggered, [=, this]() {
280 if (QMessageBox::question(this,
281 tr("Remove item"),
282 tr("Are you sure you want to delete the item?")) == QMessageBox::Yes) {
283 onTreeViewRemoveItem(m_pUi->m_treeView_loadedData->indexAt(pos));
284 }
285 });
286
287 // QAction* pHideDesc = menu->addAction(tr("Toggle description"));
288 // connect(pHideDesc, &QAction::triggered,
289 // this, &Control3DView::onTreeViewDescriptionHide);
290
291 //show context menu
292 menu->popup(m_pUi->m_treeView_loadedData->viewport()->mapToGlobal(pos));
293}
294
295//=============================================================================================================
296
298{
299 if (state) {
300 this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
301 this->show();
302 } else {
303 this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
304 this->show();
305 }
306}
307
308//=============================================================================================================
309
310void Control3DView::onSceneColorChanged(const QColor& color)
311{
312 emit sceneColorChanged(color);
313}
314
315//=============================================================================================================
316
318{
319 emit showFullScreen(checked);
320}
321
322//=============================================================================================================
323
325{
326 emit rotationChanged(checked);
327}
328
329//=============================================================================================================
330
332{
333 emit showCoordAxis(checked);
334}
335
336//=============================================================================================================
337
339{
340 QColorDialog dialog(m_colCurrentLightColor, this);
341
342 //Update all connected View3D's light colors
343 connect(&dialog, &QColorDialog::currentColorChanged,
345
346 if (dialog.exec() == QDialog::Accepted) {
347 m_colCurrentLightColor = dialog.currentColor();
348 } else {
350 }
351
352 //Set color of button new new scene color
353 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()));
354}
355
356//=============================================================================================================
357
358void Control3DView::onLightColorChanged(const QColor& color)
359{
360 emit lightColorChanged(color);
361}
362
363//=============================================================================================================
364
366{
367 emit lightIntensityChanged(value);
368}
369
370//=============================================================================================================
371
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)
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)
Ui::Control3DViewWidget * m_pUi
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)