g2o
Public Member Functions | Public Attributes | Protected Attributes | List of all members
g2o::G2oQGLViewer Class Reference

OpenGL based viewer for the graph. More...

#include <g2o_qglviewer.h>

Inheritance diagram for g2o::G2oQGLViewer:
Inheritance graph
[legend]
Collaboration diagram for g2o::G2oQGLViewer:
Collaboration graph
[legend]

Public Member Functions

 G2oQGLViewer (QWidget *parent=NULL, const QGLWidget *shareWidget=0, Qt::WindowFlags flags=0)
 
 ~G2oQGLViewer ()
 
void draw ()
 
void init ()
 
bool updateDisplay () const
 
void setUpdateDisplay (bool updateDisplay)
 
DrawAction::Parametersparameters ()
 

Public Attributes

SparseOptimizergraph
 

Protected Attributes

HyperGraphElementAction_drawActions
 
GLuint _drawList
 
bool _updateDisplay
 
DrawAction::Parameters_drawActionParameters
 

Detailed Description

OpenGL based viewer for the graph.

Definition at line 33 of file g2o_qglviewer.h.

Constructor & Destructor Documentation

g2o::G2oQGLViewer::G2oQGLViewer ( QWidget *  parent = NULL,
const QGLWidget *  shareWidget = 0,
Qt::WindowFlags  flags = 0 
)

Definition at line 85 of file g2o_qglviewer.cpp.

References _drawActionParameters.

85  :
86  QGLViewer(parent, shareWidget, flags),
87  graph(0), _drawActions(0), _drawList(0)
88 {
89  setAxisIsDrawn(false);
90  _drawActionParameters = new DrawAction::Parameters();
91 }
SparseOptimizer * graph
Definition: g2o_qglviewer.h:51
HyperGraphElementAction * _drawActions
Definition: g2o_qglviewer.h:54
DrawAction::Parameters * _drawActionParameters
Definition: g2o_qglviewer.h:57
g2o::G2oQGLViewer::~G2oQGLViewer ( )

Definition at line 93 of file g2o_qglviewer.cpp.

References _drawActionParameters, and _drawList.

94 {
95  delete _drawActionParameters;
96  glDeleteLists(_drawList, 1);
97 }
DrawAction::Parameters * _drawActionParameters
Definition: g2o_qglviewer.h:57

Member Function Documentation

void g2o::G2oQGLViewer::draw ( )

Definition at line 99 of file g2o_qglviewer.cpp.

References _drawActionParameters, _drawActions, _drawList, _updateDisplay, g2o::HyperGraphActionLibrary::actionByName(), g2o::applyAction(), graph, and g2o::HyperGraphActionLibrary::instance().

100 {
101  if (! graph)
102  return;
103 
104  if (_drawActions == 0) {
106  assert(_drawActions);
107  }
108 
109  if (! _drawActions) // avoid segmentation fault in release build
110  return;
111  if (_updateDisplay) {
112  _updateDisplay = false;
113  glNewList(_drawList, GL_COMPILE_AND_EXECUTE);
115  glEndList();
116  } else {
117  glCallList(_drawList);
118  }
119 }
SparseOptimizer * graph
Definition: g2o_qglviewer.h:51
void applyAction(HyperGraph *graph, HyperGraphElementAction *action, HyperGraphElementAction::Parameters *params, const std::string &typeName)
HyperGraphElementAction * _drawActions
Definition: g2o_qglviewer.h:54
static HyperGraphActionLibrary * instance()
return the single instance of the HyperGraphActionLibrary
HyperGraphElementAction * actionByName(const std::string &name)
DrawAction::Parameters * _drawActionParameters
Definition: g2o_qglviewer.h:57
void g2o::G2oQGLViewer::init ( )

Definition at line 121 of file g2o_qglviewer.cpp.

References _drawList, and g2o::types_icp::init().

122 {
123  QGLViewer::init();
124  //glDisable(GL_LIGHT0);
125  //glDisable(GL_LIGHTING);
126 
127  setBackgroundColor(QColor::fromRgb(51, 51, 51));
128 
129  // some default settings i like
130  glEnable(GL_LINE_SMOOTH);
131  glEnable(GL_BLEND);
132  glEnable(GL_DEPTH_TEST);
133  glEnable(GL_NORMALIZE);
134  //glEnable(GL_CULL_FACE);
135  glShadeModel(GL_FLAT);
136  //glShadeModel(GL_SMOOTH);
137  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
138 
139  setAxisIsDrawn();
140 
141  // don't save state
142  setStateFileName(QString::null);
143 
144  // mouse bindings
145 #ifdef QGLVIEWER_DEPRECATED_MOUSEBINDING
146  setMouseBinding(Qt::NoModifier, Qt::RightButton, CAMERA, ZOOM);
147  setMouseBinding(Qt::NoModifier, Qt::MidButton, CAMERA, TRANSLATE);
148 #else
149  setMouseBinding(Qt::RightButton, CAMERA, ZOOM);
150  setMouseBinding(Qt::MidButton, CAMERA, TRANSLATE);
151 #endif
152 
153  // keyboard shortcuts
154  setShortcut(CAMERA_MODE, 0);
155  setShortcut(EXIT_VIEWER, 0);
156  //setShortcut(SAVE_SCREENSHOT, 0);
157 
158  // replace camera
159  qglviewer::Camera* oldcam = camera();
160  qglviewer::Camera* cam = new StandardCamera();
161  setCamera(cam);
162  cam->setPosition(qglviewer::Vec(0., 0., 75.));
163  cam->setUpVector(qglviewer::Vec(0., 1., 0.));
164  cam->lookAt(qglviewer::Vec(0., 0., 0.));
165  delete oldcam;
166 
167  // getting a display list
168  _drawList = glGenLists(1);
169 }
DrawAction::Parameters* g2o::G2oQGLViewer::parameters ( )
inline

Definition at line 48 of file g2o_qglviewer.h.

Referenced by ViewerPropertiesWidget::setViewer().

48 { return _drawActionParameters;}
DrawAction::Parameters * _drawActionParameters
Definition: g2o_qglviewer.h:57
void g2o::G2oQGLViewer::setUpdateDisplay ( bool  updateDisplay)
bool g2o::G2oQGLViewer::updateDisplay ( ) const
inline

the viewer uses a display list to cache the drawing, use setUpdateDisplay() to force the creation of an updated display list.

Definition at line 45 of file g2o_qglviewer.h.

References updateDisplay().

Referenced by setUpdateDisplay().

45 { return _updateDisplay;}

Member Data Documentation

DrawAction::Parameters* g2o::G2oQGLViewer::_drawActionParameters
protected

Definition at line 57 of file g2o_qglviewer.h.

Referenced by draw(), G2oQGLViewer(), and ~G2oQGLViewer().

HyperGraphElementAction* g2o::G2oQGLViewer::_drawActions
protected

Definition at line 54 of file g2o_qglviewer.h.

Referenced by draw().

GLuint g2o::G2oQGLViewer::_drawList
protected

Definition at line 55 of file g2o_qglviewer.h.

Referenced by draw(), init(), and ~G2oQGLViewer().

bool g2o::G2oQGLViewer::_updateDisplay
protected

Definition at line 56 of file g2o_qglviewer.h.

Referenced by draw(), and setUpdateDisplay().

SparseOptimizer* g2o::G2oQGLViewer::graph

Definition at line 51 of file g2o_qglviewer.h.

Referenced by draw().


The documentation for this class was generated from the following files: