Git commit 659b3cdb84f08ab60df1a042ca690470a21cf609 by Akarsh Simha. Committed on 17/01/2016 at 06:13. Pushed by asimha into branch 'master'.
EyepieceField: Allow downloading DSS when no image has been supplied This is particularly useful when launching Eyepiece View from the sky map popup menu, since no DSS image is then supplied to Eyepiece View. A "Fetch DSS" button is displayed which may be used to download an image from DSS and then render it in Eyepiece View. The file is a temporary file, that is reused and finally removed when EyepieceField is destroyed -- so the DSS image is not saved. Future work would include the option to save downloaded DSS images to make a library, to avoid re-downloading. Eventually, this library could be used for DSS overlay. FEATURE: Allow fetching of image in eyepiece view when none is supplied GUI: A new button to fetch DSS images has been added to Eyepiece View. M +44 -1 kstars/tools/eyepiecefield.cpp M +21 -2 kstars/tools/eyepiecefield.h http://commits.kde.org/kstars/659b3cdb84f08ab60df1a042ca690470a21cf609 diff --git a/kstars/tools/eyepiecefield.cpp b/kstars/tools/eyepiecefield.cpp index a9244c6..6e43925 100644 --- a/kstars/tools/eyepiecefield.cpp +++ b/kstars/tools/eyepiecefield.cpp @@ -25,6 +25,7 @@ #include "kstars.h" #include "Options.h" #include "ksdssimage.h" +#include "ksdssdownloader.h" /* KDE Includes */ /* Qt Includes */ @@ -48,6 +49,9 @@ EyepieceField::EyepieceField( QWidget *parent ) : QDialog( parent ) { m_sp = 0; m_lat = 0; + m_currentFOV = 0; + m_fovWidth = m_fovHeight = 0; + m_dler = 0; QWidget *mainWidget = new QWidget( this ); QVBoxLayout *mainLayout = new QVBoxLayout; @@ -81,6 +85,9 @@ EyepieceField::EyepieceField( QWidget *parent ) : QDialog( parent ) { m_flipView = new QCheckBox( i18n( "Flip view" ), this ); m_overlay = new QCheckBox( i18n( "Overlay" ), this ); m_invertColors = new QCheckBox( i18n( "Invert colors" ), this ); + m_getDSS = new QPushButton( i18n( "Fetch DSS image" ), this ); + + m_getDSS->setVisible( false ); QHBoxLayout *optionsLayout = new QHBoxLayout; optionsLayout->addWidget( m_invertView ); @@ -88,6 +95,7 @@ EyepieceField::EyepieceField( QWidget *parent ) : QDialog( parent ) { optionsLayout->addStretch(); optionsLayout->addWidget( m_overlay ); optionsLayout->addWidget( m_invertColors ); + optionsLayout->addWidget( m_getDSS ); rows->addLayout( optionsLayout ); @@ -123,6 +131,7 @@ EyepieceField::EyepieceField( QWidget *parent ) : QDialog( parent ) { connect( m_rotationSlider, SIGNAL( valueChanged( int ) ), this, SLOT( render() ) ); connect( m_presetCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( slotEnforcePreset( int ) ) ); connect( m_presetCombo, SIGNAL( activated( int ) ), this, SLOT( slotEnforcePreset( int ) ) ); + connect( m_getDSS, SIGNAL( clicked() ), this, SLOT( slotDownloadDss() ) ); m_skyChart = 0; m_skyImage = 0; @@ -189,6 +198,7 @@ void EyepieceField::showEyepieceField( SkyPoint *sp, FOV const * const fov, cons } showEyepieceField( sp, fovWidth, fovHeight, imagePath ); + m_currentFOV = fov; } @@ -224,7 +234,9 @@ void EyepieceField::showEyepieceField( SkyPoint *sp, const double fovWidth, doub slotEnforcePreset( -1 ); // Render the display render(); - + m_fovWidth = fovWidth; + m_fovHeight = fovHeight; + m_currentFOV = 0; } @@ -442,11 +454,13 @@ void EyepieceField::render() { m_skyImageDisplay->setVisible( true ); m_overlay->setVisible( true ); m_invertColors->setVisible( true ); + m_getDSS->setVisible( false ); } else { m_skyImageDisplay->setVisible( false ); m_overlay->setVisible( false ); m_invertColors->setVisible( false ); + m_getDSS->setVisible( true ); } @@ -459,6 +473,35 @@ void EyepieceField::render() { show(); } +void EyepieceField::slotDownloadDss() { + double fovWidth, fovHeight; + if( m_fovWidth == 0 && m_currentFOV == 0 ) { + fovWidth = fovHeight = 15.0; + } + else if( m_currentFOV ) { + fovWidth = m_currentFOV->sizeX(); + fovWidth = m_currentFOV->sizeY(); + } + if( !m_dler ) { + m_dler = new KSDssDownloader( this ); + connect( m_dler, SIGNAL ( downloadComplete( bool ) ), SLOT ( slotDssDownloaded( bool ) ) ); + } + KSDssImage::Metadata md; + m_tempFile.open(); + QUrl srcUrl = QUrl( KSDssDownloader::getDSSURL( m_sp, fovWidth, fovHeight, "all", &md ) ); + m_dler->startSingleDownload( srcUrl, m_tempFile.fileName(), md ); + m_tempFile.close(); +} + +void EyepieceField::slotDssDownloaded( bool success ) { + if( !success ) { + KMessageBox::sorry(0, i18n( "Failed to download DSS/SDSS image!" ) ); + return; + } + else + showEyepieceField( m_sp, m_fovWidth, m_fovHeight, m_tempFile.fileName() ); +} + EyepieceField::~EyepieceField() { // Empty delete m_skyChart; diff --git a/kstars/tools/eyepiecefield.h b/kstars/tools/eyepiecefield.h index 7fd1f83..faed7fb 100644 --- a/kstars/tools/eyepiecefield.h +++ b/kstars/tools/eyepiecefield.h @@ -22,6 +22,7 @@ #include <QDialog> #include <QImage> +#include <QTemporaryFile> class SkyPoint; class FOV; @@ -30,6 +31,9 @@ class QLabel; class QSlider; class QComboBox; class QCheckBox; +class QPushButton; +class FOV; +class KSDssDownloader; /** * @class EyepieceField @@ -95,7 +99,7 @@ class EyepieceField : public QDialog { // FIXME: Rename to EyepieceView static void generateEyepieceView( SkyPoint *sp, QImage *skyChart, QImage *skyImage = 0, const FOV *fov = 0, const QString &imagePath = QString() ); -public slots: + public slots: /** * @short Re-renders the view @@ -108,6 +112,17 @@ public slots: */ void slotEnforcePreset( int index = -1 ); + private slots: + /** + * @short downloads a DSS image + */ + void slotDownloadDss(); + + /** + * @short loads a downloaded DSS image + */ + void slotDssDownloaded( bool success ); + private: QLabel *m_skyChartDisplay; QLabel *m_skyImageDisplay; @@ -119,9 +134,13 @@ public slots: QCheckBox *m_invertView; QCheckBox *m_flipView; QComboBox *m_presetCombo; + QPushButton *m_getDSS; + const FOV *m_currentFOV; + double m_fovWidth, m_fovHeight; + KSDssDownloader *m_dler; SkyPoint *m_sp; double m_lat; // latitude - + QTemporaryFile m_tempFile; }; #endif _______________________________________________ kde-doc-english mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-doc-english
