Merge lp:~stellarium/stellarium/toastImages into lp:stellarium

Proposed by Alexander Wolf
Status: Merged
Merged at revision: 8858
Proposed branch: lp:~stellarium/stellarium/toastImages
Merge into: lp:stellarium
Diff against target: 2224 lines (+1671/-115)
32 files modified
data/gui/guiRes.qrc (+2/-0)
src/CMakeLists.txt (+6/-1)
src/core/MultiLevelJsonBase.cpp (+1/-1)
src/core/StelApp.cpp (+6/-1)
src/core/StelLocationMgr.cpp (+1/-1)
src/core/StelSkyLayerMgr.cpp (+1/-0)
src/core/StelSphereGeometry.cpp (+5/-0)
src/core/StelTexture.cpp (+6/-4)
src/core/StelTexture.hpp (+1/-1)
src/core/StelTextureMgr.cpp (+1/-1)
src/core/StelToast.cpp (+235/-0)
src/core/StelToast.hpp (+114/-0)
src/core/StelToastGrid.cpp (+177/-0)
src/core/StelToastGrid.hpp (+90/-0)
src/core/StelUtils.cpp (+17/-0)
src/core/StelUtils.hpp (+3/-0)
src/core/modules/ConstellationMgr.cpp (+1/-1)
src/core/modules/ToastMgr.cpp (+97/-0)
src/core/modules/ToastMgr.hpp (+53/-0)
src/gui/ConfigurationDialog.cpp (+8/-11)
src/gui/ConfigurationDialog.hpp (+0/-2)
src/gui/StelGui.cpp (+31/-0)
src/gui/StelGui.hpp (+9/-0)
src/gui/configurationDialog.ui (+101/-91)
util/DSSToStellarium/UTdssUtils.py (+35/-0)
util/DSSToStellarium/createUpperToastLevels.py (+81/-0)
util/DSSToStellarium/dssUtils.py (+169/-0)
util/DSSToStellarium/generateFullPlate.py (+159/-0)
util/DSSToStellarium/prepareAllPlates.py (+117/-0)
util/DSSToStellarium/readme.txt (+33/-0)
util/toastForShape/main.cpp (+38/-0)
util/toastForShape/toastForShape.pro (+73/-0)
To merge this branch: bzr merge lp:~stellarium/stellarium/toastImages
Reviewer Review Type Date Requested Status
gzotti Approve
Guillaume Chereau Pending
Fabien Chéreau Pending
Review via email: mp+310716@code.launchpad.net
To post a comment you must log in.
Revision history for this message
gzotti (georg-zotti) wrote :

Works like a charm as long as network is good.

Maybe fix following: When disabling network (tset with aircraft mode on notebook), and reenabling, re-establish connection? Not sure what happens currently, network stays disabled. What about short network interruptions - would we have to completely restart Stellarium (and break connection to telescope etc.) to re-enable? It may be acceptable to toggle DSS off/on to reconnect. Maybe give screen notice "DSS: network unavailable" or such?

Things to possibly consider:

Fix TODOs (links) in ToastMgr::init(), and host data at stellarium.org?
Explain what TOAST actually means?
We should be prepared to answer questions about installing data locally (for use at off-line observing sites! Either private PCs or data on an in-house server.) (source, legal state, bandwidth, instructions?)
A chapter in the Guide should explain all this! (Can be added after merge, though.)

review: Needs Fixing
Revision history for this message
Alexander Wolf (alexwolf) wrote :

