From ae2a03c2941bf92573f89b88ef73f8aa842bea0a Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdetoys@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmoon/AUTHORS | 10 ++ kmoon/Makefile.am | 20 +++ kmoon/hi16-app-kmoon.png | Bin 0 -> 332 bytes kmoon/hi32-app-kmoon.png | Bin 0 -> 2111 bytes kmoon/hi48-app-kmoon.png | Bin 0 -> 4120 bytes kmoon/kmoonapplet.cpp | 165 ++++++++++++++++++++ kmoon/kmoonapplet.desktop | 109 +++++++++++++ kmoon/kmoonapplet.h | 67 ++++++++ kmoon/kmoondlg.cpp | 114 ++++++++++++++ kmoon/kmoondlg.h | 55 +++++++ kmoon/kmoonwidget.cpp | 369 ++++++++++++++++++++++++++++++++++++++++++++ kmoon/kmoonwidget.h | 68 ++++++++ kmoon/phases.cpp | 383 ++++++++++++++++++++++++++++++++++++++++++++++ kmoon/pics/Makefile.am | 13 ++ kmoon/pics/moon1.png | Bin 0 -> 3186 bytes kmoon/pics/moon10.png | Bin 0 -> 4770 bytes kmoon/pics/moon11.png | Bin 0 -> 4814 bytes kmoon/pics/moon12.png | Bin 0 -> 4809 bytes kmoon/pics/moon13.png | Bin 0 -> 4794 bytes kmoon/pics/moon14.png | Bin 0 -> 5496 bytes kmoon/pics/moon15.png | Bin 0 -> 4806 bytes kmoon/pics/moon16.png | Bin 0 -> 4818 bytes kmoon/pics/moon17.png | Bin 0 -> 4803 bytes kmoon/pics/moon18.png | Bin 0 -> 4836 bytes kmoon/pics/moon19.png | Bin 0 -> 4858 bytes kmoon/pics/moon2.png | Bin 0 -> 3186 bytes kmoon/pics/moon20.png | Bin 0 -> 4868 bytes kmoon/pics/moon21.png | Bin 0 -> 4786 bytes kmoon/pics/moon22.png | Bin 0 -> 4613 bytes kmoon/pics/moon23.png | Bin 0 -> 4317 bytes kmoon/pics/moon24.png | Bin 0 -> 4049 bytes kmoon/pics/moon25.png | Bin 0 -> 3768 bytes kmoon/pics/moon26.png | Bin 0 -> 3543 bytes kmoon/pics/moon27.png | Bin 0 -> 3341 bytes kmoon/pics/moon28.png | Bin 0 -> 3207 bytes kmoon/pics/moon29.png | Bin 0 -> 3186 bytes kmoon/pics/moon3.png | Bin 0 -> 3187 bytes kmoon/pics/moon4.png | Bin 0 -> 3349 bytes kmoon/pics/moon5.png | Bin 0 -> 3611 bytes kmoon/pics/moon6.png | Bin 0 -> 3859 bytes kmoon/pics/moon7.png | Bin 0 -> 4228 bytes kmoon/pics/moon8.png | Bin 0 -> 4497 bytes kmoon/pics/moon9.png | Bin 0 -> 4678 bytes kmoon/version.h | 1 + 44 files changed, 1374 insertions(+) create mode 100644 kmoon/AUTHORS create mode 100644 kmoon/Makefile.am create mode 100644 kmoon/hi16-app-kmoon.png create mode 100644 kmoon/hi32-app-kmoon.png create mode 100644 kmoon/hi48-app-kmoon.png create mode 100644 kmoon/kmoonapplet.cpp create mode 100644 kmoon/kmoonapplet.desktop create mode 100644 kmoon/kmoonapplet.h create mode 100644 kmoon/kmoondlg.cpp create mode 100644 kmoon/kmoondlg.h create mode 100644 kmoon/kmoonwidget.cpp create mode 100644 kmoon/kmoonwidget.h create mode 100644 kmoon/phases.cpp create mode 100644 kmoon/pics/Makefile.am create mode 100644 kmoon/pics/moon1.png create mode 100644 kmoon/pics/moon10.png create mode 100644 kmoon/pics/moon11.png create mode 100644 kmoon/pics/moon12.png create mode 100644 kmoon/pics/moon13.png create mode 100644 kmoon/pics/moon14.png create mode 100644 kmoon/pics/moon15.png create mode 100644 kmoon/pics/moon16.png create mode 100644 kmoon/pics/moon17.png create mode 100644 kmoon/pics/moon18.png create mode 100644 kmoon/pics/moon19.png create mode 100644 kmoon/pics/moon2.png create mode 100644 kmoon/pics/moon20.png create mode 100644 kmoon/pics/moon21.png create mode 100644 kmoon/pics/moon22.png create mode 100644 kmoon/pics/moon23.png create mode 100644 kmoon/pics/moon24.png create mode 100644 kmoon/pics/moon25.png create mode 100644 kmoon/pics/moon26.png create mode 100644 kmoon/pics/moon27.png create mode 100644 kmoon/pics/moon28.png create mode 100644 kmoon/pics/moon29.png create mode 100644 kmoon/pics/moon3.png create mode 100644 kmoon/pics/moon4.png create mode 100644 kmoon/pics/moon5.png create mode 100644 kmoon/pics/moon6.png create mode 100644 kmoon/pics/moon7.png create mode 100644 kmoon/pics/moon8.png create mode 100644 kmoon/pics/moon9.png create mode 100644 kmoon/version.h (limited to 'kmoon') diff --git a/kmoon/AUTHORS b/kmoon/AUTHORS new file mode 100644 index 0000000..3acac86 --- /dev/null +++ b/kmoon/AUTHORS @@ -0,0 +1,10 @@ +KDE interface: +Stephan Kulow +M G berberich + +phase calculation code: +Christopher Osburn + +Graphics by: +Tim Beauchamp + diff --git a/kmoon/Makefile.am b/kmoon/Makefile.am new file mode 100644 index 0000000..c2875c1 --- /dev/null +++ b/kmoon/Makefile.am @@ -0,0 +1,20 @@ + +kde_module_LTLIBRARIES = kmoon_panelapplet.la + +kmoon_panelapplet_la_SOURCES = kmoonapplet.cpp phases.cpp kmoondlg.cpp kmoonwidget.cpp +kmoon_panelapplet_la_LDFLAGS = $(KDE_PLUGIN) -module $(all_libraries) +kmoon_panelapplet_la_LIBADD = $(LIB_KSYCOCA) + +lnkdir = $(kde_datadir)/kicker/applets +lnk_DATA = kmoonapplet.desktop + +INCLUDES = $(all_includes) + +METASOURCES = AUTO + +KDE_ICON = kmoon + +SUBDIRS = pics + +messages: + $(XGETTEXT) *.cpp -o $(podir)/kmoon.pot diff --git a/kmoon/hi16-app-kmoon.png b/kmoon/hi16-app-kmoon.png new file mode 100644 index 0000000..8913b34 Binary files /dev/null and b/kmoon/hi16-app-kmoon.png differ diff --git a/kmoon/hi32-app-kmoon.png b/kmoon/hi32-app-kmoon.png new file mode 100644 index 0000000..65deb09 Binary files /dev/null and b/kmoon/hi32-app-kmoon.png differ diff --git a/kmoon/hi48-app-kmoon.png b/kmoon/hi48-app-kmoon.png new file mode 100644 index 0000000..1ce020f Binary files /dev/null and b/kmoon/hi48-app-kmoon.png differ diff --git a/kmoon/kmoonapplet.cpp b/kmoon/kmoonapplet.cpp new file mode 100644 index 0000000..9b3dd87 --- /dev/null +++ b/kmoon/kmoonapplet.cpp @@ -0,0 +1,165 @@ +/* + * kmoon - a moon phase indicator + * $Id$ + * Copyright (C) 1998,2000 Stephan Kulow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" +#include "kmoondlg.h" +#include "kmoonwidget.h" +#include "kmoonapplet.h" + +const char *description = I18N_NOOP("Moon Phase Indicator for KDE"); + +extern "C" +{ + KDE_EXPORT KPanelApplet *init(QWidget *parent, const QString& configFile) + { + KGlobal::locale()->insertCatalogue("kmoon"); + return new MoonPAWidget(configFile, KPanelApplet::Normal, + KPanelApplet::About|KPanelApplet::Preferences, + parent, "kmoonapplet"); + } +} + +MoonPAWidget::MoonPAWidget(const QString& configFile, Type type, int actions, + QWidget *parent, const char *name) + : KPanelApplet(configFile, type, actions, parent, name) +{ + KConfig *config = KGlobal::config(); + config->setGroup("General"); + + QVBoxLayout *vbox = new QVBoxLayout(this, 0,0); + moon = new MoonWidget(this); + moon->setAngle(config->readNumEntry("Rotation", 0)); + moon->setNorthHemi(config->readBoolEntry("Northern", true)); + moon->setMask(config->readBoolEntry("Mask", false)); + vbox->addWidget(moon); + startTimer(1000 * 60 * 20); + + popup = new QPopupMenu(); + popup->insertItem(SmallIcon("kmoon"), + i18n("&About"), this, + SLOT(showAbout())); + popup->insertItem(SmallIcon("configure"), i18n("&Configure..."), this, + SLOT(settings())); + + // missuse timerEvent for initialising + timerEvent(0); +} + +MoonPAWidget::~MoonPAWidget() +{ + delete moon; + delete popup; +} + +void MoonPAWidget::showAbout() +{ + KDialogBase *dialog = new KDialogBase( + i18n("About Moon Phase Indicator"), + KDialogBase::Yes, + KDialogBase::Yes, KDialogBase::Yes, + 0, "about", true, true, + KStdGuiItem::ok() ); + + QPixmap ret = DesktopIcon("kmoon"); + QString text = i18n(description) + QString::fromLatin1("\n\n") + + i18n("Written by Stephan Kulow \n" + "\n" + "Made an applet by M G Berberich " + "\n" + "\n" + "Lunar code by Chris Osburn " + "\n" + "\n" + "Moon graphics by Tim Beauchamp " + ""); + + dialog->setIcon(ret); + + KMessageBox::createKMessageBox(dialog, ret, text, QStringList(), QString::null, 0, KMessageBox::Notify); +} + +void MoonPAWidget::settings() +{ + KMoonDlg dlg(moon->angle(), moon->northHemi(), moon->mask(), + this, "moondlg"); + if (dlg.exec() == KMoonDlg::Accepted) { + moon->setAngle(dlg.getAngle()); + moon->setNorthHemi(dlg.getNorthHemi()); + moon->setMask(dlg.getMask()); + KConfig *config = KGlobal::config(); + config->setGroup("General"); + config->writeEntry("Rotation", moon->angle()); + config->writeEntry("Northern", moon->northHemi()); + config->writeEntry("Mask", moon->mask()); + config->sync(); + } + repaint(); +} + +void MoonPAWidget::timerEvent( QTimerEvent * ) +{ + time_t clock; + time(&clock); + struct tm *t = localtime(&clock); + moon->calcStatus(mktime(t)); + moon->repaint(); +} + +void MoonPAWidget::mousePressEvent( QMouseEvent *e) +{ + if (!popup) + return; + + if (e->button() == RightButton) { + popup->popup(mapToGlobal(e->pos())); + popup->exec(); + } + if (e->button() == LeftButton) { + showAbout(); + } +} + +#include "kmoonapplet.moc" diff --git a/kmoon/kmoonapplet.desktop b/kmoon/kmoonapplet.desktop new file mode 100644 index 0000000..a89e167 --- /dev/null +++ b/kmoon/kmoonapplet.desktop @@ -0,0 +1,109 @@ +[Desktop Entry] +Type=Plugin +Icon=kmoon +Name=Moon Phase +Name[be]=Фаза луны +Name[bg]=Фази на луната +Name[bn]=চাঁদের কলা +Name[br]=Prantadoù al loariad +Name[ca]=Fase de la lluna +Name[cs]=Měsíční fáze +Name[cy]=Gweddau'r Lleuad +Name[da]=Månefase +Name[de]=Mondphasen-Darstellung +Name[el]=Δείκτης των φάσεων της Σελήνης +Name[eo]=Lunfazo +Name[es]=Fase lunar +Name[et]=Kuu faasid +Name[eu]=Ilargiaren fasea +Name[fa]=هلال ماه +Name[fi]=Kuunvaihenäyttäjä +Name[fr]=Phase de la Lune +Name[ga]=Céim na Gealaí +Name[gl]=Fase da Lua +Name[he]=מופע הירח +Name[hr]=Mjesečeva mjena +Name[hu]=KMoon +Name[is]=Tunglskiptabirtir +Name[it]=Fasi lunari +Name[ja]=月の満ち欠け +Name[km]=ដំណើរ​ព្រះចន្ទ +Name[ko]=달 모양 보기 +Name[lv]=Mēness fāzes +Name[mk]=Месечеви мени +Name[nb]=Se månefasene +Name[nds]=Maandwieser +Name[ne]=चन्द्रमाको रूप +Name[nl]=Maanstand +Name[nn]=Månefase +Name[pa]=ਚੰਦ ਕਲਾਵਾਂ +Name[pl]=Fazy księżyca +Name[pt]=Fase Lunar +Name[pt_BR]=Fase da Lua +Name[ro]=Fazele Lunii +Name[ru]=Фазы Луны +Name[sk]=Fázy Mesiaca +Name[sl]=Lunina mena +Name[sr]=Месечеве мене +Name[sr@Latn]=Mesečeve mene +Name[sv]=Månfaser +Name[tg]=Авзои Моҳ +Name[tr]=Ay'ın Durumu +Name[uk]=Фази місяця +Name[wa]=Fazes del lune +Name[zh_CN]=月相 +Name[zh_TW]=月亮圓缺 +Comment=Displays the current moon phase +Comment[ar]=يعرض وجه القمر الحالي +Comment[be]=Паказвае бягучаю фазу луны +Comment[bg]=Показване на текущата фаза на луната +Comment[bn]=চাঁদের বর্তমান কলা প্রদর্শন করে +Comment[br]=Diskouez ar prantad loariad red +Comment[ca]=Mostra la fase actual de la lluna +Comment[cs]=Zobrazuje aktuální fázi měsíce +Comment[cy]=Dangos gwedd gyfredol y lleuad +Comment[da]=Viser nuværende månefase +Comment[de]=Zeigt die aktuelle Mondphase an +Comment[el]=Εμφανίζει την τρέχουσα φάση της Σελήνης +Comment[eo]=Montru la nunan lunfazon +Comment[es]=Indica la fase lunar actual +Comment[et]=Kuu faaside näitaja +Comment[eu]=Uneko ilargiaren fasea bistaratzen du +Comment[fa]=هلال ماه جاری را نمایش می‌دهد +Comment[fi]=Näyttää kuun nykyisen vaiheen +Comment[fr]=Affiche la phase actuelle de la Lune +Comment[ga]=Taispeáin céim reatha na gealaí +Comment[gl]=Mostra a fase da lua +Comment[he]=מציג את מופע הירח הנוכחי +Comment[hr]=Prikazivanje trenutnih mjesečevih mjena +Comment[hu]=Megjeleníti a Hold aktuális állapotát +Comment[is]=Sýnir núverandi stöðu tunglsins +Comment[it]=Visualizza la fase lunare corrente +Comment[ja]=月の満ち欠けの状態を表示 +Comment[km]=បង្ហាញ​ដំណើរ​ព្រះចន្ទ​បច្ចុប្បន្ន +Comment[lv]=Rāda pašreizējo mēness fāzi +Comment[mk]=Ја прикажува тековната месечева мена +Comment[nb]=Vis vilken månefase vi er i +Comment[nds]=Wiest den aktuellen Maand +Comment[ne]=हालको चन्द्रमाको रूप प्रदर्शन गर्दछ +Comment[nl]=Toont de huidige maanstand +Comment[nn]=Viser månefasen +Comment[pl]=Pokazuje aktualną fazę księżyca +Comment[pt]=Mostra a fase lunar actual +Comment[pt_BR]=Mostra a atual fase da lua +Comment[ro]=Afişează faza curentă a lunii +Comment[ru]=Показывает текущую фазу Луны +Comment[sk]=Zobrazí aktuálnu fázu Mesiaca +Comment[sl]=Prikazuje trenutno Lunino meno +Comment[sr]=Приказује тренутну фазу месеца +Comment[sr@Latn]=Prikazuje trenutnu fazu meseca +Comment[sv]=Visar den nuvarande månfasen +Comment[tg]=Намоиши авзои Моҳи равон +Comment[tr]=Ayın şimdiki durumunu gösterir +Comment[uk]=Показує поточну фазу місяця +Comment[wa]=Håynêye li faze del lune do moumint +Comment[zh_CN]=显示当前的月相 +Comment[zh_TW]=顯示目前月亮的圓缺狀態 +X-KDE-Library=kmoon_panelapplet +X-KDE-UniqueApplet=true +DocPath=kmoon/index.html diff --git a/kmoon/kmoonapplet.h b/kmoon/kmoonapplet.h new file mode 100644 index 0000000..ac25d0f --- /dev/null +++ b/kmoon/kmoonapplet.h @@ -0,0 +1,67 @@ +/* + * kmoon - a moon phase indicator + * Copyright (C) 1998,2000 Stephan Kulow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef KMOONAPPLET +#define KMOONAPPLET + +#include +#include +#include +#include +#include +#include + +// #include "kmoonwidget.h" + +class QPopupMenu; + +class MoonWidget; + +class MoonPAWidget : public KPanelApplet +{ + Q_OBJECT + +public: + MoonPAWidget(const QString& configFile, Type t = Normal, int actions = 0, + QWidget *parent = 0, const char *name = 0); + ~MoonPAWidget(); + + int widthForHeight(int height) const { return height; } + int heightForWidth(int width) const { return width; } + +protected: + QPopupMenu *popup; + MoonWidget *moon; + QString tooltip; + + void about() { showAbout(); } + void preferences() { settings(); } + +protected slots: + + void timerEvent( QTimerEvent *e); + void showAbout(); + void settings(); + +protected: + void mousePressEvent( QMouseEvent *e); +}; + +#endif diff --git a/kmoon/kmoondlg.cpp b/kmoon/kmoondlg.cpp new file mode 100644 index 0000000..14f6f5a --- /dev/null +++ b/kmoon/kmoondlg.cpp @@ -0,0 +1,114 @@ +/* + * kmoon - a moon phase indicator + * Copyright (C) 1998 Stephan Kulow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "kmoondlg.h" +#include "kmoonwidget.h" + +KMoonDlg::KMoonDlg(int a, bool n, bool m, QWidget *parent, const char *name) + : KDialogBase(parent, name, true, i18n("Change View"), + Ok|Cancel|Help), angle(a), north(n), mask(m) +{ + QWidget *page = new QWidget( this ); + setMainWidget(page); + QHBoxLayout *topLayout = new QHBoxLayout( page, 0, spacingHint() ); + + QVBox *vbox = new QVBox(page); + QHBox *hbox1 = new QHBox(vbox); + hbox1->setSpacing(15); + + QLabel *label = new QLabel( i18n("View angle:"), hbox1, "caption" ); + QString text = i18n("You can use this to rotate the moon to the correct\n" + "angle for your location.\n" + "\n" + "This angle is (almost) impossible to\n" + "calculate from any system-given data,\n" + "therefore you can configure how you\n" + "want KMoon to display your moon here.\n" + "The default value is 0, but it is very\n" + "unlikely that you would see the moon\n" + "at this angle."); + QWhatsThis::add(label, text); + + slider = new QSlider( -90, 90, 2, angle, Qt::Horizontal, hbox1, "slider" ); + slider->setTickmarks(QSlider::Above); + slider->setTickInterval(45); + slider->setEnabled(QPixmap::defaultDepth() > 8); + label->setEnabled(QPixmap::defaultDepth() > 8); + QWhatsThis::add(slider, text); + connect(slider, SIGNAL(valueChanged(int)), SLOT(angleChanged(int))); + + QHBox *hbox2 = new QHBox(vbox); + hbox2->setSpacing(spacingHint()); + + hemitoggle = new QPushButton(hbox2); + hemitoggle->setText(north ? i18n("Switch to Southern Hemisphere") : + i18n("Switch to Northern Hemisphere")); + + connect(hemitoggle, SIGNAL(clicked()), SLOT(toggleHemi())); + + masktoggle = new QPushButton(hbox2); + masktoggle->setText(mask ? i18n("Switch Masking Off") : + i18n("Switch Masking On")); + + connect(masktoggle, SIGNAL(clicked()), SLOT(toggleMask())); + topLayout->addWidget(vbox); + + moon = new MoonWidget(page, "preview"); + moon->setMinimumSize(50, 50); + moon->setMaximumSize(200,200); + QWhatsThis::add(moon, i18n("The moon as KMoon would display it\n" + "following your current setting and time.")); + topLayout->addWidget(moon); + connect(this, SIGNAL(helpClicked()), SLOT(help())); + // disableResize(); +} + +void KMoonDlg::angleChanged(int value) { + angle = value; + moon->setAngle(value); +} + +void KMoonDlg::help() { + kapp->invokeHelp(QString::fromLatin1("config")); +} + +void KMoonDlg::toggleHemi() { + moon->setNorthHemi(!moon->northHemi()); + north = moon->northHemi(); + hemitoggle->setText(north ? i18n("Switch to Southern Hemisphere") : + i18n("Switch to Northern Hemisphere")); +} + +void KMoonDlg::toggleMask() { + moon->setMask(!moon->mask()); + mask = moon->mask(); + masktoggle->setText(mask ? i18n("Switch Masking Off") : + i18n("Switch Masking On")); +} + +#include "kmoondlg.moc" diff --git a/kmoon/kmoondlg.h b/kmoon/kmoondlg.h new file mode 100644 index 0000000..2533a2a --- /dev/null +++ b/kmoon/kmoondlg.h @@ -0,0 +1,55 @@ +/* + * kmoon - a moon phase indicator + * Copyright (C) 1998,2000 Stephan Kulow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef KMOONDLG +#define KMOONDLG + +#include + +class QSlider; +class MoonWidget; +class QPushButton; + +class KMoonDlg : public KDialogBase { + Q_OBJECT + + public: + KMoonDlg(int angle, bool north, bool mask, QWidget *parent, const char *name); + int getAngle() const { return angle; } + bool getNorthHemi() const { return north; } + bool getMask() const { return mask; } + + private: + QSlider *slider; + MoonWidget *moon; + int angle; + bool north; + bool mask; + QPushButton *hemitoggle; + QPushButton *masktoggle; + + private slots: + void help(); + void angleChanged(int); + void toggleHemi(); + void toggleMask(); +}; + +#endif diff --git a/kmoon/kmoonwidget.cpp b/kmoon/kmoonwidget.cpp new file mode 100644 index 0000000..413b555 --- /dev/null +++ b/kmoon/kmoonwidget.cpp @@ -0,0 +1,369 @@ +/* + * kmoon - a moon phase indicator + * $Id$ + * Copyright (C) 1998,2000 Stephan Kulow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kmoondlg.h" +#include "kmoonwidget.h" +#include + +extern double moonphasebylunation(int lun, int phi); +extern time_t JDtoDate(double jd, struct tm *event_date); + +MoonWidget::MoonWidget(QWidget *parent, const char *name) + : QWidget(parent, name) +{ + struct tm * t; + time_t clock; + + counter = -1; + KConfig *config = KGlobal::config(); + config->setGroup("General"); + _angle = config->readNumEntry("Rotation", 0); + _north = config->readBoolEntry("Northern", true); + _mask = config->readBoolEntry("Mask", true); + old_angle = old_w = old_h = old_counter = -1; + old_north = false; + old_mask = false; + startTimer(1000 * 60 * 20); + + time(&clock); + t = gmtime(&clock); + // kdDebug() << "time " << t->tm_isdst << " " << timezone << " " << daylight << endl ; + calcStatus(mktime(t)); +} + +MoonWidget::~MoonWidget() +{ +} + +void MoonWidget::calcStatus( time_t time ) +{ + uint lun = 0; + time_t last_new = 0; + time_t next_new = 0; + + do { + double JDE = moonphasebylunation(lun, 0); + last_new = next_new; + next_new = JDtoDate(JDE, 0); + lun++; + } while (next_new < time); + + lun -= 2; + + QDateTime ln; + ln.setTime_t( last_new ); + kdDebug() << KGlobal::locale()->formatDateTime( ln ) << endl; + + time_t first_quarter = JDtoDate( moonphasebylunation( lun, 1 ), 0 ); + QDateTime fq; + fq.setTime_t( first_quarter ); + kdDebug() << KGlobal::locale()->formatDateTime( fq ) << endl; + + time_t full_moon = JDtoDate( moonphasebylunation( lun, 2 ), 0 ); + QDateTime fm; + fm.setTime_t( full_moon ); + kdDebug() << KGlobal::locale()->formatDateTime( fm ) << endl; + + time_t third_quarter = JDtoDate( moonphasebylunation( lun, 3 ), 0 ); + QDateTime tq; + tq.setTime_t( third_quarter ); + kdDebug() << KGlobal::locale()->formatDateTime( tq ) << endl; + + QDateTime nn; + nn.setTime_t( next_new ); + kdDebug() << KGlobal::locale()->formatDateTime( nn ) << endl; + + QDateTime now; + now.setTime_t( time ); + kdDebug() << KGlobal::locale()->formatDateTime( now ) << endl; + + counter = ln.daysTo( now ); + kdDebug() << "counter " << counter << " " << fm.daysTo( now ) << endl; + + if ( fm.daysTo( now ) == 0 ) { + counter = 14; + tooltip = i18n( "Full Moon" ); + return; + } else if ( counter <= 15 && counter >= 13 ) { + counter = 14 + fm.daysTo( now ); + kdDebug() << "around full moon " << counter << endl; + } + + int diff = fq.daysTo( now ); + if ( diff == 0 ) + counter = 7; + else if ( counter <= 8 && counter >= 6 ) { + counter = 7 + diff; + kdDebug() << "around first quarter " << counter << endl; + } + + diff = ln.daysTo( now ); + if ( diff == 0 ) + counter = 0; + else if ( counter <= 1 || counter >= 28 ) + { + counter = ( 29 + diff ) % 29; + diff = -nn.daysTo( now ); + if ( diff == 0 ) + counter = 0; + else if ( diff < 3 ) + counter = 29 - diff; + kdDebug() << "around new " << counter << " " << diff << endl; + } + + if ( tq.daysTo( now ) == 0 ) + counter = 21; + else if ( counter <= 22 && counter >= 20 ) + { + counter = 21 + tq.daysTo( now ); + kdDebug() << "around third quarter " << counter << endl; + } + + kdDebug() << "counter " << counter << endl; + + assert (counter >= 0 && counter < 29); + + switch (counter) { + case 0: + tooltip = i18n("New Moon"); + return; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + tooltip = i18n("Waxing Crescent (New Moon was yesterday)", "Waxing Crescent (%n days since New Moon)", counter ); + break; + case 7: + tooltip = i18n("First Quarter"); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + tooltip = i18n( "Waxing Gibbous (Tomorrow is Full Moon)", "Waxing Gibbous (%n days to Full Moon)", -fm.daysTo( now ) ); + break; + case 14: + assert( false ); + break; + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + tooltip = i18n("Waning Gibbous (Yesterday was Full Moon)", "Waning Gibbous (%n days since Full Moon)", fm.daysTo( now ) ); + break; + case 21: + tooltip = i18n("Last Quarter"); + break; + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + kdDebug() << "nn.days " << ln.daysTo( now ) << " " << nn.daysTo( now ) << endl; + tooltip = i18n("Waning Crescent (Tomorrow is New Moon)", "Waning Crescent (%n days to New Moon)", -nn.daysTo( now ) ); + break; + default: + kdFatal() << "coolo can't count\n"; + } + + renderGraphic(); + repaint(); +} + +QImage MoonWidget::loadMoon(int index) +{ + if (index == 0) // the new moon has the wrong filename + index = 29; + QString filename = QString("kmoon/pics/moon%1.png").arg(index); + QString path = locate("data", filename); + if (path.isNull()) + kdFatal() << "cound't find " << filename << ". Exiting.\n"; + QImage image(path); + KIconEffect iconeffect; + image=iconeffect.apply(image, KIcon::Panel, KIcon::DefaultState); + return image; +} + +void MoonWidget::setAngle(int value) +{ + _angle = value; + renderGraphic(); + repaint(); +} + +void MoonWidget::setNorthHemi(bool n) +{ + _north = n; + renderGraphic(); + repaint(); +} + +void MoonWidget::setMask(bool value) +{ + _mask = value; + renderGraphic(); + repaint(); +} + +void MoonWidget::paintEvent(QPaintEvent *) +{ + bitBlt(this, 0, 0, &pixmap, 0, 0); +} + +void MoonWidget::resizeEvent(QResizeEvent *) +{ + renderGraphic(); + repaint(); +} + +void MoonWidget::renderGraphic() +{ + if (old_counter == counter && old_w == width() && old_h == height() && + old_angle == _angle && old_north == _north) + return; + old_counter = counter; + old_w = width(); + old_h = height(); + old_north = _north; + QImage im = loadMoon(counter); + assert(!im.isNull()); + im = im.convertDepth(32, 0); + assert(!im.isNull()); + + int mw = QMIN(width(), height()); + QImage dest; + + if (QPixmap::defaultDepth() > 8) { + + if (fabs(_angle)!=0) { // nothing to rotate + //We expand the image 2x before rotating, rotate it, and then average out + //the pixel for better quality + int dmw = 2 * mw; + if (!pixmap.convertFromImage(im.smoothScale(dmw, dmw), 0)) { + return; + } + QWMatrix m; + m.rotate(_angle); + QPixmap rotated = pixmap.xForm(m); + + //Copy the relevant part back to the pixmap + QRegion r(QRect(0, 0, dmw, dmw), QRegion::Ellipse); + QPainter p; + p.begin(&pixmap); + p.fillRect(0, 0, dmw, dmw, Qt::black); + p.setClipRegion(r); + p.drawPixmap(0, 0, rotated, (rotated.width() - dmw) / 2, + (rotated.height() - dmw) / 2, + dmw, dmw); + p.end(); + + //Shrink down to the proper size, averaging from the source + im = pixmap.convertToImage(); + dest = im.copy(0, 0, mw, mw); + for (int y = 0; y < mw; y++) { + QRgb *destline = (QRgb*)dest.scanLine(y); + QRgb *sourceline1 = (QRgb*)im.scanLine(2*y); + QRgb *sourceline2 = (QRgb*)im.scanLine(2*y + 1); + for (int x = 0; x < mw; x++) { + int r = qRed(sourceline1[2*x]) + qRed(sourceline1[2*x+1]); + r = r + qRed(sourceline2[2*x]) + qRed(sourceline2[2*x+1]); + int g = qGreen(sourceline1[2*x]) + qGreen(sourceline1[2*x+1]); + g = g + qGreen(sourceline2[2*x]) + qGreen(sourceline2[2*x+1]); + int b = qBlue(sourceline1[2*x]) + qBlue(sourceline1[2*x+1]); + b = b + qBlue(sourceline2[2*x]) + qBlue(sourceline2[2*x+1]); + destline[x] = qRgb(qRound(r / 4), qRound(g / 4), + qRound(b / 4)); + } + } + } else { + dest = im.smoothScale(mw, mw).convertDepth(32); + } + if (_mask) { + // generate alpha-channel + int dmw = mw*2; + QBitmap dMask(dmw, dmw); + QRegion r(QRect(0, 0, dmw, dmw), QRegion::Ellipse); + QPainter p; + p.begin(&dMask); + p.fillRect(0, 0, dmw, dmw, Qt::white); + p.setClipRegion(r); + p.fillRect(0, 0, dmw, dmw, Qt::black); + p.end(); + QImage Mask2 = dMask.convertToImage().convertDepth(32).smoothScale(mw, mw); + dest.setAlphaBuffer(true); + for (int y = 0; y < mw; y++) { + QRgb *destline = (QRgb*)dest.scanLine(y); + QRgb *sourceline = (QRgb*)Mask2.scanLine(y); + for (int x = 0; x < mw; x++) { + destline[x] = (destline[x] & RGB_MASK)|(qRed(sourceline[x]) << 24); + } + } + } + } else { + dest = im.smoothScale(mw, mw); + } + + if (!_north) + dest = dest.mirror(true, true); + + if (!pixmap.convertFromImage(dest, 0)) { + return; + } + + QToolTip::remove(this); + + QToolTip::add(this, tooltip); +} + + +#include "kmoonwidget.moc" diff --git a/kmoon/kmoonwidget.h b/kmoon/kmoonwidget.h new file mode 100644 index 0000000..474349a --- /dev/null +++ b/kmoon/kmoonwidget.h @@ -0,0 +1,68 @@ +/* + * kmoon - a moon phase indicator + * Copyright (C) 1998,2000 Stephan Kulow + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef KMOON +#define KMOON + +#include +#include +#include +#include +#include +class QPopupMenu; + +class MoonWidget : public QWidget +{ + Q_OBJECT + +public: + MoonWidget(QWidget *parent = 0, const char *name = 0); + ~MoonWidget(); + + void calcStatus( time_t time ); + + int angle() const { return _angle; } + void setAngle(int angle); + + bool northHemi() const { return _north; } + void setNorthHemi(bool b); + + bool mask() const { return _mask; } + void setMask(bool b); + +protected: + int old_w, old_h; + int counter, old_counter; + int _angle, old_angle; + int _mask, old_mask; + bool old_north, _north; + + QPixmap pixmap; + QString tooltip; + + void paintEvent( QPaintEvent *e); + void resizeEvent( QResizeEvent *e); + +private: + QImage loadMoon(int index); + void renderGraphic(); +}; + +#endif diff --git a/kmoon/phases.cpp b/kmoon/phases.cpp new file mode 100644 index 0000000..7fc0f4c --- /dev/null +++ b/kmoon/phases.cpp @@ -0,0 +1,383 @@ +/* This file is part of the kmoon application with explicit permission by the author + Copyright (C) 1996 Christopher Osburn + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +/* +** jd.c: +** 1996/02/11 +** +** Copyright 1996, Christopher Osburn, Lunar Outreach Services, +** Non-commercial usage license granted to all. +** +** convert a Julian Day number to a struct tm +** +** Parameter: +** double jd: Julian day number with fraction of day +** +** Returns: +** struct tm *event_date: Date-time group holding year, month, day, hour, +** and minute of the event +*/ + +#include +#include + +time_t JDtoDate(double jd, struct tm *event_date) +/* convert a Julian Date to a date-time group */ +{ + long a, a1, z, b, c, d, e; + double f, day; + struct tm dummy; + if ( !event_date ) + event_date = &dummy; + + jd += 0.5; + z = (long) jd; + f = jd - z; + + if (z < 2299161) + { + a = z; + } + else + { + a1 = (long) ((z - 1867216.25) / 36524.25); + a = z + 1 + a1 - (long)(a1 / 4); + } + + b = a + 1524; + c = (long)((b - 122.1) / 365.25); + d = (long)(365.25 * c); + e = (long)((b - d)/30.6001); + + day = b - d - (long)(30.6001 * e) + f; + + if (e < 14) + { + event_date->tm_mon = (e - 1) - 1; + } + else + { + event_date->tm_mon = (e - 13) - 1; + } + + if (event_date->tm_mon > (2 - 1)) + { + event_date->tm_year = c - 4716 - 1900; + } + else + { + event_date->tm_year = c - 4715 - 1900; + } + event_date->tm_mday = (int)day; + day -= event_date->tm_mday; + day *= 24; + event_date->tm_hour = (int)day; + day -= event_date->tm_hour; + day *= 60; + event_date->tm_min = (int)day; + day -= event_date->tm_min; + day *= 60; + event_date->tm_sec = (int)day; + + event_date->tm_isdst = -1; + + return mktime(event_date); +} + +double DatetoJD(struct tm *event_date) +/* convert a date-time group to a JD with fraction */ +{ + int y, m; + double d; + int a, b; + double jd; + + y = event_date->tm_year + 1900; + m = event_date->tm_mon + 1; + d = (double)(event_date->tm_mday) + (event_date->tm_hour / 24.0) + + (event_date->tm_min / 1440.0) + (event_date->tm_sec / 86400.0); + + if (m == 1 || m == 2) + { + y--; + m += 12; + } + + a = (int)(y / 100); + b = 2 - a + (int)(a / 4); + + if (y < 1583) + if ((y < 1582) || (m < 10) || ((m == 10) && (d <= 15))) + b = 0; + + jd = (long)(365.25 * (y + 4716)) + (long)(30.6001 * (m+1)) + + d + b - 1524.5; + + return jd; +} + +/* +** misc.h +** 1996/02/11 +** +** Copyright 1996, Christopher Osburn, Lunar Outreach Services, +** Non-commercial usage license granted to all. +** +** Miscellaneous routines for moon phase programs +** +*/ + +#include + +double torad(double x) +/* convert x to radians */ +{ + x = fmod(x, 360.0); /* normalize the angle */ + return ((x) * 0.01745329251994329576); + /* and return the result */ +} + +/* +** moonphase.c +** 1996/02/11 +** +** Copyright 1996, Christopher Osburn, Lunar Outreach Services, +** Non-commercial usage license granted to all. +** +** calculate phase of the moon per Meeus Ch. 47 +** +** Parameters: +** int lun: phase parameter. This is the number of lunations +** since the New Moon of 2000 January 6. +** +** int phi: another phase parameter, selecting the phase of the +** moon. 0 = New, 1 = First Qtr, 2 = Full, 3 = Last Qtr +** +** Return: Apparent JD of the needed phase +*/ + +#include +#include + +double moonphase(double k, int phi) +{ + int i; /* iterator to be named later. Every + program needs an i */ + double T; /* time parameter, Julian Centuries since + J2000 */ + double JDE; /* Julian Ephemeris Day of phase event */ + double E; /* Eccentricity anomaly */ + double M; /* Sun's mean anomaly */ + double M1; /* Moon's mean anomaly */ + double F; /* Moon's argument of latitude */ + double O; /* Moon's longitude of ascenfing node */ + double A[15]; /* planetary arguments */ + double W; /* added correction for quarter phases */ + + T = k / 1236.85; /* (47.3) */ + + /* this is the first approximation. all else is for style points! */ + JDE = 2451550.09765 + (29.530588853 * k) /* (47.1) */ + + T * T * (0.0001337 + T * (-0.000000150 + 0.00000000073 * T)); + + /* these are correction parameters used below */ + E = 1.0 /* (45.6) */ + + T * (-0.002516 + -0.0000074 * T); + M = 2.5534 + 29.10535669 * k /* (47.4) */ + + T * T * (-0.0000218 + -0.00000011 * T); + M1 = 201.5643 + 385.81693528 * k /* (47.5) */ + + T * T * (0.0107438 + T * (0.00001239 + -0.000000058 * T)); + F = 160.7108 + 390.67050274 * k /* (47.6) */ + + T * T * (-0.0016341 * T * (-0.00000227 + 0.000000011 * T)); + O = 124.7746 - 1.56375580 * k /* (47.7) */ + + T * T * (0.0020691 + 0.00000215 * T); + + /* planetary arguments */ + A[0] = 0; /* unused! */ + A[1] = 299.77 + 0.107408 * k - 0.009173 * T * T; + A[2] = 251.88 + 0.016321 * k; + A[3] = 251.83 + 26.651886 * k; + A[4] = 349.42 + 36.412478 * k; + A[5] = 84.66 + 18.206239 * k; + A[6] = 141.74 + 53.303771 * k; + A[7] = 207.14 + 2.453732 * k; + A[8] = 154.84 + 7.306860 * k; + A[9] = 34.52 + 27.261239 * k; + A[10] = 207.19 + 0.121824 * k; + A[11] = 291.34 + 1.844379 * k; + A[12] = 161.72 + 24.198154 * k; + A[13] = 239.56 + 25.513099 * k; + A[14] = 331.55 + 3.592518 * k; + + /* all of the above crap must be made into radians!!! */ + /* except for E... */ + + M = torad(M); + M1 = torad(M1); + F = torad(F); + O = torad(O); + + /* all those planetary arguments, too! */ + for (i=1; i<=14; i++) + A[i] = torad(A[i]); + + /* ok, we have all the parameters, let's apply them to the JDE. + (remember the JDE? this is a program about the JDE...) */ + + switch(phi) + { + /* a special case for each different phase. NOTE!, + I'm not treating these in a 0123 order!!! Pay + attention, there, you! */ + + case 0: /* New Moon */ + JDE = JDE + - 0.40720 * sin (M1) + + 0.17241 * E * sin (M) + + 0.01608 * sin (2.0 * M1) + + 0.01039 * sin (2.0 * F) + + 0.00739 * E * sin (M1 - M) + - 0.00514 * E * sin (M1 + M) + + 0.00208 * E * E * sin (2.0 * M) + - 0.00111 * sin (M1 - 2.0 * F) + - 0.00057 * sin (M1 + 2.0 * F) + + 0.00056 * E * sin (2.0 * M1 + M) + - 0.00042 * sin (3.0 * M1) + + 0.00042 * E * sin (M + 2.0 * F) + + 0.00038 * E * sin (M - 2.0 * F) + - 0.00024 * E * sin (2.0 * M1 - M) + - 0.00017 * sin (O) + - 0.00007 * sin (M1 + 2.0 * M) + + 0.00004 * sin (2.0 * M1 - 2.0 * F) + + 0.00004 * sin (3.0 * M) + + 0.00003 * sin (M1 + M - 2.0 * F) + + 0.00003 * sin (2.0 * M1 + 2.0 * F) + - 0.00003 * sin (M1 + M + 2.0 * F) + + 0.00003 * sin (M1 - M + 2.0 * F) + - 0.00002 * sin (M1 - M - 2.0 * F) + - 0.00002 * sin (3.0 * M1 + M) + + 0.00002 * sin (4.0 * M1); + + break; + + case 2: /* Full Moon */ + JDE = JDE + - 0.40614 * sin (M1) + + 0.17302 * E * sin (M) + + 0.01614 * sin (2.0 * M1) + + 0.01043 * sin (2.0 * F) + + 0.00734 * E * sin (M1 - M) + - 0.00515 * E * sin (M1 + M) + + 0.00209 * E * E * sin (2.0 * M) + - 0.00111 * sin (M1 - 2.0 * F) + - 0.00057 * sin (M1 + 2.0 * F) + + 0.00056 * E * sin (2.0 * M1 + M) + - 0.00042 * sin (3.0 * M1) + + 0.00042 * E * sin (M + 2.0 * F) + + 0.00038 * E * sin (M - 2.0 * F) + - 0.00024 * E * sin (2.0 * M1 - M) + - 0.00017 * sin (O) + - 0.00007 * sin (M1 + 2.0 * M) + + 0.00004 * sin (2.0 * M1 - 2.0 * F) + + 0.00004 * sin (3.0 * M) + + 0.00003 * sin (M1 + M - 2.0 * F) + + 0.00003 * sin (2.0 * M1 + 2.0 * F) + - 0.00003 * sin (M1 + M + 2.0 * F) + + 0.00003 * sin (M1 - M + 2.0 * F) + - 0.00002 * sin (M1 - M - 2.0 * F) + - 0.00002 * sin (3.0 * M1 + M) + + 0.00002 * sin (4.0 * M1); + + break; + + case 1: /* First Quarter */ + case 3: /* Last Quarter */ + JDE = JDE + - 0.62801 * sin (M1) + + 0.17172 * E * sin (M) + - 0.01183 * E * sin (M1 + M) + + 0.00862 * sin (2.0 * M1) + + 0.00804 * sin (2.0 * F) + + 0.00454 * E * sin (M1 - M) + + 0.00204 * E * E * sin (2.0 * M) + - 0.00180 * sin (M1 - 2.0 * F) + - 0.00070 * sin (M1 + 2.0 * F) + - 0.00040 * sin (3.0 * M1) + - 0.00034 * E * sin (2.0 * M1 - M) + + 0.00032 * E * sin (M + 2.0 * F) + + 0.00032 * E * sin (M - 2.0 * F) + - 0.00028 * E * E * sin (M1 + 2.0 * M) + + 0.00027 * E * sin (2.0 * M1 + M) + - 0.00017 * sin (O) + - 0.00005 * sin (M1 - M - 2.0 * F) + + 0.00004 * sin (2.0 * M1 + 2.0 * F) + - 0.00004 * sin (M1 + M + 2.0 * F) + + 0.00004 * sin (M1 - 2.0 * M) + + 0.00003 * sin (M1 + M - 2.0 * F) + + 0.00003 * sin (3.0 * M) + + 0.00002 * sin (2.0 * M1 - 2.0 * F) + + 0.00002 * sin (M1 - M + 2.0 * F) + - 0.00002 * sin (3.0 * M1 + M); + + W = 0.00306 + - 0.00038 * E * cos(M) + + 0.00026 * cos(M1) + - 0.00002 * cos(M1 - M) + + 0.00002 * cos(M1 + M) + + 0.00002 * cos(2.0 * F); + if (phi == 3) + W = -W; + JDE += W; + + break; + + default: /* oops! */ + fprintf(stderr, "The Moon has exploded!\n"); + exit(1); + break; /* unexecuted code */ + } + /* now there are some final correction to everything */ + JDE = JDE + + 0.000325 * sin(A[1]) + + 0.000165 * sin(A[2]) + + 0.000164 * sin(A[3]) + + 0.000126 * sin(A[4]) + + 0.000110 * sin(A[5]) + + 0.000062 * sin(A[6]) + + 0.000060 * sin(A[7]) + + 0.000056 * sin(A[8]) + + 0.000047 * sin(A[9]) + + 0.000042 * sin(A[10]) + + 0.000040 * sin(A[11]) + + 0.000037 * sin(A[12]) + + 0.000035 * sin(A[13]) + + 0.000023 * sin(A[14]); + + return JDE; +} + +#define LUNATION_OFFSET 953 + +double moonphasebylunation(int lun, int phi) +{ + double k; + + k = lun - LUNATION_OFFSET + phi / 4.0; + return moonphase(k, phi); +} + diff --git a/kmoon/pics/Makefile.am b/kmoon/pics/Makefile.am new file mode 100644 index 0000000..1b498cc --- /dev/null +++ b/kmoon/pics/Makefile.am @@ -0,0 +1,13 @@ + +pics_DATA = \ + moon1.png moon10.png moon11.png moon12.png moon13.png \ + moon14.png moon15.png moon16.png moon17.png moon18.png \ + moon19.png moon2.png moon20.png moon21.png moon22.png \ + moon23.png moon24.png moon25.png moon26.png moon27.png \ + moon28.png moon29.png moon3.png moon4.png moon5.png \ + moon6.png moon7.png moon8.png moon9.png + +picsdir = $(kde_datadir)/kmoon/pics + +EXTRA_DIST = $(pics_DATA) + diff --git a/kmoon/pics/moon1.png b/kmoon/pics/moon1.png new file mode 100644 index 0000000..7f2ac91 Binary files /dev/null and b/kmoon/pics/moon1.png differ diff --git a/kmoon/pics/moon10.png b/kmoon/pics/moon10.png new file mode 100644 index 0000000..07c8c65 Binary files /dev/null and b/kmoon/pics/moon10.png differ diff --git a/kmoon/pics/moon11.png b/kmoon/pics/moon11.png new file mode 100644 index 0000000..f03cb68 Binary files /dev/null and b/kmoon/pics/moon11.png differ diff --git a/kmoon/pics/moon12.png b/kmoon/pics/moon12.png new file mode 100644 index 0000000..32eee90 Binary files /dev/null and b/kmoon/pics/moon12.png differ diff --git a/kmoon/pics/moon13.png b/kmoon/pics/moon13.png new file mode 100644 index 0000000..e95e78a Binary files /dev/null and b/kmoon/pics/moon13.png differ diff --git a/kmoon/pics/moon14.png b/kmoon/pics/moon14.png new file mode 100644 index 0000000..60b7980 Binary files /dev/null and b/kmoon/pics/moon14.png differ diff --git a/kmoon/pics/moon15.png b/kmoon/pics/moon15.png new file mode 100644 index 0000000..cb78092 Binary files /dev/null and b/kmoon/pics/moon15.png differ diff --git a/kmoon/pics/moon16.png b/kmoon/pics/moon16.png new file mode 100644 index 0000000..179a207 Binary files /dev/null and b/kmoon/pics/moon16.png differ diff --git a/kmoon/pics/moon17.png b/kmoon/pics/moon17.png new file mode 100644 index 0000000..7326135 Binary files /dev/null and b/kmoon/pics/moon17.png differ diff --git a/kmoon/pics/moon18.png b/kmoon/pics/moon18.png new file mode 100644 index 0000000..174befe Binary files /dev/null and b/kmoon/pics/moon18.png differ diff --git a/kmoon/pics/moon19.png b/kmoon/pics/moon19.png new file mode 100644 index 0000000..38b2c80 Binary files /dev/null and b/kmoon/pics/moon19.png differ diff --git a/kmoon/pics/moon2.png b/kmoon/pics/moon2.png new file mode 100644 index 0000000..2274547 Binary files /dev/null and b/kmoon/pics/moon2.png differ diff --git a/kmoon/pics/moon20.png b/kmoon/pics/moon20.png new file mode 100644 index 0000000..7bc5e87 Binary files /dev/null and b/kmoon/pics/moon20.png differ diff --git a/kmoon/pics/moon21.png b/kmoon/pics/moon21.png new file mode 100644 index 0000000..f1e1f05 Binary files /dev/null and b/kmoon/pics/moon21.png differ diff --git a/kmoon/pics/moon22.png b/kmoon/pics/moon22.png new file mode 100644 index 0000000..a2a408f Binary files /dev/null and b/kmoon/pics/moon22.png differ diff --git a/kmoon/pics/moon23.png b/kmoon/pics/moon23.png new file mode 100644 index 0000000..0c08690 Binary files /dev/null and b/kmoon/pics/moon23.png differ diff --git a/kmoon/pics/moon24.png b/kmoon/pics/moon24.png new file mode 100644 index 0000000..92b6637 Binary files /dev/null and b/kmoon/pics/moon24.png differ diff --git a/kmoon/pics/moon25.png b/kmoon/pics/moon25.png new file mode 100644 index 0000000..a950535 Binary files /dev/null and b/kmoon/pics/moon25.png differ diff --git a/kmoon/pics/moon26.png b/kmoon/pics/moon26.png new file mode 100644 index 0000000..34bd85a Binary files /dev/null and b/kmoon/pics/moon26.png differ diff --git a/kmoon/pics/moon27.png b/kmoon/pics/moon27.png new file mode 100644 index 0000000..ea8f30c Binary files /dev/null and b/kmoon/pics/moon27.png differ diff --git a/kmoon/pics/moon28.png b/kmoon/pics/moon28.png new file mode 100644 index 0000000..f40055c Binary files /dev/null and b/kmoon/pics/moon28.png differ diff --git a/kmoon/pics/moon29.png b/kmoon/pics/moon29.png new file mode 100644 index 0000000..05c06a3 Binary files /dev/null and b/kmoon/pics/moon29.png differ diff --git a/kmoon/pics/moon3.png b/kmoon/pics/moon3.png new file mode 100644 index 0000000..853a007 Binary files /dev/null and b/kmoon/pics/moon3.png differ diff --git a/kmoon/pics/moon4.png b/kmoon/pics/moon4.png new file mode 100644 index 0000000..9d320f8 Binary files /dev/null and b/kmoon/pics/moon4.png differ diff --git a/kmoon/pics/moon5.png b/kmoon/pics/moon5.png new file mode 100644 index 0000000..9fc4623 Binary files /dev/null and b/kmoon/pics/moon5.png differ diff --git a/kmoon/pics/moon6.png b/kmoon/pics/moon6.png new file mode 100644 index 0000000..36c1446 Binary files /dev/null and b/kmoon/pics/moon6.png differ diff --git a/kmoon/pics/moon7.png b/kmoon/pics/moon7.png new file mode 100644 index 0000000..aa91df1 Binary files /dev/null and b/kmoon/pics/moon7.png differ diff --git a/kmoon/pics/moon8.png b/kmoon/pics/moon8.png new file mode 100644 index 0000000..235291d Binary files /dev/null and b/kmoon/pics/moon8.png differ diff --git a/kmoon/pics/moon9.png b/kmoon/pics/moon9.png new file mode 100644 index 0000000..04e084a Binary files /dev/null and b/kmoon/pics/moon9.png differ diff --git a/kmoon/version.h b/kmoon/version.h new file mode 100644 index 0000000..b71eb3b --- /dev/null +++ b/kmoon/version.h @@ -0,0 +1 @@ +static const char version[] = "1.1"; -- cgit v1.2.1