[Kstars-devel] KDE/kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Wed Sep 6 16:24:52 CEST 2006


SVN commit 581498 by harris:

Updating to use the revised KPlotWidget.  The biggest change is that 
KStarsPlotWidget is no longer needed, because I added its extensions to 
KPlotWidget.  

CCMAIL: kstars-devel at kde.org



 M  +0 -1      CMakeLists.txt  
 M  +19 -11    tools/altvstime.cpp  
 M  +5 -4      tools/altvstime.h  
 M  +9 -8      tools/jmoontool.cpp  
 M  +2 -2      tools/jmoontool.h  
 M  +10 -9     tools/planetviewer.cpp  
 M  +6 -4      tools/pvplotwidget.cpp  
 M  +2 -2      tools/pvplotwidget.h  
 D             widgets/kstarsplotwidget.cpp  
 D             widgets/kstarsplotwidget.h  


--- trunk/KDE/kdeedu/kstars/kstars/CMakeLists.txt #581497:581498
@@ -201,7 +201,6 @@
 	widgets/clicklabel.cpp 
 	widgets/dmsbox.cpp 
 	widgets/draglistbox.cpp 
-	widgets/kstarsplotwidget.cpp 
 	widgets/logedit.cpp
 	widgets/magnitudespinbox.cpp 
 	widgets/mapcanvas.cpp 
--- trunk/KDE/kdeedu/kstars/kstars/tools/altvstime.cpp #581497:581498
@@ -41,7 +41,6 @@
 #include "finddialog.h"
 #include "locationdialog.h"
 #include "widgets/dmsbox.h"
-#include "widgets/kstarsplotwidget.h"
 
 #include "kstarsdatetime.h"
 #include "libkdeedu/extdate/extdatetimeedit.h"
@@ -71,11 +70,12 @@
 	View = new AVTPlotWidget( -12.0, 12.0, -90.0, 90.0, page );
 	View->setMinimumSize( 400, 400 );
 	View->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
-	View->setXAxisType( KStarsPlotWidget::TIME );
-	View->setYAxisType( KStarsPlotWidget::ANGLE );
 	View->setShowGrid( false );
+	View->axis(KPlotWidget::BottomAxis)->setTickLabelFormat( 't' );
 	View->axis(KPlotWidget::BottomAxis)->setLabel( i18n( "Local Time" ) );
-	View->setXAxisLabel2( i18n( "Local Sidereal Time" ) );
+	View->axis(KPlotWidget::TopAxis)->setTickLabelFormat( 't' );
+	View->axis(KPlotWidget::TopAxis)->setShowTickLabels( true );
+	View->axis(KPlotWidget::TopAxis)->setLabel( i18n( "Local Sidereal Time" ) );
 	View->axis(KPlotWidget::LeftAxis)->setLabel( i18nc( "the angle of an object above (or below) the horizon", "Altitude" ) );
 
 	avtUI = new AltVsTimeUI( page );
@@ -102,7 +102,6 @@
 	computeSunRiseSetTimes();
 
 	setLSTLimits();
-	View->updateTickmarks();
 
 	connect( avtUI->browseButton, SIGNAL( clicked() ), this, SLOT( slotBrowseObject() ) );
 	connect( avtUI->cityButton,   SIGNAL( clicked() ), this, SLOT( slotChooseCity() ) );
@@ -470,7 +469,10 @@
 	KStarsDateTime ut = getDate().addSecs( ((double)DayOffset + 0.5)*86400. );
 
 	dms lst = geo->GSTtoLST( ut.gst() );
-	View->setSecondaryLimits( lst.Hours(), lst.Hours() + 24.0, -90.0, 90.0 );
+	double h1 = lst.Hours();
+	if ( h1 > 12.0 ) h1 -= 24.0;
+	double h2 = h1 + 24.0;
+	View->setSecondaryLimits( h1, h2, -90.0, 90.0 );
 }
 
 void AltVsTime::showCurrentDate (void)
@@ -503,7 +505,7 @@
 }
 
 AVTPlotWidget::AVTPlotWidget( double x1, double x2, double y1, double y2, QWidget *parent )
