Logo Search packages:      
Sourcecode: kdeedu-kde4 version File versions  Download package

void SkyMap::keyPressEvent ( QKeyEvent *  e  )  [protected, virtual]

Process keystrokes:

  • arrow keys Slew the map
  • +/- keys Zoom in and out
  • N/E/S/W keys Go to the cardinal points on the Horizon
  • Z Go to the Zenith
  • Space Toggle between Horizontal and Equatorial coordinate systems
  • 0-9 Go to a major Solar System body (0=Sun; 1-9 are the major planets, except 3=Moon)
  • [ Place starting point for measuring an angular distance
  • ] End point for Angular Distance; display measurement.
  • Escape Cancel Angular measurement
  • ,/< Step backward one time step
  • ./> Step forward one time step

case Qt::Key_V: kDebug() << "Create a skyline: "; SkyLine sl( SkyPoint( 12.34, 33.50 ), SkyPoint( 14.00, 40.00 ) ); kDebug() << " " << sl.points().size() << " :: " << sl.point(0)->ra()->toHMSString() << " : " << sl.point(1)->ra()->toHMSString() << endl;

SkyPoint p( 11.75, 30.25 ); sl.setPoint( 1, &p ); kDebug() << " " << sl.points().size() << " :: " << sl.point(0)->ra()->toHMSString() << " : " << sl.point(1)->ra()->toHMSString() << endl; break;

Definition at line 65 of file skymapevents.cpp.

References clickedObject(), KStarsData::clock(), SkyLabeler::decDensity(), SkyPoint::EquatorialToHorizontal(), SkyMapComposite::findByName(), focus(), InfoBoxes::focusObjChanged(), focusObject(), forceUpdate(), KStarsData::geo(), SkyPoint::HorizontalToEquatorial(), KStarsData::HourAngle, dms::Hours(), SkyLabeler::incDensity(), infoBoxes(), SimClock::isActive(), isAngleMode(), isObjectLabeled(), GeoLocation::lat(), KStarsData::LST, SimClock::manualTick(), KStars::observingList(), oldfocus(), SkyLabeler::printInfo(), SkyPoint::ra(), refract(), KStarsData::resumeKey, SimClock::scale(), SkyPoint::setAlt(), SkyPoint::setAz(), setClickedObject(), setClickedPoint(), SkyPoint::setDec(), setDestination(), setDestinationAltAz(), dms::setH(), setOldFocus(), SkyPoint::setRA(), SimClock::setScale(), SkyObject::showPopupMenu(), KStarsData::skyComposite(), ObservingList::slotAddObject(), slotAddObjectLabel(), slotAddPlanetTrail(), slotBeginAngularDistance(), slotCancelAngularDistance(), slotCenter(), slotDetail(), slotEndAngularDistance(), slotRemoveObjectLabel(), slotRemovePlanetTrail(), KStars::slotZoomIn(), KStars::slotZoomOut(), SkyMapComposite::stars(), SimClock::stop(), stopTracking(), dms::toDMSString(), and toScreen().

