Skip to content

Commit ab4f77f

Browse files
committed
Improve view scene dialog handling
1 parent 43a1f3d commit ab4f77f

File tree

6 files changed

+35
-44
lines changed

6 files changed

+35
-44
lines changed

src/Interface/Modules/Render/GLWidget.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
/// \author James Hughes
3030
/// \date September 2012
31-
/// \brief Not sure this file should go in Modules/Render. But it is an
31+
/// \brief Not sure this file should go in Modules/Render. But it is an
3232
/// auxiliary file to the ViewScene render module.
3333

3434
#include <Interface/Modules/Render/GLWidget.h>
@@ -45,8 +45,8 @@ namespace Gui {
4545
const int RendererUpdateInMS = 35;
4646

4747
//------------------------------------------------------------------------------
48-
GLWidget::GLWidget(QtGLContext* context) :
49-
QGLWidget(context),
48+
GLWidget::GLWidget(QtGLContext* context, QWidget* parent) :
49+
QGLWidget(context, parent),
5050
mContext(new GLContext(this)),
5151
mCurrentTime(0.0)
5252
{
@@ -58,7 +58,7 @@ GLWidget::GLWidget(QtGLContext* context) :
5858

5959
// Call gl platform init.
6060
CPM_GL_PLATFORM_NS::glPlatformInit();
61-
61+
6262
auto shadersInBinDirectory = SCIRun::Core::Application::Instance().executablePath() / "Shaders";
6363
shaderSearchDirs.push_back(shadersInBinDirectory.string());
6464

@@ -98,7 +98,7 @@ SCIRun::Render::SRInterface::MouseButton GLWidget::getSpireButton(QMouseEvent* e
9898
btn = Render::SRInterface::MOUSE_RIGHT;
9999
else if (event->buttons() & Qt::MidButton)
100100
btn = Render::SRInterface::MOUSE_MIDDLE;
101-
101+
102102
return btn;
103103
}
104104

@@ -167,4 +167,3 @@ void GLWidget::updateRenderer()
167167

168168
} // namespace Gui
169169
} // namespace SCIRun
170-

src/Interface/Modules/Render/GLWidget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
/// \author James Hughes
3030
/// \date September 2012
31-
/// \brief Not sure this file should go in Modules/Render. But it is an
31+
/// \brief Not sure this file should go in Modules/Render. But it is an
3232
/// auxiliary file to the ViewScene render module.
3333

3434
#ifndef INTERFACE_MODULES_GLWIDGET_H
@@ -58,7 +58,7 @@ class GLWidget : public QGLWidget
5858
Q_OBJECT
5959

6060
public:
61-
GLWidget(QtGLContext* context);
61+
GLWidget(QtGLContext* context, QWidget* parent);
6262
~GLWidget();
6363

6464
std::shared_ptr<Render::SRInterface> getSpire() const {return mGraphics;}
@@ -81,7 +81,7 @@ public Q_SLOTS:
8181
void updateRenderer();
8282

8383
private:
84-
84+
8585
/// Retrieve SRInterface mouse button from mouse event.
8686
Render::SRInterface::MouseButton getSpireButton(QMouseEvent* event);
8787

