Skip to content

Commit

Permalink
PlotCurve: add ifdefs to support qwt 6.2.0
Browse files Browse the repository at this point in the history
Some member variables in qwt_series_data were renamed in 6.2.0

Signed-off-by: Steven Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed Jul 20, 2021
1 parent 8fe222e commit b1f100c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions gazebo/gui/plot/PlotCurve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include "gazebo/gui/plot/IncrementalPlot.hh"
#include "gazebo/gui/plot/PlotCurve.hh"

// member variables in qwt_series_data were renamed in 6.2.0
#if QWT_VERSION < 0x060200
#define QWT_VERSION_LT_620
#endif

using namespace gazebo;
using namespace gui;

Expand Down Expand Up @@ -53,22 +58,38 @@ namespace gazebo

private: inline const QRectF& BoundingRect() const
{
#ifdef QWT_VERSION_LT_620
return this->d_boundingRect;
#else
return this->m_boundingRect;
#endif
}

private: inline QRectF& BoundingRect()
{
#ifdef QWT_VERSION_LT_620
return this->d_boundingRect;
#else
return this->m_boundingRect;
#endif
}

private: inline const QVector<QPointF>& SamplesRef() const
{
#ifdef QWT_VERSION_LT_620
return this->d_samples;
#else
return this->m_samples;
#endif
}

private: inline QVector<QPointF>& SamplesRef()
{
#ifdef QWT_VERSION_LT_620
return this->d_samples;
#else
return this->m_samples;
#endif
}

/// \brief Bounding rectangle accessor. This create the object
Expand All @@ -77,7 +98,13 @@ namespace gazebo
public: virtual QRectF boundingRect() const
{
if (this->BoundingRect().width() < 0.0)
{
#ifdef QWT_VERSION_LT_620
this->d_boundingRect = qwtBoundingRect(*this);
#else
this->m_boundingRect = qwtBoundingRect(*this);
#endif
}

// set a minimum bounding box height
// this prevents plot's auto scale to zoom in on near-zero
Expand All @@ -89,8 +116,13 @@ namespace gazebo
double halfMinHeight = minHeight * 0.5;
double mid = this->BoundingRect().top() +
(absHeight * 0.5);
#ifdef QWT_VERSION_LT_620
this->d_boundingRect.setTop(mid - halfMinHeight);
this->d_boundingRect.setBottom(mid + halfMinHeight);
#else
this->m_boundingRect.setTop(mid - halfMinHeight);
this->m_boundingRect.setBottom(mid + halfMinHeight);
#endif
}

return this->BoundingRect();
Expand Down
2 changes: 2 additions & 0 deletions gazebo/gui/plot/qwt_gazebo.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#if defined __has_include
#if __has_include (<qwt.h>)
#include <qwt_curve_fitter.h>
#include <qwt_global.h>
#include <qwt_legend.h>
#include <qwt_painter.h>
#include <qwt_picker_machine.h>
Expand All @@ -50,6 +51,7 @@

#ifndef GAZEBO_GUI_QWT_IS_INCLUDED
#include <qwt/qwt_curve_fitter.h>
#include <qwt/qwt_global.h>
#include <qwt/qwt_legend.h>
#include <qwt/qwt_painter.h>
#include <qwt/qwt_picker_machine.h>
Expand Down

0 comments on commit b1f100c

Please sign in to comment.