Merge lp:~peppujols/stellarium/printsky into lp:stellarium

Proposed by Pep Pujols
Status: Superseded
Proposed branch: lp:~peppujols/stellarium/printsky
Merge into: lp:stellarium
Diff against target: 1887 lines (+1738/-2)
19 files modified
CMakeLists.txt (+3/-2)
plugins/CMakeLists.txt (+3/-0)
plugins/PrintSky/CMakeLists.txt (+11/-0)
plugins/PrintSky/PrintSky.qrc (+6/-0)
plugins/PrintSky/nightStyle.css (+31/-0)
plugins/PrintSky/normalStyle.css (+31/-0)
plugins/PrintSky/src/CMakeLists.txt (+69/-0)
plugins/PrintSky/src/PrintSky.cpp (+171/-0)
plugins/PrintSky/src/PrintSky.hpp (+70/-0)
plugins/PrintSky/src/gui/PrintSkyDialog.cpp (+625/-0)
plugins/PrintSky/src/gui/PrintSkyDialog.hpp (+96/-0)
plugins/PrintSky/src/gui/StelDialogPrintSky.cpp (+134/-0)
plugins/PrintSky/src/gui/StelDialogPrintSky.hpp (+52/-0)
plugins/PrintSky/src/gui/printskyDialog.ui (+350/-0)
src/CMakeLists.txt (+6/-0)
src/StelMainGraphicsView.cpp (+4/-0)
src/StelMainGraphicsView.hpp (+4/-0)
src/core/modules/StarMgr.cpp (+67/-0)
src/core/modules/StarMgr.hpp (+5/-0)
To merge this branch: bzr merge lp:~peppujols/stellarium/printsky
Reviewer Review Type Date Requested Status
Bogdan Marinov Pending
Matthew Gates Pending
Review via email: mp+42390@code.launchpad.net

This proposal supersedes a proposal from 2010-11-05.

This proposal has been superseded by a proposal from 2011-01-07.

To post a comment you must log in.
Revision history for this message
Matthew Gates (matthew-porpoisehead) wrote : Posted in a previous version of this proposal

I found a couple of without looking into the code:

1. The preview window shows badly corrupted fonts. I think the font size is too big and/or the line spacing is not big enough. See http://i.imgur.com/ccR7I.png

2. The configuration dialog form design is not so good. Spacers and a tab level layout should be used to make the form re-sizable. I would also prefer the colouration to be the same as the other configuration dialogs (this is probably just a matter of copying the stylesheet from the Satellite or Occural plugin).

Matthew

review: Needs Fixing
Revision history for this message
Bogdan Marinov (daggerstab) wrote : Posted in a previous version of this proposal

I agree that it needs some fixing.

Matthew, Pep, did you see the experimental build of Stellarium I've uploaded here?
https://launchpad.net/stellarium/+download
One of the two new plug-ins included in it is a _fixed_ version of Print Sky.

I can provide a patch with my changes. The main problem: it seems that the absolute coordinates used assume a resolution of 300 DPI (dots per inch). If the printer uses a higher resolution, the text appears too small and/or with wrong line spacing. My patch also includes some improvements to the interface.

review: Needs Fixing
Revision history for this message
treaves (treaves) wrote : Posted in a previous version of this proposal

There are several of unused method arguments. For places where you can not change the signature, please use the Q_UNUSED macro.

I'll look over it more when I get home from work; all I had time for was a simple compile check, and that's what showed the above feedback.

Revision history for this message
Bogdan Marinov (daggerstab) wrote : Posted in a previous version of this proposal

I've uploaded a branch with the changes I made to the plug-in when I added it to the experimental build and I've proposed it for merging into Pep Pujols' original branch.
https://code.launchpad.net/~daggerstab/stellarium/printsky

I have also uploaded to Scribd a sample of what the output from my version looks like:
http://www.scribd.com/doc/41205546/PrintSky-Output-Version-Exp02

Revision history for this message
Bogdan Marinov (daggerstab) wrote :

Just a comment - as the feature freeze is in effect, this should be merged only AFTER the release of 0.10.6 this weekend.

Skimming the code, I've noticed several unresolved merge conflicts, with Bazaar conflict markup in the source files.

Pep, if you set Bazaar to use the same e-mail address as the one you use in Launchpad, Launchpad will put a link to your profile page when it lists the revisions that you have committed. (See "Unmerged revisions" bellow: the author is listed as "Propietario", and there is no link.)

I'll build the plug-in and look deeper into the code later.

Revision history for this message
Pep Pujols (peppujols) wrote :

> Just a comment - as the feature freeze is in effect, this should be merged only AFTER the release of 0.10.6 this weekend.
>

Ok. No problem.

> Skimming the code, I've noticed several unresolved merge conflicts, with Bazaar conflict markup in the source files.
>

Yes, I should first pull and merge the trunk to my branch (resolving
conflicts) before push my branch to propose to merge?

> Pep, if you set Bazaar to use the same e-mail address as the one you use in Launchpad, Launchpad will put a link to your profile page when it lists the revisions that you have committed. (See "Unmerged revisions" bellow: the author is listed as "Propietario", and there is no link.)

Oh, yeah, I installed the bzr on a new PC and I forget to define my
credentials and EMail. I do it. In the future the new revisions will be
correct.

> I'll build the plug-in and look deeper into the code later.

Thanks.

Pep.

lp:~peppujols/stellarium/printsky updated
4714. By Pep Pujols

Merged in trunk, and corrected ISO C++ bug

4715. By Pep Pujols

Merge Trunk

4716. By Pep Pujols

Fixed some points: Invalid defines, removed pragma marks, reallocation owner metod from StarMgr to PrintSkyDialog

4717. By Pep Pujols

Merged from trunk

4718. By Pep Pujols

More simplified method getListMagnitudeRadius. Small patch to plugin info definition.

4719. By Pep Pujols

Fixed style dialog wrong

4720. By Pep Pujols

Merged from trunk

4721. By Pep Pujols

Merged from trunk (atmosphere refraction)

4722. By Pep Pujols

Added GNU GPL header to the main class.

4723. By Pep Pujols

Merge from code refactoring

Unmerged revisions

4723. By Pep Pujols

Merge from code refactoring

4722. By Pep Pujols

Added GNU GPL header to the main class.

4721. By Pep Pujols

Merged from trunk (atmosphere refraction)

4720. By Pep Pujols

Merged from trunk

4719. By Pep Pujols

Fixed style dialog wrong

4718. By Pep Pujols

More simplified method getListMagnitudeRadius. Small patch to plugin info definition.

4717. By Pep Pujols

Merged from trunk

4716. By Pep Pujols

Fixed some points: Invalid defines, removed pragma marks, reallocation owner metod from StarMgr to PrintSkyDialog

4715. By Pep Pujols

Merge Trunk

4714. By Pep Pujols