TOAST is "tessellated octahedral adaptive subdivision transform" (details: https://arxiv.org/pdf/1505.02291.pdf) + see section "2.3.2.8.1 The TOAST Projection" (skyview.gsfc.nasa.gov/current/docs/skyviewinajar.html)

TODOs - I hope Fabien can help with it (I can't add/change DNS names).

Network behaviour: it's more to the StelTexture class behaviour

Revision history for this message
gzotti (georg-zotti) wrote :

Thanks for the paper. This must be referenced in the Guide chapter to be written.

So this network behaviour problem must then become a "wishlist bug" for StelTexture, and should not impede branch merge.

Then it's OK from my side :-)

review: Approve
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Offline mode: full collection of DSS has a size 112GiB and it can be problematic to the usage by many users.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'data/gui/btToastSurvey-off.png'
0Binary files data/gui/btToastSurvey-off.png 1970-01-01 00:00:00 +0000 and data/gui/btToastSurvey-off.png 2016-11-13 10:24:15 +0000 differ0Binary files data/gui/btToastSurvey-off.png 1970-01-01 00:00:00 +0000 and data/gui/btToastSurvey-off.png 2016-11-13 10:24:15 +0000 differ
=== added file 'data/gui/btToastSurvey-on.png'
1Binary files data/gui/btToastSurvey-on.png 1970-01-01 00:00:00 +0000 and data/gui/btToastSurvey-on.png 2016-11-13 10:24:15 +0000 differ1Binary files data/gui/btToastSurvey-on.png 1970-01-01 00:00:00 +0000 and data/gui/btToastSurvey-on.png 2016-11-13 10:24:15 +0000 differ
=== modified file 'data/gui/guiRes.qrc'
--- data/gui/guiRes.qrc 2015-12-05 17:34:59 +0000
+++ data/gui/guiRes.qrc 2016-11-13 10:24:15 +0000
@@ -88,6 +88,8 @@
88 <file>btConstellationLines-on.png</file>88 <file>btConstellationLines-on.png</file>
89 <file>btDSS-off.png</file>89 <file>btDSS-off.png</file>
90 <file>btDSS-on.png</file>90 <file>btDSS-on.png</file>
91 <file>btToastSurvey-off.png</file>
92 <file>btToastSurvey-on.png</file>
91 <file>btEquatorialGrid-off.png</file>93 <file>btEquatorialGrid-off.png</file>
92 <file>btEquatorialGrid-on.png</file>94 <file>btEquatorialGrid-on.png</file>
93 <file>btEquatorialMount-off.png</file>95 <file>btEquatorialMount-off.png</file>
9496
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-11-05 13:35:49 +0000
+++ src/CMakeLists.txt 2016-11-13 10:24:15 +0000
@@ -153,6 +153,10 @@
153 core/TrailGroup.cpp153 core/TrailGroup.cpp
154 core/RefractionExtinction.hpp154 core/RefractionExtinction.hpp
155 core/RefractionExtinction.cpp155 core/RefractionExtinction.cpp
156 core/StelToast.hpp
157 core/StelToast.cpp
158 core/StelToastGrid.hpp
159 core/StelToastGrid.cpp
156 core/StelActionMgr.hpp160 core/StelActionMgr.hpp
157 core/StelActionMgr.cpp161 core/StelActionMgr.cpp
158 core/StelProgressController.hpp162 core/StelProgressController.hpp
@@ -249,6 +253,8 @@
249 core/modules/StarMgr.hpp253 core/modules/StarMgr.hpp
250 core/modules/StarWrapper.cpp254 core/modules/StarWrapper.cpp
251 core/modules/StarWrapper.hpp255 core/modules/StarWrapper.hpp
256 core/modules/ToastMgr.hpp
257 core/modules/ToastMgr.cpp
252 core/modules/ZoneArray.cpp258 core/modules/ZoneArray.cpp
253 core/modules/ZodiacalLight.hpp259 core/modules/ZodiacalLight.hpp
254 core/modules/ZodiacalLight.cpp260 core/modules/ZodiacalLight.cpp
@@ -314,7 +320,6 @@
314SET(stellarium_RES ${CMAKE_SOURCE_DIR}/data/mainRes.qrc)320SET(stellarium_RES ${CMAKE_SOURCE_DIR}/data/mainRes.qrc)
315QT5_ADD_RESOURCES(stellarium_RES_CXX ${stellarium_RES})321QT5_ADD_RESOURCES(stellarium_RES_CXX ${stellarium_RES})
316322
317
318#############################################################################################323#############################################################################################
319############################# Standard GUI plugin compilation ###############################324############################# Standard GUI plugin compilation ###############################
320#############################################################################################325#############################################################################################
321326
=== modified file 'src/core/MultiLevelJsonBase.cpp'
--- src/core/MultiLevelJsonBase.cpp 2014-06-12 15:47:22 +0000
+++ src/core/MultiLevelJsonBase.cpp 2016-11-13 10:24:15 +0000
@@ -169,7 +169,7 @@
169 }169 }
170 Q_ASSERT(httpReply==NULL);170 Q_ASSERT(httpReply==NULL);
171 QNetworkRequest req(qurl);171 QNetworkRequest req(qurl);
172 req.setRawHeader("User-Agent", StelUtils::getApplicationName().toLatin1());172 req.setRawHeader("User-Agent", StelUtils::getUserAgentString().toLatin1());
173 httpReply = getNetworkAccessManager().get(req);173 httpReply = getNetworkAccessManager().get(req);
174 //qDebug() << "Started downloading " << httpReply->request().url().path();174 //qDebug() << "Started downloading " << httpReply->request().url().path();
175 Q_ASSERT(httpReply->error()==QNetworkReply::NoError);175 Q_ASSERT(httpReply->error()==QNetworkReply::NoError);
176176
=== modified file 'src/core/StelApp.cpp'
--- src/core/StelApp.cpp 2016-10-23 17:09:45 +0000
+++ src/core/StelApp.cpp 2016-11-13 10:24:15 +0000
@@ -37,9 +37,9 @@
37#include "StelIniParser.hpp"37#include "StelIniParser.hpp"
38#include "StelProjector.hpp"38#include "StelProjector.hpp"
39#include "StelLocationMgr.hpp"39#include "StelLocationMgr.hpp"
40#include "ToastMgr.hpp"
40#include "StelActionMgr.hpp"41#include "StelActionMgr.hpp"
41#include "StelPropertyMgr.hpp"42#include "StelPropertyMgr.hpp"
42
43#include "StelProgressController.hpp"43#include "StelProgressController.hpp"
44#include "StelModuleMgr.hpp"44#include "StelModuleMgr.hpp"
45#include "StelLocaleMgr.hpp"45#include "StelLocaleMgr.hpp"
@@ -457,6 +457,11 @@
457 skyImageMgr->init();457 skyImageMgr->init();
458 getModuleMgr().registerModule(skyImageMgr);458 getModuleMgr().registerModule(skyImageMgr);
459459
460 // Toast surveys
461 ToastMgr* toasts = new ToastMgr();
462 toasts->init();
463 getModuleMgr().registerModule(toasts);
464
460 // Init audio manager465 // Init audio manager
461 audioMgr = new StelAudioMgr();466 audioMgr = new StelAudioMgr();
462467
463468
=== modified file 'src/core/StelLocationMgr.cpp'
--- src/core/StelLocationMgr.cpp 2016-10-25 15:39:06 +0000
+++ src/core/StelLocationMgr.cpp 2016-11-13 10:24:15 +0000
@@ -356,7 +356,7 @@
356{356{
357 QNetworkRequest req( QUrl( QString("http://freegeoip.net/json/") ) );357 QNetworkRequest req( QUrl( QString("http://freegeoip.net/json/") ) );
358 req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);358 req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
359 req.setRawHeader("User-Agent", StelUtils::getApplicationName().toLatin1());359 req.setRawHeader("User-Agent", StelUtils::getUserAgentString().toLatin1());
360 QNetworkReply* networkReply=StelApp::getInstance().getNetworkAccessManager()->get(req);360 QNetworkReply* networkReply=StelApp::getInstance().getNetworkAccessManager()->get(req);
361 connect(networkReply, SIGNAL(finished()), this, SLOT(changeLocationFromNetworkLookup()));361 connect(networkReply, SIGNAL(finished()), this, SLOT(changeLocationFromNetworkLookup()));
362}362}
363363
=== modified file 'src/core/StelSkyLayerMgr.cpp'
--- src/core/StelSkyLayerMgr.cpp 2016-06-14 14:56:19 +0000
+++ src/core/StelSkyLayerMgr.cpp 2016-11-13 10:24:15 +0000
@@ -69,6 +69,7 @@
69 qWarning() << "ERROR while loading nebula texture set default";69 qWarning() << "ERROR while loading nebula texture set default";
70 else70 else
71 insertSkyImage(path);71 insertSkyImage(path);
72
72 QSettings* conf = StelApp::getInstance().getSettings();73 QSettings* conf = StelApp::getInstance().getSettings();
73 conf->beginGroup("skylayers");74 conf->beginGroup("skylayers");
74 foreach (const QString& key, conf->childKeys())75 foreach (const QString& key, conf->childKeys())
7576
=== modified file 'src/core/StelSphereGeometry.cpp'
--- src/core/StelSphereGeometry.cpp 2016-07-23 05:23:41 +0000
+++ src/core/StelSphereGeometry.cpp 2016-11-13 10:24:15 +0000
@@ -1314,6 +1314,11 @@
1314 {1314 {
1315 return SphericalRegionP(new SphericalPolygon(pathFromQVariantList(l)));1315 return SphericalRegionP(new SphericalPolygon(pathFromQVariantList(l)));
1316 }1316 }
1317 else if (code=="CONVEX_POLYGON")
1318 {
1319 return SphericalRegionP(new SphericalConvexPolygon(singleContourFromQVariantList(l.at(1).toList())));
1320 }
1321
1317 Q_ASSERT(0);1322 Q_ASSERT(0);
1318 return EmptySphericalRegion::staticInstance;1323 return EmptySphericalRegion::staticInstance;
1319}1324}
13201325
=== modified file 'src/core/StelTexture.cpp'
--- src/core/StelTexture.cpp 2016-10-11 14:47:05 +0000
+++ src/core/StelTexture.cpp 2016-11-13 10:24:15 +0000
@@ -57,10 +57,12 @@
57 }57 }
58 id = 0;58 id = 0;
59 }59 }
60 if (networkReply != NULL)60 if (networkReply)
61 {61 {
62 networkReply->abort();62 networkReply->abort();
63 networkReply->deleteLater();63 //networkReply->deleteLater();
64 delete networkReply;
65 networkReply = NULL;
64 }66 }
65 if (loader != NULL) {67 if (loader != NULL) {
66 delete loader;68 delete loader;
@@ -124,9 +126,9 @@
124 QNetworkRequest req = QNetworkRequest(QUrl(fullPath));126 QNetworkRequest req = QNetworkRequest(QUrl(fullPath));
125 // Define that preference should be given to cached files (no etag checks)127 // Define that preference should be given to cached files (no etag checks)
126 req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);128 req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
127 req.setRawHeader("User-Agent", StelUtils::getApplicationName().toLatin1());129 req.setRawHeader("User-Agent", StelUtils::getUserAgentString().toLatin1());
128 networkReply = StelApp::getInstance().getNetworkAccessManager()->get(req);130 networkReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
129 connect(networkReply, SIGNAL(finished()), this, SLOT(onNetworkReply()));131 connect(networkReply, SIGNAL(finished()), this, SLOT(onNetworkReply()));
130 return false;132 return false;
131 }133 }
132 // The network connection is still running.134 // The network connection is still running.
133135
=== modified file 'src/core/StelTexture.hpp'
--- src/core/StelTexture.hpp 2015-02-06 19:40:02 +0000
+++ src/core/StelTexture.hpp 2016-11-13 10:24:15 +0000
@@ -147,7 +147,7 @@
147147
148148
149 //! The URL where to download the file149 //! The URL where to download the file
150 QString fullPath;150 QString fullPath;
151151
152 //! True when something when wrong in the loading process152 //! True when something when wrong in the loading process
153 bool errorOccured;153 bool errorOccured;
154154
=== modified file 'src/core/StelTextureMgr.cpp'
--- src/core/StelTextureMgr.cpp 2015-03-04 18:42:24 +0000
+++ src/core/StelTextureMgr.cpp 2016-11-13 10:24:15 +0000
@@ -67,7 +67,7 @@
6767
68 StelTextureSP tex = StelTextureSP(new StelTexture());68 StelTextureSP tex = StelTextureSP(new StelTexture());
69 tex->loadParams = params;69 tex->loadParams = params;
70 tex->fullPath = url;70 tex->fullPath = url;
71 if (!lazyLoading)71 if (!lazyLoading)
72 {72 {
73 tex->bind();73 tex->bind();
7474
=== added file 'src/core/StelToast.cpp'
--- src/core/StelToast.cpp 1970-01-01 00:00:00 +0000
+++ src/core/StelToast.cpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,235 @@
1/*
2 * Stellarium
3 * Copyright (C) 2010 Guillaume Chereau
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <QtOpenGL>
21#include "StelApp.hpp"
22#include "StelCore.hpp"
23#include "StelPainter.hpp"
24#include "StelTexture.hpp"
25#include "StelTextureMgr.hpp"
26#include "StelToast.hpp"
27
28ToastTile::ToastTile(QObject* parent, int level, int x, int y)
29 : QObject(parent), level(level), x(x), y(y), empty(false), ready(false), texture(NULL), texFader(NULL)
30{
31 Q_ASSERT(level <= getGrid()->getMaxLevel());
32 const ToastSurvey* survey = getSurvey();
33 // create the texture
34 imagePath = survey->getTilePath(level, x, y);
35
36 if (level==0)
37 {
38 boundingCap.n=Vec3d(1,0,0);
39 boundingCap.d=-1.;
40 }
41 const QVector<Vec3d>& pts = getGrid()->getPolygon(level, x, y);
42 Vec3d n = pts.at(0);
43 n+=pts.at(1);
44 n+=pts.at(2);
45 n+=pts.at(3);
46 n.normalize();
47 boundingCap.n=n;
48 if (level==1)
49 boundingCap.d=0;
50 else
51 boundingCap.d=qMin(qMin(n*pts.at(0), n*pts.at(1)), qMin(n*pts.at(2), n*pts.at(3)));
52}
53
54const ToastGrid* ToastTile::getGrid() const
55{
56 return getSurvey()->getGrid();
57}
58
59
60const ToastSurvey* ToastTile::getSurvey() const
61{
62 // the parent can either be a ToastSurvey either be a ToastTile
63 ToastSurvey* ret = qobject_cast<ToastSurvey*>(parent());
64 if (ret)
65 return ret;
66 ToastTile* tile = qobject_cast<ToastTile*>(parent());
67 Q_ASSERT(tile);
68 return tile->getSurvey();
69}
70
71
72bool ToastTile::isVisible(const SphericalCap& viewportShape, int maxVisibleLevel) const
73{
74 if (empty)
75 return false;
76 if (level == 0)
77 return true;
78 if (level > maxVisibleLevel)
79 return false;
80 return viewportShape.intersects(boundingCap);
81}
82
83bool ToastTile::isCovered(const SphericalCap& viewportShape) const
84{
85 // The tile is covered if we have at least one visible child and all the visible children are all ready to be drawn.
86 int nbVisibleChildren = 0;
87 foreach (const ToastTile* child, subTiles)
88 {
89 if (!viewportShape.intersects(child->boundingCap))
90 continue;
91 nbVisibleChildren++;
92 if (!child->ready || child->texFader->state()==QTimeLine::Running)
93 return false;
94 }
95 return nbVisibleChildren > 0;
96}
97
98
99void ToastTile::prepareDraw()
100{
101 Q_ASSERT(!empty);
102
103 if (texture.isNull())
104 {
105 //qDebug() << "load texture" << imagePath;
106 StelTextureMgr& texMgr=StelApp::getInstance().getTextureManager();
107 texture = texMgr.createTextureThread(imagePath, StelTexture::StelTextureParams(true));
108 }
109 if (texture.isNull() || (!texture->isLoading() && !texture->canBind() && !texture->getErrorMessage().isEmpty()))
110 {
111 if (!texture.isNull())
112 qDebug() << "can't get texture" << imagePath << texture->getErrorMessage();
113 empty = true;
114 return;
115 }
116 if (!texture->canBind())
117 return;
118 // Get the opengl arrays
119 if (vertexArray.empty())
120 {
121 int ml = qMin(qMax(3, level+1), getGrid()->getMaxLevel());
122 vertexArray = getGrid()->getVertexArray(level, x, y, ml);
123 textureArray = getGrid()->getTextureArray(level, x, y, ml);
124 indexArray = getGrid()->getTrianglesIndex(level, x, y, ml);
125 }
126
127 if (subTiles.isEmpty() && level < getSurvey()->getMaxLevel())
128 {
129 //qDebug() << "Create children";
130 // Create the children
131 for (int i = 0; i < 2; ++i)
132 for (int j = 0; j < 2; ++j)
133 subTiles.append(new ToastTile(this, level + 1, 2 * this->x + i, 2 * this->y + j));
134 Q_ASSERT(subTiles.size() == 4);
135 }
136 ready = true;
137}
138
139
140void ToastTile::drawTile(StelPainter* sPainter)
141{
142 if (!ready)
143 prepareDraw();
144
145 // Still not ready
146 if (texture.isNull() || !texture->bind())
147 return;
148
149 if (!texFader)
150 {
151 texFader = new QTimeLine(1000, this);
152 texFader->start();
153 }
154
155 if (texFader->state()==QTimeLine::Running)
156 {
157 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
158 glEnable(GL_BLEND);
159 sPainter->setColor(1,1,1, texFader->currentValue());
160 }
161 else
162 {
163 glDisable(GL_BLEND);
164 sPainter->setColor(1, 1, 1, 1);
165 }
166
167 sPainter->enableTexture2d(true);
168 Q_ASSERT(vertexArray.size() == textureArray.size());
169
170 glEnable(GL_CULL_FACE);
171 // sPainter.drawArrays(GL_TRIANGLES, vertexArray.size(), vertexArray.data(), textureArray.data(), NULL, NULL, indexArray.size(), indexArray.constData());
172 sPainter->setArrays(vertexArray.constData(), textureArray.constData());
173 sPainter->drawFromArray(StelPainter::Triangles, indexArray.size(), 0, true, indexArray.constData());
174 glDisable(GL_CULL_FACE);
175
176// SphericalConvexPolygon poly(getGrid()->getPolygon(level, x, y));
177// sPainter->enableTexture2d(false);
178// sPainter->drawSphericalRegion(&poly, StelPainter::SphericalPolygonDrawModeBoundary);
179}
180
181
182void ToastTile::draw(StelPainter* sPainter, const SphericalCap& viewportShape, int maxVisibleLevel)
183{
184 if (!isVisible(viewportShape, maxVisibleLevel))
185 {
186 // Clean up to save memory.
187 foreach (ToastTile* child, subTiles)
188 {
189 child->deleteLater();
190 }
191 subTiles.clear();
192 ready = false;
193 return;
194 }
195 if (level==maxVisibleLevel || !isCovered(viewportShape))
196 drawTile(sPainter);
197
198 // Draw all the children
199 foreach (ToastTile* child, subTiles)
200 {
201 child->draw(sPainter, viewportShape, maxVisibleLevel);
202 }
203}
204
205/////// ToastSurvey methods ////////////
206ToastSurvey::ToastSurvey(const QString& path, int amaxLevel)
207 : grid(amaxLevel), path(path), maxLevel(amaxLevel)
208{
209 rootTile = new ToastTile(this, 0, 0, 0);
210}
211
212
213QString ToastSurvey::getTilePath(int level, int x, int y) const
214{
215 QString ret = path;
216 ret.replace("{level}", QString::number(level));
217 ret.replace("{x}", QString::number(x));
218 ret.replace("{y}", QString::number(y));
219 return ret;
220}
221
222
223void ToastSurvey::draw(StelPainter* sPainter)
224{
225 // Compute the maximum visible level for the tiles according to the view resolution.
226 // We know that each tile at level L represents an angle of 360 / 2**L
227 // The maximum angle we want to see is the size of a tile in pixels time the angle for one visible pixel.
228 const double anglePerPixel = 1./sPainter->getProjector()->getPixelPerRadAtCenter()*180./M_PI;
229 const double maxAngle = anglePerPixel * getTilesSize();
230 int maxVisibleLevel = (int)(log2(360. / maxAngle));
231
232 // We also get the viewport shape to discard invisibly tiles.
233 const SphericalCap& viewportRegion = sPainter->getProjector()->getBoundingCap();
234 rootTile->draw(sPainter, viewportRegion, maxVisibleLevel);
235}
0236
=== added file 'src/core/StelToast.hpp'
--- src/core/StelToast.hpp 1970-01-01 00:00:00 +0000
+++ src/core/StelToast.hpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,114 @@
1/*
2 * Stellarium
3 * Copyright (C) 2010 Guillaume Chereau
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#ifndef _STELTOAST_HPP_
21#define _STELTOAST_HPP_
22
23#include <QObject>
24#include <QString>
25#include <QVector>
26
27#include "StelSphereGeometry.hpp"
28#include "StelTexture.hpp"
29#include "StelTextureTypes.hpp"
30#include "VecMath.hpp"
31#include "StelToastGrid.hpp"
32
33class StelPainter;
34class ToastSurvey;
35
36//! @class ToastTile
37//! Represents a tile in a Toast image.
38//! The tiles are stored in a tree structure, using the QObject
39//! children/parent relationships.
40class ToastTile : public QObject
41{
42 Q_OBJECT
43
44public:
45 ToastTile(QObject* parent, int level, int x, int y);
46 void draw(StelPainter* painter, const SphericalCap& viewportShape, int maxVisibleLevel);
47 bool isTransparent();
48
49protected:
50 void drawTile(StelPainter* painter);
51 //! Return the survey the tile belongs to.
52 const ToastSurvey* getSurvey() const;
53 //! Return the toast grid used by the tile.
54 const ToastGrid* getGrid() const;
55 //! Return whether the tile should be drawn
56 bool isVisible(const SphericalCap& viewportShape, int maxVisibleLevel) const;
57 //! return whether the tile is covered by its children tiles
58 //! This is used to avoid drawing tiles that will be covered anyway
59 bool isCovered(const SphericalCap& viewportShape) const;
60 void prepareDraw();
61
62private:
63 //! The level of the tile
64 int level;
65 // x coordinate of the tile
66 int x;
67 // y coordinate of the tile
68 int y;
69 //! Path to the tile image
70 QString imagePath;
71 // Set to true if the tile has no texture
72 bool empty;
73 //! Set to true if the tile is ready to draw
74 bool ready;
75 //! The texture associated with the tile
76 StelTextureSP texture;
77 //! The bounding cap used to check if the tile is visible
78 SphericalCap boundingCap;
79
80 QList<ToastTile*> subTiles;
81
82 // QList<SphericalRegionP> skyConvexPolygons;
83 //! OpenGl arrays
84 QVector<Vec3d> vertexArray;
85 QVector<Vec2f> textureArray;
86 QVector<unsigned short> indexArray;
87
88 // Used for smooth fade in
89 class QTimeLine* texFader;
90};
91
92
93//! @class ToastSurvey
94//! Represents a full Toast survey.
95class ToastSurvey : public QObject
96{
97 Q_OBJECT
98
99public:
100 ToastSurvey(const QString& path, int maxLevel);
101 QString getTilePath(int level, int x, int y) const;
102 void draw(StelPainter* sPainter);
103 const ToastGrid* getGrid() const {return &grid;}
104 int getMaxLevel() const {return maxLevel;}
105 int getTilesSize() const {return 256;}
106
107private:
108 ToastGrid grid;
109 QString path;
110 ToastTile* rootTile;
111 int maxLevel;
112};
113
114#endif // _STELTOAST_HPP_
0115
=== added file 'src/core/StelToastGrid.cpp'
--- src/core/StelToastGrid.cpp 1970-01-01 00:00:00 +0000
+++ src/core/StelToastGrid.cpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,177 @@
1/*
2 * Stellarium
3 * Copyright (C) 2010 Guillaume Chereau
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <limits>
21#include "StelToastGrid.hpp"
22
23//! compute the middle of two points on the sphere
24static inline Vec3d middle(const Vec3d& a, const Vec3d b)
25{
26 Vec3d ret = a;
27 ret += b;
28 ret.normalize();
29 return ret;
30}
31
32
33ToastGrid::ToastGrid(int amaxLevel)
34 : maxLevel(amaxLevel), size(pow2(amaxLevel) + 1)
35{
36 // We assume that initialization of the grid is fast enough to be
37 // done in the constructor.
38 init_grid();
39}
40
41
42void ToastGrid::init_grid()
43{
44 // Allocate the grid memory.
45 grid.resize(size * size);
46 // Set up the level 0.
47 at(0, 0, 0) = at(0, 1, 0) = at(0, 1, 1) = at(0, 0, 1) = Vec3d(0, 0, -1);
48 // And the level 1
49 // Need mirror
50 at(1, 1, 1) = Vec3d(0, 0, 1);
51 at(1, 1, 0) = Vec3d(0, -1, 0);
52 at(1, 2, 1) = Vec3d(1, 0, 0);
53 at(1, 1, 2) = Vec3d(0, 1, 0);
54 at(1, 0, 1) = Vec3d(-1, 0, 0);
55
56 // Then we can compute the other levels by recursion
57 init_grid(1, 0, 0, false);
58 init_grid(1, 0, 1, true);
59 init_grid(1, 1, 1, false);
60 init_grid(1, 1, 0, true);
61}
62
63
64void ToastGrid::init_grid(int level, int x, int y, bool side)
65{
66 Q_ASSERT(level >= 1); // This method won't work for level 0 !
67 int clevel = level + 1;
68 int cx = 2*x;
69 int cy = 2*y;
70 // first we compute all the mid points
71 at(clevel, cx, cy+1) = middle(at(level, x, y), at(level, x, y+1));
72 at(clevel, cx+1, cy+2) = middle(at(level, x, y+1), at(level, x+1, y+1));
73 at(clevel, cx+2, cy+1) = middle(at(level, x+1, y+1), at(level, x+1, y));
74 at(clevel, cx+1, cy) = middle(at(level, x+1, y), at(level, x, y));
75 if (side)
76 at(clevel, cx+1, cy+1) = middle(at(level, x, y), at(level, x+1, y+1));
77 else
78 at(clevel, cx+1, cy+1) = middle(at(level, x, y+1), at(level, x+1, y));
79 // now we can compute the higher levels
80 if (clevel < maxLevel)
81 {
82 init_grid(clevel, cx, cy, side);
83 init_grid(clevel, cx+1, cy, side);
84 init_grid(clevel, cx+1, cy+1, side);
85 init_grid(clevel, cx, cy+1, side);
86 }
87}
88
89
90QVector<Vec3d> ToastGrid::getVertexArray(int level, int x, int y, int resolution) const
91{
92 Q_ASSERT(resolution >= level);
93 Q_ASSERT(resolution <= maxLevel);
94 // The size of the returned array
95 int size = pow2(resolution - level) + 1;
96 QVector<Vec3d> ret;
97 ret.reserve(size * size);
98 // Compute the real position in the grid
99 int scale = pow2(maxLevel - level);
100 x *= scale;
101 y *= scale;
102 // Fill the array
103 int step = pow2(maxLevel - resolution);
104 for (int i = 0; i < size; i++)
105 {
106 for (int j = 0; j < size; j++)
107 {
108 ret.append(at(x + j * step, y + i * step));
109 }
110 }
111 Q_ASSERT(ret.size() == size * size);
112 return ret;
113}
114
115
116QVector<Vec2f> ToastGrid::getTextureArray(int level, int x, int y, int resolution) const
117{
118 Q_UNUSED(x);
119 Q_UNUSED(y);
120 Q_ASSERT(resolution >= level);
121 Q_ASSERT(resolution <= maxLevel);
122 // The size of the returned array
123 int size = pow2(resolution - level) + 1;
124 QVector<Vec2f> ret;
125 ret.reserve(size * size);
126 for (int i = size-1; i >= 0; i--)
127 {
128 for (int j = 0; j < size; j++)
129 {
130 ret.append(Vec2f(j,i) / (size-1));
131 }
132 }
133 Q_ASSERT(ret.size() == size * size);
134 return ret;
135}
136
137
138QVector<unsigned short> ToastGrid::getTrianglesIndex(int level, int x, int y, int resolution) const
139{
140 Q_ASSERT(resolution >= level);
141 Q_ASSERT(resolution <= maxLevel);
142 int size = pow2(resolution - level) + 1;
143 int nbTiles = (size - 1) * (size - 1);
144 // If we are in the top right or the bottom left quadran we invert the diagonal of the triangles.
145 int middleIndex = pow2(level) / 2;
146 bool invert = (x >= middleIndex) == (y >= middleIndex);
147 QVector<unsigned short> ret;
148 ret.reserve(nbTiles * 6);
149 for (int i = 0; i < size - 1; ++i)
150 {
151 for (int j = 0; j < size - 1; ++j)
152 {
153 Q_ASSERT(i * size + j <= std::numeric_limits<short>::max());
154 unsigned int a = i * size + j;
155 unsigned int b = (i + 1) * size + j;
156 unsigned int c = (i + 1) * size + j + 1;
157 unsigned int d = i * size + j + 1;
158 if (!invert)
159 ret << b << c << a << c << d << a;
160 else
161 ret << b << d << a << d << b << c;
162 }
163 }
164
165 Q_ASSERT(ret.size() == nbTiles * 6);
166 return ret;
167}
168
169
170QVector<Vec3d> ToastGrid::getPolygon(int level, int x, int y) const
171{
172 QVector<Vec3d> array = getVertexArray(level, x, y, level);
173 QVector<Vec3d> ret;
174 ret.reserve(4);
175 ret << array[2] << array[3] << array[1] << array[0];
176 return ret;
177}
0178
=== added file 'src/core/StelToastGrid.hpp'
--- src/core/StelToastGrid.hpp 1970-01-01 00:00:00 +0000
+++ src/core/StelToastGrid.hpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,90 @@
1/*
2 * Stellarium
3 * Copyright (C) 2010 Guillaume Chereau
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#ifndef STELTOASTGRID_HPP
21#define STELTOASTGRID_HPP
22
23#include <QVector>
24#include "VecMath.hpp"
25
26//! Compute 2^x
27inline int pow2(int x) {return 1 << x;}
28
29//! @class ToastGrid
30//! Convenience class that can be used to compute the toast grid points.
31//! The ToastGrid class allow to compute the vertex arrays associated
32//! with Toast tiles. Each method refers to a tile by its level and x
33//! and y coordinates.
34class ToastGrid
35{
36public:
37 ToastGrid(int maxLevel);
38 //! Get the vertice array for a given tile.
39 //! The position are stored in a grid.
40 //! @param level the level of the tile.
41 //! @param x the x coordinate of the tile.
42 //! @param y the y coordinate of the tile.
43 //! @param resolution the resolution of the returned array.
44 QVector<Vec3d> getVertexArray(int level, int x, int y, int resolution) const;
45 //! Get the texture array for a given tile.
46 //! The position are stored in a grid
47 //! @param level the level of the tile.
48 //! @param x the x coordinate of the tile.
49 //! @param y the y coordinate of the tile.
50 //! @param resolution the resolution of the returned array.
51 QVector<Vec2f> getTextureArray(int level, int x, int y, int resolution) const;
52 //! Get the index of the vertex from getVertexArray sorted as a list of triangles.
53 //! @param level the level of the tile.
54 //! @param x the x coordinate of the tile.
55 //! @param y the y coordinate of the tile.
56 //! @param resolution the resolution of the returned array.
57 QVector<unsigned short> getTrianglesIndex(int level, int x, int y, int resolution) const;
58 //! Returns the polygon contouring a given tile.
59 //! @param level the level of the tile.
60 //! @param x the x coordinate of the tile.
61 //! @param y the y coordinate of the tile.
62 QVector<Vec3d> getPolygon(int level, int x, int y) const;
63 //! Return the max level of this grid.
64 int getMaxLevel() const {return maxLevel;}
65
66private:
67 //! Get the vector at a given point in the grid
68 const Vec3d& at(int x, int y) const {return grid[y * size + x];}
69 //! Get the vector at a given point in the grid
70 Vec3d& at(int x, int y) {return grid[y * size + x];}
71 //! Get the vector at a given point in the grid
72 const Vec3d& at(int level, int x, int y) const
73 {int scale = pow2(maxLevel - level); return at(scale * x, scale * y);}
74 //! Get the vector at a given point in the grid
75 Vec3d& at(int level, int x, int y)
76 {int scale = pow2(maxLevel - level); return at(scale * x, scale * y);}
77
78 //! initialize the grid
79 void init_grid();
80 void init_grid(int level, int x, int y, bool side);
81
82 //! The max level of the grid
83 int maxLevel;
84 //! the size of the grid
85 int size;
86 //! The actual grid data
87 QVector<Vec3d> grid;
88};
89
90#endif // STELTOASTGRID_HPP
091
=== modified file 'src/core/StelUtils.cpp'
--- src/core/StelUtils.cpp 2016-10-29 16:37:42 +0000
+++ src/core/StelUtils.cpp 2016-11-13 10:24:15 +0000
@@ -56,6 +56,23 @@
56#endif56#endif
57}57}
5858
59QString getUserAgentString()
60{
61 // Get info about operating system
62 QString platform = StelUtils::getOperatingSystemInfo();
63 if (platform.contains("Linux"))
64 platform = "Linux";
65 if (platform.contains("FreeBSD"))
66 platform = "FreeBSD";
67 if (platform.contains("NetBSD"))
68 platform = "NetBSD";
69 if (platform.contains("OpenBSD"))
70 platform = "OpenBSD";
71
72 // Set user agent as "Stellarium/$version$ ($platform$)"
73 return QString("Stellarium/%1 (%2)").arg(StelUtils::getApplicationVersion()).arg(platform);
74}
75
59QString getOperatingSystemInfo()76QString getOperatingSystemInfo()
60{77{
61 QString OS = "Unknown operating system";78 QString OS = "Unknown operating system";
6279
=== modified file 'src/core/StelUtils.hpp'
--- src/core/StelUtils.hpp 2016-10-30 11:04:58 +0000
+++ src/core/StelUtils.hpp 2016-11-13 10:24:15 +0000
@@ -49,6 +49,9 @@
49 //! Return the name and the version of operating system, i.e. "Mac OS X 10.7"49 //! Return the name and the version of operating system, i.e. "Mac OS X 10.7"
50 QString getOperatingSystemInfo();50 QString getOperatingSystemInfo();
5151
52 //! Return the user agent name, i.e. "Stellarium/0.15.0 (Linux)"
53 QString getUserAgentString();
54
52 //! Convert an angle in hms format to radian.55 //! Convert an angle in hms format to radian.
53 //! @param h hour component56 //! @param h hour component
54 //! @param m minute component57 //! @param m minute component
5558
=== modified file 'src/core/modules/ConstellationMgr.cpp'
--- src/core/modules/ConstellationMgr.cpp 2016-09-17 18:27:21 +0000
+++ src/core/modules/ConstellationMgr.cpp 2016-11-13 10:24:15 +0000
@@ -134,7 +134,7 @@
134134
135 StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);135 StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);
136 objectManager->registerStelObjectMgr(this);136 objectManager->registerStelObjectMgr(this);
137 connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::StelModuleSelectAction)), 137 connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::StelModuleSelectAction)),
138 this, SLOT(selectedObjectChange(StelModule::StelModuleSelectAction)));138 this, SLOT(selectedObjectChange(StelModule::StelModuleSelectAction)));
139 StelApp *app = &StelApp::getInstance();139 StelApp *app = &StelApp::getInstance();
140 connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));140 connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
141141
=== added file 'src/core/modules/ToastMgr.cpp'
--- src/core/modules/ToastMgr.cpp 1970-01-01 00:00:00 +0000
+++ src/core/modules/ToastMgr.cpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,97 @@
1/*
2 * Stellarium
3 * Copyright (C) 2006 Fabien Chereau
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <QDebug>
21
22#include "ToastMgr.hpp"
23#include "StelToast.hpp"
24#include "StelFader.hpp"
25#include "StelPainter.hpp"
26#include "StelCore.hpp"
27#include "StelApp.hpp"
28#include "StelTranslator.hpp"
29#include "StelModuleMgr.hpp"
30#include "StelSkyLayerMgr.hpp"
31
32#include <QSettings>
33
34ToastMgr::ToastMgr()
35{
36 setObjectName("ToastMgr");
37 fader = new LinearFader();
38}
39
40ToastMgr::~ToastMgr()
41{
42 if (survey)
43 {
44 delete survey;
45 survey = NULL;
46 }
47
48 delete fader;
49 fader = NULL;
50}
51
52void ToastMgr::init()
53{
54 QSettings* conf = StelApp::getInstance().getSettings();
55 Q_ASSERT(conf);
56
57 // TODO: change settings before release (results->survey; dss.astro.altspu.ru->dss.stellarium.org)
58 QString toastHost = conf->value("astro/toast_survey_host", "http://dss.astro.altspu.ru").toString();
59 QString toastDir = conf->value("astro/toast_survey_directory", "results").toString();
60 int toastLevel = conf->value("astro/toast_survey_levels", 11).toInt();
61 survey = new ToastSurvey(toastHost+"/" + toastDir + "/{level}/{x}_{y}.jpg", toastLevel);
62 survey->setParent(this);
63
64 // Hide deep-sky survey by default
65 setFlagSurveyShow(conf->value("astro/flag_toast_survey", false).toBool());
66
67 addAction("actionShow_Toast_Survey", N_("Display Options"), N_("Digitized sky survey"), "surveyDisplayed", "Ctrl+Alt+D");
68}
69
70void ToastMgr::draw(StelCore* core)
71{
72 if (!getFlagSurveyShow())
73 return;
74
75 StelPainter sPainter(core->getProjection(StelCore::FrameJ2000));
76 survey->draw(&sPainter);
77}
78
79void ToastMgr::update(double deltaTime)
80{
81 fader->update((int)(deltaTime*1000));
82}
83
84void ToastMgr::setFlagSurveyShow(const bool displayed)
85{
86 if (*fader != displayed)
87 {
88 *fader = displayed;
89 GETSTELMODULE(StelSkyLayerMgr)->setFlagShow(!displayed);
90 emit surveyDisplayedChanged(displayed);
91 }
92}
93
94bool ToastMgr::getFlagSurveyShow() const
95{
96 return *fader;
97}
098
=== added file 'src/core/modules/ToastMgr.hpp'
--- src/core/modules/ToastMgr.hpp 1970-01-01 00:00:00 +0000
+++ src/core/modules/ToastMgr.hpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,53 @@
1/*
2 * Stellarium
3 * Copyright (C) 2006 Fabien Chereau
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#ifndef _TOASTMGR_HPP_
21#define _TOASTMGR_HPP_
22
23#include "StelModule.hpp"
24
25class ToastMgr : public StelModule
26{
27 Q_OBJECT
28 Q_PROPERTY(bool surveyDisplayed
29 READ getFlagSurveyShow
30 WRITE setFlagSurveyShow
31 NOTIFY surveyDisplayedChanged)
32public:
33 ToastMgr();
34 virtual ~ToastMgr();
35 virtual void init();
36 virtual void update(double deltaTime);
37 virtual void draw(StelCore* core);
38 //! Used to determine the order in which the various modules are drawn. MilkyWay=1, we use 7.
39 virtual double getCallOrder(StelModuleActionName actionName) const {Q_UNUSED(actionName); return 7.;}
40
41public slots:
42 void setFlagSurveyShow(bool displayed);
43 bool getFlagSurveyShow(void) const;
44
45signals:
46 void surveyDisplayedChanged(const bool displayed) const;
47
48private:
49 class ToastSurvey* survey;
50 class LinearFader* fader;
51};
52
53#endif // _TOASTMGR_HPP_
054
=== modified file 'src/gui/ConfigurationDialog.cpp'
--- src/gui/ConfigurationDialog.cpp 2016-11-04 17:18:42 +0000
+++ src/gui/ConfigurationDialog.cpp 2016-11-13 10:24:15 +0000
@@ -54,6 +54,7 @@
54#include "StelJsonParser.hpp"54#include "StelJsonParser.hpp"
55#include "StelTranslator.hpp"55#include "StelTranslator.hpp"
56#include "EphemWrapper.hpp"56#include "EphemWrapper.hpp"
57#include "ToastMgr.hpp"
5758
58#include <QSettings>59#include <QSettings>
59#include <QDebug>60#include <QDebug>
@@ -77,15 +78,7 @@
77 customDeltaTEquationDialog = NULL;78 customDeltaTEquationDialog = NULL;
78 hasDownloadedStarCatalog = false;79 hasDownloadedStarCatalog = false;
79 isDownloadingStarCatalog = false;80 isDownloadingStarCatalog = false;
80 savedProjectionType = StelApp::getInstance().getCore()->getCurrentProjectionType();81 savedProjectionType = StelApp::getInstance().getCore()->getCurrentProjectionType();
81 // Get info about operating system
82 QString platform = StelUtils::getOperatingSystemInfo();
83 if (platform.contains("Linux"))
84 platform = "Linux";
85 if (platform.contains("FreeBSD"))
86 platform = "FreeBSD";
87 // Set user agent as "Stellarium/$version$ ($platform$)"
88 userAgent = QString("Stellarium/%1 (%2)").arg(StelUtils::getApplicationVersion()).arg(platform);
89}82}
9083
91ConfigurationDialog::~ConfigurationDialog()84ConfigurationDialog::~ConfigurationDialog()
@@ -298,6 +291,9 @@
298 ui->showNebulaBgButtonCheckbox->setChecked(gui->getFlagShowNebulaBackgroundButton());291 ui->showNebulaBgButtonCheckbox->setChecked(gui->getFlagShowNebulaBackgroundButton());
299 connect(ui->showNebulaBgButtonCheckbox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowNebulaBackgroundButton(bool)));292 connect(ui->showNebulaBgButtonCheckbox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowNebulaBackgroundButton(bool)));
300293
294 ui->showToastSurveyButtonCheckbox->setChecked(gui->getFlagShowToastSurveyButton());
295 connect(ui->showToastSurveyButtonCheckbox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowToastSurveyButton(bool)));
296
301 ui->showBookmarksButtonCheckBox->setChecked(gui->getFlagShowBookmarksButton());297 ui->showBookmarksButtonCheckBox->setChecked(gui->getFlagShowBookmarksButton());
302 connect(ui->showBookmarksButtonCheckBox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowBookmarksButton(bool)));298 connect(ui->showBookmarksButtonCheckBox, SIGNAL(toggled(bool)), gui, SLOT(setFlagShowBookmarksButton(bool)));
303299
@@ -789,6 +785,7 @@
789 conf->setValue("gui/auto_hide_horizontal_toolbar", gui->getAutoHideHorizontalButtonBar());785 conf->setValue("gui/auto_hide_horizontal_toolbar", gui->getAutoHideHorizontalButtonBar());
790 conf->setValue("gui/auto_hide_vertical_toolbar", gui->getAutoHideVerticalButtonBar());786 conf->setValue("gui/auto_hide_vertical_toolbar", gui->getAutoHideVerticalButtonBar());
791 conf->setValue("gui/flag_show_nebulae_background_button", gui->getFlagShowNebulaBackgroundButton());787 conf->setValue("gui/flag_show_nebulae_background_button", gui->getFlagShowNebulaBackgroundButton());
788 conf->setValue("gui/flag_show_toast_survey_button", gui->getFlagShowToastSurveyButton());
792 conf->setValue("gui/flag_show_decimal_degrees", StelApp::getInstance().getFlagShowDecimalDegrees());789 conf->setValue("gui/flag_show_decimal_degrees", StelApp::getInstance().getFlagShowDecimalDegrees());
793 conf->setValue("gui/flag_use_azimuth_from_south", StelApp::getInstance().getFlagSouthAzimuthUsage());790 conf->setValue("gui/flag_use_azimuth_from_south", StelApp::getInstance().getFlagSouthAzimuthUsage());
794 conf->setValue("gui/flag_time_jd", gui->getButtonBar()->getFlagTimeJd());791 conf->setValue("gui/flag_time_jd", gui->getButtonBar()->getFlagTimeJd());
@@ -1176,7 +1173,7 @@
1176 QNetworkRequest req(nextStarCatalogToDownload.value("url").toString());1173 QNetworkRequest req(nextStarCatalogToDownload.value("url").toString());
1177 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);1174 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
1178 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);1175 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);
1179 req.setRawHeader("User-Agent", userAgent.toLatin1());1176 req.setRawHeader("User-Agent", StelUtils::getUserAgentString().toLatin1());
1180 starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);1177 starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
1181 starCatalogDownloadReply->setReadBufferSize(1024*1024*2); 1178 starCatalogDownloadReply->setReadBufferSize(1024*1024*2);
1182 connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(downloadFinished()));1179 connect(starCatalogDownloadReply, SIGNAL(finished()), this, SLOT(downloadFinished()));
@@ -1230,7 +1227,7 @@
1230 QNetworkRequest req(redirect.toUrl());1227 QNetworkRequest req(redirect.toUrl());
1231 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);1228 req.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
1232 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);1229 req.setAttribute(QNetworkRequest::RedirectionTargetAttribute, false);
1233 req.setRawHeader("User-Agent", userAgent.toLatin1());1230 req.setRawHeader("User-Agent", StelUtils::getUserAgentString().toLatin1());
1234 starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);1231 starCatalogDownloadReply = StelApp::getInstance().getNetworkAccessManager()->get(req);
1235 starCatalogDownloadReply->setReadBufferSize(1024*1024*2);1232 starCatalogDownloadReply->setReadBufferSize(1024*1024*2);
1236 connect(starCatalogDownloadReply, SIGNAL(readyRead()), this, SLOT(newStarCatalogData()));1233 connect(starCatalogDownloadReply, SIGNAL(readyRead()), this, SLOT(newStarCatalogData()));
12371234
=== modified file 'src/gui/ConfigurationDialog.hpp'
--- src/gui/ConfigurationDialog.hpp 2016-10-29 11:47:49 +0000
+++ src/gui/ConfigurationDialog.hpp 2016-11-13 10:24:15 +0000
@@ -72,8 +72,6 @@
72 QFile* currentDownloadFile;72 QFile* currentDownloadFile;
73 class StelProgressController* progressBar;73 class StelProgressController* progressBar;
7474
75 QString userAgent;
76
77private slots:75private slots:
78 void setNoSelectedInfo();76 void setNoSelectedInfo();
79 void setAllSelectedInfo();77 void setAllSelectedInfo();
8078
=== modified file 'src/gui/StelGui.cpp'
--- src/gui/StelGui.cpp 2016-10-29 12:45:33 +0000
+++ src/gui/StelGui.cpp 2016-11-13 10:24:15 +0000
@@ -42,6 +42,7 @@
42#include "StelObjectType.hpp"42#include "StelObjectType.hpp"
43#include "StelObject.hpp"43#include "StelObject.hpp"
44#include "SolarSystem.hpp"44#include "SolarSystem.hpp"
45#include "ToastMgr.hpp"
45#include "StelSkyLayerMgr.hpp"46#include "StelSkyLayerMgr.hpp"
46#include "StelStyle.hpp"47#include "StelStyle.hpp"
47#include "StelSkyDrawer.hpp"48#include "StelSkyDrawer.hpp"
@@ -102,6 +103,8 @@
102 , flipHoriz(NULL)103 , flipHoriz(NULL)
103 , flagShowNebulaBackgroundButton(false)104 , flagShowNebulaBackgroundButton(false)
104 , btShowNebulaeBackground(NULL)105 , btShowNebulaeBackground(NULL)
106 , flagShowToastSurveyButton(false)
107 , btShowToastSurvey(NULL)
105 , flagShowBookmarksButton(false)108 , flagShowBookmarksButton(false)
106 , btShowBookmarks(NULL)109 , btShowBookmarks(NULL)
107 , initDone(false)110 , initDone(false)
@@ -382,6 +385,7 @@
382 // add the flip buttons if requested in the config385 // add the flip buttons if requested in the config
383 setFlagShowFlipButtons(conf->value("gui/flag_show_flip_buttons", false).toBool());386 setFlagShowFlipButtons(conf->value("gui/flag_show_flip_buttons", false).toBool());
384 setFlagShowNebulaBackgroundButton(conf->value("gui/flag_show_nebulae_background_button", false).toBool());387 setFlagShowNebulaBackgroundButton(conf->value("gui/flag_show_nebulae_background_button", false).toBool());
388 setFlagShowToastSurveyButton(conf->value("gui/flag_show_toast_survey_button", false).toBool());
385 setFlagShowBookmarksButton(conf->value("gui/flag_show_bookmarks_button", false).toBool());389 setFlagShowBookmarksButton(conf->value("gui/flag_show_bookmarks_button", false).toBool());
386390
387 ///////////////////////////////////////////////////////////////////////391 ///////////////////////////////////////////////////////////////////////
@@ -537,6 +541,10 @@
537 if (getAction("actionShow_DSS")->isChecked() != flag)541 if (getAction("actionShow_DSS")->isChecked() != flag)
538 getAction("actionShow_DSS")->setChecked(flag);542 getAction("actionShow_DSS")->setChecked(flag);
539543
544 flag = GETSTELMODULE(ToastMgr)->getFlagSurveyShow();
545 if (getAction("actionShow_Toast_Survey")->isChecked() != flag)
546 getAction("actionShow_Toast_Survey")->setChecked(flag);
547
540 flag = StelApp::getInstance().getVisionModeNight();548 flag = StelApp::getInstance().getVisionModeNight();
541 if (getAction("actionShow_Night_Mode")->isChecked() != flag)549 if (getAction("actionShow_Night_Mode")->isChecked() != flag)
542 getAction("actionShow_Night_Mode")->setChecked(flag);550 getAction("actionShow_Night_Mode")->setChecked(flag);
@@ -712,6 +720,24 @@
712 }720 }
713}721}
714722
723// Define whether the button toggling TOAST survey images should be visible
724void StelGui::setFlagShowToastSurveyButton(bool b)
725{
726 if (b==true) {
727 if (btShowToastSurvey==NULL) {
728 // Create the nebulae background button
729 QPixmap pxmapGlow32x32(":/graphicGui/glow32x32.png");
730 QPixmap pxmapOn(":/graphicGui/btToastSurvey-on.png");
731 QPixmap pxmapOff(":/graphicGui/btToastSurvey-off.png");
732 btShowToastSurvey = new StelButton(NULL, pxmapOn, pxmapOff, pxmapGlow32x32, "actionShow_Toast_Survey");
733 }
734 getButtonBar()->addButton(btShowToastSurvey, "040-nebulaeGroup");
735 } else {
736 getButtonBar()->hideButton("actionShow_Toast_Survey");
737 }
738 flagShowToastSurveyButton = b;
739}
740
715void StelGui::setFlagShowDecimalDegrees(bool b)741void StelGui::setFlagShowDecimalDegrees(bool b)
716{742{
717 StelApp::getInstance().setFlagShowDecimalDegrees(b);743 StelApp::getInstance().setFlagShowDecimalDegrees(b);
@@ -809,6 +835,11 @@
809 return flagShowNebulaBackgroundButton;835 return flagShowNebulaBackgroundButton;
810}836}
811837
838bool StelGui::getFlagShowToastSurveyButton() const
839{
840 return flagShowToastSurveyButton;
841}
842
812bool StelGui::getFlagShowBookmarksButton() const843bool StelGui::getFlagShowBookmarksButton() const
813{844{
814 return flagShowBookmarksButton;845 return flagShowBookmarksButton;
815846
=== modified file 'src/gui/StelGui.hpp'
--- src/gui/StelGui.hpp 2016-08-24 13:32:23 +0000
+++ src/gui/StelGui.hpp 2016-11-13 10:24:15 +0000
@@ -92,6 +92,9 @@
92 //! Get whether the button toggling nebulae background is visible92 //! Get whether the button toggling nebulae background is visible
93 bool getFlagShowNebulaBackgroundButton() const;93 bool getFlagShowNebulaBackgroundButton() const;
9494
95 //! Get whether the button toggling TOAST survey is visible
96 bool getFlagShowToastSurveyButton() const;
97
95 //! Get whether the button toggling bookmarks is visible98 //! Get whether the button toggling bookmarks is visible
96 bool getFlagShowBookmarksButton() const;99 bool getFlagShowBookmarksButton() const;
97100
@@ -123,6 +126,9 @@
123 //! Define whether the button toggling nebulae background should be visible126 //! Define whether the button toggling nebulae background should be visible
124 void setFlagShowNebulaBackgroundButton(bool b);127 void setFlagShowNebulaBackgroundButton(bool b);
125128
129 //! Define whether the button toggling TOAST survey should be visible
130 void setFlagShowToastSurveyButton(bool b);
131
126 //! Define whether the button toggling bookmarks should be visible132 //! Define whether the button toggling bookmarks should be visible
127 void setFlagShowBookmarksButton(bool b);133 void setFlagShowBookmarksButton(bool b);
128134
@@ -212,6 +218,9 @@
212 bool flagShowNebulaBackgroundButton;218 bool flagShowNebulaBackgroundButton;
213 StelButton* btShowNebulaeBackground;219 StelButton* btShowNebulaeBackground;
214220
221 bool flagShowToastSurveyButton;
222 StelButton* btShowToastSurvey;
223
215 bool flagShowBookmarksButton;224 bool flagShowBookmarksButton;
216 StelButton* btShowBookmarks;225 StelButton* btShowBookmarks;
217226
218227
=== modified file 'src/gui/configurationDialog.ui'
--- src/gui/configurationDialog.ui 2016-11-05 18:23:26 +0000
+++ src/gui/configurationDialog.ui 2016-11-13 10:24:15 +0000
@@ -7,7 +7,7 @@
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>512</width>9 <width>512</width>
10 <height>563</height>10 <height>579</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <layout class="QVBoxLayout">13 <layout class="QVBoxLayout">
@@ -1291,7 +1291,70 @@
1291 <property name="bottomMargin">1291 <property name="bottomMargin">
1292 <number>0</number>1292 <number>0</number>
1293 </property>1293 </property>
1294 <item row="3" column="0">1294 <item row="8" column="0" colspan="2">
1295 <widget class="QCheckBox" name="autoZoomResetsDirectionCheckbox">
1296 <property name="toolTip">
1297 <string>When enabled, the &quot;auto zoom out&quot; key will also set the initial viewing direction</string>
1298 </property>
1299 <property name="text">
1300 <string>Auto zoom out returns to initial direction of view</string>
1301 </property>
1302 </widget>
1303 </item>
1304 <item row="0" column="1">
1305 <widget class="QCheckBox" name="diskViewportCheckbox">
1306 <property name="toolTip">
1307 <string>Mask out everything outside a central circle in the main view</string>
1308 </property>
1309 <property name="text">
1310 <string>Disc viewport</string>
1311 </property>
1312 </widget>
1313 </item>
1314 <item row="1" column="1">
1315 <widget class="QCheckBox" name="gravityLabelCheckbox">
1316 <property name="toolTip">
1317 <string>Align labels with the horizon</string>
1318 </property>
1319 <property name="text">
1320 <string>Gravity labels</string>
1321 </property>
1322 </widget>
1323 </item>
1324 <item row="4" column="1">
1325 <widget class="QCheckBox" name="decimalDegreeCheckBox">
1326 <property name="toolTip">
1327 <string>Use decimal degrees for coordinates</string>
1328 </property>
1329 <property name="text">
1330 <string>Use decimal degrees</string>
1331 </property>
1332 </widget>
1333 </item>
1334 <item row="0" column="0">
1335 <widget class="QCheckBox" name="sphericMirrorCheckbox">
1336 <property name="toolTip">
1337 <string>Spheric mirror distortion is used when projecting Stellarium onto a spheric mirror for low-cost planetarium systems.</string>
1338 </property>
1339 <property name="text">
1340 <string>Spheric mirror distortion</string>
1341 </property>
1342 <property name="checkable">
1343 <bool>true</bool>
1344 </property>
1345 </widget>
1346 </item>
1347 <item row="5" column="1">
1348 <widget class="QCheckBox" name="topocentricCheckBox">
1349 <property name="toolTip">
1350 <string>Activate to view as seen from surface of the planet (recommended). If switched off, display planetocentric view.</string>
1351 </property>
1352 <property name="text">
1353 <string>Topocentric coordinates</string>
1354 </property>
1355 </widget>
1356 </item>
1357 <item row="4" column="0">
1295 <widget class="QCheckBox" name="autoEnableAtmosphereCheckBox">1358 <widget class="QCheckBox" name="autoEnableAtmosphereCheckBox">
1296 <property name="toolTip">1359 <property name="toolTip">
1297 <string>Auto-enabling of the atmosphere for bodies with atmosphere in location window</string>1360 <string>Auto-enabling of the atmosphere for bodies with atmosphere in location window</string>
@@ -1301,6 +1364,29 @@
1301 </property>1364 </property>
1302 </widget>1365 </widget>
1303 </item>1366 </item>
1367 <item row="2" column="1">
1368 <widget class="QCheckBox" name="showFlipButtonsCheckbox">
1369 <property name="toolTip">
1370 <string>Toggle vertical and horizontal image flip buttons.</string>
1371 </property>
1372 <property name="text">
1373 <string>Show flip buttons</string>
1374 </property>
1375 </widget>
1376 </item>
1377 <item row="1" column="0">
1378 <widget class="QCheckBox" name="selectSingleConstellationButton">
1379 <property name="toolTip">
1380 <string>Hide other constellations when you click one</string>
1381 </property>
1382 <property name="statusTip">
1383 <string>Hide other constellations when you click one</string>
1384 </property>
1385 <property name="text">
1386 <string>Select single constellation</string>
1387 </property>
1388 </widget>
1389 </item>
1304 <item row="2" column="0">1390 <item row="2" column="0">
1305 <widget class="QCheckBox" name="showNebulaBgButtonCheckbox">1391 <widget class="QCheckBox" name="showNebulaBgButtonCheckbox">
1306 <property name="toolTip">1392 <property name="toolTip">
@@ -1311,7 +1397,7 @@
1311 </property>1397 </property>
1312 </widget>1398 </widget>
1313 </item>1399 </item>
1314 <item row="4" column="0">1400 <item row="5" column="0">
1315 <widget class="QCheckBox" name="nutationCheckBox">1401 <widget class="QCheckBox" name="nutationCheckBox">
1316 <property name="toolTip">1402 <property name="toolTip">
1317 <string>Nutation is a small wobble of Earth's axis, amounting to a few arcseconds.</string>1403 <string>Nutation is a small wobble of Earth's axis, amounting to a few arcseconds.</string>
@@ -1321,7 +1407,7 @@
1321 </property>1407 </property>
1322 </widget>1408 </widget>
1323 </item>1409 </item>
1324 <item row="5" column="0">1410 <item row="6" column="0">
1325 <widget class="QCheckBox" name="azimuthFromSouthcheckBox">1411 <widget class="QCheckBox" name="azimuthFromSouthcheckBox">
1326 <property name="toolTip">1412 <property name="toolTip">
1327 <string>Activate this option to calculate azimuth from south towards west.</string>1413 <string>Activate this option to calculate azimuth from south towards west.</string>
@@ -1332,72 +1418,16 @@
1332 </widget>1418 </widget>
1333 </item>1419 </item>
1334 <item row="3" column="1">1420 <item row="3" column="1">
1335 <widget class="QCheckBox" name="decimalDegreeCheckBox">1421 <widget class="QCheckBox" name="showToastSurveyButtonCheckbox">
1336 <property name="toolTip">1422 <property name="toolTip">
1337 <string>Use decimal degrees for coordinates</string>1423 <string>Toggle display Digitized Sky Survey.</string>
1338 </property>1424 </property>
1339 <property name="text">1425 <property name="text">
1340 <string>Use decimal degrees</string>1426 <string>Show DSS button</string>
1341 </property>1427 </property>
1342 </widget>1428 </widget>
1343 </item>1429 </item>
1344 <item row="4" column="1">1430 <item row="6" column="1">
1345 <widget class="QCheckBox" name="topocentricCheckBox">
1346 <property name="toolTip">
1347 <string>Activate to view as seen from surface of the planet (recommended). If switched off, display planetocentric view.</string>
1348 </property>
1349 <property name="text">
1350 <string>Topocentric coordinates</string>
1351 </property>
1352 </widget>
1353 </item>
1354 <item row="2" column="1">
1355 <widget class="QCheckBox" name="showFlipButtonsCheckbox">
1356 <property name="toolTip">
1357 <string>Toggle vertical and horizontal image flip buttons.</string>
1358 </property>
1359 <property name="text">
1360 <string>Show flip buttons</string>
1361 </property>
1362 </widget>
1363 </item>
1364 <item row="1" column="1">
1365 <widget class="QCheckBox" name="gravityLabelCheckbox">
1366 <property name="toolTip">
1367 <string>Align labels with the horizon</string>
1368 </property>
1369 <property name="text">
1370 <string>Gravity labels</string>
1371 </property>
1372 </widget>
1373 </item>
1374 <item row="1" column="0">
1375 <widget class="QCheckBox" name="selectSingleConstellationButton">
1376 <property name="toolTip">
1377 <string>Hide other constellations when you click one</string>
1378 </property>
1379 <property name="statusTip">
1380 <string>Hide other constellations when you click one</string>
1381 </property>
1382 <property name="text">
1383 <string>Select single constellation</string>
1384 </property>
1385 </widget>
1386 </item>
1387 <item row="0" column="0">
1388 <widget class="QCheckBox" name="sphericMirrorCheckbox">
1389 <property name="toolTip">
1390 <string>Spheric mirror distortion is used when projecting Stellarium onto a spheric mirror for low-cost planetarium systems.</string>
1391 </property>
1392 <property name="text">
1393 <string>Spheric mirror distortion</string>
1394 </property>
1395 <property name="checkable">
1396 <bool>true</bool>
1397 </property>
1398 </widget>
1399 </item>
1400 <item row="5" column="1">
1401 <widget class="QCheckBox" name="autoChangeLandscapesCheckBox">1431 <widget class="QCheckBox" name="autoChangeLandscapesCheckBox">
1402 <property name="toolTip">1432 <property name="toolTip">
1403 <string>Automatic change of landscape when planet is changed</string>1433 <string>Automatic change of landscape when planet is changed</string>
@@ -1407,27 +1437,7 @@
1407 </property>1437 </property>
1408 </widget>1438 </widget>
1409 </item>1439 </item>
1410 <item row="0" column="1">1440 <item row="3" column="0">
1411 <widget class="QCheckBox" name="diskViewportCheckbox">
1412 <property name="toolTip">
1413 <string>Mask out everything outside a central circle in the main view</string>
1414 </property>
1415 <property name="text">
1416 <string>Disc viewport</string>
1417 </property>
1418 </widget>
1419 </item>
1420 <item row="7" column="0" colspan="2">
1421 <widget class="QCheckBox" name="autoZoomResetsDirectionCheckbox">
1422 <property name="toolTip">
1423 <string>When enabled, the &quot;auto zoom out&quot; key will also set the initial viewing direction</string>
1424 </property>
1425 <property name="text">
1426 <string>Auto zoom out returns to initial direction of view</string>
1427 </property>
1428 </widget>
1429 </item>
1430 <item row="6" column="0">
1431 <widget class="QCheckBox" name="showBookmarksButtonCheckBox">1441 <widget class="QCheckBox" name="showBookmarksButtonCheckBox">
1432 <property name="text">1442 <property name="text">
1433 <string>Show bookmarks button</string>1443 <string>Show bookmarks button</string>
14341444
=== added directory 'util/DSSToStellarium'
=== added file 'util/DSSToStellarium/DejaVuSans.ttf'
1435Binary files util/DSSToStellarium/DejaVuSans.ttf 1970-01-01 00:00:00 +0000 and util/DSSToStellarium/DejaVuSans.ttf 2016-11-13 10:24:15 +0000 differ1445Binary files util/DSSToStellarium/DejaVuSans.ttf 1970-01-01 00:00:00 +0000 and util/DSSToStellarium/DejaVuSans.ttf 2016-11-13 10:24:15 +0000 differ
=== added file 'util/DSSToStellarium/UTdssUtils.py'
--- util/DSSToStellarium/UTdssUtils.py 1970-01-01 00:00:00 +0000
+++ util/DSSToStellarium/UTdssUtils.py 2016-11-13 10:24:15 +0000
@@ -0,0 +1,35 @@
1#!/usr/bin/python
2
3# This file is part of Stellarium. Stellarium is free software: you can
4# redistribute it and/or modify it under the terms of the GNU General Public
5# License as published by the Free Software Foundation, version 2.
6#
7# This program is distributed in the hope that it will be useful, but WITHOUT
8# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10# details.
11#
12# You should have received a copy of the GNU General Public License along with
13# this program; if not, write to the Free Software Foundation, Inc., 51
14# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15#
16# Copyright Fabien Chereau <fabien.chereau@gmail.com>
17
18import dssUtils
19import unittest
20
21class TestDssUtils(unittest.TestCase):
22
23 def setUp(self):
24 pass
25
26 def test_pointProjection(self):
27 wcs = dssUtils.DssWcs("S032")
28 pixPos = [500, 1253]
29 raDecPos = wcs.pixelToRaDec(pixPos)
30 self.assertAlmostEqual(pixPos[0], wcs.raDecToPixel(raDecPos)[0])
31 self.assertAlmostEqual(pixPos[1], wcs.raDecToPixel(raDecPos)[1])
32
33if __name__ == '__main__':
34 unittest.main()
35
036
=== added file 'util/DSSToStellarium/createUpperToastLevels.py'
--- util/DSSToStellarium/createUpperToastLevels.py 1970-01-01 00:00:00 +0000
+++ util/DSSToStellarium/createUpperToastLevels.py 2016-11-13 10:24:15 +0000
@@ -0,0 +1,81 @@
1#!/usr/bin/python
2
3# This file is part of Stellarium. Stellarium is free software: you can
4# redistribute it and/or modify it under the terms of the GNU General Public
5# License as published by the Free Software Foundation, version 2.
6#
7# This program is distributed in the hope that it will be useful, but WITHOUT
8# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10# details.
11#
12# You should have received a copy of the GNU General Public License along with
13# this program; if not, write to the Free Software Foundation, Inc., 51
14# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15#
16# Copyright Fabien Chereau <fabien.chereau@gmail.com>
17
18import Image
19import os
20from subprocess import Popen, PIPE, STDOUT
21
22outDirectory = 'results'
23level=11
24imSize = 256
25
26print "Generate upper levels tile in " + outDirectory
27
28if not os.path.exists(outDirectory):
29 print "Output directory %s doesn't exist. It should be there and contain tiles for level %d" % (outDirectory, level)
30 exit(-1)
31
32level=level-1
33while level>=0:
34 print "Start level %s" % level
35 os.system("mkdir %s/%d" % (outDirectory, level))
36 allTiles = []
37 for filename in os.listdir("%s/%d" % (outDirectory, level+1)):
38 basename, extension = filename.split('.')
39 if basename.endswith("partial"):
40 tmp, partial = basename.split('-')
41 if not os.path.exists("%s/%d/%s" % (outDirectory, level+1, tmp+'.'+extension)):
42 cmd = "mv %s/%d/%s %s/%d/%s" % (outDirectory, level+1, filename, outDirectory, level+1, tmp+'.'+extension)
43 os.system(cmd)
44 basename = tmp
45 xystr = basename.split('_')
46 allTiles.append((int(xystr[0]), int(xystr[1])))
47
48 toGenerate = {}
49 for tile in allTiles:
50 key = (tile[0]/2, tile[1]/2)
51 if key not in toGenerate:
52 toGenerate[key]=[]
53 toGenerate[key].append(tile)
54
55 i = 0
56 for (x, y) in toGenerate:
57 i = i+1
58 if i % 1000 == 0:
59 print "%d/%d" % (i,len(toGenerate))
60 resImg=Image.new("RGB", (imSize, imSize))
61 tile = toGenerate[(x, y)]
62 if (x*2, y*2) in tile:
63 im = Image.open("%s/%d/%d_%d.jpg" % (outDirectory, level+1, x*2, y*2)).resize((imSize/2, imSize/2), Image.NEAREST)
64 resImg.paste(im, (0, 0))
65 if (x*2+1, y*2) in tile:
66 im = Image.open("%s/%d/%d_%d.jpg" % (outDirectory, level+1, x*2+1, y*2)).resize((imSize/2, imSize/2), Image.NEAREST)
67 resImg.paste(im, (imSize/2, 0))
68 if (x*2, y*2+1) in tile:
69 im = Image.open("%s/%d/%d_%d.jpg" % (outDirectory, level+1, x*2, y*2+1)).resize((imSize/2, imSize/2), Image.NEAREST)
70 resImg.paste(im, (0, imSize/2))
71 if ((x*2+1, y*2+1)) in tile:
72 im = Image.open("%s/%d/%d_%d.jpg" % (outDirectory, level+1, x*2+1, y*2+1)).resize((imSize/2, imSize/2), Image.NEAREST)
73 resImg.paste(im, (imSize/2, imSize/2))
74 resImg.save("%s/%d/%d_%d.jpg" % (outDirectory, level, x, y), quality=90)
75
76 level=level-1
77
78
79
80
81
082
=== added file 'util/DSSToStellarium/dssUtils.py'
--- util/DSSToStellarium/dssUtils.py 1970-01-01 00:00:00 +0000
+++ util/DSSToStellarium/dssUtils.py 2016-11-13 10:24:15 +0000
@@ -0,0 +1,169 @@
1#!/usr/bin/python
2
3# This file is part of Stellarium. Stellarium is free software: you can
4# redistribute it and/or modify it under the terms of the GNU General Public
5# License as published by the Free Software Foundation, version 2.
6#
7# This program is distributed in the hope that it will be useful, but WITHOUT
8# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10# details.
11#
12# You should have received a copy of the GNU General Public License along with
13# this program; if not, write to the Free Software Foundation, Inc., 51
14# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15#
16# Copyright Fabien Chereau <fabien.chereau@gmail.com>
17
18
19import Image, ImageFilter, ImageStat, ImageChops
20import os
21import json
22import sys
23from astropy import wcs
24from astropy.io import fits
25import numpy
26import scipy.interpolate
27
28def getAllPlatesNames():
29 """Return the list of all DSS plates names"""
30 ret = []
31 for i in range(1, 895):
32 ret.append("S%03d" % i)
33 for i in range(2, 899):
34 ret.append("N%03d" % i)
35 return ret
36
37def getTestingPlatesNames():
38 """Return a list of some testing DSS plates names"""
39 ret = []
40 for i in range(100, 305):
41 ret.append("N%03d" % i)
42 return ret
43
44def getTestingPlatesNamesLMC():
45 """Return a list of some testing DSS plates names covering the Large Magellanic Cloud (one of the worst case)"""
46 return ["S086", "S085", "S057", "S056", "S033", "S032", "S055", "S054"]
47
48def getValidRegionForPlate(plateName):
49 """Return the polygon defining the valid pixels inside the full resolution plate image"""
50 if plateName[0]=='N':
51 return [[0,0], [17232, 0], [17232, 1200], [19200, 1200], [19200, 19200], [0, 19200]]
52 else:
53 assert plateName[0]=='S'
54 return [[480,0], [17232, 0], [17232, 17232], [0, 17232], [0, 624], [480, 624]]
55
56def enhancePlate(plateName, plate, referenceImage):
57 """Return a transformed version of the plate so that it matches the referenceImage
58 This is Fabien's version. It just attempts to scale brightness based on the average
59 brightness on a 8x8 map"""
60
61 print "Enhance darker part of the image"
62 plate = plate.point(lambda t : 2.*t-256.*(t/256.)**1.8)
63
64 """
65 plate.save("tmp/%s-full.jpg" % plateName, 'JPEG', quality=80)
66 referenceImage.save("tmp/%s-reference.jpg" % plateName, 'JPEG', quality=95)
67 return plate
68
69 print "Enhance plate"
70 plateMap = plate.resize((8,8) , Image.ANTIALIAS)
71 plateMap.save("tmp/%s-full.jpg" % plateName, 'JPEG', quality=95)
72
73 referenceImageMap = referenceImage.resize((8,8) , Image.ANTIALIAS)
74 referenceImageMap.save("tmp/%s-reference.jpg" % plateName, 'JPEG', quality=95)
75
76 diffMap = plateMap-referenceImageMap
77
78 step=8./plate.size[0]
79
80 platePix = plate.load()
81 for i in range(plate.size[0]):
82 for j in range(plate.size[1]):
83 platePix[i, j] = platePix[i, j]+i*step
84
85 print "Done enhancing plate"
86 """
87 return plate
88
89def enhancePlate2(plateName, plate, referenceImage):
90 """Return a transformed version of the plate so that it matches the referenceImage"""
91 #print "Enhance darker part of the image"
92 plate = plate.point(lambda t : 2.*t-256.*(t/256.)**1.8)
93
94 enhanceScaling = 32
95
96 print "Enhance plate"
97 plate = plate.resize((256,256) , Image.BICUBIC)
98 plate.save("tmp/%s-full.jpg" % plateName, 'JPEG', quality=95)
99 #referenceImage = referenceImage.resize(plate.size, Image.BILINEAR)
100 referenceImage.save("tmp/%s-reference.jpg" % plateName, 'JPEG', quality=95)
101
102 plate = None
103 #referenceImage = None
104
105 #os.system("python src/main.py --hi_res tmp/%s-full.jpg --lo_res tmp/%s-reference.jpg --output tmp/%s-enhanced.jpg" % (plateName, plateName, plateName) )
106 referenceImage.save("tmp/%s-enhanced.jpg" % plateName, 'JPEG', quality=95)
107
108 plate = Image.open("tmp/%s-enhanced.jpg" % plateName)
109 plate = plate.resize((plate.size[0]*enhanceScaling, plate.size[0]*enhanceScaling) , Image.BILINEAR)
110 print "Done enhancing plate"
111
112 return plate
113
114class DssWcs:
115 """A pixel to sky conversion class. It wraps a WCS object read from the FITS header"""
116 def __init__(self, plateName):
117 # Load the FITS hdulist using astropy.io.fits
118 assert os.path.exists("preparedPlates/")
119 hdulist = fits.open("preparedPlates/%s/%s_00_00_x64-FITS-header.hhh" % (plateName, plateName))
120 self.w = wcs.WCS(hdulist[0].header)
121
122 try:
123 f = open("preparedPlates/%s/%s.offsets" % (plateName, plateName), 'r')
124 except IOError:
125 self.gridPixelPos = None
126 self.gridOffset = None
127 self.inverseGridPixelPos = None
128 else:
129 offsets = json.loads(f.read())
130 f.close()
131
132 self.gridPixelPos = []
133 self.gridOffset = []
134 self.inverseGridPixelPos = []
135 for el in offsets:
136 self.gridPixelPos.append(el['pixelPos'])
137 self.gridOffset.append(el['offset'])
138 self.inverseGridPixelPos.append([el['pixelPos'][0]+el['offset'][0], el['pixelPos'][1]+el['offset'][1]])
139 self.gridPixelPos = numpy.array(self.gridPixelPos)
140 self.gridOffset = numpy.array(self.gridOffset)
141 self.inverseGridPixelPos = numpy.array(self.inverseGridPixelPos)
142
143 def pixelToRaDec(self, pixelPos):
144 """Return the RA DEC pair for a given pixel position (even if outside the plate)
145 the passed wcs must be the one laying in the preparedPlates directory"""
146 arr = [pixelPos[0], pixelPos[1]]
147 if self.inverseGridPixelPos!=None:
148 nearestOffset = scipy.interpolate.griddata(self.inverseGridPixelPos, self.gridOffset, [arr], method='nearest')
149 arr = [arr[0]-nearestOffset[0][0], arr[1]-nearestOffset[0][1]]
150
151 arr = [arr[0]/64.+1.5, arr[1]/64.+1.5]
152 arr = numpy.array([arr], numpy.float_)
153 ret = self.w.wcs_pix2world(arr, 1)
154 return [ret[0][0], ret[0][1]]
155
156 def raDecToPixel(self, raDecPos):
157 """Return the pixel pos for a given RA DEC sky position (even if outside the plate)
158 the passed wcs must be the one laying in the preparedPlates directory"""
159 arr = numpy.array([[raDecPos[0], raDecPos[1]]], numpy.float_)
160 ret = self.w.wcs_world2pix(arr, 1)
161 ret = [(ret[0][0]-1.5)*64., (ret[0][1]-1.5)*64.]
162
163 # Add offset to compensate for linear WCS model errors
164 if self.gridOffset!=None:
165 nearestOffset = scipy.interpolate.griddata(self.gridPixelPos, self.gridOffset, [ret], method='nearest')
166 ret = [ret[0]+nearestOffset[0][0], ret[1]+nearestOffset[0][1]]
167
168 return ret
169
0170
=== added file 'util/DSSToStellarium/generateFullPlate.py'
--- util/DSSToStellarium/generateFullPlate.py 1970-01-01 00:00:00 +0000
+++ util/DSSToStellarium/generateFullPlate.py 2016-11-13 10:24:15 +0000
@@ -0,0 +1,159 @@
1#!/usr/bin/python
2
3# This file is part of Stellarium. Stellarium is free software: you can
4# redistribute it and/or modify it under the terms of the GNU General Public
5# License as published by the Free Software Foundation, version 2.
6#
7# This program is distributed in the hope that it will be useful, but WITHOUT
8# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10# details.
11#
12# You should have received a copy of the GNU General Public License along with
13# this program; if not, write to the Free Software Foundation, Inc., 51
14# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15#
16# Copyright Fabien Chereau <fabien.chereau@gmail.com>
17
18
19# -----------------------------------------------------------
20# Generate the survey, i.e.
21# Cut and re-project toast tiles from color DSS plates
22# -----------------------------------------------------------
23# python generateFullPlate.py
24#
25# input : the "preparedPlates" directory created in step 1 must be present
26# output: a "results" directory containing the survey ready for display in Stellarium
27
28
29import Image, ImageFilter, ImageStat, ImageChops, ImageOps, ImageDraw, ImageFont
30import os
31import json
32from subprocess import Popen, PIPE, STDOUT
33import sys
34import dssUtils
35
36# Test code where I tried to use a low res image from Axel mellinger as reference
37# for color harmonization (the image we use for the milky way in Stellarium)
38# It's not working well yet, so let commented for now
39#mellingerImage = Image.open("mellinger_rgb_rect-curved.jpg")
40#mellingerImagePix = mellingerImage.load()
41
42def generatePlate(plateName, maxLevel):
43 if not os.path.exists("results"):
44 os.system("mkdir results")
45 if not os.path.exists("results/%d" % maxLevel):
46 os.system("mkdir results/%d" % maxLevel)
47 if not os.path.exists("tmp"):
48 os.system("mkdir tmp")
49
50 print "-------- " + plateName + " --------"
51 if os.path.exists("results/%s.stamp" % (plateName)):
52 print "Plate %s already processed" % (plateName)
53 return
54
55 assert os.path.exists("preparedPlates")
56 assert os.path.exists("preparedPlates/%s/%s.jpg" % (plateName, plateName))
57
58 print "Get list of TOAST tiles intersecting the plate"
59
60 wcs = dssUtils.DssWcs(plateName)
61
62 # And make sure to get rid of the plate edges in the corner..
63 #points = dssUtils.getValidRegionForPlate(plateName)
64 points = [[0,0], [19200, 0], [19200, 19200], [0, 19200]]
65 plateCornersRaDec = [wcs.pixelToRaDec(p) for p in points]
66 cmd = './toastForShape %d "' % (maxLevel) + json.dumps(plateCornersRaDec).replace('"', '\\"') + '"'
67 print cmd
68 p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
69 jsonTriangles = p.stdout.read()
70 triangles = json.loads(jsonTriangles)
71
72 print "Convert the pixel position of the toast tiles into the existing DSS image"
73 allTrianglesRadecPos = []
74 for tri in triangles:
75 allTrianglesRadecPos.extend(tri['tile'][1:])
76 allTrianglesPixelPos = [wcs.raDecToPixel(p) for p in allTrianglesRadecPos]
77
78 # Put all contained triangles (to be cut) in the tiles dict
79 tiles = {}
80 i=0
81 for tri in triangles:
82 tile = allTrianglesPixelPos[i*4:i*4+4]
83 t = {'XY': [tri['i'], tri['j']], 'tile': tile}
84 tiles[json.dumps(t['XY'])]=t
85 i=i+1
86
87 tiles = tiles.values()
88
89 print "Cut and save the toast tiles (%d tiles at level %s)." % (len(tiles), maxLevel)
90
91 # Create the sub directories
92
93 os.system("mkdir tmp/%s" % plateName)
94 os.system("mkdir tmp/%s/%d" % (plateName, maxLevel))
95
96
97 print "load full plate image"
98 resImg = Image.open("preparedPlates/%s/%s.jpg" % (plateName, plateName))
99 #draw = ImageDraw.Draw(resImg)
100 #font = ImageFont.truetype("DejaVuSans.ttf", 600)
101 #draw.text([9500, 9500], plateName, font=font, fill=(255,255,0))
102
103 resImg = ImageOps.flip(resImg)
104
105 def raDecToMellinger(raDec):
106 return [(-raDec[0]/360.+0.5)*mellingerImage.size[0], (-raDec[1]/180.+0.5)*mellingerImage.size[1]]
107
108 # Generate a low res reference image from Mellinger data
109 delta = 19200./256.
110 referenceImage = Image.new("RGB", (256, 256))
111 #pix = referenceImage.load()
112 #for i in range(256):
113 # for j in range(256):
114 # raDec = wcs.pixelToRaDec((i*delta+delta/2, j*delta+delta/2))
115 # if raDec[0]>180:
116 # raDec[0]=raDec[0]-360
117 # mellingerPos = raDecToMellinger(raDec)
118 # pix[i, j] = mellingerImagePix[mellingerPos[0], mellingerPos[1]]
119
120 # Enhance plate
121 resImg = dssUtils.enhancePlate(plateName, resImg, referenceImage)
122
123 def isPartial(imageW, imageH, region):
124 for i in range(len(region)/2):
125 p = [region[i*2], region[i*2+1]]
126 if p[0]<0 or p[0]>imageW or p[1]<0 or p[1]>imageH:
127 return True
128 return False
129
130 print "Cut tiles"
131 for tile in tiles:
132 tt = []
133 partial = False
134 for p in tile['tile']:
135 x=p[0]
136 y=p[1]
137 tt.append(x)
138 tt.append(y)
139 tt = tt[6:]+tt[0:6]
140
141 partial = isPartial(resImg.size[0], resImg.size[1], tt)
142 im = resImg.transform((256,256), Image.QUAD, tuple(tt), Image.BILINEAR)
143
144 xy = tile['XY']
145 im.save("tmp/%s/%d/%d_%d%s.jpg" % (plateName, maxLevel, xy[0], xy[1], "-partial" if partial else ""), quality=95)
146
147 print "package and store results"
148 os.system("mv tmp/%s/%d/* results/%d/" % (plateName, maxLevel, maxLevel))
149 os.system("rm -rf tmp/%s" % plateName)
150 os.system("touch results/%s.stamp" % plateName)
151
152
153if __name__ == '__main__':
154 maxLevel = 11
155
156 for plate in dssUtils.getAllPlatesNames():
157 generatePlate(plate, maxLevel)
158
159 os.system("python createUpperToastLevels.py")
0160
=== added file 'util/DSSToStellarium/mellinger_rgb_rect-curved.jpg'
1Binary files util/DSSToStellarium/mellinger_rgb_rect-curved.jpg 1970-01-01 00:00:00 +0000 and util/DSSToStellarium/mellinger_rgb_rect-curved.jpg 2016-11-13 10:24:15 +0000 differ161Binary files util/DSSToStellarium/mellinger_rgb_rect-curved.jpg 1970-01-01 00:00:00 +0000 and util/DSSToStellarium/mellinger_rgb_rect-curved.jpg 2016-11-13 10:24:15 +0000 differ
=== added file 'util/DSSToStellarium/prepareAllPlates.py'
--- util/DSSToStellarium/prepareAllPlates.py 1970-01-01 00:00:00 +0000
+++ util/DSSToStellarium/prepareAllPlates.py 2016-11-13 10:24:15 +0000
@@ -0,0 +1,117 @@
1#!/usr/bin/python
2
3# This file is part of Stellarium. Stellarium is free software: you can
4# redistribute it and/or modify it under the terms of the GNU General Public
5# License as published by the Free Software Foundation, version 2.
6#
7# This program is distributed in the hope that it will be useful, but WITHOUT
8# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10# details.
11#
12# You should have received a copy of the GNU General Public License along with
13# this program; if not, write to the Free Software Foundation, Inc., 51
14# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15#
16# Copyright Fabien Chereau <fabien.chereau@gmail.com>
17
18import Image, ImageFilter, ImageStat, ImageChops
19import os
20from astLib import astWCS
21import json
22from subprocess import Popen, PIPE, STDOUT
23import sys
24from multiprocessing import Pool
25import dssUtils
26from astropy import wcs
27from astropy.io import fits
28import numpy
29
30# -----------------------------------------------------------
31# Pre-process zipped plates to extract only necessary data
32# This has to be run once if you don't already have the
33# preprocessed plates
34# -----------------------------------------------------------
35# python prepareAllPlates.py
36#
37# input : a directory with all original plates .tgz files (change in code)
38# output: a directory "preparedPlates" containing for each plate a single full resolution jpg image + a FITS headers necessary for sky-to-pixel projection
39# usage : you must change the location of your input DSS plates path directly in the script
40
41# The directory containing the plates .tgz files
42originalPlatesDirectory = "/media/fabien/data/DSS-orig"
43
44# Pre-compute meta-infos about the plate as well as a re-combination of all tile into one large image
45def preparePlate(plateName):
46 if not os.path.exists("preparedPlates"):
47 os.system("mkdir preparedPlates")
48
49 if os.path.exists("preparedPlates/%s-x64-FITS-header.hhh" % plateName):
50 print "%s already processed, skip." % plateName
51 return
52
53 print "-------- " + plateName + " --------"
54 if os.path.exists("preparedPlates/%s" % (plateName)):
55 print "Plate %s already pre-processed" % (plateName)
56 return
57 print "Copy and prepare plate data"
58 os.system("cp %s/%s.tgz ." % (originalPlatesDirectory, plateName))
59 os.system("tar -xzf %s.tgz" % plateName)
60 os.system("chmod -R a+w %s" % plateName)
61 assert os.path.exists("%s" % plateName)
62
63 print "create full plate image"
64 resImg=Image.new("RGB", (64*300, 64*300))
65 for j in range(0, 64):
66 for i in range(0,64):
67 if os.path.exists("%s/x1/%s_%.2d_%.2d_x1.jpg" % (plateName, plateName, i, j)):
68 im = Image.open("%s/x1/%s_%.2d_%.2d_x1.jpg" % (plateName, plateName, i, j))
69 resImg.paste(im, (i*300, 64*300-j*300-300))
70 else:
71 print "Missing jpeg tile: %s/x1/%s_%.2d_%.2d_x1.jpg" % (plateName, plateName, i, j)
72
73 print "package and store results"
74 os.system("mkdir preparedPlates/%s" % plateName)
75 resImg.save("preparedPlates/%s/%s.jpg" % (plateName, plateName))
76 os.system("cp %s/x64/%s_00_00_x64.hhh preparedPlates/%s/%s_00_00_x64-FITS-header.hhh" % (plateName, plateName, plateName, plateName))
77
78 wcsWithoutCorrection = dssUtils.DssWcs(plateName)
79
80 print "Compute the array of pixel offsets needed to adjust WCS conversions."
81 # Load the x1 FITS headers to get the corrective offset term
82 allOffsets = []
83
84 for i in range(0,64, 4):
85 for j in range(0, 64, 4):
86 if not os.path.exists("%s/x1/%s_%.2d_%.2d_x1.hhh" % (plateName, plateName, i, j)):
87 print "Missing .hhh file"
88 continue
89 hdulist = fits.open("%s/x1/%s_%.2d_%.2d_x1.hhh" % (plateName, plateName, i, j))
90 w = wcs.WCS(hdulist[0].header)
91 arr = numpy.array([[0., 0.]], numpy.float_) # Bottom left corner
92 radecCorner = w.wcs_pix2world(arr, 1)
93 realPixelPos = [i*300, j*300]
94 currPixelPos = wcsWithoutCorrection.raDecToPixel([radecCorner[0][0], radecCorner[0][1]])
95 assert currPixelPos!=None
96 allOffsets.append({'pixelPos': currPixelPos, 'offset': [realPixelPos[0]-currPixelPos[0], realPixelPos[1]-currPixelPos[1]]})
97
98 f = open("preparedPlates/%s/%s.offsets" % (plateName, plateName), 'w')
99 f.write(json.dumps(allOffsets))
100 f.close()
101
102 print "clean up"
103 os.system("rm %s.tgz" % plateName)
104 os.system("rm -rf %s" % plateName)
105
106jobsArgs = dssUtils.getAllPlatesNames()()
107
108pool = Pool(2)
109try:
110 pool.map_async(preparePlate, jobsArgs).get(9999999)
111except KeyboardInterrupt:
112 print "Caught KeyboardInterrupt, terminating workers"
113 pool.terminate()
114 pool.join()
115
116
117
0118
=== added file 'util/DSSToStellarium/readme.txt'
--- util/DSSToStellarium/readme.txt 1970-01-01 00:00:00 +0000
+++ util/DSSToStellarium/readme.txt 2016-11-13 10:24:15 +0000
@@ -0,0 +1,33 @@
1A set of pyton scripts used to process DSS plates for Stellarium
2
3Dependencies:
4 - astropy: (sudo pip install astropy)
5 - PIL (sudo apt-get install python-imaging)
6 - numpy
7
8-----------------------------------------------------------
91- Pre-process zipped plates to extract only necessary data
10-----------------------------------------------------------
11python prepareAllPlates.py
12
13input: a directory with all original plates .tgz files (change in code)
14output: a directory "preparedPlates" containing for each plate a single full resolution jpg image + a FITS headers necessary for sky-to-pixel projection
15usage: you must change the location of your input DSS plates path directly in the script
16
17
18-----------------------------------------------------------
192- Generate the survey
20-----------------------------------------------------------
21python generateFullPlate.py
22
23input: the "preparedPlates" directory created in step 1 must be present
24output: a "results" directory containing the survey ready for display in Stellarium
25
26
27-----------------------------------------------------------
283- Display the survey
29-----------------------------------------------------------
30Get the Stellarium branch bzr+ssh://bazaar.launchpad.net/~stellarium/stellarium/toastImages
31Change the base location of the survey to match the path where the results/ directory is stored. This can be done in ToastMgr.cpp line 29
32Compile and run the soft. Remove ground and atmosphere (press G and A), the survey should be visible in the south hemisphere.
33
034
=== added file 'util/DSSToStellarium/toastForShape'
1Binary files util/DSSToStellarium/toastForShape 1970-01-01 00:00:00 +0000 and util/DSSToStellarium/toastForShape 2016-11-13 10:24:15 +0000 differ35Binary files util/DSSToStellarium/toastForShape 1970-01-01 00:00:00 +0000 and util/DSSToStellarium/toastForShape 2016-11-13 10:24:15 +0000 differ
=== added directory 'util/toastForShape'
=== added file 'util/toastForShape/main.cpp'
--- util/toastForShape/main.cpp 1970-01-01 00:00:00 +0000
+++ util/toastForShape/main.cpp 2016-11-13 10:24:15 +0000
@@ -0,0 +1,38 @@
1#include <QtCore/QCoreApplication>
2#include "StelToast.hpp"
3#include "StelJsonParser.hpp"
4
5int main(int argc, char *argv[])
6{
7 Q_ASSERT(argc==3);
8 QByteArray ar = argv[1];
9 bool ok;
10 int level = ar.toInt(&ok);
11 if (!ok)
12 {
13 qFatal("Argument 1 must be a valid level number");
14 }
15 int length = sqrt(pow(4, level));
16 SphericalRegionP reg = SphericalRegionP::loadFromQVariant(StelJsonParser::parse(argv[2]).toList());
17 //SphericalRegionP reg = SphericalRegionP::loadFromQVariant(StelJsonParser::parse("[[21.286982057125858, 82.117482778097937], [341.20801035028205, 82.141350178494122], [308.54824444399429, 86.661406614892087], [54.398199236987082, 86.613098160666411]]").toList());
18 ToastGrid grid(level);
19 QVariantList l;
20 for (int i=0;i<length;++i)
21 {
22 for (int j=0;j<length;++j)
23 {
24 SphericalConvexPolygon poly(grid.getPolygon(level,i,j));
25 if (reg->intersects(poly))
26 {
27 QVariantMap m;
28 m["i"]=i;
29 m["j"]=j;
30 m["tile"]= poly.toQVariant();
31 l << m;
32 }
33 }
34 }
35 printf("%s", StelJsonParser::write(l).constData());
36
37 return 0;
38}
039
=== added file 'util/toastForShape/toastForShape.pro'
--- util/toastForShape/toastForShape.pro 1970-01-01 00:00:00 +0000
+++ util/toastForShape/toastForShape.pro 2016-11-13 10:24:15 +0000
@@ -0,0 +1,73 @@
1#-------------------------------------------------
2#
3# Project created by QtCreator 2010-11-28T20:43:35
4#
5#-------------------------------------------------
6
7QT += core gui opengl network
8
9DEFINES += PACKAGE_VERSION=\\\"0.10.6\\\"
10DEFINES += DEFAULT_GRAPHICS_SYSTEM=\\\"raster\\\"
11DEFINES += INSTALL_DATADIR=\\\"/usr/share/stellarium\\\"
12DEFINES += INSTALL_LOCALEDIR=\\\"/usr/share/locale\\\"
13DEFINES += NDEBUG=1
14
15TARGET = toastForShape
16CONFIG += console
17CONFIG -= app_bundle
18
19TEMPLATE = app
20
21INCLUDEPATH += ../../src/core/ ../../src/core/external/glues_stel/source ../../src/core/external
22
23SOURCES += main.cpp \
24 ../../src/core/StelSphereGeometry.cpp \
25 ../../src/core/StelToastGrid.cpp \
26 ../../src/core/StelJsonParser.cpp \
27 ../../src/core/OctahedronPolygon.cpp \
28 ../../src/core/StelUtils.cpp \
29 ../../src/core/StelProjector.cpp \
30 ../../src/core/external/glues_stel/source/glues_error.c \
31 ../../src/core/external/glues_stel/source/libtess/tessmono.c \
32 ../../src/core/external/glues_stel/source/libtess/tess.c \
33 ../../src/core/external/glues_stel/source/libtess/sweep.c \
34 ../../src/core/external/glues_stel/source/libtess/render.c \
35 ../../src/core/external/glues_stel/source/libtess/priorityq.c \
36 ../../src/core/external/glues_stel/source/libtess/normal.c \
37 ../../src/core/external/glues_stel/source/libtess/mesh.c \
38 ../../src/core/external/glues_stel/source/libtess/memalloc.c \
39 ../../src/core/external/glues_stel/source/libtess/geom.c \
40 ../../src/core/external/glues_stel/source/libtess/dict.c \
41 ../../src/core/StelVertexArray.cpp \
42 ../../src/core/StelTranslator.cpp \
43 ../../src/core/StelFileMgr.cpp
44
45HEADERS += \
46 ../../src/core/VecMath.hpp \
47 ../../src/core/StelSphereGeometry.hpp \
48 ../../src/core/StelToastGrid.hpp \
49 ../../src/core/StelJsonParser.hpp \
50 ../../src/core/OctahedronPolygon.hpp \
51 ../../src/core/StelUtils.hpp \
52 ../../src/core/external/glues_stel/source/glues.h \
53 ../../src/core/external/glues_stel/source/glues_error.h \
54 ../../src/core/external/glues_stel/source/libtess/tessmono.h \
55 ../../src/core/external/glues_stel/source/libtess/tess.h \
56 ../../src/core/external/glues_stel/source/libtess/sweep.h \
57 ../../src/core/external/glues_stel/source/libtess/render.h \
58 ../../src/core/external/glues_stel/source/libtess/priorityq.h \
59 ../../src/core/external/glues_stel/source/libtess/priorityq-sort.h \
60 ../../src/core/external/glues_stel/source/libtess/priorityq-heap.h \
61 ../../src/core/external/glues_stel/source/libtess/normal.h \
62 ../../src/core/external/glues_stel/source/libtess/mesh.h \
63 ../../src/core/external/glues_stel/source/libtess/memalloc.h \
64 ../../src/core/external/glues_stel/source/libtess/geom.h \
65 ../../src/core/external/glues_stel/source/libtess/dict.h \
66 ../../src/core/external/glues_stel/source/libtess/dict-list.h \
67 ../../src/core/StelVertexArray.hpp \
68 ../../src/core/StelTranslator.hpp
69
70OTHER_FILES += \
71 ../../src/core/external/glues_stel/source/libtess/README \
72 ../../src/core/external/glues_stel/source/libtess/priorityq-heap.i \
73 ../../src/core/external/glues_stel/source/libtess/alg-outline