2011-06-05 14:45:39 +00:00
/*
* Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke
*
* This file is part of RTAB-Map.
*
* RTAB-Map is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RTAB-Map is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RTAB-Map. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rtabmap/gui/PreferencesDialog.h"
2012-12-11 18:05:05 +00:00
#include "rtabmap/gui/DatabaseViewer.h"
2013-12-11 00:12:44 +00:00
#include "rtabmap/gui/OdometryViewer.h"
2011-06-05 14:45:39 +00:00
#include <QtCore/QSettings>
#include <QtCore/QDir>
2013-12-11 00:12:44 +00:00
#include <QtCore/QTimer>
2011-06-05 14:45:39 +00:00
#include <QtGui/QFileDialog>
#include <QtGui/QMessageBox>
#include <QtGui/QStandardItemModel>
#include <QtGui/QMainWindow>
#include <QtGui/QProgressDialog>
2012-12-11 18:05:05 +00:00
#include <QtGui/QScrollBar>
2013-12-11 00:12:44 +00:00
#include <QtGui/QCloseEvent>
2011-06-05 14:45:39 +00:00
#include "ui_preferencesDialog.h"
2013-12-11 00:12:44 +00:00
2011-06-05 14:45:39 +00:00
#include "rtabmap/core/Rtabmap.h"
#include "rtabmap/core/Parameters.h"
2013-12-11 00:12:44 +00:00
#include "rtabmap/core/Odometry.h"
#include "rtabmap/core/CameraOpenni.h"
2014-06-03 04:42:08 +00:00
#include "rtabmap/core/CameraFreenect.h"
2013-12-11 00:12:44 +00:00
#include "rtabmap/core/Memory.h"
#include "rtabmap/gui/LoopClosureViewer.h"
2013-04-30 20:16:01 +00:00
#include <rtabmap/utilite/ULogger.h>
#include <rtabmap/utilite/UConversion.h>
#include <rtabmap/utilite/UStl.h>
2013-12-11 00:12:44 +00:00
#include <rtabmap/utilite/UEventsManager.h>
#include "utilite/UPlot.h"
2011-06-05 14:45:39 +00:00
2013-12-14 02:43:26 +00:00
#include <opencv2/gpu/gpu.hpp>
2011-06-05 14:45:39 +00:00
using namespace rtabmap ;
namespace rtabmap {
PreferencesDialog :: PreferencesDialog ( QWidget * parent ) :
QDialog ( parent ),
_obsoletePanels ( kPanelDummy ),
_ui ( 0 ),
_indexModel ( 0 ),
2013-12-11 00:12:44 +00:00
_initialized ( false ),
2014-06-03 04:42:08 +00:00
_odomCameraOpenNI ( 0 ),
_odomCameraFreenect ( 0 ),
2013-12-11 00:12:44 +00:00
_odomThread ( 0 )
2011-06-05 14:45:39 +00:00
{
ULOGGER_DEBUG ( "" );
_ui = new Ui_preferencesDialog ();
_ui -> setupUi ( this );
2013-12-14 02:43:26 +00:00
if ( cv :: gpu :: getCudaEnabledDeviceCount () == 0 )
{
_ui -> surf_checkBox_gpuVersion -> setEnabled ( false );
_ui -> label_surf_checkBox_gpuVersion -> setEnabled ( false );
}
2014-02-13 21:32:46 +00:00
2011-06-05 14:45:39 +00:00
_ui -> predictionPlot -> showLegend ( false );
2013-12-11 00:12:44 +00:00
QButtonGroup * buttonGroup = new QButtonGroup ( this );
buttonGroup -> addButton ( _ui -> radioButton_basic );
buttonGroup -> addButton ( _ui -> radioButton_advanced );
2011-06-05 14:45:39 +00:00
// Connect
connect ( _ui -> buttonBox_global , SIGNAL ( clicked ( QAbstractButton * )), this , SLOT ( closeDialog ( QAbstractButton * )));
connect ( _ui -> buttonBox_local , SIGNAL ( clicked ( QAbstractButton * )), this , SLOT ( resetApply ( QAbstractButton * )));
connect ( _ui -> pushButton_loadConfig , SIGNAL ( clicked ()), this , SLOT ( loadConfigFrom ()));
connect ( _ui -> pushButton_saveConfig , SIGNAL ( clicked ()), this , SLOT ( saveConfigTo ()));
2014-01-22 19:49:28 +00:00
connect ( _ui -> pushButton_resetConfig , SIGNAL ( clicked ()), this , SLOT ( resetConfig ()));
2012-03-03 01:46:30 +00:00
connect ( _ui -> radioButton_basic , SIGNAL ( toggled ( bool )), this , SLOT ( setupTreeView ()));
2014-04-02 15:51:02 +00:00
connect ( _ui -> pushButton_testOdometry , SIGNAL ( clicked ()), this , SLOT ( testOdometry ()));
2011-06-05 14:45:39 +00:00
// General panel
connect ( _ui -> general_checkBox_imagesKept , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
connect ( _ui -> checkBox_verticalLayoutUsed , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
connect ( _ui -> checkBox_imageFlipped , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
connect ( _ui -> checkBox_imageRejectedShown , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
2012-03-03 01:46:30 +00:00
connect ( _ui -> checkBox_imageHighestHypShown , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
2011-06-05 14:45:39 +00:00
connect ( _ui -> checkBox_beep , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
connect ( _ui -> horizontalSlider_keypointsOpacity , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteGeneralPanel ()));
2013-12-11 00:12:44 +00:00
// Cloud rendering panel
_3dRenderingShowClouds . resize ( 3 );
_3dRenderingShowClouds [ 0 ] = _ui -> checkBox_showClouds ;
_3dRenderingShowClouds [ 1 ] = _ui -> checkBox_showOdomClouds ;
_3dRenderingShowClouds [ 2 ] = _ui -> checkBox_showSaveClouds ;
_3dRenderingVoxelSize . resize ( 3 );
_3dRenderingVoxelSize [ 0 ] = _ui -> doubleSpinBox_voxelSize ;
_3dRenderingVoxelSize [ 1 ] = _ui -> doubleSpinBox_voxelSize_odom ;
_3dRenderingVoxelSize [ 2 ] = _ui -> doubleSpinBox_voxelSize_save ;
_3dRenderingDecimation . resize ( 3 );
_3dRenderingDecimation [ 0 ] = _ui -> spinBox_decimation ;
_3dRenderingDecimation [ 1 ] = _ui -> spinBox_decimation_odom ;
_3dRenderingDecimation [ 2 ] = _ui -> spinBox_decimation_save ;
_3dRenderingMaxDepth . resize ( 3 );
_3dRenderingMaxDepth [ 0 ] = _ui -> doubleSpinBox_maxDepth ;
_3dRenderingMaxDepth [ 1 ] = _ui -> doubleSpinBox_maxDepth_odom ;
_3dRenderingMaxDepth [ 2 ] = _ui -> doubleSpinBox_maxDepth_save ;
_3dRenderingOpacity . resize ( 2 );
_3dRenderingOpacity [ 0 ] = _ui -> doubleSpinBox_opacity ;
_3dRenderingOpacity [ 1 ] = _ui -> doubleSpinBox_opacity_odom ;
_3dRenderingPtSize . resize ( 2 );
_3dRenderingPtSize [ 0 ] = _ui -> spinBox_ptsize ;
_3dRenderingPtSize [ 1 ] = _ui -> spinBox_ptsize_odom ;
_3dRenderingShowScans . resize ( 3 );
_3dRenderingShowScans [ 0 ] = _ui -> checkBox_showScans ;
_3dRenderingShowScans [ 1 ] = _ui -> checkBox_showOdomScans ;
_3dRenderingShowScans [ 2 ] = _ui -> checkBox_showSaveScans ;
_3dRenderingOpacityScan . resize ( 2 );
_3dRenderingOpacityScan [ 0 ] = _ui -> doubleSpinBox_opacity_scan ;
_3dRenderingOpacityScan [ 1 ] = _ui -> doubleSpinBox_opacity_odom_scan ;
_3dRenderingPtSizeScan . resize ( 2 );
_3dRenderingPtSizeScan [ 0 ] = _ui -> spinBox_ptsize_scan ;
_3dRenderingPtSizeScan [ 1 ] = _ui -> spinBox_ptsize_odom_scan ;
_3dRenderingMeshing . resize ( 1 );
_3dRenderingMeshing [ 0 ] = _ui -> checkBox_meshing ;
2014-06-03 19:28:59 +00:00
_3dRenderingNormalKSearch . resize ( 2 );
_3dRenderingNormalKSearch [ 0 ] = _ui -> spinBox_normalKSearch ;
_3dRenderingNormalKSearch [ 1 ] = _ui -> spinBox_normalKSearch_save ;
_3dRenderingGP3Radius . resize ( 2 );
_3dRenderingGP3Radius [ 0 ] = _ui -> doubleSpinBox_gp3Radius ;
_3dRenderingGP3Radius [ 1 ] = _ui -> doubleSpinBox_gp3Radius_save ;
_3dRenderingSmoothing . resize ( 2 );
_3dRenderingSmoothing [ 0 ] = _ui -> checkBox_mls ;
_3dRenderingSmoothing [ 1 ] = _ui -> checkBox_mls_save ;
_3dRenderingSmoothingRadius . resize ( 2 );
_3dRenderingSmoothingRadius [ 0 ] = _ui -> doubleSpinBox_mlsRadius ;
_3dRenderingSmoothingRadius [ 1 ] = _ui -> doubleSpinBox_mlsRadius_save ;
2013-12-11 00:12:44 +00:00
for ( int i = 0 ; i < 3 ; ++ i )
{
connect ( _3dRenderingShowClouds [ i ], SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingVoxelSize [ i ], SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingDecimation [ i ], SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingMaxDepth [ i ], SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingShowScans [ i ], SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
if ( i < 2 )
{
connect ( _3dRenderingOpacity [ i ], SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingPtSize [ i ], SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingOpacityScan [ i ], SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingPtSizeScan [ i ], SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
2014-06-03 19:28:59 +00:00
connect ( _3dRenderingNormalKSearch [ i ], SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingGP3Radius [ i ], SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingSmoothing [ i ], SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _3dRenderingSmoothingRadius [ i ], SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
2013-12-11 00:12:44 +00:00
}
if ( i < 1 )
{
connect ( _3dRenderingMeshing [ i ], SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
}
}
2014-02-13 21:32:46 +00:00
connect ( _ui -> groupBox_poseFiltering , SIGNAL ( clicked ( bool )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _ui -> doubleSpinBox_cloudFilterRadius , SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
connect ( _ui -> doubleSpinBox_cloudFilterAngle , SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteCloudRenderingPanel ()));
2013-12-11 00:12:44 +00:00
//Logging panel
connect ( _ui -> comboBox_loggerLevel , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( makeObsoleteLoggingPanel ()));
connect ( _ui -> comboBox_loggerEventLevel , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( makeObsoleteLoggingPanel ()));
connect ( _ui -> comboBox_loggerPauseLevel , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( makeObsoleteLoggingPanel ()));
connect ( _ui -> checkBox_logger_printTime , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteLoggingPanel ()));
connect ( _ui -> comboBox_loggerType , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( makeObsoleteLoggingPanel ()));
2011-06-05 14:45:39 +00:00
//Source panel
connect ( _ui -> general_doubleSpinBox_imgRate , SIGNAL ( valueChanged ( double )), this , SLOT ( makeObsoleteSourcePanel ()));
2012-06-24 17:19:34 +00:00
//Image source
connect ( _ui -> groupBox_sourceImage , SIGNAL ( toggled ( bool )), this , SLOT ( makeObsoleteSourcePanel ()));
_ui -> stackedWidget_image -> setCurrentIndex ( _ui -> source_comboBox_image_type -> currentIndex ());
connect ( _ui -> source_comboBox_image_type , SIGNAL ( currentIndexChanged ( int )), _ui -> stackedWidget_image , SLOT ( setCurrentIndex ( int )));
connect ( _ui -> source_comboBox_image_type , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2011-06-05 14:45:39 +00:00
connect ( _ui -> general_checkBox_autoRestart , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2012-03-03 01:46:30 +00:00
connect ( _ui -> general_checkBox_cameraKeypoints , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2011-06-05 14:45:39 +00:00
//usbDevice group
connect ( _ui -> source_usbDevice_spinBox_id , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
connect ( _ui -> source_spinBox_imgWidth , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
connect ( _ui -> source_spinBox_imgheight , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2012-06-24 17:19:34 +00:00
connect ( _ui -> source_spinBox_framesDropped , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2011-06-05 14:45:39 +00:00
//images group
2012-06-24 17:19:34 +00:00
connect ( _ui -> source_images_toolButton_selectSource , SIGNAL ( clicked ()), this , SLOT ( selectSourceImage ()));
2011-06-05 14:45:39 +00:00
connect ( _ui -> source_images_lineEdit_path , SIGNAL ( textChanged ( const QString & )), this , SLOT ( makeObsoleteSourcePanel ()));
connect ( _ui -> source_images_spinBox_startPos , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
connect ( _ui -> source_images_refreshDir , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
//video group
2012-06-24 17:19:34 +00:00
connect ( _ui -> source_video_toolButton_selectSource , SIGNAL ( clicked ()), this , SLOT ( selectSourceImage ()));
2011-06-05 14:45:39 +00:00
connect ( _ui -> source_video_lineEdit_path , SIGNAL ( textChanged ( const QString & )), this , SLOT ( makeObsoleteSourcePanel ()));
//database group
2012-06-24 17:19:34 +00:00
connect ( _ui -> source_database_toolButton_selectSource , SIGNAL ( clicked ()), this , SLOT ( selectSourceDatabase ()));
2012-12-11 18:05:05 +00:00
connect ( _ui -> toolButton_dbViewer , SIGNAL ( clicked ()), this , SLOT ( openDatabaseViewer ()));
2012-06-24 17:19:34 +00:00
connect ( _ui -> groupBox_sourceDatabase , SIGNAL ( toggled ( bool )), this , SLOT ( makeObsoleteSourcePanel ()));
2012-12-11 18:05:05 +00:00
connect ( _ui -> source_database_lineEdit_path , SIGNAL ( textChanged ( const QString & )), this , SLOT ( makeObsoleteSourcePanel ()));
2013-12-11 00:12:44 +00:00
connect ( _ui -> source_checkBox_ignoreOdometry , SIGNAL ( stateChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2012-12-11 18:05:05 +00:00
connect ( _ui -> source_spinBox_databaseStartPos , SIGNAL ( valueChanged ( int )), this , SLOT ( makeObsoleteSourcePanel ()));
2013-12-11 00:12:44 +00:00
//openni group
connect ( _ui -> groupBox_sourceOpenni , SIGNAL ( toggled ( bool )), this , SLOT ( makeObsoleteSourcePanel ()));
2014-06-03 04:42:08 +00:00
connect ( _ui -> radioButton_openni , SIGNAL ( toggled ( bool )), this , SLOT ( makeObsoleteSourcePanel ()));
connect ( _ui -> radioButton_freenect , SIGNAL ( toggled ( bool )), this , SLOT ( makeObsoleteSourcePanel ()));
2013-12-11 00:12:44 +00:00
connect ( _ui -> lineEdit_openniDevice , SIGNAL ( textChanged ( const QString & )), this , SLOT ( makeObsoleteSourcePanel ()));
connect ( _ui -> lineEdit_openniLocalTransform , SIGNAL ( textChanged ( const QString & )), this , SLOT ( makeObsoleteSourcePanel ()));
2011-06-05 14:45:39 +00:00
2012-03-03 01:46:30 +00:00
//Rtabmap basic
connect ( _ui -> general_doubleSpinBox_timeThr , SIGNAL ( valueChanged ( double )), _ui -> general_doubleSpinBox_timeThr_2 , SLOT ( setValue ( double )));
connect ( _ui -> general_doubleSpinBox_hardThr , SIGNAL ( valueChanged ( double )), _ui -> general_doubleSpinBox_hardThr_2 , SLOT ( setValue ( double )));
2012-12-11 18:05:05 +00:00
connect ( _ui -> doubleSpinBox_similarityThreshold , SIGNAL ( valueChanged ( double )), _ui -> doubleSpinBox_similarityThreshold_2 , SLOT ( setValue ( double )));
2013-12-11 00:12:44 +00:00
connect ( _ui -> general_doubleSpinBox_detectionRate , SIGNAL ( valueChanged ( double )), _ui -> general_doubleSpinBox_detectionRate_2 , SLOT ( setValue ( double )));
2012-03-03 01:46:30 +00:00
connect ( _ui -> general_spinBox_imagesBufferSize , SIGNAL ( valueChanged ( int )), _ui -> general_spinBox_imagesBufferSize_2 , SLOT ( setValue ( int )));
2012-06-24 17:19:34 +00:00
connect ( _ui -> general_spinBox_maxStMemSize , SIGNAL ( valueChanged ( int )), _ui -> general_spinBox_maxStMemSize_2 , SLOT ( setValue ( int )));
2013-12-11 00:12:44 +00:00
connect ( _ui -> lineEdit_databasePath , SIGNAL ( textChanged ( const QString & )), _ui -> lineEdit_databasePath_2 , SLOT ( setText ( const QString & )));
2012-03-03 01:46:30 +00:00
2012-06-24 17:19:34 +00:00
connect ( _ui -> general_doubleSpinBox_timeThr_2 , SIGNAL ( editingFinished ()), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_doubleSpinBox_hardThr_2 , SIGNAL ( editingFinished ()), this , SLOT ( updateBasicParameter ()));
2012-12-11 18:05:05 +00:00
connect ( _ui -> doubleSpinBox_similarityThreshold_2 , SIGNAL ( editingFinished ()), this , SLOT ( updateBasicParameter ()));
2013-12-11 00:12:44 +00:00
connect ( _ui -> general_doubleSpinBox_detectionRate_2 , SIGNAL ( editingFinished ()), this , SLOT ( updateBasicParameter ()));
2012-06-24 17:19:34 +00:00
connect ( _ui -> general_spinBox_imagesBufferSize_2 , SIGNAL ( editingFinished ()), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_spinBox_maxStMemSize_2 , SIGNAL ( editingFinished ()), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_checkBox_publishStats , SIGNAL ( stateChanged ( int )), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_checkBox_publishStats_2 , SIGNAL ( stateChanged ( int )), this , SLOT ( updateBasicParameter ()));
2013-12-11 00:12:44 +00:00
connect ( _ui -> general_checkBox_activateRGBD , SIGNAL ( stateChanged ( int )), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_checkBox_activateRGBD_2 , SIGNAL ( stateChanged ( int )), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_checkBox_SLAM_mode , SIGNAL ( stateChanged ( int )), this , SLOT ( updateBasicParameter ()));
connect ( _ui -> general_checkBox_SLAM_mode_2 , SIGNAL ( stateChanged ( int )), this , SLOT ( updateBasicParameter ()));
2012-06-24 17:19:34 +00:00
2013-12-11 00:12:44 +00:00
connect ( _ui -> lineEdit_databasePath_2 , SIGNAL ( textChanged ( const QString & )), _ui -> lineEdit_databasePath , SLOT ( setText ( const QString & )));
connect ( _ui -> toolButton_databasePath_2 , SIGNAL ( clicked ()), this , SLOT ( changeDatabasePath ()));
2011-06-05 14:45:39 +00:00
// Map objects name with the corresponding parameter key, needed for the addParameter() slots
//Rtabmap
_ui -> general_checkBox_publishStats -> setObjectName ( Parameters :: kRtabmapPublishStats (). c_str ());
2012-12-11 18:05:05 +00:00
_ui -> general_checkBox_publishRawData -> setObjectName ( Parameters :: kRtabmapPublishImage (). c_str ());
2012-03-03 01:46:30 +00:00
_ui -> general_checkBox_publishPdf -> setObjectName ( Parameters :: kRtabmapPublishPdf (). c_str ());
_ui -> general_checkBox_publishLikelihood -> setObjectName ( Parameters :: kRtabmapPublishLikelihood (). c_str ());
2012-12-11 18:05:05 +00:00
_ui -> general_checkBox_statisticLogsBufferedInRAM -> setObjectName ( Parameters :: kRtabmapStatisticLogsBufferedInRAM (). c_str ());
2013-03-02 21:53:47 +00:00
_ui -> general_checkBox_statisticLogged -> setObjectName ( Parameters :: kRtabmapStatisticLogged (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> general_doubleSpinBox_timeThr -> setObjectName ( Parameters :: kRtabmapTimeThr (). c_str ());
2012-03-03 01:46:30 +00:00
_ui -> general_spinBox_memoryThr -> setObjectName ( Parameters :: kRtabmapMemoryThr (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> general_doubleSpinBox_detectionRate -> setObjectName ( Parameters :: kRtabmapDetectionRate (). c_str ());
2012-12-11 18:05:05 +00:00
_ui -> general_spinBox_imagesBufferSize -> setObjectName ( Parameters :: kRtabmapImageBufferSize (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> general_spinBox_maxRetrieved -> setObjectName ( Parameters :: kRtabmapMaxRetrieved (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> lineEdit_databasePath -> setObjectName ( Parameters :: kRtabmapDatabasePath (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> lineEdit_workingDirectory -> setObjectName ( Parameters :: kRtabmapWorkingDirectory (). c_str ());
2013-12-11 00:12:44 +00:00
connect ( _ui -> toolButton_databasePath , SIGNAL ( clicked ()), this , SLOT ( changeDatabasePath ()));
2011-06-05 14:45:39 +00:00
connect ( _ui -> toolButton_workingDirectory , SIGNAL ( clicked ()), this , SLOT ( changeWorkingDirectory ()));
// Memory
2012-12-11 18:05:05 +00:00
_ui -> general_checkBox_keepRawData -> setObjectName ( Parameters :: kMemImageKept (). c_str ());
2013-03-02 21:53:47 +00:00
_ui -> general_checkBox_keepRehearsedNodes -> setObjectName ( Parameters :: kMemRehearsedNodesKept (). c_str ());
2012-12-11 18:05:05 +00:00
_ui -> general_spinBox_maxStMemSize -> setObjectName ( Parameters :: kMemSTMSize (). c_str ());
_ui -> doubleSpinBox_similarityThreshold -> setObjectName ( Parameters :: kMemRehearsalSimilarity (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> general_checkBox_SLAM_mode -> setObjectName ( Parameters :: kMemIncrementalMemory (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> general_doubleSpinBox_recentWmRatio -> setObjectName ( Parameters :: kMemRecentWmRatio (). c_str ());
2013-01-27 04:50:49 +00:00
_ui -> general_checkBox_RehearsalIdUpdatedToNewOne -> setObjectName ( Parameters :: kMemRehearsalIdUpdatedToNewOne (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> general_checkBox_generateIds -> setObjectName ( Parameters :: kMemGenerateIds (). c_str ());
2014-01-15 20:41:58 +00:00
_ui -> general_checkBox_badSignaturesIgnored -> setObjectName ( Parameters :: kMemBadSignaturesIgnored (). c_str ());
2011-06-05 14:45:39 +00:00
// Database
_ui -> checkBox_dbInMemory -> setObjectName ( Parameters :: kDbSqlite3InMemory (). c_str ());
_ui -> spinBox_dbCacheSize -> setObjectName ( Parameters :: kDbSqlite3CacheSize (). c_str ());
_ui -> comboBox_dbJournalMode -> setObjectName ( Parameters :: kDbSqlite3JournalMode (). c_str ());
2012-03-03 01:46:30 +00:00
_ui -> comboBox_dbSynchronous -> setObjectName ( Parameters :: kDbSqlite3Synchronous (). c_str ());
_ui -> comboBox_dbTempStore -> setObjectName ( Parameters :: kDbSqlite3TempStore (). c_str ());
2011-06-05 14:45:39 +00:00
// Create hypotheses
_ui -> general_doubleSpinBox_hardThr -> setObjectName ( Parameters :: kRtabmapLoopThr (). c_str ());
_ui -> general_doubleSpinBox_loopRatio -> setObjectName ( Parameters :: kRtabmapLoopRatio (). c_str ());
//Bayes
_ui -> general_doubleSpinBox_vp -> setObjectName ( Parameters :: kBayesVirtualPlacePriorThr (). c_str ());
_ui -> lineEdit_bayes_predictionLC -> setObjectName ( Parameters :: kBayesPredictionLC (). c_str ());
2012-12-11 18:05:05 +00:00
_ui -> checkBox_bayes_fullPredictionUpdate -> setObjectName ( Parameters :: kBayesFullPredictionUpdate (). c_str ());
2012-03-03 01:46:30 +00:00
connect ( _ui -> lineEdit_bayes_predictionLC , SIGNAL ( textChanged ( const QString & )), this , SLOT ( updatePredictionPlot ()));
2011-06-05 14:45:39 +00:00
//Keypoint-based
2012-03-03 01:46:30 +00:00
_ui -> checkBox_kp_publishKeypoints -> setObjectName ( Parameters :: kKpPublishKeypoints (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> comboBox_dictionary_strategy -> setObjectName ( Parameters :: kKpNNStrategy (). c_str ());
_ui -> checkBox_dictionary_incremental -> setObjectName ( Parameters :: kKpIncrementalDictionary (). c_str ());
_ui -> comboBox_detector_strategy -> setObjectName ( Parameters :: kKpDetectorStrategy (). c_str ());
_ui -> checkBox_dictionary_minDistUsed -> setObjectName ( Parameters :: kKpMinDistUsed (). c_str ());
_ui -> surf_doubleSpinBox_matchThr -> setObjectName ( Parameters :: kKpMinDist (). c_str ());
_ui -> checkBox_dictionary_nndrUsed -> setObjectName ( Parameters :: kKpNndrUsed (). c_str ());
_ui -> surf_doubleSpinBox_nndrRatio -> setObjectName ( Parameters :: kKpNndrRatio (). c_str ());
_ui -> surf_spinBox_maxLeafs -> setObjectName ( Parameters :: kKpMaxLeafs (). c_str ());
2014-04-03 19:59:46 +00:00
_ui -> surf_doubleSpinBox_maxDepth -> setObjectName ( Parameters :: kKpMaxDepth (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> surf_spinBox_wordsPerImageTarget -> setObjectName ( Parameters :: kKpWordsPerImage (). c_str ());
_ui -> surf_doubleSpinBox_ratioBadSign -> setObjectName ( Parameters :: kKpBadSignRatio (). c_str ());
_ui -> checkBox_kp_tfIdfLikelihoodUsed -> setObjectName ( Parameters :: kKpTfIdfLikelihoodUsed (). c_str ());
_ui -> checkBox_kp_parallelized -> setObjectName ( Parameters :: kKpParallelized (). c_str ());
_ui -> lineEdit_kp_roi -> setObjectName ( Parameters :: kKpRoiRatios (). c_str ());
_ui -> lineEdit_dictionaryPath -> setObjectName ( Parameters :: kKpDictionaryPath (). c_str ());
connect ( _ui -> toolButton_dictionaryPath , SIGNAL ( clicked ()), this , SLOT ( changeDictionaryPath ()));
//SURF detector
_ui -> surf_doubleSpinBox_hessianThr -> setObjectName ( Parameters :: kSURFHessianThreshold (). c_str ());
_ui -> surf_spinBox_octaves -> setObjectName ( Parameters :: kSURFOctaves (). c_str ());
_ui -> surf_spinBox_octaveLayers -> setObjectName ( Parameters :: kSURFOctaveLayers (). c_str ());
_ui -> checkBox_surfExtended -> setObjectName ( Parameters :: kSURFExtended (). c_str ());
_ui -> surf_checkBox_upright -> setObjectName ( Parameters :: kSURFUpright (). c_str ());
2012-06-24 17:19:34 +00:00
_ui -> surf_checkBox_gpuVersion -> setObjectName ( Parameters :: kSURFGpuVersion (). c_str ());
2011-06-05 14:45:39 +00:00
//SIFT detector
2012-06-24 17:19:34 +00:00
_ui -> sift_spinBox_nFeatures -> setObjectName ( Parameters :: kSIFTNFeatures (). c_str ());
_ui -> sift_spinBox_nOctaveLayers -> setObjectName ( Parameters :: kSIFTNOctaveLayers (). c_str ());
_ui -> sift_doubleSpinBox_contrastThr -> setObjectName ( Parameters :: kSIFTContrastThreshold (). c_str ());
2011-06-05 14:45:39 +00:00
_ui -> sift_doubleSpinBox_edgeThr -> setObjectName ( Parameters :: kSIFTEdgeThreshold (). c_str ());
2012-06-24 17:19:34 +00:00
_ui -> sift_doubleSpinBox_sigma -> setObjectName ( Parameters :: kSIFTSigma (). c_str ());
2011-06-05 14:45:39 +00:00
// verifyHypotheses
_ui -> comboBox_vh_strategy -> setObjectName ( Parameters :: kRtabmapVhStrategy (). c_str ());
_ui -> surf_spinBox_matchCountMinAccepted -> setObjectName ( Parameters :: kVhEpMatchCountMin (). c_str ());
_ui -> surf_doubleSpinBox_ransacParam1 -> setObjectName ( Parameters :: kVhEpRansacParam1 (). c_str ());
_ui -> surf_doubleSpinBox_ransacParam2 -> setObjectName ( Parameters :: kVhEpRansacParam2 (). c_str ());
2013-12-11 00:12:44 +00:00
// RGB-D SLAM
_ui -> general_checkBox_activateRGBD -> setObjectName ( Parameters :: kRGBDEnabled (). c_str ());
_ui -> rgdb_linearUpdate -> setObjectName ( Parameters :: kRGBDLinearUpdate (). c_str ());
_ui -> rgdb_angularUpdate -> setObjectName ( Parameters :: kRGBDAngularUpdate (). c_str ());
2014-02-19 19:00:38 +00:00
_ui -> rgdb_newMapOdomChange -> setObjectName ( Parameters :: kRGBDNewMapOdomChangeDistance (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> odomScanHistory -> setObjectName ( Parameters :: kRGBDScanMatchingSize (). c_str ());
2014-02-11 23:04:22 +00:00
_ui -> globalDetection_toroIterations -> setObjectName ( Parameters :: kRGBDToroIterations (). c_str ());
2013-12-11 00:12:44 +00:00
2014-01-22 19:49:28 +00:00
_ui -> groupBox_localDetection_time -> setObjectName ( Parameters :: kRGBDLocalLoopDetectionTime (). c_str ());
_ui -> groupBox_localDetection_space -> setObjectName ( Parameters :: kRGBDLocalLoopDetectionSpace (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> localDetection_radius -> setObjectName ( Parameters :: kRGBDLocalLoopDetectionRadius (). c_str ());
_ui -> localDetection_maxNeighbors -> setObjectName ( Parameters :: kRGBDLocalLoopDetectionNeighbors (). c_str ());
2014-01-22 19:49:28 +00:00
_ui -> localDetection_maxDiffID -> setObjectName ( Parameters :: kRGBDLocalLoopDetectionMaxDiffID (). c_str ());
2013-12-11 00:12:44 +00:00
_ui -> loopClosure_bowMinInliers -> setObjectName ( Parameters :: kLccBowMinInliers (). c_str ());
_ui -> loopClosure_bowInlierDistance -> setObjectName ( Parameters :: kLccBowInlierDistance (). c_str ());
_ui -> loopClosure_bowIterations -> setObjectName ( Parameters :: kLccBowIterations (). c_str ());
_ui -> loopClosure_bowMaxDepth -> setObjectName ( Parameters :: kLccBowMaxDepth (). c_str ());
2014-01-22 19:49:28 +00:00
_ui -> globalDetection_icpType -> setObjectName ( Parameters :: kLccIcpType (). c_str ());
2014-02-19 19:00:38 +00:00
_ui -> globalDetection_icpMaxDistance -> setObjectName ( Parameters :: kLccIcpMaxDistance (). c_str ());
2014-01-22 19:49:28 +00:00
2013-12-11 00:12:44 +00:00
_ui -> loopClosure_icpDecimation -> setObjectName ( Parameters :: kLccIcp3Decimation (). c_str ());
_ui -> loopClosure_icpMaxDepth -> setObjectName ( Parameters :: kLccIcp3MaxDepth (). c_str ());
_ui -> loopClosure_icpVoxelSize -> setObjectName ( Parameters :: kLccIcp3VoxelSize (). c_str ());
_ui -> loopClosure_icpSamples -> setObjectName ( Parameters :: kLccIcp3Samples (). c_str ());
_ui -> loopClosure_icpMaxCorrespondenceDistance -> setObjectName ( Parameters :: kLccIcp3MaxCorrespondenceDistance (). c_str ());
_ui -> loopClosure_icpIterations -> setObjectName ( Parameters :: kLccIcp3Iterations (). c_str ());
_ui -> loopClosure_icpMaxFitness -> setObjectName ( Parameters :: kLccIcp3MaxFitness (). c_str ());
_ui -> loopClosure_icp2MaxCorrespondenceDistance -> setObjectName ( Parameters :: kLccIcp2MaxCorrespondenceDistance (). c_str ());
_ui -> loopClosure_icp2Iterations -> setObjectName ( Parameters :: kLccIcp2Iterations (). c_str ());
_ui -> loopClosure_icp2MaxFitness -> setObjectName ( Parameters :: kLccIcp2MaxFitness (). c_str ());
_ui -> loopClosure_icp2Ratio -> setObjectName ( Parameters :: kLccIcp2CorrespondenceRatio (). c_str ());
2014-01-22 19:49:28 +00:00
_ui -> loopClosure_icp2Voxel -> setObjectName ( Parameters :: kLccIcp2VoxelSize (). c_str ());
2013-12-11 00:12:44 +00:00
//Odometry
_ui -> odom_type -> setObjectName ( Parameters :: kOdomType (). c_str ());
_ui -> odom_linearUpdate -> setObjectName ( Parameters :: kOdomLinearUpdate (). c_str ());
_ui -> odom_angularUpdate -> setObjectName ( Parameters :: kOdomAngularUpdate (). c_str ());
_ui -> odom_countdown -> setObjectName ( Parameters :: kOdomResetCountdown (). c_str ());
_ui -> odom_maxFeatures -> setObjectName ( Parameters :: kOdomMaxWords (). c_str ());
_ui -> odom_inlierDistance -> setObjectName ( Parameters :: kOdomInlierDistance (). c_str ());
_ui -> odom_iterations -> setObjectName ( Parameters :: kOdomIterations (). c_str ());
_ui -> odom_maxDepth -> setObjectName ( Parameters :: kOdomMaxDepth (). c_str ());
_ui -> odom_minInliers -> setObjectName ( Parameters :: kOdomMinInliers (). c_str ());
_ui -> stackedWidget_odom -> setCurrentIndex ( _ui -> odom_type -> currentIndex ());
connect ( _ui -> odom_type , SIGNAL ( currentIndexChanged ( int )), _ui -> stackedWidget_odom , SLOT ( setCurrentIndex ( int )));
_ui -> odom_bin_briefBytes -> setObjectName ( Parameters :: kOdomBinBriefBytes (). c_str ());
_ui -> odom_bin_fastSuppressNonMax -> setObjectName ( Parameters :: kOdomBinFastNonmaxSuppression (). c_str ());
_ui -> odom_bin_fastThreshold -> setObjectName ( Parameters :: kOdomBinFastThreshold (). c_str ());
_ui -> odom_bin_bruteForceMatching -> setObjectName ( Parameters :: kOdomBinBruteForceMatching (). c_str ());
_ui -> odom_icpDecimation -> setObjectName ( Parameters :: kOdomICPDecimation (). c_str ());
_ui -> odom_icpVoxelSize -> setObjectName ( Parameters :: kOdomICPVoxelSize (). c_str ());
_ui -> odom_icpSamples -> setObjectName ( Parameters :: kOdomICPSamples (). c_str ());
_ui -> odom_icpMaxCorrespondenceDistance -> setObjectName ( Parameters :: kOdomICPCorrespondencesDistance (). c_str ());
_ui -> odom_icpIterations -> setObjectName ( Parameters :: kOdomICPIterations (). c_str ());
_ui -> odom_icpMaxFitness -> setObjectName ( Parameters :: kOdomICPMaxFitness (). c_str ());
2011-06-05 14:45:39 +00:00
setupSignals ();
// custom signals
connect ( _ui -> doubleSpinBox_kp_roi0 , SIGNAL ( valueChanged ( double )), this , SLOT ( updateKpROI ()));
connect ( _ui -> doubleSpinBox_kp_roi1 , SIGNAL ( valueChanged ( double )), this , SLOT ( updateKpROI ()));
connect ( _ui -> doubleSpinBox_kp_roi2 , SIGNAL ( valueChanged ( double )), this , SLOT ( updateKpROI ()));
connect ( _ui -> doubleSpinBox_kp_roi3 , SIGNAL ( valueChanged ( double )), this , SLOT ( updateKpROI ()));
//Create a model from the stacked widgets
// This will add all parameters to the parameters Map
_ui -> stackedWidget -> setCurrentIndex ( 0 );
this -> setupTreeView ();
connect ( _ui -> treeView , SIGNAL ( clicked ( QModelIndex )), this , SLOT ( clicked ( QModelIndex )));
_obsoletePanels = kPanelAll ;
2011-06-09 13:57:01 +00:00
_progressDialog = new QProgressDialog ( this );
_progressDialog -> setWindowTitle ( tr ( "Read parameters..." ));
_progressDialog -> setMaximum ( 2 );
2011-06-05 14:45:39 +00:00
}
PreferencesDialog ::~ PreferencesDialog () {
this -> saveWindowGeometry ( "PreferencesDialog" , this );
delete _ui ;
}
2011-06-09 12:51:13 +00:00
void PreferencesDialog :: init ()
{
this -> readSettings ();
this -> writeSettings (); // This will create the ini file if not exist
this -> loadWindowGeometry ( "PreferencesDialog" , this );
_obsoletePanels = kPanelAll ;
_initialized = true ;
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: setupTreeView ()
{
2012-03-03 01:46:30 +00:00
if ( _indexModel )
2011-06-05 14:45:39 +00:00
{
2012-03-03 01:46:30 +00:00
_ui -> treeView -> setModel ( 0 );
delete _indexModel ;
}
_indexModel = new QStandardItemModel ( this );
// Parse the model
QList < QGroupBox *> boxes = this -> getGroupBoxes ();
if ( _ui -> radioButton_basic -> isChecked ())
{
2013-12-11 00:12:44 +00:00
boxes = boxes . mid ( 0 , 5 );
2012-03-03 01:46:30 +00:00
}
else // Advanced
{
2013-12-11 00:12:44 +00:00
boxes . removeAt ( 4 );
2012-03-03 01:46:30 +00:00
}
QStandardItem * parentItem = _indexModel -> invisibleRootItem ();
int index = 0 ;
this -> parseModel ( boxes , parentItem , 0 , index ); // recursive method
if ( _ui -> radioButton_advanced -> isChecked () && index != _ui -> stackedWidget -> count () - 1 )
{
ULOGGER_ERROR ( "The tree model is not the same size of the stacked widgets...%d vs %d advanced stacks" , index , _ui -> stackedWidget -> count () - 1 );
}
2013-12-11 00:12:44 +00:00
int currentIndex = _ui -> stackedWidget -> currentIndex ();
2012-03-03 01:46:30 +00:00
if ( _ui -> radioButton_basic -> isChecked ())
{
2013-12-11 00:12:44 +00:00
if ( currentIndex >= 4 )
2011-06-05 14:45:39 +00:00
{
2013-12-11 00:12:44 +00:00
_ui -> stackedWidget -> setCurrentIndex ( 4 );
currentIndex = 4 ;
2011-06-05 14:45:39 +00:00
}
}
2012-03-03 01:46:30 +00:00
else // Advanced
2011-06-05 14:45:39 +00:00
{
2013-12-11 00:12:44 +00:00
if ( currentIndex == 4 )
2012-03-03 01:46:30 +00:00
{
2013-12-11 00:12:44 +00:00
_ui -> stackedWidget -> setCurrentIndex ( 5 );
2012-03-03 01:46:30 +00:00
}
2011-06-05 14:45:39 +00:00
}
2012-03-03 01:46:30 +00:00
_ui -> treeView -> setModel ( _indexModel );
2013-12-11 00:12:44 +00:00
if ( currentIndex == 0 ) // GUI
{
_ui -> treeView -> setCurrentIndex ( _indexModel -> index ( 0 , 0 ));
}
else if ( currentIndex == 1 ) //3d rendering
{
_ui -> treeView -> setCurrentIndex ( _indexModel -> index ( 0 , 0 ). child ( 0 , 0 ));
}
else if ( currentIndex == 2 ) // logging
{
_ui -> treeView -> setCurrentIndex ( _indexModel -> index ( 0 , 0 ). child ( 1 , 0 ));
}
else // source, rtabmap
{
_ui -> treeView -> setCurrentIndex ( _indexModel -> index ( currentIndex - 2 , 0 ));
}
2012-12-11 18:05:05 +00:00
_ui -> treeView -> expandToDepth ( 0 );
2011-06-05 14:45:39 +00:00
}
// recursive...
bool PreferencesDialog :: parseModel ( QList < QGroupBox *> & boxes , QStandardItem * parentItem , int currentLevel , int & absoluteIndex )
{
if ( parentItem == 0 )
{
ULOGGER_ERROR ( "Parent item is null !" );
return false ;
}
QStandardItem * currentItem = 0 ;
while ( absoluteIndex < boxes . size ())
{
2012-03-03 01:46:30 +00:00
QString objectName = boxes . at ( absoluteIndex ) -> objectName ();
2011-06-05 14:45:39 +00:00
QString title = boxes . at ( absoluteIndex ) -> title ();
bool ok = false ;
2012-03-03 01:46:30 +00:00
int lvl = QString ( objectName . at ( objectName . size () - 1 )). toInt ( & ok );
2011-06-05 14:45:39 +00:00
if ( ! ok )
{
2012-03-03 01:46:30 +00:00
ULOGGER_ERROR ( "Error while parsing the first number of the QGroupBox title (%s), the first character must be the number in the hierarchy" , title . toStdString (). c_str ());
2011-06-05 14:45:39 +00:00
return false ;
}
if ( lvl == currentLevel )
{
QStandardItem * item = new QStandardItem ( title );
item -> setData ( absoluteIndex );
currentItem = item ;
//ULOGGER_DEBUG("PreferencesDialog::parseModel() lvl(%d) Added %s", currentLevel, title.toStdString().c_str());
parentItem -> appendRow ( item );
++ absoluteIndex ;
}
else if ( lvl > currentLevel )
{
if ( lvl > currentLevel + 1 )
{
ULOGGER_ERROR ( "Intermediary lvl doesn't exist, lvl %d to %d, indexes %d and %d" , currentLevel , lvl , absoluteIndex - 1 , absoluteIndex );
return false ;
}
else
{
parseModel ( boxes , currentItem , currentLevel + 1 , absoluteIndex ); // recursive
}
}
else
{
return false ;
}
}
return true ;
}
void PreferencesDialog :: setupSignals ()
{
const rtabmap :: ParametersMap & parameters = Parameters :: getDefaultParameters ();
for ( rtabmap :: ParametersMap :: const_iterator iter = parameters . begin (); iter != parameters . end (); ++ iter )
{
QObject * obj = _ui -> stackedWidget -> findChild < QObject *> (( * iter ). first . c_str ());
if ( obj )
{
QSpinBox * spin = qobject_cast < QSpinBox *> ( obj );
QDoubleSpinBox * doubleSpin = qobject_cast < QDoubleSpinBox *> ( obj );
QComboBox * combo = qobject_cast < QComboBox *> ( obj );
QCheckBox * check = qobject_cast < QCheckBox *> ( obj );
2013-12-11 00:12:44 +00:00
QRadioButton * radio = qobject_cast < QRadioButton *> ( obj );
2011-06-05 14:45:39 +00:00
QLineEdit * lineEdit = qobject_cast < QLineEdit *> ( obj );
2014-01-22 19:49:28 +00:00
QGroupBox * groupBox = qobject_cast < QGroupBox *> ( obj );
2011-06-05 14:45:39 +00:00
if ( spin )
{
connect ( spin , SIGNAL ( valueChanged ( int )), this , SLOT ( addParameter ( int )));
}
else if ( doubleSpin )
{
connect ( doubleSpin , SIGNAL ( valueChanged ( double )), this , SLOT ( addParameter ( double )));
}
else if ( combo )
{
connect ( combo , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( addParameter ( int )));
}
else if ( check )
{
2013-12-11 00:12:44 +00:00
connect ( check , SIGNAL ( toggled ( bool )), this , SLOT ( addParameter ( bool )));
}
else if ( radio )
{
connect ( radio , SIGNAL ( toggled ( bool )), this , SLOT ( addParameter ( bool )));
2011-06-05 14:45:39 +00:00
}
else if ( lineEdit )
{
connect ( lineEdit , SIGNAL ( textChanged ( const QString & )), this , SLOT ( addParameter ( const QString & )));
}
2014-01-22 19:49:28 +00:00
else if ( groupBox )
{
connect ( groupBox , SIGNAL ( clicked ( bool )), this , SLOT ( addParameter ( bool )));
}
2011-06-05 14:45:39 +00:00
else
{
ULOGGER_WARN ( "QObject called %s can't be cast to a supported widget" , ( * iter ). first . c_str ());
}
}
else
{
ULOGGER_WARN ( "Can't find the related QObject for parameter %s" , ( * iter ). first . c_str ());
}
}
}
void PreferencesDialog :: clicked ( const QModelIndex & index )
{
QStandardItem * item = _indexModel -> itemFromIndex ( index );
2013-01-28 18:13:56 +00:00
if ( item && item -> isEnabled ())
2011-06-05 14:45:39 +00:00
{
2012-03-03 01:46:30 +00:00
int index = item -> data (). toInt ();
2013-12-11 00:12:44 +00:00
if ( _ui -> radioButton_advanced -> isChecked () && index >= 4 )
2012-03-03 01:46:30 +00:00
{
++ index ;
}
_ui -> stackedWidget -> setCurrentIndex ( index );
2012-12-11 18:05:05 +00:00
_ui -> scrollArea -> horizontalScrollBar () -> setValue ( 0 );
_ui -> scrollArea -> verticalScrollBar () -> setValue ( 0 );
2011-06-05 14:45:39 +00:00
}
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: closeEvent ( QCloseEvent * event )
{
UDEBUG ( "" );
_parameters . clear ();
_obsoletePanels = kPanelDummy ;
event -> accept ();
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: closeDialog ( QAbstractButton * button )
{
2013-12-11 00:12:44 +00:00
UDEBUG ( "" );
2011-06-05 14:45:39 +00:00
QDialogButtonBox :: ButtonRole role = _ui -> buttonBox_global -> buttonRole ( button );
switch ( role )
{
case QDialogButtonBox :: RejectRole :
_parameters . clear ();
_obsoletePanels = kPanelDummy ;
this -> reject ();
break ;
case QDialogButtonBox :: AcceptRole :
2012-06-24 17:19:34 +00:00
updateBasicParameter (); // make that changes without editing finished signal are updated.
2012-03-03 01:46:30 +00:00
if (( _obsoletePanels & kPanelAll ) || _parameters . size ())
2011-06-05 14:45:39 +00:00
{
if ( validateForm ())
{
writeSettings ();
this -> accept ();
}
}
else
{
this -> accept ();
}
break ;
default :
break ;
}
}
void PreferencesDialog :: resetApply ( QAbstractButton * button )
{
QDialogButtonBox :: ButtonRole role = _ui -> buttonBox_local -> buttonRole ( button );
switch ( role )
{
case QDialogButtonBox :: ApplyRole :
2012-06-24 17:19:34 +00:00
updateBasicParameter (); // make that changes without editing finished signal are updated.
2011-06-05 14:45:39 +00:00
if ( validateForm ())
{
writeSettings ();
}
break ;
case QDialogButtonBox :: ResetRole :
resetSettings ( _ui -> stackedWidget -> currentIndex ());
break ;
default :
break ;
}
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: resetSettings ( QGroupBox * groupBox )
{
if ( groupBox -> objectName () == _ui -> groupBox_generalSettingsGui0 -> objectName ())
{
_ui -> general_checkBox_imagesKept -> setChecked ( true );
_ui -> checkBox_beep -> setChecked ( false );
_ui -> checkBox_verticalLayoutUsed -> setChecked ( false );
_ui -> checkBox_imageFlipped -> setChecked ( false );
_ui -> checkBox_imageRejectedShown -> setChecked ( true );
_ui -> checkBox_imageHighestHypShown -> setChecked ( false );
_ui -> horizontalSlider_keypointsOpacity -> setSliderPosition ( 20 );
}
else if ( groupBox -> objectName () == _ui -> groupBox_cloudRendering1 -> objectName ())
{
for ( int i = 0 ; i < 3 ; ++ i )
{
_3dRenderingShowClouds [ i ] -> setChecked ( true );
_3dRenderingVoxelSize [ i ] -> setValue ( i == 2 ? 0.01 : 0.00 );
_3dRenderingDecimation [ i ] -> setValue ( i == 0 ? 4 : i == 1 ? 2 : 1 );
_3dRenderingMaxDepth [ i ] -> setValue ( i == 1 ? 0.0 : 4.0 );
_3dRenderingShowScans [ i ] -> setChecked ( true );
if ( i < 2 )
{
_3dRenderingOpacity [ i ] -> setValue ( i == 0 ? 0.6 : 1.0 );
_3dRenderingPtSize [ i ] -> setValue ( i == 0 ? 1 : 2 );
_3dRenderingOpacityScan [ i ] -> setValue ( 1.0 );
_3dRenderingPtSizeScan [ i ] -> setValue ( 1 );
2014-06-03 19:28:59 +00:00
_3dRenderingNormalKSearch [ i ] -> setValue ( 20 );
_3dRenderingGP3Radius [ i ] -> setValue ( 0.04 );
_3dRenderingSmoothing [ i ] -> setChecked ( true );
_3dRenderingSmoothingRadius [ i ] -> setValue ( 0.04 );
2013-12-11 00:12:44 +00:00
}
if ( i < 1 )
{
_3dRenderingMeshing [ i ] -> setChecked ( false );
}
}
2014-02-13 21:32:46 +00:00
_ui -> groupBox_poseFiltering -> setChecked ( false );
_ui -> doubleSpinBox_cloudFilterRadius -> setValue ( 0.5 );
_ui -> doubleSpinBox_cloudFilterAngle -> setValue ( 30 );
2013-12-11 00:12:44 +00:00
}
else if ( groupBox -> objectName () == _ui -> groupBox_logging1 -> objectName ())
{
_ui -> comboBox_loggerLevel -> setCurrentIndex ( 2 );
_ui -> comboBox_loggerEventLevel -> setCurrentIndex ( 3 );
_ui -> comboBox_loggerPauseLevel -> setCurrentIndex ( 3 );
_ui -> checkBox_logger_printTime -> setChecked ( true );
_ui -> comboBox_loggerType -> setCurrentIndex ( 1 );
}
else if ( groupBox -> objectName () == _ui -> groupBox_source0 -> objectName ())
{
_ui -> general_doubleSpinBox_imgRate -> setValue ( 0.0 );
_ui -> groupBox_sourceImage -> setChecked ( false );
_ui -> source_spinBox_imgWidth -> setValue ( 0 );
_ui -> source_spinBox_imgheight -> setValue ( 0 );
_ui -> source_spinBox_framesDropped -> setValue ( 0 );
_ui -> general_checkBox_autoRestart -> setChecked ( false );
_ui -> general_checkBox_cameraKeypoints -> setChecked ( false );
_ui -> source_images_spinBox_startPos -> setValue ( 1 );
_ui -> source_images_refreshDir -> setChecked ( false );
_ui -> groupBox_sourceDatabase -> setChecked ( false );
_ui -> source_checkBox_ignoreOdometry -> setChecked ( false );
_ui -> source_spinBox_databaseStartPos -> setValue ( 0 );
_ui -> groupBox_sourceOpenni -> setChecked ( true );
2014-06-03 04:42:08 +00:00
_ui -> radioButton_openni -> setChecked ( true );
_ui -> radioButton_freenect -> setChecked ( false );
_ui -> lineEdit_openniDevice -> setText ( "" );
2013-12-11 00:12:44 +00:00
_ui -> lineEdit_openniLocalTransform -> setText ( "0 0 0 -PI_2 0 -PI_2" );
}
else if ( groupBox -> objectName () == _ui -> groupBox_rtabmap_basic0 -> objectName ())
{
_ui -> general_doubleSpinBox_timeThr_2 -> setValue ( Parameters :: defaultRtabmapTimeThr ());
_ui -> general_doubleSpinBox_hardThr_2 -> setValue ( Parameters :: defaultRtabmapLoopThr ());
_ui -> doubleSpinBox_similarityThreshold_2 -> setValue ( Parameters :: defaultMemRehearsalSimilarity ());
_ui -> general_spinBox_imagesBufferSize_2 -> setValue ( Parameters :: defaultRtabmapImageBufferSize ());
_ui -> general_spinBox_maxStMemSize_2 -> setValue ( Parameters :: defaultMemSTMSize ());
_ui -> general_checkBox_publishStats_2 -> setChecked ( Parameters :: defaultRtabmapPublishStats ());
_ui -> general_checkBox_activateRGBD_2 -> setChecked ( Parameters :: defaultRGBDEnabled ());
_ui -> general_checkBox_SLAM_mode_2 -> setChecked ( Parameters :: defaultMemIncrementalMemory ());
_ui -> lineEdit_databasePath_2 -> setText ( Parameters :: defaultRtabmapDatabasePath (). c_str ());
_ui -> general_doubleSpinBox_detectionRate_2 -> setValue ( Parameters :: defaultRtabmapDetectionRate ());
// match the advanced (spin and doubleSpin boxes)
_ui -> general_doubleSpinBox_timeThr -> setValue ( Parameters :: defaultRtabmapTimeThr ());
_ui -> general_doubleSpinBox_hardThr -> setValue ( Parameters :: defaultRtabmapLoopThr ());
_ui -> surf_doubleSpinBox_hessianThr -> setValue ( Parameters :: defaultSURFHessianThreshold ());
_ui -> doubleSpinBox_similarityThreshold -> setValue ( Parameters :: defaultMemRehearsalSimilarity ());
_ui -> general_spinBox_imagesBufferSize -> setValue ( Parameters :: defaultRtabmapImageBufferSize ());
_ui -> general_spinBox_maxStMemSize -> setValue ( Parameters :: defaultMemSTMSize ());
_ui -> general_doubleSpinBox_detectionRate -> setValue ( Parameters :: defaultRtabmapDetectionRate ());
}
else
{
QObjectList children = groupBox -> children ();
rtabmap :: ParametersMap defaults = Parameters :: getDefaultParameters ();
std :: string key ;
for ( int i = 0 ; i < children . size (); ++ i )
{
key = children . at ( i ) -> objectName (). toStdString ();
if ( uContains ( defaults , key ))
{
this -> setParameter ( key , defaults . at ( key ));
}
else if ( qobject_cast < const QGroupBox *> ( children . at ( i )))
{
this -> resetSettings (( QGroupBox * ) children . at ( i ));
}
}
if ( groupBox -> findChild < QLineEdit *> ( _ui -> lineEdit_kp_roi -> objectName ()))
{
this -> setupKpRoiPanel ();
}
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: resetSettings ( int panelNumber )
{
QList < QGroupBox *> boxes = this -> getGroupBoxes ();
if ( panelNumber >= 0 && panelNumber < boxes . size ())
{
2013-12-11 00:12:44 +00:00
this -> resetSettings ( boxes . at ( panelNumber ));
2011-06-05 14:45:39 +00:00
}
2014-01-22 19:49:28 +00:00
else if ( panelNumber == - 1 )
{
for ( QList < QGroupBox *>:: iterator iter = boxes . begin (); iter != boxes . end (); ++ iter )
{
this -> resetSettings ( * iter );
}
}
2011-06-05 14:45:39 +00:00
else
{
ULOGGER_WARN ( "panel number and the number of stacked widget doesn't match" );
}
}
2013-12-11 00:12:44 +00:00
QString PreferencesDialog :: getWorkingDirectory () const
2011-06-05 14:45:39 +00:00
{
return _ui -> lineEdit_workingDirectory -> text ();
}
2013-12-14 02:43:26 +00:00
QString PreferencesDialog :: getDatabasePath () const
{
return _ui -> lineEdit_databasePath -> text ();
}
2013-12-11 00:12:44 +00:00
QString PreferencesDialog :: getIniFilePath () const
2011-06-05 14:45:39 +00:00
{
2013-01-10 20:29:01 +00:00
QString privatePath = QDir :: homePath () + "/.rtabmap" ;
if ( ! QDir ( privatePath ). exists ())
{
QDir :: home (). mkdir ( ".rtabmap" );
}
return privatePath + "/rtabmap.ini" ;
2011-06-05 14:45:39 +00:00
}
void PreferencesDialog :: loadConfigFrom ()
{
2014-01-22 19:49:28 +00:00
QString path = QFileDialog :: getOpenFileName ( this , tr ( "Load settings..." ), this -> getWorkingDirectory (), "*.ini" );
2011-06-05 14:45:39 +00:00
if ( ! path . isEmpty ())
{
this -> readSettings ( path );
}
}
void PreferencesDialog :: readSettings ( const QString & filePath )
{
ULOGGER_DEBUG ( "" );
readGuiSettings ( filePath );
readCameraSettings ( filePath );
2012-06-26 14:57:31 +00:00
if ( ! readCoreSettings ( filePath ))
{
_parameters . clear ();
_obsoletePanels = kPanelDummy ;
2013-01-28 18:13:56 +00:00
// only keep GUI settings
QStandardItem * parentItem = _indexModel -> invisibleRootItem ();
if ( parentItem )
{
for ( int i = 1 ; i < parentItem -> rowCount (); ++ i )
{
parentItem -> child ( i ) -> setEnabled ( false );
}
}
_ui -> radioButton_basic -> setEnabled ( false );
_ui -> radioButton_advanced -> setEnabled ( false );
}
else
{
// enable settings
QStandardItem * parentItem = _indexModel -> invisibleRootItem ();
if ( parentItem )
{
for ( int i = 0 ; i < parentItem -> rowCount (); ++ i )
{
parentItem -> child ( i ) -> setEnabled ( true );
}
}
_ui -> radioButton_basic -> setEnabled ( true );
_ui -> radioButton_advanced -> setEnabled ( true );
2012-06-26 14:57:31 +00:00
}
2011-06-05 14:45:39 +00:00
}
void PreferencesDialog :: readGuiSettings ( const QString & filePath )
{
QString path = getIniFilePath ();
if ( ! filePath . isEmpty ())
{
path = filePath ;
}
QSettings settings ( path , QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( "General" );
_ui -> general_checkBox_imagesKept -> setChecked ( settings . value ( "imagesKept" , _ui -> general_checkBox_imagesKept -> isChecked ()). toBool ());
_ui -> comboBox_loggerLevel -> setCurrentIndex ( settings . value ( "loggerLevel" , _ui -> comboBox_loggerLevel -> currentIndex ()). toInt ());
_ui -> comboBox_loggerEventLevel -> setCurrentIndex ( settings . value ( "loggerEventLevel" , _ui -> comboBox_loggerEventLevel -> currentIndex ()). toInt ());
_ui -> comboBox_loggerPauseLevel -> setCurrentIndex ( settings . value ( "loggerPauseLevel" , _ui -> comboBox_loggerPauseLevel -> currentIndex ()). toInt ());
_ui -> comboBox_loggerType -> setCurrentIndex ( settings . value ( "loggerType" , _ui -> comboBox_loggerType -> currentIndex ()). toInt ());
_ui -> checkBox_logger_printTime -> setChecked ( settings . value ( "loggerPrintTime" , _ui -> checkBox_logger_printTime -> isChecked ()). toBool ());
_ui -> checkBox_verticalLayoutUsed -> setChecked ( settings . value ( "verticalLayoutUsed" , _ui -> checkBox_verticalLayoutUsed -> isChecked ()). toBool ());
_ui -> checkBox_imageFlipped -> setChecked ( settings . value ( "imageFlipped" , _ui -> checkBox_imageFlipped -> isChecked ()). toBool ());
_ui -> checkBox_imageRejectedShown -> setChecked ( settings . value ( "imageRejectedShown" , _ui -> checkBox_imageRejectedShown -> isChecked ()). toBool ());
2011-06-10 14:04:06 +00:00
_ui -> checkBox_imageHighestHypShown -> setChecked ( settings . value ( "imageHighestHypShown" , _ui -> checkBox_imageHighestHypShown -> isChecked ()). toBool ());
2011-06-05 14:45:39 +00:00
_ui -> checkBox_beep -> setChecked ( settings . value ( "beep" , _ui -> checkBox_beep -> isChecked ()). toBool ());
_ui -> horizontalSlider_keypointsOpacity -> setValue ( settings . value ( "keypointsOpacity" , _ui -> horizontalSlider_keypointsOpacity -> value ()). toInt ());
2013-12-11 00:12:44 +00:00
for ( int i = 0 ; i < 3 ; ++ i )
{
_3dRenderingShowClouds [ i ] -> setChecked ( settings . value ( tr ( "showClouds%1" ). arg ( i ), _3dRenderingShowClouds [ i ] -> isChecked ()). toBool ());
_3dRenderingVoxelSize [ i ] -> setValue ( settings . value ( tr ( "voxelSize%1" ). arg ( i ), _3dRenderingVoxelSize [ i ] -> value ()). toDouble ());
_3dRenderingDecimation [ i ] -> setValue ( settings . value ( tr ( "decimation%1" ). arg ( i ), _3dRenderingDecimation [ i ] -> value ()). toInt ());
_3dRenderingMaxDepth [ i ] -> setValue ( settings . value ( tr ( "maxDepth%1" ). arg ( i ), _3dRenderingMaxDepth [ i ] -> value ()). toDouble ());
_3dRenderingShowScans [ i ] -> setChecked ( settings . value ( tr ( "showScans%1" ). arg ( i ), _3dRenderingShowScans [ i ] -> isChecked ()). toBool ());
if ( i < 2 )
{
_3dRenderingOpacity [ i ] -> setValue ( settings . value ( tr ( "opacity%1" ). arg ( i ), _3dRenderingOpacity [ i ] -> value ()). toDouble ());
_3dRenderingPtSize [ i ] -> setValue ( settings . value ( tr ( "ptSize%1" ). arg ( i ), _3dRenderingPtSize [ i ] -> value ()). toInt ());
_3dRenderingOpacityScan [ i ] -> setValue ( settings . value ( tr ( "opacityScan%1" ). arg ( i ), _3dRenderingOpacityScan [ i ] -> value ()). toDouble ());
_3dRenderingPtSizeScan [ i ] -> setValue ( settings . value ( tr ( "ptSizeScan%1" ). arg ( i ), _3dRenderingPtSizeScan [ i ] -> value ()). toInt ());
2014-06-03 19:28:59 +00:00
_3dRenderingNormalKSearch [ i ] -> setValue ( settings . value ( tr ( "meshNormalKSearch%1" ). arg ( i ), _3dRenderingNormalKSearch [ i ] -> value ()). toInt ());
_3dRenderingGP3Radius [ i ] -> setValue ( settings . value ( tr ( "meshGP3Radius%1" ). arg ( i ), _3dRenderingGP3Radius [ i ] -> value ()). toDouble ());
_3dRenderingSmoothing [ i ] -> setChecked ( settings . value ( tr ( "meshSmoothing%1" ). arg ( i ), _3dRenderingSmoothing [ i ] -> isChecked ()). toBool ());
_3dRenderingSmoothingRadius [ i ] -> setValue ( settings . value ( tr ( "meshSmoothingRadius%1" ). arg ( i ), _3dRenderingSmoothingRadius [ i ] -> value ()). toDouble ());
2013-12-11 00:12:44 +00:00
}
if ( i < 1 )
{
_3dRenderingMeshing [ i ] -> setChecked ( settings . value ( tr ( "meshing%1" ). arg ( i ), _3dRenderingMeshing [ i ] -> isChecked ()). toBool ());
}
}
2014-02-13 21:32:46 +00:00
_ui -> groupBox_poseFiltering -> setChecked ( settings . value ( "cloudFiltering" , _ui -> groupBox_poseFiltering -> isChecked ()). toBool ());
_ui -> doubleSpinBox_cloudFilterRadius -> setValue ( settings . value ( "cloudFilteringRadius" , _ui -> doubleSpinBox_cloudFilterRadius -> value ()). toDouble ());
_ui -> doubleSpinBox_cloudFilterAngle -> setValue ( settings . value ( "cloudFilteringAngle" , _ui -> doubleSpinBox_cloudFilterAngle -> value ()). toDouble ());
2011-06-05 14:45:39 +00:00
settings . endGroup (); // General
settings . endGroup (); // rtabmap
}
void PreferencesDialog :: readCameraSettings ( const QString & filePath )
{
QString path = getIniFilePath ();
if ( ! filePath . isEmpty ())
{
path = filePath ;
}
QSettings settings ( path , QSettings :: IniFormat );
settings . beginGroup ( "Camera" );
2012-06-24 17:19:34 +00:00
_ui -> groupBox_sourceImage -> setChecked ( settings . value ( "imageUsed" , _ui -> groupBox_sourceImage -> isChecked ()). toBool ());
2011-06-05 14:45:39 +00:00
_ui -> general_doubleSpinBox_imgRate -> setValue ( settings . value ( "imgRate" , _ui -> general_doubleSpinBox_imgRate -> value ()). toDouble ());
_ui -> general_checkBox_autoRestart -> setChecked ( settings . value ( "autoRestart" , _ui -> general_checkBox_autoRestart -> isChecked ()). toBool ());
2012-03-03 01:46:30 +00:00
_ui -> general_checkBox_cameraKeypoints -> setChecked ( settings . value ( "cameraKeypoints" , _ui -> general_checkBox_cameraKeypoints -> isChecked ()). toBool ());
2012-06-24 17:19:34 +00:00
_ui -> source_comboBox_image_type -> setCurrentIndex ( settings . value ( "type" , _ui -> source_comboBox_image_type -> currentIndex ()). toInt ());
2011-06-05 14:45:39 +00:00
_ui -> source_spinBox_imgWidth -> setValue ( settings . value ( "imgWidth" , _ui -> source_spinBox_imgWidth -> value ()). toInt ());
_ui -> source_spinBox_imgheight -> setValue ( settings . value ( "imgHeight" , _ui -> source_spinBox_imgheight -> value ()). toInt ());
2012-06-24 17:19:34 +00:00
_ui -> source_spinBox_framesDropped -> setValue ( settings . value ( "framesDropped" , _ui -> source_spinBox_framesDropped -> value ()). toInt ());
2011-06-05 14:45:39 +00:00
//usbDevice group
settings . beginGroup ( "usbDevice" );
_ui -> source_usbDevice_spinBox_id -> setValue ( settings . value ( "id" , _ui -> source_usbDevice_spinBox_id -> value ()). toInt ());
settings . endGroup (); // usbDevice
//images group
settings . beginGroup ( "images" );
_ui -> source_images_lineEdit_path -> setText ( settings . value ( "path" , _ui -> source_images_lineEdit_path -> text ()). toString ());
_ui -> source_images_spinBox_startPos -> setValue ( settings . value ( "startPos" , _ui -> source_images_spinBox_startPos -> value ()). toInt ());
_ui -> source_images_refreshDir -> setChecked ( settings . value ( "refreshDir" , _ui -> source_images_refreshDir -> isChecked ()). toBool ());
settings . endGroup (); // images
//video group
settings . beginGroup ( "video" );
_ui -> source_video_lineEdit_path -> setText ( settings . value ( "path" , _ui -> source_video_lineEdit_path -> text ()). toString ());
settings . endGroup (); // video
settings . endGroup (); // Camera
2012-06-24 17:19:34 +00:00
settings . beginGroup ( "Database" );
_ui -> groupBox_sourceDatabase -> setChecked ( settings . value ( "databaseUsed" , _ui -> groupBox_sourceDatabase -> isChecked ()). toBool ());
_ui -> source_database_lineEdit_path -> setText ( settings . value ( "path" , _ui -> source_database_lineEdit_path -> text ()). toString ());
2013-12-11 00:12:44 +00:00
_ui -> source_checkBox_ignoreOdometry -> setChecked ( settings . value ( "ignoreOdometry" , _ui -> source_checkBox_ignoreOdometry -> isChecked ()). toBool ());
2012-12-11 18:05:05 +00:00
_ui -> source_spinBox_databaseStartPos -> setValue ( settings . value ( "startPos" , _ui -> source_spinBox_databaseStartPos -> value ()). toInt ());
2012-06-24 17:19:34 +00:00
settings . endGroup (); // Database
2013-12-11 00:12:44 +00:00
settings . beginGroup ( "Openni" );
_ui -> groupBox_sourceOpenni -> setChecked ( settings . value ( "openniUsed" , _ui -> groupBox_sourceOpenni -> isChecked ()). toBool ());
2014-06-03 04:42:08 +00:00
_ui -> radioButton_openni -> setChecked ( settings . value ( "openniType" , _ui -> radioButton_openni -> isChecked ()). toBool ());
_ui -> radioButton_freenect -> setChecked ( settings . value ( "freenectType" , _ui -> radioButton_freenect -> isChecked ()). toBool ());
2013-12-11 00:12:44 +00:00
_ui -> lineEdit_openniDevice -> setText ( settings . value ( "device" , _ui -> lineEdit_openniDevice -> text ()). toString ());
_ui -> lineEdit_openniLocalTransform -> setText ( settings . value ( "localTransform" , _ui -> lineEdit_openniLocalTransform -> text ()). toString ());
settings . endGroup (); // Openni
2011-06-05 14:45:39 +00:00
}
2012-06-26 14:57:31 +00:00
bool PreferencesDialog :: readCoreSettings ( const QString & filePath )
2011-06-05 14:45:39 +00:00
{
UDEBUG ( "" );
QString path = getIniFilePath ();
if ( ! filePath . isEmpty ())
{
path = filePath ;
}
2012-06-26 14:57:31 +00:00
if ( ! QFile :: exists ( path ))
{
QMessageBox :: information ( this , tr ( "INI file doesn't exist..." ), tr ( "The configuration file \" %1 \" does not exist, it will be created with default parameters." ). arg ( path ));
}
2011-06-05 14:45:39 +00:00
QSettings settings ( path , QSettings :: IniFormat );
2012-12-11 18:05:05 +00:00
2011-06-05 14:45:39 +00:00
settings . beginGroup ( "Core" );
QStringList keys = settings . allKeys ();
2012-12-11 18:05:05 +00:00
// Get profile
const rtabmap :: ParametersMap & parameters = Parameters :: getDefaultParameters ();
2011-06-05 14:45:39 +00:00
for ( rtabmap :: ParametersMap :: const_iterator iter = parameters . begin (); iter != parameters . end (); ++ iter )
{
QString key (( * iter ). first . c_str ());
QString value = settings . value ( key , "" ). toString ();
if ( ! value . isEmpty ())
{
this -> setParameter ( key . toStdString (), value . toStdString ());
}
else
{
UDEBUG ( "key.toStdString()=%s" , key . toStdString (). c_str ());
// Use the default value if the key doesn't exist yet
this -> setParameter ( key . toStdString (), ( * iter ). second );
// Add information about the working directory if not in the config file
if ( key . toStdString (). compare ( Parameters :: kRtabmapWorkingDirectory ()) == 0 )
{
if ( ! _initialized )
{
QMessageBox :: information ( this ,
tr ( "Working directory" ),
tr ( "RTAB-Map needs a working directory to put the database. \n\n "
"By default, the directory \" %1 \" is used. \n\n "
"The working directory can be changed any time in the "
"preferences menu." ). arg (
Parameters :: defaultRtabmapWorkingDirectory (). c_str ()));
}
}
}
}
settings . endGroup (); // Core
2012-06-26 14:57:31 +00:00
return true ;
2011-06-05 14:45:39 +00:00
}
2014-01-22 19:49:28 +00:00
bool PreferencesDialog :: saveConfigTo ()
2011-06-05 14:45:39 +00:00
{
2014-01-22 19:49:28 +00:00
QString path = QFileDialog :: getSaveFileName ( this , tr ( "Save settings..." ), this -> getWorkingDirectory () + "/config.ini" , "*.ini" );
2011-06-05 14:45:39 +00:00
if ( ! path . isEmpty ())
{
this -> writeSettings ( path );
2014-01-22 19:49:28 +00:00
return true ;
}
return false ;
}
void PreferencesDialog :: resetConfig ()
{
int button = QMessageBox :: warning ( this ,
tr ( "Reset settings..." ),
tr ( "This will reset all settings. Restore all settings to default without saving them first?" ),
QMessageBox :: Cancel | QMessageBox :: Yes | QMessageBox :: Save ,
QMessageBox :: Cancel );
if ( button == QMessageBox :: Yes ||
( button == QMessageBox :: Save && saveConfigTo ()))
{
this -> resetSettings ( - 1 );
2011-06-05 14:45:39 +00:00
}
}
void PreferencesDialog :: writeSettings ( const QString & filePath )
{
writeGuiSettings ( filePath );
writeCameraSettings ( filePath );
writeCoreSettings ( filePath );
if ( _parameters . size ())
{
emit settingsChanged ( _parameters );
}
if ( _obsoletePanels )
{
emit settingsChanged ( _obsoletePanels );
}
_parameters . clear ();
_obsoletePanels = kPanelDummy ;
}
void PreferencesDialog :: writeGuiSettings ( const QString & filePath )
{
QString path = getIniFilePath ();
if ( ! filePath . isEmpty ())
{
path = filePath ;
}
QSettings settings ( path , QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( "General" );
settings . setValue ( "imagesKept" , _ui -> general_checkBox_imagesKept -> isChecked ());
settings . setValue ( "loggerLevel" , _ui -> comboBox_loggerLevel -> currentIndex ());
settings . setValue ( "loggerEventLevel" , _ui -> comboBox_loggerEventLevel -> currentIndex ());
settings . setValue ( "loggerPauseLevel" , _ui -> comboBox_loggerPauseLevel -> currentIndex ());
settings . setValue ( "loggerType" , _ui -> comboBox_loggerType -> currentIndex ());
settings . setValue ( "loggerPrintTime" , _ui -> checkBox_logger_printTime -> isChecked ());
settings . setValue ( "verticalLayoutUsed" , _ui -> checkBox_verticalLayoutUsed -> isChecked ());
settings . setValue ( "imageFlipped" , _ui -> checkBox_imageFlipped -> isChecked ());
settings . setValue ( "imageRejectedShown" , _ui -> checkBox_imageRejectedShown -> isChecked ());
2011-06-10 14:04:06 +00:00
settings . setValue ( "imageHighestHypShown" , _ui -> checkBox_imageHighestHypShown -> isChecked ());
2011-06-05 14:45:39 +00:00
settings . setValue ( "beep" , _ui -> checkBox_beep -> isChecked ());
settings . setValue ( "keypointsOpacity" , _ui -> horizontalSlider_keypointsOpacity -> value ());
2013-12-11 00:12:44 +00:00
for ( int i = 0 ; i < 3 ; ++ i )
{
settings . setValue ( tr ( "showClouds%1" ). arg ( i ), _3dRenderingShowClouds [ i ] -> isChecked ());
settings . setValue ( tr ( "voxelSize%1" ). arg ( i ), _3dRenderingVoxelSize [ i ] -> value ());
settings . setValue ( tr ( "decimation%1" ). arg ( i ), _3dRenderingDecimation [ i ] -> value ());
settings . setValue ( tr ( "maxDepth%1" ). arg ( i ), _3dRenderingMaxDepth [ i ] -> value ());
settings . setValue ( tr ( "showScans%1" ). arg ( i ), _3dRenderingShowScans [ i ] -> isChecked ());
if ( i < 2 )
{
settings . setValue ( tr ( "opacity%1" ). arg ( i ), _3dRenderingOpacity [ i ] -> value ());
settings . setValue ( tr ( "ptSize%1" ). arg ( i ), _3dRenderingPtSize [ i ] -> value ());
settings . setValue ( tr ( "opacityScan%1" ). arg ( i ), _3dRenderingOpacityScan [ i ] -> value ());
settings . setValue ( tr ( "ptSizeScan%1" ). arg ( i ), _3dRenderingPtSizeScan [ i ] -> value ());
2014-06-03 19:28:59 +00:00
settings . setValue ( tr ( "meshNormalKSearch%1" ). arg ( i ), _3dRenderingNormalKSearch [ i ] -> value ());
settings . setValue ( tr ( "meshGP3Radius%1" ). arg ( i ), _3dRenderingGP3Radius [ i ] -> value ());
settings . setValue ( tr ( "meshSmoothing%1" ). arg ( i ), _3dRenderingSmoothing [ i ] -> isChecked ());
settings . setValue ( tr ( "meshSmoothingRadius%1" ). arg ( i ), _3dRenderingSmoothingRadius [ i ] -> value ());
2013-12-11 00:12:44 +00:00
}
if ( i < 1 )
{
settings . setValue ( tr ( "meshing%1" ). arg ( i ), _3dRenderingMeshing [ i ] -> isChecked ());
}
}
2014-02-13 21:32:46 +00:00
settings . setValue ( "cloudFiltering" , _ui -> groupBox_poseFiltering -> isChecked ());
settings . setValue ( "cloudFilteringRadius" , _ui -> doubleSpinBox_cloudFilterRadius -> value ());
settings . setValue ( "cloudFilteringAngle" , _ui -> doubleSpinBox_cloudFilterAngle -> value ());
2013-12-11 00:12:44 +00:00
2011-06-05 14:45:39 +00:00
settings . endGroup (); // General
settings . endGroup (); // rtabmap
}
void PreferencesDialog :: writeCameraSettings ( const QString & filePath )
{
QString path = getIniFilePath ();
if ( ! filePath . isEmpty ())
{
path = filePath ;
}
QSettings settings ( path , QSettings :: IniFormat );
settings . beginGroup ( "Camera" );
2012-06-24 17:19:34 +00:00
settings . setValue ( "imageUsed" , _ui -> groupBox_sourceImage -> isChecked ());
2011-06-05 14:45:39 +00:00
settings . setValue ( "imgRate" , _ui -> general_doubleSpinBox_imgRate -> value ());
settings . setValue ( "autoRestart" , _ui -> general_checkBox_autoRestart -> isChecked ());
2012-03-03 01:46:30 +00:00
settings . setValue ( "cameraKeypoints" , _ui -> general_checkBox_cameraKeypoints -> isChecked ());
2012-06-24 17:19:34 +00:00
settings . setValue ( "type" , _ui -> source_comboBox_image_type -> currentIndex ());
2011-06-05 14:45:39 +00:00
settings . setValue ( "imgWidth" , _ui -> source_spinBox_imgWidth -> value ());
settings . setValue ( "imgHeight" , _ui -> source_spinBox_imgheight -> value ());
2012-06-24 17:19:34 +00:00
settings . setValue ( "framesDropped" , _ui -> source_spinBox_framesDropped -> value ());
2011-06-05 14:45:39 +00:00
//usbDevice group
settings . beginGroup ( "usbDevice" );
settings . setValue ( "id" , _ui -> source_usbDevice_spinBox_id -> value ());
settings . endGroup (); //usbDevice
//images group
settings . beginGroup ( "images" );
settings . setValue ( "path" , _ui -> source_images_lineEdit_path -> text ());
settings . setValue ( "startPos" , _ui -> source_images_spinBox_startPos -> value ());
settings . setValue ( "refreshDir" , _ui -> source_images_refreshDir -> isChecked ());
settings . endGroup (); //images
//video group
settings . beginGroup ( "video" );
settings . setValue ( "path" , _ui -> source_video_lineEdit_path -> text ());
settings . endGroup (); //video
settings . endGroup (); // Camera
2012-06-24 17:19:34 +00:00
settings . beginGroup ( "Database" );
settings . setValue ( "databaseUsed" , _ui -> groupBox_sourceDatabase -> isChecked ());
settings . setValue ( "path" , _ui -> source_database_lineEdit_path -> text ());
2013-12-11 00:12:44 +00:00
settings . setValue ( "ignoreOdometry" , _ui -> source_checkBox_ignoreOdometry -> isChecked ());
2012-12-11 18:05:05 +00:00
settings . setValue ( "startPos" , _ui -> source_spinBox_databaseStartPos -> value ());
2012-06-24 17:19:34 +00:00
settings . endGroup ();
2013-12-11 00:12:44 +00:00
settings . beginGroup ( "Openni" );
settings . setValue ( "openniUsed" , _ui -> groupBox_sourceOpenni -> isChecked ());
2014-06-03 04:42:08 +00:00
settings . setValue ( "openniType" , _ui -> radioButton_openni -> isChecked ());
settings . setValue ( "freenectType" , _ui -> radioButton_freenect -> isChecked ());
2013-12-11 00:12:44 +00:00
settings . setValue ( "device" , _ui -> lineEdit_openniDevice -> text ());
settings . setValue ( "localTransform" , _ui -> lineEdit_openniLocalTransform -> text ());
settings . endGroup ();
2011-06-05 14:45:39 +00:00
}
void PreferencesDialog :: writeCoreSettings ( const QString & filePath )
{
QString path = getIniFilePath ();
if ( ! filePath . isEmpty ())
{
path = filePath ;
}
QSettings settings ( path , QSettings :: IniFormat );
settings . beginGroup ( "Core" );
const rtabmap :: ParametersMap & parameters = Parameters :: getDefaultParameters ();
for ( rtabmap :: ParametersMap :: const_iterator iter = parameters . begin (); iter != parameters . end (); ++ iter )
{
QObject * obj = _ui -> stackedWidget -> findChild < QObject *> (( * iter ). first . c_str ());
if ( obj )
{
QSpinBox * spin = qobject_cast < QSpinBox *> ( obj );
QDoubleSpinBox * doubleSpin = qobject_cast < QDoubleSpinBox *> ( obj );
QComboBox * combo = qobject_cast < QComboBox *> ( obj );
QCheckBox * check = qobject_cast < QCheckBox *> ( obj );
2013-12-11 00:12:44 +00:00
QRadioButton * radio = qobject_cast < QRadioButton *> ( obj );
2011-06-05 14:45:39 +00:00
QLineEdit * lineEdit = qobject_cast < QLineEdit *> ( obj );
2014-01-22 19:49:28 +00:00
QGroupBox * groupBox = qobject_cast < QGroupBox *> ( obj );
2011-06-05 14:45:39 +00:00
if ( spin )
{
settings . setValue ( obj -> objectName (), spin -> value ());
}
else if ( doubleSpin )
{
settings . setValue ( obj -> objectName (), doubleSpin -> value ());
}
else if ( combo )
{
settings . setValue ( obj -> objectName (), combo -> currentIndex ());
}
else if ( check )
{
2012-03-03 01:46:30 +00:00
settings . setValue ( obj -> objectName (), uBool2Str ( check -> isChecked ()). c_str ());
2011-06-05 14:45:39 +00:00
}
2013-12-11 00:12:44 +00:00
else if ( radio )
{
settings . setValue ( obj -> objectName (), uBool2Str ( radio -> isChecked ()). c_str ());
}
2011-06-05 14:45:39 +00:00
else if ( lineEdit )
{
settings . setValue ( obj -> objectName (), lineEdit -> text ());
}
2014-01-22 19:49:28 +00:00
else if ( groupBox )
{
settings . setValue ( obj -> objectName (), uBool2Str ( groupBox -> isChecked ()). c_str ());
}
2011-06-05 14:45:39 +00:00
else
{
ULOGGER_WARN ( "QObject called %s can't be cast to a supported widget" , ( * iter ). first . c_str ());
}
}
else
{
ULOGGER_WARN ( "Can't find the related QObject for parameter %s" , ( * iter ). first . c_str ());
}
}
settings . endGroup (); // Core
}
bool PreferencesDialog :: validateForm ()
{
2011-06-09 13:57:01 +00:00
//TODO...
2011-06-05 14:45:39 +00:00
return true ;
}
QString PreferencesDialog :: getParamMessage ()
{
return tr ( "Reading parameters from the configuration file..." );
}
void PreferencesDialog :: showEvent ( QShowEvent * event )
{
2013-12-11 00:12:44 +00:00
if ( _monitoringState )
{
// In monitoring state, you cannot change remote paths
_ui -> lineEdit_databasePath -> setEnabled ( false );
_ui -> lineEdit_databasePath_2 -> setEnabled ( false );
_ui -> toolButton_databasePath -> setEnabled ( false );
_ui -> toolButton_databasePath_2 -> setEnabled ( false );
_ui -> label_databasePath -> setEnabled ( false );
_ui -> label_databasePath_2 -> setEnabled ( false );
_ui -> lineEdit_workingDirectory -> setEnabled ( false );
_ui -> toolButton_workingDirectory -> setEnabled ( false );
_ui -> label_workingDirectory -> setEnabled ( false );
_ui -> lineEdit_dictionaryPath -> setEnabled ( false );
_ui -> toolButton_dictionaryPath -> setEnabled ( false );
_ui -> label_dictionaryPath -> setEnabled ( false );
_ui -> groupBox_source0 -> setEnabled ( false );
_ui -> groupBox_odometry2 -> setEnabled ( false );
this -> setWindowTitle ( tr ( "Preferences [Monitoring mode]" ));
}
else
{
_ui -> lineEdit_databasePath -> setEnabled ( true );
_ui -> lineEdit_databasePath_2 -> setEnabled ( true );
_ui -> toolButton_databasePath -> setEnabled ( true );
_ui -> toolButton_databasePath_2 -> setEnabled ( true );
_ui -> label_databasePath -> setEnabled ( true );
_ui -> label_databasePath_2 -> setEnabled ( true );
_ui -> lineEdit_workingDirectory -> setEnabled ( true );
_ui -> toolButton_workingDirectory -> setEnabled ( true );
_ui -> label_workingDirectory -> setEnabled ( true );
2014-02-13 21:32:46 +00:00
2013-12-11 00:12:44 +00:00
_ui -> lineEdit_dictionaryPath -> setEnabled ( true );
_ui -> toolButton_dictionaryPath -> setEnabled ( true );
_ui -> label_dictionaryPath -> setEnabled ( true );
2014-02-13 21:32:46 +00:00
2013-12-11 00:12:44 +00:00
_ui -> groupBox_source0 -> setEnabled ( true );
_ui -> groupBox_odometry2 -> setEnabled ( true );
this -> setWindowTitle ( tr ( "Preferences" ));
}
2011-06-09 13:57:01 +00:00
this -> readSettingsBegin ();
}
void PreferencesDialog :: readSettingsBegin ()
{
_progressDialog -> setLabelText ( this -> getParamMessage ());
_progressDialog -> show ();
// this will let the MainThread to display the progress dialog before reading the parameters...
QTimer :: singleShot ( 10 , this , SLOT ( readSettingsEnd ()));
}
void PreferencesDialog :: readSettingsEnd ()
{
QApplication :: processEvents ();
2011-06-05 14:45:39 +00:00
this -> readSettings ();
2011-06-09 13:57:01 +00:00
_progressDialog -> setValue ( 1 );
2012-06-26 14:57:31 +00:00
if ( this -> isVisible ())
{
_progressDialog -> setLabelText ( tr ( "Setup dialog..." ));
2011-06-09 13:57:01 +00:00
2012-06-26 14:57:31 +00:00
this -> updatePredictionPlot ();
this -> setupKpRoiPanel ();
}
2011-06-09 13:57:01 +00:00
_progressDialog -> setValue ( 2 ); // this will make closing...
2011-06-05 14:45:39 +00:00
}
void PreferencesDialog :: saveWindowGeometry ( const QString & windowName , const QWidget * window )
{
QSettings settings ( getIniFilePath (), QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( windowName );
settings . setValue ( "geometry" , window -> saveGeometry ());
settings . endGroup (); // "windowName"
settings . endGroup (); // rtabmap
}
void PreferencesDialog :: loadWindowGeometry ( const QString & windowName , QWidget * window )
{
QByteArray bytes ;
QSettings settings ( getIniFilePath (), QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( windowName );
bytes = settings . value ( "geometry" , QByteArray ()). toByteArray ();
if ( ! bytes . isEmpty ())
{
window -> restoreGeometry ( bytes );
}
settings . endGroup (); // "windowName"
settings . endGroup (); // rtabmap
}
void PreferencesDialog :: saveMainWindowState ( const QMainWindow * mainWindow )
{
QSettings settings ( getIniFilePath (), QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( "MainWindow" );
settings . setValue ( "state" , mainWindow -> saveState ());
settings . endGroup (); // "MainWindow"
settings . endGroup (); // rtabmap
saveWindowGeometry ( "MainWindow" , mainWindow );
}
void PreferencesDialog :: loadMainWindowState ( QMainWindow * mainWindow )
{
QByteArray bytes ;
QSettings settings ( getIniFilePath (), QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( "MainWindow" );
bytes = settings . value ( "state" , QByteArray ()). toByteArray ();
if ( ! bytes . isEmpty ())
{
mainWindow -> restoreState ( bytes );
}
settings . endGroup (); // "MainWindow"
settings . endGroup (); // rtabmap
loadWindowGeometry ( "MainWindow" , mainWindow );
}
void PreferencesDialog :: saveCustomConfig ( const QString & section , const QString & key , const QString & value )
{
QSettings settings ( getIniFilePath (), QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( section );
settings . setValue ( key , value );
settings . endGroup (); // "section"
settings . endGroup (); // rtabmap
}
QString PreferencesDialog :: loadCustomConfig ( const QString & section , const QString & key )
{
QString value ;
QSettings settings ( getIniFilePath (), QSettings :: IniFormat );
settings . beginGroup ( "Gui" );
settings . beginGroup ( section );
value = settings . value ( key , QString ()). toString ();
settings . endGroup (); // "section"
settings . endGroup (); // rtabmap
return value ;
}
2012-06-24 17:19:34 +00:00
void PreferencesDialog :: selectSourceImage ( Src src )
2011-06-05 14:45:39 +00:00
{
2012-06-24 17:19:34 +00:00
ULOGGER_DEBUG ( "" );
2011-06-05 14:45:39 +00:00
2013-12-11 00:12:44 +00:00
if ( _ui -> general_checkBox_activateRGBD -> isChecked ())
{
int button = QMessageBox :: information ( this ,
tr ( "Desactivate RGB-D SLAM?" ),
tr ( "You've selected source input as images only and RGB-D SLAM mode is activated. "
"RGB-D SLAM cannot work with images only so do you want to desactivate it?" ),
QMessageBox :: Yes | QMessageBox :: No );
if ( button & QMessageBox :: Yes )
{
_ui -> general_checkBox_activateRGBD -> setChecked ( false );
}
}
2011-06-05 14:45:39 +00:00
bool fromPrefDialog = false ;
//bool modified = false;
if ( src == kSrcUndef )
{
fromPrefDialog = true ;
2012-06-24 17:19:34 +00:00
if ( _ui -> source_comboBox_image_type -> currentIndex () == 1 )
2011-06-05 14:45:39 +00:00
{
src = kSrcImages ;
}
2012-06-24 17:19:34 +00:00
else if ( _ui -> source_comboBox_image_type -> currentIndex () == 2 )
2011-06-05 14:45:39 +00:00
{
src = kSrcVideo ;
}
else
{
src = kSrcUsbDevice ;
}
}
2012-06-24 17:19:34 +00:00
else
{
// from user
_ui -> groupBox_sourceImage -> setChecked ( true );
}
2011-06-05 14:45:39 +00:00
if ( src == kSrcImages )
{
QString path = QFileDialog :: getExistingDirectory ( this , QString (), _ui -> source_images_lineEdit_path -> text ());
QDir dir ( path );
if ( ! path . isEmpty () && dir . exists ())
{
QStringList filters ;
2011-06-30 02:51:37 +00:00
filters << "*.jpg" << "*.ppm" << "*.bmp" << "*.png" << "*.pnm" ;
2011-06-05 14:45:39 +00:00
dir . setNameFilters ( filters );
QFileInfoList files = dir . entryInfoList ();
if ( ! files . empty ())
{
2012-06-24 17:19:34 +00:00
_ui -> source_comboBox_image_type -> setCurrentIndex ( 1 );
2011-06-05 14:45:39 +00:00
_ui -> source_images_lineEdit_path -> setText ( path );
_ui -> source_images_spinBox_startPos -> setValue ( 1 );
_ui -> source_images_refreshDir -> setChecked ( false );
}
else
{
QMessageBox :: information ( this ,
tr ( "RTAB-Map" ),
tr ( "Images must be one of these formats: " ) + filters . join ( " " ));
}
}
}
else if ( src == kSrcVideo )
{
2012-06-24 17:19:34 +00:00
QString path = QFileDialog :: getOpenFileName ( this , tr ( "Select file" ), _ui -> source_video_lineEdit_path -> text (), tr ( "Videos (*.avi *.mpg *.mp4)" ));
2011-06-05 14:45:39 +00:00
QFile file ( path );
if ( ! path . isEmpty () && file . exists ())
{
2012-06-24 17:19:34 +00:00
_ui -> source_comboBox_image_type -> setCurrentIndex ( 2 );
2011-06-05 14:45:39 +00:00
_ui -> source_video_lineEdit_path -> setText ( path );
}
}
2013-12-11 00:12:44 +00:00
else // kSrcUsbDevice
2011-06-05 14:45:39 +00:00
{
2012-06-24 17:19:34 +00:00
_ui -> source_comboBox_image_type -> setCurrentIndex ( 0 );
2011-06-05 14:45:39 +00:00
}
if ( ! fromPrefDialog && _obsoletePanels )
{
2012-06-24 17:19:34 +00:00
_ui -> groupBox_sourceDatabase -> setChecked ( false );
2013-12-11 00:12:44 +00:00
_ui -> groupBox_sourceOpenni -> setChecked ( false );
2012-06-24 17:19:34 +00:00
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
this -> readSettingsBegin ();
}
}
}
void PreferencesDialog :: selectSourceDatabase ( bool user )
{
ULOGGER_DEBUG ( "" );
if ( user )
{
// from user
_ui -> groupBox_sourceDatabase -> setChecked ( true );
}
QString path = QFileDialog :: getOpenFileName ( this , tr ( "Select file" ), _ui -> source_database_lineEdit_path -> text (), tr ( "RTAB-Map database files (*.db)" ));
QFile file ( path );
if ( ! path . isEmpty () && file . exists ())
{
_ui -> source_database_lineEdit_path -> setText ( path );
2012-12-11 18:05:05 +00:00
_ui -> source_spinBox_databaseStartPos -> setValue ( 0 );
2012-06-24 17:19:34 +00:00
}
if ( user && _obsoletePanels )
{
_ui -> groupBox_sourceImage -> setChecked ( false );
2013-12-11 00:12:44 +00:00
_ui -> groupBox_sourceOpenni -> setChecked ( false );
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
this -> readSettingsBegin ();
}
}
}
2014-06-03 04:42:08 +00:00
void PreferencesDialog :: selectSourceOpenni ( bool openni )
2013-12-11 00:12:44 +00:00
{
ULOGGER_DEBUG ( "" );
if ( ! _ui -> general_checkBox_activateRGBD -> isChecked ())
{
int button = QMessageBox :: information ( this ,
tr ( "Activate RGB-D SLAM?" ),
2014-06-03 04:42:08 +00:00
tr ( "You've selected %1 camera as source input, "
"would you want to activate RGB-D SLAM mode?" ). arg ( openni ? "OpenNI" : "Freenect" ),
2013-12-11 00:12:44 +00:00
QMessageBox :: Yes | QMessageBox :: No );
if ( button & QMessageBox :: Yes )
{
_ui -> general_checkBox_activateRGBD -> setChecked ( true );
}
}
2014-06-03 04:42:08 +00:00
_ui -> groupBox_sourceOpenni -> setChecked ( true );
_ui -> radioButton_openni -> setChecked ( openni );
_ui -> radioButton_freenect -> setChecked ( ! openni );
2013-12-11 00:12:44 +00:00
2014-06-03 04:42:08 +00:00
if ( _obsoletePanels )
2013-12-11 00:12:44 +00:00
{
_ui -> groupBox_sourceImage -> setChecked ( false );
_ui -> groupBox_sourceDatabase -> setChecked ( false );
2011-06-05 14:45:39 +00:00
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
2011-06-09 16:00:45 +00:00
this -> readSettingsBegin ();
2011-06-05 14:45:39 +00:00
}
}
}
2012-12-11 18:05:05 +00:00
void PreferencesDialog :: openDatabaseViewer ()
{
DatabaseViewer * viewer = new DatabaseViewer ( this );
viewer -> setAttribute ( Qt :: WA_DeleteOnClose , true );
viewer -> setWindowModality ( Qt :: WindowModal );
if ( viewer -> openDatabase ( _ui -> source_database_lineEdit_path -> text ()))
{
viewer -> show ();
}
else
{
delete viewer ;
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: setParameter ( const std :: string & key , const std :: string & value )
{
2011-06-09 16:00:45 +00:00
UDEBUG ( "%s=%s" , key . c_str (), value . c_str ());
2011-06-05 14:45:39 +00:00
QObject * obj = _ui -> stackedWidget -> findChild < QObject *> ( key . c_str ());
if ( obj )
{
QSpinBox * spin = qobject_cast < QSpinBox *> ( obj );
QDoubleSpinBox * doubleSpin = qobject_cast < QDoubleSpinBox *> ( obj );
QComboBox * combo = qobject_cast < QComboBox *> ( obj );
QCheckBox * check = qobject_cast < QCheckBox *> ( obj );
2013-12-11 00:12:44 +00:00
QRadioButton * radio = qobject_cast < QRadioButton *> ( obj );
2011-06-05 14:45:39 +00:00
QLineEdit * lineEdit = qobject_cast < QLineEdit *> ( obj );
2014-01-22 19:49:28 +00:00
QGroupBox * groupBox = qobject_cast < QGroupBox *> ( obj );
2012-12-11 18:05:05 +00:00
bool ok ;
2011-06-05 14:45:39 +00:00
if ( spin )
{
2012-12-11 18:05:05 +00:00
spin -> setValue ( QString ( value . c_str ()). toInt ( & ok ));
if ( ! ok )
{
UERROR ( "Conversion failed from \" %s \" for parameter %s" , value . c_str (), key . c_str ());
}
2011-06-05 14:45:39 +00:00
}
else if ( doubleSpin )
{
2012-12-11 18:05:05 +00:00
doubleSpin -> setValue ( QString ( value . c_str ()). toDouble ( & ok ));
if ( ! ok )
{
UERROR ( "Conversion failed from \" %s \" for parameter %s" , value . c_str (), key . c_str ());
}
2011-06-05 14:45:39 +00:00
}
else if ( combo )
{
2012-12-11 18:05:05 +00:00
combo -> setCurrentIndex ( QString ( value . c_str ()). toInt ( & ok ));
if ( ! ok )
{
UERROR ( "Conversion failed from \" %s \" for parameter %s" , value . c_str (), key . c_str ());
}
2011-06-05 14:45:39 +00:00
}
else if ( check )
{
check -> setChecked ( uStr2Bool ( value . c_str ()));
}
2013-12-11 00:12:44 +00:00
else if ( radio )
{
radio -> setChecked ( uStr2Bool ( value . c_str ()));
}
2011-06-05 14:45:39 +00:00
else if ( lineEdit )
{
lineEdit -> setText ( value . c_str ());
}
2014-01-22 19:49:28 +00:00
else if ( groupBox )
{
groupBox -> setChecked ( uStr2Bool ( value . c_str ()));
}
2011-06-05 14:45:39 +00:00
else
{
ULOGGER_WARN ( "QObject called %s can't be cast to a supported widget" , key . c_str ());
}
}
else
{
ULOGGER_WARN ( "Can't find the related QObject for parameter %s" , key . c_str ());
}
}
void PreferencesDialog :: addParameter ( int value )
{
if ( sender ())
{
this -> addParameter ( sender (), value );
}
else
{
ULOGGER_ERROR ( "This slot must be triggered by a signal, not a direct call..." );
}
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: addParameter ( bool value )
{
if ( sender ())
{
this -> addParameter ( sender (), value );
}
else
{
ULOGGER_ERROR ( "This slot must be triggered by a signal, not a direct call..." );
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: addParameter ( double value )
{
if ( sender ())
{
this -> addParameter ( sender (), value );
}
else
{
ULOGGER_ERROR ( "This slot must be triggered by a signal, not a direct call..." );
}
}
void PreferencesDialog :: addParameter ( const QString & value )
{
if ( sender ())
{
this -> addParameter ( sender (), value );
}
else
{
ULOGGER_ERROR ( "This slot must be triggered by a signal, not a direct call..." );
}
}
void PreferencesDialog :: addParameter ( const QObject * object , int value )
{
if ( object )
{
// Make sure the value is inserted, check if the same key already exists
rtabmap :: ParametersMap :: iterator iter = _parameters . find ( object -> objectName (). toStdString ());
if ( iter != _parameters . end ())
{
_parameters . erase ( iter );
}
2012-03-03 01:46:30 +00:00
const QComboBox * comboBox = qobject_cast < const QComboBox *> ( object );
const QSpinBox * spinbox = qobject_cast < const QSpinBox *> ( object );
if ( comboBox || spinbox )
{
if ( comboBox )
{
// Add related panels to parameters
if ( comboBox == _ui -> comboBox_vh_strategy )
{
if ( value == 0 ) // 0 none
{
// No panel related...
}
2012-12-11 18:05:05 +00:00
else if ( value == 1 ) // 2 epipolar
2012-03-03 01:46:30 +00:00
{
this -> addParameters ( _ui -> groupBox_vh_epipolar2 );
}
}
else if ( comboBox == _ui -> comboBox_detector_strategy )
{
if ( value == 0 ) // 0 surf
{
2013-12-11 00:12:44 +00:00
this -> addParameters ( _ui -> groupBox_detector_surf );
_ui -> stackedWidget_visualWord -> setCurrentIndex ( 0 );
2012-03-03 01:46:30 +00:00
}
2012-12-11 18:05:05 +00:00
else if ( value == 1 ) // 1 sift
2012-03-03 01:46:30 +00:00
{
2013-12-11 00:12:44 +00:00
this -> addParameters ( _ui -> groupBox_detector_sift );
_ui -> stackedWidget_visualWord -> setCurrentIndex ( 1 );
2012-03-03 01:46:30 +00:00
}
}
2013-12-11 00:12:44 +00:00
else if ( comboBox == _ui -> odom_type )
2012-03-03 01:46:30 +00:00
{
2013-12-11 00:12:44 +00:00
if ( value == 0 ) // 0 bow
2012-03-03 01:46:30 +00:00
{
2013-12-11 00:12:44 +00:00
this -> addParameters ( _ui -> groupBox_odom_bow );
_ui -> stackedWidget_odom -> setCurrentIndex ( 0 );
2012-03-03 01:46:30 +00:00
}
2013-12-11 00:12:44 +00:00
else if ( value == 1 ) // 1 fast
2012-03-03 01:46:30 +00:00
{
2013-12-11 00:12:44 +00:00
this -> addParameters ( _ui -> groupBox_odom_fast );
_ui -> stackedWidget_odom -> setCurrentIndex ( 1 );
}
else if ( value == 2 ) // 1 fast
{
this -> addParameters ( _ui -> groupBox_odom_icp );
_ui -> stackedWidget_odom -> setCurrentIndex ( 2 );
}
}
2014-01-22 19:49:28 +00:00
else if ( comboBox == _ui -> globalDetection_icpType )
2013-12-11 00:12:44 +00:00
{
2014-01-22 19:49:28 +00:00
if ( value == 1 ) // 1 icp3
2013-12-11 00:12:44 +00:00
{
this -> addParameters ( _ui -> groupBox_loopClosure_icp3 );
}
2014-01-22 19:49:28 +00:00
else if ( value == 2 ) // 2 icp2
2013-12-11 00:12:44 +00:00
{
this -> addParameters ( _ui -> groupBox_loopClosure_icp2 );
2012-03-03 01:46:30 +00:00
}
}
}
// Add parameter
_parameters . insert ( rtabmap :: ParametersPair ( object -> objectName (). toStdString (), QString :: number ( value ). toStdString ()));
}
2013-12-11 00:12:44 +00:00
else
{
UWARN ( "Undefined object \" %s \" " , object -> objectName (). toStdString (). c_str ());
}
}
else
{
ULOGGER_ERROR ( "Object is null" );
}
}
void PreferencesDialog :: addParameter ( const QObject * object , bool value )
{
if ( object )
{
// Make sure the value is inserted, check if the same key already exists
rtabmap :: ParametersMap :: iterator iter = _parameters . find ( object -> objectName (). toStdString ());
if ( iter != _parameters . end ())
{
_parameters . erase ( iter );
}
const QCheckBox * checkbox = qobject_cast < const QCheckBox *> ( object );
const QRadioButton * radio = qobject_cast < const QRadioButton *> ( object );
2014-01-22 19:49:28 +00:00
const QGroupBox * groupBox = qobject_cast < const QGroupBox *> ( object );
if ( checkbox || radio || groupBox )
2012-03-03 01:46:30 +00:00
{
// Add parameter
_parameters . insert ( rtabmap :: ParametersPair ( object -> objectName (). toStdString (), uBool2Str ( value )));
2014-01-15 20:41:58 +00:00
2014-01-22 19:49:28 +00:00
// RGBD panel
2014-01-15 20:41:58 +00:00
if ( value && checkbox == _ui -> general_checkBox_activateRGBD )
{
// add all RGBD parameters!
2014-01-22 19:49:28 +00:00
this -> addParameters ( _ui -> groupBox_slam_update );
this -> addParameters ( _ui -> groupBox_odom_correction );
this -> addParameters ( _ui -> groupBox_localDetection_time );
this -> addParameters ( _ui -> groupBox_localDetection_space );
this -> addParameters ( _ui -> groupBox_globalConstraints );
this -> addParameters ( _ui -> groupBox_visualTransform2 );
2014-01-15 20:41:58 +00:00
}
2014-01-22 19:49:28 +00:00
if ( groupBox )
2014-01-15 20:41:58 +00:00
{
2014-01-22 19:49:28 +00:00
// RGBD panel
if ( value && groupBox == _ui -> groupBox_localDetection_time )
{
this -> addParameters ( _ui -> groupBox_globalConstraints );
this -> addParameters ( _ui -> groupBox_visualTransform2 );
}
if ( value && groupBox == _ui -> groupBox_localDetection_space )
{
this -> addParameters ( _ui -> groupBox_loopClosure_icp2 );
}
this -> addParameters ( groupBox );
2014-01-15 20:41:58 +00:00
}
2012-03-03 01:46:30 +00:00
}
else
{
UWARN ( "Undefined object \" %s \" " , object -> objectName (). toStdString (). c_str ());
}
2011-06-05 14:45:39 +00:00
}
else
{
ULOGGER_ERROR ( "Object is null" );
}
}
void PreferencesDialog :: addParameter ( const QObject * object , double value )
{
if ( object )
{
// Make sure the value is inserted, check if the same key already exists
rtabmap :: ParametersMap :: iterator iter = _parameters . find ( object -> objectName (). toStdString ());
if ( iter != _parameters . end ())
{
_parameters . erase ( iter );
}
_parameters . insert ( rtabmap :: ParametersPair ( object -> objectName (). toStdString (), QString :: number ( value ). toStdString ()));
//ULOGGER_DEBUG("PreferencesDialog::addParameter(object, double) Added [\"%s\",\"%s\"]", object->objectName().toStdString().c_str(), QString::number(value).toStdString().c_str());
}
else
{
ULOGGER_ERROR ( "Object is null" );
}
}
void PreferencesDialog :: addParameter ( const QObject * object , const QString & value )
{
if ( object )
{
// Make sure the value is inserted, check if the same key already exists
rtabmap :: ParametersMap :: iterator iter = _parameters . find ( object -> objectName (). toStdString ());
if ( iter != _parameters . end ())
{
_parameters . erase ( iter );
}
_parameters . insert ( rtabmap :: ParametersPair ( object -> objectName (). toStdString (), value . toStdString ()));
//ULOGGER_DEBUG("PreferencesDialog::addParameter(object, QString) Added [\"%s\",\"%s\"]", object->objectName().toStdString().c_str(), QString::number(value).toStdString().c_str());
}
else
{
ULOGGER_ERROR ( "Object is null" );
}
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: addParameters ( const QObjectList & children )
{
//ULOGGER_DEBUG("PreferencesDialog::addParameters(QGroupBox) box %s has %d children", box->objectName().toStdString().c_str(), children.size());
for ( int i = 0 ; i < children . size (); ++ i )
{
const QSpinBox * spin = qobject_cast < const QSpinBox *> ( children [ i ]);
const QDoubleSpinBox * doubleSpin = qobject_cast < const QDoubleSpinBox *> ( children [ i ]);
const QComboBox * combo = qobject_cast < const QComboBox *> ( children [ i ]);
const QCheckBox * check = qobject_cast < const QCheckBox *> ( children [ i ]);
const QRadioButton * radio = qobject_cast < const QRadioButton *> ( children [ i ]);
const QLineEdit * lineEdit = qobject_cast < const QLineEdit *> ( children [ i ]);
const QGroupBox * groupBox = qobject_cast < const QGroupBox *> ( children [ i ]);
const QStackedWidget * stackedWidget = qobject_cast < const QStackedWidget *> ( children [ i ]);
if ( spin )
{
this -> addParameter ( spin , spin -> value ());
}
else if ( doubleSpin )
{
this -> addParameter ( doubleSpin , doubleSpin -> value ());
}
else if ( combo )
{
this -> addParameter ( combo , combo -> currentIndex ());
}
else if ( check )
{
this -> addParameter ( check , check -> isChecked ());
}
else if ( radio )
{
this -> addParameter ( radio , radio -> isChecked ());
}
else if ( lineEdit )
{
this -> addParameter ( lineEdit , lineEdit -> text ());
}
else if ( groupBox )
{
2014-01-22 19:49:28 +00:00
if ( groupBox -> isCheckable ())
{
this -> addParameter ( groupBox , groupBox -> isChecked ());
}
else
{
this -> addParameters ( groupBox );
}
2013-12-11 00:12:44 +00:00
}
else if ( stackedWidget )
{
this -> addParameters ( stackedWidget );
}
}
}
void PreferencesDialog :: addParameters ( const QStackedWidget * stackedWidget )
{
if ( stackedWidget )
{
for ( int i = 0 ; i < stackedWidget -> count (); ++ i )
{
const QObjectList & children = stackedWidget -> widget ( i ) -> children ();
addParameters ( children );
}
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: addParameters ( const QGroupBox * box )
{
if ( box )
{
2013-12-11 00:12:44 +00:00
const QObjectList & children = box -> children ();
addParameters ( children );
2011-06-05 14:45:39 +00:00
}
}
2012-06-24 17:19:34 +00:00
void PreferencesDialog :: updateBasicParameter ()
{
// This method is used to update basic/advanced referred parameters, see above editingFinished()
// basic to advanced (advanced to basic must be done by connecting signal valueChanged())
if ( sender () == _ui -> general_doubleSpinBox_timeThr_2 )
{
_ui -> general_doubleSpinBox_timeThr -> setValue ( _ui -> general_doubleSpinBox_timeThr_2 -> value ());
}
else if ( sender () == _ui -> general_doubleSpinBox_hardThr_2 )
{
_ui -> general_doubleSpinBox_hardThr -> setValue ( _ui -> general_doubleSpinBox_hardThr_2 -> value ());
}
2013-12-11 00:12:44 +00:00
else if ( sender () == _ui -> general_doubleSpinBox_detectionRate_2 )
2012-06-24 17:19:34 +00:00
{
2013-12-11 00:12:44 +00:00
_ui -> general_doubleSpinBox_detectionRate -> setValue ( _ui -> general_doubleSpinBox_detectionRate_2 -> value ());
2012-06-24 17:19:34 +00:00
}
else if ( sender () == _ui -> general_spinBox_imagesBufferSize_2 )
{
_ui -> general_spinBox_imagesBufferSize -> setValue ( _ui -> general_spinBox_imagesBufferSize_2 -> value ());
}
else if ( sender () == _ui -> general_spinBox_maxStMemSize_2 )
{
_ui -> general_spinBox_maxStMemSize -> setValue ( _ui -> general_spinBox_maxStMemSize_2 -> value ());
}
else if ( sender () == _ui -> general_checkBox_publishStats )
{
_ui -> general_checkBox_publishStats_2 -> setChecked ( _ui -> general_checkBox_publishStats -> isChecked ());
}
else if ( sender () == _ui -> general_checkBox_publishStats_2 )
{
_ui -> general_checkBox_publishStats -> setChecked ( _ui -> general_checkBox_publishStats_2 -> isChecked ());
}
2012-12-11 18:05:05 +00:00
else if ( sender () == _ui -> doubleSpinBox_similarityThreshold_2 )
{
_ui -> doubleSpinBox_similarityThreshold -> setValue ( _ui -> doubleSpinBox_similarityThreshold_2 -> value ());
}
2013-12-11 00:12:44 +00:00
else if ( sender () == _ui -> general_checkBox_activateRGBD )
{
_ui -> general_checkBox_activateRGBD_2 -> setChecked ( _ui -> general_checkBox_activateRGBD -> isChecked ());
}
else if ( sender () == _ui -> general_checkBox_activateRGBD_2 )
{
_ui -> general_checkBox_activateRGBD -> setChecked ( _ui -> general_checkBox_activateRGBD_2 -> isChecked ());
}
else if ( sender () == _ui -> general_checkBox_SLAM_mode )
{
_ui -> general_checkBox_SLAM_mode_2 -> setChecked ( _ui -> general_checkBox_SLAM_mode -> isChecked ());
}
else if ( sender () == _ui -> general_checkBox_SLAM_mode_2 )
{
_ui -> general_checkBox_SLAM_mode -> setChecked ( _ui -> general_checkBox_SLAM_mode_2 -> isChecked ());
}
2012-06-24 17:19:34 +00:00
else
{
//update all values (only those using editingFinished signal)
_ui -> general_doubleSpinBox_timeThr -> setValue ( _ui -> general_doubleSpinBox_timeThr_2 -> value ());
_ui -> general_doubleSpinBox_hardThr -> setValue ( _ui -> general_doubleSpinBox_hardThr_2 -> value ());
2013-12-11 00:12:44 +00:00
_ui -> general_doubleSpinBox_detectionRate -> setValue ( _ui -> general_doubleSpinBox_detectionRate_2 -> value ());
2012-06-24 17:19:34 +00:00
_ui -> general_spinBox_imagesBufferSize -> setValue ( _ui -> general_spinBox_imagesBufferSize_2 -> value ());
_ui -> general_spinBox_maxStMemSize -> setValue ( _ui -> general_spinBox_maxStMemSize_2 -> value ());
2012-12-11 18:05:05 +00:00
_ui -> doubleSpinBox_similarityThreshold -> setValue ( _ui -> doubleSpinBox_similarityThreshold_2 -> value ());
2012-06-24 17:19:34 +00:00
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: makeObsoleteGeneralPanel ()
{
ULOGGER_DEBUG ( "" );
_obsoletePanels = _obsoletePanels | kPanelGeneral ;
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: makeObsoleteCloudRenderingPanel ()
{
ULOGGER_DEBUG ( "" );
_obsoletePanels = _obsoletePanels | kPanelCloudRendering ;
}
void PreferencesDialog :: makeObsoleteLoggingPanel ()
{
ULOGGER_DEBUG ( "" );
_obsoletePanels = _obsoletePanels | kPanelLogging ;
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: makeObsoleteSourcePanel ()
{
2012-06-24 17:19:34 +00:00
if ( sender () == _ui -> groupBox_sourceDatabase && _ui -> groupBox_sourceDatabase -> isChecked ())
{
_ui -> groupBox_sourceImage -> setChecked ( false );
2013-12-11 00:12:44 +00:00
_ui -> groupBox_sourceOpenni -> setChecked ( false );
2012-06-24 17:19:34 +00:00
}
2012-12-11 18:05:05 +00:00
else if ( sender () == _ui -> groupBox_sourceImage && _ui -> groupBox_sourceImage -> isChecked ())
2012-06-24 17:19:34 +00:00
{
_ui -> groupBox_sourceDatabase -> setChecked ( false );
2013-12-11 00:12:44 +00:00
_ui -> groupBox_sourceOpenni -> setChecked ( false );
}
else if ( sender () == _ui -> groupBox_sourceOpenni && _ui -> groupBox_sourceOpenni -> isChecked ())
{
_ui -> groupBox_sourceImage -> setChecked ( false );
_ui -> groupBox_sourceDatabase -> setChecked ( false );
2012-06-24 17:19:34 +00:00
}
2011-06-05 14:45:39 +00:00
ULOGGER_DEBUG ( "" );
_obsoletePanels = _obsoletePanels | kPanelSource ;
}
rtabmap :: ParametersMap PreferencesDialog :: getAllParameters ()
{
rtabmap :: ParametersMap result ;
rtabmap :: ParametersMap tmpParameters = _parameters ;
_parameters . clear ();
QList < QGroupBox *> boxes = this -> getGroupBoxes ();
for ( int i = 0 ; i < boxes . size (); ++ i )
{
this -> addParameters ( boxes . at ( i ));
}
result = _parameters ;
_parameters = tmpParameters ;
return result ;
}
QList < QGroupBox *> PreferencesDialog :: getGroupBoxes ()
{
QList < QGroupBox *> boxes ;
for ( int i = 0 ; i < _ui -> stackedWidget -> count (); ++ i )
{
QGroupBox * gb = 0 ;
const QObjectList & children = _ui -> stackedWidget -> widget ( i ) -> children ();
for ( int j = 0 ; j < children . size (); ++ j )
{
if (( gb = qobject_cast < QGroupBox *> ( children . at ( j ))))
{
//ULOGGER_DEBUG("PreferencesDialog::setupTreeView() index(%d) Added %s, box name=%s", i, gb->title().toStdString().c_str(), gb->objectName().toStdString().c_str());
break ;
}
}
if ( gb )
{
boxes . append ( gb );
}
else
{
ULOGGER_ERROR ( "A QGroupBox must be included in the first level of children in stacked widget, index=%d" , i );
}
}
return boxes ;
}
2012-03-03 01:46:30 +00:00
void PreferencesDialog :: updatePredictionPlot ()
2011-06-05 14:45:39 +00:00
{
2012-12-11 18:05:05 +00:00
QStringList values = _ui -> lineEdit_bayes_predictionLC -> text (). simplified (). split ( ' ' );
2012-06-26 14:57:31 +00:00
if ( values . size () < 2 )
{
UERROR ( "Error parsing prediction (must have at least 2 items) : %s" ,
_ui -> lineEdit_bayes_predictionLC -> text (). toStdString (). c_str ());
return ;
}
2012-03-03 01:46:30 +00:00
QVector < float > dataX (( values . size () - 2 ) * 2 + 1 );
QVector < float > dataY (( values . size () - 2 ) * 2 + 1 );
double value ;
double sum = 0 ;
int lvl = 1 ;
bool ok = false ;
bool error = false ;
int loopClosureIndex = ( dataX . size () - 1 ) / 2 ;
for ( int i = 0 ; i < values . size (); ++ i )
2011-06-05 14:45:39 +00:00
{
2012-03-03 01:46:30 +00:00
value = values . at ( i ). toDouble ( & ok );
2011-06-05 14:45:39 +00:00
if ( ! ok )
{
2012-12-11 18:05:05 +00:00
UERROR ( "Error parsing prediction : \" %s \" " , values . at ( i ). toStdString (). c_str ());
2012-03-03 01:46:30 +00:00
error = true ;
2011-06-05 14:45:39 +00:00
}
sum += value ;
if ( i == 0 )
{
//do nothing
}
else if ( i == 1 )
{
dataY [ loopClosureIndex ] = value ;
dataX [ loopClosureIndex ] = 0 ;
}
else
{
dataY [ loopClosureIndex - lvl ] = value ;
dataX [ loopClosureIndex - lvl ] = - lvl ;
dataY [ loopClosureIndex + lvl ] = value ;
dataX [ loopClosureIndex + lvl ] = lvl ;
++ lvl ;
}
}
_ui -> label_prediction_sum -> setNum ( sum );
2012-03-03 01:46:30 +00:00
if ( error )
2011-06-05 14:45:39 +00:00
{
_ui -> label_prediction_sum -> setText ( QString ( "<font color=#FF0000>" ) + _ui -> label_prediction_sum -> text () + "</font>" );
}
2012-03-03 01:46:30 +00:00
else if ( sum == 1.0 )
{
_ui -> label_prediction_sum -> setText ( QString ( "<font color=#00FF00>" ) + _ui -> label_prediction_sum -> text () + "</font>" );
}
else if ( sum > 1.0 )
2011-06-05 14:45:39 +00:00
{
_ui -> label_prediction_sum -> setText ( QString ( "<font color=#FFa500>" ) + _ui -> label_prediction_sum -> text () + "</font>" );
}
else
{
_ui -> label_prediction_sum -> setText ( QString ( "<font color=#000000>" ) + _ui -> label_prediction_sum -> text () + "</font>" );
}
_ui -> predictionPlot -> removeCurves ();
2012-06-24 17:19:34 +00:00
_ui -> predictionPlot -> addCurve ( new UPlotCurve ( "Prediction" , dataX , dataY , _ui -> predictionPlot ));
2011-06-05 14:45:39 +00:00
}
void PreferencesDialog :: setupKpRoiPanel ()
{
QStringList strings = _ui -> lineEdit_kp_roi -> text (). split ( ' ' );
if ( strings . size () != 4 )
{
UERROR ( "ROI must have 4 values (%s)" , _ui -> lineEdit_kp_roi -> text (). toStdString (). c_str ());
return ;
}
_ui -> doubleSpinBox_kp_roi0 -> setValue ( strings [ 0 ]. toDouble () * 100.0 );
_ui -> doubleSpinBox_kp_roi1 -> setValue ( strings [ 1 ]. toDouble () * 100.0 );
_ui -> doubleSpinBox_kp_roi2 -> setValue ( strings [ 2 ]. toDouble () * 100.0 );
_ui -> doubleSpinBox_kp_roi3 -> setValue ( strings [ 3 ]. toDouble () * 100.0 );
}
void PreferencesDialog :: updateKpROI ()
{
QStringList strings ;
strings . append ( QString :: number ( _ui -> doubleSpinBox_kp_roi0 -> value () / 100.0 ));
strings . append ( QString :: number ( _ui -> doubleSpinBox_kp_roi1 -> value () / 100.0 ));
strings . append ( QString :: number ( _ui -> doubleSpinBox_kp_roi2 -> value () / 100.0 ));
strings . append ( QString :: number ( _ui -> doubleSpinBox_kp_roi3 -> value () / 100.0 ));
_ui -> lineEdit_kp_roi -> setText ( strings . join ( " " ));
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: changeDatabasePath ()
{
2014-02-11 23:04:22 +00:00
QString path = QFileDialog :: getOpenFileName (
2013-12-11 00:12:44 +00:00
this ,
tr ( "Select database file..." ),
_ui -> lineEdit_databasePath -> text (),
tr ( "RTAB-Map database files (*.db)" ),
2014-02-11 23:04:22 +00:00
0 );
2013-12-11 00:12:44 +00:00
if ( ! path . isEmpty ())
{
_ui -> lineEdit_databasePath -> setText ( path );
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: changeWorkingDirectory ()
{
QString directory = QFileDialog :: getExistingDirectory ( this , tr ( "Working directory" ), _ui -> lineEdit_workingDirectory -> text ());
if ( ! directory . isEmpty ())
{
ULOGGER_DEBUG ( "New working directory = %s" , directory . toStdString (). c_str ());
_ui -> lineEdit_workingDirectory -> setText ( directory );
}
}
void PreferencesDialog :: changeDictionaryPath ()
{
QString path ;
if ( _ui -> lineEdit_dictionaryPath -> text (). isEmpty ())
{
path = QFileDialog :: getOpenFileName ( this , tr ( "Dictionary" ), this -> getWorkingDirectory ());
}
else
{
path = QFileDialog :: getOpenFileName ( this , tr ( "Dictionary" ), _ui -> lineEdit_dictionaryPath -> text ());
}
if ( ! path . isEmpty ())
{
_ui -> lineEdit_dictionaryPath -> setText ( path );
}
}
/*** GETTERS ***/
//General
int PreferencesDialog :: getGeneralLoggerLevel () const
{
return _ui -> comboBox_loggerLevel -> currentIndex ();
}
int PreferencesDialog :: getGeneralLoggerEventLevel () const
{
return _ui -> comboBox_loggerEventLevel -> currentIndex ();
}
int PreferencesDialog :: getGeneralLoggerPauseLevel () const
{
return _ui -> comboBox_loggerPauseLevel -> currentIndex ();
}
int PreferencesDialog :: getGeneralLoggerType () const
{
return _ui -> comboBox_loggerType -> currentIndex ();
}
bool PreferencesDialog :: getGeneralLoggerPrintTime () const
{
return _ui -> checkBox_logger_printTime -> isChecked ();
}
bool PreferencesDialog :: isVerticalLayoutUsed () const
{
return _ui -> checkBox_verticalLayoutUsed -> isChecked ();
}
bool PreferencesDialog :: isImageFlipped () const
{
return _ui -> checkBox_imageFlipped -> isChecked ();
}
bool PreferencesDialog :: imageRejectedShown () const
{
return _ui -> checkBox_imageRejectedShown -> isChecked ();
}
2011-06-10 14:04:06 +00:00
bool PreferencesDialog :: imageHighestHypShown () const
{
return _ui -> checkBox_imageHighestHypShown -> isChecked ();
}
2011-06-05 14:45:39 +00:00
bool PreferencesDialog :: beepOnPause () const
{
return _ui -> checkBox_beep -> isChecked ();
}
int PreferencesDialog :: getKeypointsOpacity () const
{
return _ui -> horizontalSlider_keypointsOpacity -> value ();
}
2013-12-11 00:12:44 +00:00
bool PreferencesDialog :: isCloudsShown ( int index ) const
{
UASSERT ( index >= 0 && index <= 2 );
return _3dRenderingShowClouds [ index ] -> isChecked ();
}
bool PreferencesDialog :: isCloudMeshing ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingMeshing [ index ] -> isChecked ();
}
double PreferencesDialog :: getCloudVoxelSize ( int index ) const
{
UASSERT ( index >= 0 && index <= 2 );
return _3dRenderingVoxelSize [ index ] -> value ();
}
int PreferencesDialog :: getCloudDecimation ( int index ) const
{
UASSERT ( index >= 0 && index <= 2 );
return _3dRenderingDecimation [ index ] -> value ();
}
double PreferencesDialog :: getCloudMaxDepth ( int index ) const
{
UASSERT ( index >= 0 && index <= 2 );
return _3dRenderingMaxDepth [ index ] -> value ();
}
double PreferencesDialog :: getCloudOpacity ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingOpacity [ index ] -> value ();
}
int PreferencesDialog :: getCloudPointSize ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingPtSize [ index ] -> value ();
}
bool PreferencesDialog :: isScansShown ( int index ) const
{
UASSERT ( index >= 0 && index <= 2 );
return _3dRenderingShowScans [ index ] -> isChecked ();
}
double PreferencesDialog :: getScanOpacity ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingOpacityScan [ index ] -> value ();
}
int PreferencesDialog :: getScanPointSize ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingPtSizeScan [ index ] -> value ();
}
2014-06-03 19:28:59 +00:00
int PreferencesDialog :: getMeshNormalKSearch ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingNormalKSearch [ index ] -> value ();
}
double PreferencesDialog :: getMeshGP3Radius ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingGP3Radius [ index ] -> value ();
}
bool PreferencesDialog :: getMeshSmoothing ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingSmoothing [ index ] -> isChecked ();
}
double PreferencesDialog :: getMeshSmoothingRadius ( int index ) const
{
UASSERT ( index >= 0 && index <= 1 );
return _3dRenderingSmoothingRadius [ index ] -> value ();
}
2014-02-13 21:32:46 +00:00
bool PreferencesDialog :: isCloudFiltering () const
{
return _ui -> groupBox_poseFiltering -> isChecked ();
}
double PreferencesDialog :: getCloudFilteringRadius () const
{
return _ui -> doubleSpinBox_cloudFilterRadius -> value ();
}
double PreferencesDialog :: getCloudFilteringAngle () const
{
return _ui -> doubleSpinBox_cloudFilterAngle -> value ();
}
2013-12-11 00:12:44 +00:00
2011-06-05 14:45:39 +00:00
// Source
2012-06-24 17:19:34 +00:00
double PreferencesDialog :: getGeneralInputRate () const
2011-06-05 14:45:39 +00:00
{
return _ui -> general_doubleSpinBox_imgRate -> value ();
}
2012-06-24 17:19:34 +00:00
bool PreferencesDialog :: isSourceImageUsed () const
{
return _ui -> groupBox_sourceImage -> isChecked ();
}
bool PreferencesDialog :: isSourceDatabaseUsed () const
{
return _ui -> groupBox_sourceDatabase -> isChecked ();
}
2013-12-11 00:12:44 +00:00
bool PreferencesDialog :: isSourceOpenniUsed () const
{
return _ui -> groupBox_sourceOpenni -> isChecked ();
}
2014-04-02 15:51:02 +00:00
PreferencesDialog :: OdomType PreferencesDialog :: getOdometryType () const
2013-12-11 00:12:44 +00:00
{
2014-04-02 15:51:02 +00:00
if ( _ui -> odom_type -> currentIndex () == 0 )
{
return kOdomBOW ;
}
else if ( _ui -> odom_type -> currentIndex () == 1 )
{
return kOdomBIN ;
}
return kOdomICP ;
2013-12-11 00:12:44 +00:00
}
2011-06-05 14:45:39 +00:00
bool PreferencesDialog :: getGeneralAutoRestart () const
{
return _ui -> general_checkBox_autoRestart -> isChecked ();
}
2012-03-03 01:46:30 +00:00
bool PreferencesDialog :: getGeneralCameraKeypoints () const
{
return _ui -> general_checkBox_cameraKeypoints -> isChecked ();
}
2012-06-24 17:19:34 +00:00
int PreferencesDialog :: getSourceImageType () const
2011-06-05 14:45:39 +00:00
{
2012-06-24 17:19:34 +00:00
return _ui -> source_comboBox_image_type -> currentIndex ();
2011-06-05 14:45:39 +00:00
}
2012-06-24 17:19:34 +00:00
QString PreferencesDialog :: getSourceImageTypeStr () const
2011-06-05 14:45:39 +00:00
{
2012-06-24 17:19:34 +00:00
return _ui -> source_comboBox_image_type -> currentText ();
2011-06-05 14:45:39 +00:00
}
int PreferencesDialog :: getSourceWidth () const
{
return _ui -> source_spinBox_imgWidth -> value ();
}
int PreferencesDialog :: getSourceHeight () const
{
return _ui -> source_spinBox_imgheight -> value ();
}
2012-06-24 17:19:34 +00:00
int PreferencesDialog :: getFramesDropped () const
{
return _ui -> source_spinBox_framesDropped -> value ();
}
2011-06-05 14:45:39 +00:00
QString PreferencesDialog :: getSourceImagesPath () const
{
return _ui -> source_images_lineEdit_path -> text ();
}
int PreferencesDialog :: getSourceImagesStartPos () const
{
return _ui -> source_images_spinBox_startPos -> value ();
}
bool PreferencesDialog :: getSourceImagesRefreshDir () const
{
return _ui -> source_images_refreshDir -> isChecked ();
}
QString PreferencesDialog :: getSourceVideoPath () const
{
return _ui -> source_video_lineEdit_path -> text ();
}
int PreferencesDialog :: getSourceUsbDeviceId () const
{
return _ui -> source_usbDevice_spinBox_id -> value ();
}
QString PreferencesDialog :: getSourceDatabasePath () const
{
return _ui -> source_database_lineEdit_path -> text ();
}
2013-12-11 00:12:44 +00:00
bool PreferencesDialog :: getSourceDatabaseOdometryIgnored () const
{
return _ui -> source_checkBox_ignoreOdometry -> isChecked ();
}
2012-12-11 18:05:05 +00:00
int PreferencesDialog :: getSourceDatabaseStartPos () const
{
return _ui -> source_spinBox_databaseStartPos -> value ();
}
2014-06-03 04:42:08 +00:00
bool PreferencesDialog :: getSourceFreenect () const
{
return _ui -> radioButton_freenect -> isChecked ();
}
2013-12-11 00:12:44 +00:00
QString PreferencesDialog :: getSourceOpenniDevice () const
{
return _ui -> lineEdit_openniDevice -> text ();
}
Transform PreferencesDialog :: getSourceOpenniLocalTransform () const
{
Transform t = Transform :: getIdentity ();
QString str = _ui -> lineEdit_openniLocalTransform -> text ();
str . replace ( "PI_2" , QString :: number ( 3.141592 / 2.0 ));
QStringList list = str . split ( ' ' );
if ( list . size () != 6 )
{
UERROR ( "Local transform is wrong! must have 6 items (%s)" , str . toStdString (). c_str ());
}
else
{
std :: vector < float > numbers ( 6 );
bool ok = false ;
for ( int i = 0 ; i < list . size (); ++ i )
{
numbers [ i ] = list . at ( i ). toDouble ( & ok );
if ( ! ok )
{
UERROR ( "Parsing local transform failed! \" %s \" not recognized (%s)" ,
list . at ( i ). toStdString (). c_str (), str . toStdString (). c_str ());
break ;
}
}
if ( ok )
{
t = Transform ( numbers [ 0 ], numbers [ 1 ], numbers [ 2 ], numbers [ 3 ], numbers [ 4 ], numbers [ 5 ]);
}
}
return t ;
}
2011-06-05 14:45:39 +00:00
2012-06-24 17:19:34 +00:00
bool PreferencesDialog :: isStatisticsPublished () const
{
return _ui -> general_checkBox_publishStats -> isChecked ();
}
2011-06-05 14:45:39 +00:00
double PreferencesDialog :: getLoopThr () const
{
return _ui -> general_doubleSpinBox_hardThr -> value ();
}
double PreferencesDialog :: getVpThr () const
{
return _ui -> general_doubleSpinBox_vp -> value ();
}
bool PreferencesDialog :: isImagesKept () const
{
return _ui -> general_checkBox_imagesKept -> isChecked ();
}
2012-03-03 01:46:30 +00:00
float PreferencesDialog :: getTimeLimit () const
2011-06-05 14:45:39 +00:00
{
return _ui -> general_doubleSpinBox_timeThr -> value ();
}
2013-12-11 00:12:44 +00:00
float PreferencesDialog :: getDetectionRate () const
{
return _ui -> general_doubleSpinBox_detectionRate -> value ();
}
bool PreferencesDialog :: isSLAMMode () const
{
return _ui -> general_checkBox_SLAM_mode -> isChecked ();
}
2011-06-05 14:45:39 +00:00
/*** SETTERS ***/
void PreferencesDialog :: setHardThr ( int value )
{
double dValue = double ( value ) / 100 ;
ULOGGER_DEBUG ( "PreferencesDialog::setHardThr(%f)" , dValue );
if ( _ui -> general_doubleSpinBox_hardThr -> value () != dValue )
{
_ui -> general_doubleSpinBox_hardThr -> setValue ( dValue );
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
2011-06-09 13:57:01 +00:00
this -> readSettingsBegin ();
2011-06-05 14:45:39 +00:00
}
}
}
2012-06-24 17:19:34 +00:00
void PreferencesDialog :: setInputRate ( double value )
2011-06-05 14:45:39 +00:00
{
ULOGGER_DEBUG ( "imgRate=%2.2f" , value );
if ( _ui -> general_doubleSpinBox_imgRate -> value () != value )
{
_ui -> general_doubleSpinBox_imgRate -> setValue ( value );
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
2011-06-09 13:57:01 +00:00
this -> readSettingsBegin ();
2011-06-05 14:45:39 +00:00
}
}
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: setDetectionRate ( double value )
{
ULOGGER_DEBUG ( "detectionRate=%2.2f" , value );
if ( _ui -> general_doubleSpinBox_detectionRate -> value () != value )
{
_ui -> general_doubleSpinBox_detectionRate -> setValue ( value );
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
this -> readSettingsBegin ();
}
}
}
2011-06-05 14:45:39 +00:00
void PreferencesDialog :: setAutoRestart ( bool value )
{
ULOGGER_DEBUG ( "autoRestart=%d" , value );
if ( _ui -> general_checkBox_autoRestart -> isChecked () != value )
{
_ui -> general_checkBox_autoRestart -> setChecked ( value );
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
2011-06-09 13:57:01 +00:00
this -> readSettingsBegin ();
2011-06-05 14:45:39 +00:00
}
}
}
2012-03-03 01:46:30 +00:00
void PreferencesDialog :: setTimeLimit ( float value )
2011-06-05 14:45:39 +00:00
{
ULOGGER_DEBUG ( "timeLimit=%fs" , value );
if ( _ui -> general_doubleSpinBox_timeThr -> value () != value )
{
_ui -> general_doubleSpinBox_timeThr -> setValue ( value );
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
2011-06-09 13:57:01 +00:00
this -> readSettingsBegin ();
2011-06-05 14:45:39 +00:00
}
}
}
2013-12-11 00:12:44 +00:00
void PreferencesDialog :: setSLAMMode ( bool enabled )
2012-06-24 17:19:34 +00:00
{
2013-12-11 00:12:44 +00:00
ULOGGER_DEBUG ( "slam mode=%s" , enabled ? "true" : "false" );
if ( _ui -> general_checkBox_SLAM_mode -> isChecked () != enabled )
2012-06-24 17:19:34 +00:00
{
2013-12-11 00:12:44 +00:00
_ui -> general_checkBox_SLAM_mode -> setChecked ( enabled );
2012-06-24 17:19:34 +00:00
if ( validateForm ())
{
this -> writeSettings ();
}
else
{
this -> readSettingsBegin ();
}
}
}
2014-04-02 15:51:02 +00:00
void PreferencesDialog :: testOdometry ()
2013-12-11 00:12:44 +00:00
{
if ( _ui -> odom_type -> currentIndex () == 0 )
{
testOdometry ( kOdomBOW );
}
else if ( _ui -> odom_type -> currentIndex () == 1 )
{
testOdometry ( kOdomBIN );
}
else // ICP
{
testOdometry ( kOdomICP );
}
}
2014-04-02 15:51:02 +00:00
void PreferencesDialog :: testOdometry ( OdomType type )
2013-12-11 00:12:44 +00:00
{
2014-06-03 04:42:08 +00:00
UASSERT ( _odomCameraOpenNI == 0 && _odomCameraFreenect == 0 && _odomThread == 0 );
2013-12-11 00:12:44 +00:00
2014-06-03 04:42:08 +00:00
if ( this -> getSourceFreenect ())
{
_odomCameraFreenect = new CameraFreenect (
this -> getSourceOpenniDevice (). isEmpty () ? 0 : atoi ( this -> getSourceOpenniDevice (). toStdString (). c_str ()),
this -> getGeneralInputRate (),
this -> getSourceOpenniLocalTransform ());
if ( ! _odomCameraFreenect -> init ())
{
2014-06-04 20:24:54 +00:00
if ( ! _odomCameraFreenect -> available ())
{
QMessageBox :: warning ( this ,
tr ( "RTAB-Map" ),
tr ( "Freenect camera unavailable! RTAB-Map is not built with Freenect support (libfreenect)." ));
}
else
{
QMessageBox :: warning ( this ,
tr ( "RTAB-Map" ),
tr ( "Freenect camera initialization failed!" ));
}
2014-06-03 04:42:08 +00:00
delete _odomCameraFreenect ;
_odomCameraFreenect = 0 ;
}
}
else
{
_odomCameraOpenNI = new CameraOpenni (
this -> getSourceOpenniDevice (). toStdString (),
this -> getGeneralInputRate (),
this -> getSourceOpenniLocalTransform ());
if ( ! _odomCameraOpenNI -> init ())
{
2014-06-04 20:24:54 +00:00
QMessageBox :: warning ( this ,
tr ( "RTAB-Map" ),
tr ( "OpenNI camera initialization failed!" ));
2014-06-03 04:42:08 +00:00
delete _odomCameraOpenNI ;
_odomCameraOpenNI = 0 ;
}
}
2013-12-11 00:12:44 +00:00
2014-06-03 04:42:08 +00:00
if ( _odomCameraOpenNI || _odomCameraFreenect )
2013-12-11 00:12:44 +00:00
{
Odometry * odometry ;
ParametersMap parameters = this -> getAllParameters ();
2014-04-02 15:51:02 +00:00
if ( type == kOdomBIN )
2013-12-11 00:12:44 +00:00
{
odometry = new OdometryBinary ( parameters );
}
2014-04-02 15:51:02 +00:00
else if ( type == kOdomICP )
2013-12-11 00:12:44 +00:00
{
odometry = new OdometryICP ( parameters );
}
else // kOdomBOW
{
odometry = new OdometryBOW ( parameters );
}
_odomThread = new OdometryThread ( odometry ); // take ownership of odometry
QWidget * window = new QWidget ( this , Qt :: Popup );
window -> setAttribute ( Qt :: WA_DeleteOnClose );
window -> setWindowFlags ( Qt :: Dialog );
2014-04-02 15:51:02 +00:00
window -> setWindowTitle ( tr ( "%1 Odometry viewer" ). arg ( type == kOdomBIN ? "Binary" : "Bag-of-words" ));
2013-12-11 00:12:44 +00:00
window -> setMinimumWidth ( 800 );
window -> setMinimumHeight ( 600 );
connect ( window , SIGNAL ( destroyed ( QObject * )), this , SLOT ( cleanOdometryTest ()) );
2014-02-28 22:11:36 +00:00
OdometryViewer * odomViewer = new OdometryViewer ( 10 , 2 , 0.0 , window );
2013-12-11 00:12:44 +00:00
QVBoxLayout * layout = new QVBoxLayout ();
layout -> addWidget ( odomViewer );
window -> setLayout ( layout );
UEventsManager :: addHandler ( _odomThread );
UEventsManager :: addHandler ( odomViewer );
2014-06-03 04:42:08 +00:00
if ( _odomCameraFreenect )
{
UEventsManager :: createPipe ( _odomCameraFreenect , _odomThread , "CameraEvent" );
}
else
{
UEventsManager :: createPipe ( _odomCameraOpenNI , _odomThread , "CameraEvent" );
}
2013-12-11 00:12:44 +00:00
UEventsManager :: createPipe ( _odomThread , odomViewer , "OdometryEvent" );
window -> showNormal ();
QApplication :: processEvents ();
uSleep ( 500 );
QApplication :: processEvents ();
_odomThread -> start ();
2014-06-03 04:42:08 +00:00
if ( _odomCameraFreenect )
{
_odomCameraFreenect -> start ();
}
else
{
_odomCameraOpenNI -> start ();
}
2013-12-11 00:12:44 +00:00
}
}
void PreferencesDialog :: cleanOdometryTest ()
{
UDEBUG ( "" );
2014-06-03 04:42:08 +00:00
if ( _odomCameraOpenNI )
2013-12-11 00:12:44 +00:00
{
2014-06-03 04:42:08 +00:00
_odomCameraOpenNI -> kill ();
delete _odomCameraOpenNI ;
_odomCameraOpenNI = 0 ;
}
if ( _odomCameraFreenect )
{
_odomCameraFreenect -> join ( true );
delete _odomCameraFreenect ;
_odomCameraFreenect = 0 ;
2013-12-11 00:12:44 +00:00
}
if ( _odomThread )
{
_odomThread -> join ( true );
delete _odomThread ;
_odomThread = 0 ;
}
}
2011-06-05 14:45:39 +00:00
}