ViewerSettingsPanelCamera.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/ViewerSettingsPanelCamera.h>
00027 #include <iostream>
00028 
00029 ViewerSettingsPanelCamera::ViewerSettingsPanelCamera(QWidget *parent)
00030 : QWidget(parent), m_currentFrame(1), m_numberFrames(0), m_robotTrajectoryAvailable(false)
00031 {
00032   ui.setupUi(this);
00033   connect(ui.posX, SIGNAL(valueChanged(double)), this, SLOT(positionEditDone(double)));
00034   connect(ui.posY, SIGNAL(valueChanged(double)), this, SLOT(positionEditDone(double)));
00035   connect(ui.posZ, SIGNAL(valueChanged(double)), this, SLOT(positionEditDone(double)));
00036   connect(ui.lookX, SIGNAL(valueChanged(double)), this, SLOT(positionEditDone(double)));
00037   connect(ui.lookY, SIGNAL(valueChanged(double)), this, SLOT(positionEditDone(double)));
00038   connect(ui.lookZ, SIGNAL(valueChanged(double)), this, SLOT(positionEditDone(double)));
00039 
00040   ui.followTrajectoryButton->setEnabled(m_robotTrajectoryAvailable);
00041   dataChanged();
00042 }
00043 
00044 ViewerSettingsPanelCamera::~ViewerSettingsPanelCamera()
00045 {
00046 
00047 }
00048 
00049 QSize ViewerSettingsPanelCamera::sizeHint() const {
00050   return QSize(250, 180);
00051 }
00052 
00053 void ViewerSettingsPanelCamera::positionEditDone(double){
00054   emit changeCamPosition(ui.posX->value(), ui.posY->value(), ui.posZ->value(), ui.lookX->value(), ui.lookY->value(), ui.lookZ->value());
00055 }
00056 
00057 void ViewerSettingsPanelCamera::setNumberOfFrames(unsigned frames){
00058   m_numberFrames = frames;
00059   dataChanged();
00060 }
00061 
00062 void ViewerSettingsPanelCamera::setCurrentFrame(unsigned frame){
00063   m_currentFrame = frame;
00064   dataChanged();
00065 }
00066 
00067 void ViewerSettingsPanelCamera::setRobotTrajectoryAvailable(bool available) {
00068   m_robotTrajectoryAvailable = available;
00069   if(!available) ui.followTrajectoryButton->setChecked(false);
00070   ui.followTrajectoryButton->setEnabled(available);
00071 }
00072 
00073 void ViewerSettingsPanelCamera::gotoFrame(unsigned int frame) {
00074   if(frame > 0 && frame <= m_numberFrames) {
00075     m_currentFrame = frame;
00076     emit jumpToFrame(m_currentFrame);
00077     dataChanged();
00078   }
00079 }
00080 
00081 void ViewerSettingsPanelCamera::on_nextScanButton_clicked(){
00082   gotoFrame(m_currentFrame + 1);
00083 }
00084 
00085 void ViewerSettingsPanelCamera::on_previousScanButton_clicked(){
00086   gotoFrame(m_currentFrame - 1);
00087 }
00088 
00089 void ViewerSettingsPanelCamera::on_firstScanButton_clicked(){
00090   gotoFrame(1);
00091 }
00092 
00093 void ViewerSettingsPanelCamera::on_lastScanButton_clicked(){
00094   gotoFrame(m_numberFrames);
00095 }
00096 
00097 void ViewerSettingsPanelCamera::on_followCameraPathButton_clicked(){
00098   emit followCameraPath();
00099 }
00100 
00101 void ViewerSettingsPanelCamera::on_followTrajectoryButton_clicked(){
00102   emit followRobotPath();
00103 }
00104 
00105 void ViewerSettingsPanelCamera::on_cameraPathAdd_clicked(){
00106   emit addToCameraPath();
00107 }
00108 
00109 void ViewerSettingsPanelCamera::on_cameraPathRemove_clicked(){
00110   emit removeFromCameraPath();
00111 }
00112 
00113 void ViewerSettingsPanelCamera::on_cameraPathClear_clicked(){
00114   emit clearCameraPath();
00115 }
00116 
00117 void ViewerSettingsPanelCamera::on_cameraPathSave_clicked(){
00118   emit saveToCameraPath();
00119 }
00120 
00121 void ViewerSettingsPanelCamera::on_playScanButton_clicked(){
00122   if(ui.playScanButton->isChecked()) {
00123     ui.scanProgressSlider->setEnabled(false);
00124     ui.followGroupBox->setEnabled(false);
00125     emit play();
00126   } else {
00127     ui.scanProgressSlider->setEnabled(true);
00128     ui.followGroupBox->setEnabled(true);
00129     emit pause();
00130   }
00131   dataChanged();
00132 }
00133 
00134 void ViewerSettingsPanelCamera::on_scanProgressSlider_sliderMoved(int value) {
00135   gotoFrame(value);
00136 }
00137 
00138 void ViewerSettingsPanelCamera::setStopped(){
00139   ui.followGroupBox->setEnabled(true);
00140   ui.scanProgressSlider->setEnabled(true);
00141   ui.playScanButton->setChecked(false);
00142   dataChanged();
00143 }
00144 
00145 
00146 void ViewerSettingsPanelCamera::dataChanged(){
00147   unsigned int max = std::max(0,int(m_numberFrames));
00148   unsigned int cur = std::min(max, m_currentFrame);
00149 
00150   ui.scanProgressSlider->setMaximum(max);
00151   ui.scanProgressSlider->setMinimum(1);
00152 
00153   if(ui.playScanButton->isChecked()) {
00154     ui.firstScanButton->setEnabled(false);
00155     ui.nextScanButton->setEnabled(false);
00156     ui.previousScanButton->setEnabled(false);
00157     ui.lastScanButton->setEnabled(false);
00158   } else {
00159     if (m_currentFrame >= max){
00160       ui.nextScanButton->setEnabled(false);
00161       ui.playScanButton->setEnabled(false);
00162       ui.lastScanButton->setEnabled(false);
00163     } else {
00164       ui.nextScanButton->setEnabled(true);
00165       ui.playScanButton->setEnabled(true);
00166       ui.lastScanButton->setEnabled(true);
00167     }
00168 
00169     if (m_currentFrame < 2){
00170       ui.firstScanButton->setEnabled(cur > 0);
00171       ui.previousScanButton->setEnabled(false);
00172     } else{
00173       ui.firstScanButton->setEnabled(true);
00174       ui.previousScanButton->setEnabled(true);
00175     }
00176 
00177     if (max > 1) {
00178       ui.playScanButton->setEnabled(true);
00179     } else {
00180       ui.playScanButton->setEnabled(false);
00181     }
00182   }
00183 
00184   if(followRobotTrajectory() || ui.playScanButton->isChecked()) {
00185     ui.cameraPathAdd->setEnabled(false);
00186     ui.cameraPathRemove->setEnabled(false);
00187     ui.cameraPathSave->setEnabled(false);
00188     ui.cameraPathClear->setEnabled(false);
00189   } else {
00190     ui.cameraPathAdd->setEnabled(true);
00191     ui.cameraPathRemove->setEnabled(m_numberFrames > 0);
00192     ui.cameraPathSave->setEnabled(m_numberFrames > 0);
00193     ui.cameraPathClear->setEnabled(m_numberFrames > 0);
00194   }
00195 
00196   if(max > 0 && !ui.playScanButton->isChecked()) {
00197     ui.scanProgressSlider->setEnabled(true);
00198   } else {
00199     ui.scanProgressSlider->setEnabled(false);
00200   }
00201 
00202   ui.scanProgressSlider->setValue(cur);
00203   ui.scanProgressLabel->setText(QString("%1/%2").arg(cur).arg(max));
00204 
00205   // queue a redraw:
00206   ui.scanProgressSlider->update();
00207 
00208 }
00209 
00210 bool ViewerSettingsPanelCamera::followRobotTrajectory(){
00211   return ui.followTrajectoryButton->isChecked();
00212 }
00213 
00214 


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