-	: KStarsPlotWidget( x1, x2, y1, y2, parent )
+	: KPlotWidget( x1, x2, y1, y2, parent )
 {
 	//Default SunRise/SunSet values
 	SunRise = 0.25;
@@ -544,10 +546,14 @@
 	QPainter p;
 
 	p.begin( this );
-	p.fillRect( 0, 0, width(), height(), backgroundColor() );
-
+	p.setRenderHint( QPainter::Antialiasing, UseAntialias );
+	p.fillRect( rect(), backgroundColor() );
 	p.translate( leftPadding(), topPadding() );
 
+	setPixRect();
+	p.setClipRect( PixRect );
+	p.setClipping( true );
+
 	int pW = PixRect.width();
 	int pH = PixRect.height();
 
@@ -577,9 +583,11 @@
 	//draw ground
 	p.fillRect( 0, int(0.5*pH), pW, int(0.5*pH), QColor( "#002200" ) );
 
-	drawBox( &p );
 	drawObjects( &p );
 
+	p.setClipping( false );
+	drawAxes( &p );
+
 	//Add vertical line indicating "now"
 	QTime t = QTime::currentTime();
 	double x = 12.0 + t.hour() + t.minute()/60.0 + t.second()/3600.0;
@@ -591,7 +599,7 @@
 	//Label this vertical line with the current time
 	p.save();
 	QFont smallFont = p.font();
-	smallFont.setPointSize( smallFont.pointSize() - 3 );
+	smallFont.setPointSize( smallFont.pointSize() - 2 );
 	p.setFont( smallFont );
 	p.translate( ix + 10, pH - 20 );
 	p.rotate(-90);
--- trunk/KDE/kdeedu/kstars/kstars/tools/altvstime.h #581497:581498
@@ -23,7 +23,7 @@
 #include <QVBoxLayout>
 #include <QPaintEvent>
 
-#include "widgets/kstarsplotwidget.h"
+#include "libkdeedu/kdeeduplot/kplotwidget.h"
 #include "ui_altvstime.h"
 
 class KStarsDateTime;
@@ -46,7 +46,7 @@
 };
 
 /**@class AVTPlotWidget
-	*@short An extension of the KStarsPlotWidget for the AltVsTime tool.
+	*@short An extension of the KPlotWidget for the AltVsTime tool.
 	*The biggest difference is that in addition to the plot objects, it 
 	*draws the "ground" below Alt=0 and draws the sky light blue for day 
 	*times, and black for night times.  The transition between day and 
@@ -54,10 +54,12 @@
 	*sunrise/sunset times of the given date/location.
 	*Also, this plot widget provides two time axes (local time along the 
 	*bottom, and local sideral time along the top).
+	*Finally, it provides user interaction: on mouse click, it draws 
+	*crosshairs at the mouse position with labels for the time and altitude.
 	*@version 1.0
 	*@author Jason Harris
 	*/
