Logo Search packages:      
Sourcecode: ktechlab version File versions

void Oscilloscope::setZoomLevel ( double  zoomLevel  ) 

Sets the zoom level (and in the process, checks that it is within the bounds allowed).

Definition at line 113 of file oscilloscope.cpp.

References pixelsPerSecond(), and sliderTicksPerSecond().

Referenced by slotZoomSliderChanged().

      if( zoomLevel < 0.0)
            zoomLevel = 0.0;
      else if( zoomLevel > 1.0)
            zoomLevel = 1.0;
      KGlobal::config()->writeEntry( "ZoomLevel", zoomLevel);
      // We want to maintain the position of the *center* of the view, not the
      // left edge, so have to record time at center of view... We also have to
      // handle the case where the scroll is at the end separately.
      bool wasAtUpperEnd = horizontalScroll->maxValue() == horizontalScroll->value();
      int pageLength = int(oscilloscopeView->width()*sliderTicksPerSecond()/pixelsPerSecond());
      int at_ticks = horizontalScroll->value() + (pageLength/2);
      m_zoomLevel = zoomLevel;
      zoomSlider->setValue( int((double(zoomSlider->maxValue())*zoomLevel)+0.5));
      // And restore the center position of the slider
            int pageLength = int(oscilloscopeView->width()*sliderTicksPerSecond()/pixelsPerSecond());
            horizontalScroll->setValue( at_ticks - (pageLength/2));

Generated by  Doxygen 1.6.0   Back to index