Joey Mukherjee | 4 Jun 2008 23:36
Favicon

Autoscaling and Log axes

With the recent versions of Qwt (including the recent trunk), when I  
draw my plots, one of my axes are not drawn if the axis is auto  
scaled and logarithmic.  If the axis is not auto scaled, or is linear  
(either auto scaled or not), the axis is drawn fine.

Here is a snippet of how I am creating my axis:

     QwtScaleEngine *se = NULL;
     if (axis.GetIsLog () == true)
         se = new QwtLog10ScaleEngine ();
     else se = new QwtLinearScaleEngine ();

     _qwtplot->setAxisScaleDraw (axisId, new ScaleDraw);
     se->setAttribute (QwtScaleEngine::Floating, true);
     _qwtplot->setAxisScaleEngine (axisId, se);
     if (axis.GetIsAutoScaled () == false) {
         _qwtplot->setAxisScale (axisId, axis.GetLower (),  
axis.GetUpper ());
     }

I could swear this use to work fine.

Any ideas?

Thanks,
Joey

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
(Continue reading)

Joey Mukherjee | 5 Jun 2008 00:14
Favicon

Re: Autoscaling and Log axes

Oops.  Ok, I figured out why I have my problem and it was my fault.   
Sorry for the noise...

However, the real problem I have is the log scale, when it is  
floating and autoscaled, will hang for a very long time given a large  
range in the limits, but still not over a decade.

Here is how I fixed it:

Index: qwt_scale_engine.cpp
===================================================================
--- qwt_scale_engine.cpp        (revision 406)
+++ qwt_scale_engine.cpp        (working copy)
 <at>  <at>  -655,8 +655,12  <at>  <at> 
          interval = buildInterval(interval.minValue());

      stepSize = divideInterval(log10(interval).width(), qwtMax 
(maxNumSteps, 1));
-    if ( stepSize < 1.0 )
-        stepSize = 1.0;
+    if ( stepSize < 1.0 ) {
+        if (interval.maxValue() / interval.minValue() < 10.0)
+            stepSize = divideInterval(interval.width(), qwtMax 
(maxNumSteps, 1));
+        else stepSize = 1.0;
+    }

      if (!testAttribute(QwtScaleEngine::Floating))
          interval = align(interval, stepSize);

(Continue reading)


Gmane