Commit b52ad2b8 authored by David Saxton's avatar David Saxton

Use 3 significant figures instead of 2 decimal places for displaying (x,y)

coordinates in statusbar.

svn path=/trunk/KDE/kdeedu/kmplot/; revision=525215
parent 14c7591a
......@@ -564,6 +564,7 @@ void MainDlg::slotCoord1()
Settings::setXRange( 0 );
Settings::setYRange( 0 );
m_modified = true;
View::self()->getSettings();
View::self()->drawPlot();
}
......@@ -572,6 +573,7 @@ void MainDlg::slotCoord2()
Settings::setXRange( 2 );
Settings::setYRange( 0 );
m_modified = true;
View::self()->getSettings();
View::self()->drawPlot();
}
......@@ -580,6 +582,7 @@ void MainDlg::slotCoord3()
Settings::setXRange( 2 );
Settings::setYRange( 2 );
m_modified = true;
View::self()->getSettings();
View::self()->drawPlot();
}
......
......@@ -150,9 +150,6 @@ void View::draw(QPaintDevice *dev, int form)
w=rc.width();
h=rc.height();
setPlotRange();
setScaling();
if(form==0) // screen
{
ref=QPoint(120, 100);
......@@ -211,6 +208,7 @@ void View::draw(QPaintDevice *dev, int form)
}
dgr.updateSettings();
// kDebug() << "tlgx="<<tlgx<<" tlgy="<<tlgy<<endl;
dgr.Skal( tlgx, tlgy );
if ( form!=0 && areaDraw)
......@@ -1131,8 +1129,17 @@ void View::mouseMoveEvent(QMouseEvent *e)
if ( inBounds )
{
sx.sprintf( " x= %+.2f", csxpos );
sy.sprintf( " y= %+.2f", csypos );
// sx.sprintf( " x= %+.2f", csxpos );
// sy.sprintf( " y= %+.2f", csypos );
if ( qAbs(csxpos) > 1e4 )
sx = QString( "x = %1" ).arg( csxpos, 0, 'f', 0 );
else
sx = QString( "x = %1" ).arg( csxpos, 0, 'g', 3 );
if ( qAbs(csypos) > 1e4 )
sy = QString( "y = %1" ).arg( csypos, 0, 'f', 0 );
else
sy = QString( "y = %1" ).arg( csypos, 0, 'g', 3 );
}
else
sx = sy = "";
......@@ -1324,7 +1331,7 @@ bool View::updateCrosshairPosition()
{
QString str=" ";
str+=i18n("root");
setStatusBar(str+QString().sprintf(": x0= %+.5f", x0), 3);
setStatusBar(str+QString().sprintf(": x0 = %+.5f", x0), 3);
rootflg=true;
}
}
......@@ -1521,13 +1528,21 @@ void View::animateZoom( const QRectF & _newCoords )
; // do nothing
}
Settings::setXMin( Parser::number( newCoords.left() ) );
Settings::setXMax( Parser::number( newCoords.right() ) );
Settings::setYMin( Parser::number( newCoords.top() ) );
Settings::setYMax( Parser::number( newCoords.bottom() ) );
xmin = newCoords.left();
xmax = newCoords.right();
ymin = newCoords.top();
ymax = newCoords.bottom();
Settings::setXMin( Parser::number( xmin ) );
Settings::setXMax( Parser::number( xmax ) );
Settings::setYMin( Parser::number( ymin ) );
Settings::setYMax( Parser::number( ymax ) );
Settings::setXRange(4); //custom x-range
Settings::setYRange(4); //custom y-range
setScaling();
drawPlot(); //update all graphs
m_zoomMode = Normal;
......@@ -1548,9 +1563,12 @@ void View::translateView( int dx, int dy )
Settings::setXMax( Parser::number( xmax ) );
Settings::setYMin( Parser::number( ymin ) );
Settings::setYMax( Parser::number( ymax ) );
Settings::setXRange(4); //custom x-range
Settings::setYRange(4); //custom y-range
setScaling();
drawPlot(); //update all graphs
}
......@@ -1582,20 +1600,18 @@ void View::coordToMinMax( const int koord, const QString &minStr, const QString
}
}
void View::setPlotRange()
{
coordToMinMax( Settings::xRange(), Settings::xMin(), Settings::xMax(), xmin, xmax );
coordToMinMax( Settings::yRange(), Settings::yMin(), Settings::yMax(), ymin, ymax );
}
void View::setScaling()
{
QString units[ 9 ] = { "10", "5", "2", "1", "0.5", "pi/2", "pi/3", "pi/4",i18n("automatic") };
assert( (Settings::xScaling >= 0) && (Settings::xScaling() < 9) );
assert( (Settings::yScaling >= 0) && (Settings::yScaling() < 9) );
if( Settings::xScaling() == 8) //automatic x-scaling
{
tlgx = double(xmax-xmin)/16;
tlgxstr = units[ Settings::xScaling() ];
// kDebug() << "xmax="<<xmax<<" xmin="<<xmin<<" tlgx="<<tlgx<<endl;
}
else
{
......@@ -1622,6 +1638,12 @@ void View::setScaling()
void View::getSettings()
{
// kDebug() << "###############################" << k_funcinfo << endl;
coordToMinMax( Settings::xRange(), Settings::xMin(), Settings::xMax(), xmin, xmax );
coordToMinMax( Settings::yRange(), Settings::yMin(), Settings::yMax(), ymin, ymax );
setScaling();
m_parser->setAngleMode( Settings::anglemode() );
backgroundcolor = Settings::backgroundcolor();
......
......@@ -272,8 +272,6 @@ private:
*/
void coordToMinMax( const int koord, const QString &minStr, const QString &maxStr,
double &min, double &max );
/// Sets the plot range from Settings
void setPlotRange();
//@{
/** Current plot range endge. */
double ymin;
......
......@@ -83,7 +83,7 @@ KmPlot::KmPlot( KCmdLineArgs* args)
}
if (!initialGeometrySet())
resize( QSize(450, 520).expandedTo(minimumSizeHint()));
resize( QSize(800, 520).expandedTo(minimumSizeHint()));
// apply the saved mainwindow settings, if any, and ask the mainwindow
// to automatically save settings if changed: window size, toolbar
......@@ -300,8 +300,8 @@ void KmPlot::setStatusBarText(const QString &text, int id)
void KmPlot::setupStatusBar()
{
statusBar()->insertFixedItem( "1234567890", 1 );
statusBar()->insertFixedItem( "1234567890", 2 );
statusBar()->insertFixedItem( "123456789012", 1 );
statusBar()->insertFixedItem( "123456789012", 2 );
statusBar()->insertItem( "", 3, 3 );
statusBar()->insertItem( "", 4 );
statusBar()->changeItem( "", 1 );
......
......@@ -346,6 +346,8 @@ void KmPlotIO::parseAxes( const QDomElement &n )
Settings::setYRange( n.namedItem( "ycoord" ).toElement().text().toInt() );
Settings::setYMin( n.namedItem( "ymin" ).toElement().text() );
Settings::setYMax( n.namedItem( "ymax" ).toElement().text() );
View::self()->getSettings();
}
void KmPlotIO::parseGrid( const QDomElement & n )
......@@ -372,6 +374,8 @@ void KmPlotIO::parseScale(const QDomElement & n )
Settings::setYScaling( n.namedItem( "tic-y" ).toElement().text().toInt() );
Settings::setXPrinting( n.namedItem( "print-tic-x" ).toElement().text().toInt() );
Settings::setYPrinting( n.namedItem( "print-tic-y" ).toElement().text().toInt() );
View::self()->getSettings();
}
// static
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment