예제 #1
0
void JMoonTool::keyPressEvent( QKeyEvent *e ) {
    QRectF dataRect = pw->dataRect();
    switch ( e->key() ) {
    case Qt::Key_BracketRight:
        {
            double dy = 0.02*dataRect.height();
            pw->setLimits( dataRect.x(), dataRect.right(), dataRect.y()+dy, dataRect.bottom()+dy );
            initPlotObjects();
            pw->update();
            break;
        }
    case Qt::Key_BracketLeft:
        {
            double dy = 0.02*dataRect.height();
            pw->setLimits( dataRect.x(), dataRect.right(), dataRect.y()-dy, dataRect.bottom()-dy );
            initPlotObjects();
            pw->update();
            break;
        }
    case Qt::Key_Plus:
    case Qt::Key_Equal:
        {
            if ( dataRect.height() > 2.0 ) {
                double dy = 0.45*dataRect.height();
                double y0 = dataRect.y() + 0.5*dataRect.height();
                pw->setLimits( dataRect.x(), dataRect.right(), y0-dy, y0+dy );
                initPlotObjects();
                pw->update();
            }
            break;
        }
    case Qt::Key_Minus:
    case Qt::Key_Underscore:
        {
            if ( dataRect.height() < 40.0 ) {
                double dy = 0.55*dataRect.height();
                double y0 = dataRect.y() + 0.5*dataRect.height();
                pw->setLimits( dataRect.x(), dataRect.right(), y0-dy, y0+dy );
                initPlotObjects();
                pw->update();
            }
            break;
        }
    case Qt::Key_Escape:
        {
            close();
            break;
        }

    default: { e->ignore(); break; }
    }
}
예제 #2
0
void JMoonTool::keyPressEvent( QKeyEvent *e ) {
	switch ( e->key() ) {
		case Key_BracketRight:
		{
			double dy = 0.02*pw->dataHeight();
			pw->setLimits( pw->x(), pw->x2(), pw->y()+dy, pw->y2()+dy );
			initPlotObjects();
			pw->update();
			break;
		}
		case Key_BracketLeft:
		{
			double dy = 0.02*pw->dataHeight();
			pw->setLimits( pw->x(), pw->x2(), pw->y()-dy, pw->y2()-dy );
			initPlotObjects();
			pw->update();
			break;
		}
		case Key_Plus:
		case Key_Equal:
		{
			if ( pw->dataHeight() > 48.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 );
				initPlotObjects();
				pw->update();
			}
			break;
		}
		case Key_Minus:
		case Key_Underscore:
		{
			if ( pw->dataHeight() < 960.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 );
				initPlotObjects();
				pw->update();
			}
			break;
		}
		case Key_Escape:
		{
			close();
			break;
		}
		
		default: { e->ignore(); break; }
	}
}
예제 #3
0
JMoonTool::JMoonTool(QWidget *parent, const char *name)
 : KDialogBase( KDialogBase::Plain, i18n("Jupiter Moons Tool"), Close, Close, parent, name )
{
	ksw = (KStars*)parent;
	
	QFrame *page = plainPage();
	QVBoxLayout *vlay = new QVBoxLayout( page, 0, 0 );
	
	colJp = "White";
	colIo = "Red";
	colEu = "Yellow";
	colGn = "Orange";
	colCa = "YellowGreen";
	
	QLabel *labIo = new QLabel( "Io", page );
	QLabel *labEu = new QLabel( "Europa", page );
	QLabel *labGn = new QLabel( "Ganymede", page );
	QLabel *labCa = new QLabel( "Callisto", page );
	
	labIo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
	labEu->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
	labGn->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
	labCa->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
	labIo->setAlignment( AlignHCenter );
	labEu->setAlignment( AlignHCenter );
	labGn->setAlignment( AlignHCenter );
	labCa->setAlignment( AlignHCenter );

	labIo->setPaletteForegroundColor( colIo );
	labEu->setPaletteForegroundColor( colEu );
	labGn->setPaletteForegroundColor( colGn );
	labCa->setPaletteForegroundColor( colCa );
	labIo->setPaletteBackgroundColor( "Black" );
	labEu->setPaletteBackgroundColor( "Black" );
	labGn->setPaletteBackgroundColor( "Black" );
	labCa->setPaletteBackgroundColor( "Black" );
	
	QGridLayout *glay = new QGridLayout( 2, 2, 0 );
	glay->addWidget( labIo, 0, 0 );
	glay->addWidget( labEu, 1, 0 );
	glay->addWidget( labGn, 0, 1 );
	glay->addWidget( labCa, 1, 1 );
	
	pw = new KStarsPlotWidget( 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->setXAxisLabel( i18n( "offset from Jupiter (arcmin)" ) );
	pw->setYAxisLabel( i18n( "time since now (days)" ) );
	vlay->addLayout( glay );
	vlay->addWidget( pw );
	resize( 250, 500 );

	initPlotObjects();
	update();
}
예제 #4
0
JMoonTool::JMoonTool(QWidget *parent)
        : KDialog( parent )
{
    ksw = (KStars*)parent;
    QFrame *page = new QFrame(this);
    setMainWidget( page );
    setCaption( i18n("Jupiter Moons Tool") );
    setButtons( KDialog::Close );
    setModal( false );

    QVBoxLayout *vlay = new QVBoxLayout( page );
    vlay->setMargin( 0 );
    vlay->setSpacing( 0 );

    colJp = QColor(Qt::white);
    colIo = QColor(Qt::red);
    colEu = QColor(Qt::yellow);
    colGn = QColor(Qt::cyan);
    colCa = QColor(Qt::green);

    QLabel *labIo = new QLabel( i18n("Io"), page );
    QLabel *labEu = new QLabel( i18n("Europa"), page );
    QLabel *labGn = new QLabel( i18n("Ganymede"), page );
    QLabel *labCa = new QLabel( i18n("Callisto"), page );

    labIo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labEu->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labGn->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labCa->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    labIo->setAlignment( Qt::AlignHCenter );
    labEu->setAlignment( Qt::AlignHCenter );
    labGn->setAlignment( Qt::AlignHCenter );
    labCa->setAlignment( Qt::AlignHCenter );

    QPalette p = palette();
    p.setColor( QPalette::Window, Qt::black );
    p.setColor( QPalette::WindowText, colIo );
    labIo->setPalette( p );
    p.setColor( QPalette::WindowText, colEu );
    labEu->setPalette( p );
    p.setColor( QPalette::WindowText, colGn );
    labGn->setPalette( p );
    p.setColor( QPalette::WindowText, colCa );
    labCa->setPalette( p );
    labIo->setAutoFillBackground( true );
    labEu->setAutoFillBackground( true );
    labGn->setAutoFillBackground( true );
    labCa->setAutoFillBackground( true );

    QGridLayout *glay = new QGridLayout();
    glay->addWidget( labIo, 0, 0 );
    glay->addWidget( labEu, 1, 0 );
    glay->addWidget( labGn, 0, 1 );
    glay->addWidget( labCa, 1, 1 );

    pw = new KPlotWidget( page );
    pw->setShowGrid( false );
    pw->setAntialiasing( 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( 350, 600 );

    initPlotObjects();
    update();
}
예제 #5
0
PlanetViewer::PlanetViewer(QWidget *parent, const char *name)
    : KDialogBase( KDialogBase::Plain, i18n("Solar System Viewer"), Close, Close, parent, name ), PCat( ((KStars*)parent)->data() ), scale(1.0), isClockRunning(false), tmr(this)
{
    QFrame *page = plainPage();
    QVBoxLayout *vlay = new QVBoxLayout( page, 0, spacingHint() );
    pw = new PlanetViewerUI( page );
    pw->map->setLimits( -48.0, 48.0, -48.0, 48.0 );
    pw->map->setXAxisLabel( i18n( "axis label for x-coordinate of solar system viewer.  AU means astronomical unit.", "X-position (AU)" ) );
    pw->map->setYAxisLabel( i18n( "axis label for y-coordinate of solar system viewer.  AU means astronomical unit.", "Y-position (AU)" ) );

    pw->timeStep->setDaysOnly( true );
    pw->timeStep->tsbox()->setValue( 1 ); //start with 1-day timestep

    pw->RunButton->setPixmap( KGlobal::iconLoader()->loadIcon( "1rightarrow", KIcon::Toolbar ) );
    pw->dateBox->setDate( ((KStars*)parent)->data()->lt().date() );

    vlay->addWidget( pw );
    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[8] = "Pluto";
    pColor[8] = "gray";

    setCenterPlanet("");

    PCat.initialize();
    ut = ((KStars*)parent)->data()->ut();
    KSNumbers num( ut.djd() );
    PCat.findPosition( &num, 0, 0 ); //NULL args: don't need geocent. coords.

    for ( uint i=0; i<9; ++i )
        LastUpdate[i] = int( ut.date().jd() );

    //The planets' update intervals are 0.25% of one period:
    UpdateInterval[0] = 0;
    UpdateInterval[1] = 0;
    UpdateInterval[2] = 0;
    UpdateInterval[3] = 1;
    UpdateInterval[4] = 5;
    UpdateInterval[5] = 13;
    UpdateInterval[6] = 38;
    UpdateInterval[7] = 75;
    UpdateInterval[8] = 113;

    QTimer::singleShot( 0, this, SLOT( initPlotObjects() ) );

    connect( &tmr, SIGNAL( timeout() ), SLOT( tick() ) );
    connect( pw->timeStep, SIGNAL( scaleChanged(float) ), SLOT( setTimeScale(float) ) );
    connect( pw->RunButton, SIGNAL( clicked() ), SLOT( slotRunClock() ) );
    connect( pw->dateBox, SIGNAL( valueChanged( const ExtDate & ) ), SLOT( slotChangeDate( const ExtDate & ) ) );
    connect( pw->TodayButton, SIGNAL( clicked() ), SLOT( slotToday() ) );
}