2

I have some code where I draw a symbol and attach it to a plot. Now I want to find out whether there is a bounding rectangle automatically created with the symbol so that I can write some code to select the symbol so that users can edit it - select it in order to delete it for example.

I have seen a boundingRect() method in qwt_plot_marker.h, how would I use this to determine whether there is a rectangle created when the following code is implemented?

void DataPointMarker::draw(QPainter *p, 
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRect &) const
{
  const int posX = xMap.transform(m_positionX);
  const int posY = yMap.transform(m_positionY);

p->save();

symbol().draw(p, posX, posY);

p->restore();

The symbol is defined elsewhere. Thanks in advance.

David Bejar
  • 512
  • 4
  • 20
programmingNoob
  • 141
  • 2
  • 3
  • 8
  • Not too familiar with the qt classes, maybe [this](http://harmattan-dev.nokia.com/docs/library/html/qt4/qgraphicsitem.html#boundingRect) helps? – Ghost2 Oct 03 '12 at 11:50
  • This is what I was looking at before I asked the question but I can't make any sense of it. – programmingNoob Oct 05 '12 at 07:54

1 Answers1

2

The boundingRect function returns a rectangle large enough that all points of a series fit into it. This is needed for autoscaling and definately not what you are looking for. What you want is something like a focus or selection indicator. You may take a look into the event_filter example shipped with qwt. There it is possible to select and move points/markers.

The qwt example directoy can be found in the base directory of qwt (at least on Windows), for example qwt-6.0\examples. The binaries are located in qwt-6.0\examples\bin. Take a look into the INSTALL file to see how to build the binaries.

quinmars
  • 11,175
  • 8
  • 32
  • 41
  • Alright, I will give it a try. May you provide a link to the example - if there is one - or direct me to where I can find it please? Thanks. – programmingNoob Oct 05 '12 at 07:59