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

Jason Harris kstars at 30doradus.org
Sun Jul 13 01:24:58 CEST 2008


On 7/12/08, Akarsh Simha <akarshsimha at gmail.com> wrote:
> SVN commit 831466 by asimha:
>
> Double clicking on a list item in the conjunction tool will take you
> right to the conjunction. (geographical location, time, and object)

Great!

> CCMAIL: kstars-devel at kde.org
>
>
>
>  M  +35 -9     conjunctions.cpp
>  M  +3 -0      conjunctions.h
>
>
> --- trunk/KDE/kdeedu/kstars/kstars/tools/conjunctions.cpp #831465:831466
> @@ -44,8 +44,10 @@
>  #include "finddialog.h"
>  #include "kscomet.h"
>  #include "ksasteroid.h"
> +#include "skymap.h"
> +#include "infoboxes.h"
>
> -ConjunctionsTool::ConjunctionsTool(QWidget *parentSplit)
> +ConjunctionsTool::ConjunctionsTool(QWidget *parentSplit)
>      : QFrame(parentSplit), Object1( 0 ), Object2( 0 ) {
>
>    setupUi(this);
> @@ -62,13 +64,13 @@
>    KStarsData *kd = KStarsData::Instance();
>    KStarsDateTime dtStart ( KStarsDateTime::currentDateTime() );
>    KStarsDateTime dtStop ( dtStart.djd() + 365.24 ); // TODO: Refine
> -
> +
>    startDate -> setDateTime( dtStart.dateTime() );
>    stopDate -> setDateTime( dtStop.dateTime() );
> -
> +
>    geoPlace = kd -> geo();
>    LocationButton -> setText( geoPlace -> fullName() );
> -
> +
>    pNames[KSPlanetBase::MERCURY] = i18n("Mercury");
>    pNames[KSPlanetBase::VENUS] = i18n("Venus");
>    pNames[KSPlanetBase::MARS] = i18n("Mars");
> @@ -89,6 +91,8 @@
>    connect(LocationButton, SIGNAL(clicked()), this, SLOT(slotLocation()));
>    connect(Obj1FindButton, SIGNAL(clicked()), this, SLOT(slotFindObject()));
>    connect(ComputeButton, SIGNAL(clicked()), this, SLOT(slotCompute()));
> +  connect( OutputView, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ),
> this, SLOT( slotGoto() ) );
> +
>    show();
>  }
>
> @@ -99,6 +103,23 @@
>          delete Object2;
>  }
>
> +void ConjunctionsTool::slotGoto() {
> +    int index = OutputView->currentRow();
> +    long double jd = outputJDList.value( index );
> +    KStarsDateTime dt;
> +    KStars *ks= (KStars *) topLevelWidget()->parent();
> +    KStarsData *data = KStarsData::Instance();
> +    SkyMap *map = ks->map();
> +
> +    data->setLocation( *geoPlace );
> +    ks->infoBoxes()->geoChanged( geoPlace );
> +    dt.setDJD( jd );
> +    data->changeDateTime( dt );
> +    map->setClickedObject( data->skyComposite()->findByName(
> Object1->name() ) ); // This is required, because the Object1 we have is a
> copy
> +    map->setClickedPoint( map->clickedObject() );
> +    map->slotCenter();
> +}
> +
>  void ConjunctionsTool::slotFindObject() {
>      FindDialog fd( (KStars*) topLevelWidget()->parent() );
>      if ( fd.exec() == QDialog::Accepted ) {
> @@ -142,7 +163,7 @@
>  void ConjunctionsTool::slotLocation()
>  {
>    LocationDialog ld( (KStars*) topLevelWidget()->parent() );
> -
> +
>    if ( ld.exec() == QDialog::Accepted ) {
>      geoPlace = ld.selectedCity();
>      LocationButton -> setText( geoPlace -> fullName() );
> @@ -159,7 +180,7 @@
>    dms maxSeparation(1.0); // TODO: Make maxSeparation user-specifiable
>    // TODO: Get geoPlace from user.
>    //    dms LST( geoPlace->GSTtoLST( dt.gst() ) );
> -
> +
>    if( !Object1 ) {
>        // TODO: Display some error message
>        KMessageBox::sorry( 0, i18n("Please select an object to check
> conjunctions with, by clicking on the \'Find Object\' button.") );
> @@ -171,11 +192,12 @@
>    KSConjunct ksc;
>    ComputeStack->setCurrentIndex( 1 );
>    connect( &ksc, SIGNAL(madeProgress(int)), this, SLOT(showProgress(int))
> );
> -
> -  showConjunctions(ksc.findClosestApproach(*Object1, *Object2, startJD,
> stopJD, maxSeparation));
> +
> +  showConjunctions( ksc.findClosestApproach(*Object1, *Object2, startJD,
> stopJD, maxSeparation) );
> +
>    ComputeStack->setCurrentIndex( 0 );
>    QApplication::restoreOverrideCursor();
> -
> +
>    delete Object2;
>    Object2 = NULL;
>
> @@ -189,12 +211,16 @@
>
>    KStarsDateTime dt;
>    QMap<long double, dms>::Iterator it;
> +  int i;
>
>    OutputView->clear();
> +  outputJDList.clear();
> +  i = 0;
>
>    for(it = conjunctionlist.begin(); it != conjunctionlist.end(); ++it) {
>      dt.setDJD( it.key() );
>      OutputView -> addItem( i18n("Conjunction on %1 UT: Separation is %2",
> dt.toString("%a, %d %b %Y %H:%M"), it.data().toDMSString()) );
> +    outputJDList.insert( i, it.key() );
>    }
>  }
>
> --- trunk/KDE/kdeedu/kstars/kstars/tools/conjunctions.h #831465:831466
> @@ -34,6 +34,7 @@
>  class GeoLocation;
>  class KSPlanetBase;
>  class dms;
> +class QListWidgetItem;
>
>  /**
>    *@short Predicts conjunctions using KSConjunct in the background
> @@ -53,12 +54,14 @@
>      void slotCompute();
>      void showProgress(int);
>      void slotFindObject();
> +    void slotGoto();
>
>  private:
>      SkyObject *Object1;
>      KSPlanetBase *Object2;        // Second object is always a planet.
>
>      QHash<int, QString> pNames;   // To store the names of Planets vs.
> values expected by KSPlanetBase::createPlanet()
> +    QMap<int, long double> outputJDList; // To store Julian Days
> corresponding to the row index in the output list widget
>
>      void showConjunctions(QMap<long double, dms> conjunctionlist);
>
> _______________________________________________
> Kstars-devel mailing list
> Kstars-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kstars-devel
>


More information about the Kstars-devel mailing list