Skip to content

Commit

Permalink
Merge branch 'newWorkingBase'
Browse files Browse the repository at this point in the history
  • Loading branch information
plattenschieber committed Jul 8, 2015
2 parents 9c7c86e + 4ed7227 commit 922605b
Show file tree
Hide file tree
Showing 27 changed files with 1,312 additions and 748 deletions.
62 changes: 10 additions & 52 deletions hscgv_uebung_5/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,19 @@ ApplicationWindow::ApplicationWindow()
m_frame = new GLFrame(this);
setCentralWidget(m_frame);

QActionGroup *renderModeActions = new QActionGroup(this);
renderModeActions->addAction(ui.actionCPU);
/* QActionGroup *renderModeActions = new QActionGroup(this);
renderModeActions->addAction(ui.actionGPU);
renderModeActions->addAction(ui.actionAntialiasing);
renderModeActions->addAction(ui.actionAntialiasing);*/

// connect actions
connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(fileQuit()));

connect(ui.actionResetCamera, SIGNAL(triggered()), this, SIGNAL(resetCam()));
connect(ui.actionResetLight, SIGNAL(triggered()), this, SIGNAL(resetLight()));

connect(ui.actionAnimate, SIGNAL(toggled(bool)), this, SLOT(animate(bool)));
connect(ui.actionAntialiasing, SIGNAL(toggled(bool)), SLOT(antialiasing(bool)));

connect(ui.actionCPU, SIGNAL(toggled(bool)), SLOT(renderModeChanged()));
connect(ui.actionGPU, SIGNAL(toggled(bool)), SLOT(renderModeChanged()));
connect(ui.actionAntialiasing, SIGNAL(toggled(bool)), SLOT(antialiasingChanged()));
connect(ui.actionGPU, SIGNAL(toggled(bool)), m_frame, SLOT(setRenderMode(bool)));

// ----- SIGNALS -----

Expand All @@ -57,7 +54,7 @@ ApplicationWindow::ApplicationWindow()
connect(ui.actionLoadFile, SIGNAL(triggered()), this, SLOT(loadFile()));
connect(this, SIGNAL(openFile(const QString&)), m_frame, SLOT(loadScene(const QString&)));

connect(this, SIGNAL(renderMode(int)), m_frame, SLOT(setRenderMode(int)));
connect(this, SIGNAL(renderMode(bool)), m_frame, SLOT(setRenderMode(bool)));

// timer for updating fps display
QTimer *timer = new QTimer(this);
Expand All @@ -67,10 +64,8 @@ ApplicationWindow::ApplicationWindow()

// timer for continuous rendering
m_trigger = new QTimer(this);
m_trigger->setInterval(1); // every ms
connect(m_trigger, SIGNAL(timeout()), m_frame, SLOT(updateGL()));

initState();
m_trigger->start();

// load standard scene
// if(qApp->argc() > 1)
Expand All @@ -79,17 +74,6 @@ ApplicationWindow::ApplicationWindow()
// loadFile("REF1.data");
}

void ApplicationWindow::initState() const
{
// trigger toggles the action's state

ui.actionAnimate->setChecked(true);
ui.actionAnimate->trigger();

ui.actionCPU->trigger();
}


// destroy the application window
ApplicationWindow::~ApplicationWindow()
{
Expand All @@ -112,19 +96,14 @@ void ApplicationWindow::updateMessage(const QString& message)
statusBar()->showMessage(message);
}


void ApplicationWindow::updateFps()
{
static int oldFrames = 0;
m_secondsToDisplay--;
int frames = m_frame->frameCounter() - oldFrames;
oldFrames = m_frame->frameCounter();

if(m_secondsToDisplay >= 0)
statusBar()->showMessage(m_message);
else if(frames > 0)
statusBar()->showMessage(QString::number(frames) + " f/s");
else
statusBar()->showMessage("Use mouse buttons and wheel to move camera, hold shift to move light");
statusBar()->showMessage(QString::number(frames) + " f/s");
}

void ApplicationWindow::loadFile()
Expand All @@ -148,30 +127,9 @@ void ApplicationWindow::loadFile(QString filename)
emit openFile(filename);
}

void ApplicationWindow::animate(bool on)
void ApplicationWindow::antialiasing(bool on)
{
if(on)
m_trigger->start();
else
m_trigger->stop();
m_frame->m_antialiasing = on;
}


int ApplicationWindow::getRenderMode() const
{
if(ui.actionCPU->isChecked())
return GLFrame::CPU;
else //if(ui.actionGPU->isChecked())
return GLFrame::GPU;
}

void ApplicationWindow::renderModeChanged() const
{
emit renderMode(getRenderMode());
}

void ApplicationWindow::antialiasingChanged() const
{
// TODO: change to appropriate antialiasing set method
emit renderMode(getRenderMode());
}
17 changes: 3 additions & 14 deletions hscgv_uebung_5/ApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ class ApplicationWindow : public QMainWindow
void openFile(const QString &filename) const;

//! render mode was changed
void renderMode(int mode) const;
void renderMode(bool mode) const;

protected:
//! initialize application state
void initState() const;

//! our main widget in the application is a OGLCanvas
GLFrame *m_frame;

Expand Down Expand Up @@ -93,17 +90,9 @@ class ApplicationWindow : public QMainWindow
//! update FPS display
void updateFps();

//! start and stop render timer
void animate(bool on);

//! deduce render mode from menu state
int getRenderMode() const;

//! make sure that render mode signal is triggerd
void renderModeChanged() const;

//! we want to have some nice output
void antialiasingChanged() const;
void antialiasing(bool on);


private:
//! store status bar message
Expand Down
17 changes: 5 additions & 12 deletions hscgv_uebung_5/ApplicationWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Aufgabe 1: &quot;Ui, OpenGL!&quot;</string>
<string>Aufgabe 5: &quot;Jeros CUDA Realtime Raytracer!&quot;</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
Expand All @@ -21,7 +21,7 @@
<x>0</x>
<y>0</y>
<width>520</width>
<height>22</height>
<height>18</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand All @@ -36,18 +36,13 @@
<property name="title">
<string>View</string>
</property>
<addaction name="actionResetCamera"/>
<addaction name="actionResetLight"/>
<addaction name="separator"/>
<addaction name="actionAnimate"/>
</widget>
<widget class="QMenu" name="menuRendering">
<property name="title">
<string>Rendering</string>
</property>
<addaction name="actionCPU"/>
<addaction name="actionGPU"/>
<addaction name="separator"/>
<addaction name="actionAntialiasing"/>
</widget>
<addaction name="menuFile"/>
Expand Down Expand Up @@ -116,12 +111,10 @@
<enum>QAction::TextHeuristicRole</enum>
</property>
</action>
<action name="actionCPU">
<property name="text">
<string>CPU</string>
</property>
</action>
<action name="actionGPU">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>GPU</string>
</property>
Expand Down
Loading

0 comments on commit 922605b

Please sign in to comment.