Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00205 ui.scanProgressSlider->update();
00206
00207 }
00208
00209 bool ViewerSettingsPanelCamera::followRobotTrajectory(){
00210 return ui.followTrajectoryButton->isChecked();
00211 }
00212
00213