Joey Mukherjee | 25 Jul 20:01
Favicon

Alignment of QwtPlotScaleItem with axis

I use QwtPlotScaleItem to draw inner axes tick marks and when the  
plot first comes up, the inner tick marks are not aligned with the  
outer tick marks.  If I resize the plot a little, the tick marks  
correct themselves.

Does anyone know what I might be doing wrong?

I tried modifying one of the examples to match what I am doing, and  
was unsuccessful in duplicating the problem.  Here's essentially the  
code I am using:

+    QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem ();
+    scaleItem->setAlignment (QwtScaleDraw::TopScale);
+    scaleItem->setAxis (QwtPlot::xBottom, QwtPlot::yLeft);
+    scaleItem->setBorderDistance (0);
+    scaleItem->scaleDraw ()->setTickLength (QwtScaleDiv::MajorTick, 8);
+    scaleItem->scaleDraw ()->setTickLength (QwtScaleDiv::MinorTick, 4);
+    scaleItem->scaleDraw ()->enableComponent  
(QwtAbstractScaleDraw::Labels, false);
+    scaleItem->attach (this);

Naturally, this is part of a bigger program so I am sure it is an  
order of operations type of thing, but I am lost at what else I can  
check.  Does anyone have ideas of where to look or what else I can  
set or call which might help?

Thanks,
Joey

-------------------------------------------------------------------------
(Continue reading)

David Stranz | 25 Jul 20:20

RE: Alignment of QwtPlotScaleItem with axis

Hi Joey,

There's this mysterious call in some of the examples:

	pPlot->plotLayout()->setAlignCanvasToScales( true );

Maybe that's the magic dust you need to sprinkle on your axes?

Regards,

David
_______________________________________________________________
David Stranz, Ph.D.	david_stranz <at> MassSpec.com

Sierra Analytics, Inc.
5815 Stoddard Road, Suite 601
Modesto, CA  95356

Tel: (209) 545-8508
http://www.massspec.com
_______________________________________________________________

> -----Original Message-----
> From: qwt-interest-bounces <at> lists.sourceforge.net 
> [mailto:qwt-interest-bounces <at> lists.sourceforge.net] On Behalf 
> Of Joey Mukherjee
> Sent: Friday, July 25, 2008 11:05 AM
> To: List for both Qwt users and developers
> Subject: Alignment of QwtPlotScaleItem with axis
> 
(Continue reading)

Joey Mukherjee | 25 Jul 23:02
Favicon

Re: Alignment of QwtPlotScaleItem with axis

Sadly, I have one of those and I put it before and after setting the  
scales and every which way, but nothing will make those lines line up!

Thanks for the response!

Joey

On Jul 25, 2008, at 1:20 PM, David Stranz wrote:

> Hi Joey,
>
> There's this mysterious call in some of the examples:
>
> 	pPlot->plotLayout()->setAlignCanvasToScales( true );
>
> Maybe that's the magic dust you need to sprinkle on your axes?
>
> Regards,
>
> David
> _______________________________________________________________
> David Stranz, Ph.D.	david_stranz <at> MassSpec.com
>
> Sierra Analytics, Inc.
> 5815 Stoddard Road, Suite 601
> Modesto, CA  95356
>
> Tel: (209) 545-8508
> http://www.massspec.com
> _______________________________________________________________
(Continue reading)

Uwe Rathmann | 27 Jul 10:31

Re: Alignment of QwtPlotScaleItem with axis

On Friday 25 July 2008 20:04, Joey Mukherjee wrote:

> I use QwtPlotScaleItem to draw inner axes tick marks and when the  
> plot first comes up, the inner tick marks are not aligned with the  
> outer tick marks.  If I resize the plot a little, the tick marks  
> correct themselves.

Position and size of the scale item (and its tick positions) are recalculated 
each time the item gets painted. So the only situation I can imagine where 
this might happen is, when the outer scales have been changed without any 
following replot. But then all other plot items will be wrong too.
Maybe insert a line marker to see if I'm right.

I also noticed, that there is a rounding problem, that might leads to a 1 
pixel misalignment for some of the ticks.

Uwe

PS: I remember, that I had fixed a couple of bugs in QwtPlotScaleItem in Qwt 
5.1.

-------------------------------------------------------------------------
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=/
Joey Mukherjee | 29 Jul 15:04
Favicon

Re: Alignment of QwtPlotScaleItem with axis

On Sun, Jul 27, 2008 at 3:31 AM, Uwe Rathmann <Uwe.Rathmann <at> tigertal.de> wrote:
On Friday 25 July 2008 20:04, Joey Mukherjee wrote:

> I use QwtPlotScaleItem to draw inner axes tick marks and when the  
> plot first comes up, the inner tick marks are not aligned with the  
> outer tick marks.  If I resize the plot a little, the tick marks  
> correct themselves.

Position and size of the scale item (and its tick positions) are recalculated
each time the item gets painted. So the only situation I can imagine where
this might happen is, when the outer scales have been changed without any
following replot. But then all other plot items will be wrong too.
Maybe insert a line marker to see if I'm right.

