[Kstars-devel] branches/kstars/summer/kstars/kstars/tools

Prakash Mohan prak902000 at gmail.com
Thu Jun 11 12:44:55 CEST 2009


SVN commit 980164 by prakash:

Implementing the support for SDSS image previews in the Observing List.

CCMAIL: kstars-devel at kde.org


 M  +25 -11    observinglist.cpp  
 M  +2 -2      observinglist.h  


--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #980163:980164
@@ -476,6 +476,8 @@
             int dm = abs( o->dec0()->arcmin() );
             int ds = abs( o->dec0()->arcsec() );
             DecString = DecString.sprintf( "%c%02d+%02d+%02d", decsgn, dd, dm, ds );
+            RA = RA.sprintf( "ra=%f", o->ra0()->Degrees() );
+            Dec = Dec.sprintf( "&dec=%f", o->dec0()->Degrees() );
             ui->GetImage->setEnabled( true );//Enable anyway for updating the image
             if ( newName != i18n( "star" ) ) {
                 //Display the current object's user notes in the NotesEdit
@@ -483,7 +485,7 @@
                 saveCurrentUserLog(); //uses LogObject, which is still the previous obj.
                 //set LogObject to the new selected object
                 LogObject = currentObject();
-                CurrentImage = "dss_" + o->name().remove(' ');
+                CurrentImage = o->name().remove(' ');
                 ui->NotesLabel->setEnabled( true );
                 ui->NotesEdit->setEnabled( true );
                 ui->NotesLabel->setText( i18n( "observing notes for %1:", LogObject->translatedName() ) );
@@ -498,7 +500,7 @@
                     ui->TimeEdit->setTime( TimeHash.value( o->name(), o->transitTime( dt, geo ) ) );
                 }   
             } else { //selected object is named "star"
-                CurrentImage = "dss_" + RAString + DecString;
+                CurrentImage = "image" + RAString + DecString;
                 CurrentImage = CurrentImage.remove('+').remove('-') + decsgn;
                 //clear the log text box
                 saveCurrentUserLog();
@@ -1140,21 +1142,33 @@
     slotAddObject( o, true, true );
 }
 
-void ObservingList::slotGetImage() {
+void ObservingList::slotGetImage( bool dss ) {
     ui->ImagePreview->clearPreview();
-    QString URLprefix( "http://archive.stsci.edu/cgi-bin/dss_search?v=1" );
-    QString URLsuffix( "&e=J2000&h=15.0&w=15.0&f=gif&c=none&fov=NONE" );
-    KUrl url ( URLprefix + "&r=" + RAString + "&d=" + DecString + URLsuffix );
-    QFile::remove( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
-    downloadJob = KIO::copy ( url, KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
-    connect ( downloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadReady() ) );
+    if( dss ) {
+        QString URLprefix( "http://archive.stsci.edu/cgi-bin/dss_search?v=1" );
+        QString URLsuffix( "&e=J2000&h=15.0&w=15.0&f=gif&c=none&fov=NONE" );
+        KUrl url ( URLprefix + "&r=" + RAString + "&d=" + DecString + URLsuffix );
+        QFile::remove( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
+        downloadJob = KIO::copy ( url, KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
+        connect ( downloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadReady() ) );
+    } else {
+      	QString URLprefix( "http://casjobs.sdss.org/ImgCutoutDR6/getjpeg.aspx?" );
+        QString URLsuffix( "&scale=1.0&width=600&height=600&opt=GST&query=SR(10,20)" );
+        KUrl url ( URLprefix + RA + Dec + URLsuffix );
+        QFile::remove( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
+        downloadJob = KIO::copy ( url, KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
+        connect ( downloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadReady() ) );
+    }
 }
 
 void ObservingList::downloadReady() {
     // set downloadJob to 0, but don't delete it - the job will be deleted automatically
     downloadJob = 0;
-    ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
-    ImageList.append( CurrentImage );
+    if( QFile( KStandardDirs::locateLocal( "appdata", CurrentImage ) ).size() > 9000 ) {//The default image is around 8689 bytes
+        ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
+        ImageList.append( CurrentImage );
+    } else
+        slotGetImage(true);
 }  
 
 #include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #980163:980164
@@ -242,7 +242,7 @@
     /**@short Downloads the corresponding DSS or SDSS image from the web and
         *displays it
         */
-    void slotGetImage();
+    void slotGetImage( bool dss=false );
 
 protected slots:
     void slotClose();
@@ -256,7 +256,7 @@
     SkyObject *LogObject, *m_CurrentObject;
     uint noNameStars;
     bool isModified, bIsLarge, sessionView;
-    QString FileName, SessionName, CurrentImage, RAString, DecString;
+    QString FileName, SessionName, CurrentImage, RAString, DecString, RA, Dec,  DSSUrl, SDSSUrl;
     char decsgn;
     KStarsDateTime dt;
     GeoLocation *geo;


More information about the Kstars-devel mailing list