[Kstars-devel] branches/kstars/summer/kstars/kstars/tools
Prakash Mohan
prak902000 at gmail.com
Fri Jun 12 15:46:51 CEST 2009
SVN commit 980757 by prakash:
Optimising the slotGetImage function, also preventing it from going into a infinite loop.
Removing variables that need not be global from observinglist.h and adding them as local variables in setCurrentImage.
CCMAIL: kstars-devel at kde.org
M +39 -28 observinglist.cpp
M +9 -3 observinglist.h
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #980756:980757
@@ -468,16 +468,8 @@
if ( found ) {
m_CurrentObject = o;
plot( o );
- //Change the RAString, DecString, CurrentImage to correspond to the new object
- RAString = RAString.sprintf( "%02d+%02d+%02d", o->ra0()->hour(), o->ra0()->minute(), o->ra0()->second() );
- decsgn = '+';
- if ( o->dec0()->Degrees() < 0.0 ) decsgn = '-';
- int dd = abs( o->dec0()->degree() );
- 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() );
+ //Change the CurrentImage, DSS/SDSS Url to correspond to the new object
+ setCurrentImage( o );
ui->GetImage->setEnabled( true );//Enable anyway for updating the image
if ( newName != i18n( "star" ) ) {
//Display the current object's user notes in the NotesEdit
@@ -485,7 +477,6 @@
saveCurrentUserLog(); //uses LogObject, which is still the previous obj.
//set LogObject to the new selected object
LogObject = currentObject();
- CurrentImage = o->name().remove(' ');
ui->NotesLabel->setEnabled( true );
ui->NotesEdit->setEnabled( true );
ui->NotesLabel->setText( i18n( "observing notes for %1:", LogObject->translatedName() ) );
@@ -500,8 +491,6 @@
ui->TimeEdit->setTime( TimeHash.value( o->name(), o->transitTime( dt, geo ) ) );
}
} else { //selected object is named "star"
- CurrentImage = "image" + RAString + DecString;
- CurrentImage = CurrentImage.remove('+').remove('-') + decsgn;
//clear the log text box
saveCurrentUserLog();
ui->NotesLabel->setText( i18n( "observing notes (disabled for unnamed star)" ) );
@@ -1142,33 +1131,55 @@
slotAddObject( o, true, true );
}
-void ObservingList::slotGetImage( bool dss ) {
+void ObservingList::slotGetImage( bool _dss ) {
+ dss = _dss;
+ ui->GetImage->setEnabled( false );
ui->ImagePreview->clearPreview();
+ QFile::remove( KStandardDirs::locateLocal( "appdata", CurrentImage ) );
+ KUrl url;
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() ) );
+ url.setUrl( DSSUrl );
} 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() ) );
+ url.setUrl( SDSSUrl );
}
+ 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;
if( QFile( KStandardDirs::locateLocal( "appdata", CurrentImage ) ).size() > 9000 ) {//The default image is around 8689 bytes
+ ui->GetImage->setEnabled( true );
ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal( "appdata", CurrentImage ) ) );
ImageList.append( CurrentImage );
- } else
- slotGetImage(true);
+ }
+ else if( ! dss )
+ slotGetImage( true );
}
+void ObservingList::setCurrentImage( SkyObject *o ) {
+ QString RAString, DecString, RA, Dec;
+ RAString = RAString.sprintf( "%02d+%02d+%02d", o->ra0()->hour(), o->ra0()->minute(), o->ra0()->second() );
+ decsgn = '+';
+ if ( o->dec0()->Degrees() < 0.0 ) decsgn = '-';
+ int dd = abs( o->dec0()->degree() );
+ 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() );
+ CurrentImage = o->name().remove(' ');
+ if( o->name() == "star" ) {
+ CurrentImage = "image" + RAString + DecString;
+ CurrentImage = CurrentImage.remove('+').remove('-') + decsgn;
+ }
+ 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" );
+ DSSUrl = UrlPrefix + "&r=" + RAString + "&d=" + DecString + UrlSuffix;
+ UrlPrefix = "http://casjobs.sdss.org/ImgCutoutDR6/getjpeg.aspx?";
+ UrlSuffix = "&scale=1.0&width=600&height=600&opt=GST&query=SR(10,20)";
+ SDSSUrl = UrlPrefix + RA + Dec + UrlSuffix;
+}
+
#include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #980756:980757
@@ -128,6 +128,7 @@
/**@short Return the list of downloaded images
*/
QList<QString> imageList() { return ImageList; }
+
public slots:
/**@short add a new object to list
*@p o pointer to the object to add to the list
@@ -242,8 +243,13 @@
/**@short Downloads the corresponding DSS or SDSS image from the web and
*displays it
*/
- void slotGetImage( bool dss=false );
+ void slotGetImage( bool _dss = false );
+ /**@short Sets the image parameters for the current object
+ *@p o The passed object for setting the parameters
+ */
+ void setCurrentImage( SkyObject *o );
+
protected slots:
void slotClose();
void downloadReady();
@@ -255,8 +261,8 @@
QList<SkyObject*> m_ObservingList, m_SessionList;
SkyObject *LogObject, *m_CurrentObject;
uint noNameStars;
- bool isModified, bIsLarge, sessionView;
- QString FileName, SessionName, CurrentImage, RAString, DecString, RA, Dec, DSSUrl, SDSSUrl;
+ bool isModified, bIsLarge, sessionView, saveOnly, dss;
+ QString FileName, SessionName, CurrentImage, DSSUrl, SDSSUrl;
char decsgn;
KStarsDateTime dt;
GeoLocation *geo;
More information about the Kstars-devel
mailing list