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


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Feb 11 2016 23:51:20