PostProcessingDialog.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #include "rtabmap/gui/PostProcessingDialog.h"
00029 #include "ui_postProcessingDialog.h"
00030 
00031 #include <QPushButton>
00032 #include <rtabmap/core/Optimizer.h>
00033 
00034 namespace rtabmap {
00035 
00036 PostProcessingDialog::PostProcessingDialog(QWidget * parent) :
00037         QDialog(parent)
00038 {
00039         _ui = new Ui_PostProcessingDialog();
00040         _ui->setupUi(this);
00041 
00042         if(!Optimizer::isAvailable(Optimizer::kTypeCVSBA) && !Optimizer::isAvailable(Optimizer::kTypeG2O))
00043         {
00044                 _ui->sba->setEnabled(false);
00045                 _ui->sba->setChecked(false);
00046         }
00047         else if(!Optimizer::isAvailable(Optimizer::kTypeCVSBA))
00048         {
00049                 _ui->comboBox_sbaType->setItemData(1, 0, Qt::UserRole - 1);
00050                 _ui->comboBox_sbaType->setCurrentIndex(0);
00051         }
00052         else if(!Optimizer::isAvailable(Optimizer::kTypeG2O))
00053         {
00054                 _ui->comboBox_sbaType->setItemData(0, 0, Qt::UserRole - 1);
00055                 _ui->comboBox_sbaType->setCurrentIndex(1);
00056         }
00057 
00058         restoreDefaults();
00059 
00060         connect(_ui->detectMoreLoopClosures, SIGNAL(clicked(bool)), this, SLOT(updateButtonBox()));
00061         connect(_ui->refineNeighborLinks, SIGNAL(stateChanged(int)), this, SLOT(updateButtonBox()));
00062         connect(_ui->refineLoopClosureLinks, SIGNAL(stateChanged(int)), this, SLOT(updateButtonBox()));
00063         connect(_ui->sba, SIGNAL(clicked(bool)), this, SLOT(updateButtonBox()));
00064         connect(_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), this, SLOT(restoreDefaults()));
00065 
00066         connect(_ui->detectMoreLoopClosures, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
00067         connect(_ui->clusterRadius, SIGNAL(valueChanged(double)), this, SIGNAL(configChanged()));
00068         connect(_ui->clusterAngle, SIGNAL(valueChanged(double)), this, SIGNAL(configChanged()));
00069         connect(_ui->iterations, SIGNAL(valueChanged(int)), this, SIGNAL(configChanged()));
00070         connect(_ui->refineNeighborLinks, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
00071         connect(_ui->refineLoopClosureLinks, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
00072 
00073         connect(_ui->sba, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
00074         connect(_ui->sba_iterations, SIGNAL(valueChanged(int)), this, SIGNAL(configChanged()));
00075         connect(_ui->comboBox_sbaType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(configChanged()));
00076         connect(_ui->comboBox_sbaType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateVisibility()));
00077 
00078         updateVisibility();
00079 }
00080 
00081 PostProcessingDialog::~PostProcessingDialog()
00082 {
00083         delete _ui;
00084 }
00085 
00086 void PostProcessingDialog::updateVisibility()
00087 {
00088         _ui->sba_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
00089         _ui->label_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
00090 }
00091 
00092 void PostProcessingDialog::saveSettings(QSettings & settings, const QString & group) const
00093 {
00094         if(!group.isEmpty())
00095         {
00096                 settings.beginGroup(group);
00097         }
00098         settings.setValue("detect_more_lc", this->isDetectMoreLoopClosures());
00099         settings.setValue("cluster_radius", this->clusterRadius());
00100         settings.setValue("cluster_angle", this->clusterAngle());
00101         settings.setValue("iterations", this->iterations());
00102         settings.setValue("refine_neigbors", this->isRefineNeighborLinks());
00103         settings.setValue("refine_lc", this->isRefineLoopClosureLinks());
00104         settings.setValue("sba", this->isSBA());
00105         settings.setValue("sba_iterations", this->sbaIterations());
00106         settings.setValue("sba_type", this->sbaType());
00107         settings.setValue("sba_variance", this->sbaVariance());
00108         if(!group.isEmpty())
00109         {
00110                 settings.endGroup();
00111         }
00112 }
00113 
00114 void PostProcessingDialog::loadSettings(QSettings & settings, const QString & group)
00115 {
00116         if(!group.isEmpty())
00117         {
00118                 settings.beginGroup(group);
00119         }
00120         this->setDetectMoreLoopClosures(settings.value("detect_more_lc", this->isDetectMoreLoopClosures()).toBool());
00121         this->setClusterRadius(settings.value("cluster_radius", this->clusterRadius()).toDouble());
00122         this->setClusterAngle(settings.value("cluster_angle", this->clusterAngle()).toDouble());
00123         this->setIterations(settings.value("iterations", this->iterations()).toInt());
00124         this->setRefineNeighborLinks(settings.value("refine_neigbors", this->isRefineNeighborLinks()).toBool());
00125         this->setRefineLoopClosureLinks(settings.value("refine_lc", this->isRefineLoopClosureLinks()).toBool());
00126         this->setSBA(settings.value("sba", this->isSBA()).toBool());
00127         this->setSBAIterations(settings.value("sba_iterations", this->sbaIterations()).toInt());
00128         this->setSBAType((Optimizer::Type)settings.value("sba_type", this->sbaType()).toInt());
00129         this->setSBAVariance(settings.value("sba_variance", this->sbaVariance()).toDouble());
00130         if(!group.isEmpty())
00131         {
00132                 settings.endGroup();
00133         }
00134 }
00135 
00136 void PostProcessingDialog::restoreDefaults()
00137 {
00138         setDetectMoreLoopClosures(true);
00139         setClusterRadius(1);
00140         setClusterAngle(30);
00141         setIterations(5);
00142         setRefineNeighborLinks(false);
00143         setRefineLoopClosureLinks(false);
00144         setSBA(false);
00145         setSBAIterations(20);
00146         setSBAType(!Optimizer::isAvailable(Optimizer::kTypeG2O)&&Optimizer::isAvailable(Optimizer::kTypeCVSBA)?Optimizer::kTypeCVSBA:Optimizer::kTypeG2O);
00147         setSBAVariance(1.0);
00148 }
00149 
00150 void PostProcessingDialog::updateButtonBox()
00151 {
00152         _ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
00153                         isDetectMoreLoopClosures() || isRefineNeighborLinks() || isRefineLoopClosureLinks() || isSBA());
00154 }
00155 
00156 bool PostProcessingDialog::isDetectMoreLoopClosures() const
00157 {
00158         return _ui->detectMoreLoopClosures->isChecked();
00159 }
00160 
00161 double PostProcessingDialog::clusterRadius() const
00162 {
00163         return _ui->clusterRadius->value();
00164 }
00165 
00166 double PostProcessingDialog::clusterAngle() const
00167 {
00168         return _ui->clusterAngle->value();
00169 }
00170 
00171 int PostProcessingDialog::iterations() const
00172 {
00173         return _ui->iterations->value();
00174 }
00175 
00176 bool PostProcessingDialog::isRefineNeighborLinks() const
00177 {
00178         return _ui->refineNeighborLinks->isChecked();
00179 }
00180 
00181 bool PostProcessingDialog::isRefineLoopClosureLinks() const
00182 {
00183         return _ui->refineLoopClosureLinks->isChecked();
00184 }
00185 
00186 bool PostProcessingDialog::isSBA() const
00187 {
00188         return _ui->sba->isChecked();
00189 }
00190 
00191 int PostProcessingDialog::sbaIterations() const
00192 {
00193         return _ui->sba_iterations->value();
00194 }
00195 double PostProcessingDialog::sbaVariance() const
00196 {
00197         return _ui->sba_variance->value();
00198 }
00199 Optimizer::Type PostProcessingDialog::sbaType() const
00200 {
00201         return _ui->comboBox_sbaType->currentIndex()==0?Optimizer::kTypeG2O:Optimizer::kTypeCVSBA;
00202 }
00203 
00204 //setters
00205 void PostProcessingDialog::setDetectMoreLoopClosures(bool on)
00206 {
00207         _ui->detectMoreLoopClosures->setChecked(on);
00208 }
00209 void PostProcessingDialog::setClusterRadius(double radius)
00210 {
00211         _ui->clusterRadius->setValue(radius);
00212 }
00213 void PostProcessingDialog::setClusterAngle(double angle)
00214 {
00215         _ui->clusterAngle->setValue(angle);
00216 }
00217 void PostProcessingDialog::setIterations(int iterations)
00218 {
00219         _ui->iterations->setValue(iterations);
00220 }
00221 void PostProcessingDialog::setRefineNeighborLinks(bool on)
00222 {
00223         _ui->refineNeighborLinks->setChecked(on);
00224 }
00225 void PostProcessingDialog::setRefineLoopClosureLinks(bool on)
00226 {
00227         _ui->refineLoopClosureLinks->setChecked(on);
00228 }
00229 void PostProcessingDialog::setSBA(bool on)
00230 {
00231         _ui->sba->setChecked(Optimizer::isAvailable(Optimizer::kTypeCVSBA) && on);
00232 }
00233 void PostProcessingDialog::setSBAIterations(int iterations)
00234 {
00235         _ui->sba_iterations->setValue(iterations);
00236 }
00237 void PostProcessingDialog::setSBAVariance(double variance)
00238 {
00239         _ui->sba_variance->setValue(variance);
00240 }
00241 void PostProcessingDialog::setSBAType(Optimizer::Type type)
00242 {
00243         if(type == Optimizer::kTypeCVSBA)
00244         {
00245                 _ui->comboBox_sbaType->setCurrentIndex(1);
00246         }
00247         else
00248         {
00249                 _ui->comboBox_sbaType->setCurrentIndex(0);
00250         }
00251 }
00252 
00253 
00254 }


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:21