g2o
viewer_properties_widget.cpp
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3 //
4 // This file is part of g2o.
5 //
6 // g2o is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // g2o is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with g2o. If not, see <http://www.gnu.org/licenses/>.
18 
20 
21 #include "g2o_qglviewer.h"
22 #include "g2o/stuff/property.h"
23 
24 #include <QLineEdit>
25 
26 #include <iostream>
27 #include <cassert>
28 
29 #ifdef __GNUC__
30  #include <cxxabi.h>
31 #endif
32 
33 using namespace std;
34 
35 using namespace g2o;
36 
40 static std::string demangleName(const std::string& fullPropName)
41 {
42 #ifdef __GNUC__
43  // find :: and extract the mangled class name from the whole string
44  string mangledName;
45  string propName;
46  string::size_type found = fullPropName.rfind("::");
47  if (found != string::npos) {
48  mangledName = fullPropName.substr(0, found);
49  propName = fullPropName.substr(found);
50  } else {
51  mangledName = propName;
52  }
53 
54  int status;
55  char* s = abi::__cxa_demangle(mangledName.c_str(), 0, 0, &status);
56  if (status != 0) {
57  free(s);
58  return fullPropName;
59  } else {
60  std::string demangled(s);
61  free(s);
62  return demangled + propName;
63  }
64 #else
65  // TODO for other compilers
66  return fullPropName;
67 #endif
68 }
69 
70 ViewerPropertiesWidget::ViewerPropertiesWidget(QWidget * parent, Qt::WindowFlags f) :
71  PropertiesWidget(parent, f)
72 {
73 }
74 
76 {
77 }
78 
80 {
82 
83  // draw with the new properties
85  _viewer->updateGL();
86 }
87 
89 {
90  _viewer = viewer;
91  setProperties(viewer->parameters());
92 }
93 
94 std::string ViewerPropertiesWidget::humanReadablePropName(const std::string& propertyName) const
95 {
96  return demangleName(propertyName);
97 }
ViewerPropertiesWidget(QWidget *parent=0, Qt::WindowFlags f=0)
void setUpdateDisplay(bool updateDisplay)
OpenGL based viewer for the graph.
Definition: g2o_qglviewer.h:33
virtual std::string humanReadablePropName(const std::string &probName) const
DrawAction::Parameters * parameters()
Definition: g2o_qglviewer.h:48
void setProperties(g2o::PropertyMap *properties)
void setViewer(g2o::G2oQGLViewer *viewer)
virtual void applyProperties()
static std::string demangleName(const std::string &fullPropName)