src/Interface/Modules/Render/ViewScene.cc

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ using namespace SCIRun::Render;
4646
//------------------------------------------------------------------------------
4747
ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle state,
4848
QWidget* parent /* = 0 */)
49-
: ModuleDialogGeneric(state, parent), shown_(false), itemManager_(new ViewSceneItemManager)
49+
: ModuleDialogGeneric(state, parent), mConfigurationDock(0), shown_(false),
50+
itemManager_(new ViewSceneItemManager)
5051
{
5152
setupUi(this);
5253
setWindowTitle(QString::fromStdString(name));
@@ -63,7 +64,7 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat
6364
fmt.setDoubleBuffer(true);
6465
fmt.setDepthBufferSize(24);
6566

66-
mGLWidget = new GLWidget(new QtGLContext(fmt));
67+
mGLWidget = new GLWidget(new QtGLContext(fmt), parentWidget());
6768

6869
if (mGLWidget->isValid())
6970
{
@@ -96,26 +97,18 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat
9697

9798
state->connect_state_changed(boost::bind(&ViewSceneDialog::newGeometryValueForwarder, this));
9899
connect(this, SIGNAL(newGeometryValueForwarder()), this, SLOT(newGeometryValue()));
99-
100-
addConfigurationDock(QString::fromStdString(name));
101100
}
102101

103-
//------------------------------------------------------------------------------
104-
ViewSceneDialog::~ViewSceneDialog()
105-
{
106-
}
107-
108-
//------------------------------------------------------------------------------
109102
void ViewSceneDialog::closeEvent(QCloseEvent *evt)
110103
{
111104
// NOTE: At one point this was required because the renderer was
112105
// multi-threaded. It is likely we will run into the same issue in the
113106
// future. Kept for future reference.
114107
//glLayout->removeWidget(mGLWidget);
115108
mGLWidget->close();
109+
ModuleDialogGeneric::closeEvent(evt);
116110
}
117111

118-
//------------------------------------------------------------------------------
119112
void ViewSceneDialog::newGeometryValue()
120113
{
121114
LOG_DEBUG("ViewSceneDialog::asyncExecute before locking");
@@ -371,6 +364,9 @@ void ViewSceneDialog::lookDownAxisZ(int upIndex, glm::vec3& up)
371364
//------------------------------------------------------------------------------
372365
void ViewSceneDialog::configurationButtonClicked()
373366
{
367+
if (!mConfigurationDock)
368+
addConfigurationDock(windowTitle());
369+
374370
showConfiguration_ = !mConfigurationDock->isVisible();
375371
mConfigurationDock->setEnabled(showConfiguration_);
376372
mConfigurationDock->setVisible(showConfiguration_);
@@ -441,7 +437,7 @@ void ViewSceneDialog::addObjectToggleMenu()
441437

442438
void ViewSceneDialog::addViewBarButton()
443439
{
444-
QPushButton* viewBarBtn = new QPushButton(this);
440+
QPushButton* viewBarBtn = new QPushButton();
445441
viewBarBtn->setToolTip("Show View Options");
446442
viewBarBtn->setText("Views");
447443
viewBarBtn->setAutoDefault(false);
@@ -499,7 +495,7 @@ void ViewSceneDialog::addViewOptions()
499495

500496
void ViewSceneDialog::addConfigurationButton()
501497
{
502-
QPushButton* configurationButton = new QPushButton(this);
498+
QPushButton* configurationButton = new QPushButton();
503499
configurationButton->setToolTip("Open/Close Configuration Menu");
504500
configurationButton->setText("Configure");
505501
configurationButton->setAutoDefault(false);
@@ -513,34 +509,37 @@ void ViewSceneDialog::addConfigurationDock(const QString& viewName)
513509
{
514510
QString name = viewName + " Configuration";
515511
mConfigurationDock = new ViewSceneControlsDock(name, this);
516-
mConfigurationDock->close();
512+
mConfigurationDock->setVisible(false);
517513

518514
showConfiguration_ = false;
519515
}
520516

521-
void ViewSceneDialog::closeConfigurationDock()
517+
void ViewSceneDialog::hideConfigurationDock()
522518
{
523-
showConfiguration_ = mConfigurationDock->isVisible();
524-
if (showConfiguration_)
525-
{
526-
configurationButtonClicked();
527-
}
519+
if (mConfigurationDock)
520+
{
521+
showConfiguration_ = mConfigurationDock->isVisible();
522+
if (showConfiguration_)
523+
{
524+
configurationButtonClicked();
525+
}
526+
}
528527
}
529528

530529
void ViewSceneDialog::showEvent(QShowEvent* evt)
531530
{
532-
ModuleDialogGeneric::showEvent(evt);
533531
if (!shown_)
534532
{
535533
autoViewClicked();
536534
shown_ = true;
537535
}
536+
ModuleDialogGeneric::showEvent(evt);
538537
}
539538

540539
void ViewSceneDialog::hideEvent(QHideEvent* evt)
541540
{
542-
ModuleDialogGeneric::hideEvent(evt);
543-
closeConfigurationDock();
541+
hideConfigurationDock();
542+
ModuleDialogGeneric::hideEvent(evt);
544543
}
545544

546545
ViewSceneItemManager::ViewSceneItemManager() : model_(new QStandardItemModel(3, 1))

src/Interface/Modules/Render/ViewScene.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ namespace SCIRun {
6868
ViewSceneDialog(const std::string& name,
6969
SCIRun::Dataflow::Networks::ModuleStateHandle state,
7070
QWidget* parent = 0);
71-
~ViewSceneDialog();
7271
virtual void pull() {}
7372

7473
Q_SIGNALS:
@@ -99,7 +98,7 @@ namespace SCIRun {
9998
void addViewOptions();
10099
void addConfigurationButton();
101100
void addConfigurationDock(const QString& viewName);
102-
void closeConfigurationDock();
101+
void hideConfigurationDock();
103102

104103
void lookDownAxisX(int upIndex, glm::vec3& up);
105104
void lookDownAxisY(int upIndex, glm::vec3& up);

src/Interface/Modules/Render/ViewSceneControlsDock.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ using namespace SCIRun::Render;
3636
ViewSceneControlsDock::ViewSceneControlsDock(const QString& name, ViewSceneDialog* parent) : QDockWidget(parent)
3737
{
3838
setupUi(this);
39-
//scene_ = parent;
4039

41-
close();
4240
setWindowTitle(name);
4341
setAllowedAreas(Qt::BottomDockWidgetArea);
4442
setFloating(true);
4543
setVisible(false);
4644
setEnabled(false);
45+
setStyleSheet(parent->styleSheet());
4746

4847
parent->menuMouseControlChanged(mouseControlComboBox_->currentIndex());
4948

@@ -56,14 +55,10 @@ ViewSceneControlsDock::ViewSceneControlsDock(const QString& name, ViewSceneDialo
5655
WidgetStyleMixin::tabStyle(tabWidget);
5756
}
5857

59-
ViewSceneControlsDock::~ViewSceneControlsDock()
60-
{
61-
}
62-
63-
void ViewSceneControlsDock::setSampleColor(QColor color)
58+
void ViewSceneControlsDock::setSampleColor(const QColor& color)
6459
{
6560
QString styleSheet = "QLabel{ background: rgb(" + QString::number(color.red()) + "," +
6661
QString::number(color.green()) + "," + QString::number(color.blue()) + "); }";
67-
62+
6863
currentBackgroundLabel_->setStyleSheet(styleSheet);
6964
}

src/Interface/Modules/Render/ViewSceneControlsDock.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ namespace SCIRun {
5151

5252
public:
5353
ViewSceneControlsDock(const QString& name, ViewSceneDialog* parent);
54-
~ViewSceneControlsDock();
5554

56-
void setSampleColor(QColor color);
55+
void setSampleColor(const QColor& color);
5756

5857
private:
5958
//ViewSceneDialog* scene_;

0 commit comments

Comments
 (0)