2

I want to register QRectF as a model::box with Boost.Geometry. The documentation for BOOST_GEOMETRY_REGISTER_BOX states that I should provide two parameters: 'minimum corner (should be public member or method)' and 'maximum corner (should be public member or method)' as the last two parameters to the macro. However when trying this with QRectF I get the following error:

error: reference to non-static member function must be called; did you mean to call it with no arguments?
BOOST_GEOMETRY_REGISTER_BOX(QRectF, QPointF, topLeft, bottomRight);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

It appears that these parameters have to be public members. There doesn't seem to be a macro where I can specify getter and setter methods equivalent to BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET.

I am invoking the macro as follows:

#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/register/box.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <QRectF>
BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(QPointF, qreal, cs::cartesian, x, y, setX, setY);
BOOST_GEOMETRY_REGISTER_BOX(QRectF, QPointF, topLeft, bottomRight);

Is there a way around this in boost as is? I can work around this by copying data across into a model::box instantiation but I would rather have something like BOOST_GEOMETRY_REGISTER_BOX_GET_SET available to use so that I can avoid copying and use QRectF directly.

0

1 Answer 1

3

Somebody posted a correct answer to this yesterday but deleted it before I could accept it. Anyway the solution was to use:

BOOST_GEOMETRY_REGISTER_BOX(QRectF, QPointF, topLeft(), bottomRight());

As if you look at the implementation of BOOST_GEOMETRY_REGISTER_BOX(Box, Point, MinCorner, MaxCorner) it uses the parameters like so:

typedef typename coordinate_type<Point>::type ct; \
static inline ct get(Box const& b) \
{ return geometry::get<D>(b. MinCorner);  } \

Which when substituted becomes:

typedef typename coordinate_type<QPointF>::type ct; \
static inline ct get(QRectF const& b) \
{ return geometry::get<D>(b. topLeft());  } \
1
  • There is no deleted answer on this question though.
    – sehe
    Aug 9, 2015 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.