Merged in trunk, and corrected ISO C++ bug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2010-12-06 14:07:59 +0000
3+++ CMakeLists.txt 2011-01-07 22:29:26 +0000
4@@ -9,7 +9,7 @@
5 ENDIF()
6
7 ########### Project name ###########
8-PROJECT(Stellarium)
9+PROJECT(Printsky)
10 SET(STELLARIUM_MAJOR "0")
11 SET(STELLARIUM_MINOR "10")
12 SET(STELLARIUM_PATCH "6")
13@@ -61,7 +61,7 @@
14 # SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.5")
15 # SET(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk/")
16 # Universal binary
17- #SET(CMAKE_OSX_ARCHITECTURES "x86_64")
18+SET(CMAKE_OSX_ARCHITECTURES "x86_64")
19 ENDIF()
20
21 ########### Check functions ###########
22@@ -137,6 +137,7 @@
23 SET(USE_PLUGIN_TIMEZONECONFIGURATION 1 CACHE BOOL "Define whether the TimeZoneConfiguration plugin should be created.")
24 SET(USE_PLUGIN_VIRGO 0 CACHE BOOL "Define whether the VirGO plugin should be created.")
25 SET(USE_PLUGIN_SOLARSYSTEMEDITOR 1 CACHE BOOL "Define whether the Solar System Editor should be built.")
26+SET(USE_PLUGIN_PRINTSKY 1 CACHE BOOL "Define wheter the PrintSky plugin should be created.")
27
28 ########## Static plugins need to define includes and libraries
29 ########## for the compilation of Stellarium itself
30
31=== modified file 'plugins/CMakeLists.txt'
32--- plugins/CMakeLists.txt 2010-11-12 15:29:52 +0000
33+++ plugins/CMakeLists.txt 2011-01-07 22:29:26 +0000
34@@ -44,3 +44,6 @@
35 IF (USE_PLUGIN_SOLARSYSTEMEDITOR)
36 ADD_SUBDIRECTORY( SolarSystemEditor )
37 ENDIF()
38+IF (USE_PLUGIN_PRINTSKY)
39+ ADD_SUBDIRECTORY( PrintSky )
40+ENDIF()
41
42=== added directory 'plugins/PrintSky'
43=== added file 'plugins/PrintSky/CMakeLists.txt'
44--- plugins/PrintSky/CMakeLists.txt 1970-01-01 00:00:00 +0000
45+++ plugins/PrintSky/CMakeLists.txt 2011-01-07 22:29:26 +0000
46@@ -0,0 +1,11 @@
47+# This is the cmake config file for the PrintSky plugin
48+SET(PRINTSKY_VERSION "0.1.0")
49+
50+ADD_SUBDIRECTORY( src )
51+
52+IF(APPLE)
53+ SET(CMAKE_INSTALL_PREFIX $ENV{HOME}/Library/Application\ Support/Stellarium)
54+ElSE(APPLE)
55+ SET(CMAKE_INSTALL_PREFIX $ENV{HOME}/.stellarium)
56+ENDIF(APPLE)
57+INSTALL(FILES DESTINATION "modules/PrintSky")
58
59=== added file 'plugins/PrintSky/PrintSky.qrc'
60--- plugins/PrintSky/PrintSky.qrc 1970-01-01 00:00:00 +0000
61+++ plugins/PrintSky/PrintSky.qrc 2011-01-07 22:29:26 +0000
62@@ -0,0 +1,6 @@
63+<RCC>
64+ <qresource prefix="printsky">
65+ <file>nightStyle.css</file>
66+ <file>normalStyle.css</file>
67+ </qresource>
68+</RCC>
69
70=== added file 'plugins/PrintSky/nightStyle.css'
71--- plugins/PrintSky/nightStyle.css 1970-01-01 00:00:00 +0000
72+++ plugins/PrintSky/nightStyle.css 2011-01-07 22:29:26 +0000
73@@ -0,0 +1,31 @@
74+QTabBar {
75+ border: none;
76+ margin: 0px;
77+ padding: 0px;
78+ font-weight: bold;
79+ color: rgb(120, 0, 0);
80+ background-color: rgb(22, 0, 0);
81+ font-size: 14px;
82+}
83+
84+QTabBar::tab {
85+ border: 0px;
86+ margin: 0px;
87+ padding: 4px 1ex;
88+ min-height: 28px;
89+ /*font-size: 14px; <-- Causes text being cut by the frame*/
90+}
91+
92+QTabBar::tab:selected {
93+ border: none;
94+ margin: 0px;
95+ border-top-left-radius: 10px;
96+ border-top-right-radius: 10px;
97+ color: rgb(220, 0, 0);
98+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(68, 0, 0), stop: 1 rgb(86, 0, 0));
99+}
100+
101+QTabWidget::pane {
102+ margin-top: 0px;
103+ border-top: none;
104+}
105
106=== added file 'plugins/PrintSky/normalStyle.css'
107--- plugins/PrintSky/normalStyle.css 1970-01-01 00:00:00 +0000
108+++ plugins/PrintSky/normalStyle.css 2011-01-07 22:29:26 +0000
109@@ -0,0 +1,31 @@
110+QTabBar {
111+ border: none;
112+ margin: 0px;
113+ padding: 0px;
114+ font-weight: bold;
115+ color: rgb(170, 173, 164);
116+ background-color: rgb(31, 31, 31);
117+ font-size: 14px;
118+}
119+
120+QTabBar::tab {
121+ border: 0px;
122+ margin: 0px;
123+ padding: 4px 1ex;
124+ min-height: 28px;
125+ /*font-size: 14px; <-- Causes text being cut by the frame*/
126+}
127+
128+QTabBar::tab:selected {
129+ border: none;
130+ margin: 0px;
131+ border-top-left-radius: 10px;
132+ border-top-right-radius: 10px;
133+ color: rgb(220, 223, 214);
134+ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(68, 69, 72), stop: 1 rgb(86, 87, 90));
135+}
136+
137+QTabWidget::pane {
138+ margin-top: 0px;
139+ border-top: none;
140+}
141
142=== added directory 'plugins/PrintSky/src'
143=== added file 'plugins/PrintSky/src/CMakeLists.txt'
144--- plugins/PrintSky/src/CMakeLists.txt 1970-01-01 00:00:00 +0000
145+++ plugins/PrintSky/src/CMakeLists.txt 2011-01-07 22:29:26 +0000
146@@ -0,0 +1,69 @@
147+INCLUDE_DIRECTORIES(
148+ .
149+ gui
150+ ${CMAKE_BINARY_DIR}/plugins/PrintSky/src
151+)
152+LINK_DIRECTORIES(${BUILD_DIR}/src)
153+
154+SET(PrintSky_SRCS
155+ PrintSky.hpp
156+ PrintSky.cpp
157+ gui/PrintSkyDialog.hpp
158+ gui/PrintSkyDialog.cpp
159+ gui/StelDialogPrintSky.hpp
160+ gui/StelDialogPrintSky.cpp
161+ )
162+
163+################# compiles resources files ############
164+SET(PrintSky_RES ../PrintSky.qrc)
165+QT4_ADD_RESOURCES(PrintSky_RES_CXX ${PrintSky_RES})
166+
167+################# compiles .ui files ############
168+SET(PrintSky_UIS
169+ gui/printskyDialog.ui
170+)
171+QT4_WRAP_UI(PrintSky_UIS_H ${PrintSky_UIS})
172+
173+# Add here all the files which require moc compilation
174+# that is, all the headers with SIGNAL/SLOTS/PLUGIN_INTERFACE etc..
175+SET(PrintSky_MOC_HDRS
176+ PrintSky.hpp
177+ gui/PrintSkyDialog.hpp
178+ gui/StelDialogPrintSky.hpp
179+ )
180+
181+# After this call, PrintSky_MOC_SRCS = moc_PrintSky.cxx
182+QT4_WRAP_CPP(PrintSky_MOC_SRCS ${PrintSky_MOC_HDRS})
183+
184+SET(extLinkerOption ${QT_LIBRARIES} ${FreeType2_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES} ${ICONV_LIBRARIES} ${INTL_LIBRARIES})
185+
186+############### For building the dynamic library ######################
187+IF(BUILD_DYNAMIC_PLUGINS)
188+ ADD_LIBRARY(PrintSky MODULE ${PrintSky_SRCS} ${PrintSky_MOC_SRCS} ${PrintSky_RES_CXX} ${PrintSky_UIS_H})
189+ IF(APPLE)
190+ FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
191+ MARK_AS_ADVANCED(OPENGL_LIBRARY)
192+ SET_TARGET_PROPERTIES(PrintSky PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" SUFFIX ".dylib")
193+ ENDIF(APPLE)
194+
195+ IF(WIN32)
196+ SET_TARGET_PROPERTIES(PrintSky PROPERTIES LINK_FLAGS "-enable-runtime-pseudo-reloc -Wl,--allow-multiple-definition" )
197+ SET(StelMain stelMain)
198+ ELSE(WIN32)
199+ SET(StelMain )
200+ ENDIF(WIN32)
201+
202+ TARGET_LINK_LIBRARIES(PrintSky ${StelMain} ${extLinkerOption})
203+ INSTALL(TARGETS PrintSky DESTINATION "modules/${PACKAGE}")
204+ENDIF()
205+
206+############### For building the static library ######################
207+IF(BUILD_STATIC_PLUGINS)
208+ ADD_LIBRARY(PrintSky-static STATIC ${PrintSky_SRCS} ${PrintSky_MOC_SRCS} ${PrintSky_RES_CXX} ${PrintSky_UIS_H})
209+ # The library target "PrintSky-static" has a default OUTPUT_NAME of "PrintSky-static", so change it.
210+ SET_TARGET_PROPERTIES(PrintSky-static PROPERTIES OUTPUT_NAME "PrintSky")
211+ TARGET_LINK_LIBRARIES(PrintSky-static ${extLinkerOption})
212+ SET_TARGET_PROPERTIES(PrintSky-static PROPERTIES COMPILE_FLAGS "-fPIC -DQT_STATICPLUGIN")
213+ ADD_DEPENDENCIES(AllStaticPlugins PrintSky-static)
214+ENDIF()
215+
216
217=== added file 'plugins/PrintSky/src/PrintSky.cpp'
218--- plugins/PrintSky/src/PrintSky.cpp 1970-01-01 00:00:00 +0000
219+++ plugins/PrintSky/src/PrintSky.cpp 2011-01-07 22:29:26 +0000
220@@ -0,0 +1,171 @@
221+#include <QDebug>
222+#include <QKeyEvent>
223+#include "StelProjector.hpp"
224+#include "StelPainter.hpp"
225+#include "StelApp.hpp"
226+#include "StelCore.hpp"
227+#include "StelFileMgr.hpp"
228+#include "StelLocaleMgr.hpp"
229+#include "StelModuleMgr.hpp"
230+#include "StelGui.hpp"
231+#include "StelGuiItems.hpp"
232+#include "StelIniParser.hpp"
233+#include "StelVertexArray.hpp"
234+#include "PrintSky.hpp"
235+#include <QAction>
236+#include "StelMainGraphicsView.hpp"
237+#include <QGLWidget>
238+
239+//! This method is the one called automatically by the StelModuleMgr just
240+//! after loading the dynamic library
241+StelModule* PrintSkyStelPluginInterface::getStelModule() const
242+{
243+ return new PrintSky();
244+}
245+
246+StelPluginInfo PrintSkyStelPluginInterface::getPluginInfo() const
247+{
248+ // Allow to load the resources when used as a static plugin
249+ Q_INIT_RESOURCE(PrintSky);
250+
251+ StelPluginInfo info;
252+ info.id = "PrintSky";
253+ info.displayedName = "Print Sky";
254+ info.authors = "Pep Pujols";
255+ info.contact = "maslarocaxica@gmail.com";
256+ info.description = "Provides an system printing sky";
257+ return info;
258+}
259+
260+Q_EXPORT_PLUGIN2(PrintSky, PrintSkyStelPluginInterface)
261+
262+PrintSky::PrintSky()
263+{
264+ setObjectName("PrintSky");
265+ useInvertColors=scaleToFit=false;
266+ printData=true;
267+}
268+
269+PrintSky::~PrintSky()
270+{
271+ delete printskyDialog;
272+ printskyDialog = NULL;
273+}
274+
275+void PrintSky::init()
276+{
277+ printskyDialog = new PrintSkyDialog();
278+
279+ // create action for enable/disable & hook up signals
280+ StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
281+ Q_ASSERT(gui);
282+
283+ gui->addGuiActions("actionInit_Printing_Sky", N_("Printing Sky"), "Ctrl+P", "Plugin Key Bindings", true, false);
284+ gui->getGuiActions("actionInit_Printing_Sky")->setChecked(true);
285+ connect(gui->getGuiActions("actionInit_Printing_Sky"), SIGNAL(triggered()), this, SLOT(initPrintingSky()));
286+
287+ try
288+ {
289+ //Make sure that "/modules/PrintSky" exists
290+ StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::getUserDir() + "/modules/PrintSky/");
291+
292+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
293+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
294+
295+ QSettings settings(printskyIniPath, QSettings::IniFormat);
296+ useInvertColors = settings.value("use_invert_colors", 0.0).toBool();
297+ scaleToFit=settings.value("use_scale_to_fit", true).toBool();
298+ orientation=settings.value("orientation", "Portrait").toString();
299+ printData=settings.value("print_data", true).toBool();
300+ printSSEphemerides=settings.value("print_SS_ephemerides", true).toBool();
301+ }
302+ catch (std::runtime_error& e)
303+ {
304+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
305+ }
306+
307+ //Load the module's custom style sheets
308+ QFile styleSheetFile;
309+ styleSheetFile.setFileName(":/printsky/normalStyle.css");
310+ if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
311+ {
312+ normalStyleSheet = styleSheetFile.readAll();
313+ }
314+ styleSheetFile.close();
315+ styleSheetFile.setFileName(":/printsky/nightStyle.css");
316+ if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
317+ {
318+ nightStyleSheet = styleSheetFile.readAll();
319+ }
320+ styleSheetFile.close();
321+
322+}
323+
324+void PrintSky::update(double deltaTime)
325+{
326+}
327+
328+//! Draw any parts on the screen which are for our module
329+void PrintSky::draw(StelCore* core)
330+{
331+}
332+
333+//! Determine which "layer" the plagin's drawing will happen on.
334+double PrintSky::getCallOrder(StelModuleActionName actionName) const
335+{
336+ return 0;
337+}
338+
339+void PrintSky::handleKeys(QKeyEvent* event)
340+{
341+ event->setAccepted(false);
342+}
343+
344+void PrintSky::handleMouseClicks(class QMouseEvent* event)
345+{
346+ event->setAccepted(false);
347+
348+}
349+
350+bool PrintSky::handleMouseMoves(int x, int y, Qt::MouseButtons b)
351+{
352+ return false;
353+}
354+
355+//! Show dialog printing enabling preview and print buttons
356+void PrintSky::initPrintingSky()
357+{
358+ printskyDialog->setVisible(true);
359+ printskyDialog->enableOutputOptions(true);
360+}
361+
362+
363+const StelStyle PrintSky::getModuleStyleSheet(const StelStyle& style)
364+{
365+ StelStyle pluginStyle(style);
366+ if (style.confSectionName == "color")
367+ {
368+ pluginStyle.qtStyleSheet.append(normalStyleSheet);
369+ }
370+ else
371+ {
372+ pluginStyle.qtStyleSheet.append(nightStyleSheet);
373+ }
374+ return pluginStyle;
375+}
376+
377+void PrintSky::setStelStyle(const QString& section)
378+{
379+ printskyDialog->updateStyle();
380+}
381+
382+bool PrintSky::configureGui(bool show)
383+{
384+ if (show)
385+ {
386+ printskyDialog->setVisible(true);
387+ printskyDialog->enableOutputOptions(false);
388+ }
389+
390+ return true;
391+}
392
393=== added file 'plugins/PrintSky/src/PrintSky.hpp'
394--- plugins/PrintSky/src/PrintSky.hpp 1970-01-01 00:00:00 +0000
395+++ plugins/PrintSky/src/PrintSky.hpp 2011-01-07 22:29:26 +0000
396@@ -0,0 +1,70 @@
397+#ifndef PrintSky_H
398+#define PrintSky_H
399+
400+#include "StelModule.hpp"
401+#include <QPrinter>
402+#include <QPrintPreviewWidget>
403+#include <QPrintPreviewDialog>
404+#include "StelStyle.hpp"
405+#include "PrintSkyDialog.hpp"
406+
407+//class PrintSky
408+class PrintSky : public StelModule
409+{
410+ Q_OBJECT
411+public:
412+ PrintSky();
413+ virtual ~PrintSky();
414+
415+
416+ ///////////////////////////////////////////////////////////////////////////
417+ // Methods defined in the StelModule class
418+ virtual void init();
419+ virtual bool configureGui(bool show=true);
420+ virtual void update(double deltaTime);
421+ virtual void draw(StelCore* core);
422+ virtual double getCallOrder(StelModuleActionName actionName) const;
423+ virtual void handleKeys(class QKeyEvent* event);
424+ virtual void handleMouseClicks(class QMouseEvent* event);
425+ virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b);
426+ virtual void setStelStyle(const QString& style);
427+
428+ //! Returns the module-specific style sheet.
429+ //! The main StelStyle instance should be passed.
430+ const StelStyle getModuleStyleSheet(const StelStyle& style);
431+
432+public slots:
433+
434+ //! Show dialog printing enabling preview and print buttons
435+ void initPrintingSky();
436+
437+private slots:
438+
439+private:
440+
441+ //Styles
442+ QByteArray normalStyleSheet;
443+ QByteArray nightStyleSheet;
444+
445+ //Printing options
446+ bool useInvertColors, scaleToFit, printData, printSSEphemerides;
447+ QString orientation;
448+
449+ PrintSkyDialog *printskyDialog;
450+};
451+
452+#include "fixx11h.h"
453+#include <QObject>
454+#include "StelPluginInterface.hpp"
455+
456+//! This class is used by Qt to manage a plug-in interface
457+class PrintSkyStelPluginInterface : public QObject, public StelPluginInterface
458+{
459+ Q_OBJECT
460+ Q_INTERFACES(StelPluginInterface)
461+public:
462+ virtual StelModule* getStelModule() const;
463+ virtual StelPluginInfo getPluginInfo() const;
464+ };
465+
466+#endif // PrintSky_H
467
468=== added directory 'plugins/PrintSky/src/gui'
469=== added file 'plugins/PrintSky/src/gui/PrintSkyDialog.cpp'
470--- plugins/PrintSky/src/gui/PrintSkyDialog.cpp 1970-01-01 00:00:00 +0000
471+++ plugins/PrintSky/src/gui/PrintSkyDialog.cpp 2011-01-07 22:29:26 +0000
472@@ -0,0 +1,625 @@
473+/*
474+ * Copyright (C) 2010 Pep Pujols
475+ *
476+ * This program is free software; you can redistribute it and/or
477+ * modify it under the terms of the GNU General Public License
478+ * as published by the Free Software Foundation; either version 2
479+ * of the License, or (at your option) any later version.
480+ *
481+ * This program is distributed in the hope that it will be useful,
482+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
483+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
484+ * GNU General Public License for more details.
485+ *
486+ * You should have received a copy of the GNU General Public License
487+ * along with this program; if not, write to the Free Software
488+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
489+ */
490+
491+#include "PrintSkyDialog.hpp"
492+#include "ui_printskyDialog.h"
493+#include "PrintSky.hpp"
494+#include <QAction>
495+#include <QGLWidget>
496+#include <QPrintDialog>
497+#include <QTimer>
498+#include <QGraphicsWidget>
499+
500+#include "StelApp.hpp"
501+#include "StelGui.hpp"
502+#include "StelFileMgr.hpp"
503+#include "StelModuleMgr.hpp"
504+#include "StelMainGraphicsView.hpp"
505+#include "StelTranslator.hpp"
506+#include "StelNavigator.hpp"
507+#include "StelCore.hpp"
508+#include "StelLocaleMgr.hpp"
509+#include "StelMovementMgr.hpp"
510+#include "StelSkyDrawer.hpp"
511+#include "StarMgr.hpp"
512+#include "SolarSystem.hpp"
513+#include "Planet.hpp"
514+
515+#include <QDataWidgetMapper>
516+#include <QDebug>
517+#include <QFrame>
518+#include <QSettings>
519+
520+
521+PrintSkyDialog::PrintSkyDialog()
522+{
523+ ui = new Ui_printskyDialogForm;
524+}
525+
526+PrintSkyDialog::~PrintSkyDialog()
527+{
528+ //These exist only if the window has been shown once:
529+ if (dialog)
530+ {
531+ }
532+
533+ delete ui;
534+ ui = NULL;
535+
536+}
537+
538+/* ********************************************************************* */
539+#if 0
540+#pragma mark -
541+#pragma mark StelModule Methods
542+#endif
543+/* ********************************************************************* */
544+void PrintSkyDialog::languageChanged()
545+{
546+ if (dialog) {
547+ ui->retranslateUi(dialog);
548+ }
549+}
550+
551+void PrintSkyDialog::updateStyle()
552+{
553+ if(dialog) {
554+ gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
555+ Q_ASSERT(gui);
556+ const StelStyle pluginStyle = GETSTELMODULE(PrintSky)->getModuleStyleSheet(gui->getStelStyle());
557+ dialog->setStyleSheet(pluginStyle.qtStyleSheet);
558+ //ui->textBrowser->document()->setDefaultStyleSheet(QString(pluginStyle.htmlStyleSheet));
559+ }
560+}
561+
562+void PrintSkyDialog::styleChanged()
563+{
564+ // Nothing for now
565+}
566+
567+/* ********************************************************************* */
568+#if 0
569+#pragma mark -
570+#pragma mark Slot Methods
571+#endif
572+/* ********************************************************************* */
573+void PrintSkyDialog::closeWindow()
574+{
575+ setVisible(false);
576+ StelMainGraphicsView::getInstance().scene()->setActiveWindow(0);
577+}
578+
579+
580+/* ********************************************************************* */
581+#if 0
582+#pragma mark -
583+#pragma mark Private Slot Methods
584+#endif
585+/* ********************************************************************* */
586+void PrintSkyDialog::invertColorsStateChanged(int state)
587+{
588+ bool shouldInvert = (state == Qt::Checked);
589+
590+ try
591+ {
592+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
593+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
594+ QSettings settings(printskyIniPath, QSettings::IniFormat);
595+ bool useInvertColors = settings.value("use_invert_colors", 0.0).toBool();
596+ if (state != useInvertColors)
597+ {
598+ settings.setValue("use_invert_colors", shouldInvert);
599+ emit(invertColorsChanged(shouldInvert));
600+ }
601+ }
602+ catch (std::runtime_error& e)
603+ {
604+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
605+ }
606+
607+}
608+
609+/* ********************************************************************* */
610+#if 0
611+#pragma mark -
612+#pragma mark Private Slot Methods
613+#endif
614+/* ********************************************************************* */
615+void PrintSkyDialog::scaleToFitStateChanged(int state)
616+{
617+ bool shouldScale = (state == Qt::Checked);
618+
619+ try
620+ {
621+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
622+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
623+ QSettings settings(printskyIniPath, QSettings::IniFormat);
624+ bool useScaleToFit = settings.value("use_scale_to_fit", 0.0).toBool();
625+ if (state != useScaleToFit)
626+ {
627+ settings.setValue("use_scale_to_fit", shouldScale);
628+ emit(scaleToFitChanged(shouldScale));
629+ }
630+ }
631+ catch (std::runtime_error& e)
632+ {
633+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
634+ }
635+
636+}
637+
638+/* ********************************************************************* */
639+#if 0
640+#pragma mark -
641+#pragma mark Private Slot Methods
642+#endif
643+/* ********************************************************************* */
644+void PrintSkyDialog::orientationStateChanged(bool state)
645+{
646+ QString newOrientation=(ui->orientationPortraitRadioButton->isChecked()? "Portrait": "Landscape");
647+
648+ try
649+ {
650+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
651+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
652+ QSettings settings(printskyIniPath, QSettings::IniFormat);
653+ QString currentOrientation = settings.value("orientation", "Portrait").toString();
654+ if (newOrientation != currentOrientation)
655+ {
656+ settings.setValue("orientation", newOrientation);
657+ emit(orientationChanged(true));
658+ }
659+ }
660+ catch (std::runtime_error& e)
661+ {
662+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
663+ }
664+
665+}
666+
667+/* ********************************************************************* */
668+#if 0
669+#pragma mark -
670+#pragma mark Private Slot Methods
671+#endif
672+/* ********************************************************************* */
673+void PrintSkyDialog::printDataStateChanged(int state)
674+{
675+ bool shouldPrint = (state == Qt::Checked);
676+
677+ try
678+ {
679+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
680+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
681+ QSettings settings(printskyIniPath, QSettings::IniFormat);
682+ bool printData = settings.value("print_data", 0.0).toBool();
683+ if (state != printData)
684+ {
685+ settings.setValue("print_data", shouldPrint);
686+ emit(printDataChanged(shouldPrint));
687+ }
688+ }
689+ catch (std::runtime_error& e)
690+ {
691+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
692+ }
693+
694+}
695+
696+/* ********************************************************************* */
697+#if 0
698+#pragma mark -
699+#pragma mark Private Slot Methods
700+#endif
701+/* ********************************************************************* */
702+void PrintSkyDialog::printSSEphemeridesStateChanged(int state)
703+{
704+ bool shouldPrint = (state == Qt::Checked);
705+
706+ try
707+ {
708+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
709+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
710+ QSettings settings(printskyIniPath, QSettings::IniFormat);
711+ bool printSSEphemerides = settings.value("print_SS_ephemerides", 0.0).toBool();
712+ if (state != printSSEphemerides)
713+ {
714+ settings.setValue("print_SS_ephemerides", shouldPrint);
715+ emit(printSSEphemeridesChanged(shouldPrint));
716+ }
717+ }
718+ catch (std::runtime_error& e)
719+ {
720+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
721+ }
722+
723+}
724+
725+
726+/* ********************************************************************* */
727+#if 0
728+#pragma mark -
729+#pragma mark Protected Methods
730+#endif
731+/* ********************************************************************* */
732+void PrintSkyDialog::createDialogContent()
733+{
734+
735+ ui->setupUi(dialog);
736+
737+ //Now the rest of the actions.
738+ connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
739+ connect(ui->invertColorsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(invertColorsStateChanged(int)));
740+ connect(ui->scaleToFitCheckBox, SIGNAL(stateChanged(int)), this, SLOT(scaleToFitStateChanged(int)));
741+ connect(ui->previewSkyPushButton, SIGNAL(clicked()), this, SLOT(previewSky()));
742+ connect(ui->printSkyPushButton, SIGNAL(clicked()), this, SLOT(printSky()));
743+ connect(ui->orientationPortraitRadioButton, SIGNAL(toggled(bool)), this, SLOT(orientationStateChanged(bool)));
744+ connect(ui->printDataCheckBox, SIGNAL(stateChanged(int)), this, SLOT(printDataStateChanged(int)));
745+ connect(ui->printSSEphemeridesCheckBox, SIGNAL(stateChanged(int)), this, SLOT(printSSEphemeridesStateChanged(int)));
746+
747+ // set the initial state
748+ try
749+ {
750+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
751+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
752+ QSettings settings(printskyIniPath, QSettings::IniFormat);
753+ bool useInvertColors = settings.value("use_invert_colors", false).toBool();
754+ if (useInvertColors)
755+ {
756+ ui->invertColorsCheckBox->setCheckState(Qt::Checked);
757+ }
758+ bool useScaleToFit = settings.value("use_scale_to_fit", true).toBool();
759+ if (useScaleToFit)
760+ {
761+ ui->scaleToFitCheckBox->setCheckState(Qt::Checked);
762+ }
763+ QString orientation=settings.value("orientation", "Portrait").toString();
764+ if (orientation=="Portrait")
765+ ui->orientationPortraitRadioButton->setChecked(true);
766+ if (orientation=="Landscape")
767+ ui->orientationLandscapeRadioButton->setChecked(true);
768+ bool printData = settings.value("print_data", true).toBool();
769+ if (printData)
770+ {
771+ ui->printDataCheckBox->setCheckState(Qt::Checked);
772+ }
773+ bool printSSEphemerides = settings.value("print_SS_ephemerides", true).toBool();
774+ if (printSSEphemerides)
775+ {
776+ ui->printSSEphemeridesCheckBox->setCheckState(Qt::Checked);
777+ }
778+
779+ }
780+ catch (std::runtime_error& e)
781+ {
782+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
783+ }
784+
785+
786+ //Initialize the style
787+ updateStyle();
788+}
789+
790+//! Print report on a preview window
791+void PrintSkyDialog::previewSky()
792+{
793+ currentVisibilityGui = gui->getVisible();
794+ gui->setVisible(false);
795+ dialog->setVisible(false);
796+
797+ outputOption = true;
798+
799+ QTimer::singleShot(50, this, SLOT(executePrinterOutputOption()));
800+}
801+
802+//! Draw contents report
803+void PrintSkyDialog::printDataSky(QPrinter * printer)
804+{
805+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
806+
807+ QPainter painter(printer);
808+
809+ QGLWidget* glQGLWidget=(QGLWidget *) StelMainGraphicsView::getInstance().getStelQGLWidget();
810+ Q_ASSERT(glQGLWidget);
811+
812+
813+ QImage img=glQGLWidget->grabFrameBuffer();
814+
815+ int imageYPos=(printDataOption? 400: 0);
816+
817+ QSize sizeReal=printer->pageRect().size();
818+ sizeReal.setHeight(sizeReal.height()-imageYPos);
819+
820+ if (scaleToFitOption)
821+ img=img.scaled(sizeReal, Qt::KeepAspectRatio, Qt::SmoothTransformation);
822+
823+ if (invertColorsOption)
824+ img.invertPixels();
825+
826+ int imageXPos=(printer->pageRect().width()-img.width())/2;
827+
828+ painter.drawImage(imageXPos, 0, img);
829+
830+ StelCore* core = StelApp::getInstance().getCore();
831+ StelLocation locationData=core->getNavigator()->getCurrentLocation();
832+ double jd = core->getNavigator()->getJDay();
833+
834+ QFont font("DejaVu Sans", 10, QFont::Normal);
835+ font.setPixelSize(printer->pageRect().width()/60);
836+ painter.setFont(font);
837+ int lineSpacing=font.pixelSize()+5;
838+
839+ //qDebug() << "PrintSky: printer debugging information:";
840+ //qDebug() << "Current printer resolution:" << printer->resolution();
841+ //qDebug() << "Supported printer resolutions:" << printer->supportedResolutions();
842+ //qDebug() << "Page size (size index, 0-30)" << printer->paperSize();
843+ //For the paper size index, see http://doc.qt.nokia.com/qprinter.html#PaperSize-enum
844+ //qDebug() << "Pixel Size:" << font.pixelSize();
845+ //qDebug() << "Paper Rect: "<< printer->paperRect();
846+ //qDebug() << "Page Rect: "<< printer->pageRect();
847+
848+ if (printDataOption)
849+ {
850+ int posY=img.height()+lineSpacing;
851+
852+ QRect surfaceData(printer->pageRect().left(), posY, printer->pageRect().width(), printer->pageRect().height()-posY);
853+
854+ painter.drawText(surfaceData.adjusted(0, 0, 0, -(surfaceData.height()-lineSpacing)), Qt::AlignCenter, "CHART INFORMATION");
855+
856+ QString printLatitude=StelUtils::radToDmsStr((std::fabs(locationData.latitude)/180.)*M_PI);
857+ QString printLongitude=StelUtils::radToDmsStr((std::fabs(locationData.longitude)/180.)*M_PI);
858+
859+ QString location = QString("Location: %1\t%2\t%3\t%4\t%5\t%6m")
860+ .arg(locationData.name)
861+ .arg(locationData.country)
862+ .arg(locationData.planetName)
863+ .arg(locationData.latitude<0 ? QString("%1S").arg(printLatitude) : QString("%1N").arg(printLatitude))
864+ .arg(locationData.longitude<0 ? QString("%1W").arg(printLongitude) : QString("%1E").arg(printLongitude))
865+ .arg(locationData.altitude);
866+ painter.drawText(surfaceData.adjusted(50, lineSpacing, 0, 0), Qt::AlignLeft, location);
867+
868+ QString time="Local time: ";
869+ QString newDate = StelApp::getInstance().getLocaleMgr().getPrintableDateLocal(jd) +" "
870+ +StelApp::getInstance().getLocaleMgr().getPrintableTimeLocal(jd)+QString(" (GMT%1%2)").arg(StelApp::getInstance().getLocaleMgr().getGMTShift(jd)>=0? '+':'-').arg(StelApp::getInstance().getLocaleMgr().getGMTShift(jd));
871+ time+=newDate;
872+ painter.drawText(surfaceData.adjusted(50, (lineSpacing)*2, 0, 0), Qt::AlignLeft, time);
873+
874+ QString str;
875+ QTextStream wos(&str);
876+ wos << "FOV: " << qSetRealNumberPrecision(3) << core->getMovementMgr()->getCurrentFov() << QChar(0x00B0);
877+ painter.drawText(surfaceData.adjusted(50, (lineSpacing)*3, 0, 0), Qt::AlignLeft, *wos.string());
878+
879+ painter.drawText(surfaceData.adjusted(surfaceData.width()-(15*font.pixelSize()), 0, 0, 0), Qt::AlignLeft, "Radius-magnitude relation");
880+
881+ StarMgr* smgr = GETSTELMODULE(StarMgr);
882+ QList< QPair<float,float> > listPairsMagnitudesRadius=smgr->getListMagnitudeRadius(core);
883+
884+ int xPos=-(12*font.pixelSize()), yPos=lineSpacing+10;
885+ for (int icount=1; icount<=listPairsMagnitudesRadius.count(); ++icount)
886+ {
887+ painter.drawText(surfaceData.adjusted(surfaceData.width()+xPos, yPos, 0, 0), Qt::AlignLeft, QString("%1").arg(listPairsMagnitudesRadius.at(icount-1).first));
888+ painter.setBrush(Qt::SolidPattern);
889+ painter.drawEllipse(QPoint(surfaceData.left() + surfaceData.width() + xPos - 40, surfaceData.top() + yPos + (font.pixelSize()/2)),
890+ (int) std::ceil(listPairsMagnitudesRadius.at(icount - 1).second),
891+ (int) std::ceil(listPairsMagnitudesRadius.at(icount - 1).second));
892+ yPos+=lineSpacing;
893+ if (yPos+lineSpacing>=surfaceData.height())
894+ {
895+ xPos+=200;
896+ yPos=lineSpacing+10;
897+ }
898+ }
899+ }
900+
901+ // Print solar system ephemerides
902+ if (printSSEphemeridesOption)
903+ {
904+
905+ SolarSystem* ssmgr = GETSTELMODULE(SolarSystem);
906+
907+ double geographicLongitude=-locationData.longitude*M_PI/180.;
908+ double geographicLatitude=locationData.latitude*M_PI/180.;
909+
910+ PlanetP pHome=ssmgr->searchByEnglishName(locationData.planetName);
911+ double standardSideralTime=pHome->getSiderealTime(((int) jd)+0.5)*M_PI/180.;
912+
913+ QStringList allBodiesNames=ssmgr->getAllPlanetEnglishNames();
914+ allBodiesNames.sort();
915+ bool doHeader=true;
916+ int yPos;
917+ bool oddLine=false;
918+ for (int iBodyName=1; iBodyName<=allBodiesNames.count(); ++iBodyName)
919+ {
920+ QString englishName=allBodiesNames.at(iBodyName-1);
921+ PlanetP p=ssmgr->searchByEnglishName(englishName);
922+ double dec, ra;
923+ StelUtils::rectToSphe(&ra,&dec, p->getEquinoxEquatorialPos(core->getNavigator()));
924+ double standardAltitude=-0.5667;
925+ if (englishName=="Sun")
926+ standardAltitude=-0.8333;
927+ if (englishName=="Moon")
928+ standardAltitude=0.125;
929+ standardAltitude*=M_PI/180.;
930+
931+ double cosH=(std::sin(standardAltitude)-(std::sin(geographicLatitude)*std::sin(dec)))/(std::cos(geographicLatitude)*std::cos(dec));
932+
933+ if (englishName!=locationData.planetName && cosH>=-1. && cosH<=1.)
934+ {
935+
936+ if (doHeader)
937+ {
938+
939+ yPos=50;
940+ printer->newPage();
941+ painter.drawText(0, 0, printer->paperRect().width(), yPos, Qt::AlignCenter, "SOLAR SYSTEM EPHEMERIDES");
942+
943+ int ratioWidth=300.*(double) font.pixelSize()/45.;
944+ int xPos=printer->pageRect().left()-ratioWidth;;
945+ yPos+=(lineSpacing)*2;
946+
947+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Name");
948+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "RA");
949+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Dec");
950+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Rising");
951+ painter.drawText(QRect(xPos, yPos-font.pixelSize()-10, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Local Time");
952+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Transit");
953+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Setting");
954+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Dist.(AU)");
955+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, "Ap.Mag.");
956+ yPos+=lineSpacing;
957+ doHeader=false;
958+ }
959+
960+
961+ double angleH=std::acos(cosH);
962+ double transit=((ra+geographicLongitude-standardSideralTime)/(2*M_PI));
963+ if (transit>1.)
964+ transit-=1.;
965+ if (transit<0)
966+ transit+=1.;
967+
968+ double rising=transit-angleH/(2*M_PI);
969+ if (rising>1.)
970+ rising-=1.;
971+ if (rising<0.)
972+ rising+=1.;
973+
974+ double setting=transit+angleH/(2*M_PI);
975+ if (setting>1.)
976+ setting-=1.;
977+ if (setting<0.)
978+ setting+=1.;
979+
980+ int shift=StelApp::getInstance().getLocaleMgr().getGMTShift(jd);
981+
982+ int ratioWidth=300.*(double) font.pixelSize()/45.;
983+ int xPos=printer->pageRect().left()-ratioWidth;
984+
985+ oddLine=!oddLine;
986+
987+
988+ painter.setPen(Qt::NoPen);
989+ painter.setBrush((oddLine? Qt::white: Qt::gray));
990+ painter.drawRect(QRect(xPos+ratioWidth, yPos, ratioWidth*8, font.pixelSize()));
991+ painter.setPen(Qt::SolidLine);
992+
993+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignLeft, englishName);
994+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignRight, QString("%1").arg(StelUtils::radToHmsStr(ra)));
995+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignRight, QString("%1").arg(StelUtils::radToDmsStr(dec)));
996+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, QString("%1").arg(printableTime(rising, shift)));
997+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, QString("%1").arg(printableTime(transit, shift)));
998+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignCenter, QString("%1").arg(printableTime(setting, shift)));
999+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignRight, QString("%1").arg(p->getDistance(), 0, 'g', 5));
1000+ painter.drawText(QRect(xPos+=ratioWidth, yPos, ratioWidth, font.pixelSize()), Qt::AlignRight, QString("%1").arg(p->getVMagnitude(core->getNavigator()), 0, 'g', 3));
1001+
1002+ yPos+=lineSpacing;
1003+ if (yPos+((lineSpacing)*3)>=printer->pageRect().top()+printer->pageRect().height())
1004+ doHeader=true;
1005+ }
1006+ }
1007+ }
1008+ QApplication::restoreOverrideCursor();
1009+}
1010+
1011+//! Print report direct to printer
1012+void PrintSkyDialog::printSky()
1013+{
1014+ currentVisibilityGui=gui->getVisible();
1015+ gui->setVisible(false);
1016+ dialog->setVisible(false);
1017+
1018+ outputOption=false;
1019+
1020+ QTimer::singleShot(50, this, SLOT(executePrinterOutputOption()));
1021+
1022+}
1023+
1024+//! Read the printer parameters and run the output option selected (Print/Preview)
1025+void PrintSkyDialog::executePrinterOutputOption()
1026+{
1027+ //Options for printing image.
1028+ invertColorsOption=false;
1029+ scaleToFitOption=true;
1030+ orientationOption="Portrait";
1031+ printDataOption=true;
1032+ printSSEphemeridesOption=true;
1033+
1034+ try
1035+ {
1036+ StelFileMgr::Flags flags = (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable);
1037+ QString printskyIniPath = StelFileMgr::findFile("modules/PrintSky/", flags) + "printsky.ini";
1038+ QSettings settings(printskyIniPath, QSettings::IniFormat);
1039+ invertColorsOption=settings.value("use_invert_colors", false).toBool();
1040+ scaleToFitOption=settings.value("use_scale_to_fit", true).toBool();
1041+ orientationOption=settings.value("orientation", "Portrait").toString();
1042+ printDataOption=settings.value("print_data", true).toBool();
1043+ printSSEphemeridesOption=settings.value("print_SS_ephemerides", true).toBool();
1044+ }
1045+ catch (std::runtime_error& e)
1046+ {
1047+ qWarning() << "WARNING: unable to locate printsky.ini file or create a default one for PrintSky plugin: " << e.what();
1048+ }
1049+
1050+
1051+ //QPrinter printer(QPrinter::HighResolution);
1052+ QPrinter printer(QPrinter::ScreenResolution);
1053+ printer.setResolution(300);
1054+ printer.setDocName("STELLARIUM REPORT");
1055+ printer.setOrientation((orientationOption=="Portrait"? QPrinter::Portrait: QPrinter::Landscape));
1056+
1057+ if (outputOption)
1058+ {
1059+ //QPrintPreviewDialog oPrintPreviewDialog(&printer, &StelMainGraphicsView::getInstance());
1060+ QPrintPreviewDialog oPrintPreviewDialog(&printer);
1061+ connect(&oPrintPreviewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(printDataSky(QPrinter *)));
1062+ oPrintPreviewDialog.exec();
1063+ }
1064+ else
1065+ {
1066+ //QPrintDialog dialogPrinter(&printer, &StelMainGraphicsView::getInstance());
1067+ QPrintDialog dialogPrinter(&printer);
1068+ if (dialogPrinter.exec() == QDialog::Accepted)
1069+ printDataSky(&printer);
1070+ }
1071+
1072+ gui->setVisible(currentVisibilityGui);
1073+ ((QGraphicsWidget*)StelMainGraphicsView::getInstance().getStelAppGraphicsWidget())->setFocus(Qt::OtherFocusReason);
1074+}
1075+
1076+
1077+
1078+void PrintSkyDialog::enableOutputOptions(bool enable)
1079+{
1080+ ui->buttonsFrame->setVisible(enable);
1081+}
1082+
1083+
1084+QString PrintSkyDialog::printableTime(double time, int shift)
1085+{
1086+ time*=24.;
1087+ time+=shift;
1088+ if (time>=24.)
1089+ time-=24.;
1090+ if (time<0)
1091+ time+=24.;
1092+ int hour=(int) time;
1093+ time-=hour;
1094+ time*=60;
1095+ int minute=(int) time;
1096+ return(QString("%1:%2").arg(hour, 2, 10, QChar('0')).arg(minute, 2, 10, QChar('0')));
1097+}
1098
1099=== added file 'plugins/PrintSky/src/gui/PrintSkyDialog.hpp'
1100--- plugins/PrintSky/src/gui/PrintSkyDialog.hpp 1970-01-01 00:00:00 +0000
1101+++ plugins/PrintSky/src/gui/PrintSkyDialog.hpp 2011-01-07 22:29:26 +0000
1102@@ -0,0 +1,96 @@
1103+/*
1104+ * Copyright (C) 2010 Pep Pujols
1105+ *
1106+ * This program is free software; you can redistribute it and/or
1107+ * modify it under the terms of the GNU General Public License
1108+ * as published by the Free Software Foundation; either version 2
1109+ * of the License, or (at your option) any later version.
1110+ *
1111+ * This program is distributed in the hope that it will be useful,
1112+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1113+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1114+ * GNU General Public License for more details.
1115+ *
1116+ * You should have received a copy of the GNU General Public License
1117+ * along with this program; if not, write to the Free Software
1118+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1119+ */
1120+
1121+#ifndef _PRINTSKYDIALOG_HPP_
1122+#define _PRINTSKYDIALOG_HPP_
1123+
1124+#include <QObject>
1125+#include "StelDialogPrintSky.hpp"
1126+#include "StelStyle.hpp"
1127+#include <QPrinter>
1128+#include <QPrintPreviewWidget>
1129+#include <QPrintPreviewDialog>
1130+#include "StelGui.hpp"
1131+
1132+class Ui_printskyDialogForm;
1133+
1134+
1135+class PrintSkyDialog : public StelDialogPrintSky
1136+{
1137+ Q_OBJECT
1138+
1139+public:
1140+ PrintSkyDialog();
1141+ virtual ~PrintSkyDialog();
1142+ void languageChanged();
1143+ void updateStyle();
1144+
1145+ //! Notify that the application style changed
1146+ void styleChanged();
1147+ void enableOutputOptions(bool enable);
1148+
1149+public slots:
1150+ void closeWindow();
1151+
1152+ //! Print report on a preview window
1153+ void previewSky();
1154+ //! Read the printer parameters and run the output option selected (Print/Preview)
1155+ void executePrinterOutputOption();
1156+ //! Print report direct to printer
1157+ void printSky();
1158+
1159+signals:
1160+ void invertColorsChanged(bool state);
1161+ void scaleToFitChanged(bool state);
1162+ void orientationChanged(bool state);
1163+ void printDataChanged(bool state);
1164+ void printSSEphemeridesChanged(bool state);
1165+
1166+protected:
1167+ //! Initialize the dialog widgets and connect the signals/slots
1168+ virtual void createDialogContent();
1169+ Ui_printskyDialogForm* ui;
1170+
1171+private slots:
1172+ void invertColorsStateChanged(int state);
1173+ //! Draw contents report
1174+ //! @param printer the paint device to paint on a print
1175+ void printDataSky(QPrinter * printer);
1176+ void scaleToFitStateChanged(int state);
1177+ void orientationStateChanged(bool state);
1178+ void printDataStateChanged(int state);
1179+ void printSSEphemeridesStateChanged(int state);
1180+
1181+private:
1182+
1183+ //Gui
1184+ StelGui* gui;
1185+ bool currentVisibilityGui;
1186+
1187+ //! Printing options
1188+ bool outputOption;
1189+ bool invertColorsOption;
1190+ bool scaleToFitOption;
1191+ QString orientationOption;
1192+ bool printDataOption;
1193+ bool printSSEphemeridesOption;
1194+ QString printableTime(double time, int shift);
1195+
1196+};
1197+
1198+#endif // _OCULARDIALOG_HPP_
1199
1200=== added file 'plugins/PrintSky/src/gui/StelDialogPrintSky.cpp'
1201--- plugins/PrintSky/src/gui/StelDialogPrintSky.cpp 1970-01-01 00:00:00 +0000
1202+++ plugins/PrintSky/src/gui/StelDialogPrintSky.cpp 2011-01-07 22:29:26 +0000
1203@@ -0,0 +1,134 @@
1204+/*
1205+ * Stellarium
1206+ * Copyright (C) 2008 Fabien Chereau
1207+ *
1208+ * This program is free software; you can redistribute it and/or
1209+ * modify it under the terms of the GNU General Public License
1210+ * as published by the Free Software Foundation; either version 2
1211+ * of the License, or (at your option) any later version.
1212+ *
1213+ * This program is distributed in the hope that it will be useful,
1214+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1215+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1216+ * GNU General Public License for more details.
1217+ *
1218+ * You should have received a copy of the GNU General Public License
1219+ * along with this program; if not, write to the Free Software
1220+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1221+*/
1222+
1223+
1224+#include "StelDialogPrintSky.hpp"
1225+#include "StelMainGraphicsView.hpp"
1226+#include "StelMainWindow.hpp"
1227+
1228+#include <QDebug>
1229+#include <QDialog>
1230+#include <QGraphicsProxyWidget>
1231+#include <QStyleOptionGraphicsItem>
1232+
1233+class CustomProxy : public QGraphicsProxyWidget
1234+{
1235+ public:
1236+ CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0) : QGraphicsProxyWidget(parent, wFlags)
1237+ {
1238+ setFocusPolicy(Qt::StrongFocus);
1239+ }
1240+ //! Reimplement this method to add windows decorations. Currently there are invisible 2 px decorations
1241+ void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
1242+ {
1243+/* QStyleOptionTitleBar bar;
1244+ initStyleOption(&bar);
1245+ bar.subControls = QStyle::SC_TitleBarCloseButton;
1246+ qWarning() << style()->subControlRect(QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton);
1247+ QGraphicsProxyWidget::paintWindowFrame(painter, option, widget);*/
1248+ }
1249+ protected:
1250+
1251+ virtual bool event(QEvent* event)
1252+ {
1253+ if (event->type()==QEvent::WindowDeactivate)
1254+ {
1255+ widget()->setWindowOpacity(0.4);
1256+ }
1257+ if (event->type()==QEvent::WindowActivate)
1258+ {
1259+ widget()->setWindowOpacity(0.9);
1260+ }
1261+ return QGraphicsProxyWidget::event(event);
1262+ }
1263+};
1264+
1265+StelDialogPrintSky::StelDialogPrintSky() : dialog(NULL)
1266+{
1267+}
1268+
1269+StelDialogPrintSky::~StelDialogPrintSky()
1270+{
1271+}
1272+
1273+
1274+void StelDialogPrintSky::close()
1275+{
1276+ setVisible(false);
1277+ StelMainGraphicsView::getInstance().scene()->setActiveWindow(0);
1278+ ((QGraphicsWidget*)StelMainGraphicsView::getInstance().getStelAppGraphicsWidget())->setFocus(Qt::OtherFocusReason);
1279+}
1280+
1281+void StelDialogPrintSky::setVisible(bool v)
1282+{
1283+ if (v)
1284+ {
1285+
1286+ QSize screenSize = StelMainWindow::getInstance().size();
1287+ if (dialog)
1288+ {
1289+ dialog->show();
1290+ StelMainGraphicsView::getInstance().scene()->setActiveWindow(proxy);
1291+ // If the main window has been resized, it is possible the dialog
1292+ // will be off screen. Check for this and move it to a visible
1293+ // position if necessary
1294+ QPointF newPos = proxy->pos();
1295+ if (newPos.x()>=screenSize.width())
1296+ newPos.setX(screenSize.width() - dialog->size().width());
1297+ if (newPos.y()>=screenSize.height())
1298+ newPos.setY(screenSize.height() - dialog->size().height());
1299+ if (newPos != dialog->pos())
1300+ proxy->setPos(newPos);
1301+
1302+ proxy->setFocus();
1303+ return;
1304+ }
1305+ dialog = new QDialog(NULL);
1306+ connect(dialog, SIGNAL(rejected()), this, SLOT(close()));
1307+ createDialogContent();
1308+
1309+ proxy = new CustomProxy(NULL, Qt::Tool);
1310+ proxy->setWidget(dialog);
1311+ QRectF bound = proxy->boundingRect();
1312+
1313+ // centre with dialog according to current window size.
1314+ proxy->setPos((int)((screenSize.width()-bound.width())/2), (int)((screenSize.height()-bound.height())/2));
1315+ StelMainGraphicsView::getInstance().scene()->addItem(proxy);
1316+ proxy->setWindowFrameMargins(2,0,2,2);
1317+
1318+ // The caching is buggy on all plateforms with Qt 4.5.2
1319+
1320+#if QT_VERSION==0x040502
1321+ proxy->setCacheMode(QGraphicsItem::NoCache);
1322+#else
1323+ proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
1324+#endif
1325+
1326+ proxy->setZValue(100);
1327+ StelMainGraphicsView::getInstance().scene()->setActiveWindow(proxy);
1328+ proxy->setFocus();
1329+ }
1330+ else
1331+ {
1332+ dialog->hide();
1333+ emit visibleChanged(false);
1334+ //proxy->clearFocus();
1335+ StelMainGraphicsView::getInstance().scene()->setActiveWindow(0);
1336+ }
1337+}
1338
1339=== added file 'plugins/PrintSky/src/gui/StelDialogPrintSky.hpp'
1340--- plugins/PrintSky/src/gui/StelDialogPrintSky.hpp 1970-01-01 00:00:00 +0000
1341+++ plugins/PrintSky/src/gui/StelDialogPrintSky.hpp 2011-01-07 22:29:26 +0000
1342@@ -0,0 +1,52 @@
1343+/*
1344+ * Stellarium
1345+ * Copyright (C) 2008 Fabien Chereau
1346+ *
1347+ * This program is free software; you can redistribute it and/or
1348+ * modify it under the terms of the GNU General Public License
1349+ * as published by the Free Software Foundation; either version 2
1350+ * of the License, or (at your option) any later version.
1351+ *
1352+ * This program is distributed in the hope that it will be useful,
1353+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1354+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1355+ * GNU General Public License for more details.
1356+ *
1357+ * You should have received a copy of the GNU General Public License
1358+ * along with this program; if not, write to the Free Software
1359+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1360+*/
1361+
1362+#ifndef _STELDIALOGPRINTSKY_HPP_
1363+#define _STELDIALOGPRINTSKY_HPP_
1364+
1365+#include <QObject>
1366+
1367+//! @class StelDialog
1368+//! A local copy of StelDialog, the base class for all the GUI windows in Stellarium, included to allow the plug-in to be
1369+//! loaded dynamically on Windows. (An "Invalid access to memory location" error is thrown otherwise.)
1370+class StelDialogPrintSky : public QObject
1371+{
1372+ Q_OBJECT
1373+public:
1374+ StelDialogPrintSky();
1375+ virtual ~StelDialogPrintSky();
1376+ //! Retranslate the content of the dialog
1377+ virtual void languageChanged()=0;
1378+
1379+public slots:
1380+ void setVisible(bool);
1381+ void close();
1382+signals:
1383+ void visibleChanged(bool);
1384+
1385+protected:
1386+ //! Initialize the dialog widgets and connect the signals/slots
1387+ virtual void createDialogContent()=0;
1388+
1389+ //! The main dialog
1390+ QWidget* dialog;
1391+ class CustomProxy* proxy;
1392+};
1393+
1394+#endif // _STELDIALOGPRINTSKY_HPP_
1395
1396=== added file 'plugins/PrintSky/src/gui/printskyDialog.ui'
1397--- plugins/PrintSky/src/gui/printskyDialog.ui 1970-01-01 00:00:00 +0000
1398+++ plugins/PrintSky/src/gui/printskyDialog.ui 2011-01-07 22:29:26 +0000
1399@@ -0,0 +1,350 @@
1400+<?xml version="1.0" encoding="UTF-8"?>
1401+<ui version="4.0">
1402+ <class>printskyDialogForm</class>
1403+ <widget class="QWidget" name="printskyDialogForm">
1404+ <property name="geometry">
1405+ <rect>
1406+ <x>0</x>
1407+ <y>0</y>
1408+ <width>500</width>
1409+ <height>300</height>
1410+ </rect>
1411+ </property>
1412+ <property name="sizePolicy">
1413+ <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
1414+ <horstretch>0</horstretch>
1415+ <verstretch>0</verstretch>
1416+ </sizepolicy>
1417+ </property>
1418+ <property name="minimumSize">
1419+ <size>
1420+ <width>300</width>
1421+ <height>300</height>
1422+ </size>
1423+ </property>
1424+ <layout class="QVBoxLayout" name="verticalLayout_2">
1425+ <property name="spacing">
1426+ <number>0</number>
1427+ </property>
1428+ <property name="margin">
1429+ <number>0</number>
1430+ </property>
1431+ <item>
1432+ <widget class="BarFrame" name="LocationBar">
1433+ <property name="sizePolicy">
1434+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
1435+ <horstretch>0</horstretch>
1436+ <verstretch>0</verstretch>
1437+ </sizepolicy>
1438+ </property>
1439+ <property name="maximumSize">
1440+ <size>
1441+ <width>16777215</width>
1442+ <height>25</height>
1443+ </size>
1444+ </property>
1445+ <property name="frameShape">
1446+ <enum>QFrame::StyledPanel</enum>
1447+ </property>
1448+ <property name="frameShadow">
1449+ <enum>QFrame::Raised</enum>
1450+ </property>
1451+ <layout class="QHBoxLayout" name="horizontalLayout_7">
1452+ <property name="spacing">
1453+ <number>6</number>
1454+ </property>
1455+ <property name="leftMargin">
1456+ <number>0</number>
1457+ </property>
1458+ <property name="topMargin">
1459+ <number>0</number>
1460+ </property>
1461+ <property name="rightMargin">
1462+ <number>4</number>
1463+ </property>
1464+ <property name="bottomMargin">
1465+ <number>0</number>
1466+ </property>
1467+ <item>
1468+ <spacer name="spacer_2">
1469+ <property name="orientation">
1470+ <enum>Qt::Horizontal</enum>
1471+ </property>
1472+ <property name="sizeHint" stdset="0">
1473+ <size>
1474+ <width>40</width>
1475+ <height>20</height>
1476+ </size>
1477+ </property>
1478+ </spacer>
1479+ </item>
1480+ <item>
1481+ <widget class="QLabel" name="stelWindowTitle">
1482+ <property name="text">
1483+ <string>Print sky</string>
1484+ </property>
1485+ </widget>
1486+ </item>
1487+ <item>
1488+ <spacer name="spacer">
1489+ <property name="orientation">
1490+ <enum>Qt::Horizontal</enum>
1491+ </property>
1492+ <property name="sizeHint" stdset="0">
1493+ <size>
1494+ <width>40</width>
1495+ <height>20</height>
1496+ </size>
1497+ </property>
1498+ </spacer>
1499+ </item>
1500+ <item>
1501+ <widget class="QPushButton" name="closeStelWindow">
1502+ <property name="minimumSize">
1503+ <size>
1504+ <width>16</width>
1505+ <height>16</height>
1506+ </size>
1507+ </property>
1508+ <property name="maximumSize">
1509+ <size>
1510+ <width>16</width>
1511+ <height>16</height>
1512+ </size>
1513+ </property>
1514+ <property name="focusPolicy">
1515+ <enum>Qt::NoFocus</enum>
1516+ </property>
1517+ <property name="text">
1518+ <string/>
1519+ </property>
1520+ </widget>
1521+ </item>
1522+ </layout>
1523+ </widget>
1524+ </item>
1525+ <item>
1526+ <widget class="QFrame" name="Contents">
1527+ <property name="sizePolicy">
1528+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
1529+ <horstretch>0</horstretch>
1530+ <verstretch>0</verstretch>
1531+ </sizepolicy>
1532+ </property>
1533+ <property name="frameShape">
1534+ <enum>QFrame::StyledPanel</enum>
1535+ </property>
1536+ <property name="frameShadow">
1537+ <enum>QFrame::Raised</enum>
1538+ </property>
1539+ <layout class="QVBoxLayout" name="verticalLayout_4">
1540+ <property name="spacing">
1541+ <number>0</number>
1542+ </property>
1543+ <property name="margin">
1544+ <number>0</number>
1545+ </property>
1546+ <item>
1547+ <widget class="QTabWidget" name="Tabs">
1548+ <property name="currentIndex">
1549+ <number>0</number>
1550+ </property>
1551+ <widget class="QWidget" name="General">
1552+ <attribute name="title">
1553+ <string>General</string>
1554+ </attribute>
1555+ <layout class="QVBoxLayout" name="verticalLayout_3">
1556+ <property name="spacing">
1557+ <number>0</number>
1558+ </property>
1559+ <property name="margin">
1560+ <number>0</number>
1561+ </property>
1562+ <item>
1563+ <widget class="QGroupBox" name="groupBox">
1564+ <property name="title">
1565+ <string>Options</string>
1566+ </property>
1567+ <layout class="QGridLayout" name="gridLayout_2">
1568+ <property name="margin">
1569+ <number>0</number>
1570+ </property>
1571+ <item row="0" column="0" colspan="2">
1572+ <layout class="QVBoxLayout" name="verticalLayout">
1573+ <item>
1574+ <widget class="QCheckBox" name="invertColorsCheckBox">
1575+ <property name="text">
1576+ <string>Invert colors</string>
1577+ </property>
1578+ </widget>
1579+ </item>
1580+ <item>
1581+ <widget class="QCheckBox" name="scaleToFitCheckBox">
1582+ <property name="text">
1583+ <string>Scale to fit</string>
1584+ </property>
1585+ </widget>
1586+ </item>
1587+ <item>
1588+ <widget class="QCheckBox" name="printDataCheckBox">
1589+ <property name="text">
1590+ <string>Print scene information</string>
1591+ </property>
1592+ </widget>
1593+ </item>
1594+ <item>
1595+ <widget class="QCheckBox" name="printSSEphemeridesCheckBox">
1596+ <property name="text">
1597+ <string>Print Solar System ephemerides</string>
1598+ </property>
1599+ </widget>
1600+ </item>
1601+ </layout>
1602+ </item>
1603+ <item row="0" column="2">
1604+ <widget class="QGroupBox" name="orientationGroupBox">
1605+ <property name="title">
1606+ <string>Orientation</string>
1607+ </property>
1608+ <layout class="QVBoxLayout" name="verticalLayout_5">
1609+ <property name="margin">
1610+ <number>0</number>
1611+ </property>
1612+ <item>
1613+ <widget class="QRadioButton" name="orientationPortraitRadioButton">
1614+ <property name="text">
1615+ <string>Portrait</string>
1616+ </property>
1617+ <property name="checked">
1618+ <bool>true</bool>
1619+ </property>
1620+ </widget>
1621+ </item>
1622+ <item>
1623+ <widget class="QRadioButton" name="orientationLandscapeRadioButton">
1624+ <property name="text">
1625+ <string>Landscape</string>
1626+ </property>
1627+ </widget>
1628+ </item>
1629+ </layout>
1630+ </widget>
1631+ </item>
1632+ <item row="1" column="0" colspan="3">
1633+ <widget class="QFrame" name="buttonsFrame">
1634+ <layout class="QHBoxLayout" name="horizontalLayout">
1635+ <item>
1636+ <widget class="QPushButton" name="previewSkyPushButton">
1637+ <property name="text">
1638+ <string>Preview</string>
1639+ </property>
1640+ </widget>
1641+ </item>
1642+ <item>
1643+ <widget class="QPushButton" name="printSkyPushButton">
1644+ <property name="text">
1645+ <string>Print</string>
1646+ </property>
1647+ </widget>
1648+ </item>
1649+ </layout>
1650+ </widget>
1651+ </item>
1652+ </layout>
1653+ </widget>
1654+ </item>
1655+ <item>
1656+ <spacer name="verticalSpacer">
1657+ <property name="orientation">
1658+ <enum>Qt::Vertical</enum>
1659+ </property>
1660+ <property name="sizeHint" stdset="0">
1661+ <size>
1662+ <width>20</width>
1663+ <height>40</height>
1664+ </size>
1665+ </property>
1666+ </spacer>
1667+ </item>
1668+ </layout>
1669+ </widget>
1670+ <widget class="QWidget" name="About">
1671+ <attribute name="title">
1672+ <string>About</string>
1673+ </attribute>
1674+ <layout class="QGridLayout" name="gridLayout">
1675+ <item row="1" column="0">
1676+ <widget class="QLabel" name="labelAbout">
1677+ <property name="text">
1678+ <string>This plugin allows the user to preview and print the current screen and some aditional data as the current location, the screen time adding the GMT difference, and also a relation radius magnitude as a field reference.
1679+
1680+In a optional second page you can get some Solar System ephemerides.
1681+
1682+Use Ctrl+P to open the print window.</string>
1683+ </property>
1684+ <property name="textFormat">
1685+ <enum>Qt::AutoText</enum>
1686+ </property>
1687+ <property name="alignment">
1688+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
1689+ </property>
1690+ <property name="wordWrap">
1691+ <bool>true</bool>
1692+ </property>
1693+ </widget>
1694+ </item>
1695+ <item row="2" column="0">
1696+ <spacer name="verticalSpacer_2">
1697+ <property name="orientation">
1698+ <enum>Qt::Vertical</enum>
1699+ </property>
1700+ <property name="sizeHint" stdset="0">
1701+ <size>
1702+ <width>20</width>
1703+ <height>40</height>
1704+ </size>
1705+ </property>
1706+ </spacer>
1707+ </item>
1708+ <item row="0" column="0">
1709+ <widget class="QLabel" name="label">
1710+ <property name="text">
1711+ <string>Author: &lt;a href=&quot;mailto:maslarocaxica@gmail.com&quot;&gt;Pep Pujols&lt;/a&gt; (with fixes by Bogdan Marinov)</string>
1712+ </property>
1713+ <property name="openExternalLinks">
1714+ <bool>true</bool>
1715+ </property>
1716+ </widget>
1717+ </item>
1718+ </layout>
1719+ </widget>
1720+ </widget>
1721+ </item>
1722+ </layout>
1723+ </widget>
1724+ </item>
1725+ </layout>
1726+ </widget>
1727+ <customwidgets>
1728+ <customwidget>
1729+ <class>BarFrame</class>
1730+ <extends>QFrame</extends>
1731+ <header>Dialog.hpp</header>
1732+ <container>1</container>
1733+ </customwidget>
1734+ </customwidgets>
1735+ <tabstops>
1736+ <tabstop>Tabs</tabstop>
1737+ <tabstop>invertColorsCheckBox</tabstop>
1738+ <tabstop>scaleToFitCheckBox</tabstop>
1739+ <tabstop>printDataCheckBox</tabstop>
1740+ <tabstop>printSSEphemeridesCheckBox</tabstop>
1741+ <tabstop>orientationPortraitRadioButton</tabstop>
1742+ <tabstop>orientationLandscapeRadioButton</tabstop>
1743+ <tabstop>previewSkyPushButton</tabstop>
1744+ <tabstop>printSkyPushButton</tabstop>
1745+ <tabstop>labelAbout</tabstop>
1746+ </tabstops>
1747+ <resources/>
1748+ <connections/>
1749+</ui>
1750
1751=== modified file 'src/CMakeLists.txt'
1752--- src/CMakeLists.txt 2011-01-05 14:26:19 +0000
1753+++ src/CMakeLists.txt 2011-01-07 22:29:26 +0000
1754@@ -580,6 +580,12 @@
1755 SET(STELLARIUM_STATIC_PLUGINS_LIBRARIES ${STELLARIUM_STATIC_PLUGINS_LIBRARIES} ${CMAKE_BINARY_DIR}/plugins/VirGO/src/${CMAKE_CFG_INTDIR}/libVirGO.a ${CFITSIO_LIBRARIES})
1756 ADD_DEFINITIONS(-DUSE_STATIC_PLUGIN_VIRGO)
1757 ENDIF()
1758+
1759+ IF (USE_PLUGIN_PRINTSKY)
1760+ SET(STELLARIUM_STATIC_PLUGINS_LIBRARIES ${STELLARIUM_STATIC_PLUGINS_LIBRARIES} "${CMAKE_BINARY_DIR}/plugins/PrintSky/src/${CMAKE_CFG_INTDIR}/libPrintSky.a")
1761+ ADD_DEFINITIONS(-DUSE_STATIC_PLUGIN_PRINTSKY)
1762+ ENDIF()
1763+
1764 ENDIF()
1765
1766
1767
1768=== modified file 'src/StelMainGraphicsView.cpp'
1769--- src/StelMainGraphicsView.cpp 2010-11-12 15:29:52 +0000
1770+++ src/StelMainGraphicsView.cpp 2011-01-07 22:29:26 +0000
1771@@ -101,6 +101,10 @@
1772 Q_IMPORT_PLUGIN(TimeZoneConfiguration)
1773 #endif
1774
1775+#ifdef USE_STATIC_PLUGIN_PRINTSKY
1776+Q_IMPORT_PLUGIN(PrintSky)
1777+#endif
1778+
1779 // Initialize static variables
1780 StelMainGraphicsView* StelMainGraphicsView::singleton = NULL;
1781
1782
1783=== modified file 'src/StelMainGraphicsView.hpp'
1784--- src/StelMainGraphicsView.hpp 2010-09-09 11:50:25 +0000
1785+++ src/StelMainGraphicsView.hpp 2011-01-07 22:29:26 +0000
1786@@ -65,6 +65,10 @@
1787 StelScriptMgr& getScriptMgr() {return *scriptMgr;}
1788 #endif
1789
1790+ //! Return the QGLWidget encapsulating the Stellarium main sky view.
1791+ //! Use its layout if you want to rendering OpenGL Graphics.
1792+ StelQGLWidget* getStelQGLWidget() {return glWidget;}
1793+
1794 public slots:
1795
1796 ///////////////////////////////////////////////////////////////////////////
1797
1798=== modified file 'src/core/modules/StarMgr.cpp'
1799--- src/core/modules/StarMgr.cpp 2010-10-19 15:28:27 +0000
1800+++ src/core/modules/StarMgr.cpp 2011-01-07 22:29:26 +0000
1801@@ -945,3 +945,70 @@
1802 setFlagSciNames(skyCultureDir.startsWith("western"));
1803 updateI18n();
1804 }
1805+
1806+//! Get relations between magnitude stars and draw radius
1807+QList< QPair<float, float> > StarMgr::getListMagnitudeRadius(StelCore *core)
1808+{
1809+ QList< QPair<float, float> > listPairsMagnitudesRadius;
1810+
1811+ StelNavigator* nav = core->getNavigator();
1812+ const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
1813+ StelSkyDrawer* skyDrawer = core->getSkyDrawer();
1814+ // If stars are turned off don't waste time below
1815+ // projecting all stars just to draw disembodied labels
1816+ if (!starsFader.getInterstate())
1817+ return(listPairsMagnitudesRadius);
1818+
1819+ float rcmag_table[2*256];
1820+ float mag_table[256];
1821+
1822+ for (ZoneArrayMap::const_iterator it(zoneArrays.constBegin()); it!=zoneArrays.constEnd();++it)
1823+ {
1824+ const float mag_min = 0.001f*it.value()->mag_min;
1825+ const float k = (0.001f*it.value()->mag_range)/it.value()->mag_steps;
1826+ for (int i=it.value()->mag_steps-1;i>=0;--i)
1827+ {
1828+ const float mag = mag_min+k*i;
1829+
1830+ mag_table[i]=mag;
1831+ if (skyDrawer->computeRCMag(mag,rcmag_table + 2*i)==false)
1832+ {
1833+ if (i==0) goto exit_loop;
1834+ }
1835+ if (skyDrawer->getFlagPointStar())
1836+ {
1837+ rcmag_table[2*i+1] *= starsFader.getInterstate();
1838+ }
1839+ else
1840+ {
1841+ rcmag_table[2*i] *= starsFader.getInterstate();
1842+ }
1843+
1844+ }
1845+
1846+
1847+ for (int index=0; index<=255; ++index)
1848+ {
1849+ double magnitude=mag_table[index];
1850+ double maginteger=magnitude-(int) magnitude;
1851+ if ((int) magnitude==0)
1852+ magnitude=0;
1853+ if (rcmag_table[2*index]>0. && rcmag_table[2*index]<13.&& (int) (maginteger*100000)==0)
1854+ {
1855+ QPair<float, float> pairMagnitudeRadius;
1856+ pairMagnitudeRadius.first=(int) magnitude;
1857+ pairMagnitudeRadius.second=rcmag_table[2*index];
1858+ bool found=false;
1859+ for (int icount=1; !found && icount<=listPairsMagnitudesRadius.count();++icount)
1860+ found=listPairsMagnitudesRadius.at(icount-1).first==pairMagnitudeRadius.first;
1861+ if (!found)
1862+ {
1863+ listPairsMagnitudesRadius << pairMagnitudeRadius;
1864+ }
1865+ }
1866+ }
1867+ };
1868+ exit_loop:
1869+
1870+ return(listPairsMagnitudesRadius);
1871+}
1872
1873=== modified file 'src/core/modules/StarMgr.hpp'
1874--- src/core/modules/StarMgr.hpp 2010-05-19 13:33:21 +0000
1875+++ src/core/modules/StarMgr.hpp 2011-01-07 22:29:26 +0000
1876@@ -182,6 +182,11 @@
1877 //! @return false in case of failure.
1878 bool checkAndLoadCatalog(QVariantMap m);
1879
1880+ //! Get relations between magnitude stars and draw radius
1881+ //! @param core the instance of stellarium's core
1882+ //! @return a list of pairs magnitude-radius
1883+ QList< QPair<float, float> > getListMagnitudeRadius(StelCore *core);
1884+
1885 private:
1886
1887 void setCheckFlag(const QString& catalogId, bool b);