Referenced by invokeKey().

                                         {
    QString s;
    bool arrowKeyPressed( false );
    bool shiftPressed( false );
    float step = 1.0;
    if ( e->modifiers() & Qt::ShiftModifier ) { step = 10.0; shiftPressed = true; }

    //If the DBus resume key is not empty, then DBus processing is
    //paused while we wait for a keypress
    if ( ! data->resumeKey.isEmpty() && QKeySequence(e->key()) == data->resumeKey ) {
        //The resumeKey was pressed.  Signal that it was pressed by
        //resetting it to empty; this will break the loop in
        //KStars::waitForKey()
        data->resumeKey = QString();
        return;
    }

    switch ( e->key() ) {
    case Qt::Key_Left :
        if ( Options::useAltAz() ) {
            focus()->setAz( dms( focus()->az()->Degrees() - step * MINZOOM/Options::zoomFactor() ).reduce() );
            focus()->HorizontalToEquatorial( data->LST, data->geo()->lat() );
        } else {
            focus()->setRA( focus()->ra()->Hours() + 0.05*step * MINZOOM/Options::zoomFactor() );
            focus()->EquatorialToHorizontal( data->LST, data->geo()->lat() );
        }

        arrowKeyPressed = true;
        slewing = true;
        ++scrollCount;
        break;

    case Qt::Key_Right :
        if ( Options::useAltAz() ) {
            focus()->setAz( dms( focus()->az()->Degrees() + step * MINZOOM/Options::zoomFactor() ).reduce() );
            focus()->HorizontalToEquatorial( data->LST, data->geo()->lat() );
        } else {
            focus()->setRA( focus()->ra()->Hours() - 0.05*step * MINZOOM/Options::zoomFactor() );
            focus()->EquatorialToHorizontal( data->LST, data->geo()->lat() );
        }

        arrowKeyPressed = true;
        slewing = true;
        ++scrollCount;
        break;

    case Qt::Key_Up :
        if ( Options::useAltAz() ) {
            focus()->setAlt( focus()->alt()->Degrees() + step * MINZOOM/Options::zoomFactor() );
            if ( focus()->alt()->Degrees() > 90.0 ) focus()->setAlt( 90.0 );
            focus()->HorizontalToEquatorial( data->LST, data->geo()->lat() );
        } else {
            focus()->setDec( focus()->dec()->Degrees() + step * MINZOOM/Options::zoomFactor() );
            if (focus()->dec()->Degrees() > 90.0) focus()->setDec( 90.0 );
            focus()->EquatorialToHorizontal( data->LST, data->geo()->lat() );
        }

        arrowKeyPressed = true;
        slewing = true;
        ++scrollCount;
        break;

    case Qt::Key_Down:
        if ( Options::useAltAz() ) {
            focus()->setAlt( focus()->alt()->Degrees() - step * MINZOOM/Options::zoomFactor() );
            if ( focus()->alt()->Degrees() < -90.0 ) focus()->setAlt( -90.0 );
            focus()->HorizontalToEquatorial(data->LST, data->geo()->lat() );
        } else {
            focus()->setDec( focus()->dec()->Degrees() - step * MINZOOM/Options::zoomFactor() );
            if (focus()->dec()->Degrees() < -90.0) focus()->setDec( -90.0 );
            focus()->EquatorialToHorizontal( data->LST, data->geo()->lat() );
        }

        arrowKeyPressed = true;
        slewing = true;
        ++scrollCount;
        break;

    case Qt::Key_Plus:   //Zoom in
    case Qt::Key_Equal:
        if ( ks ) ks->slotZoomIn();
        slewing = true;
        break;

    case Qt::Key_Minus:  //Zoom out
    case Qt::Key_Underscore:
        if ( ks ) ks->slotZoomOut();
        slewing = true;
        break;

    //In the following cases, we set slewing=true in order to disengage tracking
    case Qt::Key_N: //center on north horizon
        stopTracking();
        setDestinationAltAz( 15.0, 0.0001 );
        break;

    case Qt::Key_E: //center on east horizon
        stopTracking();
        setDestinationAltAz( 15.0, 90.0 );
        break;

    case Qt::Key_S: //center on south horizon
        stopTracking();
        setDestinationAltAz( 15.0, 180.0 );
        break;

    case Qt::Key_W: //center on west horizon
        stopTracking();
        setDestinationAltAz( 15.0, 270.0 );
        break;

    case Qt::Key_Z: //center on Zenith
        stopTracking();
        setDestinationAltAz( 90.0, focus()->az()->Degrees() );
        break;

    case Qt::Key_0: //center on Sun
        setClickedObject( data->skyComposite()->findByName("Sun") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_1: //center on Mercury
        setClickedObject( data->skyComposite()->findByName("Mercury") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_2: //center on Venus
        setClickedObject( data->skyComposite()->findByName("Venus") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_3: //center on Moon
        setClickedObject( data->skyComposite()->findByName("Moon") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_4: //center on Mars
        setClickedObject( data->skyComposite()->findByName("Mars") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_5: //center on Jupiter
        setClickedObject( data->skyComposite()->findByName("Jupiter") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_6: //center on Saturn
        setClickedObject( data->skyComposite()->findByName("Saturn") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_7: //center on Uranus
        setClickedObject( data->skyComposite()->findByName("Uranus") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_8: //center on Neptune
        setClickedObject( data->skyComposite()->findByName("Neptune") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_9: //center on Pluto
        setClickedObject( data->skyComposite()->findByName("Pluto") );
        setClickedPoint( clickedObject() );
        slotCenter();
        break;

    case Qt::Key_BracketLeft:   // Begin measuring angular distance
        if ( !isAngleMode() ) {
            slotBeginAngularDistance();
        }

        break;

    case Qt::Key_BracketRight:  // End measuring angular distance
        if ( isAngleMode() ) {
            slotEndAngularDistance();
        }

        break;

    case Qt::Key_Escape:        // Cancel angular distance measurement
        if  (isAngleMode() ) {
            slotCancelAngularDistance();
        }
        break;

    case Qt::Key_Comma:  //advance one step backward in time
    case Qt::Key_Less:
        if ( data->clock()->isActive() ) data->clock()->stop();
        data->clock()->setScale( -1.0 * data->clock()->scale() ); //temporarily need negative time step
        data->clock()->manualTick( true );
        data->clock()->setScale( -1.0 * data->clock()->scale() ); //reset original sign of time step
        update();
        qApp->processEvents();
        break;

    case Qt::Key_Period: //advance one step forward in time
    case Qt::Key_Greater:
        if ( data->clock()->isActive() ) data->clock()->stop();
        data->clock()->manualTick( true );
        update();
        qApp->processEvents();
        break;

    case Qt::Key_C: //Center clicked object
        if ( clickedObject() ) slotCenter();
        break;

    case Qt::Key_D: //Details window for Clicked/Centered object
        if ( shiftPressed ) setClickedObject( focusObject() );
        if ( clickedObject() ) slotDetail();
        break;

    case Qt::Key_P: //Show Popup menu for Clicked/Centered object
        if ( shiftPressed ) setClickedObject( focusObject() );
        if ( clickedObject() )
            clickedObject()->showPopupMenu( pmenu, QCursor::pos() );
        break;

    case Qt::Key_O: //Add object to Observing List
        if ( shiftPressed ) setClickedObject( focusObject() );
        if ( clickedObject() )
            ks->observingList()->slotAddObject();
        break;

    case Qt::Key_L: //Toggle User label on Clicked/Centered object
        if ( shiftPressed ) setClickedObject( focusObject() );
        if ( clickedObject() ) {
            if ( isObjectLabeled( clickedObject() ) )
                slotRemoveObjectLabel();
            else
                slotAddObjectLabel();
        }
        break;

    case Qt::Key_T: //Toggle planet trail on Clicked/Centered object (if solsys)
        if ( shiftPressed ) setClickedObject( focusObject() );
        if ( clickedObject() && clickedObject()->isSolarSystem() ) {
            if ( ((KSPlanetBase*)clickedObject())->hasTrail() )
                slotRemovePlanetTrail();
            else
                slotAddPlanetTrail();
        }
        break;

    //DEBUG_REFRACT
    case Qt::Key_Q:
        {
            for ( double alt=-0.5; alt<30.5; alt+=1.0 ) {
                dms a( alt );
                dms b( refract( &a, true ) ); //find apparent alt from true alt
                dms c( refract( &b, false ) );

                kDebug() << a.toDMSString() << b.toDMSString() << c.toDMSString();
            }
            break;
        }

        //TIMING
        // *** Uncomment and insert timing test code here ***
    case Qt::Key_X:
        {
            QTime t;
            t.start();
            foreach ( SkyObject *star, data->skyComposite()->stars() )
            toScreen( star );
            kDebug() << QString("toScreen() for all stars took %1 ms").arg(t.elapsed());
            t.start();
            foreach ( SkyObject *star, data->skyComposite()->stars() )
            toScreenQuaternion( star );
            kDebug() << QString("toScreenQuaternion() for all stars took %1 ms").arg(t.elapsed());
            break;
        }
        //END_TIMING

    case Qt::Key_A:
        Options::setUseAntialias( ! Options::useAntialias() );
        kDebug() << "Use Antialiasing: " << Options::useAntialias();
        forceUpdate();
        break;

        //Test code: create a SkyLine
        /**
        case Qt::Key_V:
        kDebug() << "Create a skyline: ";
        SkyLine sl( SkyPoint( 12.34, 33.50 ), SkyPoint( 14.00, 40.00 ) );
        kDebug() << "  " << sl.points().size() << " :: "
        << sl.point(0)->ra()->toHMSString() << " : " 
        << sl.point(1)->ra()->toHMSString() << endl;

        SkyPoint p( 11.75, 30.25 );
        sl.setPoint( 1, &p );
        kDebug() << "  " << sl.points().size() << " :: "
        << sl.point(0)->ra()->toHMSString() << " : " 
        << sl.point(1)->ra()->toHMSString() << endl;
            break;
        **/
    case Qt::Key_B:  // print labeler info
        SkyLabeler::Instance()->printInfo();
        break;
    case Qt::Key_F:  // print labeler info
        SkyLabeler::Instance()->decDensity();
        break;
    case Qt::Key_G:  // print labeler info
        SkyLabeler::Instance()->incDensity();
        break;



    }

    setOldFocus( focus() );
    oldfocus()->setAz( focus()->az()->Degrees() );
    oldfocus()->setAlt( focus()->alt()->Degrees() );

    double dHA = data->LST->Hours() - focus()->ra()->Hours();
    while ( dHA < 0.0 ) dHA += 24.0;
    data->HourAngle->setH( dHA );

    if ( arrowKeyPressed ) {
        infoBoxes()->focusObjChanged( i18n( "nothing" ) );
        stopTracking();

        if ( scrollCount > 10 ) {
            setDestination( focus() );
            scrollCount = 0;
        }
    }

    forceUpdate(); //need a total update, or slewing with the arrow keys doesn't work.
}


Generated by  Doxygen 1.6.0   Back to index