I have added markers and all the markers are in the right place (down to the pixel!); however, the inner ticks continue to be off!

Here is one "odd" thing I do:

// Set the top axis to be the same limits as the bottom so we get lined up (more or less) tick marks

    lastPlot->plotLayout ()->setAlignCanvasToScales (true);

// Draw inward ticks regardless of whether they are enabled on the top/bottom axes

    <create the inner ticks plot scale item here>

    lastPlot->replot (); // needed for time axis so upper bound is computed

    if ((topAxis.IsActive () && !bottomAxis.IsActive ()) ||
        (rightAxis.IsActive () && !leftAxis.IsActive ()))
        lastPlot->setAxisScaleDiv (QwtPlot::xBottom, *(lastPlot->axisScaleDiv (QwtPlot::xTop)));
    else
        lastPlot->setAxisScaleDiv (QwtPlot::xTop, *(lastPlot->axisScaleDiv (QwtPlot::xBottom)));

I have to call replot so the upper/lower bounds are calculated before I set the top axis to be the same as the bottom axis.  I have tried adding the inner ticks both before and after this bit of code and it makes no difference as well as moving the replot around. 

One other thing - when making all these calls, the plot is not visible on the screen.  For some reason, the recalculation that needs to occur for the inner ticks does not occur unless the plot is visible?
 
I also noticed, that there is a rounding problem, that might leads to a 1
pixel misalignment for some of the ticks.
PS: I remember, that I had fixed a couple of bugs in QwtPlotScaleItem in Qwt
5.1.

I've noticed the off by 1 pixel as well; however, most of the ticks are lined up okay.  In my current problem, the ticks are really off.  I am using the trunk version of Qwt so I assume those fixes are in there.

Any other ideas?

Thanks,
Joey
-------------------------------------------------------------------------
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=/
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Uwe Rathmann | 30 Jul 07:05

Re: Alignment of QwtPlotScaleItem with axis

On Tuesday 29 July 2008 15:04, Joey Mukherjee wrote:

> Here is one "odd" thing I do:

I couldn't reproduce the problem. So I'm afraid you need to send me the code 
of a small application, demonstrating the problem.

Uwe

-------------------------------------------------------------------------
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=/
Joey Mukherjee | 4 Aug 19:58
Favicon

Re: Alignment of QwtPlotScaleItem with axis

On Wed, Jul 30, 2008 at 12:05 AM, Uwe Rathmann <Uwe.Rathmann <at> tigertal.de> wrote:

I couldn't reproduce the problem. So I'm afraid you need to send me the code
of a small application, demonstrating the problem.

I've had a hard time reproducing this problem in a small sample program, so I did some more debugging and found out this:

If I comment out the "replot()" in QwtPlot::polish (which is the whole routine basically), all the ticks are lined up okay.  However, any zooming that is done causes the ticks to get out of line again.  

If I apply this patch:

--- src/qwt_plot_scaleitem.cpp  (revision 391)
+++ src/qwt_plot_scaleitem.cpp  (working copy)
<at> <at> -476,6 +476,6 <at> <at>
     }
 
     QwtScaleDiv scaleDiv = d_data->scaleDraw->scaleDiv();
-    scaleDiv.setInterval(interval);
+//    scaleDiv.setInterval(interval);
     d_data->scaleDraw->setScaleDiv(scaleDiv);
 }

everything is okay.  Basically, the interval it has is perfectly fine, yet it is the recomputation of the interval that causes it to fail.  

Maybe it is tied to the zooming of the axes in that they are not getting updated?  I have my own zooming classes which descend from QwtPlotZoomer, but the only code I am only overloading the widgetMouseReleaseEvent and the trackerText. 

Anyway, does that give any clues of what might be wrong or what else I can check?  

Thanks,
Joey
-------------------------------------------------------------------------
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=/
_______________________________________________
qwt-interest mailing list
qwt-interest <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qwt-interest
Uwe Rathmann | 6 Aug 07:39

Re: Alignment of QwtPlotScaleItem with axis

On Monday 04 August 2008 19:58, Joey Mukherjee wrote:

> Anyway, does that give any clues of what might be wrong or what else I can
> check?

The geometry of a QwtPlotScaleItem is updated each time it is painted. Try to 
debug QwtPlotScaleItem::draw: maybe the most interesting part is to compare 
the QwtScaleMaps (xMap/yMap vs. sd->map() ) after(!)  d_data->scaleDraw has 
been updated.

Uwe

-------------------------------------------------------------------------
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=/
Uwe Rathmann | 30 Jul 07:55

Re: Alignment of QwtPlotScaleItem with axis

On Tuesday 29 July 2008 15:04, Joey Mukherjee wrote:

> I've noticed the off by 1 pixel as well;

Almost fixed in SVN: the ticks are on the right positions now, but the inner 
scale is one pixel too short now. I will have a look at this later.

Uwe

-------------------------------------------------------------------------
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=/

Gmane