Adding circulating source dialog

parent 1fccc5ff
......@@ -72,6 +72,8 @@ set( Redstart_Sources
"src/RedstartSessionList.h"
"src/RedstartSessionDetailsTreeView.h"
"src/RedstartCoreOutputPlainTextEdit.h"
"src/RedstartRunCirculatingSourceDialog.h"
"src/RedstartRunCirculatingSourceDialog.cpp"
)
set( Redstart_UIs
......@@ -80,6 +82,7 @@ set( Redstart_UIs
"ui/RedstartSessionExperimentalTalkthroughDialog.ui"
"ui/RedstartSessionImportDialog.ui"
"ui/RedstartSessionWizardDialog.ui"
"ui/RedstartRunCirculatingSourceDialog.ui"
)
# Qt UI form compiler
......@@ -88,6 +91,7 @@ qt5_wrap_ui( "ui_RedstartSessionBinauralHeadphonesDialog.h" "ui/RedstartSessionB
qt5_wrap_ui( "ui_RedstartSessionExperimentalTalkthroughDialog.h" "ui/RedstartSessionExperimentalTalkthroughDialog.ui" )
qt5_wrap_ui( "ui_RedstartSessionImportDialog.h" "ui/RedstartSessionImportDialog.ui" )
qt5_wrap_ui( "ui_RedstartSessionWizardDialog.h" "ui/RedstartSessionWizardDialog.ui" )
qt5_wrap_ui( "ui_RedstartRunCirculatingSourceDialog.h" "ui/RedstartRunCirculatingSourceDialog.ui" )
include_directories( "${CMAKE_CURRENT_BINARY_DIR}" ) # Qt UI form compiler generates files into this folder
......
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2017
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#include "RedstartRunCirculatingSourceDialog.h"
#include <ui_RedstartRunCirculatingSourceDialog.h>
#include <QFileDialog>
#include <QSettings>
#include <QErrorMessage>
#include "RedstartDefaultCoreConfig.h"
#include <VA.h>
RedstartRunCirculatingSourceDialog::RedstartRunCirculatingSourceDialog( QWidget *parent )
: QDialog( parent )
, ui( new Ui::RedstartRunCirculatingSourceDialog )
, m_pVAInterface( NULL )
{
ui->setupUi( this );
QDialog::setWindowTitle( "Run circulating source" );
QSettings qSettings;
QString sLastBrowseFolder = qSettings.value( "Redstart/last_browse_folder" ).toString();
std::string s = sLastBrowseFolder.toStdString();
if( QDir( sLastBrowseFolder ).exists() )
m_oLastBasePath.setCurrent( sLastBrowseFolder );
}
RedstartRunCirculatingSourceDialog::~RedstartRunCirculatingSourceDialog()
{
if( m_oLastBasePath.exists() )
m_qSettings.setValue( "Redstart/last_browse_folder", m_oLastBasePath.absolutePath() );
delete ui;
}
void RedstartRunCirculatingSourceDialog::SetVAInterface( IVAInterface* pVA )
{
if( pVA )
m_pVAInterface = pVA;
}
void RedstartRunCirculatingSourceDialog::Start()
{
try
{
CreateScene();
StartUpdateTimer();
ui->pushButton_start->setEnabled( false );
ui->pushButton_stop->setEnabled( true );
ui->pushButton_run->setEnabled( false );
}
catch( CVAException& e )
{
QString sErrorMessage = QString( "Could not run scene: %1" ).arg( QString::fromStdString( e.ToString() ) );
QErrorMessage oErrMsg;
oErrMsg.showMessage( sErrorMessage );
oErrMsg.exec();
}
}
void RedstartRunCirculatingSourceDialog::Stop()
{
StopUpdateTimer();
ui->pushButton_start->setEnabled( true );
ui->pushButton_stop->setEnabled( false );
ui->pushButton_run->setEnabled( true );
}
void RedstartRunCirculatingSourceDialog::Run()
{
try
{
CreateScene();
StartUpdateTimer();
}
catch( CVAException& e )
{
QString sErrorMessage = QString( "Could not run scene: %1" ).arg( QString::fromStdString( e.ToString() ) );
QErrorMessage oErrMsg;
oErrMsg.showMessage( sErrorMessage );
oErrMsg.exec();
}
}
void RedstartRunCirculatingSourceDialog::on_pushButton_run_clicked()
{
Run();
accept();
}
void RedstartRunCirculatingSourceDialog::CreateScene()
{
if( !m_pVAInterface )
VA_EXCEPT2( MODAL_ERROR, "No connection to a VA core available" );
const std::string sSignalSourceID = m_pVAInterface->CreateSignalSourceBufferFromFile( ui->lineEdit_macro_DemoSound->text().toStdString() );
m_pVAInterface->SetSignalSourceBufferPlaybackAction( sSignalSourceID, IVAInterface::VA_PLAYBACK_ACTION_PLAY );
m_pVAInterface->SetSignalSourceBufferLooping( sSignalSourceID, true );
const int iSoundSourceID = m_pVAInterface->CreateSoundSource( "Redstart C++ example sound source" );
m_pVAInterface->SetSoundSourcePose( iSoundSourceID, VAVec3( 2.0f, 1.7f, 2.0f ), VAQuat( 0.0f, 0.0f, 0.0f, 1.0f ) );
m_pVAInterface->SetSoundSourceSignalSource( iSoundSourceID, sSignalSourceID );
const int iHRIR = m_pVAInterface->CreateDirectivityFromFile( ui->lineEdit_macro_DefaultHRIR->text().toStdString() );
const int iSoundReceiverID = m_pVAInterface->CreateSoundReceiver( "Redstart C++ example sound receiver" );
m_pVAInterface->SetSoundReceiverPose( iSoundReceiverID, VAVec3( 0.0f, 1.7f, 0.0f ), VAQuat( 0.0f, 0.0f, 0.0f, 1.0f ) );
m_pVAInterface->SetSoundReceiverDirectivity( iSoundReceiverID, iHRIR );
}
void RedstartRunCirculatingSourceDialog::StartUpdateTimer()
{
ui->doubleSpinBox_timeout->value();
}
void RedstartRunCirculatingSourceDialog::StopUpdateTimer()
{
}
void RedstartRunCirculatingSourceDialog::on_pushButton_BrowseDemoSound_clicked()
{
QFileDialog fd;
fd.setNameFilter( "WAV files (*.wav)" );
fd.setViewMode( QFileDialog::Detail );
if( m_oLastBasePath.exists() )
fd.setDirectory( m_oLastBasePath );
else
fd.setDirectory( QDir( QApplication::applicationDirPath() ) );
if( fd.exec() )
{
QStringList lFiles = fd.selectedFiles();
if( lFiles.empty() == false )
{
QString sFilePath = lFiles[ 0 ];
QFile oFile( sFilePath );
if( oFile.exists() )
{
m_oDemoSoundBasePath = fd.directory();
m_oLastBasePath = m_oDemoSoundBasePath;
}
ui->lineEdit_macro_DemoSound->setText( oFile.fileName() );
}
}
}
void RedstartRunCirculatingSourceDialog::on_pushButton_BrowseHRIR_clicked()
{
QFileDialog fd;
fd.setNameFilter( "DAFF files (*.daff)" );
fd.setViewMode( QFileDialog::Detail );
if( m_oLastBasePath.exists() )
fd.setDirectory( m_oLastBasePath );
else
fd.setDirectory( QDir( QApplication::applicationDirPath() ) );
if( fd.exec() )
{
QStringList lFiles = fd.selectedFiles();
if( lFiles.empty() == false )
{
QString sFilePath = lFiles[ 0 ];
QFile oFile( sFilePath );
if( oFile.exists() )
{
m_oHRIRBasePath = fd.directory();
m_oLastBasePath = m_oHRIRBasePath;
}
ui->lineEdit_macro_DefaultHRIR->setText( sFilePath );
}
}
}
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2017
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_REDSTART_RUN_CIRCULATING_SOURCE_DIALOG
#define IW_REDSTART_RUN_CIRCULATING_SOURCE_DIALOG
#include <QDialog>
#include <QDir>
#include <QString>
#include <QSettings>
#include <QHash>
class IVAInterface;
namespace Ui
{
class RedstartRunCirculatingSourceDialog;
}
class RedstartRunCirculatingSourceDialog : public QDialog
{
Q_OBJECT
public:
explicit RedstartRunCirculatingSourceDialog( QWidget *parent );
~RedstartRunCirculatingSourceDialog();
void SetVAInterface( IVAInterface* );
void Run();
void Start();
void Stop();
private slots:
void on_pushButton_BrowseDemoSound_clicked();
void on_pushButton_BrowseHRIR_clicked();
void on_pushButton_run_clicked();
private:
Ui::RedstartRunCirculatingSourceDialog* ui;
QDir m_oLastBasePath;
QDir m_oHRIRBasePath;
QDir m_oDemoSoundBasePath;
QString m_sFileBaseName;
QSettings m_qSettings;
IVAInterface* m_pVAInterface;
void CreateScene();
void StartUpdateTimer();
void StopUpdateTimer();
};
#endif // IW_REDSTART_RUN_CIRCULATING_SOURCE_DIALOG
......@@ -49,7 +49,7 @@ QVariantHash RedstartSessionBinauralHeadphonesDialog::GetCoreConfig() const
QVariantHash oPaths;
if( m_oDemoSoundBasePath.exists() )
oPaths[ "DemoSoundBasePath" ] = m_oDemoSoundBasePath.absolutePath();
if( m_oHRIRBasePath.exists() )
if( m_oHRIRBasePath.exists() && m_oHRIRBasePath != m_oDemoSoundBasePath )
oPaths[ "DefaultHRIRBasePath" ] = m_oHRIRBasePath.absolutePath();
oFinalCoreConfig[ "Paths" ] = oPaths;
......
......@@ -52,7 +52,7 @@ QVariantHash RedstartSessionExperimentalTalkthroughDialog::GetCoreConfig() const
QVariantHash oPaths;
if( m_oDemoSoundBasePath.exists() )
oPaths[ "DemoSoundBasePath" ] = m_oDemoSoundBasePath.absolutePath();
if( m_oHRIRBasePath.exists() )
if( m_oHRIRBasePath.exists() && m_oDemoSoundBasePath != m_oHRIRBasePath )
oPaths[ "DefaultHRIRBasePath" ] = m_oHRIRBasePath.absolutePath();
oFinalCoreConfig[ "Paths" ] = oPaths;
......
......@@ -28,6 +28,7 @@
#include "RedstartSessionWizardDialog.h"
#include "RedstartUtils.h"
#include "RedstartCoreOutputPlainTextEdit.h"
#include "RedstartRunCirculatingSourceDialog.h"
#include <VA.h>
#include <VACore.h>
......@@ -88,6 +89,8 @@ RedstartWindow::RedstartWindow( bool bFailSafeMode, bool bAutoStart, bool bSkipC
if( ( ui->checkBox_redstart_auto_start->isChecked() || bAutoStart ) && !bFailSafeMode )
on_pushButton_start_stop_clicked();
m_pCirculatingSourceDialog = new RedstartRunCirculatingSourceDialog( this );
}
RedstartWindow::~RedstartWindow()
......@@ -752,7 +755,12 @@ void RedstartWindow::on_actionDefault_experimental_session_triggered()
void RedstartWindow::on_actionCirculating_source_triggered()
{
if( !m_pVAInterface )
return;
m_pCirculatingSourceDialog->SetVAInterface( m_pVAInterface );
m_pCirculatingSourceDialog->exec();
m_pCirculatingSourceDialog->hide();
}
void RedstartWindow::on_actionAmbisonics_triggered()
......
......@@ -32,6 +32,7 @@
class IVAInterface;
class IVANetClient;
class IVANetServer;
class RedstartRunCirculatingSourceDialog;
namespace Ui
{
......@@ -140,10 +141,9 @@ private slots:
void on_actionDefault_experimental_session_triggered();
void on_actionRunSimpleExample_triggered();
void on_pushButton_core_control_reset_clicked();
void on_actionCirculating_source_triggered();
void on_actionCirculating_source_triggered();
void on_pushButton_core_control_reset_clicked();
void on_actionAmbisonics_triggered();
......@@ -183,6 +183,8 @@ private:
RedstartSessionListView* pSessionListModel;
RedstartRunCirculatingSourceDialog* m_pCirculatingSourceDialog;
void LoadConfiguration();
void StoreConfiguration();
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RedstartRunCirculatingSourceDialog</class>
<widget class="QDialog" name="RedstartRunCirculatingSourceDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<height>312</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="3">
<widget class="QPushButton" name="pushButton_BrowseHRIR">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_macro_DefaultHRIR">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>$(DefaultHRIR)</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Demo sound</string>
</property>
<property name="buddy">
<cstring>lineEdit_macro_DemoSound</cstring>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_BrowseDemoSound">
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_macro_DemoSound">
<property name="text">
<string>$(DemoSound)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default HRIR</string>
</property>
<property name="buddy">
<cstring>lineEdit_macro_DefaultHRIR</cstring>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="checkBox_folders_as_search_path">
<property name="text">
<string>Add all folders as search paths (instead of using absolute paths)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>seconds</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Runtime</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_runtime">
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>99999999.000000000000000</double>
</property>
<property name="value">
<double>20.000000000000000</double>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_stop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Update timeout</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_timeout">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>0.000100000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>0.001000000000000</double>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>seconds</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_start">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Azimuth increment</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Elevation increment</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_azi_inc">
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>3.600000000000000</double>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_ele_inc">
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>degrees</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>degrees</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Radius</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>meters</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_radius">
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton_run">
<property name="text">
<string>Run and close</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>pushButton_BrowseDemoSound</tabstop>
<tabstop>lineEdit_macro_DemoSound</tabstop>
<tabstop>lineEdit_macro_DefaultHRIR</tabstop>
<tabstop>checkBox_folders_as_search_path</tabstop>
<tabstop>pushButton_BrowseHRIR</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -92,8 +92,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1071</width>
<height>788</height>
<width>1085</width>
<height>736</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,2">
......@@ -987,7 +987,6 @@ background-color: rgb(208, 255, 188);</string>
</property>
<addaction name="actionRunSimpleExample"/>
<addaction name="actionCirculating_source"/>
<addaction name="actionExperimental_BRIR_switching"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment