]> Git trees. - libqmvoc.git/commitdiff
zoomed tickmarks, but worng labels
authorMartin Pfeiffer <hubipete@gmx.net>
Thu, 14 Jul 2005 16:23:42 +0000 (16:23 +0000)
committerMartin Pfeiffer <hubipete@gmx.net>
Thu, 14 Jul 2005 16:23:42 +0000 (16:23 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/spectrum.cpp; revision=434575

kalzium/src/spectrum.cpp

index 16ac48350da4ca466ecf6ae31e91bfb8b79fd372..3780c4c9f11b81e2d2d3ccc12d295d736438d2b8 100644 (file)
@@ -35,7 +35,7 @@ SpectrumWidget::SpectrumWidget( QWidget* parent, const char* name )
        Gamma = 0.8;
        IntensityMax = 255,
        
-       startValue = 450;
+       startValue = 400;
        endValue = 700;
 
        m_realWidth = 360;
@@ -144,7 +144,7 @@ void SpectrumWidget::drawEmmissionSpectrum( QPainter *p )
 void SpectrumWidget::drawTickmarks( QPainter* p )
 {
        const int space = 13;
-       
+/*     
        for ( int i = 0; i < width() ; i+=10 )
        {
                p->drawLine( i,m_realHeight,i, m_realHeight+5 );
@@ -158,6 +158,29 @@ void SpectrumWidget::drawTickmarks( QPainter* p )
                p->drawLine( i,m_realHeight,i, m_realHeight+10 );
                p->fillRect( i-space, m_realHeight+12, 2*space, 15, Qt::white );
                p->drawText( i-space, m_realHeight+12, 2*space, 15, Qt::AlignCenter, QString::number( wave ) );
+       }*/
+
+       int start = (int)startValue % 10;
+       double dist =  width()/(endValue-startValue) * 10;      //distance between the tickles in px
+
+       int count = startValue + start;
+       start *= width()/(endValue-startValue);
+
+       for ( int i = start; i < width(); i += dist )
+       {
+               if(count%50 == 0 )
+               {
+                       int wave = ( int )Wavelength( i/width() );
+
+                       p->drawLine( i, m_realHeight, i, m_realHeight+10 );     
+                       p->fillRect( i-space, m_realHeight+12, 2*space, 15, Qt::white );
+                       p->drawText( i-space, m_realHeight+12, 2*space, 15, Qt::AlignCenter, QString::number( wave ) );         
+               }
+               else
+               {
+                       p->drawLine( i, m_realHeight, i, m_realHeight+5 );
+               }
+               count += 10;
        }
 }