• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

opscatalog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           opscatalog.cpp  -  K Desktop Planetarium
00003                              -------------------
00004     begin                : Sun Feb 29  2004
00005     copyright            : (C) 2004 by Jason Harris
00006     email                : jharris@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <qlistview.h> //QCheckListItem
00019 #include <qcheckbox.h>
00020 #include <qlabel.h>
00021 #include <kfiledialog.h>
00022 
00023 #include "opscatalog.h"
00024 #include "Options.h"
00025 #include "kstars.h"
00026 #include "kstarsdata.h"
00027 #include "skymap.h"
00028 #include "addcatdialog.h"
00029 #include "magnitudespinbox.h"
00030 #include "customcatalog.h"
00031 
00032 OpsCatalog::OpsCatalog( QWidget *p, const char *name, WFlags fl ) 
00033     : OpsCatalogUI( p, name, fl ) 
00034 {
00035     ksw = (KStars *)p;
00036 
00037     //Populate CatalogList
00038     showIC = new QCheckListItem( CatalogList, i18n( "Index Catalog (IC)" ), QCheckListItem::CheckBox );
00039     showIC->setOn( Options::showIC() );
00040 
00041     showNGC = new QCheckListItem( CatalogList, i18n( "New General Catalog (NGC)" ), QCheckListItem::CheckBox );
00042     showNGC->setOn( Options::showNGC() );
00043 
00044     showMessImages = new QCheckListItem( CatalogList, i18n( "Messier Catalog (images)" ), QCheckListItem::CheckBox );
00045     showMessImages->setOn( Options::showMessierImages() );
00046 
00047     showMessier = new QCheckListItem( CatalogList, i18n( "Messier Catalog (symbols)" ), QCheckListItem::CheckBox );
00048     showMessier->setOn( Options::showMessier() );
00049 
00050     kcfg_MagLimitDrawStar->setValue( Options::magLimitDrawStar() );
00051     kcfg_MagLimitDrawStarZoomOut->setValue( Options::magLimitDrawStarZoomOut() );
00052     kcfg_MagLimitDrawStar->setMinValue( Options::magLimitDrawStarZoomOut() );
00053     kcfg_MagLimitDrawStarZoomOut->setMaxValue( Options::magLimitDrawStar() );
00054     
00055     kcfg_MagLimitDrawDeepSky->setMaxValue( 16.0 );
00056     kcfg_MagLimitDrawDeepSkyZoomOut->setMaxValue( 16.0 );
00057     
00058     //disable star-related widgets if not showing stars
00059     if ( ! kcfg_ShowStars->isChecked() ) slotStarWidgets(false);
00060     
00061     //Add custom catalogs, if necessary
00062     for ( unsigned int i=0; i<ksw->data()->customCatalogs().count(); ++i ) { //loop over custom catalogs
00063         QCheckListItem *newItem = new QCheckListItem( CatalogList, ksw->data()->customCatalogs().at(i)->name(), QCheckListItem::CheckBox );
00064         newItem->setOn( Options::showCatalog()[i] );
00065     }
00066 
00067     connect( CatalogList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( updateDisplay() ) );
00068     connect( CatalogList, SIGNAL( selectionChanged() ), this, SLOT( selectCatalog() ) );
00069     connect( AddCatalog, SIGNAL( clicked() ), this, SLOT( slotAddCatalog() ) );
00070     connect( LoadCatalog, SIGNAL( clicked() ), this, SLOT( slotLoadCatalog() ) );
00071     connect( RemoveCatalog, SIGNAL( clicked() ), this, SLOT( slotRemoveCatalog() ) );
00072 
00073     connect( kcfg_MagLimitDrawStar, SIGNAL( valueChanged(double) ),
00074         SLOT( slotSetDrawStarMagnitude(double) ) );
00075     connect( kcfg_MagLimitDrawStarZoomOut, SIGNAL( valueChanged(double) ),
00076         SLOT( slotSetDrawStarZoomOutMagnitude(double) ) );
00077     connect( kcfg_ShowStars, SIGNAL( toggled(bool) ), SLOT( slotStarWidgets(bool) ) );
00078 }
00079 
00080 //empty destructor
00081 OpsCatalog::~OpsCatalog() {}
00082 
00083 void OpsCatalog::updateDisplay() {
00084     //Modify display according to settings in the CatalogList
00085     if ( sender()->name() == QString( "CatalogList" ) )
00086         Options::setShowDeepSky( true );
00087 
00088     Options::setShowMessier( showMessier->isOn() );
00089     Options::setShowMessierImages( showMessImages->isOn() );
00090     Options::setShowNGC( showNGC->isOn() );
00091     Options::setShowIC( showIC->isOn() );
00092     for ( unsigned int i=0; i<ksw->data()->customCatalogs().count(); ++i ) {
00093         QCheckListItem *item = (QCheckListItem*)( CatalogList->findItem( ksw->data()->customCatalogs().at(i)->name(), 0 ));
00094         Options::showCatalog()[i] = item->isOn();
00095     }
00096 
00097     // update time for all objects because they might be not initialized
00098     // it's needed when using horizontal coordinates
00099     ksw->data()->setFullTimeUpdate();
00100     ksw->updateTime();
00101     ksw->map()->forceUpdate();
00102 }
00103 
00104 void OpsCatalog::selectCatalog() {
00105 //If selected item is a custom catalog, enable the remove button (otherwise, disable it)
00106     RemoveCatalog->setEnabled( false );
00107     for ( unsigned int i=0; i < ksw->data()->customCatalogs().count(); ++i ) {
00108         if ( CatalogList->currentItem()->text( 0 ) == ksw->data()->customCatalogs().at(i)->name() ) {
00109             RemoveCatalog->setEnabled( true );
00110             break;
00111         }
00112     }
00113 }
00114 
00115 void OpsCatalog::slotAddCatalog() {
00116     AddCatDialog ac(this);
00117     if ( ac.exec()==QDialog::Accepted ) 
00118         insertCatalog( ac.filename() );
00119 }
00120 
00121 void OpsCatalog::slotLoadCatalog() {
00122     //Get the filename from the user
00123     QString filename = KFileDialog::getOpenFileName( QDir::homeDirPath(), "*");
00124     if ( ! filename.isEmpty() ) {
00125         //test integrity of file before trying to add it
00126         CustomCatalog *newCat = ksw->data()->createCustomCatalog( filename, true ); //true = show errors
00127         if ( newCat ) {
00128             int nObjects = newCat->objList().count();
00129             delete newCat;
00130             if ( nObjects )
00131                 insertCatalog( filename );
00132         }
00133     }
00134 }
00135 
00136 void OpsCatalog::insertCatalog( const QString &filename ) {
00137     //Add new custom catalog, based on the list of SkyObjects we just parsed
00138     ksw->data()->addCatalog( filename );
00139 
00140     //Get the new catalog's name, add entry to the listbox
00141     QString name = ksw->data()->customCatalogs().current()->name();
00142     QCheckListItem *newCat = new QCheckListItem( CatalogList, name, QCheckListItem::CheckBox );
00143     newCat->setOn( true );
00144     CatalogList->insertItem( newCat );
00145 
00146     //update Options object
00147     QStringList tFileList = Options::catalogFile();
00148     QValueList<int> tShowList = Options::showCatalog();
00149     tFileList.append( filename );
00150     tShowList.append( true );
00151     Options::setCatalogFile( tFileList );
00152     Options::setShowCatalog( tShowList );
00153     
00154     ksw->map()->forceUpdate();
00155 }
00156 
00157 void OpsCatalog::slotRemoveCatalog() {
00158     //Remove CatalogName, CatalogFile, and ShowCatalog entries, and decrement CatalogCount
00159     for ( unsigned int i=0; i < ksw->data()->customCatalogs().count(); ++i ) {
00160         if ( CatalogList->currentItem()->text( 0 ) == ksw->data()->customCatalogs().at(i)->name() ) {
00161 
00162             ksw->data()->removeCatalog( i );
00163 
00164             //Update Options object
00165             QStringList tFileList = Options::catalogFile();
00166             QValueList<int> tShowList = Options::showCatalog();
00167             tFileList.remove( tFileList[i] );
00168             tShowList.remove( tShowList[i] );
00169             Options::setCatalogFile( tFileList );
00170             Options::setShowCatalog( tShowList );
00171             break;
00172         }
00173     }
00174 
00175     //Remove entry in the QListView
00176     CatalogList->takeItem( CatalogList->currentItem() );
00177 
00178     ksw->map()->forceUpdate();
00179 }
00180 
00181 void OpsCatalog::slotSetDrawStarMagnitude(double newValue) {
00182     kcfg_MagLimitDrawStarZoomOut->setMaxValue( newValue );
00183     ksw->data()->setMagnitude( newValue );
00184 }
00185 
00186 void OpsCatalog::slotSetDrawStarZoomOutMagnitude(double newValue) {
00187     kcfg_MagLimitDrawStar->setMinValue( newValue );
00188     Options::setMagLimitDrawStarZoomOut( newValue );
00189     // force redraw
00190     ksw->map()->forceUpdate();
00191 }
00192 
00193 void OpsCatalog::slotStarWidgets(bool on) {
00194     textLabelMagStars->setEnabled(on);
00195     textLabelMagStarsZoomOut->setEnabled(on);
00196     textLabelMagStarInfo->setEnabled(on);
00197     textLabelMag1->setEnabled(on);
00198     textLabelMag2->setEnabled(on);
00199     textLabelMag3->setEnabled(on);
00200     kcfg_MagLimitDrawStar->setEnabled(on);
00201     kcfg_MagLimitDrawStarZoomOut->setEnabled(on);
00202     kcfg_MagLimitDrawStarInfo->setEnabled(on);
00203     kcfg_ShowStarNames->setEnabled(on);
00204     kcfg_ShowStarMagnitudes->setEnabled(on);
00205 }
00206 
00207 #include "opscatalog.moc"

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal