Merge lp:~stolowski/stellarium/oculars-barlow-lens into lp:stellarium
- oculars-barlow-lens
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Alexander Wolf |
Approved revision: | 5764 |
Merged at revision: | 5788 |
Proposed branch: | lp:~stolowski/stellarium/oculars-barlow-lens |
Merge into: | lp:stellarium |
Diff against target: |
1356 lines (+698/-26) 14 files modified
data/gui/nightStyle.css (+2/-2) data/gui/normalStyle.css (+2/-2) plugins/Oculars/src/Barlow.cpp (+92/-0) plugins/Oculars/src/Barlow.hpp (+53/-0) plugins/Oculars/src/CMakeLists.txt (+2/-1) plugins/Oculars/src/Ocular.cpp (+8/-5) plugins/Oculars/src/Ocular.hpp (+3/-2) plugins/Oculars/src/Oculars.cpp (+138/-5) plugins/Oculars/src/Oculars.hpp (+17/-2) plugins/Oculars/src/gui/OcularDialog.cpp (+64/-1) plugins/Oculars/src/gui/OcularDialog.hpp (+10/-1) plugins/Oculars/src/gui/OcularsGuiPanel.cpp (+139/-4) plugins/Oculars/src/gui/OcularsGuiPanel.hpp (+8/-1) plugins/Oculars/src/gui/ocularDialog.ui (+160/-0) |
To merge this branch: | bzr merge lp:~stolowski/stellarium/oculars-barlow-lens |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexander Wolf | Approve | ||
Review via email: mp+145210@code.launchpad.net |
Commit message
Implementation of barlow lens for Oculars plugin.
Description of the change
Implementation of barlow lens for Oculars plugin. Barlow lenses can be managed via ocular config dialog (see http://
This change introduces new "barlow" section in the settings file, but this section is optional. No barlow is defined by default (that was intended, but I can add one in the default .ini if desired, though this would affect only new installations).
Other than that, this patch introduces new strings for translators.
- 5764. By Paweł Stołowski
-
Reverted some unintended changes to the .ui file.
Alexander Wolf (alexwolf) : | # |
Preview Diff
1 | === modified file 'data/gui/nightStyle.css' |
2 | --- data/gui/nightStyle.css 2012-10-05 13:00:30 +0000 |
3 | +++ data/gui/nightStyle.css 2013-01-28 17:20:27 +0000 |
4 | @@ -235,11 +235,11 @@ |
5 | image: url(:/graphicGui/nv_searchButtonImage.png); |
6 | } |
7 | |
8 | -QPushButton#pushButtonMoveSensorUp, QPushButton#pushButtonMoveOcularUp, QPushButton#pushButtonMoveTelescopeUp { |
9 | +QPushButton#pushButtonMoveSensorUp, QPushButton#pushButtonMoveOcularUp, QPushButton#pushButtonMoveTelescopeUp, QPushButton#pushButtonMoveBarlowUp { |
10 | image: url(:/graphicGui/nv_spinup.png); |
11 | } |
12 | |
13 | -QPushButton#pushButtonMoveSensorDown, QPushButton#pushButtonMoveOcularDown, QPushButton#pushButtonMoveTelescopeDown { |
14 | +QPushButton#pushButtonMoveSensorDown, QPushButton#pushButtonMoveOcularDown, QPushButton#pushButtonMoveTelescopeDown, QPushButton#pushButtonMoveBarlowDown { |
15 | image: url(:/graphicGui/nv_spindown.png); |
16 | } |
17 | |
18 | |
19 | === modified file 'data/gui/normalStyle.css' |
20 | --- data/gui/normalStyle.css 2012-10-05 13:00:30 +0000 |
21 | +++ data/gui/normalStyle.css 2013-01-28 17:20:27 +0000 |
22 | @@ -243,11 +243,11 @@ |
23 | background-image: url(:/graphicGui/closeButton-hover.png); |
24 | } |
25 | |
26 | -QPushButton#pushButtonMoveSensorUp, QPushButton#pushButtonMoveOcularUp, QPushButton#pushButtonMoveTelescopeUp { |
27 | +QPushButton#pushButtonMoveSensorUp, QPushButton#pushButtonMoveOcularUp, QPushButton#pushButtonMoveTelescopeUp, QPushButton#pushButtonMoveBarlowUp { |
28 | image: url(:/graphicGui/spinup.png); |
29 | } |
30 | |
31 | -QPushButton#pushButtonMoveSensorDown, QPushButton#pushButtonMoveOcularDown, QPushButton#pushButtonMoveTelescopeDown { |
32 | +QPushButton#pushButtonMoveSensorDown, QPushButton#pushButtonMoveOcularDown, QPushButton#pushButtonMoveTelescopeDown, QPushButton#pushButtonMoveBarlowDown { |
33 | image: url(:/graphicGui/spindown.png); |
34 | } |
35 | |
36 | |
37 | === added file 'plugins/Oculars/src/Barlow.cpp' |
38 | --- plugins/Oculars/src/Barlow.cpp 1970-01-01 00:00:00 +0000 |
39 | +++ plugins/Oculars/src/Barlow.cpp 2013-01-28 17:20:27 +0000 |
40 | @@ -0,0 +1,92 @@ |
41 | +/* |
42 | + * Copyright (C) 2009 Timothy Reaves |
43 | + * Copytight (C) 2013 Pawel Stolowski |
44 | + * |
45 | + * This program is free software; you can redistribute it and/or |
46 | + * modify it under the terms of the GNU General Public License |
47 | + * as published by the Free Software Foundation; either version 2 |
48 | + * of the License, or (at your option) any later version. |
49 | + * |
50 | + * This program is distributed in the hope that it will be useful, |
51 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
52 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
53 | + * GNU General Public License for more details. |
54 | + * |
55 | + * You should have received a copy of the GNU General Public License |
56 | + * along with this program; if not, write to the Free Software |
57 | + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. |
58 | + */ |
59 | + |
60 | +#include "Barlow.hpp" |
61 | +#include <QSettings> |
62 | + |
63 | +Barlow::Barlow() |
64 | +{ |
65 | +} |
66 | + |
67 | +Barlow::Barlow(const QObject& other) |
68 | +{ |
69 | + this->m_multipler = other.property("multipler").toDouble(); |
70 | + this->m_name = other.property("name").toString(); |
71 | +} |
72 | + |
73 | +Barlow::~Barlow() |
74 | +{ |
75 | +} |
76 | + |
77 | +static QMap<int, QString> mapping; |
78 | +QMap<int, QString> Barlow::propertyMap() |
79 | +{ |
80 | + if(mapping.isEmpty()) { |
81 | + mapping = QMap<int, QString>(); |
82 | + mapping[0] = "name"; |
83 | + mapping[1] = "multipler"; |
84 | + } |
85 | + return mapping; |
86 | +} |
87 | + |
88 | +const QString Barlow::name() const |
89 | +{ |
90 | + return m_name; |
91 | +} |
92 | + |
93 | +void Barlow::setName(const QString& theValue) |
94 | +{ |
95 | + m_name = theValue; |
96 | +} |
97 | + |
98 | +double Barlow::multipler() const |
99 | +{ |
100 | + return m_multipler; |
101 | +} |
102 | + |
103 | +void Barlow::setMultipler(double theValue) |
104 | +{ |
105 | + m_multipler = theValue; |
106 | +} |
107 | + |
108 | +/* ********************************************************************* */ |
109 | +#if 0 |
110 | +#pragma mark - |
111 | +#pragma mark Static Methods |
112 | +#endif |
113 | +/* ********************************************************************* */ |
114 | + |
115 | +Barlow* Barlow:: barlowFromSettings(QSettings* theSettings, int barlowIndex) |
116 | +{ |
117 | + Barlow* barlow = new Barlow(); |
118 | + QString prefix = "barlow/" + QVariant(barlowIndex).toString() + "/"; |
119 | + |
120 | + barlow->setName(theSettings->value(prefix + "name", "").toString()); |
121 | + barlow->setMultipler(theSettings->value(prefix + "multipler", "1").toDouble()); |
122 | + |
123 | + return barlow; |
124 | +} |
125 | + |
126 | +Barlow* Barlow::barlowModel() |
127 | +{ |
128 | + Barlow* model = new Barlow(); |
129 | + model->setName("My Barlow"); |
130 | + model->setMultipler(2.0f); |
131 | + return model; |
132 | +} |
133 | |
134 | === added file 'plugins/Oculars/src/Barlow.hpp' |
135 | --- plugins/Oculars/src/Barlow.hpp 1970-01-01 00:00:00 +0000 |
136 | +++ plugins/Oculars/src/Barlow.hpp 2013-01-28 17:20:27 +0000 |
137 | @@ -0,0 +1,53 @@ |
138 | +/* |
139 | + * Copyright (C) 2009 Timothy Reaves |
140 | + * Copytight (C) 2013 Pawel Stolowski |
141 | + * |
142 | + * This program is free software; you can redistribute it and/or |
143 | + * modify it under the terms of the GNU General Public License |
144 | + * as published by the Free Software Foundation; either version 2 |
145 | + * of the License, or (at your option) any later version. |
146 | + * |
147 | + * This program is distributed in the hope that it will be useful, |
148 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
149 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
150 | + * GNU General Public License for more details. |
151 | + * |
152 | + * You should have received a copy of the GNU General Public License |
153 | + * along with this program; if not, write to the Free Software |
154 | + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. |
155 | + */ |
156 | + |
157 | +#ifndef BARLOW_HPP_ |
158 | +#define BARLOW_HPP_ |
159 | + |
160 | +#include <QObject> |
161 | +#include <QString> |
162 | +#include <QMap> |
163 | + |
164 | +class QSettings; |
165 | + |
166 | +class Barlow : public QObject |
167 | +{ |
168 | + Q_OBJECT |
169 | + Q_PROPERTY(QString name READ name WRITE setName) |
170 | + Q_PROPERTY(double multipler READ multipler WRITE setMultipler) |
171 | + |
172 | +public: |
173 | + Barlow(); |
174 | + Q_INVOKABLE Barlow(const QObject& other); |
175 | + virtual ~Barlow(); |
176 | + static Barlow* barlowFromSettings(QSettings* theSettings, int barlowIndex); |
177 | + static Barlow* barlowModel(); |
178 | + |
179 | + double multipler() const; |
180 | + void setMultipler(double theValue); |
181 | + const QString name() const; |
182 | + void setName(const QString& theValue); |
183 | + QMap<int, QString> propertyMap(); |
184 | + |
185 | +private: |
186 | + QString m_name; |
187 | + double m_multipler; |
188 | +}; |
189 | + |
190 | +#endif |
191 | |
192 | === modified file 'plugins/Oculars/src/CMakeLists.txt' |
193 | --- plugins/Oculars/src/CMakeLists.txt 2012-12-06 15:00:12 +0000 |
194 | +++ plugins/Oculars/src/CMakeLists.txt 2013-01-28 17:20:27 +0000 |
195 | @@ -9,6 +9,8 @@ |
196 | SET(Oculars_SRCS |
197 | CCD.hpp |
198 | CCD.cpp |
199 | + Barlow.hpp |
200 | + Barlow.cpp |
201 | Ocular.hpp |
202 | Ocular.cpp |
203 | Oculars.hpp |
204 | @@ -73,4 +75,3 @@ |
205 | SET_TARGET_PROPERTIES(Oculars-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN") |
206 | ADD_DEPENDENCIES(AllStaticPlugins Oculars-static) |
207 | ENDIF() |
208 | - |
209 | |
210 | === modified file 'plugins/Oculars/src/Ocular.cpp' |
211 | --- plugins/Oculars/src/Ocular.cpp 2012-01-11 10:50:37 +0000 |
212 | +++ plugins/Oculars/src/Ocular.cpp 2013-01-28 17:20:27 +0000 |
213 | @@ -18,6 +18,7 @@ |
214 | |
215 | #include "Ocular.hpp" |
216 | #include "Telescope.hpp" |
217 | +#include "Barlow.hpp" |
218 | |
219 | Ocular::Ocular() |
220 | { |
221 | @@ -57,27 +58,29 @@ |
222 | #pragma mark Instance Methods |
223 | #endif |
224 | /* ********************************************************************* */ |
225 | -double Ocular::actualFOV(Telescope *telescope) const |
226 | +double Ocular::actualFOV(Telescope *telescope, Barlow *barlow) const |
227 | { |
228 | + const double barlow_multipler = (barlow != NULL ? barlow->multipler() : 1.0f); |
229 | double actualFOV = 0.0; |
230 | if (m_binoculars) { |
231 | actualFOV = appearentFOV(); |
232 | } else if (fieldStop() > 0.0) { |
233 | - actualFOV = fieldStop() / telescope->focalLength() * 57.3; |
234 | + actualFOV = fieldStop() / (telescope->focalLength() * barlow_multipler) * 57.3; |
235 | } else { |
236 | //actualFOV = apparent / mag |
237 | - actualFOV = appearentFOV() / (telescope->focalLength() / effectiveFocalLength()); |
238 | + actualFOV = appearentFOV() / (telescope->focalLength() * barlow_multipler / effectiveFocalLength()); |
239 | } |
240 | return actualFOV; |
241 | } |
242 | |
243 | -double Ocular::magnification(Telescope *telescope) const |
244 | +double Ocular::magnification(Telescope *telescope, Barlow *barlow) const |
245 | { |
246 | double magnifiction = 0.0; |
247 | if (m_binoculars) { |
248 | magnifiction = effectiveFocalLength(); |
249 | } else { |
250 | - magnifiction = telescope->focalLength() / effectiveFocalLength(); |
251 | + const double barlow_multipler = (barlow != NULL ? barlow->multipler() : 1.0f); |
252 | + magnifiction = telescope->focalLength() * barlow_multipler / effectiveFocalLength(); |
253 | } |
254 | return magnifiction; |
255 | } |
256 | |
257 | === modified file 'plugins/Oculars/src/Ocular.hpp' |
258 | --- plugins/Oculars/src/Ocular.hpp 2012-01-11 10:50:37 +0000 |
259 | +++ plugins/Oculars/src/Ocular.hpp 2013-01-28 17:20:27 +0000 |
260 | @@ -25,6 +25,7 @@ |
261 | #include <QSettings> |
262 | |
263 | class Telescope; |
264 | +class Barlow; |
265 | |
266 | class Ocular : public QObject |
267 | { |
268 | @@ -52,8 +53,8 @@ |
269 | bool isBinoculars() const; |
270 | void setBinoculars(bool flag); |
271 | |
272 | - double actualFOV(Telescope *telescope) const; |
273 | - double magnification(Telescope *telescope) const; |
274 | + double actualFOV(Telescope *telescope, Barlow *barlow) const; |
275 | + double magnification(Telescope *telescope, Barlow *barlow) const; |
276 | QMap<int, QString> propertyMap(); |
277 | |
278 | private: |
279 | |
280 | === modified file 'plugins/Oculars/src/Oculars.cpp' |
281 | --- plugins/Oculars/src/Oculars.cpp 2013-01-07 13:54:44 +0000 |
282 | +++ plugins/Oculars/src/Oculars.cpp 2013-01-28 17:20:27 +0000 |
283 | @@ -119,14 +119,18 @@ |
284 | ccds = QList<CCD *>(); |
285 | oculars = QList<Ocular *>(); |
286 | telescopes = QList<Telescope *>(); |
287 | + barlows = QList<Barlow *> (); |
288 | + |
289 | ccdRotationSignalMapper = new QSignalMapper(this); |
290 | ccdsSignalMapper = new QSignalMapper(this); |
291 | ocularsSignalMapper = new QSignalMapper(this); |
292 | telescopesSignalMapper = new QSignalMapper(this); |
293 | + barlowSignalMapper = new QSignalMapper(this); |
294 | |
295 | selectedCCDIndex = -1; |
296 | selectedOcularIndex = -1; |
297 | selectedTelescopeIndex = -1; |
298 | + selectedBarlowIndex = -1; |
299 | |
300 | usageMessageLabelID = -1; |
301 | |
302 | @@ -157,6 +161,8 @@ |
303 | telescopes.clear(); |
304 | qDeleteAll(oculars); |
305 | oculars.clear(); |
306 | + qDeleteAll(barlows); |
307 | + barlows.clear(); |
308 | } |
309 | |
310 | QSettings* Oculars::appSettings() |
311 | @@ -186,6 +192,7 @@ |
312 | settings->remove("ccd"); |
313 | settings->remove("ocular"); |
314 | settings->remove("telescope"); |
315 | + settings->remove("barlow"); |
316 | int index = 0; |
317 | foreach(CCD* ccd, ccds) { |
318 | QString prefix = "ccd/" + QVariant(index).toString() + "/"; |
319 | @@ -218,9 +225,18 @@ |
320 | settings->setValue(prefix + "vFlip", telescope->isVFlipped()); |
321 | index++; |
322 | } |
323 | + index = 0; |
324 | + foreach(Barlow* barlow, barlows) { |
325 | + QString prefix = "barlow/" + QVariant(index).toString() + "/"; |
326 | + settings->setValue(prefix + "name", barlow->name()); |
327 | + settings->setValue(prefix + "multipler", barlow->multipler()); |
328 | + index++; |
329 | + } |
330 | + |
331 | settings->setValue("ocular_count", oculars.count()); |
332 | settings->setValue("telescope_count", telescopes.count()); |
333 | settings->setValue("ccd_count", ccds.count()); |
334 | + settings->setValue("barlow_count", barlows.count()); |
335 | settings->sync(); |
336 | } |
337 | |
338 | @@ -495,7 +511,23 @@ |
339 | selectedTelescopeIndex = 0; |
340 | } |
341 | |
342 | - ocularDialog = new OcularDialog(this, &ccds, &oculars, &telescopes); |
343 | + int barlowCount = settings->value("barlow_count", 0).toInt(); |
344 | + int actualBarlowCount = barlowCount; |
345 | + for (int index = 0; index<barlowCount; index++) { |
346 | + Barlow *newBarlow = Barlow::barlowFromSettings(settings, index); |
347 | + if (newBarlow != NULL) { |
348 | + barlows.append(newBarlow); |
349 | + } |
350 | + else { |
351 | + actualBarlowCount--; |
352 | + } |
353 | + } |
354 | + if (barlowCount > 0 && actualBarlowCount < barlowCount) |
355 | + { |
356 | + qWarning() << "The Oculars ini file appears to be corrupt; delete it."; |
357 | + } |
358 | + |
359 | + ocularDialog = new OcularDialog(this, &ccds, &oculars, &telescopes, &barlows); |
360 | initializeActivationActions(); |
361 | determineMaxEyepieceAngle(); |
362 | |
363 | @@ -822,6 +854,15 @@ |
364 | emit(selectedTelescopeChanged()); |
365 | } |
366 | |
367 | +void Oculars::decrementBarlowIndex() |
368 | +{ |
369 | + selectedBarlowIndex++; |
370 | + if (selectedBarlowIndex == barlows.count()) { |
371 | + selectedBarlowIndex = -1; |
372 | + } |
373 | + emit(selectedBarlowChanged()); |
374 | +} |
375 | + |
376 | void Oculars::displayPopupMenu() |
377 | { |
378 | QMenu* popup = new QMenu(&StelMainWindow::getInstance()); |
379 | @@ -877,6 +918,8 @@ |
380 | { |
381 | QMenu* submenu = addTelescopeSubmenu(popup); |
382 | popup->addMenu(submenu); |
383 | + submenu = addBarlowSubmenu(popup); |
384 | + popup->addMenu(submenu); |
385 | popup->addSeparator(); |
386 | } |
387 | |
388 | @@ -1029,6 +1072,21 @@ |
389 | emit(selectedTelescopeChanged()); |
390 | } |
391 | |
392 | +void Oculars::incrementBarlowIndex() |
393 | +{ |
394 | + selectedBarlowIndex++; |
395 | + if (selectedBarlowIndex == barlows.count()) { |
396 | + selectedBarlowIndex = -1; |
397 | + } |
398 | + emit(selectedBarlowChanged()); |
399 | +} |
400 | + |
401 | +void Oculars::disableBarlow() |
402 | +{ |
403 | + selectedBarlowIndex = -1; |
404 | + emit(selectedBarlowChanged()); |
405 | +} |
406 | + |
407 | void Oculars::rotateCCD(QString amount) |
408 | { |
409 | ccdRotationAngle += amount.toInt(); |
410 | @@ -1077,6 +1135,15 @@ |
411 | } |
412 | } |
413 | |
414 | +void Oculars::selectBarlowAtIndex(QString indexString) |
415 | +{ |
416 | + int index = indexString.toInt(); |
417 | + if (index > -2 && index < barlows.count()) { |
418 | + selectedBarlowIndex = index; |
419 | + emit(selectedBarlowChanged()); |
420 | + } |
421 | +} |
422 | + |
423 | void Oculars::toggleCCD(bool show) |
424 | { |
425 | //If there are no sensors... |
426 | @@ -1239,6 +1306,7 @@ |
427 | connect(this, SIGNAL(selectedOcularChanged()), this, SLOT(instrumentChanged())); |
428 | connect(this, SIGNAL(selectedTelescopeChanged()), this, SLOT(instrumentChanged())); |
429 | connect(this, SIGNAL(selectedTelescopeChanged()), this, SLOT(setScreenFOVForCCD())); |
430 | + connect(this, SIGNAL(selectedBarlowChanged()), this, SLOT(instrumentChanged())); |
431 | connect(ocularDialog, SIGNAL(requireSelectionChanged(bool)), this, SLOT(setRequireSelection(bool))); |
432 | connect(ocularDialog, SIGNAL(scaleImageCircleChanged(bool)), this, SLOT(setScaleImageCircle(bool))); |
433 | |
434 | @@ -1248,6 +1316,7 @@ |
435 | connect(ocularsSignalMapper, SIGNAL(mapped(QString)), this, SLOT(selectOcularAtIndex(QString))); |
436 | connect(telescopesSignalMapper, SIGNAL(mapped(QString)), this, SLOT(selectTelescopeAtIndex(QString))); |
437 | connect(telescopesSignalMapper, SIGNAL(mapped(QString)), this, SLOT(setScreenFOVForCCD())); |
438 | + connect(barlowSignalMapper, SIGNAL(mapped(QString)), this, SLOT(selectBarlowAtIndex(QString))); |
439 | } |
440 | |
441 | bool Oculars::isBinocularDefined() |
442 | @@ -1422,6 +1491,7 @@ |
443 | } |
444 | Ocular *ocular = oculars[selectedOcularIndex]; |
445 | Telescope *telescope = telescopes[selectedTelescopeIndex]; |
446 | + Barlow *barlow = selectedBarlowIndex >=0 ? barlows[selectedBarlowIndex] : NULL; |
447 | |
448 | // set up drawing |
449 | if (StelApp::getInstance().getVisionModeNight()) |
450 | @@ -1478,7 +1548,28 @@ |
451 | .arg(ocularFov); |
452 | renderer->drawText(TextParams(xPosition, yPosition, ocularFOVLabel)); |
453 | yPosition-=lineHeight; |
454 | - |
455 | + |
456 | + QString barlowNumberLabel; |
457 | + // Barlow lens |
458 | + if (barlow != NULL) // it's null if barlow is not selected (barlow index = -1) |
459 | + { |
460 | + QString barlowName = barlow->name(); |
461 | + if (barlowName.isEmpty()) |
462 | + { |
463 | + barlowNumberLabel = QString(q_("Barlow #%1")).arg(selectedBarlowIndex); |
464 | + } |
465 | + else |
466 | + { |
467 | + barlowNumberLabel = QString (q_("Barlow #%1: %2")).arg(selectedBarlowIndex).arg(barlowName); |
468 | + } |
469 | + } |
470 | + else |
471 | + { |
472 | + barlowNumberLabel = QString (q_("Barlow: none")); //FIXME |
473 | + } |
474 | + renderer->drawText(TextParams(xPosition, yPosition, barlowNumberLabel)); |
475 | + yPosition-=lineHeight; |
476 | + |
477 | // The telescope |
478 | QString telescopeNumberLabel; |
479 | QString telescopeName = telescope->name(); |
480 | @@ -1497,7 +1588,7 @@ |
481 | yPosition-=lineHeight; |
482 | |
483 | // General info |
484 | - double magnification = ((int)(ocular->magnification(telescope) * 10.0)) / 10.0; |
485 | + double magnification = ((int)(ocular->magnification(telescope, barlow) * 10.0)) / 10.0; |
486 | QString magString = QString::number(magnification); |
487 | magString.append(QChar(0x00D7));//Multiplication sign |
488 | QString magnificationLabel = QString(q_("Magnification: %1")) |
489 | @@ -1505,7 +1596,7 @@ |
490 | renderer->drawText(TextParams(xPosition, yPosition, magnificationLabel)); |
491 | yPosition-=lineHeight; |
492 | |
493 | - double fov = ((int)(ocular->actualFOV(telescope) * 10000.00)) / 10000.0; |
494 | + double fov = ((int)(ocular->actualFOV(telescope, barlow) * 10000.00)) / 10000.0; |
495 | QString fovString = QString::number(fov); |
496 | fovString.append(QChar(0x00B0));//Degree sign |
497 | QString fovLabel = QString(q_("FOV: %1")).arg(fovString); |
498 | @@ -1700,6 +1791,7 @@ |
499 | // core->setMaskType(StelProjector::MaskDisk); |
500 | Ocular *ocular = oculars[selectedOcularIndex]; |
501 | Telescope *telescope = NULL; |
502 | + Barlow *barlow = NULL; |
503 | // Only consider flip is we're not binoculars |
504 | if (ocular->isBinoculars()) |
505 | { |
506 | @@ -1708,12 +1800,14 @@ |
507 | } |
508 | else |
509 | { |
510 | + if (selectedBarlowIndex >= 0) |
511 | + barlow = barlows[selectedBarlowIndex]; |
512 | telescope = telescopes[selectedTelescopeIndex]; |
513 | core->setFlipHorz(telescope->isHFlipped()); |
514 | core->setFlipVert(telescope->isVFlipped()); |
515 | } |
516 | |
517 | - double actualFOV = ocular->actualFOV(telescope); |
518 | + double actualFOV = ocular->actualFOV(telescope, barlow); |
519 | // See if the mask was scaled; if so, correct the actualFOV. |
520 | if (useMaxEyepieceAngle && ocular->appearentFOV() > 0.0 && !ocular->isBinoculars()) { |
521 | actualFOV = maxEyepieceAngle * actualFOV / ocular->appearentFOV(); |
522 | @@ -1732,6 +1826,45 @@ |
523 | } |
524 | } |
525 | |
526 | +Barlow* Oculars::selectedBarlow() |
527 | +{ |
528 | + if (selectedBarlowIndex >= 0 && selectedBarlowIndex < barlows.count()) |
529 | + return barlows[selectedBarlowIndex]; |
530 | + return NULL; |
531 | +} |
532 | + |
533 | +QMenu* Oculars::addBarlowSubmenu(QMenu* parent) |
534 | +{ |
535 | + Q_ASSERT(parent); |
536 | + |
537 | + QMenu *submenu = new QMenu(q_("&Barlow"), parent); |
538 | + submenu->addAction(q_("&Previous barlow"), this, SLOT(decrementBarlowIndex())); |
539 | + submenu->addAction(q_("&Next barlow"), this, SLOT(incrementBarlowIndex())); |
540 | + submenu->addSeparator(); |
541 | + submenu->addAction(q_("None"), this, SLOT(disableBarlow())); |
542 | + |
543 | + for (int index = 0; index < barlows.count(); ++index) |
544 | + { |
545 | + QString label; |
546 | + if (index < 10) |
547 | + { |
548 | + label = QString("&%1: %2").arg(index).arg(barlows[index]->name()); |
549 | + } |
550 | + else |
551 | + { |
552 | + label = barlows[index]->name(); |
553 | + } |
554 | + QAction* action = submenu->addAction(label, barlowSignalMapper, SLOT(map())); |
555 | + if (index == selectedBarlowIndex) |
556 | + { |
557 | + action->setCheckable(true); |
558 | + action->setChecked(true); |
559 | + } |
560 | + barlowSignalMapper->setMapping(action, QString("%1").arg(index)); |
561 | + } |
562 | + return submenu; |
563 | +} |
564 | + |
565 | QMenu* Oculars::addTelescopeSubmenu(QMenu *parent) |
566 | { |
567 | Q_ASSERT(parent); |
568 | |
569 | === modified file 'plugins/Oculars/src/Oculars.hpp' |
570 | --- plugins/Oculars/src/Oculars.hpp 2012-08-12 12:26:44 +0000 |
571 | +++ plugins/Oculars/src/Oculars.hpp 2013-01-28 17:20:27 +0000 |
572 | @@ -26,6 +26,7 @@ |
573 | #include "CCD.hpp" |
574 | #include "Ocular.hpp" |
575 | #include "Telescope.hpp" |
576 | +#include "Barlow.hpp" |
577 | |
578 | #include <QFont> |
579 | #include <QSettings> |
580 | @@ -86,6 +87,7 @@ |
581 | void decrementCCDIndex(); |
582 | void decrementOcularIndex(); |
583 | void decrementTelescopeIndex(); |
584 | + void decrementBarlowIndex(); |
585 | void displayPopupMenu(); |
586 | //! This method is called with we detect that our hot key is pressed. It handles |
587 | //! determining if we should do anything - based on a selected object. |
588 | @@ -93,10 +95,13 @@ |
589 | void incrementCCDIndex(); |
590 | void incrementOcularIndex(); |
591 | void incrementTelescopeIndex(); |
592 | + void incrementBarlowIndex(); |
593 | + void disableBarlow(); |
594 | void rotateCCD(QString amount); //!< amount must be a number. |
595 | void selectCCDAtIndex(QString indexString); //!< indexString must be an integer, in the range of -1:ccds.count() |
596 | void selectOcularAtIndex(QString indexString); //!< indexString must be an integer, in the range of -1:oculars.count() |
597 | void selectTelescopeAtIndex(QString indexString); //!< indexString must be an integer, in the range of -1:telescopes.count() |
598 | + void selectBarlowAtIndex(QString indexString); //!< indexString must be an integer, in the range -1:barlows.count<() |
599 | //! Toggles the sensor frame overlay. |
600 | void toggleCCD(bool show); |
601 | //! Toggles the sensor frame overlay (overloaded for blind switching). |
602 | @@ -115,6 +120,7 @@ |
603 | void selectedCCDChanged(); |
604 | void selectedOcularChanged(); |
605 | void selectedTelescopeChanged(); |
606 | + void selectedBarlowChanged(); |
607 | |
608 | private slots: |
609 | //! Signifies a change in ocular or telescope. Sets new zoom level. |
610 | @@ -129,7 +135,7 @@ |
611 | private: |
612 | //! Set up the Qt actions needed to activate the plugin. |
613 | void initializeActivationActions(); |
614 | - |
615 | + |
616 | //! Returns TRUE if at least one bincular is defined. |
617 | bool isBinocularDefined(); |
618 | |
619 | @@ -168,16 +174,25 @@ |
620 | |
621 | void hideUsageMessageIfDisplayed(); |
622 | |
623 | + //! Creates the sub-menu listing barlow lenses in the pop-up menu |
624 | + QMenu* addBarlowSubmenu(QMenu* parent); |
625 | + |
626 | //! Creates the sub-menu listing telescopes in the pop-up menu. |
627 | QMenu* addTelescopeSubmenu(QMenu* parent); |
628 | |
629 | + //! Returns selected barlow,or NULL if no barlow is selected |
630 | + Barlow* selectedBarlow(); |
631 | + |
632 | //! A list of all the oculars defined in the ini file. Must have at least one, or module will not run. |
633 | QList<CCD *> ccds; |
634 | QList<Ocular *> oculars; |
635 | QList<Telescope *> telescopes; |
636 | + QList<Barlow *> barlows; |
637 | + |
638 | int selectedCCDIndex; //!< index of the current CCD, in the range of -1:ccds.count(). -1 means no CCD is selected. |
639 | int selectedOcularIndex; //!< index of the current ocular, in the range of -1:oculars.count(). -1 means no ocular is selected. |
640 | int selectedTelescopeIndex; //!< index of the current telescope, in the range of -1:telescopes.count(). -1 means none is selected. |
641 | + int selectedBarlowIndex; //!< index of the current barlow lends, in the range of -1:barlows.count(). -1 means no barlow is selected |
642 | |
643 | QFont font; //!< The font used for drawing labels. |
644 | bool flagShowCCD; //!< flag used to track f we are in CCD mode. |
645 | @@ -209,6 +224,7 @@ |
646 | QSignalMapper* ccdsSignalMapper; //!< Used to determine which CCD was selected from the popup navigator. */ |
647 | QSignalMapper* ocularsSignalMapper; //!< Used to determine which ocular was selected from the popup navigator. */ |
648 | QSignalMapper* telescopesSignalMapper; //!< Used to determine which telescope was selected from the popup navigator. */ |
649 | + QSignalMapper* barlowSignalMapper; //!< Used to determine which barlow was selected from the popup navigator */ |
650 | |
651 | // for toolbar button |
652 | QPixmap* pxmapGlow; |
653 | @@ -249,4 +265,3 @@ |
654 | }; |
655 | |
656 | #endif /*_OCULARS_HPP_*/ |
657 | - |
658 | |
659 | === modified file 'plugins/Oculars/src/gui/OcularDialog.cpp' |
660 | --- plugins/Oculars/src/gui/OcularDialog.cpp 2012-08-14 05:48:00 +0000 |
661 | +++ plugins/Oculars/src/gui/OcularDialog.cpp 2013-01-28 17:20:27 +0000 |
662 | @@ -38,7 +38,7 @@ |
663 | #include <QStandardItemModel> |
664 | #include <limits> |
665 | |
666 | -OcularDialog::OcularDialog(Oculars* pluginPtr, QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes) : |
667 | +OcularDialog::OcularDialog(Oculars* pluginPtr, QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes, QList<Barlow *>* barlows) : |
668 | plugin(pluginPtr) |
669 | { |
670 | ui = new Ui_ocularDialogForm; |
671 | @@ -60,12 +60,18 @@ |
672 | telescopeModel, |
673 | telescopeModel->propertyMap()); |
674 | |
675 | + this->barlows = barlows; |
676 | + barlowTableModel = new PropertyBasedTableModel(this); |
677 | + Barlow* barlowModel = Barlow::barlowModel(); |
678 | + barlowTableModel->init(reinterpret_cast<QList<QObject *>* >(barlows), barlowModel, barlowModel->propertyMap()); |
679 | + |
680 | validatorPositiveInt = new QIntValidator(0, std::numeric_limits<int>::max(), this); |
681 | validatorPositiveDouble = new QDoubleValidator(.0, std::numeric_limits<double>::max(), 24, this); |
682 | validatorOcularAFOV = new QDoubleValidator(1.0, 120.0, 1, this); |
683 | validatorOcularEFL = new QDoubleValidator(1.0, 60.0, 1, this); |
684 | validatorTelescopeDiameter = new QDoubleValidator(1.0, 1000.0, 1, this); |
685 | validatorTelescopeFL = new QDoubleValidator(1.0, 10000.0, 1, this); |
686 | + validatorBarlowMultipler = new QDoubleValidator(1.0, 6.0, 1, this); |
687 | QRegExp nameExp("^\\S.*"); |
688 | validatorName = new QRegExpValidator(nameExp, this); |
689 | } |
690 | @@ -146,6 +152,17 @@ |
691 | } |
692 | } |
693 | |
694 | +void OcularDialog::deleteSelectedBarlow() |
695 | +{ |
696 | + if (barlowTableModel->rowCount() > 0) { |
697 | + barlowTableModel->removeRows(ui->barlowListView->currentIndex().row(), 1); |
698 | + if (barlowTableModel->rowCount() > 0) { |
699 | + ui->barlowListView->setCurrentIndex(barlowTableModel->index(0, 1)); |
700 | + } |
701 | + plugin->updateLists(); |
702 | + } |
703 | +} |
704 | + |
705 | void OcularDialog::insertNewCCD() |
706 | { |
707 | ccdTableModel->insertRows(ccdTableModel->rowCount(), 1); |
708 | @@ -164,6 +181,12 @@ |
709 | ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(telescopeTableModel->rowCount() - 1, 1)); |
710 | } |
711 | |
712 | +void OcularDialog::insertNewBarlow() |
713 | +{ |
714 | + barlowTableModel->insertRows(barlowTableModel->rowCount(), 1); |
715 | + ui->barlowListView->setCurrentIndex(barlowTableModel->index(barlowTableModel->rowCount() - 1, 1)); |
716 | +} |
717 | + |
718 | void OcularDialog::moveUpSelectedSensor() |
719 | { |
720 | int index = ui->ccdListView->currentIndex().row(); |
721 | @@ -194,6 +217,16 @@ |
722 | } |
723 | } |
724 | |
725 | +void OcularDialog::moveUpSelectedBarlow() |
726 | +{ |
727 | + int index = ui->barlowListView->currentIndex().row(); |
728 | + if (index > 0) |
729 | + { |
730 | + barlowTableModel->moveRowUp(index); |
731 | + plugin->updateLists(); |
732 | + } |
733 | +} |
734 | + |
735 | void OcularDialog::moveDownSelectedSensor() |
736 | { |
737 | int index = ui->ccdListView->currentIndex().row(); |
738 | @@ -224,6 +257,16 @@ |
739 | } |
740 | } |
741 | |
742 | +void OcularDialog::moveDownSelectedBarlow() |
743 | +{ |
744 | + int index = ui->barlowListView->currentIndex().row(); |
745 | + if (index >= 0 && index < barlowTableModel->rowCount() - 1) |
746 | + { |
747 | + barlowTableModel->moveRowDown(index); |
748 | + plugin->updateLists(); |
749 | + } |
750 | +} |
751 | + |
752 | /* ********************************************************************* */ |
753 | #if 0 |
754 | #pragma mark - |
755 | @@ -288,6 +331,7 @@ |
756 | ui->ccdListView->setModel(ccdTableModel); |
757 | ui->ocularListView->setModel(ocularTableModel); |
758 | ui->telescopeListView->setModel(telescopeTableModel); |
759 | + ui->barlowListView->setModel(barlowTableModel); |
760 | |
761 | //Now the rest of the actions. |
762 | connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); |
763 | @@ -301,6 +345,8 @@ |
764 | connect(ui->deleteCCD, SIGNAL(clicked()), this, SLOT(deleteSelectedCCD())); |
765 | connect(ui->addOcular, SIGNAL(clicked()), this, SLOT(insertNewOcular())); |
766 | connect(ui->deleteOcular, SIGNAL(clicked()), this, SLOT(deleteSelectedOcular())); |
767 | + connect(ui->addBarlow, SIGNAL(clicked()), this, SLOT(insertNewBarlow())); |
768 | + connect(ui->deleteBarlow, SIGNAL(clicked()), this, SLOT(deleteSelectedBarlow())); |
769 | connect(ui->addTelescope, SIGNAL(clicked()), this, SLOT(insertNewTelescope())); |
770 | connect(ui->deleteTelescope, SIGNAL(clicked()), this, SLOT(deleteSelectedTelescope())); |
771 | |
772 | @@ -319,6 +365,8 @@ |
773 | ui->telescopeDiameter->setValidator(validatorTelescopeDiameter); |
774 | ui->ocularName->setValidator(validatorName); |
775 | ui->telescopeName->setValidator(validatorName); |
776 | + ui->barlowName->setValidator(validatorName); |
777 | + ui->barlowMultipler->setValidator(validatorBarlowMultipler); |
778 | |
779 | // The key bindings |
780 | QString bindingString = Oculars::appSettings()->value("bindings/toggle_oculars", "Ctrl+O").toString(); |
781 | @@ -348,6 +396,10 @@ |
782 | this, SLOT(moveUpSelectedTelescope())); |
783 | connect(ui->pushButtonMoveTelescopeDown, SIGNAL(pressed()), |
784 | this, SLOT(moveDownSelectedTelescope())); |
785 | + connect(ui->pushButtonMoveBarlowUp, SIGNAL(pressed()), |
786 | + this, SLOT(moveUpSelectedBarlow())); |
787 | + connect(ui->pushButtonMoveBarlowDown, SIGNAL(pressed()), |
788 | + this, SLOT(moveDownSelectedBarlow())); |
789 | |
790 | // The CCD mapper |
791 | ccdMapper = new QDataWidgetMapper(); |
792 | @@ -379,6 +431,17 @@ |
793 | ocularMapper, SLOT(setCurrentModelIndex(QModelIndex))); |
794 | ui->ocularListView->setCurrentIndex(ocularTableModel->index(0, 1)); |
795 | |
796 | + // The barlow lens mapper |
797 | + barlowMapper = new QDataWidgetMapper(); |
798 | + barlowMapper->setModel(barlowTableModel); |
799 | + barlowMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit); |
800 | + barlowMapper->addMapping(ui->barlowName, 0); |
801 | + barlowMapper->addMapping(ui->barlowMultipler, 1); |
802 | + barlowMapper->toFirst(); |
803 | + connect(ui->barlowListView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), |
804 | + barlowMapper, SLOT(setCurrentModelIndex(QModelIndex))); |
805 | + ui->barlowListView->setCurrentIndex(barlowTableModel->index(0, 1)); |
806 | + |
807 | // The telescope mapper |
808 | telescopeMapper = new QDataWidgetMapper(); |
809 | telescopeMapper->setModel(telescopeTableModel); |
810 | |
811 | === modified file 'plugins/Oculars/src/gui/OcularDialog.hpp' |
812 | --- plugins/Oculars/src/gui/OcularDialog.hpp 2012-04-01 21:12:29 +0000 |
813 | +++ plugins/Oculars/src/gui/OcularDialog.hpp 2013-01-28 17:20:27 +0000 |
814 | @@ -27,6 +27,7 @@ |
815 | #include "StelDialog.hpp" |
816 | #include "StelStyle.hpp" |
817 | #include "Telescope.hpp" |
818 | +#include "Barlow.hpp" |
819 | |
820 | class Ui_ocularDialogForm; |
821 | |
822 | @@ -46,7 +47,7 @@ |
823 | Q_OBJECT |
824 | |
825 | public: |
826 | - OcularDialog(Oculars* plugin, QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes); |
827 | + OcularDialog(Oculars* plugin, QList<CCD *>* ccds, QList<Ocular *>* oculars, QList<Telescope *>* telescopes, QList<Barlow *>* barlows); |
828 | virtual ~OcularDialog(); |
829 | //! Notify that the application style changed |
830 | void styleChanged(); |
831 | @@ -57,15 +58,19 @@ |
832 | void deleteSelectedCCD(); |
833 | void deleteSelectedOcular(); |
834 | void deleteSelectedTelescope(); |
835 | + void deleteSelectedBarlow(); |
836 | void insertNewCCD(); |
837 | void insertNewOcular(); |
838 | void insertNewTelescope(); |
839 | + void insertNewBarlow(); |
840 | void moveUpSelectedSensor(); |
841 | void moveUpSelectedOcular(); |
842 | void moveUpSelectedTelescope(); |
843 | + void moveUpSelectedBarlow(); |
844 | void moveDownSelectedSensor(); |
845 | void moveDownSelectedOcular(); |
846 | void moveDownSelectedTelescope(); |
847 | + void moveDownSelectedBarlow(); |
848 | void retranslate(); |
849 | |
850 | signals: |
851 | @@ -96,10 +101,14 @@ |
852 | QDataWidgetMapper* telescopeMapper; |
853 | QList<Telescope *>* telescopes; |
854 | PropertyBasedTableModel* telescopeTableModel; |
855 | + QDataWidgetMapper* barlowMapper; |
856 | + QList<Barlow *>* barlows; |
857 | + PropertyBasedTableModel* barlowTableModel; |
858 | QDoubleValidator* validatorOcularAFOV; |
859 | QDoubleValidator* validatorOcularEFL; |
860 | QDoubleValidator* validatorTelescopeDiameter; |
861 | QDoubleValidator* validatorTelescopeFL; |
862 | + QDoubleValidator* validatorBarlowMultipler; |
863 | QRegExpValidator* validatorName; |
864 | QIntValidator* validatorPositiveInt; |
865 | QDoubleValidator* validatorPositiveDouble; |
866 | |
867 | === modified file 'plugins/Oculars/src/gui/OcularsGuiPanel.cpp' |
868 | --- plugins/Oculars/src/gui/OcularsGuiPanel.cpp 2012-07-06 17:00:39 +0000 |
869 | +++ plugins/Oculars/src/gui/OcularsGuiPanel.cpp 2013-01-28 17:20:27 +0000 |
870 | @@ -130,6 +130,9 @@ |
871 | ocularControls = new QGraphicsWidget(this); |
872 | ocularControls->setParentItem(this); |
873 | ocularControls->setVisible(false); |
874 | + barlowControls = new QGraphicsWidget(this); |
875 | + barlowControls->setParentItem(this); |
876 | + barlowControls->setVisible(false); |
877 | ccdControls = new QGraphicsWidget(this); |
878 | ccdControls->setParentItem(this); |
879 | ccdControls->setVisible(false); |
880 | @@ -147,6 +150,9 @@ |
881 | fieldMagnification = new QGraphicsTextItem(telescopeControls); |
882 | fieldFov = new QGraphicsTextItem(telescopeControls); |
883 | |
884 | + fieldBarlowName = new QGraphicsTextItem(barlowControls); |
885 | + fieldBarlowMultipler = new QGraphicsTextItem(barlowControls); |
886 | + |
887 | QFont newFont = font(); |
888 | newFont.setPixelSize(12); |
889 | setControlsFont(newFont); |
890 | @@ -167,6 +173,9 @@ |
891 | fieldMagnification->setTextWidth(maxWidth); |
892 | fieldFov->setTextWidth(maxWidth); |
893 | |
894 | + fieldBarlowName->setTextWidth(maxWidth); |
895 | + fieldBarlowMultipler->setTextWidth(maxWidth); |
896 | + |
897 | QPixmap pa(":/graphicGui/btTimeRewind-on.png"); |
898 | QPixmap prevArrow = pa.scaledToHeight(lineHeight, Qt::SmoothTransformation); |
899 | QPixmap paOff(":/graphicGui/btTimeRewind-off.png"); |
900 | @@ -190,6 +199,18 @@ |
901 | QPixmap(), |
902 | defaultAction); |
903 | nextOcularButton->setToolTip(q_("Next ocular")); |
904 | + prevBarlowButton = new StelButton(barlowControls, |
905 | + prevArrow, |
906 | + prevArrowOff, |
907 | + QPixmap(), |
908 | + defaultAction); |
909 | + prevBarlowButton->setToolTip(q_("Previous Barlow lens")); |
910 | + nextBarlowButton = new StelButton(barlowControls, |
911 | + nextArrow, |
912 | + nextArrowOff, |
913 | + QPixmap(), |
914 | + defaultAction); |
915 | + nextBarlowButton->setToolTip(q_("Next Barlow lens")); |
916 | prevCcdButton = new StelButton(ccdControls, |
917 | prevArrow, |
918 | prevArrowOff, |
919 | @@ -227,6 +248,10 @@ |
920 | ocularsPlugin, SLOT(decrementCCDIndex())); |
921 | connect(prevTelescopeButton, SIGNAL(triggered()), |
922 | ocularsPlugin, SLOT(decrementTelescopeIndex())); |
923 | + connect(nextBarlowButton, SIGNAL(triggered()), |
924 | + ocularsPlugin, SLOT(incrementBarlowIndex())); |
925 | + connect(prevBarlowButton, SIGNAL(triggered()), |
926 | + ocularsPlugin, SLOT(decrementBarlowIndex())); |
927 | |
928 | QColor cOn(255, 255, 255); |
929 | QColor cOff(102, 102, 102); |
930 | @@ -368,6 +393,7 @@ |
931 | ocularControls->setMaximumWidth(width); |
932 | ccdControls->setMaximumWidth(width); |
933 | telescopeControls->setMaximumWidth(width); |
934 | + barlowControls->setMaximumWidth(width); |
935 | resize(width + left + right, 10); |
936 | buttonBar->resize(width, size().height()); |
937 | updateMainButtonsPositions(); |
938 | @@ -394,6 +420,8 @@ |
939 | this, SLOT(updateCcdControls())); |
940 | connect(ocularsPlugin, SIGNAL(selectedTelescopeChanged()), |
941 | this, SLOT(updateTelescopeControls())); |
942 | + connect(ocularsPlugin, SIGNAL(selectedBarlowChanged()), |
943 | + this, SLOT(updateTelescopeControls())); |
944 | |
945 | //Night mode |
946 | connect(&stelApp, SIGNAL(colorSchemeChanged(const QString&)), |
947 | @@ -418,6 +446,7 @@ |
948 | { |
949 | setOcularControlsVisible(false); |
950 | setTelescopeControlsVisible(false); |
951 | + setBarlowControlsVisible(false); |
952 | updatePosition(); |
953 | } |
954 | } |
955 | @@ -433,6 +462,7 @@ |
956 | setOcularControlsVisible(false); |
957 | setCcdControlsVisible(false); |
958 | setTelescopeControlsVisible(false); |
959 | + setBarlowControlsVisible(false); |
960 | updatePosition(); |
961 | } |
962 | |
963 | @@ -545,6 +575,76 @@ |
964 | updateTelescopeControls();//Contains a call to updatePosition() |
965 | } |
966 | |
967 | +void OcularsGuiPanel::updateBarlowControls() |
968 | +{ |
969 | + if (ocularsPlugin->flagShowCCD) |
970 | + { |
971 | + setBarlowControlsVisible(false); |
972 | + return; |
973 | + } |
974 | + int index = ocularsPlugin->selectedOcularIndex; |
975 | + Ocular* ocular = ocularsPlugin->oculars[index]; |
976 | + |
977 | + Barlow* barlow = ocularsPlugin->selectedBarlow(); |
978 | + index = ocularsPlugin->selectedBarlowIndex; |
979 | + |
980 | + QString fullName; |
981 | + QString multiplerString; |
982 | + if (barlow != NULL) |
983 | + { |
984 | + QString name = barlow->name(); |
985 | + if (name.isEmpty()) |
986 | + { |
987 | + fullName = QString(q_("Barlow #%1")).arg(index); |
988 | + } |
989 | + else |
990 | + { |
991 | + fullName = QString(q_("Barlow #%1: %2")).arg(index).arg(name); |
992 | + } |
993 | + multiplerString = QString(q_("Multiplicity: %1")).arg(barlow->multipler()); |
994 | + multiplerString.append(QChar(0x00D7)); |
995 | + } |
996 | + else |
997 | + { |
998 | + fullName = QString(q_("Barlow: None")); |
999 | + multiplerString = QString(q_("Multiplicity: N/A")); |
1000 | + } |
1001 | + fieldBarlowName->setPlainText(fullName); |
1002 | + fieldBarlowMultipler->setPlainText(multiplerString); |
1003 | + fieldOcularFl->setToolTip(q_("Multiplicity of barlow lens")); |
1004 | + |
1005 | + qreal posX = 0.; |
1006 | + qreal posY = 0.; |
1007 | + qreal widgetWidth = 0.; |
1008 | + qreal widgetHeight = 0.; |
1009 | + |
1010 | + //Prev button |
1011 | + qreal heightAdjustment = (fieldBarlowName->boundingRect().height() - prevBarlowButton->boundingRect().height()) / 2.; |
1012 | + prevBarlowButton->setPos(posX, round(posY + heightAdjustment)); |
1013 | + posX += prevBarlowButton->boundingRect().width(); |
1014 | + widgetWidth += prevBarlowButton->boundingRect().width(); |
1015 | + |
1016 | + //Name field |
1017 | + fieldBarlowName->setPos(posX, posY); |
1018 | + posX += fieldBarlowName->boundingRect().width(); |
1019 | + widgetWidth += fieldBarlowName->boundingRect().width(); |
1020 | + widgetHeight += fieldBarlowName->boundingRect().height(); |
1021 | + |
1022 | + //Next button |
1023 | + nextBarlowButton->setPos(posX, posY + heightAdjustment); |
1024 | + widgetWidth += nextBarlowButton->boundingRect().width(); |
1025 | + |
1026 | + posX = prevBarlowButton->boundingRect().width(); |
1027 | + posY += fieldBarlowName->boundingRect().height(); |
1028 | + fieldBarlowMultipler->setPos(posX, posY); |
1029 | + widgetHeight += fieldBarlowMultipler->boundingRect().height(); |
1030 | + |
1031 | + barlowControls->setMinimumSize(widgetWidth, widgetHeight); |
1032 | + barlowControls->resize(widgetWidth, widgetHeight); |
1033 | + |
1034 | + setBarlowControlsVisible(true); |
1035 | +} |
1036 | + |
1037 | void OcularsGuiPanel::updateCcdControls() |
1038 | { |
1039 | setOcularControlsVisible(false); |
1040 | @@ -702,6 +802,8 @@ |
1041 | int index = ocularsPlugin->selectedOcularIndex; |
1042 | Ocular* ocular = ocularsPlugin->oculars[index]; |
1043 | Q_ASSERT(ocular); |
1044 | + |
1045 | + Barlow *barlow = ocularsPlugin->selectedBarlow(); |
1046 | |
1047 | if (ocular->isBinoculars()) |
1048 | { |
1049 | @@ -720,12 +822,12 @@ |
1050 | nextTelescopeButton->setVisible(true); |
1051 | fieldTelescopeName->setVisible(true); |
1052 | |
1053 | - fieldMagnification->setToolTip(q_("Magnification provided by this ocular/telescope combination")); |
1054 | - fieldFov->setToolTip(q_("Actual field of view provided by this ocular/telescope combination")); |
1055 | + fieldMagnification->setToolTip(q_("Magnification provided by this ocular/barlow/telescope combination")); |
1056 | + fieldFov->setToolTip(q_("Actual field of view provided by this ocular/barlow/telescope combination")); |
1057 | } |
1058 | |
1059 | //WTF? Rounding? |
1060 | - double magnification = ((int)(ocular->magnification(telescope) * 10.0)) / 10.0; |
1061 | + double magnification = ((int)(ocular->magnification(telescope, barlow) * 10.0)) / 10.0; |
1062 | QString magnificationString = QString::number(magnification); |
1063 | magnificationString.append(QChar(0x00D7)); |
1064 | QString magnificationLabel = QString(q_("Magnification: %1")) |
1065 | @@ -735,7 +837,7 @@ |
1066 | posY += fieldMagnification->boundingRect().height(); |
1067 | widgetHeight += fieldMagnification->boundingRect().height(); |
1068 | |
1069 | - double fov = ((int)(ocular->actualFOV(telescope) * 10000.00)) / 10000.0; |
1070 | + double fov = ((int)(ocular->actualFOV(telescope, barlow) * 10000.00)) / 10000.0; |
1071 | QString fovString = QString::number(fov) + QChar(0x00B0); |
1072 | QString fovLabel = QString(q_("FOV: %1")).arg(fovString); |
1073 | fieldFov->setPlainText(fovLabel); |
1074 | @@ -759,9 +861,34 @@ |
1075 | telescopeControls->resize(widgetWidth, widgetHeight); |
1076 | setTelescopeControlsVisible(true); |
1077 | |
1078 | + updateBarlowControls(); |
1079 | updatePosition(); |
1080 | } |
1081 | |
1082 | +void OcularsGuiPanel::setBarlowControlsVisible(bool show) |
1083 | +{ |
1084 | + if (show) |
1085 | + { |
1086 | + if (!barlowControls->isVisible()) |
1087 | + { |
1088 | + barlowControls->setVisible(true); |
1089 | + mainLayout->insertItem(2, barlowControls); |
1090 | + } |
1091 | + } |
1092 | + else |
1093 | + { |
1094 | + if (barlowControls->isVisible()) |
1095 | + { |
1096 | + mainLayout->removeItem(barlowControls); |
1097 | + barlowControls->setVisible(false); |
1098 | + } |
1099 | + } |
1100 | + mainLayout->invalidate(); |
1101 | + mainLayout->activate(); |
1102 | + resize(mainLayout->geometry().width(), |
1103 | + mainLayout->geometry().height()); |
1104 | +} |
1105 | + |
1106 | void OcularsGuiPanel::setOcularControlsVisible(bool show) |
1107 | { |
1108 | if (show) |
1109 | @@ -881,6 +1008,8 @@ |
1110 | Q_ASSERT(fieldTelescopeName); |
1111 | Q_ASSERT(fieldMagnification); |
1112 | Q_ASSERT(fieldFov); |
1113 | + Q_ASSERT(fieldBarlowName); |
1114 | + Q_ASSERT(fieldBarlowMultipler); |
1115 | |
1116 | fieldOcularName->setDefaultTextColor(color); |
1117 | fieldOcularFl->setDefaultTextColor(color); |
1118 | @@ -891,6 +1020,8 @@ |
1119 | fieldTelescopeName->setDefaultTextColor(color); |
1120 | fieldMagnification->setDefaultTextColor(color); |
1121 | fieldFov->setDefaultTextColor(color); |
1122 | + fieldBarlowName->setDefaultTextColor(color); |
1123 | + fieldBarlowMultipler->setDefaultTextColor(color); |
1124 | } |
1125 | |
1126 | void OcularsGuiPanel::setControlsFont(const QFont& font) |
1127 | @@ -904,6 +1035,8 @@ |
1128 | Q_ASSERT(fieldTelescopeName); |
1129 | Q_ASSERT(fieldMagnification); |
1130 | Q_ASSERT(fieldFov); |
1131 | + Q_ASSERT(fieldBarlowName); |
1132 | + Q_ASSERT(fieldBarlowMultipler); |
1133 | |
1134 | fieldOcularName->setFont(font); |
1135 | fieldOcularFl->setFont(font); |
1136 | @@ -914,6 +1047,8 @@ |
1137 | fieldTelescopeName->setFont(font); |
1138 | fieldMagnification->setFont(font); |
1139 | fieldFov->setFont(font); |
1140 | + fieldBarlowName->setFont(font); |
1141 | + fieldBarlowMultipler->setFont(font); |
1142 | } |
1143 | |
1144 | void OcularsGuiPanel::setButtonsNightMode(bool nightMode) |
1145 | |
1146 | === modified file 'plugins/Oculars/src/gui/OcularsGuiPanel.hpp' |
1147 | --- plugins/Oculars/src/gui/OcularsGuiPanel.hpp 2012-01-11 10:50:37 +0000 |
1148 | +++ plugins/Oculars/src/gui/OcularsGuiPanel.hpp 2013-01-28 17:20:27 +0000 |
1149 | @@ -61,7 +61,8 @@ |
1150 | //! Updates the information that depends on the current telescope. |
1151 | //! Called in both updateOcularControls() and updateCcdControls(). |
1152 | void updateTelescopeControls(); |
1153 | - |
1154 | + //! Updates the information that depends on the current barlow |
1155 | + void updateBarlowControls(); |
1156 | //! Sets the color scheme (day/night mode) |
1157 | void setColorScheme(const QString& schemeName); |
1158 | |
1159 | @@ -78,6 +79,7 @@ |
1160 | //! Mini-toolbar holding StelButtons |
1161 | QGraphicsWidget* buttonBar; |
1162 | QGraphicsWidget* ocularControls; |
1163 | + QGraphicsWidget* barlowControls; |
1164 | QGraphicsWidget* ccdControls; |
1165 | QGraphicsWidget* telescopeControls; |
1166 | |
1167 | @@ -95,6 +97,10 @@ |
1168 | StelButton* nextTelescopeButton; |
1169 | StelButton* prevCcdButton; |
1170 | StelButton* nextCcdButton; |
1171 | + StelButton* prevBarlowButton; |
1172 | + StelButton* nextBarlowButton; |
1173 | + QGraphicsTextItem* fieldBarlowName; |
1174 | + QGraphicsTextItem* fieldBarlowMultipler; |
1175 | QGraphicsTextItem* fieldOcularName; |
1176 | QGraphicsTextItem* fieldOcularFl; |
1177 | QGraphicsTextItem* fieldOcularAfov; |
1178 | @@ -118,6 +124,7 @@ |
1179 | void setOcularControlsVisible(bool show); |
1180 | void setCcdControlsVisible(bool show); |
1181 | void setTelescopeControlsVisible(bool show); |
1182 | + void setBarlowControlsVisible(bool show); |
1183 | //! Updates the positions of the buttons inside the button bar. |
1184 | void updateMainButtonsPositions(); |
1185 | |
1186 | |
1187 | === modified file 'plugins/Oculars/src/gui/ocularDialog.ui' |
1188 | --- plugins/Oculars/src/gui/ocularDialog.ui 2012-08-10 14:45:17 +0000 |
1189 | +++ plugins/Oculars/src/gui/ocularDialog.ui 2013-01-28 17:20:27 +0000 |
1190 | @@ -596,6 +596,166 @@ |
1191 | </item> |
1192 | </layout> |
1193 | </widget> |
1194 | + <widget class="QWidget" name="tab"> |
1195 | + <attribute name="title"> |
1196 | + <string>Barlow lenses</string> |
1197 | + </attribute> |
1198 | + <layout class="QHBoxLayout" name="horizontalLayout_4"> |
1199 | + <item> |
1200 | + <layout class="QVBoxLayout" name="verticalLayout_10"> |
1201 | + <item> |
1202 | + <widget class="QLabel" name="label_6"> |
1203 | + <property name="text"> |
1204 | + <string>Barlows</string> |
1205 | + </property> |
1206 | + </widget> |
1207 | + </item> |
1208 | + <item> |
1209 | + <widget class="QListView" name="barlowListView"/> |
1210 | + </item> |
1211 | + <item> |
1212 | + <widget class="QFrame" name="frame_5"> |
1213 | + <property name="frameShape"> |
1214 | + <enum>QFrame::StyledPanel</enum> |
1215 | + </property> |
1216 | + <property name="frameShadow"> |
1217 | + <enum>QFrame::Raised</enum> |
1218 | + </property> |
1219 | + <layout class="QHBoxLayout" name="horizontalLayout_3"> |
1220 | + <property name="leftMargin"> |
1221 | + <number>0</number> |
1222 | + </property> |
1223 | + <property name="topMargin"> |
1224 | + <number>5</number> |
1225 | + </property> |
1226 | + <property name="rightMargin"> |
1227 | + <number>0</number> |
1228 | + </property> |
1229 | + <property name="bottomMargin"> |
1230 | + <number>0</number> |
1231 | + </property> |
1232 | + <item> |
1233 | + <widget class="QPushButton" name="addBarlow"> |
1234 | + <property name="minimumSize"> |
1235 | + <size> |
1236 | + <width>0</width> |
1237 | + <height>24</height> |
1238 | + </size> |
1239 | + </property> |
1240 | + <property name="text"> |
1241 | + <string>Add</string> |
1242 | + </property> |
1243 | + </widget> |
1244 | + </item> |
1245 | + <item> |
1246 | + <widget class="QPushButton" name="pushButtonMoveBarlowUp"> |
1247 | + <property name="sizePolicy"> |
1248 | + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
1249 | + <horstretch>0</horstretch> |
1250 | + <verstretch>0</verstretch> |
1251 | + </sizepolicy> |
1252 | + </property> |
1253 | + <property name="minimumSize"> |
1254 | + <size> |
1255 | + <width>24</width> |
1256 | + <height>24</height> |
1257 | + </size> |
1258 | + </property> |
1259 | + </widget> |
1260 | + </item> |
1261 | + <item> |
1262 | + <widget class="QPushButton" name="pushButtonMoveBarlowDown"> |
1263 | + <property name="sizePolicy"> |
1264 | + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
1265 | + <horstretch>0</horstretch> |
1266 | + <verstretch>0</verstretch> |
1267 | + </sizepolicy> |
1268 | + </property> |
1269 | + <property name="minimumSize"> |
1270 | + <size> |
1271 | + <width>24</width> |
1272 | + <height>24</height> |
1273 | + </size> |
1274 | + </property> |
1275 | + </widget> |
1276 | + </item> |
1277 | + <item> |
1278 | + <widget class="QPushButton" name="deleteBarlow"> |
1279 | + <property name="minimumSize"> |
1280 | + <size> |
1281 | + <width>0</width> |
1282 | + <height>24</height> |
1283 | + </size> |
1284 | + </property> |
1285 | + <property name="text"> |
1286 | + <string>Delete</string> |
1287 | + </property> |
1288 | + </widget> |
1289 | + </item> |
1290 | + </layout> |
1291 | + </widget> |
1292 | + </item> |
1293 | + </layout> |
1294 | + </item> |
1295 | + <item> |
1296 | + <layout class="QVBoxLayout" name="verticalLayout_9"> |
1297 | + <item> |
1298 | + <widget class="QFrame" name="frame_2"> |
1299 | + <property name="frameShape"> |
1300 | + <enum>QFrame::StyledPanel</enum> |
1301 | + </property> |
1302 | + <property name="frameShadow"> |
1303 | + <enum>QFrame::Raised</enum> |
1304 | + </property> |
1305 | + <layout class="QFormLayout" name="formLayout_4"> |
1306 | + <item row="0" column="0"> |
1307 | + <widget class="QLabel" name="label_7"> |
1308 | + <property name="text"> |
1309 | + <string>Name</string> |
1310 | + </property> |
1311 | + </widget> |
1312 | + </item> |
1313 | + <item row="0" column="1"> |
1314 | + <widget class="QLineEdit" name="barlowName"> |
1315 | + <property name="maxLength"> |
1316 | + <number>50</number> |
1317 | + </property> |
1318 | + </widget> |
1319 | + </item> |
1320 | + <item row="1" column="0"> |
1321 | + <widget class="QLabel" name="label_13"> |
1322 | + <property name="text"> |
1323 | + <string>Multiplicity</string> |
1324 | + </property> |
1325 | + </widget> |
1326 | + </item> |
1327 | + <item row="1" column="1"> |
1328 | + <widget class="QLineEdit" name="barlowMultipler"> |
1329 | + <property name="maxLength"> |
1330 | + <number>5</number> |
1331 | + </property> |
1332 | + </widget> |
1333 | + </item> |
1334 | + </layout> |
1335 | + </widget> |
1336 | + </item> |
1337 | + <item> |
1338 | + <spacer name="verticalSpacer_4"> |
1339 | + <property name="orientation"> |
1340 | + <enum>Qt::Vertical</enum> |
1341 | + </property> |
1342 | + <property name="sizeHint" stdset="0"> |
1343 | + <size> |
1344 | + <width>20</width> |
1345 | + <height>40</height> |
1346 | + </size> |
1347 | + </property> |
1348 | + </spacer> |
1349 | + </item> |
1350 | + </layout> |
1351 | + </item> |
1352 | + </layout> |
1353 | + </widget> |
1354 | <widget class="QWidget" name="CCD"> |
1355 | <attribute name="title"> |
1356 | <string>Sensors</string> |