[kde-doc-english] [kstars] kstars/tools: Well... this is embarrassing. Classic case of forgotten files.

Akarsh Simha akarsh.simha at kdemail.net
Tue Dec 23 01:15:34 UTC 2014


Git commit 5858b12a627baef0fc6563f7047bc9d82366e6ab by Akarsh Simha, on behalf of Utkarsh Simha.
Committed on 23/12/2014 at 01:13.
Pushed by asimha into branch 'master'.

Well... this is embarrassing. Classic case of forgotten files.

Missed three files in the previous commit. I'm adding them now.

Again, the files were authored by Utkarsh Simha. I'm only committing
them.

-- Akarsh

GUI:

A  +106  -0    kstars/tools/starhopperdialog.cpp     [License: GPL (v2+)]
A  +64   -0    kstars/tools/starhopperdialog.h     [License: GPL (v2+)]
A  +69   -0    kstars/tools/starhopperdialog.ui

http://commits.kde.org/kstars/5858b12a627baef0fc6563f7047bc9d82366e6ab

diff --git a/kstars/tools/starhopperdialog.cpp b/kstars/tools/starhopperdialog.cpp
new file mode 100644
index 0000000..1e344f6
--- /dev/null
+++ b/kstars/tools/starhopperdialog.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+               starhopperdialog.cpp  -  UI of Star Hopping Guide for KStars
+                             -------------------
+    begin                : Sat 15th Nov 2014
+    copyright            : (C) 2014 Utkarsh Simha
+    email                : utkarshsimha at gmail.com
+***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "starhopperdialog.h"
+
+StarHopperDialog::StarHopperDialog( QWidget *parent ) : QDialog( parent ), ui( new Ui::StarHopperDialog ) {
+    ui->setupUi( this );
+    lw = ui->listWidget;
+    sh = new StarHopper();
+    connect( ui->NextButton, SIGNAL( clicked() ), this, SLOT( slotNext() ) );
+    connect( ui->GotoButton, SIGNAL( clicked() ), this, SLOT( slotGoto() ) );
+    connect( ui->DetailsButton, SIGNAL( clicked() ), this, SLOT( slotDetails() ) );
+    connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater()));
+}
+
+StarHopperDialog::~StarHopperDialog() {
+    TargetListComponent *t = getTargetListComponent();
+    t->list->clear();
+    SkyMap::Instance()->forceUpdate( true );
+    delete sh;
+}
+
+void StarHopperDialog::starHop( const SkyPoint &startHop, const SkyPoint &stopHop, float fov, float maglim ) {
+    QList<StarObject *> *starList = sh->computePath( startHop, stopHop, fov, maglim );
+    foreach( StarObject *so, *starList ) {
+        setData( so );
+    }
+    m_skyObjList = KSUtils::castStarObjListToSkyObjList( starList );
+    starList->clear();
+    delete starList;
+    TargetListComponent *t = getTargetListComponent();
+    delete t->list;
+    t->list = m_skyObjList;
+}
+
+void StarHopperDialog::setData( StarObject * sobj ) {
+    QListWidgetItem *item = new QListWidgetItem();
+    QString starName;
+    if( sobj->name() != "star" ) {
+        starName = sobj->translatedLongName();
+    }
+    else if( sobj->getHDIndex() ) {
+        starName = QString( "HD%1" ).arg( QString::number( sobj->getHDIndex() ) );
+    }
+    else {
+        starName = "";
+        starName+= sobj->spchar();
+        starName+= QString( " Star of mag %2" ).arg( QString::number( sobj->mag() ) );
+    }
+    item->setText( starName );
+    QVariant qv;
+    qv.setValue( sobj );
+    item->setData( Qt::UserRole, qv );
+    lw->addItem( item );
+}
+
+void StarHopperDialog::slotNext() {
+    lw->setCurrentRow( lw->currentRow()+1 );
+}
+
+void StarHopperDialog::slotGoto() {
+    SkyObject *skyobj = getStarData( lw->currentItem() );
+    if( skyobj ) {
+        KStars *ks = KStars::Instance();
+        ks->map()->setClickedObject( skyobj );
+        ks->map()->setClickedPoint( skyobj );
+        ks->map()->slotCenter();
+    }
+}
+
+void StarHopperDialog::slotDetails() {
+    SkyObject *skyobj = getStarData( lw->currentItem() );
+    if ( skyobj ) {
+        DetailDialog *detailDialog = new DetailDialog( skyobj, KStarsData::Instance()->lt(), KStarsData::Instance()->geo(), KStars::Instance());
+        detailDialog->exec();
+        delete detailDialog;
+   }
+}
+
+SkyObject * StarHopperDialog::getStarData(QListWidgetItem *item) {
+    if( !item )
+        return 0;
+    else {
+        QVariant v = item->data( Qt::UserRole );
+        StarObject *starobj = v.value<StarObject *>();
+        return starobj;
+    }
+}
+
+inline TargetListComponent * StarHopperDialog::getTargetListComponent() {
+    return KStarsData::Instance()->skyComposite()->getStarHopRouteList();
+}
diff --git a/kstars/tools/starhopperdialog.h b/kstars/tools/starhopperdialog.h
new file mode 100644
index 0000000..15c1c7d
--- /dev/null
+++ b/kstars/tools/starhopperdialog.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+               starhopperdialog.cpp  -  UI of Star Hopping Guide for KStars
+                             -------------------
+    begin                : Sat 15th Nov 2014
+    copyright            : (C) 2014 Utkarsh Simha
+    email                : utkarshsimha at gmail.com
+***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef _STARHOPPERDIALOG_H_
+#define _STARHOPPERDIALOG_H_
+
+#include "skyobjects/starobject.h"
+#include "skymap.h"
+#include "dialogs/detaildialog.h"
+#include "tools/starhopper.h"
+#include "skycomponents/targetlistcomponent.h"
+#include "skycomponents/skymapcomposite.h"
+#include "ksutils.h"
+
+#include "ui_starhopperdialog.h"
+#include<QDialog>
+
+Q_DECLARE_METATYPE(StarObject *)
+
+class StarHopperDialog : public QDialog, public Ui::StarHopperDialog {
+    Q_OBJECT
+	public:
+        StarHopperDialog(QWidget *parent = 0);
+        virtual ~StarHopperDialog();
+        /**
+         *@short Forms a Star Hop route from source to destination and displays on skymap
+         *@param startHop SkyPoint to the start of Star Hop
+         *@param stopHop SkyPoint to destination of StarHop
+         *@param fov Field of view under consideration
+         *@param maglim Magnitude limit of star to search for
+         *@note In turn calls StarHopper to perform computations
+         */
+        void starHop( const SkyPoint& startHop, const SkyPoint& stopHop, float fov, float maglim);
+
+	private slots:
+        void slotNext();
+        void slotGoto();
+        void slotDetails();
+
+	private:
+        SkyObject * getStarData(QListWidgetItem *);
+        void setData(StarObject *);
+        inline TargetListComponent * getTargetListComponent();
+        QList<SkyObject *> *m_skyObjList;
+        StarHopper *sh;
+        Ui::StarHopperDialog *ui;
+        QListWidget *lw;
+};
+#endif
+
diff --git a/kstars/tools/starhopperdialog.ui b/kstars/tools/starhopperdialog.ui
new file mode 100644
index 0000000..929f750
--- /dev/null
+++ b/kstars/tools/starhopperdialog.ui
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StarHopperDialog</class>
+ <widget class="QDialog" name="StarHopperDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Star-Hopper Results</string>
+  </property>
+  <widget class="QListWidget" name="listWidget">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>30</y>
+     <width>361</width>
+     <height>211</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="NextButton">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>250</y>
+     <width>85</width>
+     <height>27</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Next</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="DetailsButton">
+   <property name="geometry">
+    <rect>
+     <x>150</x>
+     <y>250</y>
+     <width>85</width>
+     <height>27</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Details</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="GotoButton">
+   <property name="geometry">
+    <rect>
+     <x>270</x>
+     <y>250</y>
+     <width>90</width>
+     <height>30</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Center on map</string>
+   </property>
+  </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>


More information about the kde-doc-english mailing list