1# A Desktop Planetarium for KDE
2
3KStars is free, open source, cross-platform Astronomy Software.
4
5It provides an accurate graphical simulation of the night sky, from any location on Earth, at any date and time. The display includes up to 100 million stars, 13,000 deep-sky objects,all 8 planets, the Sun and Moon, and thousands of comets, asteroids, supernovae, and satellites.
6
7For students and teachers, it supports adjustable simulation speeds in order to view phenomena that happen over long timescales, the KStars Astrocalculator to predict conjunctions, and many common astronomical calculations. For the amateur astronomer, it provides an observation planner, a sky calendar tool, and an FOV editor to calculate field of view of equipment and display them. Find out interesting objects in the "What's up Tonight" tool, plot altitude vs. time graphs for any object, print high-quality sky charts, and gain access to lots of information and resources to help you explore the universe!
8
9Included with KStars is Ekos astrophotography suite, a complete astrophotography solution that can control all INDI devices including numerous telescopes, CCDs, DSLRs, focusers, filters, and a lot more. Ekos supports highly accurate tracking using online and offline astrometry solver, autofocus and autoguiding capabilities, and capture of single or multiple images using the powerful built in sequence manager.
10
11## Copyright
12
13Copyright (c) 2001 - 2020 by The KStars Team:
14
15KStars is Free Software, released under the GNU Public License. See COPYING for GPL license information.
16
17## Downloads
18
19KStars is available for Windows, MacOS, and Linux. You can download the latest version from [KStars official website](https://edu.kde.org/kstars).
20
21On Linux, it is available for most Linux distributions.
22
23Latest stable version is v3.4.2
24
25## Important URLs and files.
26
27* The [KStars homepage](https://edu.kde.org/kstars)
28* KStars [Git Repository](https://invent.kde.org/education/kstars)
29* KStars [Web Chat](https://webchat.kde.org/#/room/#kstars:kde.org)
30* Forum [where KStars is often discussed](https://indilib.org/forum.html)
31
32## KStars documentation
33
34The KStars handbook can be found in your $(KDEDIR)/share/doc/HTML/<lang>/kstars/
35directory.  You can also easily access it from the Help menu, or by pressing
36the [F1] key, or by visiting https://docs.kde.org/?application=kstars
37Unfortunately, it's a bit out-of-date. We welcome volunteers to help
38update it.
39
40In addition, there are the following README files:
41
42README:             This file; general information
43README.planetmath:  Explanation of algorithms used to compute planet positions
44README.customize:   Advanced customization options
45README.images:      Copyright information for images used in KStars.
46README.i18n:        Instructions for translators
47
48## Development
49
50Code can be cloned, viewed and merge requests can be made via the [KStars repository](https://invent.kde.org/education/kstars). If you are new to remote git repositories, please see the Git Tips section below.
51Note: Previously KStars used Phabricator for its merge requests. That system is no longer in use.
52
53### Integrated Development Environment IDE
54
55If you plan to develop KStars, it is highly recommended to utilize an IDE. You can use any IDE of your choice, but QtCreator(https://www.qt.io/product) or KDevelop(https://www.kdevelop.org) are recommended as they are more suited for Qt/KDE development.
56
57To open KStars in QtCreator, select the CMakeLists.txt file in the KStars source folder and then configure the build location and type.
58
59### Building
60
611. Prerequisite Packages
62
63To build and develop KStars, several packages may be required from your distribution. Here's a list.
64
65* Required dependencies
66    * GNU Make, GCC -- Essential tools for building
67    * cmake -- buildsystem used by KDE
68    * Qt Library > 5.9.0
69    * Several KDE Frameworks: KConfig, KDocTools, KGuiAddons, KWidgetsAddons, KNewStuff, KI18n, KInit, KIO, KXmlGui, KPlotting, KIconThemes
70    * eigen -- linear algebra library
71    * zlib -- compression library
72    * StellarSolver -- see [https://github.com/rlancaste/stellarsolver](https://github.com/rlancaste/stellarsolver)
73
74* Optional dependencies
75    * libcfitsio -- FITS library
76    * libindi -- Instrument Neutral Distributed Interface, for controlling equipment.
77    * xplanet
78    * astrometry.net
79    * libraw
80    * wcslib
81    * libgsl
82    * qtkeychain
83
84
852. Installing Prerequisites
86
87Debian/Ubuntu
88
89The apt-add-respository command is needed for the apt-get's libstellarsolver-dev. Alternatively, you can skip the apt-add-repository, remove the libstellarsolver-dev from the apt-get, and build & install stellarsolver from https://github.com/rlancaste/stellarsolver.
90```
91sudo apt-add-repository ppa:mutlaqja/ppa
92sudo apt-get -y install build-essential cmake git libstellarsolver-dev libeigen3-dev libcfitsio-dev zlib1g-dev libindi-dev extra-cmake-modules libkf5plotting-dev libqt5svg5-dev libkf5xmlgui-dev libkf5kio-dev kinit-dev libkf5newstuff-dev kdoctools-dev libkf5notifications-dev qtdeclarative5-dev libkf5crash-dev gettext libnova-dev libgsl-dev libraw-dev libkf5notifyconfig-dev wcslib-dev libqt5websockets5-dev xplanet xplanet-images qt5keychain-dev libsecret-1-dev breeze-icon-theme
93```
94
95Fedora
96```
97yum install cfitsio-devel eigen3-devel stellarsolver-devel cmake extra-cmake-modules.noarch kf5-kconfig-devel kf5-kdbusaddons-devel kf5-kdoctools-devel kf5-kguiaddons-devel kf5-ki18n-devel kf5-kiconthemes-devel kf5-kinit-devel kf5-kio-devel kf5-kjobwidgets-devel kf5-knewstuff-devel kf5-kplotting-devel kf5-ktexteditor-devel kf5-kwidgetsaddons-devel kf5-kwindowsystem-devel kf5-kxmlgui-devel libindi-devel libindi-static qt5-qtdeclarative-devel qt5-qtmultimedia-devel qt5-qtsvg-devel wcslib-devel xplanet zlib-devel
98```
99
1003. Compiling
101
102Open a console and run in the following commands:
103```
104mkdir -p ~/Projects
105git clone https://invent.kde.org/education/kstars.git
106mkdir -p kstars-build
107cd kstars-build
108cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo ../kstars
109make -j8
110sudo make install
111```
112
113To run KStars, simply type **kstars** in the terminal.
114
115### Code Style
116
117KStars uses [Artistic Style](http://astyle.sourceforge.net) to format all the C++ source files. Please make sure to apply the following astyle rules to any code that is submitted to INDI. On Linux, you can create ***~/.astylerc*** file containing the following rules:
118```
119--style=allman
120--align-reference=name
121--indent-switches
122--indent-modifiers
123--indent-classes
124--pad-oper
125--indent-col1-comments
126--lineend=linux
127--max-code-length=124
128```
129Some IDEs (e.g. QtCreator) support automatic formatting for the code every time you save the file to disk.
130
131### Making Updates to the Handbook
132
133On linux run the following to install the necessary programs:
134
135```
136sudo apt-get install docbook docbook-utils
137```
138
139The source for the handbook is in kstars/doc.
140You can edit those files, include them in commits and MRs like you would c++ files (see below).
141You could figure out the markup by example, or learn from [online doc for docbook](https://opensource.com/article/17/9/docbook).
142In general, it is best to first copy the entire kstars/doc directory to a temporary directory, and edit and generate the handbook there,
143because if you ran meinproc in the main source directory, you would generate many .html files there,
144and you don't want to commit the generated files to your git repository.
145
146```
147cp -pr kstars/doc ~/DOCBOOK
148cd ~/DOCBOOK
149meinproc5 index.docbook
150```
151
152The above should generate html files. Then, in a browser, you can simply open DOCBOOK/index.html and navigate your way to the part you want, e.g. just type something similar to this in the url bar of chrome: file:///home/YOUR_USER_NAME/DOCBOOK/doc/tool-ekos.html
153Make changes to some of the .docbook files in ~/DOCBOOK/*.docbook. Regenerate the html files, and view your changes in the browser, as before. Iterate.
154
155To check syntax, you might want to run:
156
157```
158checkXML5 index.docbook
159```
160
161Once you're happy, copy your modified files back to kstars/doc, and treat the edited/new files as usual with git,
162including your modified files in a new commit and eventually a new merge request.
163
164### Merge Request Descriptions
165
166See the section below, Git Tips, on technical specifics of how to generate a Merge Request.
167In the process of making the request, you will need to describe the request.
168Please use a format similar to [this one](https://invent.kde.org/education/kstars/-/merge_requests/33)
169which has sections for a summary of what was done, what was modified in each file, other relevant notes, and how to test your changes.
170
171### Git Tips
172
173You must be familiar with git to make changes to KStars, and this is not the place for such a tutorial. There
174are many excellent resources for that on the web. The paragraph below, though, will give an overview of one way
175to make a Merge Request, given you already have sufficient git experience to clone KStars, make a local branch,
176modify the code as you like, commit your changes to your local branch, and test your code thoroughly.
177
178Here's one good resource for a [fork-branch-git-workflow to make KStars changes](https://blog.scottlowe.org/2015/01/27/using-fork-branch-git-workflow). The steps below are inspired by that page.
179
180**One-time KStars git environment setup.**
181
182* [Make your KDE identity](https://community.kde.org/Infrastructure/Get_a_Developer_Account)
183* **Login.** Go to the [KStars gitlab page](https://invent.kde.org/education/kstars) and login in the upper right corner.
184* **Fork the project.** Then, still on the KStars gitlab page, Click FORK in the upper right hand corner, to create your own fork of the project.
185* **Copy your URL.** Note the url of your fork. It should be https://invent.kde.org/YOUR_KDE_NAME/kstars
186* **Clone KStars.** Back on your computer run these commands
187    * mkdir -p ~/Projects
188    * cd ~/Projects
189    * git clone https://invent.kde.org/YOUR_KDE_NAME/kstars
190    * cd kstars
191* **Add your upstream.** Add the KStars main repo to your forked repo.
192    * git remote add upstream https://invent.kde.org/education/kstars
193
194You are set up now.
195
196**Steps used for each change.** After the one-time setup (above), the steps below could be used for each new feature submission. In summary, you will make a feature branch in your local repository, make your desired changes there and test, push them to your fork, create a request to merge your fork with the main KStars repo, wait for feedback, and possibly iterate on your changes hoping for approval from an authority.
197
198* **Create your feature branch.**
199    * git checkout -b YOUR_BRANCH_NAME
200* **Make your changes**
201* **Commit your changes**
202    * git commit -a
203* **Push changes to your forked repo.**
204    * git push origin YOUR_BRANCH_NAME
205* **Create a Merge Request**
206    * Use your browser to visit your forked repo at  https://invent.kde.org/YOUR_KDE_NAME/kstars
207    * You should see an option to create a Merge Request for YOUR_BRANCH_NAME. Fill in the details (see the above section).
208    * You should be able to see a new URL dedicated to that Merge Request.
209* **Make Some Changes.** You may get requests to modify some of your code.
210    * If so, you simply go back to your local branch, make and test your changes.
211    * Commit your changes as above, inside your branch, with: git commit -a
212    * Push your branch's changes to your forked repo as above with: git push origin YOUR_BRANCH_NAME
213    * Your changes should automatically be added to your Merge Request. Check the Merge Request's page to be sure.
214    * You may need to rebase your code--see below for details.
215
216**Rebasing your changes.** Others may be making changes to KStars at the same time you are working on your feature.
217Rebasing is updating your version of KStars and your particular changes to make it as if you changed the latest KStars version,
218e.g. reflect changes to the codebase made after you cloned or updated your own KStars copy. This is a significant topic
219you can Google, but the following instructions work most of the time.
220
221Note that this is done before you create your merge request, when you are the only one seeing your code changes.
222Once you have started your merge request, your code is "public" and instead of rebasing, you should follow the merge procedure below.
223
224```
225cd ~/Projects/kstars
226git checkout master
227git pull upstream master  # Get the master from the main KStars repo onto your local clone
228git push origin master    # Then push your updated local clone into your forked repo
229git checkout YOUR_BRANCH_NAME
230git rebase master
231git push origin YOUR_BRANCH_NAME -f
232```
233
234If there are complications with the rebase, git will make suggestions on how to correct the issues.
235
236**Merging others' changes.** Once you submit a merge request, your code can be seen (and edited) by
237others. At this point, though you still may need to update to the latest KStars version, rebasing destroys
238change information and can overwrite what others are doing. Instead it is best to 'merge' in the current
239version of KStars into your code.
240
241```
242cd ~/Projects/kstars
243git checkout master
244git pull upstream master  # Get the master from the main KStars repo onto your local clone
245git push origin master    # Then push your updated local clone into your forked repo
246git checkout YOUR_BRANCH_NAME
247git merge master
248git push origin YOUR_BRANCH_NAME
249```
250
251The differences from the rebase section are the last 2 commands: 'git merge master' is used instead of 'git rebase master'.
252Also the 'git push' doesn't use the -f option. The first time you run the 'git push',
253you may be asked by git to add 'set-upstream origin' to the command. In that case, follow those instructions.
254
255If you follow this procedure, you will find a new 'merge commit' added to your branch's git log.
256
257
258**Your next change**. Once your Merge Request is complete (and possibly integrated into KStars), you may wish to move on and develop again.
259The next change will use another (new) feature branch, and the first feature branch could be deleted.
260You may want to run the following regularly to keep your master branch up-to-date with KStars.
261```
262cd ~/Projects/kstars
263git checkout master
264git pull upstream master  # Get the master from the main KStars repo onto your local clone
265git push origin master    # Then push your updated local clone into your forked repo
266```
267
268## Writing Tests
269Tests are stored in the `Tests` folder and use QTest as support framework:
270* Unitary tests can be found in `auxiliary`, `capture`, `fitsviewer`, etc. They try to verify the behavior
271  of a minimal set of classes, and are support for feature development.
272* UI tests can be found in `kstars_lite_ui` and `kstars_ui`. They execute use cases as the end-user would do from the user
273  interface, and focus on availability of visual feedback and stability of procedures.
274
275### Writing Unitary Tests
2761. Decide where your new unitary test will reside in `Tests`.
277KStars classes should live in a folder matching their origin: for instance, auxiliary class tests live in `auxiliary`.
278Find a suitable place for your test, based on the part of the system that is being tested.
279As an example, a folder named `thatkstarscategory`.
280
2812. Create a new unitary test class, or copy-paste an existing unitary test to a new one.
282Check `Tests/kstars_ui_tests/kstars_ui_tests.h` as an example.
283Name the `.h` and `.cpp` files as "test[lowercase kstars class]" (for instance "testthatkstarsclass"), and update them to match the following:
284```
285/* [Author+Licence header] */
286#ifndef TESTTHATKSTARSCLASS_H
287#define TESTTHATKSTARSCLASS_H
288
289#include <QtTest>
290#include <QObject>
291
292class TestThatKStarsClass: public QObject
293{
294    Q_OBJECT
295public:
296    explicit TestThatKStarsClass(QObject *parent = null);
297
298private slots:
299    void initTestCase();                    // Will trigger once at beginning
300    void cleanupTestCase();                 // Will trigger once at end
301
302    void init();                            // Will trigger before each test
303    void cleanup();                         // Will trigger after each test
304
305    void testThisParticularFunction_data(); // Data fixtures for the test function (Qt 5.9+)
306    void testThisParticularFunction();      // Test function
307}
308#endif // TESTTHATKSTARSCLASS_H
309```
310```
311/* [Author+Licence header] */
312#include "testthatkstarsclass.h"
313TestThatKStarsClass::TestThatKStarsClass(QObject* parent): QObject(parent) {}
314TestThatKStarsClass::initTestCase() {}
315TestThatKStarsClass::cleanupTestCase() {}
316TestThatKStarsClass::init() {}
317TestThatKStarsClass::cleanup() {}
318
319TestThatKStarsClass::testThisParticularFunction_data()
320{
321    // If needed, add data fixtures with QTest::AddColumn/QTest::AddRow, each will trigger testThisParticularFunction
322}
323
324TestThatKStarsClass::testThisParticularFunction()
325{
326    // Write your tests here, eventually using QFETCH to retrieve the current data fixture
327}
328
329QTEST_GUILESS_MAIN(TestThatKStarsClass);
330```
331You can use a single file to hold both declaration and definition, but you will need to `#include "testthatkstarsclass.moc"` between the declaration and the definition.
332
3333. Update the CMake configuration to add your test.
334If you created a new folder, create a new `CMakeLists.txt` to add your test:
335```
336ADD_EXECUTABLE( testthatkstarsclass testthatkstarsclass.cpp )
337TARGET_LINK_LIBRARIES( testthatkstarsclass ${TEST_LIBRARIES})
338ADD_TEST( NAME ThatKStarsClassTest COMMAND testthatkstarsclass )
339```
340Have the `CMakeLists.txt` residing one folder higher in the filesystem include that `CMakeLists.txt` by adding:
341```
342include_directories(
343    ...
344    ${kstars_SOURCE_DIR}/kstars/path/to/the/folder/of/the/kstars/class/you/are/testing
345)
346...
347add_subdirectory(thatkstarscategory)
348```
349Make sure you add your `add_subdirectory` in the right dependency group. Ekos tests require `INDI_FOUND` for instance.
350
3514. Write your tests
352Make sure you document behavior with your tests. If you happen to find a bug, don't fix it, mark it with an `QEXPECT_FAIL` macro.
353The test will document the incorrect behavior while the bug is alive, and will fail when the bug is fixed. Then only after that the test may be updated.
354Also pay attention to Qt library version support. For instance, data fixtures require Qt 5.9+.
355
356### Writing User Interface Tests
357
358Follow the same steps as for unitary tests, but locate your test classes in `kstars_ui_tests`.
359
360One important thing about UI tests is that they must all use `QStandardPaths::setTestModeEnabled(true)`, so that they execute with a separate user
361configuration that is initially blank. User interface tests thus require a preliminary setup to function properly, such as using the new configuration
362wizard or setting the geographical location up. For this reason, you need to add the execution of your test in `Tests/kstars_ui_tests/kstars_ui_tests.cpp`,
363in `main()`, **after** the execution of `TestKStarsStartup`.
364
365A second important thing about QTest generally is that test functions have no return code. One therefore needs to write macros to factor duplicated code.
366You will find many existing macros in the header files of `kstars_ui_tests` test classes, to retrieve gadgets, to click buttons or to fill `QComboBox` widgets...
367
368A third important thing about the KStars interface is that it mixes KDE and Qt UI elements. Thus, sometimes tests require verification code to be moved
369to a `QTimer::singleShot` call, and sometimes even clicking on a button has to be made asynchronous for the test to remain in control (modal dialogs).
370Fortunately, these hacks do not alter the execution of the tested code.
371
372When testing, you need to make sure you always use elements that the end-user is able to use. Of course, if a test requires a setup that is not actually part of the
373interesting calls, you may hack a direct call. For instance, some Ekos tests requiring the Telescope Simulator to be pointing at a specific location use
374`QVERIFY(Ekos::Manager::Instance()->mountModule()->sync(ra,dec))`. Remember that sometimes you need to leave time for asynchronous signals to be emitted and caught.
375
376## Credits
377### The KStars Team
378#### Original Author
379Jason Harris <kstars@30doradus.org>
380#### Current Maintainer
381Jasem Mutlaq <mutlaqja@ikarustech.com>
382#### Contributors (Alphabetical)
383* Akarsh Simha <akarsh.simha@kdemail.net>
384* Alexey Khudyakov <alexey.skladnoy@gmail.com>
385* Artem Fedoskin <afedoskin3@gmail.com>
386* Carsten Niehaus <cniehaus@kde.org>
387* Chris Rowland <chris.rowland@cherryfield.me.uk>
388* Csaba Kertesz <csaba.kertesz@gmail.com>
389* Eric Dejouhanet <eric.dejouhanet@gmail.com>
390* Harry de Valence <hdevalence@gmail.com>
391* Heiko Evermann <heiko@evermann.de>
392* Hy Murveit <murveit@gmail.com>
393* James Bowlin <bowlin@mindspring.com>
394* Jérôme Sonrier <jsid@emor3j.fr.eu.org>
395* Mark Hollomon <mhh@mindspring.com>
396* Martin Piskernig <martin.piskernig@stuwo.at>
397* Médéric Boquien <mboquien@free.fr>
398* Pablo de Vicente <pvicentea@wanadoo.es>
399* Prakash Mohan <prakash.mohan@kdemail.net>
400* Rafał Kułaga <rl.kulaga@gmail.com>
401* Rishab Arora <ra.rishab@gmail.com>
402* Robert Lancaster <rlancaste@gmail.com>
403* Samikshan Bairagya <samikshan@gmail.com>
404* Thomas Kabelmann <tk78@gmx.de>
405* Valentin Boettcher <hiro@protagon.space>
406* Victor Cărbune <victor.carbune@kdemail.net>
407* Vincent Jagot <vincent.jagot@free.fr>
408* Wolfgang Reissenberger <sterne-jaeger@t-online.de>
409* Yuri Chornoivan <yurchor@ukr.net>
410
411### Data Sources:
412
413 Most of the catalog data came from the Astronomical Data Center, run by
414 NASA.  The website is:
415 http://adc.gsfc.nasa.gov/
416
417 NGC/IC data is compiled by Christian Dersch from OpenNGC database.
418 https://github.com/mattiaverga/OpenNGC (CC-BY-SA-4.0 license)
419
420 Supernovae data is from the Open Supernova Catalog project at https://sne.space
421 Please refer to the published paper here: http://adsabs.harvard.edu/abs/2016arXiv160501054G
422
423 KStars links to the excellent image collections and HTML pages put together
424 by the Students for the Exploration and Development of Space, at:
425 http://www.seds.org
426
427 KStars links to the online Digitized Sky Survey images, which you can
428 query at:
429 http://archive.stsci.edu/cgi-bin/dss_form
430
431 KStars links to images from the HST Heritage project, and from HST
432 press releases:
433 http://heritage.stsci.edu
434 http://oposite.stsci.edu/pubinfo/pr.html
435
436 KStars links to images from the Advanced Observer Program at
437 Kitt Peak National Observatory.  If you are interested in astrophotography,
438 you might consider checking out their program:
439 http://www.noao.edu/outreach/aop/
440
441 Credits for each image used in the program are listed in README.images
442
443
444# Original Acknowledgement from the Project Founder
445
446 KStars is a labor of love.  It started as a personal hobby of mine, but
447 very soon after I first posted the code on Sourceforge, it started to
448 attract other developers.  I am just completely impressed and gratified
449 by my co-developers.  I couldn't ask for a more talented, friendly crew.
450 It goes without saying that KStars would be nowhere near what it is today
451 without their efforts.  Together, we've made something we can all be
452 proud of.
453
454 We used (primarily) two books as a guide in writing the algorithms used
455 in KStars:
456 + "Practical Astronomy With Your Calculator" by Peter Duffett-Smith
457 + "Astronomical Algorithms" by Jean Meeus
458
459 Thanks to the developers of Qt and KDE whose peerless API made KStars
460 possible.  Thanks also to the tireless efforts of the KDE translation
461 teams, who bring KStars to a global audience.
462
463 Thanks to everyone at the KDevelop message boards and on irc.kde.org,
464 for answering my frequent questions.
465
466 Thanks also to the many users who have submitted bug reports or other
467 feedback.
468
469
470You're still reading this? :)
471Well, that's about it.  I hope you enjoy KStars!
472
473Jason Harris
474kstars@30doradus.org
475
476KStars Development Mailing list
477kstars-devel@kde.org
478
479Send us ideas and feedback!
480