Merge lp:~daggerstab/stellarium/oculars-gui-improvement into lp:stellarium

Proposed by Bogdan Marinov
Status: Merged
Merged at revision: 5050
Proposed branch: lp:~daggerstab/stellarium/oculars-gui-improvement
Merge into: lp:stellarium
Diff against target: 3693 lines (+2317/-478)
16 files modified
doc/plugIns.doxygen (+8/-1)
plugins/Oculars/resources/Oculars.qrc (+16/-9)
plugins/Oculars/src/CMakeLists.txt (+3/-0)
plugins/Oculars/src/Oculars.cpp (+467/-170)
plugins/Oculars/src/Oculars.hpp (+47/-14)
plugins/Oculars/src/gui/OcularDialog.cpp (+154/-12)
plugins/Oculars/src/gui/OcularDialog.hpp (+12/-2)
plugins/Oculars/src/gui/OcularsGuiPanel.cpp (+954/-0)
plugins/Oculars/src/gui/OcularsGuiPanel.hpp (+137/-0)
plugins/Oculars/src/gui/PropertyBasedTableModel.cpp (+26/-0)
plugins/Oculars/src/gui/PropertyBasedTableModel.hpp (+3/-0)
plugins/Oculars/src/gui/ocularDialog.ui (+352/-200)
src/gui/StelGui.cpp (+2/-0)
src/gui/StelGui.hpp (+4/-0)
src/gui/StelGuiItems.cpp (+123/-70)
src/gui/StelGuiItems.hpp (+9/-0)
To merge this branch: bzr merge lp:~daggerstab/stellarium/oculars-gui-improvement
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
treaves Pending
Review via email: mp+83349@code.launchpad.net

This proposal supersedes a proposal from 2011-11-13.

Description of the change

The original name of this branch was "plugins-gui-improvements", but I've changed it to better reflect the contents. It introduces two main changes.

One is a small change to StelGui allowing plug-ins to draw on the same QGraphics widget as the rest of Stellarium's GUI elements.

All of the other changes are to the Oculars plug-in:
- A GUI control panel with buttons has been added in the upper-right corner of the screen. It can be toggled in the configuration window.
- I found what was the problem with the keyboard shortcuts in the pop-up menu. Now it uses the standard "underlined letters" approach and the plug-in is usable with the keyboard only. The menu has been restructured to avoid duplicate shortcut keys.
- The "About" tab of the configuration window is now dynamically filled, including the proper names of the shortcut codes. It should be able to automatically display "Ctrl" and "Cmd" on the appropriate platforms (this should be tested). This will also make easier to make it translateable.
- Buttons allowing change of the order of the items in the lists in the configuration window.
- Fixed the inappropriate flipping of the binoculars view that happened sometimes.
- Fixed a bug with changing the key binding of the "actionShow_Ocular" action.
- And some other stuff - see the revision log below.

I was going to bump the version number, but apparently it is tracked only in the configuration file. As there have been no changes to the format, I decided to skip it.

There were a few more things that I'd like to do, but I'll do them after the merge, if I bother at all.

And if the merge is approved, I'd like to be the one to do it.

To post a comment you must log in.
Revision history for this message
treaves (treaves) wrote : Posted in a previous version of this proposal

The menu still does not work for me; I hit the letters, and nothing happens. This could be a Qt bug however. Not sure.

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

As the menu didn't work before, that it still does not is no big deal.

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

OK, according to Alexander Wolf, the latest revision enables the shortcuts on Mac. Apparently, they are disabled by default because they don't fit in Apple's design philosophy or something.

More info:
http://doc.qt.nokia.com/stable/qshortcut.html#details
http://doc.qt.nokia.com/stable/qtglobal.html#qt_set_sequence_auto_mnemonic

