本文整理汇总了C++中QwtMetricsMap::layoutToDeviceY方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtMetricsMap::layoutToDeviceY方法的具体用法?C++ QwtMetricsMap::layoutToDeviceY怎么用?C++ QwtMetricsMap::layoutToDeviceY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtMetricsMap
的用法示例。
在下文中一共展示了QwtMetricsMap::layoutToDeviceY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawBreak
void ScaleDraw::drawBreak(QPainter *painter) const {
ScaleEngine *sc_engine =
static_cast<ScaleEngine *>(d_plot->axisScaleEngine(axis()));
/*const QwtScaleEngine * qwtsc_engine=d_plot->axisScaleEngine(axis());
const ScaleEngine *sc_engine =dynamic_cast<const ScaleEngine*>(qwtsc_engine);
if(sc_engine!=NULL)
{*/
if (!sc_engine->hasBreak() || !sc_engine->hasBreakDecoration())
return;
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
int len = majTickLength();
QwtScaleMap scaleMap = map();
const QwtMetricsMap metricsMap = QwtPainter::metricsMap();
QPoint pos = this->pos();
if (!metricsMap.isIdentity()) {
QwtPainter::resetMetricsMap();
pos = metricsMap.layoutToDevice(pos);
if (orientation() == Qt::Vertical) {
scaleMap.setPaintInterval(metricsMap.layoutToDeviceY((int)scaleMap.p1()),
metricsMap.layoutToDeviceY((int)scaleMap.p2()));
len = metricsMap.layoutToDeviceX(len);
} else {
scaleMap.setPaintInterval(metricsMap.layoutToDeviceX((int)scaleMap.p1()),
metricsMap.layoutToDeviceX((int)scaleMap.p2()));
len = metricsMap.layoutToDeviceY(len);
}
}
int lval = scaleMap.transform(sc_engine->axisBreakLeft());
int rval = scaleMap.transform(sc_engine->axisBreakRight());
switch (alignment()) {
case LeftScale:
QwtPainter::drawLine(painter, pos.x(), lval, pos.x() - len, lval + len);
QwtPainter::drawLine(painter, pos.x(), rval, pos.x() - len, rval + len);
break;
case RightScale:
QwtPainter::drawLine(painter, pos.x(), lval, pos.x() + len, lval - len);
QwtPainter::drawLine(painter, pos.x(), rval, pos.x() + len, rval - len);
break;
case BottomScale:
QwtPainter::drawLine(painter, lval, pos.y(), lval - len, pos.y() + len);
QwtPainter::drawLine(painter, rval, pos.y(), rval - len, pos.y() + len);
break;
case TopScale:
QwtPainter::drawLine(painter, lval, pos.y(), lval + len, pos.y() - len);
QwtPainter::drawLine(painter, rval, pos.y(), rval + len, pos.y() - len);
break;
}
QwtPainter::setMetricsMap(metricsMap); // restore metrics map
painter->restore();
//}
}
示例2: drawBreak
void ScaleDraw::drawBreak(QPainter *painter) const
{
ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis());
if (!sc_engine->hasBreak() || !sc_engine->hasBreakDecoration())
return;
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
QPen pen = painter->pen();
pen.setColor(d_plot->axisWidget(axis())->palette().color(QPalette::Active, QColorGroup::Foreground));
painter->setPen(pen);
int len = d_plot->majorTickLength();
QwtScaleMap scaleMap = map();
const QwtMetricsMap metricsMap = QwtPainter::metricsMap();
QPoint pos = this->pos();
if (!d_plot->isPrinting()){
QwtPainter::resetMetricsMap();
pos = metricsMap.layoutToDevice(pos);
if ( orientation() == Qt::Vertical ){
scaleMap.setPaintInterval(
metricsMap.layoutToDeviceY((int)scaleMap.p1()),
metricsMap.layoutToDeviceY((int)scaleMap.p2()));
len = metricsMap.layoutToDeviceX(len);
} else {
scaleMap.setPaintInterval(
metricsMap.layoutToDeviceX((int)scaleMap.p1()),
metricsMap.layoutToDeviceX((int)scaleMap.p2()));
len = metricsMap.layoutToDeviceY(len);
}
}
int lval = scaleMap.transform(sc_engine->axisBreakLeft());
int rval = scaleMap.transform(sc_engine->axisBreakRight());
switch(alignment()){
case LeftScale:
case RightScale:
QwtPainter::drawLine(painter, pos.x() + len, lval - len, pos.x() - len, lval + len);
QwtPainter::drawLine(painter, pos.x() + len, rval - len, pos.x() - len, rval + len);
break;
case TopScale:
case BottomScale:
QwtPainter::drawLine(painter, lval + len, pos.y() - len, lval - len, pos.y() + len);
QwtPainter::drawLine(painter, rval + len, pos.y() - len, rval - len, pos.y() + len);
break;
}
if (!d_plot->isPrinting())
QwtPainter::setMetricsMap(metricsMap); // restore metrics map
painter->restore();
}
示例3: drawTick
/*!
Draw a tick
\param painter Painter
\param value Value of the tick
\param len Lenght of the tick
\sa drawBackbone(), drawLabel()
*/
void QwtScaleDraw::drawTick(QPainter *painter, double value, int len) const
{
if ( len <= 0 )
return;
int pw2 = qwtMin((int)painter->pen().width(), len) / 2;
QwtScaleMap scaleMap = map();
const QwtMetricsMap metricsMap = QwtPainter::metricsMap();
QPoint pos = d_data->pos;
if ( !metricsMap.isIdentity() )
{
/*
The perfect position of the ticks is important.
To avoid rounding errors we have to use
device coordinates.
*/
QwtPainter::resetMetricsMap();
pos = metricsMap.layoutToDevice(pos);
if ( orientation() == Qt::Vertical )
{
scaleMap.setPaintInterval(
metricsMap.layoutToDeviceY((int)scaleMap.p1()),
metricsMap.layoutToDeviceY((int)scaleMap.p2())
);
len = metricsMap.layoutToDeviceX(len);
}
else
{
scaleMap.setPaintInterval(
metricsMap.layoutToDeviceX((int)scaleMap.p1()),
metricsMap.layoutToDeviceX((int)scaleMap.p2())
);
len = metricsMap.layoutToDeviceY(len);
}
}
const int tval = scaleMap.transform(value);
switch(alignment())
{
case LeftScale:
{
#if QT_VERSION < 0x040000
QwtPainter::drawLine(painter, pos.x() + pw2, tval,
pos.x() - len - 2 * pw2, tval);
#else
QwtPainter::drawLine(painter, pos.x() - pw2, tval,
pos.x() - len, tval);
#endif
break;
}
case RightScale:
{
#if QT_VERSION < 0x040000
QwtPainter::drawLine(painter, pos.x(), tval,
pos.x() + len + pw2, tval);
#else
QwtPainter::drawLine(painter, pos.x() + pw2, tval,
pos.x() + len, tval);
#endif
break;
}
case BottomScale:
{
#if QT_VERSION < 0x040000
QwtPainter::drawLine(painter, tval, pos.y(),
tval, pos.y() + len + 2 * pw2);
#else
QwtPainter::drawLine(painter, tval, pos.y() + pw2,
tval, pos.y() + len);
#endif
break;
}
case TopScale:
{
#if QT_VERSION < 0x040000
QwtPainter::drawLine(painter, tval, pos.y() + pw2,
tval, pos.y() - len - 2 * pw2);
#else
QwtPainter::drawLine(painter, tval, pos.y() - pw2,
tval, pos.y() - len);
#endif
break;
}
//.........这里部分代码省略.........
示例4: drawInwardTick
void ScaleDraw::drawInwardTick(QPainter *painter, double value, int len) const
{
ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis());
if (sc_engine->hasBreak() && (sc_engine->axisBreakLeft() <= value && sc_engine->axisBreakRight() >= value))
return;
int pw2 = qwtMin((int)painter->pen().width(), len) / 2;
QwtScaleMap scaleMap = map();
const QwtMetricsMap metricsMap = QwtPainter::metricsMap();
QPoint pos = this->pos();
int majLen = tickLength(QwtScaleDiv::MajorTick);
if ( !metricsMap.isIdentity() ){
/*
The perfect position of the ticks is important.
To avoid rounding errors we have to use
device coordinates.
*/
QwtPainter::resetMetricsMap();
pos = metricsMap.layoutToDevice(pos);
if ( orientation() == Qt::Vertical ){
scaleMap.setPaintInterval(
metricsMap.layoutToDeviceY((int)scaleMap.p1()),
metricsMap.layoutToDeviceY((int)scaleMap.p2())
);
len = metricsMap.layoutToDeviceX(len);
majLen = metricsMap.layoutToDeviceX(majLen);
} else {
scaleMap.setPaintInterval(
metricsMap.layoutToDeviceX((int)scaleMap.p1()),
metricsMap.layoutToDeviceX((int)scaleMap.p2())
);
len = metricsMap.layoutToDeviceY(len);
majLen = metricsMap.layoutToDeviceY(majLen);
}
}
const int clw = d_plot->canvasLineWidth();
const int tval = scaleMap.transform(value);
bool draw = false;
if ( orientation() == Qt::Vertical ){
int low = (int)scaleMap.p2() + majLen;
int high = (int)scaleMap.p1() - majLen;
if ((tval > low && tval < high) ||
(tval > high && !d_plot->axisEnabled (QwtPlot::xBottom) && !clw) ||
(tval < low && !d_plot->axisEnabled(QwtPlot::xTop) && !clw)) draw = true;
} else {
int low = (int)scaleMap.p1() + majLen;
int high = (int)scaleMap.p2() - majLen;
if ((tval > low && tval < high) ||
(tval > high && !d_plot->axisEnabled(QwtPlot::yRight) && !clw) ||
(tval < low && !d_plot->axisEnabled(QwtPlot::yLeft) && !clw)) draw = true;
}
if (draw){
switch(alignment()){
case LeftScale:
{
QwtPainter::drawLine(painter, pos.x() + pw2, tval, pos.x() + len, tval);
break;
}
case RightScale:
{
QwtPainter::drawLine(painter, pos.x() - pw2, tval, pos.x() - len, tval);
break;
}
case BottomScale:
{
QwtPainter::drawLine(painter, tval, pos.y() - pw2, tval, pos.y() - len);
break;
}
case TopScale:
{
QwtPainter::drawLine(painter, tval, pos.y() + pw2, tval, pos.y() + len);
break;
}
}
}
QwtPainter::setMetricsMap(metricsMap); // restore metrics map
}