subsurface/qt-ui/profile/ruleritem.h
Tomaz Canabrava 006265d7a0 Try to fix the font issue on the ruler.
This changes the ruler a bit, I hope nobody gets offended by it. :)

The main issue is that the scene is now 100x100 pixels wide, so the font
was *really* huge. and setting itemIgnoresTransformations on the ruler
broke a lot of stuff.

I removed the code that painted the text and created a QGraphics TextItem
for that - that will hold the text for the ruler.

Then I played with the view to get the correct angle of the line, that was
in scene coordinates and thus, could not be used directly on the item that
had ignore transformation changes.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 18:57:48 -08:00

59 lines
No EOL
1.3 KiB
C++

#ifndef RULERITEM_H
#define RULERITEM_H
#include <QObject>
#include <QGraphicsEllipseItem>
#include <QGraphicsObject>
#include "divecartesianaxis.h"
#include "display.h"
struct plot_data;
class RulerItem2;
class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem
{
Q_OBJECT
friend class RulerItem2;
public:
explicit RulerNodeItem2(struct plot_info& info);
void setRuler(RulerItem2 *r);
void recalculate();
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant & value );
private:
struct plot_info &pInfo;
struct plot_data *entry;
RulerItem2* ruler;
DiveCartesianAxis *timeAxis;
DiveCartesianAxis *depthAxis;
};
class RulerItem2 : public QGraphicsObject
{
Q_OBJECT
public:
explicit RulerItem2();
void recalculate();
void setPlotInfo(struct plot_info pInfo);
RulerNodeItem2* sourceNode() const;
RulerNodeItem2* destNode() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0);
QRectF boundingRect() const;
QPainterPath shape() const;
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
private:
struct plot_info pInfo;
QPointF startPoint, endPoint;
RulerNodeItem2 *source, *dest;
QString text;
int height;
int paint_direction;
DiveCartesianAxis *timeAxis;
DiveCartesianAxis *depthAxis;
QGraphicsSimpleTextItem *textItem;
};
#endif