-class AVTPlotWidget : public KStarsPlotWidget
+class AVTPlotWidget : public KPlotWidget
 {
 	Q_OBJECT
 public:
@@ -108,7 +110,6 @@
 	*@version 1.0
 	*@author Jason Harris
 	*/
-
 class AltVsTime : public KDialog
 {
 	Q_OBJECT
--- trunk/KDE/kdeedu/kstars/kstars/tools/jmoontool.cpp #581497:581498
@@ -31,6 +31,7 @@
 #include "simclock.h"
 #include "dms.h"
 #include "ksnumbers.h"
+#include "libkdeedu/kdeeduplot/kplotwidget.h"
 #include "libkdeedu/kdeeduplot/kplotobject.h"
 #include "libkdeedu/kdeeduplot/kplotaxis.h"
 
@@ -89,15 +90,15 @@
 	glay->addWidget( labGn, 0, 1 );
 	glay->addWidget( labCa, 1, 1 );
 
-	pw = new KStarsPlotWidget( 0.0, 1.0, 0.0, 1.0, page );
+	pw = new KPlotWidget( 0.0, 1.0, 0.0, 1.0, page );
 	pw->setShowGrid( false );
-	pw->setYAxisType0( KStarsPlotWidget::TIME );
-	pw->setLimits( -12.0, 12.0, -240.0, 240.0 );
+	pw->setAntialias( true );
+	pw->setLimits( -12.0, 12.0, -11.0, 11.0 );
 	pw->axis(KPlotWidget::BottomAxis)->setLabel( i18n( "offset from Jupiter (arcmin)" ) );
 	pw->axis(KPlotWidget::LeftAxis)->setLabel( i18n( "time since now (days)" ) );
 	vlay->addLayout( glay );
 	vlay->addWidget( pw );
-	resize( 250, 500 );
+	resize( 350, 600 );
 
 	initPlotObjects();
 	update();
@@ -125,9 +126,9 @@
 
 	double dy = 0.01*pw->dataHeight();
 
-	//t is the offset from jd0, in hours.
+	//t is the offset from jd0, in days.
 	for ( double t=pw->y(); t<=pw->y2(); t+=dy ) {
-		KSNumbers num( jd0 + t/24.0 );
+		KSNumbers num( jd0 + t );
 		jm.findPosition( &num, jup, ksun );
 
 		//jm.x(i) tells the offset from Jupiter, in units of Jupiter's angular radius.
@@ -165,7 +166,7 @@
 		case Qt::Key_Plus:
 		case Qt::Key_Equal:
 		{
-			if ( pw->dataHeight() > 48.0 ) {
+			if ( pw->dataHeight() > 2.0 ) {
 				double dy = 0.45*pw->dataHeight();
 				double y0 = pw->y() + 0.5*pw->dataHeight();
 				pw->setLimits( pw->x(), pw->x2(), y0-dy, y0+dy );
@@ -177,7 +178,7 @@
 		case Qt::Key_Minus:
 		case Qt::Key_Underscore:
 		{
-			if ( pw->dataHeight() < 960.0 ) {
+			if ( pw->dataHeight() < 40.0 ) {
 				double dy = 0.55*pw->dataHeight();
 				double y0 = pw->y() + 0.5*pw->dataHeight();
 				pw->setLimits( pw->x(), pw->x2(), y0-dy, y0+dy );
--- trunk/KDE/kdeedu/kstars/kstars/tools/jmoontool.h #581497:581498
@@ -18,10 +18,10 @@
 #define JMOONTOOL_H_
 
 #include <kdialog.h>
-#include "widgets/kstarsplotwidget.h"
 
 class KStars;
 class QColor;
+class KPlotWidget;
 
 /**@class JMoonTool
 	*@short Display the positions of Jupiter's moons as a function of time
@@ -40,7 +40,7 @@
 
 private:
 	void initPlotObjects();
-	KStarsPlotWidget *pw;
+	KPlotWidget *pw;
 	KStars *ksw;
 	QColor colJp, colIo, colEu, colGn, colCa;
 };
--- trunk/KDE/kdeedu/kstars/kstars/tools/planetviewer.cpp #581497:581498
@@ -68,14 +68,14 @@
 	resize( 500, 500 );
 	pw->map->QWidget::setFocus(); //give keyboard focus to the plot widget for key and mouse events
 
-	pName[0] = "Mercury"; pColor[0] = "SlateBlue1";
-	pName[1] = "Venus";   pColor[1] = "LightGreen";
-	pName[2] = "Earth";   pColor[2] = "Blue";
-	pName[3] = "Mars";    pColor[3] = "Red";
-	pName[4] = "Jupiter"; pColor[4] = "Goldenrod";
-	pName[5] = "Saturn";  pColor[5] = "LightYellow2";
-	pName[6] = "Uranus";  pColor[6] = "LightSeaGreen";
-	pName[7] = "Neptune"; pColor[7] = "SkyBlue";
+	pName[0] = "Mercury"; pColor[0] = "slateblue";
+	pName[1] = "Venus";   pColor[1] = "lightgreen";
+	pName[2] = "Earth";   pColor[2] = "deepskyblue";
+	pName[3] = "Mars";    pColor[3] = "orangered";
+	pName[4] = "Jupiter"; pColor[4] = "goldenrod";
+	pName[5] = "Saturn";  pColor[5] = "khaki";
+	pName[6] = "Uranus";  pColor[6] = "lightseagreen";
+	pName[7] = "Neptune"; pColor[7] = "dodgerblue";
 	pName[8] = "Pluto";   pColor[8] = "gray";
 
 	setCenterPlanet(QString());
@@ -207,9 +207,10 @@
 		if ( KSUtils::openDataFile( orbitFile, pName[i].toLower() + ".orbit" ) ) {
 			QTextStream orbitStream( &orbitFile );
 			double x, y, z;
+			orbitStream >> x >> y >> z;
 			while ( !orbitStream.atEnd() ) {
+				orbit[i]->addPoint( new QPointF( x, y ) );
 				orbitStream >> x >> y >> z;
-				orbit[i]->addPoint( new QPointF( x, y ) );
 			}
 		}
 
--- trunk/KDE/kdeedu/kstars/kstars/tools/pvplotwidget.cpp #581497:581498
@@ -23,16 +23,18 @@
 #include "libkdeedu/kdeeduplot/kplotobject.h"
 
 PVPlotWidget::PVPlotWidget( double x1, double x2, double y1, double y2, QWidget *par ) :
-			KStarsPlotWidget( x1, x2, y1, y2, par ), 
-			mouseButtonDown(false), oldx(0), oldy(0) {
+			KPlotWidget( x1, x2, y1, y2, par ), 
+			mouseButtonDown(false), oldx(0), oldy(0)
+{
 	setFocusPolicy( Qt::StrongFocus );
 	setMouseTracking (true);
 	pv = (PlanetViewer*)topLevelWidget();
 }
 
 PVPlotWidget::PVPlotWidget( QWidget *parent ) :
-			KStarsPlotWidget( 0.0, 1.0, 0.0, 1.0, parent ), 
-			mouseButtonDown(false), oldx(0), oldy(0) {
+			KPlotWidget( 0.0, 1.0, 0.0, 1.0, parent ), 
+			mouseButtonDown(false), oldx(0), oldy(0)
+{
 	setFocusPolicy( Qt::StrongFocus );
 	setMouseTracking (true);
 	pv = (PlanetViewer*)topLevelWidget();
--- trunk/KDE/kdeedu/kstars/kstars/tools/pvplotwidget.h #581497:581498
@@ -19,11 +19,11 @@
 
 #include <QFrame>
 
-#include "widgets/kstarsplotwidget.h"
+#include "libkdeedu/kdeeduplot/kplotwidget.h"
 
 class PlanetViewer;
 
-class PVPlotWidget : public KStarsPlotWidget
+class PVPlotWidget : public KPlotWidget
 {
 Q_OBJECT
 public:


More information about the Kstars-devel mailing list