[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [marble/esasocis-2012-eclipse] src/plugins/render/eclipses: EclipsesPlugin: Enable lunar eclipses
From: Rene Kuettner <rene () bitkanal ! net>
Date: 2013-01-22 9:53:29
Message-ID: 20130122095329.480B0A6091 () git ! kde ! org
[Download RAW message or body]
Git commit 17d70d411289f82637da891b9795e1367c34c47d by Rene Kuettner.
Committed on 22/01/2013 at 10:53.
Pushed by renek into branch 'esasocis-2012-eclipse'.
EclipsesPlugin: Enable lunar eclipses
M +15 -2 src/plugins/render/eclipses/EclipsesBrowserDialog.cpp
M +17 -1 src/plugins/render/eclipses/EclipsesBrowserDialog.h
M +1 -1 src/plugins/render/eclipses/EclipsesConfigDialog.ui
M +19 -12 src/plugins/render/eclipses/EclipsesItem.cpp
M +9 -6 src/plugins/render/eclipses/EclipsesItem.h
M +24 -9 src/plugins/render/eclipses/EclipsesModel.cpp
M +36 -13 src/plugins/render/eclipses/EclipsesModel.h
M +21 -1 src/plugins/render/eclipses/EclipsesPlugin.cpp
http://commits.kde.org/marble/17d70d411289f82637da891b9795e1367c34c47d
diff --git a/src/plugins/render/eclipses/EclipsesBrowserDialog.cpp \
b/src/plugins/render/eclipses/EclipsesBrowserDialog.cpp index d2ad2ab..e90fe90 100644
--- a/src/plugins/render/eclipses/EclipsesBrowserDialog.cpp
+++ b/src/plugins/render/eclipses/EclipsesBrowserDialog.cpp
@@ -44,6 +44,19 @@ int EclipsesBrowserDialog::year() const
return m_browserWidget->spinBoxYear->value();
}
+void EclipsesBrowserDialog::setWithLunarEclipses( const bool enable )
+{
+ if( m_eclModel->withLunarEclipses() != enable ) {
+ m_eclModel->setWithLunarEclipses( enable );
+ m_eclModel->update();
+ }
+}
+
+bool EclipsesBrowserDialog::withLunarEclipses() const
+{
+ return m_eclModel->withLunarEclipses();
+}
+
void EclipsesBrowserDialog::accept()
{
QItemSelectionModel *s = m_browserWidget->treeView->selectionModel();
@@ -57,7 +70,7 @@ void EclipsesBrowserDialog::accept()
QDialog::accept();
}
-void EclipsesBrowserDialog::updateEclipsesBrowserForYear( int year )
+void EclipsesBrowserDialog::updateEclipsesForYear( int year )
{
m_eclModel->setYear( year );
updateButtonStates();
@@ -84,7 +97,7 @@ void EclipsesBrowserDialog::initialize()
connect( m_browserWidget->buttonClose, SIGNAL(clicked()),
this, SLOT(reject()) );
connect( m_browserWidget->spinBoxYear, SIGNAL(valueChanged(int)),
- this, SLOT(updateEclipsesBrowserForYear(int)) );
+ this, SLOT(updateEclipsesForYear(int)) );
connect( m_browserWidget->treeView->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&,
const QItemSelection&)),
diff --git a/src/plugins/render/eclipses/EclipsesBrowserDialog.h \
b/src/plugins/render/eclipses/EclipsesBrowserDialog.h index 5c3d81a..21038b9 100644
--- a/src/plugins/render/eclipses/EclipsesBrowserDialog.h
+++ b/src/plugins/render/eclipses/EclipsesBrowserDialog.h
@@ -57,6 +57,22 @@ public:
*/
int year() const;
+ /**
+ * @brief Set wheter or not to list lunar eclipses
+ * @param enable wheter or not to list lunar eclipses
+ *
+ * @see withLunarEclipses
+ */
+ void setWithLunarEclipses( const bool enable );
+
+ /**
+ * @brief Returns wheter or not lunar eclipses are listed
+ *
+ * @return Wheter or not lunar eclipses are listed
+ * @see setWithLunarEclipses
+ */
+ bool withLunarEclipses() const;
+
Q_SIGNALS:
/**
* @brief This signal is emitted when the use clicks the "show" button
@@ -84,7 +100,7 @@ protected Q_SLOTS:
* @brief Update the list of eclipses for the given year
* @param year The year to list eclipses for
*/
- void updateEclipsesBrowserForYear( int year );
+ void updateEclipsesForYear( int year );
/**
* @brief Update the dialog's button states
diff --git a/src/plugins/render/eclipses/EclipsesConfigDialog.ui \
b/src/plugins/render/eclipses/EclipsesConfigDialog.ui index e5b88eb..422855f 100644
--- a/src/plugins/render/eclipses/EclipsesConfigDialog.ui
+++ b/src/plugins/render/eclipses/EclipsesConfigDialog.ui
@@ -39,7 +39,7 @@
<item>
<widget class="QCheckBox" name="checkBoxEnableLunarEclipses">
<property name="enabled">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="text">
<string>Enable &Lunar Eclipses</string>
diff --git a/src/plugins/render/eclipses/EclipsesItem.cpp \
b/src/plugins/render/eclipses/EclipsesItem.cpp index 1e16235..1907aa4 100644
--- a/src/plugins/render/eclipses/EclipsesItem.cpp
+++ b/src/plugins/render/eclipses/EclipsesItem.cpp
@@ -51,12 +51,15 @@ EclipsesItem::EclipsePhase EclipsesItem::phase() const
QString EclipsesItem::phaseText() const
{
switch( m_phase ) {
- case PartialSun: return tr( "Partial Sun" );
- case NonCentralAnnularSun: return tr( "non-central Annular Sun" );
- case NonCentralTotalSun: return tr( "non-central Total Sun" );
- case AnnularSun: return tr( "Annular Sun" );
- case TotalSun: return tr( "Total Sun" );
- case AnnularTotalSun: return tr( "Annular / Total Sun" );
+ case TotalMoon: return tr( "Moon, Total" );
+ case PartialMoon: return tr( "Moon, Partial" );
+ case PenumbralMoon: return tr( "Moon, Penumbral" );
+ case PartialSun: return tr( "Sun, Partial" );
+ case NonCentralAnnularSun: return tr( "Sun, non-central, Annular" );
+ case NonCentralTotalSun: return tr( "Sun, non-central, Total" );
+ case AnnularSun: return tr( "Sun, Annular" );
+ case TotalSun: return tr( "Sun, Total" );
+ case AnnularTotalSun: return tr( "Sun, Annular/Total" );
}
return QString();
@@ -190,12 +193,16 @@ void EclipsesItem::initialize()
tz, m_magnitude );
switch( phase ) {
- case 1: m_phase = EclipsesItem::PartialSun; break;
- case 2: m_phase = EclipsesItem::NonCentralAnnularSun; break;
- case 3: m_phase = EclipsesItem::NonCentralTotalSun; break;
- case 4: m_phase = EclipsesItem::AnnularSun; break;
- case 5: m_phase = EclipsesItem::TotalSun; break;
- case 6: m_phase = EclipsesItem::AnnularTotalSun; break;
+ case -4: m_phase = EclipsesItem::TotalMoon; break;
+ case -3: m_phase = EclipsesItem::PartialMoon; break;
+ case -2:
+ case -1: m_phase = EclipsesItem::PenumbralMoon; break;
+ case 1: m_phase = EclipsesItem::PartialSun; break;
+ case 2: m_phase = EclipsesItem::NonCentralAnnularSun; break;
+ case 3: m_phase = EclipsesItem::NonCentralTotalSun; break;
+ case 4: m_phase = EclipsesItem::AnnularSun; break;
+ case 5: m_phase = EclipsesItem::TotalSun; break;
+ case 6: m_phase = EclipsesItem::AnnularTotalSun; break;
default:
mDebug() << "Invalid phase for eclipse at" << year << "/" <<
day << "/" << month << "!";
diff --git a/src/plugins/render/eclipses/EclipsesItem.h \
b/src/plugins/render/eclipses/EclipsesItem.h index 19469c3..c1413d1 100644
--- a/src/plugins/render/eclipses/EclipsesItem.h
+++ b/src/plugins/render/eclipses/EclipsesItem.h
@@ -44,12 +44,15 @@ public:
* @brief A type of an eclipse event
*/
enum EclipsePhase {
- PartialSun = 1,
- NonCentralAnnularSun = 2,
- NonCentralTotalSun = 3,
- AnnularSun = 4,
- TotalSun = 5,
- AnnularTotalSun = 6
+ TotalMoon = -4,
+ PartialMoon = -3,
+ PenumbralMoon = -1,
+ PartialSun = 1,
+ NonCentralAnnularSun = 2,
+ NonCentralTotalSun = 3,
+ AnnularSun = 4,
+ TotalSun = 5,
+ AnnularTotalSun = 6
};
/**
diff --git a/src/plugins/render/eclipses/EclipsesModel.cpp \
b/src/plugins/render/eclipses/EclipsesModel.cpp index de9d6f2..9679b1f 100644
--- a/src/plugins/render/eclipses/EclipsesModel.cpp
+++ b/src/plugins/render/eclipses/EclipsesModel.cpp
@@ -22,11 +22,12 @@ namespace Marble
EclipsesModel::EclipsesModel( const MarbleModel *model, QObject *parent )
: QAbstractItemModel( parent ),
m_marbleModel( model ),
- m_currentYear( 0 )
+ m_currentYear( 0 ),
+ m_withLunarEclipses( false )
{
- m_ecps = new EclSolar();
- m_ecps->setLunarEcl( false );
- m_ecps->setTimezone( model->clock()->timezone() / 3600. );
+ m_ecl = new EclSolar();
+ m_ecl->setTimezone( model->clock()->timezone() / 3600. );
+ m_ecl->setLunarEcl( m_withLunarEclipses );
// oberservation point defaults to home location
qreal lon, lat;
@@ -39,7 +40,7 @@ EclipsesModel::EclipsesModel( const MarbleModel *model, QObject \
*parent ) EclipsesModel::~EclipsesModel()
{
clear();
- delete m_ecps;
+ delete m_ecl;
}
const GeoDataCoordinates& EclipsesModel::observationPoint() const
{
@@ -49,7 +50,7 @@ const GeoDataCoordinates& EclipsesModel::observationPoint() const
void EclipsesModel::setObservationPoint( const GeoDataCoordinates &coords )
{
m_observationPoint = coords;
- m_ecps->setLocalPos( coords.latitude(), coords.altitude(), 6000. );
+ m_ecl->setLocalPos( coords.latitude(), coords.altitude(), 6000. );
}
void EclipsesModel::setYear( int year )
@@ -58,7 +59,7 @@ void EclipsesModel::setYear( int year )
mDebug() << "Year changed - Calculating eclipses...";
m_currentYear = year;
- m_ecps->putYear( year );
+ m_ecl->putYear( year );
update();
}
@@ -69,6 +70,20 @@ int EclipsesModel::year() const
return m_currentYear;
}
+void EclipsesModel::setWithLunarEclipses( const bool enable )
+{
+ if( m_withLunarEclipses != enable ) {
+ m_withLunarEclipses = enable;
+ m_ecl->setLunarEcl( m_withLunarEclipses );
+ update();
+ }
+}
+
+bool EclipsesModel::withLunarEclipses() const
+{
+ return m_withLunarEclipses;
+}
+
EclipsesItem* EclipsesModel::eclipseWithIndex( int index )
{
foreach( EclipsesItem *item, m_items ) {
@@ -179,9 +194,9 @@ void EclipsesModel::update()
beginInsertRows( QModelIndex(), 0, rowCount() );
- int num = m_ecps->getNumberEclYear();
+ int num = m_ecl->getNumberEclYear();
for( int i = 1; i <= num; ++i ) {
- EclipsesItem *item = new EclipsesItem( m_ecps, i );
+ EclipsesItem *item = new EclipsesItem( m_ecl, i );
addItem( item );
}
diff --git a/src/plugins/render/eclipses/EclipsesModel.h \
b/src/plugins/render/eclipses/EclipsesModel.h index 3efceb6..3823a6a 100644
--- a/src/plugins/render/eclipses/EclipsesModel.h
+++ b/src/plugins/render/eclipses/EclipsesModel.h
@@ -89,6 +89,27 @@ public:
int year() const;
/**
+ * @brief Set if lunar eclipses are enbled
+ * @param enable Indicates wheter or not to allow lunar eclipses
+ *
+ * Allows to enable or disable inclusion of lunar eclipses.
+ *
+ * @see withLunarEclipses
+ */
+ void setWithLunarEclipses( const bool enable );
+
+ /**
+ * @brief Return wheter or not lunar eclipses are enabled
+ *
+ * Returns wheter or not lunar eclipses are included in the eclipse
+ * calculation.
+ *
+ * @return True if lunar eclipses are enabled or false otherwise
+ * @see setWithLunarEclipses
+ */
+ bool withLunarEclipses() const;
+
+ /**
* @brief Get eclipse item of a given year
*
* @param index
@@ -122,6 +143,19 @@ public:
QVariant headerData( int section, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const;
+public Q_SLOTS:
+ /**
+ * @brief Update the list of eclipse items
+ *
+ * This forces an update of the current list of eclipse items by
+ * calculating all eclipse events for the currently set year and
+ * adding them to the model. All previously added items are
+ * cleared before.
+ *
+ * @see clear
+ */
+ void update();
+
private:
/**
* @brief Add an item to the model
@@ -142,22 +176,11 @@ private:
*/
void clear();
- /**
- * @brief Update the list of eclipse items
- *
- * This forces an update of the current list of eclipse items by
- * calculating all eclipse events for the currently set year and
- * adding them to the model. All previously added items are
- * cleared before.
- *
- * @see clear
- */
- void update();
-
const MarbleModel *m_marbleModel;
- EclSolar *m_ecps;
+ EclSolar *m_ecl;
QList<EclipsesItem*> m_items;
int m_currentYear;
+ bool m_withLunarEclipses;
GeoDataCoordinates m_observationPoint;
};
diff --git a/src/plugins/render/eclipses/EclipsesPlugin.cpp \
b/src/plugins/render/eclipses/EclipsesPlugin.cpp index 0b91417..f986202 100644
--- a/src/plugins/render/eclipses/EclipsesPlugin.cpp
+++ b/src/plugins/render/eclipses/EclipsesPlugin.cpp
@@ -173,6 +173,8 @@ void EclipsesPlugin::initialize()
SIGNAL(clicked()), this, SLOT(readSettings()) );
connect( m_configWidget->buttonBox->button( QDialogButtonBox::Apply ),
SIGNAL(clicked()), this, SLOT(writeSettings()) );
+ connect( m_configWidget->buttonBox->button( QDialogButtonBox::Apply ),
+ SIGNAL(clicked()), this, SLOT(updateEclipses()) );
m_browserDialog = new EclipsesBrowserDialog( marbleModel() );
connect( m_browserDialog, SIGNAL(buttonShowClicked(int, int)),
@@ -412,14 +414,18 @@ void EclipsesPlugin::updateSettings()
if (!isInitialized()) {
return;
}
+
+ m_browserDialog->setWithLunarEclipses(
+ m_settings.value( "enableLunarEclipses" ).toBool() );
}
void EclipsesPlugin::updateEclipses()
{
mDebug() << "Updating eclipses....";
const int year = marbleModel()->clock()->dateTime().date().year();
+ const bool lun = m_configWidget->checkBoxEnableLunarEclipses->isChecked();
- if( m_menuYear != year ) {
+ if( ( m_menuYear != year ) || ( m_model->withLunarEclipses() != lun ) ) {
// remove old menus
foreach( QAction *action, m_eclipsesListMenu->actions() ) {
@@ -433,6 +439,11 @@ void EclipsesPlugin::updateEclipses()
}
m_menuYear = year;
+ // enable/disable lunar eclipses if necessary
+ if( m_model->withLunarEclipses() != lun ) {
+ m_model->setWithLunarEclipses( lun );
+ }
+
m_eclipsesListMenu->setTitle( tr("Eclipses in %1").arg( year ) );
foreach( EclipsesItem *item, m_model->items() ) {
@@ -440,6 +451,15 @@ void EclipsesPlugin::updateEclipses()
item->dateMaximum().date().toString() );
action->setData( QVariant( item->index() ) );
switch( item->phase() ) {
+ case EclipsesItem::TotalMoon:
+ action->setIcon( QIcon( ":res/lunar_total.png" ) );
+ break;
+ case EclipsesItem::PartialMoon:
+ action->setIcon( QIcon( ":res/lunar_partial.png" ) );
+ break;
+ case EclipsesItem::PenumbralMoon:
+ action->setIcon( QIcon( ":res/lunar_penumbra.png" ) );
+ break;
case EclipsesItem::PartialSun:
action->setIcon( QIcon( ":res/solar_partial.png" ) );
break;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic