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),
104 connect(m_pUi->m_checkBox_showFullScreen, &QCheckBox::clicked,
106
107 connect(m_pUi->m_checkBox_rotate, &QCheckBox::clicked,
109
110 connect(m_pUi->m_checkBox_coordAxis, &QCheckBox::clicked,
112
113 connect(m_pUi->m_pushButton_takeScreenshot, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
115
116 connect(m_pUi->m_radioButton_single, &QRadioButton::pressed,
118
119 connect(m_pUi->m_radioButton_multi, &QRadioButton::pressed,
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),
130 connect(m_pUi->m_doubleSpinBox_colorIntensity, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
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* pDialog = new QColorDialog(this);
249 pDialog->setCurrentColor(m_colCurrentSceneColor);
250
251 //Update all connected View3D's scene colors
252 connect(pDialog, &QColorDialog::currentColorChanged,
254
255 pDialog->exec();
256 m_colCurrentSceneColor = pDialog->currentColor();
257
258 //Set color of button new new scene color
259 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()));
260}
261
262//=============================================================================================================
263
265{
266 //create custom context menu and actions
267 QMenu *menu = new QMenu(this);
268
269 // Hide header
270 QAction* pHideHeader = menu->addAction(tr("Toggle header"));
271 connect(pHideHeader, &QAction::triggered,
273
274 // Remove item
275 QAction* pRemoveItem = menu->addAction(tr("Remove"));
276 connect(pRemoveItem, &QAction::triggered, [=, this]() {
277 if (QMessageBox::question(this,
278 tr("Remove item"),
279 tr("Are you sure you want to delete the item?")) == QMessageBox::Yes) {
280 onTreeViewRemoveItem(m_pUi->m_treeView_loadedData->indexAt(pos));
281 }
282 });
283
284// QAction* pHideDesc = menu->addAction(tr("Toggle description"));
285// connect(pHideDesc, &QAction::triggered,
286// this, &Control3DView::onTreeViewDescriptionHide);
287
288 //show context menu
289 menu->popup(m_pUi->m_treeView_loadedData->viewport()->mapToGlobal(pos));
290}
291
292//=============================================================================================================
293
295{
296 if(state) {
297 this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
298 this->show();
299 } else {
300 this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
301 this->show();
302 }
303}
304
305//=============================================================================================================
306
307void Control3DView::onSceneColorChanged(const QColor& color)
308{
309 emit sceneColorChanged(color);
310}
311
312//=============================================================================================================
313
315{
316 emit showFullScreen(checked);
317}
318
319//=============================================================================================================
320
322{
323 emit rotationChanged(checked);
324}
325
326//=============================================================================================================
327
329{
330 emit showCoordAxis(checked);
331}
332
333//=============================================================================================================
334
336{
337 QColorDialog* pDialog = new QColorDialog(this);
338 pDialog->setCurrentColor(m_colCurrentLightColor);
339
340 //Update all connected View3D's scene colors
341 connect(pDialog, &QColorDialog::currentColorChanged,
343
344 pDialog->exec();
345 m_colCurrentLightColor = pDialog->currentColor();
346
347 //Set color of button new new scene color
348 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()));
349}
350
351//=============================================================================================================
352
353void Control3DView::onLightColorChanged(const QColor &color)
354{
355 emit lightColorChanged(color);
356}
357
358//=============================================================================================================
359
361{
362 emit lightIntensityChanged(value);
363}
364
365//=============================================================================================================
366
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)
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)