void modCalcDayLength::initGeo(void) { KStars *ks = (KStars*) parent()->parent()->parent(); // QSplitter->AstroCalc->KStars geoPlace = ks->geo(); longBox->show( geoPlace->lng() ); latBox->show( geoPlace->lat() ); }
void KSPopupMenu::createEmptyMenu( SkyPoint *nullObj ) { KStars* ks = KStars::Instance(); SkyObject o( SkyObject::TYPE_UNKNOWN, nullObj->ra(), nullObj->dec() ); o.setAlt( nullObj->alt() ); o.setAz( nullObj->az() ); initPopupMenu( &o, i18n( "Empty sky" ), QString(), QString(), false, false ); addAction( i18nc( "Sloan Digital Sky Survey", "Show SDSS Image" ), ks->map(), SLOT( slotSDSS() ) ); addAction( i18nc( "Digitized Sky Survey", "Show DSS Image" ), ks->map(), SLOT( slotDSS() ) ); }
void WIView::onDetailsButtonClicked() { ///Code taken from WUTDialog::slotDetails() KStars *kstars = KStars::Instance(); SkyObject* so = m_CurSoItem->getSkyObject(); DetailDialog *detail = new DetailDialog(so, kstars->data()->lt(), kstars->data()->geo(), kstars); detail->exec(); delete detail; }
void modCalcAzel::showLongLat(void) { KStars *ks = (KStars*) parent()->parent()->parent(); // QSplitter->AstroCalc->KStars longBox->show( ks->geo()->lng() ); latBox->show( ks->geo()->lat() ); longBoxBatch->show( ks->geo()->lng() ); latBoxBatch->show( ks->geo()->lat() ); }
MapCanvas::MapCanvas(QWidget *parent, const char *name ) : QWidget(parent,name) { BGColor = "#33A"; setBackgroundColor( QColor( BGColor ) ); setBackgroundMode( QWidget::NoBackground ); Canvas = new QPixmap(); bgImage = new QPixmap(); LocationDialog *ld = (LocationDialog *)topLevelWidget(); KStars *ks = (KStars *)ld->parent(); QString bgFile = ks->data()->stdDirs->findResource( "data", "kstars/geomap.png" ); bgImage->load( bgFile, "PNG" ); }
void modCalcAzel::showCurrentDateTime (void) { KStars *ks = (KStars*) parent()->parent()->parent(); KStarsDateTime dt = ks->data()->geo()->LTtoUT( KStarsDateTime::currentDateTime() ); datBox->setDate( dt.date() ); timBox->setTime( dt.time() ); dateBoxBatch->setDate( dt.date() ); utBoxBatch->setTime( dt.time() ); }
void WIView::onSlewButtonClicked() { ///Slew map to selected sky-object SkyObject* so = m_CurSoItem->getSkyObject(); KStars* kstars = KStars::Instance(); if (so != 0) { kstars->map()->setFocusPoint(so); kstars->map()->setFocusObject(so); kstars->map()->setDestination(*kstars->map()->focusPoint()); } }
void ConjunctionsTool::slotGoto() { int index = m_SortModel->mapToSource( OutputList->currentIndex() ).row(); // Get the number of the line long double jd = outputJDList.value( index ); KStarsDateTime dt; KStars *ks = KStars::Instance(); KStarsData *data = KStarsData::Instance(); SkyMap *map = ks->map(); // Show conjunction data->setLocation( *geoPlace ); dt.setDJD( jd ); data->changeDateTime( dt ); map->setClickedObject( data->skyComposite()->findByName( m_Model->data( m_Model->index( index, 2 ) ).toString() ) ); map->setClickedPoint( map->clickedObject() ); map->slotCenter(); }
void FindDialog::filter() { //Filter the list of names with the string in the SearchBox KStars *p = (KStars *)parent(); SearchList->clear(); ObjectNameList &ObjNames = p->data()->ObjNames; // check if latin names are used ObjNames.setLanguage( Options::useLatinConstellNames() ); QString searchFor = SearchBox->text().lower(); for ( SkyObjectName *name = ObjNames.first( searchFor ); name; name = ObjNames.next() ) { if ( name->text().lower().startsWith( searchFor ) ) { new SkyObjectNameListItem ( SearchList, name ); /* if ( i++ >= 5000 ) { //Every 5000 name insertions, kapp->processEvents ( 50 ); //spend 50 msec processing KApplication events i = 0; }*/ } } setListItemEnabled(); // Automatically highlight first item SearchBox->setFocus(); // set cursor to QLineEdit }
void KSPopupMenu::createStarMenu( StarObject *star ) { KStars* ks = KStars::Instance(); //Add name, rise/set time, center/track, and detail-window items QString name; if( star->name() != "star" ) { name = star->translatedLongName(); } else { if( star->getHDIndex() ) { name = QString( "HD%1" ).arg( QString::number( star->getHDIndex() ) ); } else { // FIXME: this should be some catalog name too name = "Star"; } } initPopupMenu( star, name, i18n( "star" ), i18n("%1<sup>m</sup>, %2", star->mag(), star->sptype()) ); //If the star is named, add custom items to popup menu based on object's ImageList and InfoList if ( star->name() != "star" ) { addLinksToMenu( star ); } else { addAction( i18nc( "Sloan Digital Sky Survey", "Show SDSS Image" ), ks->map(), SLOT( slotSDSS() ) ); addAction( i18nc( "Digitized Sky Survey", "Show DSS Image" ), ks->map(), SLOT( slotDSS() ) ); } }
void KSPopupMenu::createSatelliteMenu( Satellite *satellite ) { KStars* ks = KStars::Instance(); QString velocity, altitude, range; velocity.setNum( satellite->velocity() ); altitude.setNum( satellite->altitude() ); range.setNum( satellite->range() ); clear(); addFancyLabel( satellite->name() ); addFancyLabel( satellite->id() ); addFancyLabel( i18n( "satellite" ) ); addFancyLabel( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( satellite ) ); addSeparator(); addFancyLabel( i18n( "Velocity: %1 km/s", velocity ), -2 ); addFancyLabel( i18n( "Altitude: %1 km", altitude ), -2 ); addFancyLabel( i18n( "Range: %1 km", range ), -2 ); addSeparator(); //Insert item for centering on object addAction( i18n( "Center && Track" ), ks->map(), SLOT( slotCenter() ) ); //Insert item for measuring distances //FIXME: add key shortcut to menu items properly! addAction( i18n( "Angular Distance To... [" ), ks->map(), SLOT(slotBeginAngularDistance()) ); addAction( i18n( "Starhop from here to... " ), ks->map(), SLOT(slotBeginStarHop()) ); //Insert "Add/Remove Label" item if ( ks->map()->isObjectLabeled( satellite ) ) addAction( i18n( "Remove Label" ), ks->map(), SLOT( slotRemoveObjectLabel() ) ); else addAction( i18n( "Attach Label" ), ks->map(), SLOT( slotAddObjectLabel() ) ); }
void WIView::onSettingsIconClicked() { KStars *kstars = KStars::Instance(); kstars->showWISettingsUI(); }
void MapCanvas::paintEvent( QPaintEvent * ) { QPainter pcanvas; LocationDialog *ld = (LocationDialog *)topLevelWidget(); KStars *ks = (KStars *)ld->parent(); //prepare the canvas pcanvas.begin( Canvas ); // pcanvas.fillRect( 0, 0, width(), height(), QBrush( QColor( BGColor ) ) ); pcanvas.drawPixmap( 0, 0, *bgImage ); // pcanvas.setBrush( white ); pcanvas.setPen( QPen( QColor( "SlateGrey" ) ) ); //Draw cities QPoint o; for ( GeoLocation *g=ks->data()->geoList.first(); g; g = ks->data()->geoList.next() ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) { pcanvas.drawPoint( o.x(), o.y() ); } } //redraw the cities that appear in the filtered list, with a white pen //If the list has not been filtered, skip the redraw. if ( ld->filteredList()->count() ) { pcanvas.setPen( white ); for ( GeoLocation *g=ld->filteredList()->first(); g; g = ld->filteredList()->next() ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) { pcanvas.drawPoint( o.x(), o.y() ); } } } GeoLocation *g = ld->selectedCity(); if ( g ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); pcanvas.setPen( red ); pcanvas.setBrush( red ); pcanvas.drawEllipse( o.x()-3, o.y()-3, 6, 6 ); pcanvas.moveTo( o.x()-16, o.y() ); pcanvas.lineTo( o.x()-8, o.y() ); pcanvas.moveTo( o.x()+8, o.y() ); pcanvas.lineTo( o.x()+16, o.y() ); pcanvas.moveTo( o.x(), o.y()-16 ); pcanvas.lineTo( o.x(), o.y()-8 ); pcanvas.moveTo( o.x(), o.y()+8 ); pcanvas.lineTo( o.x(), o.y()+16 ); pcanvas.setPen( white ); pcanvas.setBrush( white ); } pcanvas.end(); bitBlt( this, 0, 0, Canvas ); }
void PlanetViewer::slotToday() { KStars *ks = (KStars*)parent(); pw->dateBox->setDate( ks->data()->lt().date() ); }
void SkyMap::keyPressEvent( QKeyEvent *e ) { KStars* kstars = KStars::Instance(); 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 = QKeySequence(); return; } if(m_previewLegend) { slotCancelLegendPreviewMode(); } 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; 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; 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; 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; break; case Qt::Key_Plus: //Zoom in case Qt::Key_Equal: zoomInOrMagStep( e->modifiers() ); break; case Qt::Key_Minus: //Zoom out case Qt::Key_Underscore: zoomOutOrMagStep( e->modifiers() ); break; case Qt::Key_0: //center on Sun setClickedObject( data->skyComposite()->planet( KSPlanetBase::SUN ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_1: //center on Mercury setClickedObject( data->skyComposite()->planet( KSPlanetBase::MERCURY ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_2: //center on Venus setClickedObject( data->skyComposite()->planet( KSPlanetBase::VENUS ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_3: //center on Moon setClickedObject( data->skyComposite()->planet( KSPlanetBase::MOON ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_4: //center on Mars setClickedObject( data->skyComposite()->planet( KSPlanetBase:: MARS) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_5: //center on Jupiter setClickedObject( data->skyComposite()->planet( KSPlanetBase::JUPITER ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_6: //center on Saturn setClickedObject( data->skyComposite()->planet( KSPlanetBase::SATURN ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_7: //center on Uranus setClickedObject( data->skyComposite()->planet( KSPlanetBase::URANUS ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_8: //center on Neptune setClickedObject( data->skyComposite()->planet( KSPlanetBase::NEPTUNE ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_9: //center on Pluto setClickedObject( data->skyComposite()->planet( KSPlanetBase::PLUTO ) ); setClickedPoint( clickedObject() ); slotCenter(); break; case Qt::Key_BracketLeft: // Begin measuring angular distance if( !rulerMode ) slotBeginAngularDistance(); break; case Qt::Key_Escape: // Cancel angular distance measurement { if( rulerMode ) slotCancelRulerMode(); if( m_fovCaptureMode ) slotFinishFovCaptureMode(); break; } case Qt::Key_C: //Center clicked object if ( clickedObject() ) slotCenter(); break; case Qt::Key_D: //Details window for Clicked/Centered object { SkyObject *orig = 0; if ( shiftPressed ) { orig = clickedObject(); setClickedObject( focusObject() ); } if ( clickedObject() ) { slotDetail(); } if ( orig ) { setClickedObject( orig ); } break; } case Qt::Key_P: //Show Popup menu for Clicked/Centered object if ( shiftPressed ) { if ( focusObject() ) focusObject()->showPopupMenu( pmenu, QCursor::pos() ); } else { if ( clickedObject() ) clickedObject()->showPopupMenu( pmenu, QCursor::pos() ); } break; case Qt::Key_O: //Add object to Observing List { SkyObject *orig = 0; if ( shiftPressed ) { orig = clickedObject(); setClickedObject( focusObject() ); } if ( clickedObject() ) { kstars->observingList()->slotAddObject(); } if ( orig ) { setClickedObject( orig ); } break; } case Qt::Key_L: //Toggle User label on Clicked/Centered object { SkyObject *orig = 0; if ( shiftPressed ) { orig = clickedObject(); setClickedObject( focusObject() ); } if ( clickedObject() ) { if ( isObjectLabeled( clickedObject() ) ) slotRemoveObjectLabel(); else slotAddObjectLabel(); } if ( orig ) { setClickedObject( orig ); } break; } case Qt::Key_T: //Toggle planet trail on Clicked/Centered object (if solsys) { SkyObject *orig = 0; if ( shiftPressed ) { orig = clickedObject(); setClickedObject( focusObject() ); } KSPlanetBase* planet = dynamic_cast<KSPlanetBase*>( clickedObject() ); if( planet ) { if( planet->hasTrail() ) slotRemovePlanetTrail(); else slotAddPlanetTrail(); } if ( orig ) { setClickedObject( orig ); } break; } case Qt::Key_R: { // Toggle relativistic corrections Options::setUseRelativistic( ! Options::useRelativistic() ); kDebug() << "Relativistc corrections: " << Options::useRelativistic(); forceUpdate(); break; } case Qt::Key_A: Options::setUseAntialias( ! Options::useAntialias() ); kDebug() << "Use Antialiasing: " << Options::useAntialias(); forceUpdate(); break; case Qt::Key_K: { if(m_fovCaptureMode) slotCaptureFov(); break; } case Qt::Key_PageUp: { KStars::Instance()->selectPreviousFov(); break; } case Qt::Key_PageDown: { KStars::Instance()->selectNextFov(); break; } default: // We don't want to do anything in this case. Key is unknown return; } if ( arrowKeyPressed ) { stopTracking(); setDestination( *focus() ); } forceUpdate(); //need a total update, or slewing with the arrow keys doesn't work. }
void SkyMap::mousePressEvent( QMouseEvent *e ) { KStars* kstars = KStars::Instance(); if ( ( e->modifiers() & Qt::ControlModifier ) && (e->button() == Qt::LeftButton) ) { ZoomRect.moveCenter( e->pos() ); setZoomMouseCursor(); update(); //refresh without redrawing skymap return; } // if button is down and cursor is not moved set the move cursor after 500 ms QTimer::singleShot(500, this, SLOT (setMouseMoveCursor())); // break if point is unusable if ( projector()->unusablePoint( e->pos() ) ) return; if ( !midMouseButtonDown && e->button() == Qt::MidButton ) { y0 = 0.5*height() - e->y(); //record y pixel coordinate for middle-button zooming midMouseButtonDown = true; } if ( !mouseButtonDown ) { if ( e->button() == Qt::LeftButton ) { mouseButtonDown = true; } //determine RA, Dec of mouse pointer m_MousePoint = projector()->fromScreen( e->pos(), data->lst(), data->geo()->lat() ); setClickedPoint( &m_MousePoint ); //Find object nearest to clickedPoint() double maxrad = 1000.0/Options::zoomFactor(); SkyObject* obj = data->skyComposite()->objectNearest( clickedPoint(), maxrad ); setClickedObject( obj ); if( obj ) setClickedPoint( obj ); switch( e->button() ) { case Qt::LeftButton: if( kstars ) { QString name; if( clickedObject() ) name = clickedObject()->translatedLongName(); else name = i18n( "Empty sky" ); kstars->statusBar()->changeItem(name, 0 ); } break; case Qt::RightButton: if( rulerMode ) { // Compute angular distance. slotEndRulerMode(); } else { // Show popup menu if( clickedObject() ) { clickedObject()->showPopupMenu( pmenu, QCursor::pos() ); } else { pmenu->createEmptyMenu( clickedPoint() ); pmenu->popup( QCursor::pos() ); } } break; default: ; } } }
void SkyMap::stopTracking() { KStars* kstars = KStars::Instance(); emit positionChanged( focus() ); if( kstars && Options::isTracking() ) kstars->slotTrack(); }
void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QString info, bool showDetails, bool showObsList, bool showFlags ) { KStars* ks = KStars::Instance(); clear(); bool showLabel = name != i18n("star") && !name.isEmpty(); if( name.isEmpty() ) name = i18n( "Empty sky" ); addFancyLabel( name ); addFancyLabel( type ); addFancyLabel( info ); addFancyLabel( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( obj ) ); //Insert Rise/Set/Transit labels SkyObject* o = obj->clone(); addSeparator(); addFancyLabel( riseSetTimeLabel(o, true), -2 ); addFancyLabel( riseSetTimeLabel(o, false), -2 ); addFancyLabel( transitTimeLabel(o), -2 ); addSeparator(); delete o; // Show 'Select this object' item when in object pointing mode and when obj is not empty sky if(KStars::Instance()->map()->isInObjectPointingMode() && obj->type() != 21) { addAction( i18n( "Select this object"), KStars::Instance()->map(), SLOT(slotObjectSelected())); } //Insert item for centering on object addAction( i18n( "Center && Track" ), ks->map(), SLOT( slotCenter() ) ); if ( showFlags ) { //Insert actions for flag operations initFlagActions( obj ); } //Insert item for measuring distances //FIXME: add key shortcut to menu items properly! addAction( i18n( "Angular Distance To... [" ), ks->map(), SLOT(slotBeginAngularDistance()) ); addAction( i18n( "Starhop from here to... " ), ks->map(), SLOT(slotBeginStarHop()) ); //Insert item for Showing details dialog if ( showDetails ) addAction( i18nc( "Show Detailed Information Dialog", "Details" ), ks->map(), SLOT( slotDetail() ) ); //Insert "Add/Remove Label" item if ( showLabel ) { if ( ks->map()->isObjectLabeled( obj ) ) { addAction( i18n( "Remove Label" ), ks->map(), SLOT( slotRemoveObjectLabel() ) ); } else { addAction( i18n( "Attach Label" ), ks->map(), SLOT( slotAddObjectLabel() ) ); } } // Should show observing list if( showObsList ) { if ( ks->observingList()->contains( obj ) ) addAction( i18n("Remove From Observing WishList"), ks->observingList(), SLOT( slotRemoveObject() ) ); else addAction( i18n("Add to Observing WishList"), ks->observingList(), SLOT( slotAddObject() ) ); } // Should we show trail actions TrailObject* t = dynamic_cast<TrailObject*>( obj ); if( t ) { if( t->hasTrail() ) addAction( i18n( "Remove Trail" ), ks->map(), SLOT( slotRemovePlanetTrail() ) ); else addAction( i18n( "Add Trail" ), ks->map(), SLOT( slotAddPlanetTrail() ) ); } addSeparator(); #ifdef HAVE_XPLANET if ( obj->isSolarSystem() && obj->type() != SkyObject::COMET ) { // FIXME: We now have asteroids -- so should this not be isMajorPlanet() || Pluto? QMenu *xplanetSubmenu = new QMenu(); xplanetSubmenu->setTitle( i18n( "Print Xplanet view" ) ); xplanetSubmenu->addAction( i18n( "To screen" ), ks->map(), SLOT( slotXplanetToScreen() ) ); xplanetSubmenu->addAction( i18n( "To file..." ), ks->map(), SLOT( slotXplanetToFile() ) ); addMenu( xplanetSubmenu ); } #endif addSeparator(); addINDI(); }
void modCalcAzel::initGeo(void) { KStars *ks = (KStars*) parent()->parent()->parent(); // QSplitter->AstroCalc->KStars geoPlace = new GeoLocation( ks->geo() ); }