Hi, Oliver
I fix according with our comments. Thanks. I will test more careful in
next times.
see comment in patches.
I think this version can be committed and
all remain "bugs" will be fixed later.
this version is usable, isn't it?
Oliver Eichler wrote:
Andrew Vagin schrieb:
HiOliver Eichler пишет:
Hi Andrew,
yes, much better :) But I found 2 new issues ;)
* If you switch tracks the axis are not reset and adjusted to the new
values. I use 3 tracks to test 2 single ones and a third combined one.
If you switch between the tracks without closing the graph you will
see what I mean.
I will see at night
* The waypoint icons and their lines have to be clipped, too. You only
will see them if you have icons close < 20 m from the track.
sorry, I can't understand, what icons do you speak about? cat you attach
screenshot?
Sure
http://www.qlandkarte.org/shot2.jpg
http://www.qlandkarte.org/shot1.jpg
Oliver
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QLandkarte-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkarte-users
>From ffd3039356f4182594c198650393cc6b64ff75e4 Mon Sep 17 00:00:00 2001
From: Adnrew <[EMAIL PROTECTED]>
Date: Sun, 21 Sep 2008 16:54:03 +0400
Subject: [PATCH] add "zoom in/out" (separate for vertical and horizontal) to a track profile.
---
src/CPlot.cpp | 76 +++++++++++++++++++++++++++++++++++++-
src/CPlot.h | 16 ++++++++
src/CPlotAxis.cpp | 21 ++++++++++-
src/CPlotAxis.h | 4 ++
src/CTrackStatProfileWidget.cpp | 2 +-
src/CTrackStatSpeedWidget.cpp | 1 +
src/ITrackStat.cpp | 41 +++++++++------------
src/ITrackStat.h | 4 +-
8 files changed, 136 insertions(+), 29 deletions(-)
diff --git a/src/CPlot.cpp b/src/CPlot.cpp
index 2795bca..8f2c3f2 100644
--- a/src/CPlot.cpp
+++ b/src/CPlot.cpp
@@ -37,6 +37,7 @@ CPlot::CPlot(QWidget * parent)
{
setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
m_pData = new CPlotData(this);
+ createActions();
}
@@ -72,6 +73,10 @@ void CPlot::setXLabel(const QString& str)
update();
}
+void CPlot::setLimits()
+{
+ m_pData->setLimits();
+}
void CPlot::newLine(const QPolygonF& line, const QPointF& focus, const QString& label)
{
@@ -84,7 +89,6 @@ void CPlot::newLine(const QPolygonF& line, const QPointF& focus, const QString&
l.label = label;
m_pData->lines << l;
- m_pData->setLimits();
setSizes();
m_pData->x().setScale( rectGraphArea.width() );
m_pData->y().setScale( rectGraphArea.height() );
@@ -99,7 +103,6 @@ void CPlot::addLine(const QPolygonF& line, const QString& label)
l.label = label;
m_pData->lines << l;
- m_pData->setLimits();
setSizes();
m_pData->x().setScale( rectGraphArea.width() );
m_pData->y().setScale( rectGraphArea.height() );
@@ -549,3 +552,72 @@ void CPlot::drawTags(QPainter& p)
++tag;
}
}
+
+void CPlot::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu menu(this);
+ menu.addAction(hZoomAct);
+ menu.addAction(vZoomAct);
+
+ menu.exec(event->globalPos());
+}
+
+void CPlot::createActions()
+{
+ hZoomAct = new QAction("horizontal zoom", this);
+ hZoomAct->setCheckable(true);
+ hZoomAct->setChecked(true);
+
+ vZoomAct = new QAction(tr("vertical zoom"), this);
+ vZoomAct->setCheckable(true);
+ vZoomAct->setChecked(true);
+}
+
+void CPlot::zoom(CPlotAxis &axis, double factor, int curInt)
+{
+ axis.zoom(factor, curInt);
+ setSizes();
+ update();
+}
+
+void CPlot::wheelEvent ( QWheelEvent * e )
+{
+ if (hZoomAct->isChecked())
+ zoom(m_pData->x(), (1 + e->delta() / 1200.0), e->pos().x() - left);
+ if (vZoomAct->isChecked())
+ zoom(m_pData->y(), (1 + e->delta() / 1200.0), - e->pos().y() + bottom);
+}
+
+void CPlot::mouseMoveEvent(QMouseEvent * e)
+{
+ double p;
+ checkClick = false;
+
+ CPlotAxis &xaxis = m_pData->x();
+ p = xaxis.pt2val(e->pos().x()) - xaxis.pt2val(startMovePos.x());
+ xaxis.setMinMax(xaxis.getMin() - p , xaxis.getMax() - p);
+
+ CPlotAxis &yaxis = m_pData->y();
+ p = yaxis.pt2val(e->pos().y()) - yaxis.pt2val(startMovePos.y());
+ yaxis.setMinMax(yaxis.getMin() + p , yaxis.getMax() + p);
+
+ startMovePos = e->pos();
+ update();
+}
+
+void CPlot::mouseReleaseEvent(QMouseEvent * e)
+{
+ if (checkClick && e->button() == Qt::LeftButton) {
+ QPoint pos = e->pos();
+ double dist = getXValByPixel(pos.x());
+ emit activePointSignal(dist);
+ }
+}
+
+void CPlot::mousePressEvent(QMouseEvent * e)
+{
+ qDebug() << "press" << endl;
+ startMovePos = e->pos();
+ checkClick = true;
+}
+
diff --git a/src/CPlot.h b/src/CPlot.h
index e1bc63d..8ddc0cb 100644
--- a/src/CPlot.h
+++ b/src/CPlot.h
@@ -38,12 +38,21 @@ class CPlot : public QWidget
void addLine(const QPolygonF& line, const QString& label);
void newMarks(const QPolygonF& line);
void addTag(CPlotData::point_t& tag);
+ void setLimits();
void clear();
double getXValByPixel(int px);
+ signals:
+ void activePointSignal(double dist);
+
protected:
+ void contextMenuEvent(QContextMenuEvent *event);
+ void mousePressEvent(QMouseEvent * e);
+ void mouseMoveEvent(QMouseEvent * e);
+ void mouseReleaseEvent(QMouseEvent * e);
+ void wheelEvent ( QWheelEvent * e );
void paintEvent(QPaintEvent * e);
void resizeEvent(QResizeEvent * e);
@@ -66,6 +75,11 @@ class CPlot : public QWidget
void setSizeXLabel();
void setSizeYLabel();
void setSizeDrawArea();
+ void zoom(CPlotAxis &axis, double factor, int cur = 0);
+
+ void createActions();
+ QAction *hZoomAct;
+ QAction *vZoomAct;
CPlotData * m_pData;
@@ -93,5 +107,7 @@ class CPlot : public QWidget
QFontMetrics fm;
+ QPoint startMovePos;
+ int checkClick;
};
#endif //CPLOT_H
diff --git a/src/CPlotAxis.cpp b/src/CPlotAxis.cpp
index 6a4736a..2eacc7f 100644
--- a/src/CPlotAxis.cpp
+++ b/src/CPlotAxis.cpp
@@ -26,7 +26,7 @@
CPlotAxis::CPlotAxis( QObject * parent )
: QObject( parent )
, initialized( false )
-, autoscale( true )
+, autoscale( false )
, scale( 1.0 )
, given_min( 0.0 )
, given_max( 0.0 )
@@ -44,6 +44,16 @@ CPlotAxis::CPlotAxis( QObject * parent )
CPlotAxis::~CPlotAxis()
{}
+double CPlotAxis::getMin()
+{
+ return used_min;
+}
+
+double CPlotAxis::getMax()
+{
+ return used_max;
+}
+
void CPlotAxis::setMinMax( double min, double max )
{
double tmp;
@@ -302,3 +312,12 @@ void CPlotAxis::setScale( const unsigned int pts )
points = pts;
scale = pts / ( used_max - used_min );
}
+
+void CPlotAxis::zoom(double factor, int fixedPoint)
+{
+ double min, p, d;
+ p = pt2val(fixedPoint);
+ min = (p - getMin()) * (1 - factor) + getMin();
+ d = min - getMin() * factor;
+ setMinMax(min, getMax() * factor + d);
+}
diff --git a/src/CPlotAxis.h b/src/CPlotAxis.h
index 9c05da3..913ed66 100644
--- a/src/CPlotAxis.h
+++ b/src/CPlotAxis.h
@@ -47,6 +47,10 @@ class CPlotAxis : public QObject
full /**< minmax && norm*/
};
+ virtual double getMin();
+ virtual double getMax();
+
+ virtual void zoom(double factor, int fixedPoint);
///set the desired minimum and maximum value
virtual void setMinMax(double min, double max);
///set the scale factor for a given size in points
diff --git a/src/CTrackStatProfileWidget.cpp b/src/CTrackStatProfileWidget.cpp
index 483c079..ed29a25 100644
--- a/src/CTrackStatProfileWidget.cpp
+++ b/src/CTrackStatProfileWidget.cpp
@@ -39,7 +39,7 @@ CTrackStatProfileWidget::CTrackStatProfileWidget(QWidget * parent)
connect(&CWptDB::self(),SIGNAL(sigChanged()),this,SLOT(slotChanged()));
slotChanged();
-
+ plot->setLimits();
}
CTrackStatProfileWidget::~CTrackStatProfileWidget()
diff --git a/src/CTrackStatSpeedWidget.cpp b/src/CTrackStatSpeedWidget.cpp
index 0db3481..0aee0f5 100644
--- a/src/CTrackStatSpeedWidget.cpp
+++ b/src/CTrackStatSpeedWidget.cpp
@@ -34,6 +34,7 @@ CTrackStatSpeedWidget::CTrackStatSpeedWidget(QWidget * parent)
connect(&CTrackDB::self(),SIGNAL(sigChanged()),this,SLOT(slotChanged()));
slotChanged();
+ plot->setLimits();
}
diff --git a/src/ITrackStat.cpp b/src/ITrackStat.cpp
index 79a93e5..33774a5 100644
--- a/src/ITrackStat.cpp
+++ b/src/ITrackStat.cpp
@@ -39,7 +39,8 @@ ITrackStat::ITrackStat(QWidget * parent)
plot = new CPlot(this);
layout()->addWidget(plot);
-
+ QObject::connect(plot, SIGNAL(activePointSignal(double)),
+ this, SLOT(activePointEvent(double)));
}
@@ -48,32 +49,26 @@ ITrackStat::~ITrackStat()
}
-void ITrackStat::mousePressEvent(QMouseEvent * e)
+void ITrackStat::activePointEvent(double dist)
{
+ qDebug() << "ITrackStat::activePointEvent" << endl;
if(track.isNull()) return;
+ if(plot == 0) return;
+ QList<CTrack::pt_t>& trkpts = track->getTrackPoints();
+ QList<CTrack::pt_t>::const_iterator trkpt = trkpts.begin();
+ quint32 idx = 0;
+ while(trkpt != trkpts.end()) {
+ if(trkpt->flags & CTrack::pt_t::eDeleted) {
+ ++trkpt; continue;
+ }
- if(e->button() == Qt::LeftButton) {
- QPoint pos = e->pos();
-
- if(plot == 0) return;
-
- double dist = plot->getXValByPixel(pos.x() - SPACING);
- QList<CTrack::pt_t>& trkpts = track->getTrackPoints();
- QList<CTrack::pt_t>::const_iterator trkpt = trkpts.begin();
- quint32 idx = 0;
- while(trkpt != trkpts.end()) {
- if(trkpt->flags & CTrack::pt_t::eDeleted) {
- ++trkpt; continue;
- }
-
- if(dist < trkpt->distance) {
- track->setPointOfFocus(idx);
- break;
- }
- idx = trkpt->idx;
-
- ++trkpt;
+ if(dist < trkpt->distance) {
+ track->setPointOfFocus(idx);
+ break;
}
+ idx = trkpt->idx;
+
+ ++trkpt;
}
}
diff --git a/src/ITrackStat.h b/src/ITrackStat.h
index ce1710d..ce08f48 100644
--- a/src/ITrackStat.h
+++ b/src/ITrackStat.h
@@ -46,12 +46,12 @@ class ITrackStat : public QWidget, private Ui::ITrackStatWidget
CTrack::pt_t trkpt;
};
- void mousePressEvent(QMouseEvent * e);
-
void addWptTags(QVector<wpt_t>& wpts);
CPlot * plot;
QPointer<CTrack> track;
+ protected slots:
+ void activePointEvent(double x);
};
#endif //ITRACKSTAT_H
--
1.5.5.2
>From 5c9e2d5224b52b9750af24babaa9764dd6ec563c Mon Sep 17 00:00:00 2001
From: Adnrew <[EMAIL PROTECTED]>
Date: Tue, 23 Sep 2008 10:55:38 +0400
Subject: [PATCH] correct comments from Oliver:
* use flipMouseWheel() form CResources to use the same mouse wheel settings
like on the map.
* use CPlot::rectGraphArea and CPlot::rectIconArea as clipping rectangles
(QPainter::setClipRect(..))
* add a menu entry to reset zoom.
* lock min/max x axis.
---
src/CPlot.cpp | 37 ++++++++++++++++++----------
src/CPlot.h | 5 +++-
src/CPlotAxis.cpp | 50 ++++++++++++++++++++++++--------------
src/CPlotAxis.h | 20 ++++++++-------
src/CPlotData.cpp | 4 +-
src/CTrackStatProfileWidget.cpp | 1 +
src/CTrackStatSpeedWidget.cpp | 2 +-
7 files changed, 74 insertions(+), 45 deletions(-)
diff --git a/src/CPlot.cpp b/src/CPlot.cpp
index 8f2c3f2..6043788 100644
--- a/src/CPlot.cpp
+++ b/src/CPlot.cpp
@@ -129,8 +129,6 @@ void CPlot::paintEvent(QPaintEvent * )
void CPlot::resizeEvent(QResizeEvent * )
{
setSizes();
- m_pData->x().setScale( rectGraphArea.width() );
- m_pData->y().setScale( rectGraphArea.height() );
update();
}
@@ -249,8 +247,10 @@ void CPlot::draw(QPainter& p)
if(m_pData->lines.isEmpty()) return;
p.setFont(CResources::self().getMapFont());
-
+ p.setClipping(true);
+ p.setClipRect(rectGraphArea);
drawData(p);
+ p.setClipping(false);
drawLabels(p);
drawXScale(p);
drawYScale(p);
@@ -558,6 +558,7 @@ void CPlot::contextMenuEvent(QContextMenuEvent *event)
QMenu menu(this);
menu.addAction(hZoomAct);
menu.addAction(vZoomAct);
+ menu.addAction(resetZoomAct);
menu.exec(event->globalPos());
}
@@ -571,35 +572,46 @@ void CPlot::createActions()
vZoomAct = new QAction(tr("vertical zoom"), this);
vZoomAct->setCheckable(true);
vZoomAct->setChecked(true);
+
+ resetZoomAct = new QAction(tr("reset zoom"), this);
+ connect(resetZoomAct, SIGNAL(triggered()), this, SLOT(resetZoom()));
}
-void CPlot::zoom(CPlotAxis &axis, double factor, int curInt)
+void CPlot::resetZoom()
{
- axis.zoom(factor, curInt);
+ m_pData->x().resetZoom();
+ m_pData->y().resetZoom();
setSizes();
update();
}
+void CPlot::zoom(CPlotAxis &axis, bool in, int curInt)
+{
+ axis.zoom(in, curInt);
+ setSizes();
+ m_pData->x().setScale( rectGraphArea.width() );
+ m_pData->y().setScale( rectGraphArea.height() );
+ update();
+}
+
void CPlot::wheelEvent ( QWheelEvent * e )
{
+ bool in = CResources::self().flipMouseWheel() ? (e->delta() > 0) : (e->delta() < 0);
if (hZoomAct->isChecked())
- zoom(m_pData->x(), (1 + e->delta() / 1200.0), e->pos().x() - left);
+ zoom(m_pData->x(), in, e->pos().x() - left);
if (vZoomAct->isChecked())
- zoom(m_pData->y(), (1 + e->delta() / 1200.0), - e->pos().y() + bottom);
+ zoom(m_pData->y(), in, - e->pos().y() + bottom);
}
void CPlot::mouseMoveEvent(QMouseEvent * e)
{
- double p;
checkClick = false;
CPlotAxis &xaxis = m_pData->x();
- p = xaxis.pt2val(e->pos().x()) - xaxis.pt2val(startMovePos.x());
- xaxis.setMinMax(xaxis.getMin() - p , xaxis.getMax() - p);
+ xaxis.move(startMovePos.x() - e->pos().x());
CPlotAxis &yaxis = m_pData->y();
- p = yaxis.pt2val(e->pos().y()) - yaxis.pt2val(startMovePos.y());
- yaxis.setMinMax(yaxis.getMin() + p , yaxis.getMax() + p);
+ yaxis.move(e->pos().y() - startMovePos.y());
startMovePos = e->pos();
update();
@@ -616,7 +628,6 @@ void CPlot::mouseReleaseEvent(QMouseEvent * e)
void CPlot::mousePressEvent(QMouseEvent * e)
{
- qDebug() << "press" << endl;
startMovePos = e->pos();
checkClick = true;
}
diff --git a/src/CPlot.h b/src/CPlot.h
index 8ddc0cb..c1a02a5 100644
--- a/src/CPlot.h
+++ b/src/CPlot.h
@@ -75,11 +75,12 @@ class CPlot : public QWidget
void setSizeXLabel();
void setSizeYLabel();
void setSizeDrawArea();
- void zoom(CPlotAxis &axis, double factor, int cur = 0);
+ void zoom(CPlotAxis &axis, bool in, int cur = 0);
void createActions();
QAction *hZoomAct;
QAction *vZoomAct;
+ QAction *resetZoomAct;
CPlotData * m_pData;
@@ -109,5 +110,7 @@ class CPlot : public QWidget
QPoint startMovePos;
int checkClick;
+ public slots:
+ void resetZoom();
};
#endif //CPLOT_H
diff --git a/src/CPlotAxis.cpp b/src/CPlotAxis.cpp
index 2eacc7f..9e9c78b 100644
--- a/src/CPlotAxis.cpp
+++ b/src/CPlotAxis.cpp
@@ -28,8 +28,6 @@ CPlotAxis::CPlotAxis( QObject * parent )
, initialized( false )
, autoscale( false )
, scale( 1.0 )
-, given_min( 0.0 )
-, given_max( 0.0 )
, used_min( 0.0 )
, used_max( 0.0 )
, interval( 0.0 )
@@ -44,23 +42,16 @@ CPlotAxis::CPlotAxis( QObject * parent )
CPlotAxis::~CPlotAxis()
{}
-double CPlotAxis::getMin()
+void CPlotAxis::setLimits(double min, double max)
{
- return used_min;
+ limit_min = min;
+ limit_max = max;
}
-double CPlotAxis::getMax()
-{
- return used_max;
-}
-
-void CPlotAxis::setMinMax( double min, double max )
+void CPlotAxis::setMinMax( double given_min, double given_max )
{
double tmp;
- given_min = min;
- given_max = max;
-
if ( given_min == given_max ) {
if ( given_min != 0.0 ) {
given_min -= given_min / 10.0;
@@ -313,11 +304,32 @@ void CPlotAxis::setScale( const unsigned int pts )
scale = pts / ( used_max - used_min );
}
-void CPlotAxis::zoom(double factor, int fixedPoint)
+void CPlotAxis::resetZoom()
+{
+ setMinMax(limit_min, limit_max);
+}
+
+void CPlotAxis::zoom(bool in, int point)
+{
+ double min, p, d, factor;
+ if (in)
+ factor = 1/1.1;
+ else
+ factor = 1.1;
+
+ p = pt2val(point);
+ min = (p - used_min) * (1 - factor) + used_min;
+ d = min - used_min * factor;
+ setMinMax(min, used_max * factor + d);
+}
+
+void CPlotAxis::move(int delta_pt)
{
- double min, p, d;
- p = pt2val(fixedPoint);
- min = (p - getMin()) * (1 - factor) + getMin();
- d = min - getMin() * factor;
- setMinMax(min, getMax() * factor + d);
+ double delta_val = pt2val(delta_pt) - pt2val(0);
+ bool f = ! (used_max - used_min < limit_max - limit_min);
+ if (f ^ (used_min + delta_val < limit_min))
+ delta_val = (limit_min - used_min);
+ if (f ^ (used_max + delta_val > limit_max))
+ delta_val = (limit_max - used_max);
+ setMinMax(used_min + delta_val, used_max + delta_val);
}
diff --git a/src/CPlotAxis.h b/src/CPlotAxis.h
index 913ed66..56cf4b8 100644
--- a/src/CPlotAxis.h
+++ b/src/CPlotAxis.h
@@ -47,12 +47,16 @@ class CPlotAxis : public QObject
full /**< minmax && norm*/
};
- virtual double getMin();
- virtual double getMax();
-
- virtual void zoom(double factor, int fixedPoint);
+ ///zoom in/out with a given point as static
+ virtual void zoom(bool in, int point);
+ ///set the desired minimum and maximum value equal to limit values
+ virtual void resetZoom();
+ ///add delta_pt to min and max values
+ virtual void move(int delta_pt);
///set the desired minimum and maximum value
virtual void setMinMax(double min, double max);
+ ///set the limit minimum and maximum value
+ virtual void setLimits(double min, double max);
///set the scale factor for a given size in points
virtual void setScale(const unsigned int pts);
///calculate format for the given value
@@ -98,16 +102,14 @@ class CPlotAxis : public QObject
///scalefactor
double scale;
- ///the user applied min value
- double given_min;
- ///the user applied max value
- double given_max;
-
///the actual applied min value
double used_min;
///the actual applied max value
double used_max;
+ double limit_min;
+ double limit_max;
+
///the intervall of the ticmarks
double interval;
diff --git a/src/CPlotData.cpp b/src/CPlotData.cpp
index 1a39d7e..c0b6450 100644
--- a/src/CPlotData.cpp
+++ b/src/CPlotData.cpp
@@ -61,6 +61,6 @@ void CPlotData::setLimits()
++line;
}
- xaxis->setMinMax(xmin,xmax);
- yaxis->setMinMax(ymin,ymax);
+ xaxis->setLimits(xmin,xmax);
+ yaxis->setLimits(ymin,ymax);
}
diff --git a/src/CTrackStatProfileWidget.cpp b/src/CTrackStatProfileWidget.cpp
index ed29a25..1bc9e21 100644
--- a/src/CTrackStatProfileWidget.cpp
+++ b/src/CTrackStatProfileWidget.cpp
@@ -40,6 +40,7 @@ CTrackStatProfileWidget::CTrackStatProfileWidget(QWidget * parent)
slotChanged();
plot->setLimits();
+ plot->resetZoom();
}
CTrackStatProfileWidget::~CTrackStatProfileWidget()
diff --git a/src/CTrackStatSpeedWidget.cpp b/src/CTrackStatSpeedWidget.cpp
index 0aee0f5..9d799c0 100644
--- a/src/CTrackStatSpeedWidget.cpp
+++ b/src/CTrackStatSpeedWidget.cpp
@@ -35,7 +35,7 @@ CTrackStatSpeedWidget::CTrackStatSpeedWidget(QWidget * parent)
slotChanged();
plot->setLimits();
-
+ plot->resetZoom();
}
CTrackStatSpeedWidget::~CTrackStatSpeedWidget()
--
1.5.5.2
>From 04a78b2abb8806230f804cbe7c301a2272a93136 Mon Sep 17 00:00:00 2001
From: Adnrew <[EMAIL PROTECTED]>
Date: Tue, 23 Sep 2008 22:51:30 +0400
Subject: [PATCH] The waypoint icons and their lines is clipped, too.
>> * use CPlot::rectGraphArea and CPlot::rectIconArea as clipping rectangles
>> (QPainter::setClipRect(..))
don't use CPlot::rectIconArea. it isn't convenient for this case because:
"icon" include a label, a pixmap and a line.
a line should be in [left, right] only. I think my solve is good.
---
src/CPlot.cpp | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/CPlot.cpp b/src/CPlot.cpp
index 6043788..5e73f18 100644
--- a/src/CPlot.cpp
+++ b/src/CPlot.cpp
@@ -537,18 +537,23 @@ void CPlot::drawTags(QPainter& p)
ptx = left + xaxis.val2pt( tag->point.x() );
pty = bottom - yaxis.val2pt( tag->point.y() );
- rect = fm.boundingRect(tag->label);
- rect.moveCenter(QPoint(ptx, fontHeight / 2));
- p.setPen(Qt::darkBlue);
- p.drawText(rect, Qt::AlignCenter, tag->label);
-
- p.drawPixmap(ptx - tag->icon.width() / 2, fontHeight, tag->icon);
-
- p.setPen(QPen(Qt::white, 3));
- p.drawLine(ptx, fontHeight + 16, ptx, pty);
- p.setPen(QPen(Qt::black, 1));
- p.drawLine(ptx, fontHeight + 16, ptx, pty);
-
+ if (left < ptx && ptx < right) {
+ rect = fm.boundingRect(tag->label);
+ rect.moveCenter(QPoint(ptx, fontHeight / 2));
+ p.setPen(Qt::darkBlue);
+ p.drawText(rect, Qt::AlignCenter, tag->label);
+
+ p.drawPixmap(ptx - tag->icon.width() / 2, fontHeight, tag->icon);
+
+ p.setPen(QPen(Qt::white, 3));
+ if (fontHeight + 16 < pty) {
+ p.drawLine(ptx, fontHeight + 16, ptx, pty);
+ p.setPen(QPen(Qt::black, 1));
+ if (pty > bottom)
+ pty = bottom;
+ p.drawLine(ptx, fontHeight + 16, ptx, pty);
+ }
+ }
++tag;
}
}
--
1.5.5.2
>From e2cc504364a9fcaa4f9c3e655b4129055c95a99b Mon Sep 17 00:00:00 2001
From: Adnrew <[EMAIL PROTECTED]>
Date: Tue, 23 Sep 2008 22:53:14 +0400
Subject: [PATCH] correct handle switch tracks
>> * If you switch tracks the axis are not reset and adjusted to the new
>> values. I use 3 tracks to test 2 single ones and a third combined one.
>> If you switch between the tracks without closing the graph you will
>> see what I mean.
I know two way, how it may be fixed.
This patch contained simple: reset zoom after sigHighlightTrack
another way:
x and y axis should be saved for each CTrack.
this way allow save plot view preferences, but
it's more comlicated and I don't know whether it's needed.
what do you think about it?
---
src/CTrackStatProfileWidget.cpp | 12 ++++++++++++
src/CTrackStatProfileWidget.h | 5 +++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/CTrackStatProfileWidget.cpp b/src/CTrackStatProfileWidget.cpp
index 1bc9e21..4bf520b 100644
--- a/src/CTrackStatProfileWidget.cpp
+++ b/src/CTrackStatProfileWidget.cpp
@@ -30,6 +30,7 @@
CTrackStatProfileWidget::CTrackStatProfileWidget(QWidget * parent)
: ITrackStat(parent)
+, needResetZoom(true)
{
plot->setXLabel(tr("distance [m]"));
@@ -37,6 +38,7 @@ CTrackStatProfileWidget::CTrackStatProfileWidget(QWidget * parent)
connect(&CTrackDB::self(),SIGNAL(sigChanged()),this,SLOT(slotChanged()));
connect(&CWptDB::self(),SIGNAL(sigChanged()),this,SLOT(slotChanged()));
+ connect(&CTrackDB::self(), SIGNAL(sigHighlightTrack(CTrack*)), this, SLOT(slotSetTrack(CTrack*)));
slotChanged();
plot->setLimits();
@@ -48,6 +50,11 @@ CTrackStatProfileWidget::~CTrackStatProfileWidget()
}
+void CTrackStatProfileWidget::slotSetTrack(CTrack* track)
+{
+ needResetZoom = true;
+}
+
void CTrackStatProfileWidget::slotChanged()
{
track = CTrackDB::self().highlightedTrack();
@@ -112,6 +119,11 @@ void CTrackStatProfileWidget::slotChanged()
if(!lineDEM.isEmpty()){
plot->addLine(lineDEM, "DEM");
}
+ plot->setLimits();
+ if (needResetZoom) {
+ plot->resetZoom();
+ needResetZoom = false;
+ }
}
diff --git a/src/CTrackStatProfileWidget.h b/src/CTrackStatProfileWidget.h
index c90061a..f0f96ee 100644
--- a/src/CTrackStatProfileWidget.h
+++ b/src/CTrackStatProfileWidget.h
@@ -28,10 +28,11 @@ class CTrackStatProfileWidget : public ITrackStat
public:
CTrackStatProfileWidget(QWidget * parent);
virtual ~CTrackStatProfileWidget();
-
+ private:
+ bool needResetZoom;
private slots:
void slotChanged();
-
+ void slotSetTrack(CTrack *track);
};
--
1.5.5.2
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QLandkarte-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkarte-users