[go: up one dir, main page]

Menu

[af93f0]: / Ruler.cpp  Maximize  Restore  History

Download this file

116 lines (95 with data), 2.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "Ruler.h"
#include "rightclickmenu.h"
class DummyMenu : public RightClickMenu
{
public:
explicit DummyMenu(Ruler * rg):RightClickMenu(rg){}
~DummyMenu(){}
public slots:
void ShowContextMenu(const QPoint &pos)
{
}
};
Ruler::Ruler(QwtPlot* plot, const QString & name, QwtPlotMarker::LineStyle lineStyle):QwtPlotMarker(name),
_picker(0), _pos(0.0), _rightClickMenu(0)
{
if(lineStyle == QwtPlotMarker::VLine || lineStyle == QwtPlotMarker::HLine)
{
setLineStyle(lineStyle);
setLinePen(Qt::blue);
}
this->attach(plot);
_rightClickMenu = new RightClickMenu(this);
}
bool Ruler::setPicker(Picker* pick)
{
if(!pick)
return false;
if(_picker)
delete _picker;
_picker = pick;
return true;
}
void Ruler::setZoomerSearch(bool on)
{
_picker->setControlFlag(Picker::ZoomerSearch, on);
}
void Ruler::setPannerSearch(bool on)
{
_picker->setControlFlag(Picker::PannerSearch, on);
}
void Ruler::setLock(bool lock)
{
_picker->setControlFlag(Picker::Locked, lock);
}
bool Ruler::lock()const
{
return _picker->controlFlag(Picker::Locked);
}
void Ruler::setTrackingTextStyle(Picker::TrackingTextStyle trackingTextStyle)
{
_picker->setTrackingTextStyle(trackingTextStyle);
}
Picker::TrackingTextStyle Ruler::trackingTextStyle()
{
return _picker->trackingTextStyle();
}
void Ruler::setTrackingTextFont(const QFont & f)
{
_picker->setTrackerFont(f);
}
QFont Ruler::trackingTextFont()
{
return _picker->trackerFont();
}
void Ruler::setTrackingTextColor(const QColor & c)
{
QPen p = _picker->trackerPen();
p.setColor(c);
_picker->setTrackerPen(p);
}
QColor Ruler::trackingTextColor()
{
return _picker->trackerPen().color();
}
void Ruler::validatePosition(/*double min, double max*/)
{
}
Qt::CursorShape Ruler::dragCursorShape()const
{
return _picker->dragCursorShape();
}
void Ruler::setDragCursorShape(Qt::CursorShape shape)
{
_picker->setDragCursorShape(shape);
}
void Ruler::setRightClickMenu(RightClickMenu* menu)
{
if(_rightClickMenu)
{
delete _rightClickMenu;
if(!menu)
menu = new DummyMenu(this);
}
_rightClickMenu = menu;
}