main_widget.cpp
Go to the documentation of this file.
00001 // HOG-Man - Hierarchical Optimization for Pose Graphs on Manifolds
00002 // Copyright (C) 2010 G. Grisetti, R. Kümmerle, C. Stachniss
00003 //
00004 // This file is part of HOG-Man.
00005 // 
00006 // HOG-Man is free software: you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation, either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // HOG-Man is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with HOG-Man.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 #include "main_widget.h"
00020 #include "moc_main_widget.cpp"
00021 
00022 #include "graph/posegraph3d.h"
00023 
00024 #include <QFileDialog>
00025 
00026 #include <iostream>
00027 #include <fstream>
00028 using namespace std;
00029 using namespace AISNavigation;
00030 
00031 MainWidget::MainWidget(QWidget* parent, Qt::WindowFlags flags) :
00032   QMainWindow(parent, flags)
00033 {
00034   setupUi(this);
00035   setWindowTitle("GraphViewer");
00036 
00037   // main menu items (just click events)
00038   connect((const QObject*) actionLoad, SIGNAL( activated() ), 
00039           (const QObject*) this, SLOT( loadGraph() ) );
00040   connect((const QObject*) actionSave, SIGNAL( activated() ), 
00041           (const QObject*) this, SLOT( saveGraph() ) );
00042   connect((const QObject*) actionExit, SIGNAL( activated() ), 
00043           (const QObject*) this, SLOT( close() ) );
00044   connect((const QObject*) actionSave_VRML, SIGNAL( activated() ), 
00045           (const QObject*) this, SLOT( saveGraphVrml() ) );
00046 
00047   // toggle actions
00048   connect((const QObject*) actionGraph, SIGNAL( toggled(bool) ), 
00049           (const QObject*) this, SLOT( setDrawGraph(bool) ) );
00050   connect((const QObject*) actionHirarchy, SIGNAL( toggled(bool) ), 
00051           (const QObject*) this, SLOT( setDrawHirarchy(bool) ) );
00052 }
00053 
00054 MainWidget::~MainWidget()
00055 {
00056 }
00057 
00058 void MainWidget::loadGraph()
00059 {
00060   PoseGraph3D* graph = viewer->graph.getGraph();
00061   if (!graph) {
00062     cerr << "No graph available" << endl;
00063   }
00064   QString fileName = QFileDialog::getOpenFileName(this, tr("Open Graph File"), "", tr("Graph-Files (*.graph)"));
00065   if (!fileName.isEmpty()) {
00066     ifstream fin(fileName.toAscii());
00067     graph->clear();
00068     graph->load(fin);
00069     viewer->graph.setGraph(graph);
00070     viewer->updateGL();
00071   }
00072 }
00073 
00074 void MainWidget::saveGraph()
00075 {
00076   PoseGraph3D* graph = viewer->graph.getGraph();
00077   if (!graph) {
00078     cerr << "No graph available" << endl;
00079   }
00080   QString fileName = QFileDialog::getSaveFileName(this, tr("Save Graph File"), "", tr("Graph-Files (*.graph)"));
00081   if (!fileName.isEmpty()) {
00082     ofstream fout(fileName.toAscii());
00083     graph->save(fout);
00084   }
00085 }
00086 
00087 void MainWidget::saveGraphVrml()
00088 {
00089   PoseGraph3D* graph = viewer->graph.getGraph();
00090   if (!graph) {
00091     cerr << "No graph available" << endl;
00092   }
00093   QString fileName = QFileDialog::getSaveFileName(this, tr("Save Graph VRML-File"), "", tr("VRML-Files (*.wrl)"));
00094   if (!fileName.isEmpty()) {
00095     ofstream fout(fileName.toAscii());
00096     viewer->graph.writeVrml(fout);
00097   }
00098 }
00099 
00100 void MainWidget::setDrawGraph(bool b)
00101 {
00102   viewer->graph.setDrawGraph(b);
00103   viewer->updateGL();
00104 }
00105 
00106 void MainWidget::setDrawHirarchy(bool b)
00107 {
00108   viewer->graph.setDrawHirarchy(b);
00109   viewer->updateGL();
00110 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


hogman_minimal
Author(s): Maintained by Juergen Sturm
autogenerated on Wed Dec 26 2012 15:36:48