void ScaleDraw::drawTick(QPainter *p, double value, int len) const { int axis = this->axis(); ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis); if (sc_engine->hasBreak()){ double dlb = sc_engine->axisBreakLeft(); double drb = sc_engine->axisBreakRight(); if ((dlb < value && drb > value) || ((axis == QwtPlot::yLeft || axis == QwtPlot::xBottom) && value == dlb) || ((axis == QwtPlot::yRight || axis == QwtPlot::xTop) && value == drb) || (sc_engine->testAttribute(QwtScaleEngine::Inverted) && (value == dlb || value == drb))) return; if (d_plot->isPrinting()){ QwtScaleMap scaleMap = map(); double val = scaleMap.transform(value); if (val >= scaleMap.transform(dlb) && val <= scaleMap.transform(drb)) return; } } QwtScaleDiv scDiv = scaleDiv(); QwtValueList majTicks = scDiv.ticks(QwtScaleDiv::MajorTick); if (majTicks.contains(value)){ if (d_majTicks == In || d_majTicks == None) return; switch (d_show_ticks_policy){ case ShowAll: break; case HideBegin: if (majTicks.first() == value) return; break; case HideEnd: if (majTicks.last() == value) return; break; case HideBeginEnd: if (majTicks.first() == value || majTicks.last() == value) return; break; } } QwtValueList medTicks = scDiv.ticks(QwtScaleDiv::MediumTick); if (medTicks.contains(value) && (d_minTicks == In || d_minTicks == None)) return; QwtValueList minTicks = scDiv.ticks(QwtScaleDiv::MinorTick); if (minTicks.contains(value) && (d_minTicks == In || d_minTicks == None)) return; QwtScaleDraw::drawTick(p, value, len); }
void ScaleDraw::drawTick(QPainter *p, double value, int len) const { QwtScaleDiv scDiv = scaleDiv(); QwtValueList majTicks = scDiv.ticks(QwtScaleDiv::MajorTick); if (majTicks.contains(value) && (d_majTicks == In || d_majTicks == None)) return; QwtValueList medTicks = scDiv.ticks(QwtScaleDiv::MediumTick); if (medTicks.contains(value) && (d_minTicks == In || d_minTicks == None)) return; QwtValueList minTicks = scDiv.ticks(QwtScaleDiv::MinorTick); if (minTicks.contains(value) && (d_minTicks == In || d_minTicks == None)) return; QwtScaleDraw::drawTick(p, value, len); }
/*! Remove ticks from a list, that are not inside an interval \param ticks Tick list \param interval Interval \return Stripped tick list */ QwtValueList QwtScaleEngine::strip( const QwtValueList& ticks, const QwtDoubleInterval &interval) const { if ( !interval.isValid() || ticks.count() == 0 ) return QwtValueList(); QwtValueList strippedTicks; for ( int i = 0; i < (int)ticks.count(); i++ ) { double v = ticks[i]; if ( contains(interval, v) && !strippedTicks.contains(v)) strippedTicks += v; } return strippedTicks; }
void ScaleDraw::drawLabel(QPainter *painter, double value) const { if (!d_plot) return; ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis()); if (sc_engine->hasBreak() && sc_engine->axisBreakLeft() <= value && sc_engine->axisBreakRight() > value) return; QwtValueList majTicks = scaleDiv().ticks(QwtScaleDiv::MajorTick); if (majTicks.contains(value)){ switch (d_show_ticks_policy){ case ShowAll: break; case HideBegin: if (majTicks.first() == value) return; break; case HideEnd: if (majTicks.last() == value) return; break; case HideBeginEnd: if (majTicks.first() == value || majTicks.last() == value) return; break; } } QwtText lbl = tickLabel(painter->font(), value); if ( lbl.isEmpty() ) return; QPoint pos = labelPosition(value); QSize labelSize = lbl.textSize(painter->font()); if ( labelSize.height() % 2 ) labelSize.setHeight(labelSize.height() + 1); const QwtMetricsMap metricsMap = QwtPainter::metricsMap(); QwtPainter::resetMetricsMap(); labelSize = metricsMap.layoutToDevice(labelSize); pos = metricsMap.layoutToDevice(pos); painter->save(); painter->setMatrix(labelMatrix( pos, labelSize), true); if (d_selected) lbl.setBackgroundPen(QPen(Qt::blue)); else lbl.setBackgroundPen(QPen(Qt::NoPen)); lbl.setRenderFlags(labelAlignment()); lbl.draw (painter, QRect(QPoint(0, 0), labelSize) ); QwtPainter::setMetricsMap(metricsMap); // restore metrics map painter->restore(); }
void ScaleDraw::drawTick(QPainter *p, double value, int len) const { ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis()); /*QwtScaleEngine *qwtsc_engine=d_plot->axisScaleEngine(axis()); ScaleEngine *sc_engine =dynamic_cast< ScaleEngine*>(qwtsc_engine); if(sc_engine!=NULL) {*/ if (sc_engine->hasBreak()){ int align = alignment(); bool invertedScale = sc_engine->testAttribute(QwtScaleEngine::Inverted); if (align == BottomScale || align == LeftScale){ if (invertedScale && sc_engine->axisBreakRight() == value) return; if (!invertedScale && sc_engine->axisBreakLeft() == value) return; } else { if (!invertedScale && sc_engine->axisBreakRight() == value) return; if (invertedScale && sc_engine->axisBreakLeft() == value) return; } } //} QwtScaleDiv scDiv = scaleDiv(); QwtValueList majTicks = scDiv.ticks(QwtScaleDiv::MajorTick); if (majTicks.contains(value) && (d_majTicks == In || d_majTicks == None)) return; QwtValueList medTicks = scDiv.ticks(QwtScaleDiv::MediumTick); if (medTicks.contains(value) && (d_minTicks == In || d_minTicks == None)) return; QwtValueList minTicks = scDiv.ticks(QwtScaleDiv::MinorTick); if (minTicks.contains(value) && (d_minTicks == In || d_minTicks == None)) return; QwtScaleDraw::drawTick(p, value, len); }