ViewerSettingsPanel.cpp
Go to the documentation of this file.
00001 /*
00002  * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
00003  * http://octomap.github.com/
00004  *
00005  * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
00006  * All rights reserved.
00007  * License (octovis): GNU GPL v2
00008  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
00009  *
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00018  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
00019  * for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License along
00022  * with this program; if not, write to the Free Software Foundation, Inc.,
00023  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00024  */
00025 
00026 #include <octovis/ViewerSettingsPanel.h>
00027 
00028 ViewerSettingsPanel::ViewerSettingsPanel(QWidget *parent)
00029     : QWidget(parent), m_currentScan(0), m_numberScans(0), m_treeDepth(_TREE_MAX_DEPTH), m_resolution(0.1)
00030 {
00031         ui.setupUi(this);
00032         connect(ui.treeDepth, SIGNAL(valueChanged(int)), this, SLOT(setTreeDepth(int)));
00033 
00034         scanProgressChanged();
00035         leafSizeChanged();
00036 }
00037 
00038 ViewerSettingsPanel::~ViewerSettingsPanel()
00039 {
00040 
00041 }
00042 
00043 void ViewerSettingsPanel::on_nextScanButton_clicked(){
00044   if (m_currentScan < m_numberScans){
00045     m_currentScan++;
00046     scanProgressChanged();
00047     emit addNextScans(1);
00048   }
00049 }
00050 
00051 void ViewerSettingsPanel::on_fastFwdScanButton_clicked(){
00052   unsigned increase = int(m_numberScans)-int(m_currentScan);
00053   if (increase > 5) increase = 5;
00054   m_currentScan += increase;
00055   scanProgressChanged();
00056   emit addNextScans(increase);
00057 }
00058 
00059 void ViewerSettingsPanel::on_lastScanButton_clicked(){
00060   unsigned increase = int(m_numberScans)-int(m_currentScan);
00061   m_currentScan += increase;
00062   scanProgressChanged();
00063   emit addNextScans(increase);
00064 }
00065 
00066 void ViewerSettingsPanel::on_firstScanButton_clicked(){
00067   m_currentScan = 1;
00068   scanProgressChanged();
00069   emit gotoFirstScan();
00070 }
00071 
00072 void ViewerSettingsPanel::scanProgressChanged(){
00073   if (int(m_numberScans) > 1)
00074     ui.scanProgressBar->setMaximum(int(m_numberScans));
00075   else 
00076     ui.scanProgressBar->setMaximum(1);
00077 
00078   if (m_currentScan == m_numberScans){
00079     ui.nextScanButton->setEnabled(false);
00080     ui.fastFwdScanButton->setEnabled(false);
00081     ui.lastScanButton->setEnabled(false);
00082 
00083   } else{
00084     ui.nextScanButton->setEnabled(true);
00085     ui.fastFwdScanButton->setEnabled(true);
00086     ui.lastScanButton->setEnabled(true);
00087   }
00088 
00089   if (m_currentScan < 2){
00090     ui.firstScanButton->setEnabled(false);
00091   } else{
00092     ui.firstScanButton->setEnabled(true);
00093   }
00094 
00095   ui.scanProgressBar->setValue(m_currentScan);
00096   // queue a redraw:
00097   ui.scanProgressBar->update();
00098 }
00099 
00100 void ViewerSettingsPanel::setNumberOfScans(unsigned scans){
00101   m_numberScans = scans;
00102   scanProgressChanged();
00103 }
00104 
00105 void ViewerSettingsPanel::setCurrentScan(unsigned scan){
00106   m_currentScan = scan;
00107   scanProgressChanged();
00108 }
00109 
00110 void ViewerSettingsPanel::setResolution(double resolution){
00111   m_resolution = resolution;
00112   leafSizeChanged();
00113 }
00114 
00115 void ViewerSettingsPanel::setTreeDepth(int depth){
00116   emit treeDepthChanged(depth);
00117   m_treeDepth = depth;
00118   leafSizeChanged();
00119 }
00120 
00121 void ViewerSettingsPanel::leafSizeChanged(){
00122   double leafSize = m_resolution * pow(2.0, (int) (_TREE_MAX_DEPTH-m_treeDepth));
00123   ui.leafSize->setText(QString::number(leafSize)+" m");
00124 }


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26