frameeditorwindow.cpp
Go to the documentation of this file.
00001 
00018 #include <GUI/frameeditorwindow.h>
00019 #include <QFileDialog>
00020 
00021 FrameEditor::FrameEditor(QWidget *parent)
00022 {
00023     markerPublisher = new MarkerPublisher(0);
00024 
00025     //Set Toolbar
00026     fileMenu = this->menuBar()->addMenu("&File");
00027     openAct = new QAction(tr("&Open"), this);
00028     openAct->setShortcuts(QKeySequence::Open);
00029     openAct->setStatusTip(tr("Open a file"));
00030     connect(openAct, SIGNAL(triggered()), this, SLOT(openFile()));
00031     fileMenu->addAction(openAct);
00032     saveAct = new QAction(tr("&Save"), this);
00033     saveAct->setShortcuts(QKeySequence::Save);
00034     saveAct->setStatusTip(tr("Save file"));
00035     connect(saveAct, SIGNAL(triggered()), this, SLOT(saveFile()));
00036     fileMenu->addAction(saveAct);
00037 
00038     lblItemCount = new QLabel(this);
00039     lblItemCount->resize(200,30);
00040 
00041     //Set Listbox
00042     lstFrames = new QListWidget(this);
00043     lstFrames->move(20,30);
00044     lstFrames->setVisible(true);
00045     lstFrames->setSelectionMode(QAbstractItemView::SingleSelection);
00046     connect(lstFrames, SIGNAL(itemClicked(QListWidgetItem*)),  this, SLOT(lstFramesItemClicked(QListWidgetItem*)));
00047 }
00048 
00049 void FrameEditor::resizeEvent(QResizeEvent * event)
00050 {
00051     lstFrames->resize(this->width()-40, this->height()-160);
00052     lblItemCount->move(20, this->height()-150);
00053     QMainWindow::resizeEvent(event);
00054 }
00055 
00056 void FrameEditor::lstFramesItemClicked(QListWidgetItem * item)
00057 {
00058     int row = item->listWidget()->row( item );
00059     colouredCameraFrames.at(row).color.r = 1.0;
00060     colouredCameraFrames.at(row).color.g = 0.0;
00061     if (lastSelected > -1 )
00062     {
00063         colouredCameraFrames.at(lastSelected).color.r = 0.0;
00064         colouredCameraFrames.at(lastSelected).color.g = 1.0;
00065     }
00066     lastSelected = row;
00067     markerPublisher->publishColouredCameraFrames(&colouredCameraFrames);
00068 }
00069 
00070 
00071 void FrameEditor::openFile()
00072 {
00073     QString fileName = QFileDialog::getOpenFileName(this, "Open File", "CalibrationData.data", tr("Calibrationfile (*.data)"));
00074     if (fileName.length() > 0)
00075     {
00076         ROS_INFO_STREAM("File: " << fileName.toStdString());
00077         TransformationFile_Manager_Data fileManager(fileName.toStdString());
00078         transformationData = fileManager.readFromFile();
00079         lstFrames->clear();
00080         colouredCameraFrames.clear();
00081         for (unsigned int i = 0; i < transformationData.size(); i++)
00082         {
00083             Transformation_Data data = transformationData.at(i);
00084             QString name = QString::number(data.pan) + ", " + QString::number(data.tilt);
00085             new QListWidgetItem(name, lstFrames);
00086             colouredCameraFrame cCF;
00087             cCF.pose = data.PTU_Frame;
00088             ROS_INFO_STREAM(data.PTU_Frame(0,3) << ", " << data.PTU_Frame(1,3) << ", " << data.PTU_Frame(2,3));
00089             cCF.color.r = 0.0;
00090             cCF.color.g = 1.0;
00091             cCF.color.b = 0.0;
00092             cCF.color.a = 1.0;
00093             colouredCameraFrames.push_back(cCF);
00094         }
00095         lastSelected = -1;
00096         markerPublisher->publishColouredCameraFrames(&colouredCameraFrames);
00097     }
00098 }
00099 
00100 void FrameEditor::saveFile()
00101 {
00102     QString fileName = QFileDialog::getSaveFileName(this, "Save file", "CalibrationData.data", tr("Calibrationfile (*.data)"));
00103     if (fileName.length() > 0)
00104     {
00105         ROS_INFO_STREAM("File: " << fileName.toStdString());
00106         TransformationFile_Manager_Data fileManager(fileName.toStdString());
00107         fileManager.writeToFile(transformationData);
00108     }
00109 }


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Thu Jun 6 2019 21:22:44