Bug 114813

Summary: Compile error on Solaris 8 - spectrum.cpp uses round() which is not available
Product: [Applications] kalzium Reporter: Steve Evans <stevee>
Component: generalAssignee: Kalzium Developers <kalzium>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Solaris   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Steve Evans 2005-10-21 14:44:02 UTC
Version:            (using KDE KDE 3.4.92)
Installed from:    Compiled From Sources
Compiler:          gcc 3.4.3 
OS:                Solaris

if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I./../../libkdeedu/kdeeduplot -I./../../libkdeedu/kdeeduui -I/opt/kde/include -I/opt/qt/include   -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -I/gorbag/exta/cad/externals/SOLARIS/include  -DQT_THREAD_SUPPORT -I/opt/kde/include -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -I/gorbag/exta/cad/externals/SOLARIS/include -I/opt/qt/include  -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DSVR4  -Wno-long-long -Wundef -Wall -W -Wpointer-arith -DNDEBUG -DNO_DEBUG -O2 -I/opt/kde/include -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -I/gorbag/exta/cad/externals/SOLARIS/include -I/opt/qt/include -O2 -fomit-frame-pointer -DNeedVarargsPrototypes=1 -DNeedFunctionPrototypes=1 -pipe -fno-exceptions -mcpu=ultrasparc -Wno-non-virtual-dtor -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -D_ISOC99_SOURCE -MT spectrum.o -MD -MP -MF ".deps/spectrum.Tpo" -c -o spectrum.o spectrum.cpp; \
then mv -f ".deps/spectrum.Tpo" ".deps/spectrum.Po"; else rm -f ".deps/spectrum.Tpo"; exit 1; fi
spectrum.cpp: In member function `void Spectrum::adjustIntensities()':
spectrum.cpp:100: error: `round' undeclared (first use this function)
spectrum.cpp:100: error: (Each undeclared identifier is reported only once for each function it appears in.)

kcalc had a similar problem in kde 3.3 beta which was subsequently fixed, see bug 99346.
Comment 1 Steve Evans 2005-10-21 14:47:36 UTC
kalziumutils.cpp and spectrumwidget.cpp suffer from the same problem
Comment 2 Albert Astals Cid 2005-10-23 17:34:15 UTC
SVN commit 473393 by aacid:

round() -> qRound()
BUGS: 114813


 M  +1 -1      kalziumutils.cpp  
 M  +1 -1      spectrum.cpp  
 M  +3 -18     spectrumwidget.cpp  
 M  +0 -2      spectrumwidget.h  


--- branches/KDE/3.5/kdeedu/kalzium/src/kalziumutils.cpp #473392:473393
@@ -63,7 +63,7 @@
 		power *= 10;
 
 	num = num / power * 10000;
-	num = round( num );
+	num = qRound( num );
 
 	return num * power / 10000;
 }
--- branches/KDE/3.5/kdeedu/kalzium/src/spectrum.cpp #473392:473393
@@ -97,7 +97,7 @@
 		double curInt = ( ( double )( *it ).intensity );
 		
 		double newInt = max*1000/curInt;
-		( *it ).intensity = ( int ) round( newInt );
+		( *it ).intensity = qRound( newInt );
 	}
 }
 
--- branches/KDE/3.5/kdeedu/kalzium/src/spectrumwidget.cpp #473392:473393
@@ -21,6 +21,7 @@
 #include "spectrumwidget.h"
 #include "spectrum.h"
 #include "element.h"
+#include "kalziumutils.h"
 
 #include <kdebug.h>
 #include <klocale.h>
@@ -216,7 +217,7 @@
 	if ( color == 0.0 )
 		return 0;
 	else
-		return ( int )( round( IntensityMax * pow( color*factor, Gamma ) ) );
+		return qRound( IntensityMax * pow( color*factor, Gamma ) );
 }
 
 void SpectrumWidget::drawTickmarks( QPainter* p )
@@ -243,7 +244,7 @@
 			{
 				pos = ( double ) ( i*d )/width();
 				p->fillRect( i*d-space, m_realHeight+12, 2*space, 15, Qt::white );
-				p->drawText( i*d-space, m_realHeight+12, 2*space, 15, Qt::AlignCenter, QString::number( strippedValue( Wavelength( pos ) ) ) );
+				p->drawText( i*d-space, m_realHeight+12, 2*space, 15, Qt::AlignCenter, QString::number( KalziumUtils::strippedValue( Wavelength( pos ) ) ) );
 			}
 		}
 		else {//small tickmarks
@@ -252,22 +253,6 @@
 	}
 }
 
-double SpectrumWidget::strippedValue( double num )
-{
-	if ( !finite( num ) )
-		return num;
-
-	double power;
-	power = 1e-6;
-	while ( power < num )
-		power *= 10;
-
-	num = num / power * 10000;
-	num = round( num );
-
-	return num * power / 10000;
-}
-
 void SpectrumWidget::keyPressEvent( QKeyEvent *e )
 {
 	 kdDebug() << "SpectrumWidget::keyPressEvent()" << endl;
--- branches/KDE/3.5/kdeedu/kalzium/src/spectrumwidget.h #473392:473393
@@ -141,8 +141,6 @@
 			return startValue + (  (  endValue-startValue ) *  xpos );
 		}
 
-		double strippedValue( double num );
-
 		/**
 		 * This method changes the three values @p r, @p g and @p b to the
 		 * correct values