Skip to content

Commit

Permalink
hook up view commands
Browse files Browse the repository at this point in the history
  • Loading branch information
toloudis committed May 8, 2024
1 parent 039583f commit c53aac3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
6 changes: 3 additions & 3 deletions agave_app/ViewToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ ViewToolbar::ViewToolbar(QWidget* parent)
toolbarLayout->setSpacing(0);
toolbarLayout->setContentsMargins(0, 0, 0, 0);

QPushButton* topViewButton = new QPushButton(QIcon(":/icons/topView.svg"), "", this);
topViewButton = new QPushButton(QIcon(":/icons/topView.svg"), "", this);
topViewButton->setToolTip(QString("<FONT>Top view</FONT>"));
topViewButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
topViewButton->adjustSize();
topViewButton->setFocusPolicy(Qt::NoFocus);
toolbarLayout->addWidget(topViewButton);

QPushButton* frontViewButton = new QPushButton(QIcon(":/icons/frontView.svg"), "", this);
frontViewButton = new QPushButton(QIcon(":/icons/frontView.svg"), "", this);
frontViewButton->setToolTip(QString("<FONT>Front view</FONT>"));
frontViewButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
frontViewButton->adjustSize();
frontViewButton->setFocusPolicy(Qt::NoFocus);
toolbarLayout->addWidget(frontViewButton);

QPushButton* sideViewButton = new QPushButton(QIcon(":/icons/leftView.svg"), "", this);
sideViewButton = new QPushButton(QIcon(":/icons/leftView.svg"), "", this);
sideViewButton->setToolTip(QString("<FONT>Side view</FONT>"));
sideViewButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
sideViewButton->adjustSize();
Expand Down
5 changes: 5 additions & 0 deletions agave_app/ViewToolbar.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QWidget>
#include <QPushButton>

class ViewToolbar : public QWidget
{
Expand All @@ -9,5 +10,9 @@ class ViewToolbar : public QWidget
ViewToolbar(QWidget* parent = nullptr);
virtual ~ViewToolbar();

QPushButton* topViewButton;
QPushButton* frontViewButton;
QPushButton* sideViewButton;

void positionToolbar();
};
41 changes: 40 additions & 1 deletion agave_app/agaveGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ agaveGui::agaveGui(QWidget* parent)
m_glView->setMinimumSize(256, 512);
m_glView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

// TODO can make this a custom widget that exposes the toolbar and the view
m_viewWithToolbar = new QWidget(this);
auto vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 0, 0, 0);
vlayout->addWidget(new ViewToolbar());
auto toolbar = new ViewToolbar();
connect(toolbar->topViewButton, &QPushButton::clicked, this, &agaveGui::view_top);
connect(toolbar->sideViewButton, &QPushButton::clicked, this, &agaveGui::view_side);
connect(toolbar->frontViewButton, &QPushButton::clicked, this, &agaveGui::view_front);
vlayout->addWidget(toolbar);
vlayout->addWidget(m_glView, 1);

m_viewWithToolbar->setLayout(vlayout);
Expand Down Expand Up @@ -196,6 +201,16 @@ agaveGui::createActions()
connect(m_toggleRotateControlsAction, &QAction::triggered, [this](bool checked) {
this->m_glView->toggleAreaLightRotateControls();
});

m_cameraTopViewAction = new QAction(tr("&Top view"), this);
m_cameraTopViewAction->setStatusTip(tr("Set camera to top view"));
connect(m_cameraTopViewAction, SIGNAL(triggered()), this, SLOT(view_top()));
m_cameraFrontViewAction = new QAction(tr("&Front view"), this);
m_cameraFrontViewAction->setStatusTip(tr("Set camera to front view"));
connect(m_cameraFrontViewAction, SIGNAL(triggered()), this, SLOT(view_front()));
m_cameraSideViewAction = new QAction(tr("&Side view"), this);
m_cameraSideViewAction->setStatusTip(tr("Set camera to side view"));
connect(m_cameraSideViewAction, SIGNAL(triggered()), this, SLOT(view_side()));
}

void
Expand Down Expand Up @@ -794,6 +809,30 @@ agaveGui::view_reset()
m_glView->initCameraFromImage(&m_appScene);
}

void
agaveGui::view_top()
{
m_glView->borrowRenderer()->m_CCamera.SetViewMode(ViewModeTop);
RenderSettings* rs = m_glView->borrowRenderer()->m_renderSettings;
rs->m_DirtyFlags.SetFlag(CameraDirty);
}

void
agaveGui::view_front()
{
m_glView->borrowRenderer()->m_CCamera.SetViewMode(ViewModeFront);
RenderSettings* rs = m_glView->borrowRenderer()->m_renderSettings;
rs->m_DirtyFlags.SetFlag(CameraDirty);
}

void
agaveGui::view_side()
{
m_glView->borrowRenderer()->m_CCamera.SetViewMode(ViewModeLeft);
RenderSettings* rs = m_glView->borrowRenderer()->m_renderSettings;
rs->m_DirtyFlags.SetFlag(CameraDirty);
}

void
agaveGui::view_toggleProjection()
{
Expand Down
7 changes: 7 additions & 0 deletions agave_app/agaveGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class agaveGui : public QMainWindow
// only used if vs is null
bool keepCurrentUISettings);

public slots:
void view_top();
void view_front();
void view_side();
private slots:
void open();
void openDirectory();
Expand Down Expand Up @@ -116,6 +120,9 @@ private slots:
QAction* m_sourceCodeAction = nullptr;
QAction* m_citationAction = nullptr;
QAction* m_toggleRotateControlsAction = nullptr;
QAction* m_cameraTopViewAction = nullptr;
QAction* m_cameraFrontViewAction = nullptr;
QAction* m_cameraSideViewAction = nullptr;

QSlider* createAngleSlider();
QSlider* createRangeSlider();
Expand Down

0 comments on commit c53aac3

Please sign in to comment.