Unfortunately, this means that the underlines indicating the shortcuts are simply not displayed on a Mac and, by default, on Windows 7 (though this can be changed in the user settings). And this kills the whole idea. :(

Something that needs to be experimented with: using QActions like in your orignal implementation, but with setting their shortcut context to Qt::WidgetShortcut or some of the other values:
http://doc.qt.nokia.com/stable/qaction.html#shortcutContext-prop

QMenu::addAction() returns a pointer to the action, so calling setShortcut() for each menu item will be easy.

I don't have time to experiment with this right now, so I'm inclined to merge the code in its current implementation and make the adjustment later.

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

Shortcuts on Mac are underlined

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

Really? According to the Qt documentation, they shouldn't be. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/plugIns.doxygen'
--- doc/plugIns.doxygen 2010-12-03 12:04:33 +0000
+++ doc/plugIns.doxygen 2011-11-24 21:50:30 +0000
@@ -48,7 +48,14 @@
48@section code Coding48@section code Coding
49A plugin should contain a main class deriving from the StelModule class as well as an instance of the StelPluginInterface which allows Stellarium to load it. At startup, the StelModuleMgr will load the library, and an instance of the StelModule it contains will be instantiated and added to the list of other "normal" StelModules.49A plugin should contain a main class deriving from the StelModule class as well as an instance of the StelPluginInterface which allows Stellarium to load it. At startup, the StelModuleMgr will load the library, and an instance of the StelModule it contains will be instantiated and added to the list of other "normal" StelModules.
5050
51<em>Plugin developers - please note that classes used in plugins must inherit code from the core which is published under the GUN GPL. <b>If you distribute a binary plugin, you must do so under the terms of the same GNU GPL license that Stellarium uses.</b> No sneaky closed-source shenanigans now.</em>51A plugin can interact with the users in many ways, not limited to:
52 - painting directly on the viewport like other StelModules (see the examples below);
53 - defining <a href="http://doc.qt.nokia.com/latest/qaction.html">QActions</a> triggered with keyboard shortcut combinations with StelGui::addGuiActions();
54 - buttons (StelButton) added to the bottom button bar (BottomStelBar; see the examples below);
55 - windows (subclasses of StelDialog) that can be designed with Qt's UI editor (see the examples and the configuration windows of the official plugins);
56 - custom controls displayed anywhere on the screen based on any of the classes that inherit <a href="http://doc.qt.nokia.com/latest/qgraphicsitem.html">QGraphicsItem</a> (see <a href="http://doc.qt.nokia.com/latest/graphicsview.html">the documentation of Qt's Graphics View Framework</a>). To get a base widget to work on, use StelGui::getSkyGui().
57
58<em>Plugin developers - please note that classes used in plugins must inherit code from the core which is published under the GNU GPL. <strong>If you distribute a binary plugin, you must do so under the terms of the same GNU General Public License that Stellarium uses</strong> (as of August 2011, this is GNU GPL "version 2 or any later version"). No sneaky closed-source shenanigans now.</em>
5259
53@section examplePlugins Example Plugins60@section examplePlugins Example Plugins
5461
5562
=== modified file 'plugins/Oculars/resources/Oculars.qrc'
--- plugins/Oculars/resources/Oculars.qrc 2010-03-26 13:37:41 +0000
+++ plugins/Oculars/resources/Oculars.qrc 2011-11-24 21:50:30 +0000
@@ -1,10 +1,17 @@
1<!DOCTYPE RCC>1<RCC>
2<RCC version="1.0">2 <qresource prefix="/ocular">
3 <qresource prefix="ocular" >3 <file>bt_ocular_on.png</file>
4 <file>bt_ocular_on.png</file>4 <file>bt_ocular_off.png</file>
5 <file>bt_ocular_off.png</file>5 <file>normalStyle.css</file>
6 <file>normalStyle.css</file>6 <file>nightStyle.css</file>
7 <file>nightStyle.css</file>7 <file>default_ocular.ini</file>
8 <file>default_ocular.ini</file>8 <file>bt_crosshairs_off.png</file>
9 </qresource>9 <file>bt_crosshairs_on.png</file>
10 <file>bt_sensor_off.png</file>
11 <file>bt_sensor_on.png</file>
12 <file>bt_telrad_off.png</file>
13 <file>bt_telrad_on.png</file>
14 <file>bt_settings_off.png</file>
15 <file>bt_settings_on.png</file>
16 </qresource>
10</RCC>17</RCC>
1118
=== added file 'plugins/Oculars/resources/bt_crosshairs_off.png'
12Binary files plugins/Oculars/resources/bt_crosshairs_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_crosshairs_off.png 2011-11-24 21:50:30 +0000 differ19Binary files plugins/Oculars/resources/bt_crosshairs_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_crosshairs_off.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_crosshairs_on.png'
13Binary files plugins/Oculars/resources/bt_crosshairs_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_crosshairs_on.png 2011-11-24 21:50:30 +0000 differ20Binary files plugins/Oculars/resources/bt_crosshairs_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_crosshairs_on.png 2011-11-24 21:50:30 +0000 differ
=== modified file 'plugins/Oculars/resources/bt_ocular_off.png'
14Binary files plugins/Oculars/resources/bt_ocular_off.png 2010-01-22 17:37:33 +0000 and plugins/Oculars/resources/bt_ocular_off.png 2011-11-24 21:50:30 +0000 differ21Binary files plugins/Oculars/resources/bt_ocular_off.png 2010-01-22 17:37:33 +0000 and plugins/Oculars/resources/bt_ocular_off.png 2011-11-24 21:50:30 +0000 differ
=== modified file 'plugins/Oculars/resources/bt_ocular_on.png'
15Binary files plugins/Oculars/resources/bt_ocular_on.png 2010-01-22 17:37:33 +0000 and plugins/Oculars/resources/bt_ocular_on.png 2011-11-24 21:50:30 +0000 differ22Binary files plugins/Oculars/resources/bt_ocular_on.png 2010-01-22 17:37:33 +0000 and plugins/Oculars/resources/bt_ocular_on.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_sensor_off.png'
16Binary files plugins/Oculars/resources/bt_sensor_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_sensor_off.png 2011-11-24 21:50:30 +0000 differ23Binary files plugins/Oculars/resources/bt_sensor_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_sensor_off.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_sensor_on.png'
17Binary files plugins/Oculars/resources/bt_sensor_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_sensor_on.png 2011-11-24 21:50:30 +0000 differ24Binary files plugins/Oculars/resources/bt_sensor_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_sensor_on.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_settings_off.png'
18Binary files plugins/Oculars/resources/bt_settings_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_settings_off.png 2011-11-24 21:50:30 +0000 differ25Binary files plugins/Oculars/resources/bt_settings_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_settings_off.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_settings_on.png'
19Binary files plugins/Oculars/resources/bt_settings_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_settings_on.png 2011-11-24 21:50:30 +0000 differ26Binary files plugins/Oculars/resources/bt_settings_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_settings_on.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_telrad_off.png'
20Binary files plugins/Oculars/resources/bt_telrad_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_telrad_off.png 2011-11-24 21:50:30 +0000 differ27Binary files plugins/Oculars/resources/bt_telrad_off.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_telrad_off.png 2011-11-24 21:50:30 +0000 differ
=== added file 'plugins/Oculars/resources/bt_telrad_on.png'
21Binary files plugins/Oculars/resources/bt_telrad_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_telrad_on.png 2011-11-24 21:50:30 +0000 differ28Binary files plugins/Oculars/resources/bt_telrad_on.png 1970-01-01 00:00:00 +0000 and plugins/Oculars/resources/bt_telrad_on.png 2011-11-24 21:50:30 +0000 differ
=== modified file 'plugins/Oculars/src/CMakeLists.txt'
--- plugins/Oculars/src/CMakeLists.txt 2011-01-06 20:50:30 +0000
+++ plugins/Oculars/src/CMakeLists.txt 2011-11-24 21:50:30 +0000
@@ -19,6 +19,8 @@
19 gui/OcularDialog.cpp19 gui/OcularDialog.cpp
20 gui/PropertyBasedTableModel.hpp20 gui/PropertyBasedTableModel.hpp
21 gui/PropertyBasedTableModel.cpp21 gui/PropertyBasedTableModel.cpp
22 gui/OcularsGuiPanel.hpp
23 gui/OcularsGuiPanel.cpp
22)24)
2325
24SET(Oculars_RES ../resources/Oculars.qrc)26SET(Oculars_RES ../resources/Oculars.qrc)
@@ -39,6 +41,7 @@
39 Telescope.hpp41 Telescope.hpp
40 gui/OcularDialog.hpp42 gui/OcularDialog.hpp
41 gui/PropertyBasedTableModel.hpp43 gui/PropertyBasedTableModel.hpp
44 gui/OcularsGuiPanel.hpp
42)45)
4346
44# After this call, Oculars_MOC_SRCS = moc_Oculars.cxx47# After this call, Oculars_MOC_SRCS = moc_Oculars.cxx
4548
=== modified file 'plugins/Oculars/src/Oculars.cpp'
--- plugins/Oculars/src/Oculars.cpp 2011-11-12 22:55:30 +0000
+++ plugins/Oculars/src/Oculars.cpp 2011-11-24 21:50:30 +0000
@@ -1,5 +1,6 @@
1/*1/*
2 * Copyright (C) 2009 Timothy Reaves2 * Copyright (C) 2009 Timothy Reaves
3 * Copyright (C) 2011 Bogdan Marinov
3 *4 *
4 * This program is free software; you can redistribute it and/or5 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License6 * modify it under the terms of the GNU General Public License
@@ -17,6 +18,7 @@
17 */18 */
1819
19#include "Oculars.hpp"20#include "Oculars.hpp"
21#include "OcularsGuiPanel.hpp"
2022
21#include "GridLinesMgr.hpp"23#include "GridLinesMgr.hpp"
22#include "LabelMgr.hpp"24#include "LabelMgr.hpp"
@@ -33,8 +35,10 @@
33#include "StelGuiItems.hpp"35#include "StelGuiItems.hpp"
34#include "StelMainWindow.hpp"36#include "StelMainWindow.hpp"
35#include "StelTranslator.hpp"37#include "StelTranslator.hpp"
38#include "SkyGui.hpp"
3639
37#include <QAction>40#include <QAction>
41#include <QGraphicsWidget>
38#include <QKeyEvent>42#include <QKeyEvent>
39#include <QDebug>43#include <QDebug>
40#include <QMenu>44#include <QMenu>
@@ -51,6 +55,10 @@
51#include <GL/glu.h> /* Header File For The GLU Library */55#include <GL/glu.h> /* Header File For The GLU Library */
52#endif56#endif
5357
58#ifdef Q_WS_MAC
59extern void qt_set_sequence_auto_mnemonic(bool b);
60#endif
61
54static QSettings *settings; //!< The settings as read in from the ini file.62static QSettings *settings; //!< The settings as read in from the ini file.
5563
56/* ********************************************************************* */64/* ********************************************************************* */
@@ -74,7 +82,7 @@
74 StelPluginInfo info;82 StelPluginInfo info;
75 info.id = "Oculars";83 info.id = "Oculars";
76 info.displayedName = N_("Oculars");84 info.displayedName = N_("Oculars");
77 info.authors = "Timothy Reaves";85 info.authors = "Timothy Reaves, Bogdan Marinov";
78 info.contact = "treaves@silverfieldstech.com";86 info.contact = "treaves@silverfieldstech.com";
79 info.description = N_("Shows the sky as if looking through a telescope eyepiece. (Only magnification and field of view are simulated.) It can also show a sensor frame and a Telrad sight.");87 info.description = N_("Shows the sky as if looking through a telescope eyepiece. (Only magnification and field of view are simulated.) It can also show a sensor frame and a Telrad sight.");
80 return info;88 return info;
@@ -89,7 +97,16 @@
89#pragma mark Instance Methods97#pragma mark Instance Methods
90#endif98#endif
91/* ********************************************************************* */99/* ********************************************************************* */
92Oculars::Oculars() : pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon(NULL), toolbarButton(NULL)100Oculars::Oculars():
101 pxmapGlow(NULL),
102 pxmapOnIcon(NULL),
103 pxmapOffIcon(NULL),
104 toolbarButton(NULL),
105 actionShowOcular(0),
106 actionShowCrosshairs(0),
107 actionShowSensor(0),
108 actionShowTelrad(0),
109 guiPanel(0)
93{110{
94 flagShowCCD = false;111 flagShowCCD = false;
95 flagShowOculars = false;112 flagShowOculars = false;
@@ -118,12 +135,17 @@
118135
119 setObjectName("Oculars");136 setObjectName("Oculars");
120137
138#ifdef Q_WS_MAC
139 qt_set_sequence_auto_mnemonic(true);
140#endif
121}141}
122142
123Oculars::~Oculars()143Oculars::~Oculars()
124{144{
125 delete ocularDialog;145 delete ocularDialog;
126 ocularDialog = NULL;146 ocularDialog = NULL;
147 if (guiPanel)
148 delete guiPanel;
127 149
128 if (pxmapGlow)150 if (pxmapGlow)
129 delete pxmapGlow;151 delete pxmapGlow;
@@ -211,7 +233,7 @@
211 if (flagShowTelrad) {233 if (flagShowTelrad) {
212 paintTelrad();234 paintTelrad();
213 } else if (flagShowOculars){235 } else if (flagShowOculars){
214 // Insure there is a selected ocular & telescope236 // Ensure there is a selected ocular & telescope
215 if (selectedCCDIndex > ccds.count()) {237 if (selectedCCDIndex > ccds.count()) {
216 qWarning() << "Oculars: the selected sensor index of "238 qWarning() << "Oculars: the selected sensor index of "
217 << selectedCCDIndex << " is greater than the sensor count of "239 << selectedCCDIndex << " is greater than the sensor count of "
@@ -238,17 +260,37 @@
238 paintCrosshairs();260 paintCrosshairs();
239 }261 }
240 }262 }
263 if (guiPanelEnabled)
264 {
265 // Reset the state to allow the panel to be painted normally
266 glDisable(GL_TEXTURE_2D);
267 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
268 glEnable(GL_BLEND);
269 }
270 else
271 {
272 // Paint the information in the upper-right hand corner
273 paintText(core);
274 }
275 }
276 } else if (flagShowCCD) {
277 paintCCDBounds();
278 if (guiPanelEnabled)
279 {
280 // Reset the state to allow the panel to be painted normally
281 glDisable(GL_TEXTURE_2D);
282 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
283 glEnable(GL_BLEND);
284 }
285 else
286 {
241 // Paint the information in the upper-right hand corner287 // Paint the information in the upper-right hand corner
242 paintText(core);288 paintText(core);
243 }289 }
244 } else if (flagShowCCD) {290 }
245 paintCCDBounds();
246 // Paint the information in the upper-right hand corner
247 paintText(core);
248 }
249}291}
250292
251//! Determine which "layer" the plagin's drawing will happen on.293//! Determine which "layer" the plugin's drawing will happen on.
252double Oculars::getCallOrder(StelModuleActionName actionName) const294double Oculars::getCallOrder(StelModuleActionName actionName) const
253{295{
254 // TODO; this really doesn't seem to have any effect. I've tried everything from -100 to +100,296 // TODO; this really doesn't seem to have any effect. I've tried everything from -100 to +100,
@@ -287,12 +329,7 @@
287 movementManager->setFlagTracking(true);329 movementManager->setFlagTracking(true);
288 } else {330 } else {
289 // remove the usage label if it is being displayed.331 // remove the usage label if it is being displayed.
290 if (usageMessageLabelID > -1) {332 hideUsageMessageIfDisplayed();
291 LabelMgr *labelManager = GETSTELMODULE(LabelMgr);
292 labelManager->setLabelShow(usageMessageLabelID, false);
293 labelManager->deleteLabel(usageMessageLabelID);
294 usageMessageLabelID = -1;
295 }
296 }333 }
297 } else if(flagShowOculars) {334 } else if(flagShowOculars) {
298 //TODO: this is broke in Stellarium.335 //TODO: this is broke in Stellarium.
@@ -465,9 +502,12 @@
465 selectedTelescopeIndex = 0;502 selectedTelescopeIndex = 0;
466 }503 }
467504
468 ocularDialog = new OcularDialog(&ccds, &oculars, &telescopes);505 ocularDialog = new OcularDialog(this, &ccds, &oculars, &telescopes);
469 initializeActivationActions();506 initializeActivationActions();
470 determineMaxEyepieceAngle();507 determineMaxEyepieceAngle();
508
509 guiPanelEnabled = settings->value("enable_control_panel", false).toBool();
510 enableGuiPanel(guiPanelEnabled);
471 } catch (std::runtime_error& e) {511 } catch (std::runtime_error& e) {
472 qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what();512 qWarning() << "WARNING: unable to locate ocular.ini file or create a default one for Ocular plugin: " << e.what();
473 ready = false;513 ready = false;
@@ -553,12 +593,84 @@
553 }593 }
554}594}
555595
596void Oculars::enableGuiPanel(bool enable)
597{
598 if (enable)
599 {
600 if (!guiPanel)
601 {
602 StelApp& app = StelApp::getInstance();
603 StelGui* gui = dynamic_cast<StelGui*>(app.getGui());
604 Q_ASSERT(gui);
605 guiPanel = new OcularsGuiPanel(this, gui->getSkyGui());
606 }
607 }
608 else
609 {
610 if (guiPanel)
611 {
612 guiPanel->hide();
613 delete guiPanel;
614 guiPanel = 0;
615 }
616 }
617 guiPanelEnabled = enable;
618 settings->setValue("enable_control_panel", enable);
619 settings->sync();
620}
621
556/* ********************************************************************* */622/* ********************************************************************* */
557#if 0623#if 0
558#pragma mark -624#pragma mark -
559#pragma mark Slots Methods625#pragma mark Slots Methods
560#endif626#endif
561/* ********************************************************************* */627/* ********************************************************************* */
628void Oculars::updateLists()
629{
630 if (oculars.isEmpty())
631 {
632 selectedOcularIndex = -1;
633 actionShowOcular->setChecked(false);
634 }
635 else
636 {
637 if (selectedOcularIndex >= oculars.count())
638 selectedOcularIndex = oculars.count() - 1;
639
640 if (flagShowOculars)
641 emit selectedOcularChanged();
642 }
643
644 if (telescopes.isEmpty())
645 {
646 selectedTelescopeIndex = -1;
647 actionShowOcular->setChecked(false);
648 actionShowSensor->setChecked(false);
649 }
650 else
651 {
652 if (selectedTelescopeIndex >= telescopes.count())
653 selectedTelescopeIndex = telescopes.count() - 1;
654
655 if (flagShowOculars || flagShowCCD)
656 emit selectedTelescopeChanged();
657 }
658
659 if (ccds.isEmpty())
660 {
661 selectedCCDIndex = -1;
662 actionShowSensor->setChecked(false);
663 }
664 else
665 {
666 if (selectedCCDIndex >= ccds.count())
667 selectedCCDIndex = ccds.count() - 1;
668
669 if (flagShowCCD)
670 emit selectedCCDChanged();
671 }
672}
673
562void Oculars::ccdRotationReset()674void Oculars::ccdRotationReset()
563{675{
564 ccdRotationAngle = 0.0;676 ccdRotationAngle = 0.0;
@@ -566,14 +678,25 @@
566678
567void Oculars::enableOcular(bool enableOcularMode)679void Oculars::enableOcular(bool enableOcularMode)
568{680{
569 // If showing a CCD, cancel it.681 if (enableOcularMode)
570 if (flagShowCCD) {682 {
571 flagShowCCD = false;683 // Close the sensor view if it's displayed
572 selectedCCDIndex = -1;684 if (flagShowCCD)
573 }685 {
574 686 if (actionShowSensor->isChecked())
575 if (enableOcularMode) {687 actionShowSensor->setChecked(false);
576 // Check to insure that we have enough oculars & telescopes, as they may have been edited in the config dialog688 flagShowCCD = false;
689 selectedCCDIndex = -1;
690 }
691
692 // Close the Telrad sight if it's displayed
693 if (flagShowTelrad)
694 {
695 if (actionShowTelrad->isChecked())
696 actionShowTelrad->setChecked(false);
697 }
698
699 // Check to ensure that we have enough oculars & telescopes, as they may have been edited in the config dialog
577 if (oculars.count() == 0) {700 if (oculars.count() == 0) {
578 selectedOcularIndex = -1;701 selectedOcularIndex = -1;
579 qWarning() << "No oculars found";702 qWarning() << "No oculars found";
@@ -596,11 +719,11 @@
596 StelCore *core = StelApp::getInstance().getCore();719 StelCore *core = StelApp::getInstance().getCore();
597 LabelMgr* labelManager = GETSTELMODULE(LabelMgr);720 LabelMgr* labelManager = GETSTELMODULE(LabelMgr);
598721
599 // Toggle the plugin on & off. To toggle on, we want to ensure there is a selected object.722 // Toggle the ocular view on & off. To toggle on, we want to ensure there is a selected object.
600 if (!flagShowOculars && requireSelection && !StelApp::getInstance().getStelObjectMgr().getWasSelected() ) {723 if (!flagShowOculars && requireSelection && !StelApp::getInstance().getStelObjectMgr().getWasSelected() ) {
601 if (usageMessageLabelID == -1) {724 if (usageMessageLabelID == -1) {
602 QFontMetrics metrics(font);725 QFontMetrics metrics(font);
603 QString labelText = "Please select an object before enabling Ocular.";726 QString labelText = "Please select an object before switching to ocular view.";
604 StelProjector::StelProjectorParams projectorParams = core->getCurrentStelProjectorParams();727 StelProjector::StelProjectorParams projectorParams = core->getCurrentStelProjectorParams();
605 int xPosition = projectorParams.viewportCenter[0];728 int xPosition = projectorParams.viewportCenter[0];
606 xPosition = xPosition - 0.5 * (metrics.width(labelText));729 xPosition = xPosition - 0.5 * (metrics.width(labelText));
@@ -610,21 +733,20 @@
610 true, font.pixelSize(), "#99FF99");733 true, font.pixelSize(), "#99FF99");
611 }734 }
612 // we didn't accept the new status - make sure the toolbar button reflects this735 // we didn't accept the new status - make sure the toolbar button reflects this
613 StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());736 disconnect(actionShowOcular, SIGNAL(toggled(bool)),
614 Q_ASSERT(gui);737 this, SLOT(enableOcular(bool)));
615 disconnect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool)), this, SLOT(enableOcular(bool)));738 actionShowOcular->setChecked(false);
616 gui->getGuiActions("actionShow_Ocular")->setChecked(false);739 connect(actionShowOcular, SIGNAL(toggled(bool)),
617 connect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool)), this, SLOT(enableOcular(bool)));740 this, SLOT(enableOcular(bool)));
618 } else {741 } else {
619 if (selectedOcularIndex != -1) {742 if (selectedOcularIndex != -1) {
620 // remove the usage label if it is being displayed.743 // remove the usage label if it is being displayed.
621 if (usageMessageLabelID > -1) {744 hideUsageMessageIfDisplayed();
622 labelManager->setLabelShow(usageMessageLabelID, false);
623 labelManager->deleteLabel(usageMessageLabelID);
624 usageMessageLabelID = -1;
625 }
626 flagShowOculars = enableOcularMode;745 flagShowOculars = enableOcularMode;
627 zoom(false);746 zoom(false);
747 //BM: I hope this is the right place...
748 if (guiPanel)
749 guiPanel->showOcularGui();
628 }750 }
629 }751 }
630}752}
@@ -632,7 +754,7 @@
632void Oculars::decrementCCDIndex()754void Oculars::decrementCCDIndex()
633{755{
634 selectedCCDIndex--;756 selectedCCDIndex--;
635 if (selectedCCDIndex == -2) {757 if (selectedCCDIndex == -1) {
636 selectedCCDIndex = ccds.count() - 1;758 selectedCCDIndex = ccds.count() - 1;
637 }759 }
638 emit(selectedCCDChanged());760 emit(selectedCCDChanged());
@@ -671,136 +793,165 @@
671793
672void Oculars::displayPopupMenu()794void Oculars::displayPopupMenu()
673{795{
674 QMenu* popup = new QMenu();796 QMenu* popup = new QMenu(&StelMainWindow::getInstance());
675797
676 if (flagShowOculars) {798 if (flagShowOculars)
799 {
677 // We are in Oculars mode800 // We are in Oculars mode
678 // We want to show all of the Oculars, and if the current ocular is not a binocular,801 // We want to show all of the Oculars, and if the current ocular is not a binocular,
679 // we will also show the telescopes.802 // we will also show the telescopes.
680 if (oculars.count() > 0) {803 if (!oculars.isEmpty())
681 popup->addAction("previous ocular", this, SLOT(decrementOcularIndex()), Qt::Key_1);804 {
682 popup->addAction("next ocular", this, SLOT(incrementOcularIndex()), Qt::Key_2);805 popup->addAction("&Previous ocular", this, SLOT(decrementOcularIndex()));
683 QMenu* submenu = new QMenu("select ocular", popup);806 popup->addAction("&Next ocular", this, SLOT(incrementOcularIndex()));
807 QMenu* submenu = new QMenu("Select &ocular", popup);
684 int availableOcularCount = 0;808 int availableOcularCount = 0;
685 for (int index = 0; index < oculars.count(); ++index) {809 for (int index = 0; index < oculars.count(); ++index)
810 {
811 QString label;
812 if (availableOcularCount < 10)
813 {
814 label = QString("&%1: %2").arg(availableOcularCount).arg(oculars[index]->name());
815 }
816 else
817 {
818 label = oculars[index]->name();
819 }
820 //BM: Does this happen at all any more?
821 QAction* action = 0;
686 if (selectedTelescopeIndex == -1) {822 if (selectedTelescopeIndex == -1) {
687 if (oculars[index]->isBinoculars()) {823 if (oculars[index]->isBinoculars()) {
688 QAction* action = submenu->addAction(oculars[index]->name(), ocularsSignalMapper, SLOT(map()), 824 action = submenu->addAction(label, ocularsSignalMapper, SLOT(map()));
689 QKeySequence(QString("%1").arg(availableOcularCount++)));825 availableOcularCount++;
690 ocularsSignalMapper->setMapping(action, QString("%1").arg(index));826 ocularsSignalMapper->setMapping(action, QString("%1").arg(index));
691 }827 }
692 } else {828 } else {
693 QAction* action = submenu->addAction(oculars[index]->name(), ocularsSignalMapper, SLOT(map()), 829 action = submenu->addAction(label, ocularsSignalMapper, SLOT(map()));
694 QKeySequence(QString("%1").arg(availableOcularCount++)));830 availableOcularCount++;
695 ocularsSignalMapper->setMapping(action, QString("%1").arg(index));831 ocularsSignalMapper->setMapping(action, QString("%1").arg(index));
696 }832 }
697 }833 if (action && index == selectedOcularIndex)
698 popup->addMenu(submenu);834 {
699 popup->addSeparator();835 action->setCheckable(true);
700 }836 action->setChecked(true);
701837 }
702 if (telescopes.count() > 0 && (selectedOcularIndex > -1 && !oculars[selectedOcularIndex]->isBinoculars())) {838 }
703 popup->addAction("previous telescope", this, SLOT(decrementTelescopeIndex()), Qt::Key_3);839 popup->addMenu(submenu);
704 popup->addAction("next telescope", this, SLOT(incrementTelescopeIndex()), Qt::Key_4);840 popup->addSeparator();
705 QMenu* submenu = new QMenu("select telescope", popup);841 }
706 for (int index = 0; index < telescopes.count(); ++index) {842
707 QAction* action = submenu->addAction(telescopes[index]->name(), telescopesSignalMapper, SLOT(map()), 843 // If there is more than one telescope, show the prev/next/list complex.
708 QKeySequence(QString("%1").arg(index)));844 // If the selected ocular is a binoculars, show nothing.
709 telescopesSignalMapper->setMapping(action, QString("%1").arg(index));845 if (telescopes.count() > 1 && (selectedOcularIndex > -1 && !oculars[selectedOcularIndex]->isBinoculars()))
710 }846 {
711 popup->addMenu(submenu);847 QMenu* submenu = addTelescopeSubmenu(popup);
712 popup->addSeparator();848 popup->addMenu(submenu);
713 }849 popup->addSeparator();
714850 }
715 popup->addAction("toggle crosshair", this, SLOT(toggleCrosshair()), Qt::Key_5);851
852 QAction* action = popup->addAction("Toggle &crosshair");
853 action->setCheckable(true);
854 action->setChecked(flagShowCrosshairs);
855 connect(action, SIGNAL(toggled(bool)),
856 actionShowCrosshairs, SLOT(setChecked(bool)));
716 } else {857 } else {
717 int outerMenuLevel = 1;858 // We are not in ocular mode
718 // We are not in Oculars mode859 // We want to show the CCD's, and if a CCD is selected, the telescopes
719 // We want to show the CCD's, and if a CCD is selected, the Telescopes (as a CCD requires a telescope),860 //(as a CCD requires a telescope) and the general menu items.
720 // and the general menu items.861 QAction* action = new QAction("Configure &Oculars", popup);
721 QAction* action = new QAction("Configure Oculars", popup);862 action->setCheckable(true);
722 action->setCheckable(TRUE);863 action->setChecked(ocularDialog->visible());
723 action->setShortcut(QString("%1").arg(outerMenuLevel++));864 connect(action, SIGNAL(triggered(bool)),
724 connect(action, SIGNAL(toggled(bool)), ocularDialog, SLOT(setVisible(bool)));865 ocularDialog, SLOT(setVisible(bool)));
725 connect(ocularDialog, SIGNAL(visibleChanged(bool)), action, SLOT(setChecked(bool)));
726 popup->addAction(action);866 popup->addAction(action);
727 popup->addSeparator();867 popup->addSeparator();
728868
729 if (!flagShowTelrad) {869 if (!flagShowTelrad) {
730 popup->addAction("Toggle CCD", this, SLOT(toggleCCD()), QKeySequence(QString("%1").arg(outerMenuLevel++)));870 QAction* action = popup->addAction("Toggle &CCD");
871 action->setCheckable(true);
872 action->setChecked(flagShowCCD);
873 connect(action, SIGNAL(toggled(bool)),
874 actionShowSensor, SLOT(setChecked(bool)));
731 }875 }
732 876
733 if (!flagShowCCD) {877 if (!flagShowCCD) {
734 popup->addAction("Toggle Telrad", this,878 QAction* action = popup->addAction("Toggle &Telrad");
735 SLOT(toggleTelrad()), QKeySequence(QString("%1").arg(outerMenuLevel++)));879 action->setCheckable(true);
880 action->setChecked(flagShowTelrad);
881 connect(action, SIGNAL(toggled(bool)),
882 actionShowTelrad, SLOT(setChecked(bool)));
736 }883 }
737884
738 popup->addSeparator();885 popup->addSeparator();
739 if (selectedCCDIndex > -1 && selectedTelescopeIndex > -1) {886 if (flagShowCCD && selectedCCDIndex > -1 && selectedTelescopeIndex > -1)
740 popup->addAction("previous CCD", this,887 {
741 SLOT(decrementCCDIndex()), QKeySequence(QString("%1").arg(outerMenuLevel++)));888 popup->addAction("&Previous CCD", this, SLOT(decrementCCDIndex()));
742 popup->addAction("next CCD", this,889 popup->addAction("&Next CCD", this, SLOT(incrementCCDIndex()));
743 SLOT(incrementCCDIndex()), QKeySequence(QString("%1").arg(outerMenuLevel++)));890 QMenu* submenu = new QMenu("&Select CCD", popup);
744 QMenu* submenu = new QMenu("select CCD", popup);891 for (int index = 0; index < ccds.count(); ++index)
745 for (int index = 0; index < ccds.count(); ++index) {892 {
746 QAction* action = submenu->addAction(ccds[index]->name(), ccdsSignalMapper, SLOT(map()), 893 QString label;
747 QKeySequence(QString("%1").arg(index)));894 if (index < 10)
895 {
896 label = QString("&%1: %2").arg(index).arg(ccds[index]->name());
897 }
898 else
899 {
900 label = ccds[index]->name();
901 }
902 QAction* action = submenu->addAction(label, ccdsSignalMapper, SLOT(map()));
903 if (index == selectedCCDIndex)
904 {
905 action->setCheckable(true);
906 action->setChecked(true);
907 }
748 ccdsSignalMapper->setMapping(action, QString("%1").arg(index));908 ccdsSignalMapper->setMapping(action, QString("%1").arg(index));
749 }909 }
750 popup->addMenu(submenu);910 popup->addMenu(submenu);
751 911
752 submenu = new QMenu("Rotate CCD", popup);912 submenu = new QMenu("&Rotate CCD", popup);
753 QAction* rotateAction = NULL;913 QAction* rotateAction = NULL;
754 rotateAction = submenu->addAction(QString("-90") + QChar(0x00B0),914 rotateAction = submenu->addAction(QString("&1: -90") + QChar(0x00B0),
755 ccdRotationSignalMapper, SLOT(map()), Qt::Key_1);915 ccdRotationSignalMapper, SLOT(map()));
756 ccdRotationSignalMapper->setMapping(rotateAction, QString("-90"));916 ccdRotationSignalMapper->setMapping(rotateAction, QString("-90"));
757 rotateAction = submenu->addAction(QString("-45") + QChar(0x00B0),917 rotateAction = submenu->addAction(QString("&2: -45") + QChar(0x00B0),
758 ccdRotationSignalMapper, SLOT(map()), Qt::Key_2);918 ccdRotationSignalMapper, SLOT(map()));
759 ccdRotationSignalMapper->setMapping(rotateAction, QString("-45"));919 ccdRotationSignalMapper->setMapping(rotateAction, QString("-45"));
760 rotateAction = submenu->addAction(QString("-15") + QChar(0x00B0),920 rotateAction = submenu->addAction(QString("&3: -15") + QChar(0x00B0),
761 ccdRotationSignalMapper, SLOT(map()), Qt::Key_3);921 ccdRotationSignalMapper, SLOT(map()));
762 ccdRotationSignalMapper->setMapping(rotateAction, QString("-15"));922 ccdRotationSignalMapper->setMapping(rotateAction, QString("-15"));
763 rotateAction = submenu->addAction(QString("-5") + QChar(0x00B0),923 rotateAction = submenu->addAction(QString("&4: -5") + QChar(0x00B0),
764 ccdRotationSignalMapper, SLOT(map()), Qt::Key_4);924 ccdRotationSignalMapper, SLOT(map()));
765 ccdRotationSignalMapper->setMapping(rotateAction, QString("-5"));925 ccdRotationSignalMapper->setMapping(rotateAction, QString("-5"));
766 rotateAction = submenu->addAction(QString("-1") + QChar(0x00B0),926 rotateAction = submenu->addAction(QString("&5: -1") + QChar(0x00B0),
767 ccdRotationSignalMapper, SLOT(map()), Qt::Key_5);927 ccdRotationSignalMapper, SLOT(map()));
768 ccdRotationSignalMapper->setMapping(rotateAction, QString("-1"));928 ccdRotationSignalMapper->setMapping(rotateAction, QString("-1"));
769 rotateAction = submenu->addAction(QString("+1") + QChar(0x00B0),929 rotateAction = submenu->addAction(QString("&6: +1") + QChar(0x00B0),
770 ccdRotationSignalMapper, SLOT(map()), Qt::Key_6);930 ccdRotationSignalMapper, SLOT(map()));
771 ccdRotationSignalMapper->setMapping(rotateAction, QString("1"));931 ccdRotationSignalMapper->setMapping(rotateAction, QString("1"));
772 rotateAction = submenu->addAction(QString("+5") + QChar(0x00B0),932 rotateAction = submenu->addAction(QString("&7: +5") + QChar(0x00B0),
773 ccdRotationSignalMapper, SLOT(map()), Qt::Key_7);933 ccdRotationSignalMapper, SLOT(map()));
774 ccdRotationSignalMapper->setMapping(rotateAction, QString("5"));934 ccdRotationSignalMapper->setMapping(rotateAction, QString("5"));
775 rotateAction = submenu->addAction(QString("+15") + QChar(0x00B0),935 rotateAction = submenu->addAction(QString("&8: +15") + QChar(0x00B0),
776 ccdRotationSignalMapper, SLOT(map()), Qt::Key_8);936 ccdRotationSignalMapper, SLOT(map()));
777 ccdRotationSignalMapper->setMapping(rotateAction, QString("15"));937 ccdRotationSignalMapper->setMapping(rotateAction, QString("15"));
778 rotateAction = submenu->addAction(QString("+45") + QChar(0x00B0),938 rotateAction = submenu->addAction(QString("&9: +45") + QChar(0x00B0),
779 ccdRotationSignalMapper, SLOT(map()), Qt::Key_9);939 ccdRotationSignalMapper, SLOT(map()));
780 ccdRotationSignalMapper->setMapping(rotateAction, QString("45"));940 ccdRotationSignalMapper->setMapping(rotateAction, QString("45"));
781 rotateAction = submenu->addAction(QString("+90") + QChar(0x00B0),941 rotateAction = submenu->addAction(QString("&0: +90") + QChar(0x00B0),
782 ccdRotationSignalMapper, SLOT(map()), Qt::Key_0);942 ccdRotationSignalMapper, SLOT(map()));
783 ccdRotationSignalMapper->setMapping(rotateAction, QString("90"));943 ccdRotationSignalMapper->setMapping(rotateAction, QString("90"));
784 rotateAction = submenu->addAction("Reset", this, SLOT(ccdRotationReset()), Qt::Key_R);944 rotateAction = submenu->addAction("&Reset", this, SLOT(ccdRotationReset()));
785 popup->addMenu(submenu);945 popup->addMenu(submenu);
786 946
787 popup->addSeparator();947 popup->addSeparator();
788 }948 }
789 if (selectedCCDIndex > -1 && telescopes.count() > 0) {949 if (flagShowCCD && selectedCCDIndex > -1 && telescopes.count() > 1)
790 popup->addAction("previous telescope", this,950 {
791 SLOT(decrementTelescopeIndex()), QKeySequence(QString("%1").arg(outerMenuLevel++)));951 QMenu* submenu = addTelescopeSubmenu(popup);
792 popup->addAction("next telescope", this,
793 SLOT(incrementTelescopeIndex()), QKeySequence(QString("%1").arg(outerMenuLevel++)));
794 QMenu* submenu = new QMenu("select telescope", popup);
795 for (int index = 0; index < telescopes.count(); ++index) {
796 QAction* action = submenu->addAction(telescopes[index]->name(), telescopesSignalMapper, SLOT(map()),
797 QKeySequence(QString("%1").arg(index)));
798 telescopesSignalMapper->setMapping(action, QString("%1").arg(index));
799 }
800 popup->addMenu(submenu);952 popup->addMenu(submenu);
801 popup->addSeparator();953 popup->addSeparator();
802 }954 }
803
804 }955 }
805956
806 popup->exec(QCursor::pos());957 popup->exec(QCursor::pos());
@@ -811,7 +962,7 @@
811{962{
812 selectedCCDIndex++;963 selectedCCDIndex++;
813 if (selectedCCDIndex == ccds.count()) {964 if (selectedCCDIndex == ccds.count()) {
814 selectedCCDIndex = -1;965 selectedCCDIndex = 0;
815 }966 }
816 emit(selectedCCDChanged());967 emit(selectedCCDChanged());
817}968}
@@ -850,6 +1001,10 @@
850void Oculars::rotateCCD(QString amount)1001void Oculars::rotateCCD(QString amount)
851{1002{
852 ccdRotationAngle += amount.toInt();1003 ccdRotationAngle += amount.toInt();
1004 if (ccdRotationAngle >= 360)
1005 ccdRotationAngle -= 360;
1006 if (ccdRotationAngle <= -360)
1007 ccdRotationAngle += 360;
853}1008}
8541009
855void Oculars::selectCCDAtIndex(QString indexString)1010void Oculars::selectCCDAtIndex(QString indexString)
@@ -891,46 +1046,103 @@
891 }1046 }
892}1047}
8931048
894void Oculars::toggleCCD()1049void Oculars::toggleCCD(bool show)
895{1050{
896 StelCore *core = StelApp::getInstance().getCore();1051 //If there are no sensors...
897 StelMovementMgr *movementManager = core->getMovementMgr();1052 if (ccds.isEmpty() || telescopes.isEmpty())
898 if (flagShowCCD) {1053 {
1054 //TODO: BM: Make this an on-screen message and/or disable the button
1055 //if there are no sensors.
1056 if (show)
1057 qWarning() << "Oculars plugin: Unable to display a sensor boundary:"
1058 << "No sensors or telescopes are defined.";
899 flagShowCCD = false;1059 flagShowCCD = false;
900 selectedCCDIndex = -1;1060 selectedCCDIndex = -1;
901 movementManager->zoomTo(movementManager->getInitFov());1061 show = false;
902 movementManager->setFlagTracking(false);1062 if (actionShowSensor->isChecked())
903 } else {1063 actionShowSensor->setChecked(false);
904 // Check to insure that we have enough CCDs & telescopes, as they may have been edited in the config dialog1064 }
905 if (ccds.count() == 0) {1065
906 selectedCCDIndex = -1;1066 if (show)
907 qDebug() << "No CCDs found";1067 {
908 } else if (ccds.count() > 0 && selectedCCDIndex == -1) {1068 //Mutually exclusive with the ocular mode
1069 hideUsageMessageIfDisplayed();
1070 if (flagShowOculars)
1071 {
1072 if (actionShowOcular->isChecked())
1073 actionShowOcular->setChecked(false);
1074 }
1075
1076 if (flagShowTelrad)
1077 {
1078 if (actionShowTelrad->isChecked())
1079 actionShowTelrad->setChecked(false);
1080 }
1081
1082 if (selectedTelescopeIndex < 0)
1083 selectedTelescopeIndex = 0;
1084 if (selectedCCDIndex < 0)
909 selectedCCDIndex = 0;1085 selectedCCDIndex = 0;
910 }
911 if (telescopes.count() == 0) {
912 selectedTelescopeIndex = -1;
913 qDebug() << "No telescopes found";
914 } else if (telescopes.count() > 0 && selectedTelescopeIndex == -1) {
915 selectedTelescopeIndex = 0;
916 }
917 if (!ready || selectedCCDIndex == -1 || selectedTelescopeIndex == -1 ) {
918 qDebug() << "The Oculars module has been disabled.";
919 return;
920 }
921 flagShowCCD = true;1086 flagShowCCD = true;
922 setScreenFOVForCCD();1087 setScreenFOVForCCD();
923 }1088
924}1089 if (guiPanel)
9251090 guiPanel->showCcdGui();
926void Oculars::toggleCrosshair()1091 }
927{1092 else
928 flagShowCrosshairs = !flagShowCrosshairs;1093 {
1094 flagShowCCD = false;
1095
1096 //Zoom out
1097 StelCore *core = StelApp::getInstance().getCore();
1098 StelMovementMgr *movementManager = core->getMovementMgr();
1099 movementManager->zoomTo(movementManager->getInitFov());
1100 movementManager->setFlagTracking(false);
1101
1102 if (guiPanel)
1103 guiPanel->foldGui();
1104 }
1105}
1106
1107void Oculars::toggleCCD()
1108{
1109 if (flagShowCCD)
1110 toggleCCD(false);
1111 else
1112 toggleCCD(true);
1113}
1114
1115void Oculars::toggleCrosshairs(bool show)
1116{
1117 if (show && flagShowOculars)
1118 {
1119 flagShowCrosshairs = true;
1120 }
1121 else
1122 {
1123 flagShowCrosshairs = false;
1124 }
1125}
1126
1127void Oculars::toggleTelrad(bool show)
1128{
1129 if (show)
1130 {
1131 hideUsageMessageIfDisplayed();
1132 if (actionShowOcular->isChecked())
1133 actionShowOcular->setChecked(false);
1134 if (actionShowSensor->isChecked())
1135 actionShowSensor->setChecked(false);
1136 }
1137 flagShowTelrad = show;
929}1138}
9301139
931void Oculars::toggleTelrad()1140void Oculars::toggleTelrad()
932{1141{
933 flagShowTelrad = !flagShowTelrad;1142 if (flagShowTelrad)
1143 toggleTelrad(false);
1144 else
1145 toggleTelrad(true);
934}1146}
9351147
936/* ********************************************************************* */1148/* ********************************************************************* */
@@ -953,12 +1165,13 @@
953 //the necessary button is created to prevent the button from being checked1165 //the necessary button is created to prevent the button from being checked
954 //the first time this action is checked. See:1166 //the first time this action is checked. See:
955 //http://doc.qt.nokia.com/4.7/signalsandslots.html#signals1167 //http://doc.qt.nokia.com/4.7/signalsandslots.html#signals
956 gui->addGuiActions("actionShow_Ocular",1168 QString shortcutStr = settings->value("bindings/toggle_oculars", "Ctrl+O").toString();
957 N_("Ocular view"),1169 actionShowOcular = gui->addGuiActions("actionShow_Ocular",
958 settings->value("bindings/toggle_oculars", "Ctrl+O").toString(),1170 N_("Ocular view"),
959 N_("Plugin Key Bindings"),1171 shortcutStr,
960 true);1172 group,
961 gui->getGuiActions("actionShow_Ocular")->setChecked(flagShowOculars);1173 true);
1174 actionShowOcular->setChecked(flagShowOculars);
962 // Make a toolbar button1175 // Make a toolbar button
963 try {1176 try {
964 pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png");1177 pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png");
@@ -968,19 +1181,56 @@
968 *pxmapOnIcon,1181 *pxmapOnIcon,
969 *pxmapOffIcon,1182 *pxmapOffIcon,
970 *pxmapGlow,1183 *pxmapGlow,
971 gui->getGuiActions("actionShow_Ocular"));1184 actionShowOcular);
972 gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGroup");1185 gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGroup");
973 } catch (std::runtime_error& e) {1186 } catch (std::runtime_error& e) {
974 qWarning() << "WARNING: unable create toolbar button for Oculars plugin: " << e.what();1187 qWarning() << "WARNING: unable create toolbar button for Oculars plugin: " << e.what();
975 }1188 }
976 connect(gui->getGuiActions("actionShow_Ocular"), SIGNAL(toggled(bool)), this, SLOT(enableOcular(bool)));1189 connect(actionShowOcular, SIGNAL(toggled(bool)),
9771190 this, SLOT(enableOcular(bool)));
978 gui->addGuiActions("actionShow_Ocular_Menu",1191
979 N_("Oculars popup menu"),1192 shortcutStr = settings->value("bindings/popup_navigator", "Alt+O").toString();
980 settings->value("bindings/popup_navigator", "Alt+O").toString(),1193 actionMenu = gui->addGuiActions("actionShow_Ocular_Menu",
981 group,1194 N_("Oculars popup menu"),
982 true);1195 shortcutStr,
983 connect(gui->getGuiActions("actionShow_Ocular_Menu"), SIGNAL(toggled(bool)), this, SLOT(displayPopupMenu()));1196 group,
1197 true);
1198 connect(actionMenu, SIGNAL(toggled(bool)),
1199 this, SLOT(displayPopupMenu()));
1200
1201 actionShowCrosshairs = gui->addGuiActions("actionShow_Ocular_Crosshairs",
1202 N_("Crosshairs"),
1203 QString(),
1204 group,
1205 true);
1206 connect(actionShowCrosshairs, SIGNAL(toggled(bool)),
1207 this, SLOT(toggleCrosshairs(bool)));
1208
1209 actionShowSensor = gui->addGuiActions("actionShow_Sensor",
1210 N_("Sensor"),
1211 QString(),
1212 group,
1213 true);
1214 connect(actionShowSensor, SIGNAL(toggled(bool)),
1215 this, SLOT(toggleCCD(bool)));
1216
1217 actionShowTelrad = gui->addGuiActions("actionShow_Telrad",
1218 N_("Telrad"),
1219 QString(),
1220 group,
1221 true);
1222 connect(actionShowTelrad, SIGNAL(toggled(bool)),
1223 this, SLOT(toggleTelrad(bool)));
1224
1225 actionConfiguration = gui->addGuiActions("actionOpen_Oculars_Configuration",
1226 N_("Oculars plugin configuration"),
1227 QString(),
1228 group,
1229 true);
1230 connect(actionConfiguration, SIGNAL(toggled(bool)),
1231 ocularDialog, SLOT(setVisible(bool)));
1232 connect(ocularDialog, SIGNAL(visibleChanged(bool)),
1233 actionConfiguration, SLOT(setChecked(bool)));
9841234
985 connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentChanged()));1235 connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(instrumentChanged()));
986 connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(setScreenFOVForCCD()));1236 connect(this, SIGNAL(selectedCCDChanged()), this, SLOT(setScreenFOVForCCD()));
@@ -1354,7 +1604,13 @@
1354 Ocular *ocular = oculars[selectedOcularIndex];1604 Ocular *ocular = oculars[selectedOcularIndex];
1355 Telescope *telescope = NULL;1605 Telescope *telescope = NULL;
1356 // Only consider flip is we're not binoculars1606 // Only consider flip is we're not binoculars
1357 if (!ocular->isBinoculars()) {1607 if (ocular->isBinoculars())
1608 {
1609 core->setFlipHorz(false);
1610 core->setFlipVert(false);
1611 }
1612 else
1613 {
1358 telescope = telescopes[selectedTelescopeIndex];1614 telescope = telescopes[selectedTelescopeIndex];
1359 core->setFlipHorz(telescope->isHFlipped());1615 core->setFlipHorz(telescope->isHFlipped());
1360 core->setFlipVert(telescope->isVFlipped());1616 core->setFlipVert(telescope->isVFlipped());
@@ -1368,3 +1624,44 @@
1368 movementManager->zoomTo(actualFOV, 0.0);1624 movementManager->zoomTo(actualFOV, 0.0);
1369}1625}
13701626
1627void Oculars::hideUsageMessageIfDisplayed()
1628{
1629 if (usageMessageLabelID > -1)
1630 {
1631 LabelMgr *labelManager = GETSTELMODULE(LabelMgr);
1632 labelManager->setLabelShow(usageMessageLabelID, false);
1633 labelManager->deleteLabel(usageMessageLabelID);
1634 usageMessageLabelID = -1;
1635 }
1636}
1637
1638QMenu* Oculars::addTelescopeSubmenu(QMenu *parent)
1639{
1640 Q_ASSERT(parent);
1641
1642 QMenu* submenu = new QMenu("&Telescope", parent);
1643 submenu->addAction("&Previous telescope", this, SLOT(decrementTelescopeIndex()));
1644 submenu->addAction("&Next telescope", this, SLOT(incrementTelescopeIndex()));
1645 submenu->addSeparator();
1646 for (int index = 0; index < telescopes.count(); ++index)
1647 {
1648 QString label;
1649 if (index < 10)
1650 {
1651 label = QString("&%1: %2").arg(index).arg(telescopes[index]->name());
1652 }
1653 else
1654 {
1655 label = telescopes[index]->name();
1656 }
1657 QAction* action = submenu->addAction(label, telescopesSignalMapper, SLOT(map()));
1658 if (index == selectedTelescopeIndex)
1659 {
1660 action->setCheckable(true);
1661 action->setChecked(true);
1662 }
1663 telescopesSignalMapper->setMapping(action, QString("%1").arg(index));
1664 }
1665
1666 return submenu;
1667}
13711668
=== modified file 'plugins/Oculars/src/Oculars.hpp'
--- plugins/Oculars/src/Oculars.hpp 2011-03-24 16:25:59 +0000
+++ plugins/Oculars/src/Oculars.hpp 2011-11-24 21:50:30 +0000
@@ -1,5 +1,6 @@
1/*1/*
2 * Copyright (C) 2009 Timothy Reaves2 * Copyright (C) 2009 Timothy Reaves
3 * Copyright (C) 2011 Bogdan Marinov
3 *4 *
4 * This program is free software; you can redistribute it and/or5 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License6 * modify it under the terms of the GNU General Public License
@@ -32,7 +33,9 @@
32#define MIN_OCULARS_INI_VERSION 0.1233#define MIN_OCULARS_INI_VERSION 0.12
3334
34QT_BEGIN_NAMESPACE35QT_BEGIN_NAMESPACE
36class QAction;
35class QKeyEvent;37class QKeyEvent;
38class QMenu;
36class QMouseEvent;39class QMouseEvent;
37class QPixmap;40class QPixmap;
38class QSettings;41class QSettings;
@@ -41,10 +44,13 @@
4144
42class StelButton;45class StelButton;
4346
44//! This is an example of a plug-in which can be dynamically loaded into stellarium47//! Main class of the Oculars plug-in.
45class Oculars : public StelModule48class Oculars : public StelModule
46{49{
47 Q_OBJECT50 Q_OBJECT
51 //BM: Temporary, until the GUI is finalized and some other method of getting
52 //info from the main class is implemented.
53 friend class OcularsGuiPanel;
4854
49public:55public:
50 Oculars();56 Oculars();
@@ -69,6 +75,10 @@
69 virtual void update(double) {;}75 virtual void update(double) {;}
7076
71public slots:77public slots:
78 //! Update the ocular, telescope and sensor lists after the removal of a member.
79 //! Necessary because of the way model/view management in the OcularDialog
80 //! is implemented.
81 void updateLists();
72 void ccdRotationReset();82 void ccdRotationReset();
73 void decrementCCDIndex();83 void decrementCCDIndex();
74 void decrementOcularIndex();84 void decrementOcularIndex();
@@ -80,13 +90,20 @@
80 void incrementCCDIndex();90 void incrementCCDIndex();
81 void incrementOcularIndex();91 void incrementOcularIndex();
82 void incrementTelescopeIndex();92 void incrementTelescopeIndex();
83 void rotateCCD(QString amount); //<! amount must be a number.93 void rotateCCD(QString amount); //!< amount must be a number.
84 void selectCCDAtIndex(QString indexString); //<! indexString must be an integer, in the range of -1:ccds.count()94 void selectCCDAtIndex(QString indexString); //!< indexString must be an integer, in the range of -1:ccds.count()
85 void selectOcularAtIndex(QString indexString); //<! indexString must be an integer, in the range of -1:oculars.count()95 void selectOcularAtIndex(QString indexString); //!< indexString must be an integer, in the range of -1:oculars.count()
86 void selectTelescopeAtIndex(QString indexString); //<! indexString must be an integer, in the range of -1:telescopes.count()96 void selectTelescopeAtIndex(QString indexString); //!< indexString must be an integer, in the range of -1:telescopes.count()
97 //! Toggles the sensor frame overlay.
98 void toggleCCD(bool show);
99 //! Toggles the sensor frame overlay (overloaded for blind switching).
87 void toggleCCD();100 void toggleCCD();
88 void toggleCrosshair();101 void toggleCrosshairs(bool show = true);
102 //! Toggles the Telrad sight overlay.
103 void toggleTelrad(bool show);
104 //! Toggles the Telrad sight overlay (overloaded for blind switching).
89 void toggleTelrad();105 void toggleTelrad();
106 void enableGuiPanel(bool enable = true);
90107
91signals:108signals:
92 void selectedCCDChanged();109 void selectedCCDChanged();
@@ -142,13 +159,18 @@
142 //! This method is called by the zoom() method, when this plugin is toggled on; it resets the zoomed view.159 //! This method is called by the zoom() method, when this plugin is toggled on; it resets the zoomed view.
143 void zoomOcular();160 void zoomOcular();
144161
162 void hideUsageMessageIfDisplayed();
163
164 //! Creates the sub-menu listing telescopes in the pop-up menu.
165 QMenu* addTelescopeSubmenu(QMenu* parent);
166
145 //! A list of all the oculars defined in the ini file. Must have at least one, or module will not run.167 //! A list of all the oculars defined in the ini file. Must have at least one, or module will not run.
146 QList<CCD *> ccds;168 QList<CCD *> ccds;
147 QList<Ocular *> oculars;169 QList<Ocular *> oculars;
148 QList<Telescope *> telescopes;170 QList<Telescope *> telescopes;
149 int selectedCCDIndex; //<! index of the current CCD, in the range of -1:ccds.count(). -1 means no CCD is selected.171 int selectedCCDIndex; //!< index of the current CCD, in the range of -1:ccds.count(). -1 means no CCD is selected.
150 int selectedOcularIndex; //<! index of the current ocular, in the range of -1:oculars.count(). -1 means no ocular is selected.172 int selectedOcularIndex; //!< index of the current ocular, in the range of -1:oculars.count(). -1 means no ocular is selected.
151 int selectedTelescopeIndex; //<! index of the current telescope, in the range of -1:telescopes.count(). -1 means none is selected.173 int selectedTelescopeIndex; //!< index of the current telescope, in the range of -1:telescopes.count(). -1 means none is selected.
152174
153 QFont font; //!< The font used for drawing labels.175 QFont font; //!< The font used for drawing labels.
154 bool flagShowCCD; //!< flag used to track f we are in CCD mode.176 bool flagShowCCD; //!< flag used to track f we are in CCD mode.
@@ -164,15 +186,17 @@
164 bool flagEclipticLine; //!< Flag to track if EclipticLine was displayed at activation.186 bool flagEclipticLine; //!< Flag to track if EclipticLine was displayed at activation.
165 bool flagMeridianLine; //!< Flag to track if MeridianLine was displayed at activation.187 bool flagMeridianLine; //!< Flag to track if MeridianLine was displayed at activation.
166188
167 double ccdRotationAngle; //<! The angle to rotate the CCD bounding box. */189 double ccdRotationAngle; //!< The angle to rotate the CCD bounding box. */
168 double maxEyepieceAngle; //!< The maximum aFOV of any eyepiece.190 double maxEyepieceAngle; //!< The maximum aFOV of any eyepiece.
169 bool requireSelection; //!< Read from the ini file, whether an object is required to be selected to zoom in.191 bool requireSelection; //!< Read from the ini file, whether an object is required to be selected to zoom in.
170 bool useMaxEyepieceAngle; //!< Read from the ini file, whether to scale the mask based aFOV.192 bool useMaxEyepieceAngle; //!< Read from the ini file, whether to scale the mask based aFOV.
193 //! Display the GUI control panel
194 bool guiPanelEnabled;
171195
172 QSignalMapper* ccdRotationSignalMapper; //<! Used to rotate the CCD. */196 QSignalMapper* ccdRotationSignalMapper; //!< Used to rotate the CCD. */
173 QSignalMapper* ccdsSignalMapper; //<! Used to determine which CCD was selected from the popup navigator. */197 QSignalMapper* ccdsSignalMapper; //!< Used to determine which CCD was selected from the popup navigator. */
174 QSignalMapper* ocularsSignalMapper; //<! Used to determine which ocular was selected from the popup navigator. */198 QSignalMapper* ocularsSignalMapper; //!< Used to determine which ocular was selected from the popup navigator. */
175 QSignalMapper* telescopesSignalMapper; //<! Used to determine which telescope was selected from the popup navigator. */199 QSignalMapper* telescopesSignalMapper; //!< Used to determine which telescope was selected from the popup navigator. */
176200
177 // for toolbar button201 // for toolbar button
178 QPixmap* pxmapGlow;202 QPixmap* pxmapGlow;
@@ -183,6 +207,15 @@
183 OcularDialog *ocularDialog;207 OcularDialog *ocularDialog;
184 bool ready; //!< A flag that determines that this module is usable. If false, we won't open.208 bool ready; //!< A flag that determines that this module is usable. If false, we won't open.
185209
210 QAction* actionShowOcular;
211 QAction* actionShowCrosshairs;
212 QAction* actionShowSensor;
213 QAction* actionShowTelrad;
214 QAction* actionConfiguration;
215 QAction* actionMenu;
216
217 class OcularsGuiPanel* guiPanel;
218
186 //Styles219 //Styles
187 QByteArray normalStyleSheet;220 QByteArray normalStyleSheet;
188 QByteArray nightStyleSheet;221 QByteArray nightStyleSheet;
189222
=== modified file 'plugins/Oculars/src/gui/OcularDialog.cpp'
--- plugins/Oculars/src/gui/OcularDialog.cpp 2011-11-12 22:55:30 +0000
+++ plugins/Oculars/src/gui/OcularDialog.cpp 2011-11-24 21:50:30 +0000
@@ -1,5 +1,6 @@
1/*1/*
2 * Copyright (C) 2009 Timothy Reaves2 * Copyright (C) 2009 Timothy Reaves
3 * Copyright (C) 2011 Bogdan Marinov
3 *4 *
4 * This program is free software; you can redistribute it and/or5 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License6 * modify it under the terms of the GNU General Public License
@@ -37,10 +38,8 @@
37#include <QStandardItemModel>38#include <QStandardItemModel>
38#include <limits>39#include <limits>
3940
40OcularDialog::OcularDialog(QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes) :41OcularDialog::OcularDialog(Oculars* pluginPtr, QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes) :
41 ccdMapper(0),42 plugin(pluginPtr)
42 ocularMapper(0),
43 telescopeMapper(0)
44{43{
45 ui = new Ui_ocularDialogForm;44 ui = new Ui_ocularDialogForm;
46 this->ccds = ccds;45 this->ccds = ccds;
@@ -116,7 +115,7 @@
116 if(dialog) {115 if(dialog) {
117 StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());116 StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
118 Q_ASSERT(gui);117 Q_ASSERT(gui);
119 const StelStyle pluginStyle = GETSTELMODULE(Oculars)->getModuleStyleSheet(gui->getStelStyle());118 const StelStyle pluginStyle = plugin->getModuleStyleSheet(gui->getStelStyle());
120 dialog->setStyleSheet(pluginStyle.qtStyleSheet);119 dialog->setStyleSheet(pluginStyle.qtStyleSheet);
121 ui->textBrowser->document()->setDefaultStyleSheet(QString(pluginStyle.htmlStyleSheet));120 ui->textBrowser->document()->setDefaultStyleSheet(QString(pluginStyle.htmlStyleSheet));
122 }121 }
@@ -138,6 +137,7 @@
138{137{
139 ccdTableModel->removeRows(ui->ccdListView->currentIndex().row(), 1);138 ccdTableModel->removeRows(ui->ccdListView->currentIndex().row(), 1);
140 ui->ccdListView->setCurrentIndex(ccdTableModel->index(0, 1));139 ui->ccdListView->setCurrentIndex(ccdTableModel->index(0, 1));
140 plugin->updateLists();
141}141}
142142
143void OcularDialog::deleteSelectedOcular()143void OcularDialog::deleteSelectedOcular()
@@ -147,6 +147,7 @@
147 } else {147 } else {
148 ocularTableModel->removeRows(ui->ocularListView->currentIndex().row(), 1);148 ocularTableModel->removeRows(ui->ocularListView->currentIndex().row(), 1);
149 ui->ocularListView->setCurrentIndex(ocularTableModel->index(0, 1));149 ui->ocularListView->setCurrentIndex(ocularTableModel->index(0, 1));
150 plugin->updateLists();
150 }151 }
151}152}
152153
@@ -157,6 +158,7 @@
157 } else {158 } else {
158 telescopeTableModel->removeRows(ui->telescopeListView->currentIndex().row(), 1);159 telescopeTableModel->removeRows(ui->telescopeListView->currentIndex().row(), 1);
159 ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(0, 1));160 ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(0, 1));
161 plugin->updateLists();
160 }162 }
161}163}
162164
@@ -178,6 +180,66 @@
178 ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(telescopeTableModel->rowCount() - 1, 1));180 ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(telescopeTableModel->rowCount() - 1, 1));
179}181}
180182
183void OcularDialog::moveUpSelectedSensor()
184{
185 int index = ui->ccdListView->currentIndex().row();
186 if (index > 0)
187 {
188 ccdTableModel->moveRowUp(index);
189 plugin->updateLists();
190 }
191}
192
193void OcularDialog::moveUpSelectedOcular()
194{
195 int index = ui->ocularListView->currentIndex().row();
196 if (index > 0)
197 {
198 ocularTableModel->moveRowUp(index);
199 plugin->updateLists();
200 }
201}
202
203void OcularDialog::moveUpSelectedTelescope()
204{
205 int index = ui->ocularListView->currentIndex().row();
206 if (index > 0)
207 {
208 telescopeTableModel->moveRowUp(index);
209 plugin->updateLists();
210 }
211}
212
213void OcularDialog::moveDownSelectedSensor()
214{
215 int index = ui->ccdListView->currentIndex().row();
216 if (index >= 0 && index < ccdTableModel->rowCount() - 1)
217 {
218 ccdTableModel->moveRowDown(index);
219 plugin->updateLists();
220 }
221}
222
223void OcularDialog::moveDownSelectedOcular()
224{
225 int index = ui->ocularListView->currentIndex().row();
226 if (index >= 0 && index < ocularTableModel->rowCount() - 1)
227 {
228 ocularTableModel->moveRowDown(index);
229 plugin->updateLists();
230 }
231}
232
233void OcularDialog::moveDownSelectedTelescope()
234{
235 int index = ui->telescopeListView->currentIndex().row();
236 if (index >= 0 && index < telescopeTableModel->rowCount() - 1)
237 {
238 telescopeTableModel->moveRowDown(index);
239 plugin->updateLists();
240 }
241}
242
181/* ********************************************************************* */243/* ********************************************************************* */
182#if 0244#if 0
183#pragma mark -245#pragma mark -
@@ -189,7 +251,7 @@
189 Oculars::appSettings()->setValue("bindings/toggle_oculars", newString);251 Oculars::appSettings()->setValue("bindings/toggle_oculars", newString);
190 StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());252 StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
191 Q_ASSERT(gui);253 Q_ASSERT(gui);
192 QAction* action = gui->getGuiActions("toggle_oculars");254 QAction* action = gui->getGuiActions("actionShow_Ocular");
193 if (action != NULL) {255 if (action != NULL) {
194 action->setShortcut(QKeySequence(newString.trimmed()));256 action->setShortcut(QKeySequence(newString.trimmed()));
195 }257 }
@@ -223,7 +285,7 @@
223 bool useMaxImageCircle = Oculars::appSettings()->value("use_max_exit_circle",01.0).toBool();285 bool useMaxImageCircle = Oculars::appSettings()->value("use_max_exit_circle",01.0).toBool();
224 if (shouldScale != useMaxImageCircle) {286 if (shouldScale != useMaxImageCircle) {
225 Oculars::appSettings()->setValue("use_max_exit_circle", shouldScale);287 Oculars::appSettings()->setValue("use_max_exit_circle", shouldScale);
226 Oculars::appSettings()->sync();\288 Oculars::appSettings()->sync();
227 emit(scaleImageCircleChanged(shouldScale));289 emit(scaleImageCircleChanged(shouldScale));
228 }290 }
229}291}
@@ -246,6 +308,9 @@
246 connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));308 connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
247 connect(ui->scaleImageCircleCheckBox, SIGNAL(stateChanged(int)), this, SLOT(scaleImageCircleStateChanged(int)));309 connect(ui->scaleImageCircleCheckBox, SIGNAL(stateChanged(int)), this, SLOT(scaleImageCircleStateChanged(int)));
248 connect(ui->requireSelectionCheckBox, SIGNAL(stateChanged(int)), this, SLOT(requireSelectionStateChanged(int)));310 connect(ui->requireSelectionCheckBox, SIGNAL(stateChanged(int)), this, SLOT(requireSelectionStateChanged(int)));
311 connect(ui->checkBoxControlPanel, SIGNAL(clicked(bool)),
312 plugin, SLOT(enableGuiPanel(bool)));
313
249 // The add & delete buttons314 // The add & delete buttons
250 connect(ui->addCCD, SIGNAL(clicked()), this, SLOT(insertNewCCD()));315 connect(ui->addCCD, SIGNAL(clicked()), this, SLOT(insertNewCCD()));
251 connect(ui->deleteCCD, SIGNAL(clicked()), this, SLOT(deleteSelectedCCD()));316 connect(ui->deleteCCD, SIGNAL(clicked()), this, SLOT(deleteSelectedCCD()));
@@ -275,11 +340,30 @@
275 ui->togglePluginLineEdit->setText(bindingString);340 ui->togglePluginLineEdit->setText(bindingString);
276 bindingString = Oculars::appSettings()->value("bindings/popup_navigator", "Alt+O").toString();341 bindingString = Oculars::appSettings()->value("bindings/popup_navigator", "Alt+O").toString();
277 ui->togglePopupNavigatorWindowLineEdit->setText(bindingString);342 ui->togglePopupNavigatorWindowLineEdit->setText(bindingString);
278 connect(ui->togglePluginLineEdit, SIGNAL(textEdited(const QString&)), 343 connect(ui->togglePluginLineEdit, SIGNAL(textEdited(const QString&)),
279 this, SLOT(keyBindingTogglePluginChanged(const QString&)));344 this, SLOT(keyBindingTogglePluginChanged(const QString&)));
280 connect(ui->togglePopupNavigatorWindowLineEdit, SIGNAL(textEdited(const QString&)), 345 connect(ui->togglePopupNavigatorWindowLineEdit, SIGNAL(textEdited(const QString&)),
281 this, SLOT(keyBindingPopupNavigatorConfigChanged(const QString&)));346 this, SLOT(keyBindingPopupNavigatorConfigChanged(const QString&)));
282 347
348 initAboutText();
349 connect(ui->togglePluginLineEdit, SIGNAL(textEdited(QString)),
350 this, SLOT(initAboutText()));
351 connect(ui->togglePopupNavigatorWindowLineEdit, SIGNAL(textEdited(QString)),
352 this, SLOT(initAboutText()));
353
354 connect(ui->pushButtonMoveOcularUp, SIGNAL(pressed()),
355 this, SLOT(moveUpSelectedOcular()));
356 connect(ui->pushButtonMoveOcularDown, SIGNAL(pressed()),
357 this, SLOT(moveDownSelectedOcular()));
358 connect(ui->pushButtonMoveSensorUp, SIGNAL(pressed()),
359 this, SLOT(moveUpSelectedSensor()));
360 connect(ui->pushButtonMoveSensorDown, SIGNAL(pressed()),
361 this, SLOT(moveDownSelectedSensor()));
362 connect(ui->pushButtonMoveTelescopeUp, SIGNAL(pressed()),
363 this, SLOT(moveUpSelectedTelescope()));
364 connect(ui->pushButtonMoveTelescopeDown, SIGNAL(pressed()),
365 this, SLOT(moveDownSelectedTelescope()));
366
283 // The CCD mapper367 // The CCD mapper
284 ccdMapper = new QDataWidgetMapper();368 ccdMapper = new QDataWidgetMapper();
285 ccdMapper->setModel(ccdTableModel);369 ccdMapper->setModel(ccdTableModel);
@@ -331,7 +415,65 @@
331 if (Oculars::appSettings()->value("use_max_exit_circle", 0.0).toBool()) {415 if (Oculars::appSettings()->value("use_max_exit_circle", 0.0).toBool()) {
332 ui->scaleImageCircleCheckBox->setCheckState(Qt::Checked);416 ui->scaleImageCircleCheckBox->setCheckState(Qt::Checked);
333 }417 }
418 if (Oculars::appSettings()->value("enable_control_panel", false).toBool())
419 {
420 ui->checkBoxControlPanel->setChecked(true);
421 }
334422
335 //Initialize the style423 //Initialize the style
336 updateStyle();424 updateStyle();
337}425}
426
427void OcularDialog::initAboutText()
428{
429 //BM: Most of the text for now is the original contents of the About widget.
430 QString html = "<html><head><title></title></head><body>";
431
432 html += "<h1>Oculars plug-in</h1>";
433
434 //Authors
435 QString authors = "Authors: <a href=\"mailto:treaves@silverfieldstech.com\">Timothy Reaves</a>, Bogdan Marinov";
436 html += "<h3>" + authors + "</h3>";
437
438 //Overview
439 html += "<h2>Overview</h2>";
440
441 html += "<p>This plugin is intended to simulate what you would see through an eyepiece. This configuration dialog can be used to add, modify, or delete eyepieces and telescopes, as well as CCD Sensors. Your first time running the app will populate some samples to get your started.</p>";
442 html += "<p>You can choose to scale the image you see on the screen. This is intended to show you a better comparison of what one eyepiece/telescope combination will be like as compared to another. The same eyepiece in two different telescopes of differing focal length will produce two different exit circles, changing the view someone. The trade-off of this is that, with the image scaled, a good deal of the screen can be wasted. Therefor I recommend that you leave it off, unless you feel you have a need of it.</p>";
443 html += "<p>You can toggle a crosshair in the view. Ideally, I wanted this to be aligned to North. I've been unable to do so. So currently it aligns to the top of the screen.</p>";
444 html += QString("<p>You can toggle a Telrad finder; this can only be done when you have not turned on the Ocular view. This feature draws three concentric circles of 0.5%1, 2.0%1, and 4.0%1, helping you see what you would expect to see with the naked eye through the Telrad (or similar) finder.</p>").arg(QChar(0x00B0));
445 html += "<p>If you find any issues, please let me know. Enjoy!</p>";
446
447 //Keys
448 html += "<h2>Hot Keys</h2>";
449 html += "<p>The plug-in's key bindings can be edited in the General Tab.</p>";
450
451 StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
452 Q_ASSERT(gui);
453 QAction* actionOcular = gui->getGuiActions("actionShow_Ocular");
454 Q_ASSERT(actionOcular);
455 QAction* actionMenu = gui->getGuiActions("actionShow_Ocular_Menu");
456 Q_ASSERT(actionMenu);
457 QKeySequence ocularShortcut = actionOcular->shortcut();
458 QString ocularString = ocularShortcut.toString(QKeySequence::NativeText);
459 ocularString = Qt::escape(ocularString);
460 if (ocularString.isEmpty())
461 ocularString = "[no key defined]";
462 QKeySequence menuShortcut = actionMenu->shortcut();
463 QString menuString = menuShortcut.toString(QKeySequence::NativeText);
464 menuString = Qt::escape(menuString);
465 if (menuString.isEmpty())
466 menuString = "[no key defined]";
467
468 html += "<ul>";
469 html += "<li>";
470 html += QString("<strong>%1:</strong> Switches on/off the ocular overlay.").arg(ocularString);
471 html += "</li>";
472
473 html += "<li>";
474 html += QString("<strong>%1:</strong> Opens the pop-up navigation menu.").arg(menuString);
475 html += "</li>";
476 html += "</ul>";
477 html += "</body></html>";
478 ui->textBrowser->setHtml(html);
479}
338480
=== modified file 'plugins/Oculars/src/gui/OcularDialog.hpp'
--- plugins/Oculars/src/gui/OcularDialog.hpp 2011-03-24 16:25:59 +0000
+++ plugins/Oculars/src/gui/OcularDialog.hpp 2011-11-24 21:50:30 +0000
@@ -1,5 +1,6 @@
1/*1/*
2 * Copyright (C) 2009 Timothy Reaves2 * Copyright (C) 2009 Timothy Reaves
3 * Copyright (C) 2011 Bogdan Marinov
3 *4 *
4 * This program is free software; you can redistribute it and/or5 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License6 * modify it under the terms of the GNU General Public License
@@ -38,17 +39,17 @@
38class QStandardItemModel;39class QStandardItemModel;
39QT_END_NAMESPACE40QT_END_NAMESPACE
4041
42class Oculars;
4143
42class OcularDialog : public StelDialog44class OcularDialog : public StelDialog
43{45{
44 Q_OBJECT46 Q_OBJECT
4547
46public:48public:
47 OcularDialog(QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes);49 OcularDialog(Oculars* plugin, QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes);
48 virtual ~OcularDialog();50 virtual ~OcularDialog();
49 //! Notify that the application style changed51 //! Notify that the application style changed
50 void styleChanged();52 void styleChanged();
51 void setOculars(QList<Ocular*> theOculars);
52 void updateStyle();53 void updateStyle();
5354
54public slots:55public slots:
@@ -59,6 +60,12 @@
59 void insertNewCCD();60 void insertNewCCD();
60 void insertNewOcular();61 void insertNewOcular();
61 void insertNewTelescope();62 void insertNewTelescope();
63 void moveUpSelectedSensor();
64 void moveUpSelectedOcular();
65 void moveUpSelectedTelescope();
66 void moveDownSelectedSensor();
67 void moveDownSelectedOcular();
68 void moveDownSelectedTelescope();
62 void languageChanged();69 void languageChanged();
6370
64signals:71signals:
@@ -73,10 +80,13 @@
73private slots:80private slots:
74 void keyBindingTogglePluginChanged(const QString& newString);81 void keyBindingTogglePluginChanged(const QString& newString);
75 void keyBindingPopupNavigatorConfigChanged(const QString& newString);82 void keyBindingPopupNavigatorConfigChanged(const QString& newString);
83 void initAboutText();
76 void requireSelectionStateChanged(int state);84 void requireSelectionStateChanged(int state);
77 void scaleImageCircleStateChanged(int state);85 void scaleImageCircleStateChanged(int state);
7886
79private:87private:
88 Oculars* plugin;
89
80 QDataWidgetMapper* ccdMapper;90 QDataWidgetMapper* ccdMapper;
81 QList<CCD *>* ccds;91 QList<CCD *>* ccds;
82 PropertyBasedTableModel* ccdTableModel;92 PropertyBasedTableModel* ccdTableModel;
8393
=== added file 'plugins/Oculars/src/gui/OcularsGuiPanel.cpp'
--- plugins/Oculars/src/gui/OcularsGuiPanel.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Oculars/src/gui/OcularsGuiPanel.cpp 2011-11-24 21:50:30 +0000
@@ -0,0 +1,954 @@
1/*
2Oculars plug-in for Stellarium: graphical user interface widget
3Copyright (C) 2011 Bogdan Marinov
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20#include "Oculars.hpp"
21#include "OcularsGuiPanel.hpp"
22#include "StelApp.hpp"
23#include "StelGui.hpp"
24#include "StelGuiItems.hpp"
25
26#include <QAction>
27#include <QGridLayout>
28#include <QGraphicsLinearLayout>
29#include <QGraphicsPathItem>
30#include <QGraphicsProxyWidget>
31#include <QLabel>
32#include <QPainter>
33#include <QPen>
34#include <QPushButton>
35#include <QSignalMapper>
36#include <QWidget>
37
38OcularsGuiPanel::OcularsGuiPanel(Oculars* plugin,
39 QGraphicsWidget *parent,
40 Qt::WindowFlags wFlags):
41 QGraphicsWidget(parent, wFlags),
42 ocularsPlugin(plugin),
43 parentWidget(parent),
44 borderPath(0)
45{
46 //setVisible(false);
47 //setMinimumSize(0, 0);
48 setMaximumSize(300, 400);
49 //setPreferredSize(230, 100);
50 setContentsMargins(0, 0, 0, 0);
51 //TODO: set font?
52
53 //First create the layout and populate it, then set it?
54 mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
55 //layout->setContentsMargins(0, 0, 0, 0);
56 //layout->setSpacing(0);
57
58 //Button bar
59 buttonBar = new QGraphicsWidget();
60 mainLayout->addItem(buttonBar);
61
62 //QPixmap leftBackground(":/graphicGui/btbg-left.png");
63 //QPixmap middleBackground(":/graphicGui/btbg-middle.png");
64 //QPixmap rightBackground(":/graphicGui/btbg-right.png");
65
66 StelApp& stelApp = StelApp::getInstance();
67 buttonOcular = new StelButton(buttonBar,
68 QPixmap(":/ocular/bt_ocular_on.png"),
69 QPixmap(":/ocular/bt_ocular_off.png"),
70 QPixmap(),
71 ocularsPlugin->actionShowOcular,
72 true); //No background
73 buttonOcular->setToolTip("Ocular");
74 //buttonOcular->setBackgroundPixmap(leftBackground);
75 buttonOcular->setParentItem(buttonBar);
76
77 //Hack to avoid buttonOcular being left "checked" if it has been toggled
78 //without any object selected.
79 disconnect(ocularsPlugin->actionShowOcular, SIGNAL(toggled(bool)),
80 ocularsPlugin, SLOT(enableOcular(bool)));
81 connect(ocularsPlugin->actionShowOcular, SIGNAL(toggled(bool)),
82 ocularsPlugin, SLOT(enableOcular(bool)));
83
84 buttonCrosshairs = new StelButton(buttonBar,
85 QPixmap(":/ocular/bt_crosshairs_on.png"),
86 QPixmap(":/ocular/bt_crosshairs_off.png"),
87 QPixmap(),
88 ocularsPlugin->actionShowCrosshairs,
89 true);
90 buttonCrosshairs->setToolTip("Crosshairs");
91 buttonCrosshairs->setVisible(false);
92
93 buttonCcd = new StelButton(buttonBar,
94 QPixmap(":/ocular/bt_sensor_on.png"),
95 QPixmap(":/ocular/bt_sensor_off.png"),
96 QPixmap(),
97 ocularsPlugin->actionShowSensor,
98 true);
99 buttonCcd->setToolTip("Sensor");
100
101 buttonTelrad = new StelButton(buttonBar,
102 QPixmap(":/ocular/bt_telrad_on.png"),
103 QPixmap(":/ocular/bt_telrad_off.png"),
104 QPixmap(),
105 ocularsPlugin->actionShowTelrad,
106 true);
107 buttonTelrad->setToolTip("Telrad circles");
108
109 buttonConfiguration = new StelButton(buttonBar,
110 QPixmap(":/ocular/bt_settings_on.png"),
111 QPixmap(":/ocular/bt_settings_off.png"),
112 QPixmap(),
113 ocularsPlugin->actionConfiguration,
114 true);
115 buttonConfiguration->setToolTip("Oculars plugin configuration window");
116
117 qreal buttonHeight = buttonOcular->boundingRect().height();
118 buttonBar->setMinimumHeight(buttonHeight);
119 buttonBar->setMaximumHeight(buttonHeight);
120
121 setLayout(mainLayout);
122
123 //Widgets with control and information fields
124 ocularControls = new QGraphicsWidget(this);
125 ocularControls->setParentItem(this);
126 ocularControls->setVisible(false);
127 ccdControls = new QGraphicsWidget(this);
128 ccdControls->setParentItem(this);
129 ccdControls->setVisible(false);
130 telescopeControls = new QGraphicsWidget(this);
131 telescopeControls->setParentItem(this);
132 telescopeControls->setVisible(false);
133
134 fieldOcularName = new QGraphicsTextItem(ocularControls);
135 fieldOcularFl = new QGraphicsTextItem(ocularControls);
136 fieldOcularAfov = new QGraphicsTextItem(ocularControls);
137 fieldCcdName = new QGraphicsTextItem(ccdControls);
138 fieldCcdDimensions = new QGraphicsTextItem(ccdControls);
139 fieldCcdRotation = new QGraphicsTextItem(ccdControls);
140 fieldTelescopeName = new QGraphicsTextItem(telescopeControls);
141 fieldMagnification = new QGraphicsTextItem(telescopeControls);
142 fieldFov = new QGraphicsTextItem(telescopeControls);
143
144 QFont newFont = font();
145 newFont.setPixelSize(12);
146 setControlsFont(newFont);
147 //setControlsColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
148
149 //Traditional field width from Ocular ;)
150 QFontMetrics fm(fieldOcularName->font());
151 int maxWidth = fm.width(QString("MMMMMMMMMMMMMMMMMMM"));
152 int lineHeight = fm.height();
153
154 fieldOcularName->setTextWidth(maxWidth);
155 fieldOcularFl->setTextWidth(maxWidth);
156 fieldOcularAfov->setTextWidth(maxWidth);
157 fieldCcdName->setTextWidth(maxWidth);
158 fieldCcdDimensions->setTextWidth(maxWidth);
159 fieldCcdRotation->setTextWidth(maxWidth);
160 fieldTelescopeName->setTextWidth(maxWidth);
161 fieldMagnification->setTextWidth(maxWidth);
162 fieldFov->setTextWidth(maxWidth);
163
164 QPixmap pa(":/graphicGui/btTimeRewind-on.png");
165 QPixmap prevArrow = pa.scaledToHeight(lineHeight, Qt::SmoothTransformation);
166 QPixmap paOff(":/graphicGui/btTimeRewind-off.png");
167 QPixmap prevArrowOff = paOff.scaledToHeight(lineHeight, Qt::SmoothTransformation);
168 QPixmap na(":/graphicGui/btTimeForward-on.png");
169 QPixmap nextArrow = na.scaledToHeight(lineHeight, Qt::SmoothTransformation);
170 QPixmap naOff(":/graphicGui/btTimeForward-off.png");
171 QPixmap nextArrowOff = naOff.scaledToHeight(lineHeight, Qt::SmoothTransformation);
172
173 QAction* defaultAction = new QAction(this);
174 defaultAction->setCheckable(false);
175 prevOcularButton = new StelButton(ocularControls,
176 prevArrow,
177 prevArrowOff,
178 QPixmap(),
179 defaultAction);
180 prevOcularButton->setToolTip("Previous ocular");
181 nextOcularButton = new StelButton(ocularControls,
182 nextArrow,
183 nextArrowOff,
184 QPixmap(),
185 defaultAction);
186 nextOcularButton->setToolTip("Next ocular");
187 prevCcdButton = new StelButton(ccdControls,
188 prevArrow,
189 prevArrowOff,
190 QPixmap(),
191 defaultAction);
192 prevCcdButton->setToolTip("Previous CCD frame");
193 nextCcdButton = new StelButton(ccdControls,
194 nextArrow,
195 nextArrowOff,
196 QPixmap(),
197 defaultAction);
198 nextCcdButton->setToolTip("Next CCD frame");
199 prevTelescopeButton = new StelButton(telescopeControls,
200 prevArrow,
201 prevArrowOff,
202 QPixmap(),
203 defaultAction);
204 prevTelescopeButton->setToolTip("Previous telescope");
205 nextTelescopeButton = new StelButton(telescopeControls,
206 nextArrow,
207 nextArrowOff,
208 QPixmap(),
209 defaultAction);
210 nextTelescopeButton->setToolTip("Next telescope");
211
212 connect(nextOcularButton, SIGNAL(triggered()),
213 ocularsPlugin, SLOT(incrementOcularIndex()));
214 connect(nextCcdButton, SIGNAL(triggered()),
215 ocularsPlugin, SLOT(incrementCCDIndex()));
216 connect(nextTelescopeButton, SIGNAL(triggered()),
217 ocularsPlugin, SLOT(incrementTelescopeIndex()));
218 connect(prevOcularButton, SIGNAL(triggered()),
219 ocularsPlugin, SLOT(decrementOcularIndex()));
220 connect(prevCcdButton, SIGNAL(triggered()),
221 ocularsPlugin, SLOT(decrementCCDIndex()));
222 connect(prevTelescopeButton, SIGNAL(triggered()),
223 ocularsPlugin, SLOT(decrementTelescopeIndex()));
224
225 QColor cOn(255, 255, 255);
226 QColor cOff(102, 102, 102);
227 QColor cHover(162, 162, 162);
228 QString degrees = QString("-15%1").arg(QChar(0x00B0));
229 int degreesW = fm.width(degrees);
230 QPixmap pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
231 QPixmap pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
232 QPixmap pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
233 rotateCcdMinus15Button = new StelButton(ccdControls,
234 pOn,
235 pOff,
236 pHover,
237 defaultAction,
238 true);
239 rotateCcdMinus15Button->setToolTip("Rotate the sensor frame 15 degrees counterclockwise");
240
241 degrees = QString("-5%1").arg(QChar(0x00B0));
242 degreesW = fm.width(degrees);
243 pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
244 pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
245 pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
246 rotateCcdMinus5Button = new StelButton(ccdControls,
247 pOn,
248 pOff,
249 pHover,
250 defaultAction,
251 true);
252 rotateCcdMinus5Button->setToolTip("Rotate the sensor frame 5 degrees counterclockwise");
253
254 degrees = QString("-1%1").arg(QChar(0x00B0));
255 degreesW = fm.width(degrees);
256 pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
257 pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
258 pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
259 rotateCcdMinus1Button = new StelButton(ccdControls,
260 pOn,
261 pOff,
262 pHover,
263 defaultAction,
264 true);
265 rotateCcdMinus1Button->setToolTip("Rotate the sensor frame 1 degree counterclockwise");
266
267 degrees = QString("0%1").arg(QChar(0x00B0));
268 degreesW = fm.width(degrees);
269 pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
270 pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
271 pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
272 resetCcdRotationButton = new StelButton(ccdControls,
273 pOn,
274 pOff,
275 pHover,
276 defaultAction,
277 true);
278 resetCcdRotationButton->setToolTip("Reset the sensor frame rotation");
279
280 degrees = QString("+1%1").arg(QChar(0x00B0));
281 degreesW = fm.width(degrees);
282 pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
283 pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
284 pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
285 rotateCcdPlus1Button = new StelButton(ccdControls,
286 pOn,
287 pOff,
288 pHover,
289 defaultAction,
290 true);
291 rotateCcdPlus1Button->setToolTip("Rotate the sensor frame 1 degree clockwise");
292
293 degrees = QString("+5%1").arg(QChar(0x00B0));
294 degreesW = fm.width(degrees);
295 pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
296 pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
297 pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
298 rotateCcdPlus5Button = new StelButton(ccdControls,
299 pOn,
300 pOff,
301 pHover,
302 defaultAction,
303 true);
304 rotateCcdPlus5Button->setToolTip("Rotate the sensor frame 5 degrees clockwise");
305
306 degrees = QString("+15%1").arg(QChar(0x00B0));
307 degreesW = fm.width(degrees);
308 pOn = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOn);
309 pOff = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cOff);
310 pHover = createPixmapFromText(degrees, degreesW, lineHeight, newFont, cHover);
311 rotateCcdPlus15Button = new StelButton(ccdControls,
312 pOn,
313 pOff,
314 pHover,
315 defaultAction,
316 true);
317 rotateCcdPlus15Button->setToolTip("Rotate the sensor frame 15 degrees clockwise");
318
319 QSignalMapper* sm = ocularsPlugin->ccdRotationSignalMapper;
320 sm->setMapping(rotateCcdMinus15Button, QString("-15"));
321 sm->setMapping(rotateCcdMinus5Button, QString("-5"));
322 sm->setMapping(rotateCcdMinus1Button, QString("-1"));
323 sm->setMapping(rotateCcdPlus1Button, QString("1"));
324 sm->setMapping(rotateCcdPlus5Button, QString("5"));
325 sm->setMapping(rotateCcdPlus15Button, QString("15"));
326
327 connect(rotateCcdMinus15Button, SIGNAL(triggered()),
328 sm, SLOT(map()));
329 connect(rotateCcdMinus5Button, SIGNAL(triggered()),
330 sm, SLOT(map()));
331 connect(rotateCcdMinus1Button, SIGNAL(triggered()),
332 sm, SLOT(map()));
333 connect(rotateCcdPlus1Button, SIGNAL(triggered()),
334 sm, SLOT(map()));
335 connect(rotateCcdPlus5Button, SIGNAL(triggered()),
336 sm, SLOT(map()));
337 connect(rotateCcdPlus15Button, SIGNAL(triggered()),
338 sm, SLOT(map()));
339 connect(resetCcdRotationButton, SIGNAL(triggered()),
340 ocularsPlugin, SLOT(ccdRotationReset()));
341
342 connect(rotateCcdMinus15Button, SIGNAL(triggered()),
343 this, SLOT(updateCcdControls()));
344 connect(rotateCcdMinus5Button, SIGNAL(triggered()),
345 this, SLOT(updateCcdControls()));
346 connect(rotateCcdMinus1Button, SIGNAL(triggered()),
347 this, SLOT(updateCcdControls()));
348 connect(rotateCcdPlus1Button, SIGNAL(triggered()),
349 this, SLOT(updateCcdControls()));
350 connect(rotateCcdPlus5Button, SIGNAL(triggered()),
351 this, SLOT(updateCcdControls()));
352 connect(rotateCcdPlus15Button, SIGNAL(triggered()),
353 this, SLOT(updateCcdControls()));
354 connect(resetCcdRotationButton, SIGNAL(triggered()),
355 this, SLOT(updateCcdControls()));
356
357
358 //Set the layout and update the size
359 qreal width = 2*prevOcularButton->boundingRect().width() + maxWidth;
360 qreal left, right, top, bottom;
361 mainLayout->getContentsMargins(&left, &top, &right, &bottom);
362 ocularControls->setMaximumWidth(width);
363 ccdControls->setMaximumWidth(width);
364 telescopeControls->setMaximumWidth(width);
365 resize(width + left + right, 10);
366 buttonBar->resize(width, size().height());
367 updateMainButtonsPositions();
368
369
370 //Border/background for the widget
371 borderPath = new QGraphicsPathItem();
372 borderPath->setZValue(100);
373 QBrush borderBrush(QColor::fromRgbF(0.22, 0.22, 0.23, 0.2));
374 borderPath->setBrush(borderBrush);
375 QPen borderPen = QPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
376 borderPen.setWidthF(1.);
377 borderPath->setPen(borderPen);
378 borderPath->setParentItem(parentWidget);
379
380 updatePosition();
381 connect (parentWidget, SIGNAL(geometryChanged()),
382 this, SLOT(updatePosition()));
383
384 //Connecting other slots
385 connect(ocularsPlugin, SIGNAL(selectedOcularChanged()),
386 this, SLOT(updateOcularControls()));
387 connect(ocularsPlugin, SIGNAL(selectedCCDChanged()),
388 this, SLOT(updateCcdControls()));
389 connect(ocularsPlugin, SIGNAL(selectedTelescopeChanged()),
390 this, SLOT(updateTelescopeControls()));
391
392 //Night mode
393 connect(&stelApp, SIGNAL(colorSchemeChanged(const QString&)),
394 this, SLOT(setColorScheme(const QString&)));
395 setColorScheme(stelApp.getCurrentStelStyle());
396}
397
398OcularsGuiPanel::~OcularsGuiPanel()
399{
400 if (borderPath)
401 delete borderPath;
402}
403
404void OcularsGuiPanel::showOcularGui()
405{
406 setPreferredHeight(0);//WTF?
407 if (ocularsPlugin->flagShowOculars)
408 {
409 updateOcularControls();
410 }
411 else
412 {
413 setOcularControlsVisible(false);
414 setTelescopeControlsVisible(false);
415 updatePosition();
416 }
417}
418
419void OcularsGuiPanel::showCcdGui()
420{
421 updateCcdControls();
422}
423
424void OcularsGuiPanel::foldGui()
425{
426 //qDebug() << "hidePanel()";
427 setOcularControlsVisible(false);
428 setCcdControlsVisible(false);
429 setTelescopeControlsVisible(false);
430 updatePosition();
431}
432
433void OcularsGuiPanel::updatePosition()
434{
435 updateGeometry();
436 /*qDebug() << "Widget:" << size()
437 << "Buttonbar:" << buttonBar->size()
438 << "Ocular" << ocularControls->size()
439 << "CCD" << ccdControls->size()
440 << "Telescope" << telescopeControls->size()
441 << "Layout" << mainLayout->geometry();*/
442 qreal xPos = parentWidget->size().width() - size().width();
443 qreal yPos = 0;
444 setPos(xPos, yPos);
445
446 //Update border/shading
447 QPainterPath newBorderPath;
448 double cornerRadius = 12.0;
449 QPointF verticalBorderStart = geometry().topLeft();
450 QPointF horizontalBorderEnd = geometry().bottomRight();
451 QPointF cornerArcStart(verticalBorderStart.x(),
452 horizontalBorderEnd.y() - cornerRadius);
453 newBorderPath.moveTo(verticalBorderStart);
454 newBorderPath.lineTo(cornerArcStart);
455 newBorderPath.arcTo(cornerArcStart.x(), cornerArcStart.y(), cornerRadius, cornerRadius, 180, 90);
456 newBorderPath.lineTo(horizontalBorderEnd);
457 newBorderPath.lineTo(horizontalBorderEnd.x(), verticalBorderStart.y());
458 borderPath->setPath(newBorderPath);
459}
460
461void OcularsGuiPanel::updateOcularControls()
462{
463 setCcdControlsVisible(false);
464
465 //Get the name
466 int index = ocularsPlugin->selectedOcularIndex;
467 Ocular* ocular = ocularsPlugin->oculars[index];
468 Q_ASSERT(ocular);
469 QString name = ocular->name();
470 QString fullName;
471 if (name.isEmpty())
472 {
473 fullName = QString("Ocular #%1").arg(index);
474 }
475 else
476 {
477 fullName = QString("Ocular #%1: %2").arg(index).arg(name);
478 }
479 fieldOcularName->setPlainText(fullName);
480
481 qreal posX = 0.;
482 qreal posY = 0.;
483 qreal widgetWidth = 0.;
484 qreal widgetHeight = 0.;
485
486 //Prev button
487 qreal heightAdjustment = (fieldOcularName->boundingRect().height() - prevOcularButton->boundingRect().height()) / 2.;
488 prevOcularButton->setPos(posX, round(posY + heightAdjustment));
489 posX += prevOcularButton->boundingRect().width();
490 widgetWidth += prevOcularButton->boundingRect().width();
491
492 //Name field
493 fieldOcularName->setPos(posX, posY);
494 posX += fieldOcularName->boundingRect().width();
495 widgetWidth += fieldOcularName->boundingRect().width();
496
497 //Next button
498 nextOcularButton->setPos(posX, posY + heightAdjustment);
499 widgetWidth += nextOcularButton->boundingRect().width();
500
501 posX = prevOcularButton->boundingRect().width();
502 posY += fieldOcularName->boundingRect().height();
503 widgetHeight += fieldOcularName->boundingRect().height();
504
505
506 if (ocular->isBinoculars())
507 {
508 fieldOcularFl->setVisible(false);
509 fieldOcularAfov->setVisible(false);
510 }
511 else
512 {
513 double focalLength = ocular->effectiveFocalLength();
514 QString focalLengthString = QString("Ocular FL: %1mm").arg(focalLength);
515 fieldOcularFl->setPlainText(focalLengthString);
516 fieldOcularFl->setToolTip("Focal length of the ocular");
517 fieldOcularFl->setPos(posX, posY);
518 posY += fieldOcularFl->boundingRect().height();
519 widgetHeight += fieldOcularFl->boundingRect().height();
520
521 double apparentFov = ocular->appearentFOV();
522 //TODO: This one could be better. Even in LTR languages the degree sign
523 //is to the right of the value?
524 QString apparentFovString =
525 QString("Ocular aFOV: %1%2").arg(apparentFov).arg(QChar(0x00B0));
526 fieldOcularAfov->setPlainText(apparentFovString);
527 fieldOcularAfov->setToolTip("Apparent field of view of the ocular");
528 fieldOcularAfov->setPos(posX, posY);
529 widgetHeight += fieldOcularAfov->boundingRect().height();
530
531 fieldOcularFl->setVisible(true);
532 fieldOcularAfov->setVisible(true);
533 }
534
535 ocularControls->setMinimumSize(widgetWidth, widgetHeight);
536 ocularControls->resize(widgetWidth, widgetHeight);
537 setOcularControlsVisible(true);
538
539 updateTelescopeControls();//Contains a call to updatePosition()
540}
541
542void OcularsGuiPanel::updateCcdControls()
543{
544 setOcularControlsVisible(false);
545
546 //Get the name
547 int index = ocularsPlugin->selectedCCDIndex;
548 CCD* ccd = ocularsPlugin->ccds[index];
549 Q_ASSERT(ccd);
550 QString name = ccd->name();
551 QString fullName;
552 if (name.isEmpty())
553 {
554 fullName = QString("Sensor #%1").arg(index);
555 }
556 else
557 {
558 fullName = QString("Sensor #%1: %2").arg(index).arg(name);
559 }
560 fieldCcdName->setPlainText(fullName);
561
562 qreal posX = 0.;
563 qreal posY = 0.;
564 qreal widgetWidth = 0.;
565 qreal widgetHeight = 0.;
566
567 //Prev button
568 qreal heightAdjustment = (fieldCcdName->boundingRect().height() - prevCcdButton->boundingRect().height()) / 2.;
569 prevCcdButton->setPos(posX, posY + heightAdjustment);
570 posX += prevCcdButton->boundingRect().width();
571 widgetWidth += prevCcdButton->boundingRect().width();
572
573 //Name field
574 fieldCcdName->setPos(posX, posY);
575 posX += fieldCcdName->boundingRect().width();
576 widgetWidth += fieldCcdName->boundingRect().width();
577
578 //Next button
579 nextCcdButton->setPos(posX, posY + heightAdjustment);
580 widgetWidth += nextCcdButton->boundingRect().width();
581
582 posX = prevCcdButton->boundingRect().width();
583 posY = fieldCcdName->boundingRect().height();
584 widgetHeight += fieldCcdName->boundingRect().height();
585
586 //We need the current telescope
587 index = ocularsPlugin->selectedTelescopeIndex;
588 Telescope* telescope = ocularsPlugin->telescopes[index];
589 Q_ASSERT(telescope);
590 double fovX = ((int)(ccd->getActualFOVx(telescope) * 1000.0)) / 1000.0;
591 double fovY = ((int)(ccd->getActualFOVy(telescope) * 1000.0)) / 1000.0;
592 //TODO: Again, the symbol could be handled simpler.
593 QString dimensions = QString("Dimensions: %1%2 %3 %4%5").arg(fovX).arg(QChar(0x00B0)).arg(QChar(0x00D7)).arg(fovY).arg(QChar(0x00B0));
594 fieldCcdDimensions->setPlainText(dimensions);
595 fieldCcdDimensions->setPos(posX, posY);
596 posY += fieldCcdDimensions->boundingRect().height();
597 widgetHeight += fieldCcdDimensions->boundingRect().height();
598
599 QString rotation = QString("Rotation (angle): %1%2").arg(ocularsPlugin->ccdRotationAngle, 0, 'f', 2).arg(QChar(0x00B0));
600 fieldCcdRotation->setPlainText(rotation);
601 fieldCcdRotation->setPos(posX, posY);
602 posY += fieldCcdRotation->boundingRect().height();
603 widgetHeight += fieldCcdRotation->boundingRect().height();
604
605 int rotationButtonsWidth = rotateCcdMinus15Button->boundingRect().width();
606 rotationButtonsWidth += rotateCcdMinus5Button->boundingRect().width();
607 rotationButtonsWidth += rotateCcdMinus1Button->boundingRect().width();
608 rotationButtonsWidth += resetCcdRotationButton->boundingRect().width();
609 rotationButtonsWidth += rotateCcdPlus1Button->boundingRect().width();
610 rotationButtonsWidth += rotateCcdPlus5Button->boundingRect().width();
611 rotationButtonsWidth += rotateCcdPlus15Button->boundingRect().width();
612 int spacing = (fieldCcdRotation->boundingRect().width() - rotationButtonsWidth) / 6;
613 posX = fieldCcdRotation->x();
614 rotateCcdMinus15Button->setPos(posX, posY);
615 posX += rotateCcdMinus15Button->boundingRect().width() + spacing;
616 rotateCcdMinus5Button->setPos(posX, posY);
617 posX += rotateCcdMinus5Button->boundingRect().width() + spacing;
618 rotateCcdMinus1Button->setPos(posX, posY);
619 posX += rotateCcdMinus1Button->boundingRect().width() + spacing;
620 resetCcdRotationButton->setPos(posX, posY);
621 posX += resetCcdRotationButton->boundingRect().width() + spacing;
622 rotateCcdPlus1Button->setPos(posX, posY);
623 posX += rotateCcdPlus1Button->boundingRect().width() + spacing;
624 rotateCcdPlus5Button->setPos(posX, posY);
625 posX += rotateCcdPlus5Button->boundingRect().width() + spacing;
626 rotateCcdPlus15Button->setPos(posX, posY);
627 widgetHeight += rotateCcdMinus15Button->boundingRect().height();
628
629 ccdControls->setMinimumSize(widgetWidth, widgetHeight);
630 ccdControls->resize(widgetWidth, widgetHeight);
631 setCcdControlsVisible(true);
632
633 updateTelescopeControls();//Contains a call to updatePosition()
634}
635
636void OcularsGuiPanel::updateTelescopeControls()
637{
638 //Get the name
639 int index = ocularsPlugin->selectedTelescopeIndex;
640 Telescope* telescope = ocularsPlugin->telescopes[index];
641 Q_ASSERT(telescope);
642 QString name = telescope->name();
643 QString fullName;
644 if (name.isEmpty())
645 {
646 fullName = QString("Telescope #%1").arg(index);
647 }
648 else
649 {
650 fullName = QString("Telescope #%1: %2").arg(index).arg(name);
651 }
652 fieldTelescopeName->setPlainText(fullName);
653
654 qreal posX = 0.;
655 qreal posY = 0.;
656 qreal widgetWidth = 0.;
657 qreal widgetHeight = 0.;
658
659 //Prev button
660 qreal heightAdjustment = (fieldTelescopeName->boundingRect().height() - prevTelescopeButton->boundingRect().height()) / 2.;
661 prevTelescopeButton->setPos(posX, posY + heightAdjustment);
662 posX += prevTelescopeButton->boundingRect().width();
663 widgetWidth += prevTelescopeButton->boundingRect().width();
664
665 //Name field
666 fieldTelescopeName->setPos(posX, posY);
667 posX += fieldTelescopeName->boundingRect().width();
668 widgetWidth += fieldTelescopeName->boundingRect().height();
669
670 //Next button
671 nextTelescopeButton->setPos(posX, posY + heightAdjustment);
672 widgetWidth += nextTelescopeButton->boundingRect().width();
673
674 posX = prevTelescopeButton->boundingRect().width();
675 posY += fieldTelescopeName->boundingRect().height();
676 widgetHeight += fieldTelescopeName->boundingRect().height();
677
678 if (ocularsPlugin->flagShowOculars)
679 {
680 //We need the current ocular
681 int index = ocularsPlugin->selectedOcularIndex;
682 Ocular* ocular = ocularsPlugin->oculars[index];
683 Q_ASSERT(ocular);
684
685 if (ocular->isBinoculars())
686 {
687 prevTelescopeButton->setVisible(false);
688 nextTelescopeButton->setVisible(false);
689 fieldTelescopeName->setVisible(false);
690 posY = 0.;
691 widgetHeight = 0.;
692
693 fieldMagnification->setToolTip("Magnification provided by these binoculars");
694 fieldFov->setToolTip("Actual field of view provided by these binoculars");
695 }
696 else
697 {
698 prevTelescopeButton->setVisible(true);
699 nextTelescopeButton->setVisible(true);
700 fieldTelescopeName->setVisible(true);
701
702 fieldMagnification->setToolTip("Magnification provided by this ocular/telescope combination");
703 fieldFov->setToolTip("Actual field of view provided by this ocular/telescope combination");
704 }
705
706 //WTF? Rounding?
707 double magnification = ((int)(ocular->magnification(telescope) * 10.0)) / 10.0;
708 //TODO: Again, this can be simpler
709 QString magnificationString =
710 QString("Magnification: %1%2").arg(magnification).arg(QChar(0x00D7));
711 fieldMagnification->setPlainText(magnificationString);
712 fieldMagnification->setPos(posX, posY);
713 posY += fieldMagnification->boundingRect().height();
714 widgetHeight += fieldMagnification->boundingRect().height();
715
716 double fov = ((int)(ocular->actualFOV(telescope) * 10000.00)) / 10000.0;
717 //TODO: Again, this can be simpler
718 QString fovString = QString("FOV: %1%2").arg(fov).arg(QChar(0x00B0));
719 fieldFov->setPlainText(fovString);
720 fieldFov->setPos(posX, posY);
721 widgetHeight += fieldFov->boundingRect().height();
722
723 fieldMagnification->setVisible(true);
724 fieldFov->setVisible(true);
725 }
726 else
727 {
728 prevTelescopeButton->setVisible(true);
729 nextTelescopeButton->setVisible(true);
730 fieldTelescopeName->setVisible(true);
731
732 fieldMagnification->setVisible(false);
733 fieldFov->setVisible(false);
734 }
735
736 telescopeControls->setMinimumSize(widgetWidth, widgetHeight);
737 telescopeControls->resize(widgetWidth, widgetHeight);
738 setTelescopeControlsVisible(true);
739
740 updatePosition();
741}
742
743void OcularsGuiPanel::setOcularControlsVisible(bool show)
744{
745 if (show)
746 {
747 if (!ocularControls->isVisible())
748 {
749 ocularControls->setVisible(true);
750 mainLayout->insertItem(0, ocularControls);
751 }
752 }
753 else
754 {
755 if (ocularControls->isVisible())
756 {
757 mainLayout->removeItem(ocularControls);
758 ocularControls->setVisible(false);
759 }
760 }
761 buttonCrosshairs->setVisible(show);
762 updateMainButtonsPositions();
763}
764
765void OcularsGuiPanel::setCcdControlsVisible(bool show)
766{
767 if (show)
768 {
769 if (!ccdControls->isVisible())
770 {
771 ccdControls->setVisible(true);
772 mainLayout->insertItem(0, ccdControls);
773 }
774 }
775 else
776 {
777 if (ccdControls->isVisible())
778 {
779 mainLayout->removeItem(ccdControls);
780 ccdControls->setVisible(false);
781 }
782 }
783}
784
785void OcularsGuiPanel::setTelescopeControlsVisible(bool show)
786{
787 if (show)
788 {
789 if (!telescopeControls->isVisible())
790 {
791 telescopeControls->setVisible(true);
792 mainLayout->insertItem(1, telescopeControls);
793 }
794 }
795 else
796 {
797 if (telescopeControls->isVisible())
798 {
799 mainLayout->removeItem(telescopeControls);
800 telescopeControls->setVisible(false);
801 }
802 }
803 mainLayout->invalidate();
804 mainLayout->activate();
805 resize(mainLayout->geometry().width(),
806 mainLayout->geometry().height());
807}
808
809void OcularsGuiPanel::updateMainButtonsPositions()
810{
811 Q_ASSERT(buttonOcular);
812 Q_ASSERT(buttonCrosshairs);
813 Q_ASSERT(buttonCrosshairs);
814 Q_ASSERT(buttonCcd);
815 Q_ASSERT(buttonTelrad);
816 Q_ASSERT(buttonConfiguration);
817
818 int n = buttonCrosshairs->isVisible() ? 5 : 4;
819 qreal width = n * buttonOcular->getButtonPixmapWidth();
820
821 //Relative position inside the parent widget
822 qreal posX = 0.;
823 qreal posY = 0.;
824 qreal spacing = 0.;
825 if (prevTelescopeButton)
826 {
827 width += 2 * prevTelescopeButton->getButtonPixmapWidth();
828 posX = prevTelescopeButton->getButtonPixmapWidth();
829 }
830 if (buttonOcular->parentItem())
831 {
832 qreal parentWidth = buttonOcular->parentItem()->boundingRect().width();
833 int nGaps = n - 1;//n buttons have n-1 gaps
834 //posX = round((parentWidth-width)/2.0);//Centering, deprecated
835 spacing = round((parentWidth-width)/nGaps);
836 }
837 buttonOcular->setPos(posX, posY);
838 posX += buttonOcular->getButtonPixmapWidth() + spacing;
839 if (buttonCrosshairs->isVisible())
840 {
841 buttonCrosshairs->setPos(posX, posY);
842 posX += buttonCrosshairs->getButtonPixmapWidth() + spacing;
843 }
844 buttonCcd->setPos(posX, posY);
845 posX += buttonCcd->getButtonPixmapWidth() + spacing;
846 buttonTelrad->setPos(posX, posY);
847 posX += buttonTelrad->getButtonPixmapWidth() + spacing;
848 buttonConfiguration->setPos(posX, posY);
849 posX += buttonConfiguration->getButtonPixmapWidth() + spacing;
850}
851
852void OcularsGuiPanel::setControlsColor(const QColor& color)
853{
854 Q_ASSERT(fieldOcularName);
855 Q_ASSERT(fieldOcularFl);
856 Q_ASSERT(fieldOcularAfov);
857 Q_ASSERT(fieldCcdName);
858 Q_ASSERT(fieldCcdDimensions);
859 Q_ASSERT(fieldCcdRotation);
860 Q_ASSERT(fieldTelescopeName);
861 Q_ASSERT(fieldMagnification);
862 Q_ASSERT(fieldFov);
863
864 fieldOcularName->setDefaultTextColor(color);
865 fieldOcularFl->setDefaultTextColor(color);
866 fieldOcularAfov->setDefaultTextColor(color);
867 fieldCcdName->setDefaultTextColor(color);
868 fieldCcdDimensions->setDefaultTextColor(color);
869 fieldCcdRotation->setDefaultTextColor(color);
870 fieldTelescopeName->setDefaultTextColor(color);
871 fieldMagnification->setDefaultTextColor(color);
872 fieldFov->setDefaultTextColor(color);
873}
874
875void OcularsGuiPanel::setControlsFont(const QFont& font)
876{
877 Q_ASSERT(fieldOcularName);
878 Q_ASSERT(fieldOcularFl);
879 Q_ASSERT(fieldOcularAfov);
880 Q_ASSERT(fieldCcdName);
881 Q_ASSERT(fieldCcdDimensions);
882 Q_ASSERT(fieldCcdRotation);
883 Q_ASSERT(fieldTelescopeName);
884 Q_ASSERT(fieldMagnification);
885 Q_ASSERT(fieldFov);
886
887 fieldOcularName->setFont(font);
888 fieldOcularFl->setFont(font);
889 fieldOcularAfov->setFont(font);
890 fieldCcdName->setFont(font);
891 fieldCcdDimensions->setFont(font);
892 fieldCcdRotation->setFont(font);
893 fieldTelescopeName->setFont(font);
894 fieldMagnification->setFont(font);
895 fieldFov->setFont(font);
896}
897
898void OcularsGuiPanel::setButtonsNightMode(bool nightMode)
899{
900 //Reused from SkyGui, with modifications
901 foreach (QGraphicsItem *child, QGraphicsItem::children())
902 {
903 foreach (QGraphicsItem *grandchild, child->children())
904 {
905 StelButton* button = qgraphicsitem_cast<StelButton*>(grandchild);
906 if (button)
907 button->setRedMode(nightMode);
908 }
909 }
910}
911
912void OcularsGuiPanel::setColorScheme(const QString &schemeName)
913{
914 if (schemeName == "night_color")
915 {
916 borderPath->setPen(QColor::fromRgbF(0.7,0.2,0.2,0.5));
917 borderPath->setBrush(QColor::fromRgbF(0.23, 0.13, 0.03, 0.2));
918 setControlsColor(QColor::fromRgbF(0.9, 0.33, 0.33, 0.9));
919 setButtonsNightMode(true);
920 }
921 else
922 {
923 borderPath->setPen(QColor::fromRgbF(0.7,0.7,0.7,0.5));
924 borderPath->setBrush(QColor::fromRgbF(0.15, 0.16, 0.19, 0.2));
925 setControlsColor(QColor::fromRgbF(0.9, 0.91, 0.95, 0.9));
926 setButtonsNightMode(false);
927 }
928}
929
930QPixmap OcularsGuiPanel::createPixmapFromText(const QString& text,
931 int width,
932 int height,
933 const QFont& font,
934 const QColor& textColor,
935 const QColor& backgroundColor)
936{
937 if (width <= 0 || height <=0)
938 return QPixmap();
939
940 QPixmap pixmap(width, height);
941 pixmap.fill(backgroundColor);
942
943 if (text.isEmpty())
944 return pixmap;
945
946 QPainter painter(&pixmap);
947 painter.setFont(font);
948 painter.setPen(QPen(textColor));
949 painter.drawText(0, 0, width, height,
950 Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine,
951 text);
952
953 return pixmap;
954}
0955
=== added file 'plugins/Oculars/src/gui/OcularsGuiPanel.hpp'
--- plugins/Oculars/src/gui/OcularsGuiPanel.hpp 1970-01-01 00:00:00 +0000
+++ plugins/Oculars/src/gui/OcularsGuiPanel.hpp 2011-11-24 21:50:30 +0000
@@ -0,0 +1,137 @@
1/*
2Oculars plug-in for Stellarium: graphical user interface widget
3Copyright (C) 2011 Bogdan Marinov
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20#ifndef OCULARSGUIPANEL_HPP
21#define OCULARSGUIPANEL_HPP
22
23#include <QGraphicsWidget>
24
25class Oculars;
26class StelButton;
27class QGraphicsLinearLayout;
28class QGraphicsProxyWidget;
29class QLabel;
30class QPushButton;
31class QWidget;
32
33//! A screen widget similar to InfoPanel. Contains controls and information.
34class OcularsGuiPanel : public QGraphicsWidget
35{
36 Q_OBJECT
37
38public:
39 OcularsGuiPanel(Oculars* ocularsPlugin,
40 QGraphicsWidget * parent = 0,
41 Qt::WindowFlags wFlags = 0);
42 ~OcularsGuiPanel();
43
44public slots:
45 //! Show only the controls used with an ocular overlay.
46 void showOcularGui();
47 //! Show only the controls used with a CCD overlay.
48 void showCcdGui();
49 //! Hide the controls, leaving only the button bar.
50 void foldGui();
51
52private slots:
53 //! Update the position of the widget within the parent.
54 //! Tied to the parent's geometryChanged() signal.
55 void updatePosition();
56
57 //! Updates the information shown when an ocular overlay is displayed
58 void updateOcularControls();
59 //! Updates the information shown when a sensor overlay is displayed
60 void updateCcdControls();
61 //! Updates the information that depends on the current telescope.
62 //! Called in both updateOcularControls() and updateCcdControls().
63 void updateTelescopeControls();
64
65 //! Sets the color scheme (day/night mode)
66 void setColorScheme(const QString& schemeName);
67
68private:
69 Oculars* ocularsPlugin;
70
71 //! This is actually SkyGui. Perhaps it should be more specific?
72 QGraphicsWidget* parentWidget;
73
74 QGraphicsLinearLayout* mainLayout;
75
76 QGraphicsPathItem* borderPath;
77
78 //! Mini-toolbar holding StelButtons
79 QGraphicsWidget* buttonBar;
80 QGraphicsWidget* ocularControls;
81 QGraphicsWidget* ccdControls;
82 QGraphicsWidget* telescopeControls;
83
84 //Mini-toolbar
85 StelButton* buttonOcular;
86 StelButton* buttonCrosshairs;
87 StelButton* buttonCcd;
88 StelButton* buttonTelrad;
89 StelButton* buttonConfiguration;
90
91 //Information display
92 StelButton* prevOcularButton;
93 StelButton* nextOcularButton;
94 StelButton* prevTelescopeButton;
95 StelButton* nextTelescopeButton;
96 StelButton* prevCcdButton;
97 StelButton* nextCcdButton;
98 QGraphicsTextItem* fieldOcularName;
99 QGraphicsTextItem* fieldOcularFl;
100 QGraphicsTextItem* fieldOcularAfov;
101 QGraphicsTextItem* fieldCcdName;
102 QGraphicsTextItem* fieldCcdDimensions;
103 QGraphicsTextItem* fieldCcdRotation;
104 QGraphicsTextItem* fieldTelescopeName;
105 QGraphicsTextItem* fieldMagnification;
106 QGraphicsTextItem* fieldFov;
107
108 //Sensor frame rotation controls
109 StelButton* rotateCcdMinus15Button;
110 StelButton* rotateCcdMinus5Button;
111 StelButton* rotateCcdMinus1Button;
112 StelButton* resetCcdRotationButton;
113 StelButton* rotateCcdPlus1Button;
114 StelButton* rotateCcdPlus5Button;
115 StelButton* rotateCcdPlus15Button;
116
117 //! Sets the visibility of the ocular name label and the associated buttons.
118 void setOcularControlsVisible(bool show);
119 void setCcdControlsVisible(bool show);
120 void setTelescopeControlsVisible(bool show);
121 //! Updates the positions of the buttons inside the button bar.
122 void updateMainButtonsPositions();
123
124 void setControlsColor(const QColor& color);
125 void setControlsFont(const QFont& font);
126 //! Sets the night mode flag on all StelButton-s.
127 void setButtonsNightMode(bool nightMode);
128
129 static QPixmap createPixmapFromText(const QString& text,
130 int width,
131 int height,
132 const QFont& font,
133 const QColor& textColor,
134 const QColor& backgroundColor = QColor(0,0,0,0));
135};
136
137#endif // OCULARSGUIPANEL_HPP
0138
=== modified file 'plugins/Oculars/src/gui/PropertyBasedTableModel.cpp'
--- plugins/Oculars/src/gui/PropertyBasedTableModel.cpp 2011-01-12 21:08:24 +0000
+++ plugins/Oculars/src/gui/PropertyBasedTableModel.cpp 2011-11-24 21:50:30 +0000
@@ -113,3 +113,29 @@
113 return QAbstractTableModel::flags(index) | Qt::ItemIsEditable;113 return QAbstractTableModel::flags(index) | Qt::ItemIsEditable;
114}114}
115115
116void PropertyBasedTableModel::moveRowUp(int position)
117{
118 int count = content->count();
119 if (count < 2 || position < 1 || position >= count)
120 return;
121
122 beginMoveRows(QModelIndex(), position, position, QModelIndex(), position-1);
123
124 content->move(position, position - 1);
125
126 endMoveRows();
127}
128
129void PropertyBasedTableModel::moveRowDown(int position)
130{
131 int count = content->count();
132 if (count < 2 || position < 0 || position > (count - 2))
133 return;
134
135 beginMoveRows(QModelIndex(), position, position, QModelIndex(), position+2);
136
137 content->move(position, position + 1);
138
139 endMoveRows();
140}
141
116142
=== modified file 'plugins/Oculars/src/gui/PropertyBasedTableModel.hpp'
--- plugins/Oculars/src/gui/PropertyBasedTableModel.hpp 2011-01-12 21:08:24 +0000
+++ plugins/Oculars/src/gui/PropertyBasedTableModel.hpp 2011-11-24 21:50:30 +0000
@@ -40,6 +40,9 @@
40 virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole);40 virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole);
41 virtual bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());41 virtual bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex());
4242
43 void moveRowUp(int position);
44 void moveRowDown(int position);
45
43private:46private:
44 QList<QObject *>* content;47 QList<QObject *>* content;
45 QMap<int, QString> mappings;48 QMap<int, QString> mappings;
4649
=== modified file 'plugins/Oculars/src/gui/ocularDialog.ui'
--- plugins/Oculars/src/gui/ocularDialog.ui 2011-03-24 16:25:59 +0000
+++ plugins/Oculars/src/gui/ocularDialog.ui 2011-11-24 21:50:30 +0000
@@ -22,9 +22,6 @@
22 <height>320</height>22 <height>320</height>
23 </size>23 </size>
24 </property>24 </property>
25 <property name="windowTitle">
26 <string>Form</string>
27 </property>
28 <layout class="QVBoxLayout" name="verticalLayout_2">25 <layout class="QVBoxLayout" name="verticalLayout_2">
29 <property name="spacing">26 <property name="spacing">
30 <number>0</number>27 <number>0</number>
@@ -152,115 +149,149 @@
152 <property name="currentIndex">149 <property name="currentIndex">
153 <number>0</number>150 <number>0</number>
154 </property>151 </property>
155 <property name="documentMode">
156 <bool>false</bool>
157 </property>
158 <widget class="QWidget" name="General">152 <widget class="QWidget" name="General">
159 <attribute name="title">153 <attribute name="title">
160 <string>General</string>154 <string>General</string>
161 </attribute>155 </attribute>
162 <widget class="QCheckBox" name="scaleImageCircleCheckBox">156 <layout class="QVBoxLayout" name="verticalLayoutTabGeneral">
163 <property name="geometry">157 <property name="spacing">
164 <rect>158 <number>0</number>
165 <x>10</x>159 </property>
166 <y>10</y>160 <property name="margin">
167 <width>141</width>161 <number>0</number>
168 <height>21</height>162 </property>
169 </rect>163 <item>
170 </property>164 <widget class="QGroupBox" name="groupBoxOcularOptions">
171 <property name="text">165 <property name="title">
172 <string>Scale Image Circle</string>166 <string>Ocular view</string>
173 </property>167 </property>
174 </widget>168 <layout class="QVBoxLayout" name="verticalLayout_7">
175 <widget class="QGroupBox" name="groupBox">169 <property name="margin">
176 <property name="geometry">170 <number>0</number>
177 <rect>171 </property>
178 <x>0</x>172 <item>
179 <y>40</y>173 <widget class="QCheckBox" name="requireSelectionCheckBox">
180 <width>503</width>174 <property name="text">
181 <height>121</height>175 <string>Enable only if an object is selected</string>
182 </rect>176 </property>
183 </property>177 </widget>
184 <property name="title">178 </item>
185 <string>Key Mappings</string>179 <item>
186 </property>180 <widget class="QCheckBox" name="scaleImageCircleCheckBox">
187 <layout class="QGridLayout" name="gridLayout_2">181 <property name="text">
188 <item row="0" column="0">182 <string>Scale image circle</string>
189 <widget class="QLabel" name="label_11">183 </property>
190 <property name="text">184 </widget>
191 <string>Toggle Plugin:</string>185 </item>
192 </property>186 </layout>
193 <property name="alignment">187 </widget>
194 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>188 </item>
195 </property>189 <item>
196 </widget>190 <widget class="QGroupBox" name="groupBox">
197 </item>191 <property name="title">
198 <item row="0" column="1">192 <string>Key mappings</string>
199 <widget class="QLineEdit" name="togglePluginLineEdit">193 </property>
200 <property name="sizePolicy">194 <layout class="QFormLayout" name="formLayout_3">
201 <sizepolicy hsizetype="Expanding" vsizetype="Fixed">195 <property name="margin">
202 <horstretch>0</horstretch>196 <number>0</number>
203 <verstretch>0</verstretch>197 </property>
204 </sizepolicy>198 <item row="0" column="0">
205 </property>199 <widget class="QLabel" name="label_11">
206 <property name="baseSize">200 <property name="text">
207 <size>201 <string>Toggle ocular view:</string>
208 <width>100</width>202 </property>
209 <height>22</height>203 <property name="alignment">
210 </size>204 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
211 </property>205 </property>
212 <property name="text">206 </widget>
213 <string/>207 </item>
214 </property>208 <item row="0" column="1">
215 <property name="maxLength">209 <widget class="QLineEdit" name="togglePluginLineEdit">
216 <number>50</number>210 <property name="maximumSize">
217 </property>211 <size>
218 </widget>212 <width>100</width>
219 </item>213 <height>16777215</height>
220 <item row="0" column="2">214 </size>
221 <widget class="QLabel" name="label_13">215 </property>
222 <property name="text">216 <property name="baseSize">
223 <string>Popup Navigator:</string>217 <size>
224 </property>218 <width>100</width>
225 <property name="alignment">219 <height>22</height>
226 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>220 </size>
227 </property>221 </property>
228 </widget>222 <property name="text">
229 </item>223 <string/>
230 <item row="0" column="3">224 </property>
231 <widget class="QLineEdit" name="togglePopupNavigatorWindowLineEdit">225 <property name="maxLength">
232 <property name="sizePolicy">226 <number>50</number>
233 <sizepolicy hsizetype="Expanding" vsizetype="Fixed">227 </property>
234 <horstretch>0</horstretch>228 </widget>
235 <verstretch>0</verstretch>229 </item>
236 </sizepolicy>230 <item row="1" column="0">
237 </property>231 <widget class="QLabel" name="labelPopupMenuShortcut">
238 <property name="baseSize">232 <property name="text">
239 <size>233 <string>Open pop-up navigation menu:</string>
240 <width>100</width>234 </property>
241 <height>22</height>235 <property name="alignment">
242 </size>236 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
243 </property>237 </property>
244 <property name="maxLength">238 </widget>
245 <number>50</number>239 </item>
246 </property>240 <item row="1" column="1">
247 </widget>241 <widget class="QLineEdit" name="togglePopupNavigatorWindowLineEdit">
248 </item>242 <property name="maximumSize">
249 </layout>243 <size>
250 </widget>244 <width>100</width>
251 <widget class="QCheckBox" name="requireSelectionCheckBox">245 <height>16777215</height>
252 <property name="geometry">246 </size>
253 <rect>247 </property>
254 <x>260</x>248 <property name="baseSize">
255 <y>10</y>249 <size>
256 <width>201</width>250 <width>100</width>
257 <height>21</height>251 <height>22</height>
258 </rect>252 </size>
259 </property>253 </property>
260 <property name="text">254 <property name="maxLength">
261 <string>Require selection to enable</string>255 <number>50</number>
262 </property>256 </property>
263 </widget>257 </widget>
258 </item>
259 </layout>
260 </widget>
261 </item>
262 <item>
263 <widget class="QGroupBox" name="groupBoxInterface">
264 <property name="title">
265 <string>Interface</string>
266 </property>
267 <layout class="QVBoxLayout" name="verticalLayout_8">
268 <property name="margin">
269 <number>0</number>
270 </property>
271 <item>
272 <widget class="QCheckBox" name="checkBoxControlPanel">
273 <property name="text">
274 <string>On-screen control panel</string>
275 </property>
276 </widget>
277 </item>
278 </layout>
279 </widget>
280 </item>
281 <item>
282 <spacer name="verticalSpacer_3">
283 <property name="orientation">
284 <enum>Qt::Vertical</enum>
285 </property>
286 <property name="sizeHint" stdset="0">
287 <size>
288 <width>20</width>
289 <height>40</height>
290 </size>
291 </property>
292 </spacer>
293 </item>
294 </layout>
264 </widget>295 </widget>
265 <widget class="QWidget" name="Eyepieces">296 <widget class="QWidget" name="Eyepieces">
266 <attribute name="title">297 <attribute name="title">
@@ -335,9 +366,6 @@
335 <enum>QFrame::Raised</enum>366 <enum>QFrame::Raised</enum>
336 </property>367 </property>
337 <layout class="QHBoxLayout" name="horizontalLayout_2">368 <layout class="QHBoxLayout" name="horizontalLayout_2">
338 <property name="spacing">
339 <number>0</number>
340 </property>
341 <property name="leftMargin">369 <property name="leftMargin">
342 <number>0</number>370 <number>0</number>
343 </property>371 </property>
@@ -352,29 +380,65 @@
352 </property>380 </property>
353 <item>381 <item>
354 <widget class="QPushButton" name="addOcular">382 <widget class="QPushButton" name="addOcular">
383 <property name="minimumSize">
384 <size>
385 <width>0</width>
386 <height>24</height>
387 </size>
388 </property>
355 <property name="text">389 <property name="text">
356 <string>Add</string>390 <string>Add</string>
357 </property>391 </property>
358 </widget>392 </widget>
359 </item>393 </item>
360 <item>394 <item>
361 <spacer name="horizontalSpacer_3">395 <widget class="QPushButton" name="pushButtonMoveOcularUp">
362 <property name="orientation">396 <property name="sizePolicy">
363 <enum>Qt::Horizontal</enum>397 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
364 </property>398 <horstretch>0</horstretch>
365 <property name="sizeType">399 <verstretch>0</verstretch>
366 <enum>QSizePolicy::Preferred</enum>400 </sizepolicy>
367 </property>401 </property>
368 <property name="sizeHint" stdset="0">402 <property name="minimumSize">
369 <size>403 <size>
370 <width>20</width>404 <width>24</width>
371 <height>20</height>405 <height>24</height>
372 </size>406 </size>
373 </property>407 </property>
374 </spacer>408 <property name="icon">
409 <iconset resource="../../../../data/gui/guiRes.qrc">
410 <normaloff>:/graphicGui/spinup.png</normaloff>:/graphicGui/spinup.png</iconset>
411 </property>
412 </widget>
413 </item>
414 <item>
415 <widget class="QPushButton" name="pushButtonMoveOcularDown">
416 <property name="sizePolicy">
417 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
418 <horstretch>0</horstretch>
419 <verstretch>0</verstretch>
420 </sizepolicy>
421 </property>
422 <property name="minimumSize">
423 <size>
424 <width>24</width>
425 <height>24</height>
426 </size>
427 </property>
428 <property name="icon">
429 <iconset resource="../../../../data/gui/guiRes.qrc">
430 <normaloff>:/graphicGui/spindown.png</normaloff>:/graphicGui/spindown.png</iconset>
431 </property>
432 </widget>
375 </item>433 </item>
376 <item>434 <item>
377 <widget class="QPushButton" name="deleteOcular">435 <widget class="QPushButton" name="deleteOcular">
436 <property name="minimumSize">
437 <size>
438 <width>0</width>
439 <height>24</height>
440 </size>
441 </property>
378 <property name="text">442 <property name="text">
379 <string>Delete</string>443 <string>Delete</string>
380 </property>444 </property>
@@ -468,7 +532,7 @@
468 <item row="2" column="0">532 <item row="2" column="0">
469 <widget class="QLabel" name="label_5">533 <widget class="QLabel" name="label_5">
470 <property name="text">534 <property name="text">
471 <string>Focal Length:</string>535 <string>Focal length:</string>
472 </property>536 </property>
473 </widget>537 </widget>
474 </item>538 </item>
@@ -488,7 +552,7 @@
488 <item row="3" column="0">552 <item row="3" column="0">
489 <widget class="QLabel" name="label_10">553 <widget class="QLabel" name="label_10">
490 <property name="text">554 <property name="text">
491 <string>Field Stop:</string>555 <string>Field stop:</string>
492 </property>556 </property>
493 </widget>557 </widget>
494 </item>558 </item>
@@ -606,9 +670,6 @@
606 <enum>QFrame::Raised</enum>670 <enum>QFrame::Raised</enum>
607 </property>671 </property>
608 <layout class="QHBoxLayout" name="CCD_horizontalLayout_2">672 <layout class="QHBoxLayout" name="CCD_horizontalLayout_2">
609 <property name="spacing">
610 <number>0</number>
611 </property>
612 <property name="leftMargin">673 <property name="leftMargin">
613 <number>0</number>674 <number>0</number>
614 </property>675 </property>
@@ -623,29 +684,65 @@
623 </property>684 </property>
624 <item>685 <item>
625 <widget class="QPushButton" name="addCCD">686 <widget class="QPushButton" name="addCCD">
687 <property name="minimumSize">
688 <size>
689 <width>0</width>
690 <height>24</height>
691 </size>
692 </property>
626 <property name="text">693 <property name="text">
627 <string>Add</string>694 <string>Add</string>
628 </property>695 </property>
629 </widget>696 </widget>
630 </item>697 </item>
631 <item>698 <item>
632 <spacer name="horizontalSpacer_add_remove">699 <widget class="QPushButton" name="pushButtonMoveSensorUp">
633 <property name="orientation">700 <property name="sizePolicy">
634 <enum>Qt::Horizontal</enum>701 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
635 </property>702 <horstretch>0</horstretch>
636 <property name="sizeType">703 <verstretch>0</verstretch>
637 <enum>QSizePolicy::Preferred</enum>704 </sizepolicy>
638 </property>705 </property>
639 <property name="sizeHint" stdset="0">706 <property name="minimumSize">
640 <size>707 <size>
641 <width>20</width>708 <width>24</width>
642 <height>20</height>709 <height>24</height>
643 </size>710 </size>
644 </property>711 </property>
645 </spacer>712 <property name="icon">
713 <iconset resource="../../../../data/gui/guiRes.qrc">
714 <normaloff>:/graphicGui/spinup.png</normaloff>:/graphicGui/spinup.png</iconset>
715 </property>
716 </widget>
717 </item>
718 <item>
719 <widget class="QPushButton" name="pushButtonMoveSensorDown">
720 <property name="sizePolicy">
721 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
722 <horstretch>0</horstretch>
723 <verstretch>0</verstretch>
724 </sizepolicy>
725 </property>
726 <property name="minimumSize">
727 <size>
728 <width>24</width>
729 <height>24</height>
730 </size>
731 </property>
732 <property name="icon">
733 <iconset resource="../../../../data/gui/guiRes.qrc">
734 <normaloff>:/graphicGui/spindown.png</normaloff>:/graphicGui/spindown.png</iconset>
735 </property>
736 </widget>
646 </item>737 </item>
647 <item>738 <item>
648 <widget class="QPushButton" name="deleteCCD">739 <widget class="QPushButton" name="deleteCCD">
740 <property name="minimumSize">
741 <size>
742 <width>0</width>
743 <height>24</height>
744 </size>
745 </property>
649 <property name="text">746 <property name="text">
650 <string>Delete</string>747 <string>Delete</string>
651 </property>748 </property>
@@ -947,38 +1044,80 @@
947 </item>1044 </item>
948 <item>1045 <item>
949 <widget class="QFrame" name="frame_3">1046 <widget class="QFrame" name="frame_3">
950 <property name="frameShape">
951 <enum>QFrame::StyledPanel</enum>
952 </property>
953 <property name="frameShadow">
954 <enum>QFrame::Raised</enum>
955 </property>
956 <layout class="QHBoxLayout" name="horizontalLayout">1047 <layout class="QHBoxLayout" name="horizontalLayout">
1048 <property name="leftMargin">
1049 <number>0</number>
1050 </property>
1051 <property name="topMargin">
1052 <number>5</number>
1053 </property>
1054 <property name="rightMargin">
1055 <number>0</number>
1056 </property>
1057 <property name="bottomMargin">
1058 <number>0</number>
1059 </property>
957 <item>1060 <item>
958 <widget class="QPushButton" name="addTelescope">1061 <widget class="QPushButton" name="addTelescope">
1062 <property name="minimumSize">
1063 <size>
1064 <width>0</width>
1065 <height>24</height>
1066 </size>
1067 </property>
959 <property name="text">1068 <property name="text">
960 <string>Add</string>1069 <string>Add</string>
961 </property>1070 </property>
962 </widget>1071 </widget>
963 </item>1072 </item>
964 <item>1073 <item>
965 <spacer name="horizontalSpacer">1074 <widget class="QPushButton" name="pushButtonMoveTelescopeUp">
966 <property name="orientation">1075 <property name="sizePolicy">
967 <enum>Qt::Horizontal</enum>1076 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
968 </property>1077 <horstretch>0</horstretch>
969 <property name="sizeType">1078 <verstretch>0</verstretch>
970 <enum>QSizePolicy::Preferred</enum>1079 </sizepolicy>
971 </property>1080 </property>
972 <property name="sizeHint" stdset="0">1081 <property name="minimumSize">
973 <size>1082 <size>
974 <width>20</width>1083 <width>24</width>
975 <height>20</height>1084 <height>24</height>
976 </size>1085 </size>
977 </property>1086 </property>
978 </spacer>1087 <property name="icon">
1088 <iconset resource="../../../../data/gui/guiRes.qrc">
1089 <normaloff>:/graphicGui/spinup.png</normaloff>:/graphicGui/spinup.png</iconset>
1090 </property>
1091 </widget>
1092 </item>
1093 <item>
1094 <widget class="QPushButton" name="pushButtonMoveTelescopeDown">
1095 <property name="sizePolicy">
1096 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1097 <horstretch>0</horstretch>
1098 <verstretch>0</verstretch>
1099 </sizepolicy>
1100 </property>
1101 <property name="minimumSize">
1102 <size>
1103 <width>24</width>
1104 <height>24</height>
1105 </size>
1106 </property>
1107 <property name="icon">
1108 <iconset resource="../../../../data/gui/guiRes.qrc">
1109 <normaloff>:/graphicGui/spindown.png</normaloff>:/graphicGui/spindown.png</iconset>
1110 </property>
1111 </widget>
979 </item>1112 </item>
980 <item>1113 <item>
981 <widget class="QPushButton" name="deleteTelescope">1114 <widget class="QPushButton" name="deleteTelescope">
1115 <property name="minimumSize">
1116 <size>
1117 <width>0</width>
1118 <height>24</height>
1119 </size>
1120 </property>
982 <property name="text">1121 <property name="text">
983 <string>Delete</string>1122 <string>Delete</string>
984 </property>1123 </property>
@@ -1040,7 +1179,7 @@
1040 <item row="1" column="0">1179 <item row="1" column="0">
1041 <widget class="QLabel" name="label_9">1180 <widget class="QLabel" name="label_9">
1042 <property name="text">1181 <property name="text">
1043 <string>Focal Length:</string>1182 <string>Focal length:</string>
1044 </property>1183 </property>
1045 </widget>1184 </widget>
1046 </item>1185 </item>
@@ -1068,14 +1207,14 @@
1068 <item row="3" column="1">1207 <item row="3" column="1">
1069 <widget class="QCheckBox" name="telescopeHFlip">1208 <widget class="QCheckBox" name="telescopeHFlip">
1070 <property name="text">1209 <property name="text">
1071 <string>Horizontal Flip</string>1210 <string>Horizontal flip</string>
1072 </property>1211 </property>
1073 </widget>1212 </widget>
1074 </item>1213 </item>
1075 <item row="4" column="1">1214 <item row="4" column="1">
1076 <widget class="QCheckBox" name="telescopeVFlip">1215 <widget class="QCheckBox" name="telescopeVFlip">
1077 <property name="text">1216 <property name="text">
1078 <string>Vertical Flip</string>1217 <string>Vertical flip</string>
1079 </property>1218 </property>
1080 </widget>1219 </widget>
1081 </item>1220 </item>
@@ -1105,42 +1244,13 @@
1105 <string>About</string>1244 <string>About</string>
1106 </attribute>1245 </attribute>
1107 <layout class="QGridLayout" name="gridLayout">1246 <layout class="QGridLayout" name="gridLayout">
1108 <property name="leftMargin">1247 <property name="margin">
1109 <number>12</number>
1110 </property>
1111 <property name="topMargin">
1112 <number>0</number>1248 <number>0</number>
1113 </property>1249 </property>
1114 <property name="rightMargin">
1115 <number>12</number>
1116 </property>
1117 <property name="bottomMargin">
1118 <number>12</number>
1119 </property>
1120 <item row="0" column="0">1250 <item row="0" column="0">
1121 <widget class="QTextBrowser" name="textBrowser">1251 <widget class="QTextBrowser" name="textBrowser">
1122 <property name="html">1252 <property name="openExternalLinks">
1123 <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;1253 <bool>true</bool>
1124&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
1125p, li { white-space: pre-wrap; }
1126&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
1127&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
1128&lt;tr&gt;
1129&lt;td style=&quot;border: none;&quot;&gt;
1130&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Author: &lt;/span&gt;&lt;a href=&quot;treaves@silverfieldstech.com&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; text-decoration: underline; color:#0000ff;&quot;&gt;Timothy Reaves&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
1131&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;&lt;/p&gt;
1132&lt;p style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:600;&quot;&gt;Overview&lt;/span&gt;&lt;/p&gt;
1133&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;This plugin is intended to simulate what you would see through an eyepiece. This configuration dialog can be used to add, modify, or delete eyepieces and telescopes, as well as CCD Sensors. Your first time running the app will populate some samples to get your started.&lt;/span&gt;&lt;/p&gt;
1134&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;You can choose to scale the image you see on the screen. This is intended to show you a better comparison of what one eyepiece/telescope combination will be like as compared to another. The same eyepiece in two different telescopes of differing focal length will produce two different exit circles, changing the view someone. The trade-off of this is that, with the image scaled, a good deal of the screen can be wasted. Therefor I recommend that you leave it off, unless you feel you have a need of it.&lt;/span&gt;&lt;/p&gt;
1135&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;You can toggle a crosshair in the view. Ideally, I wanted this to be aligned to North. I've been unable to do so. So currently it aligns to the top of the screen.&lt;/span&gt;&lt;/p&gt;
1136&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;You can toggle a Telrad finder; this can only be done when you have not turned on the Ocular view. This feature draws three concentric circles of 0.5°, 2.0°, and 4.0°, helping you see what you would expect to see with the naked eye through the Telrad (or similar) finder.&lt;/span&gt;&lt;/p&gt;
1137&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;If you find any issues, please let me know. Enjoy!&lt;/span&gt;&lt;/p&gt;
1138&lt;p style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:600;&quot;&gt;Hot Keys&lt;/span&gt;&lt;/p&gt;
1139&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;These keys are the default, and can be edited in the General Tab. If you are not a Mac user, replace the &lt;/span&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-style:italic;&quot;&gt;Command&lt;/span&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt; key with the &lt;/span&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-style:italic;&quot;&gt;CTRL&lt;/span&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt; key.&lt;/span&gt;&lt;/p&gt;
1140&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:600;&quot;&gt;Command-O&lt;/span&gt;&lt;/p&gt;
1141&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Activate / de-activate the plugin.&lt;/span&gt;&lt;/p&gt;
1142&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:600;&quot;&gt;Alt-O&lt;/span&gt;&lt;/p&gt;
1143&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Shows the popup menu.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
1144 </property>1254 </property>
1145 </widget>1255 </widget>
1146 </item>1256 </item>
@@ -1161,6 +1271,48 @@
1161 <container>1</container>1271 <container>1</container>
1162 </customwidget>1272 </customwidget>
1163 </customwidgets>1273 </customwidgets>
1164 <resources/>1274 <tabstops>
1275 <tabstop>Tabs</tabstop>
1276 <tabstop>requireSelectionCheckBox</tabstop>
1277 <tabstop>scaleImageCircleCheckBox</tabstop>
1278 <tabstop>togglePluginLineEdit</tabstop>
1279 <tabstop>togglePopupNavigatorWindowLineEdit</tabstop>
1280 <tabstop>ocularListView</tabstop>
1281 <tabstop>addOcular</tabstop>
1282 <tabstop>pushButtonMoveOcularUp</tabstop>
1283 <tabstop>pushButtonMoveOcularDown</tabstop>
1284 <tabstop>deleteOcular</tabstop>
1285 <tabstop>ocularName</tabstop>
1286 <tabstop>ocularAFov</tabstop>
1287 <tabstop>ocularFL</tabstop>
1288 <tabstop>ocularFieldStop</tabstop>
1289 <tabstop>binocularsCheckBox</tabstop>
1290 <tabstop>ccdListView</tabstop>
1291 <tabstop>addCCD</tabstop>
1292 <tabstop>pushButtonMoveSensorUp</tabstop>
1293 <tabstop>pushButtonMoveSensorDown</tabstop>
1294 <tabstop>deleteCCD</tabstop>
1295 <tabstop>ccdName</tabstop>
1296 <tabstop>ccdResX</tabstop>
1297 <tabstop>ccdResY</tabstop>
1298 <tabstop>ccdChipX</tabstop>
1299 <tabstop>ccdChipY</tabstop>
1300 <tabstop>ccdPixelX</tabstop>
1301 <tabstop>ccdPixelY</tabstop>
1302 <tabstop>telescopeListView</tabstop>
1303 <tabstop>addTelescope</tabstop>
1304 <tabstop>pushButtonMoveTelescopeUp</tabstop>
1305 <tabstop>pushButtonMoveTelescopeDown</tabstop>
1306 <tabstop>deleteTelescope</tabstop>
1307 <tabstop>telescopeName</tabstop>
1308 <tabstop>telescopeFL</tabstop>
1309 <tabstop>telescopeDiameter</tabstop>
1310 <tabstop>telescopeHFlip</tabstop>
1311 <tabstop>telescopeVFlip</tabstop>
1312 <tabstop>textBrowser</tabstop>
1313 </tabstops>
1314 <resources>
1315 <include location="../../../../data/gui/guiRes.qrc"/>
1316 </resources>
1165 <connections/>1317 <connections/>
1166</ui>1318</ui>
11671319
=== modified file 'src/gui/StelGui.cpp'
--- src/gui/StelGui.cpp 2011-11-21 10:37:37 +0000
+++ src/gui/StelGui.cpp 2011-11-24 21:50:30 +0000
@@ -837,6 +837,8 @@
837837
838LeftStelBar* StelGui::getWindowsButtonBar() {return skyGui->winBar;}838LeftStelBar* StelGui::getWindowsButtonBar() {return skyGui->winBar;}
839839
840SkyGui* StelGui::getSkyGui() {return skyGui;}
841
840bool StelGui::getAutoHideHorizontalButtonBar() const {return skyGui->autoHideHorizontalButtonBar;}842bool StelGui::getAutoHideHorizontalButtonBar() const {return skyGui->autoHideHorizontalButtonBar;}
841843
842void StelGui::setAutoHideHorizontalButtonBar(bool b) {skyGui->autoHideHorizontalButtonBar=b;}844void StelGui::setAutoHideHorizontalButtonBar(bool b) {skyGui->autoHideHorizontalButtonBar=b;}
843845
=== modified file 'src/gui/StelGui.hpp'
--- src/gui/StelGui.hpp 2011-01-29 18:14:28 +0000
+++ src/gui/StelGui.hpp 2011-11-24 21:50:30 +0000
@@ -78,6 +78,10 @@
78 78
79 //! Get the button bar of the left of the screen79 //! Get the button bar of the left of the screen
80 class LeftStelBar* getWindowsButtonBar();80 class LeftStelBar* getWindowsButtonBar();
81
82 //! Get the SkyGui instance (useful for adding other interface elements).
83 //! It will return a valid object only if called after init().
84 class SkyGui* getSkyGui();
81 85
82 //! Get whether the buttons toggling image flip are visible86 //! Get whether the buttons toggling image flip are visible
83 bool getFlagShowFlipButtons() {return flagShowFlipButtons;}87 bool getFlagShowFlipButtons() {return flagShowFlipButtons;}
8488
=== modified file 'src/gui/StelGuiItems.cpp'
--- src/gui/StelGuiItems.cpp 2011-07-21 11:07:44 +0000
+++ src/gui/StelGuiItems.cpp 2011-11-24 21:50:30 +0000
@@ -45,11 +45,22 @@
45#include <QGraphicsLinearLayout>45#include <QGraphicsLinearLayout>
46#include <QSettings>46#include <QSettings>
4747
48StelButton::StelButton(QGraphicsItem* parent, const QPixmap& apixOn, const QPixmap& apixOff,48StelButton::StelButton(QGraphicsItem* parent,
49 const QPixmap& apixHover, QAction* aaction, bool noBackground) :49 const QPixmap& apixOn,
50 QGraphicsPixmapItem(apixOff, parent), pixOn(apixOn), pixOff(apixOff), pixHover(apixHover),50 const QPixmap& apixOff,
51 checked(ButtonStateOff), action(aaction), noBckground(noBackground), isTristate_(false),51 const QPixmap& apixHover,
52 opacity(1.), hoverOpacity(0.)52 QAction* aaction,
53 bool noBackground) :
54 QGraphicsPixmapItem(apixOff, parent),
55 pixOn(apixOn),
56 pixOff(apixOff),
57 pixHover(apixHover),
58 checked(ButtonStateOff),
59 action(aaction),
60 noBckground(noBackground),
61 isTristate_(false),
62 opacity(1.),
63 hoverOpacity(0.)
53{64{
54 Q_ASSERT(!pixOn.isNull());65 Q_ASSERT(!pixOn.isNull());
55 Q_ASSERT(!pixOff.isNull());66 Q_ASSERT(!pixOff.isNull());
@@ -70,24 +81,41 @@
7081
71 if (action!=NULL)82 if (action!=NULL)
72 {83 {
73 QObject::connect(action, SIGNAL(toggled(bool)), this, SLOT(setChecked(bool)));84 QObject::connect(action, SIGNAL(toggled(bool)),
85 this, SLOT(setChecked(bool)));
74 if (action->isCheckable())86 if (action->isCheckable())
75 {87 {
76 setChecked(action->isChecked());88 setChecked(action->isChecked());
77 QObject::connect(this, SIGNAL(toggled(bool)), action, SLOT(setChecked(bool)));89 QObject::connect(this, SIGNAL(toggled(bool)),
90 action, SLOT(setChecked(bool)));
78 }91 }
79 else92 else
80 {93 {
81 QObject::connect(this, SIGNAL(triggered()), action, SLOT(trigger()));94 QObject::connect(this, SIGNAL(triggered()),
95 action, SLOT(trigger()));
82 }96 }
83 }97 }
84}98}
8599
86StelButton::StelButton(QGraphicsItem* parent, const QPixmap& apixOn, const QPixmap& apixOff, const QPixmap& apixNoChange,100StelButton::StelButton(QGraphicsItem* parent,
87 const QPixmap& apixHover, QAction* aaction, bool noBackground, bool isTristate) :101 const QPixmap& apixOn,
88 QGraphicsPixmapItem(apixOff, parent), pixOn(apixOn), pixOff(apixOff), pixNoChange(apixNoChange), pixHover(apixHover),102 const QPixmap& apixOff,
89 checked(ButtonStateOff), action(aaction), noBckground(noBackground), isTristate_(isTristate),103 const QPixmap& apixNoChange,
90 opacity(1.), hoverOpacity(0.)104 const QPixmap& apixHover,
105 QAction* aaction,
106 bool noBackground,
107 bool isTristate) :
108 QGraphicsPixmapItem(apixOff, parent),
109 pixOn(apixOn),
110 pixOff(apixOff),
111 pixNoChange(apixNoChange),
112 pixHover(apixHover),
113 checked(ButtonStateOff),
114 action(aaction),
115 noBckground(noBackground),
116 isTristate_(isTristate),
117 opacity(1.),
118 hoverOpacity(0.)
91{119{
92 Q_ASSERT(!pixOn.isNull());120 Q_ASSERT(!pixOn.isNull());
93 Q_ASSERT(!pixOff.isNull());121 Q_ASSERT(!pixOff.isNull());
@@ -95,7 +123,8 @@
95 redMode = StelApp::getInstance().getVisionModeNight();123 redMode = StelApp::getInstance().getVisionModeNight();
96 pixOnRed = StelButton::makeRed(pixOn);124 pixOnRed = StelButton::makeRed(pixOn);
97 pixOffRed = StelButton::makeRed(pixOff);125 pixOffRed = StelButton::makeRed(pixOff);
98 if (isTristate_) {126 if (isTristate_)
127 {
99 Q_ASSERT(!pixNoChange.isNull());128 Q_ASSERT(!pixNoChange.isNull());
100 pixNoChangeRed = StelButton::makeRed(pixNoChange);129 pixNoChangeRed = StelButton::makeRed(pixNoChange);
101 }130 }
@@ -108,27 +137,33 @@
108 setAcceptsHoverEvents(true);137 setAcceptsHoverEvents(true);
109 timeLine = new QTimeLine(250, this);138 timeLine = new QTimeLine(250, this);
110 timeLine->setCurveShape(QTimeLine::EaseOutCurve);139 timeLine->setCurveShape(QTimeLine::EaseOutCurve);
111 connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animValueChanged(qreal)));140 connect(timeLine, SIGNAL(valueChanged(qreal)),
141 this, SLOT(animValueChanged(qreal)));
112142
113 if (action!=NULL)143 if (action!=NULL)
114 {144 {
115 QObject::connect(action, SIGNAL(toggled(bool)), this, SLOT(setChecked(bool)));145 QObject::connect(action, SIGNAL(toggled(bool)),
146 this, SLOT(setChecked(bool)));
116 if (action->isCheckable())147 if (action->isCheckable())
117 {148 {
118 setChecked(action->isChecked());149 setChecked(action->isChecked());
119 QObject::connect(this, SIGNAL(toggled(bool)), action, SLOT(setChecked(bool)));150 QObject::connect(this, SIGNAL(toggled(bool)),
151 action, SLOT(setChecked(bool)));
120 }152 }
121 else153 else
122 {154 {
123 QObject::connect(this, SIGNAL(triggered()), action, SLOT(trigger()));155 QObject::connect(this, SIGNAL(triggered()),
156 action, SLOT(trigger()));
124 }157 }
125 }158 }
126}159}
127160
128int StelButton::toggleChecked(int checked) {161int StelButton::toggleChecked(int checked)
162{
129 if (!isTristate_)163 if (!isTristate_)
130 checked = !!!checked;164 checked = !!!checked;
131 else {165 else
166 {
132 if (++checked > ButtonStateNoChange)167 if (++checked > ButtonStateNoChange)
133 checked = ButtonStateOff;168 checked = ButtonStateOff;
134 }169 }
@@ -169,22 +204,22 @@
169204
170void StelButton::updateIcon()205void StelButton::updateIcon()
171{206{
172 if (opacity<0.)207 if (opacity < 0.)
173 opacity=0;208 opacity = 0;
174 QPixmap pix(pixOn.size());209 QPixmap pix(pixOn.size());
175 pix.fill(QColor(0,0,0,0));210 pix.fill(QColor(0,0,0,0));
176 QPainter painter(&pix);211 QPainter painter(&pix);
177 painter.setOpacity(opacity);212 painter.setOpacity(opacity);
178 if (!pixBackground.isNull() && noBckground==false)213 if (!pixBackground.isNull() && noBckground==false)
179 painter.drawPixmap(0,0, redMode ? pixBackgroundRed : pixBackground);214 painter.drawPixmap(0, 0, redMode ? pixBackgroundRed : pixBackground);
180 painter.drawPixmap(0, 0,215 painter.drawPixmap(0, 0,
181 (isTristate_ && checked == ButtonStateNoChange) ? (redMode ? pixNoChangeRed : pixNoChange) :216 (isTristate_ && checked == ButtonStateNoChange) ? (redMode ? pixNoChangeRed : pixNoChange) :
182 (checked == ButtonStateOn) ? (redMode ? pixOnRed : pixOn) :217 (checked == ButtonStateOn) ? (redMode ? pixOnRed : pixOn) :
183 /* (checked == ButtonStateOff) ? */ (redMode ? pixOffRed : pixOff));218 /* (checked == ButtonStateOff) ? */ (redMode ? pixOffRed : pixOff));
184 if (hoverOpacity>0)219 if (hoverOpacity > 0)
185 {220 {
186 painter.setOpacity(hoverOpacity*opacity);221 painter.setOpacity(hoverOpacity * opacity);
187 painter.drawPixmap(0,0, redMode ? pixHoverRed : pixHover);222 painter.drawPixmap(0, 0, redMode ? pixHoverRed : pixHover);
188 }223 }
189 setPixmap(pix);224 setPixmap(pix);
190}225}
@@ -201,6 +236,13 @@
201 updateIcon();236 updateIcon();
202}237}
203238
239void StelButton::setBackgroundPixmap(const QPixmap &newBackground)
240{
241 pixBackground = newBackground;
242 pixBackgroundRed = makeRed(newBackground);
243 updateIcon();
244}
245
204QPixmap StelButton::makeRed(const QPixmap& p)246QPixmap StelButton::makeRed(const QPixmap& p)
205{247{
206 QImage im = p.toImage().convertToFormat(QImage::Format_ARGB32);248 QImage im = p.toImage().convertToFormat(QImage::Format_ARGB32);
@@ -314,9 +356,16 @@
314 }356 }
315}357}
316358
317BottomStelBar::BottomStelBar(QGraphicsItem* parent, const QPixmap& pixLeft, const QPixmap& pixRight,359BottomStelBar::BottomStelBar(QGraphicsItem* parent,
318 const QPixmap& pixMiddle, const QPixmap& pixSingle) : QGraphicsItem(parent), pixBackgroundLeft(pixLeft), pixBackgroundRight(pixRight),360 const QPixmap& pixLeft,
319 pixBackgroundMiddle(pixMiddle), pixBackgroundSingle(pixSingle)361 const QPixmap& pixRight,
362 const QPixmap& pixMiddle,
363 const QPixmap& pixSingle) :
364 QGraphicsItem(parent),
365 pixBackgroundLeft(pixLeft),
366 pixBackgroundRight(pixRight),
367 pixBackgroundMiddle(pixMiddle),
368 pixBackgroundSingle(pixSingle)
320{369{
321 // The text is dummy just for testing370 // The text is dummy just for testing
322 datetime = new QGraphicsSimpleTextItem("2008-02-06 17:33", this);371 datetime = new QGraphicsSimpleTextItem("2008-02-06 17:33", this);
@@ -359,17 +408,17 @@
359void BottomStelBar::addButton(StelButton* button, const QString& groupName, const QString& beforeActionName)408void BottomStelBar::addButton(StelButton* button, const QString& groupName, const QString& beforeActionName)
360{409{
361 QList<StelButton*>& g = buttonGroups[groupName].elems;410 QList<StelButton*>& g = buttonGroups[groupName].elems;
362 bool done=false;411 bool done = false;
363 for (int i=0;i<g.size();++i)412 for (int i=0; i<g.size(); ++i)
364 {413 {
365 if (g[i]->action && g[i]->action->objectName()==beforeActionName)414 if (g[i]->action && g[i]->action->objectName()==beforeActionName)
366 {415 {
367 g.insert(i, button);416 g.insert(i, button);
368 done=true;417 done = true;
369 break;418 break;
370 }419 }
371 }420 }
372 if (done==false)421 if (done == false)
373 g.append(button);422 g.append(button);
374423
375 button->setVisible(true);424 button->setVisible(true);
@@ -382,7 +431,7 @@
382StelButton* BottomStelBar::hideButton(const QString& actionName)431StelButton* BottomStelBar::hideButton(const QString& actionName)
383{432{
384 QString gName;433 QString gName;
385 StelButton* bToRemove=NULL;434 StelButton* bToRemove = NULL;
386 for (QMap<QString, ButtonGroup>::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter)435 for (QMap<QString, ButtonGroup>::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter)
387 {436 {
388 int i=0;437 int i=0;
@@ -390,7 +439,7 @@
390 {439 {
391 if (b->action && b->action->objectName()==actionName)440 if (b->action && b->action->objectName()==actionName)
392 {441 {
393 gName=iter.key();442 gName = iter.key();
394 bToRemove = b;443 bToRemove = b;
395 iter.value().elems.removeAt(i);444 iter.value().elems.removeAt(i);
396 break;445 break;
@@ -398,9 +447,9 @@
398 ++i;447 ++i;
399 }448 }
400 }449 }
401 if (bToRemove==NULL)450 if (bToRemove == NULL)
402 return NULL;451 return NULL;
403 if (buttonGroups[gName].elems.size()==0)452 if (buttonGroups[gName].elems.size() == 0)
404 {453 {
405 buttonGroups.remove(gName);454 buttonGroups.remove(gName);
406 }455 }
@@ -417,15 +466,18 @@
417{466{
418 if (!buttonGroups.contains(groupName))467 if (!buttonGroups.contains(groupName))
419 return;468 return;
420 buttonGroups[groupName].leftMargin=left;469 buttonGroups[groupName].leftMargin = left;
421 buttonGroups[groupName].rightMargin=right;470 buttonGroups[groupName].rightMargin = right;
422 updateButtonsGroups();471 updateButtonsGroups();
423}472}
424473
425//! Change the background of a group474//! Change the background of a group
426void BottomStelBar::setGroupBackground(const QString& groupName, const QPixmap& pixLeft,475void BottomStelBar::setGroupBackground(const QString& groupName,
427 const QPixmap& pixRight, const QPixmap& pixMiddle,476 const QPixmap& pixLeft,
428 const QPixmap& pixSingle){477 const QPixmap& pixRight,
478 const QPixmap& pixMiddle,
479 const QPixmap& pixSingle)
480{
429481
430 if (!buttonGroups.contains(groupName))482 if (!buttonGroups.contains(groupName))
431 return;483 return;
@@ -435,7 +487,6 @@
435 buttonGroups[groupName].pixBackgroundMiddle = new QPixmap(pixMiddle);487 buttonGroups[groupName].pixBackgroundMiddle = new QPixmap(pixMiddle);
436 buttonGroups[groupName].pixBackgroundSingle = new QPixmap(pixSingle);488 buttonGroups[groupName].pixBackgroundSingle = new QPixmap(pixSingle);
437 updateButtonsGroups();489 updateButtonsGroups();
438
439}490}
440491
441QRectF BottomStelBar::getButtonsBoundingRect() const492QRectF BottomStelBar::getButtonsBoundingRect() const
@@ -461,63 +512,65 @@
461512
462void BottomStelBar::updateButtonsGroups()513void BottomStelBar::updateButtonsGroups()
463{514{
464 double x=0;515 double x = 0;
465 double y = datetime->boundingRect().height()+3;516 double y = datetime->boundingRect().height() + 3;
466 for (QMap<QString, ButtonGroup >::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter)517 for (QMap<QString, ButtonGroup >::iterator iter=buttonGroups.begin();iter!=buttonGroups.end();++iter)
467 {518 {
468 if (iter.value().elems.empty())519 ButtonGroup& group = iter.value();
520 QList<StelButton*>& buttons = group.elems;
521 if (buttons.empty())
469 continue;522 continue;
470 x+=iter.value().leftMargin;523 x += group.leftMargin;
471 int n=0;524 int n = 0;
472 foreach (StelButton* b, iter.value().elems)525 foreach (StelButton* b, buttons)
473 {526 {
474 // We check if the group has its own background if not the case527 // We check if the group has its own background if not the case
475 // We apply a default background.528 // We apply a default background.
476 if (n==0)529 if (n == 0)
477 {530 {
478 if (iter.value().elems.size()==1)531 if (buttons.size() == 1)
479 {532 {
480 if (iter.value().pixBackgroundSingle == NULL)533 if (group.pixBackgroundSingle == NULL)
481 b->pixBackground = pixBackgroundSingle;534 b->setBackgroundPixmap(pixBackgroundSingle);
482 else535 else
483 b->pixBackground = *(iter.value().pixBackgroundSingle);536 b->setBackgroundPixmap(*group.pixBackgroundSingle);
484 }537 }
485 else538 else
486 {539 {
487 if (iter.value().pixBackgroundLeft == NULL)540 if (group.pixBackgroundLeft == NULL)
488 b->pixBackground = pixBackgroundLeft;541 b->setBackgroundPixmap(pixBackgroundLeft);
489 else542 else
490 b->pixBackground = *(iter.value().pixBackgroundLeft);543 b->setBackgroundPixmap(*group.pixBackgroundLeft);
491 }544 }
492 }545 }
493 else if (n==iter.value().elems.size()-1)546 else if (n == buttons.size()-1)
494 {547 {
495 if (iter.value().elems.size()!=1)548 if (buttons.size() != 1)
496 {549 {
497 if (iter.value().pixBackgroundSingle == NULL)550 if (group.pixBackgroundSingle == NULL)
498 b->pixBackground = pixBackgroundSingle;551 b->setBackgroundPixmap(pixBackgroundSingle);
499 else552 else
500 b->pixBackground = *(iter.value().pixBackgroundSingle);553 b->setBackgroundPixmap(*group.pixBackgroundSingle);
501 }554 }
502 if (iter.value().pixBackgroundRight == NULL)555 if (group.pixBackgroundRight == NULL)
503 b->pixBackground = pixBackgroundRight;556 b->setBackgroundPixmap(pixBackgroundRight);
504 else557 else
505 b->pixBackground = *(iter.value().pixBackgroundRight);558 b->setBackgroundPixmap(*group.pixBackgroundRight);
506 }559 }
507 else560 else
508 {561 {
509 if (iter.value().pixBackgroundMiddle == NULL)562 if (group.pixBackgroundMiddle == NULL)
510 b->pixBackground = pixBackgroundMiddle;563 b->setBackgroundPixmap(pixBackgroundMiddle);
511 else564 else
512 b->pixBackground = *(iter.value().pixBackgroundMiddle);565 b->setBackgroundPixmap(*group.pixBackgroundMiddle);
513 }566 }
514 // Update the button pixmap567 // Update the button pixmap
515 b->animValueChanged(0.);568 b->animValueChanged(0.);
516 b->setPos(x, y);569 b->setPos(x, y);
517 x+=b->pixOn.width();570 x += b->getButtonPixmapWidth();
518 ++n;571 ++n;
519 }572 }
520 x+=iter.value().rightMargin;573 x+=group.rightMargin;
521 }574 }
522 updateText(true);575 updateText(true);
523}576}
524577
=== modified file 'src/gui/StelGuiItems.hpp'
--- src/gui/StelGuiItems.hpp 2010-05-09 20:23:43 +0000
+++ src/gui/StelGuiItems.hpp 2011-11-24 21:50:30 +0000
@@ -88,12 +88,21 @@
88 //! Get whether the button is checked88 //! Get whether the button is checked
89 int isChecked() const {return checked;}89 int isChecked() const {return checked;}
9090
91 //! Get the width of the button image.
92 //! The width is based on pixOn.
93 int getButtonPixmapWidth() const {return pixOn.width();}
94
91 //! Set the button opacity95 //! Set the button opacity
92 void setOpacity(double v) {opacity=v; updateIcon();}96 void setOpacity(double v) {opacity=v; updateIcon();}
9397
94 //! Activate red mode for this button, i.e. will reduce the non red color component of the icon98 //! Activate red mode for this button, i.e. will reduce the non red color component of the icon
95 void setRedMode(bool b) {redMode=b; updateIcon();}99 void setRedMode(bool b) {redMode=b; updateIcon();}
96100
101 //! Set the background pixmap of the button.
102 //! A variant for night vision mode (pixBackgroundRed) is automatically
103 //! generated from the new background.
104 void setBackgroundPixmap(const QPixmap& newBackground);
105
97 //! Transform the pixmap so that it look red for night vision mode106 //! Transform the pixmap so that it look red for night vision mode
98 static QPixmap makeRed(const QPixmap& p);107 static QPixmap makeRed(const QPixmap& p);
99108