• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 6685397774

29 Oct 2023 07:37PM UTC coverage: 11.735% (-0.002%) from 11.737%
6685397774

push

github

10110111
Deduplicate title bar implementation

131 of 131 new or added lines in 56 files covered. (100.0%)

14842 of 126472 relevant lines covered (11.74%)

21617.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/Oculars/src/gui/OcularDialog.cpp
1
/*
2
 * Copyright (C) 2009 Timothy Reaves
3
 * Copyright (C) 2011 Bogdan Marinov
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18
 */
19

20
#include "Oculars.hpp"
21
#include "OcularDialog.hpp"
22
#include "ui_ocularDialog.h"
23

24
#include "StelApp.hpp"
25
#include "StelGui.hpp"
26
#include "StelModuleMgr.hpp"
27
#include "StelMainView.hpp"
28
#include "StelTranslator.hpp"
29

30
#include <QAbstractItemModel>
31
#include <QDataWidgetMapper>
32
#include <QDebug>
33
#include <QFrame>
34
#include <QModelIndex>
35
#include <QSettings>
36
#include <QStandardItemModel>
37
#include <QMessageBox>
38
#include <limits>
39
#include <QRegularExpression>
40

41
OcularDialog::OcularDialog(Oculars* pluginPtr,
×
42
                           QList<CCD *>* ccds,
43
                           QList<Ocular *>* oculars,
44
                           QList<Telescope *>* telescopes,
45
                           QList<Lens *> *lenses)
×
46
        : StelDialog("Oculars")
47
        , plugin(pluginPtr)
×
48
        , ccdMapper(Q_NULLPTR)
×
49
        , ocularMapper(Q_NULLPTR)
×
50
        , telescopeMapper(Q_NULLPTR)
×
51
        , lensMapper(Q_NULLPTR)
×
52
{
53
        ui = new Ui_ocularDialogForm;
×
54
        this->ccds = ccds;
×
55
        ccdTableModel = new PropertyBasedTableModel(this);
×
56
        CCD* ccdModel = CCD::ccdModel();
×
57
        ccdTableModel->init(reinterpret_cast<QList<QObject *>* >(ccds), ccdModel, ccdModel->propertyMap());
×
58
        this->oculars = oculars;
×
59
        ocularTableModel = new PropertyBasedTableModel(this);
×
60
        Ocular* ocularModel = Ocular::ocularModel();
×
61
        ocularTableModel->init(reinterpret_cast<QList<QObject *>* >(oculars), ocularModel, ocularModel->propertyMap());
×
62
        this->telescopes = telescopes;
×
63
        telescopeTableModel = new PropertyBasedTableModel(this);
×
64
        Telescope* telescopeModel = Telescope::telescopeModel();
×
65
        telescopeTableModel->init(reinterpret_cast<QList<QObject *>* >(telescopes), telescopeModel, telescopeModel->propertyMap());
×
66
        
67
        this->lenses = lenses;
×
68
        lensTableModel = new PropertyBasedTableModel(this);
×
69
        Lens* lensModel = Lens::lensModel();
×
70
        lensTableModel->init(reinterpret_cast<QList<QObject *>* >(lenses),
×
71
                             lensModel,
72
                             lensModel->propertyMap());
×
73

74
        QRegularExpression nameExp("^\\S.*");
×
75
        validatorName = new QRegularExpressionValidator(nameExp, this);
×
76
}
×
77

78
OcularDialog::~OcularDialog()
×
79
{
80
        if (dialog)
×
81
        {
82
                ui->telescopeListView->clearSelection();
×
83
                ui->ocularListView->clearSelection();
×
84
                ui->ccdListView->clearSelection();
×
85
                ui->lensListView->clearSelection();
×
86
        }
87

88
        ocularTableModel->disconnect(ocularMapper);
×
89
        telescopeTableModel->disconnect(telescopeMapper);
×
90
        ccdTableModel->disconnect(ccdMapper);
×
91
        lensTableModel->disconnect(lensMapper);
×
92

93
        delete ui;
×
94
        ui = Q_NULLPTR;
×
95
}
×
96

97
void OcularDialog::retranslate()
×
98
{
99
        if (dialog)
×
100
        {
101
                ui->retranslateUi(dialog);
×
102
                initAboutText();
×
103
                updateSuffixes();
×
104
        }
105
}
×
106

107
void OcularDialog::closeWindow()
×
108
{
109
        setVisible(false);
×
110
        StelMainView::getInstance().scene()->setActiveWindow(Q_NULLPTR);
×
111
}
×
112

113
void OcularDialog::deleteSelectedCCD()
×
114
{
115
        if (ccdTableModel->rowCount() == 1)
×
116
        {
117
                qDebug() << "Cannot delete the last entry.";
×
118
                QMessageBox::warning(&StelMainView::getInstance(), q_("Warning!"), q_("Cannot delete the last sensor."), QMessageBox::Ok);
×
119
                return;
×
120
        }
121

122
        if (askConfirmation())
×
123
        {
124
                ccdTableModel->removeRows(ui->ccdListView->currentIndex().row(), 1);
×
125
                ui->ccdListView->setCurrentIndex(ccdTableModel->index(0, 1));
×
126
                plugin->updateLists();
×
127
        }
128
}
129

130
void OcularDialog::deleteSelectedOcular()
×
131
{
132
        if (ocularTableModel->rowCount() == 1)
×
133
        {
134
                qDebug() << "Cannot delete the last entry.";
×
135
                QMessageBox::warning(&StelMainView::getInstance(), q_("Warning!"), q_("Cannot delete the last ocular."), QMessageBox::Ok);
×
136
                return;
×
137
        }
138

139
        if (askConfirmation())
×
140
        {
141
                ocularTableModel->removeRows(ui->ocularListView->currentIndex().row(), 1);
×
142
                ui->ocularListView->setCurrentIndex(ocularTableModel->index(0, 1));
×
143
                plugin->updateLists();
×
144
        }
145
}
146

147
void OcularDialog::deleteSelectedTelescope()
×
148
{
149
        if (telescopeTableModel->rowCount() == 1)
×
150
        {
151
                qDebug() << "Cannot delete the last entry.";
×
152
                QMessageBox::warning(&StelMainView::getInstance(), q_("Warning!"), q_("Cannot delete the last telescope."), QMessageBox::Ok);
×
153
                return;
×
154
        }
155

156
        if (askConfirmation())
×
157
        {
158
                telescopeTableModel->removeRows(ui->telescopeListView->currentIndex().row(), 1);
×
159
                ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(0, 1));
×
160
                plugin->updateLists();
×
161
        }
162
}
163

164
void OcularDialog::deleteSelectedLens()
×
165
{
166
        if (askConfirmation())
×
167
        {
168
                if (lensTableModel->rowCount() > 0)
×
169
                {
170
                        lensTableModel->removeRows(ui->lensListView->currentIndex().row(), 1);
×
171
                        if (lensTableModel->rowCount() > 0)
×
172
                                ui->lensListView->setCurrentIndex(lensTableModel->index(0, 1));
×
173

174
                        plugin->updateLists();
×
175
                }
176
        }
177
}
×
178

179
void OcularDialog::insertNewCCD()
×
180
{
181
        int count = ccdTableModel->rowCount();
×
182
        ccdTableModel->insertRows(count, 1);
×
183
        ui->ccdListView->setCurrentIndex(ccdTableModel->index(count, 1));
×
184
}
×
185

186
void OcularDialog::insertNewOcular()
×
187
{
188
        int count = ocularTableModel->rowCount();
×
189
        ocularTableModel->insertRows(count, 1);
×
190
        ui->ocularListView->setCurrentIndex(ocularTableModel->index(count, 1));
×
191
}
×
192

193
void OcularDialog::insertNewTelescope()
×
194
{
195
        int count = telescopeTableModel->rowCount();
×
196
        telescopeTableModel->insertRows(count, 1);
×
197
        ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(count, 1));
×
198
}
×
199

200
void OcularDialog::insertNewLens()
×
201
{
202
        int count = lensTableModel->rowCount();
×
203
        lensTableModel->insertRows(count, 1);
×
204
        ui->lensListView->setCurrentIndex(lensTableModel->index(count, 1));
×
205
}
×
206

207
void OcularDialog::moveUpSelectedSensor()
×
208
{
209
        int index = ui->ccdListView->currentIndex().row();
×
210
        if (index > 0)
×
211
        {
212
                ccdTableModel->moveRowUp(index);
×
213
                plugin->updateLists();
×
214
        }
215
}
×
216

217
void OcularDialog::moveUpSelectedOcular()
×
218
{
219
        int index = ui->ocularListView->currentIndex().row();
×
220
        if (index > 0)
×
221
        {
222
                ocularTableModel->moveRowUp(index);
×
223
                plugin->updateLists();
×
224
        }
225
}
×
226

227
void OcularDialog::moveUpSelectedTelescope()
×
228
{
229
        int index = ui->telescopeListView->currentIndex().row();
×
230
        if (index > 0)
×
231
        {
232
                telescopeTableModel->moveRowUp(index);
×
233
                plugin->updateLists();
×
234
        }
235
}
×
236

237
void OcularDialog::moveUpSelectedLens()
×
238
{
239
        int index = ui->lensListView->currentIndex().row();
×
240
        if (index > 0)
×
241
        {
242
                lensTableModel->moveRowUp(index);
×
243
                plugin->updateLists();
×
244
        }
245
}
×
246

247
void OcularDialog::moveDownSelectedSensor()
×
248
{
249
        int index = ui->ccdListView->currentIndex().row();
×
250
        if (index >= 0 && index < ccdTableModel->rowCount() - 1)
×
251
        {
252
                ccdTableModel->moveRowDown(index);
×
253
                plugin->updateLists();
×
254
        }
255
}
×
256

257
void OcularDialog::moveDownSelectedOcular()
×
258
{
259
        int index = ui->ocularListView->currentIndex().row();
×
260
        if (index >= 0 && index < ocularTableModel->rowCount() - 1)
×
261
        {
262
                ocularTableModel->moveRowDown(index);
×
263
                plugin->updateLists();
×
264
        }
265
}
×
266

267
void OcularDialog::moveDownSelectedTelescope()
×
268
{
269
        int index = ui->telescopeListView->currentIndex().row();
×
270
        if (index >= 0 && index < telescopeTableModel->rowCount() - 1)
×
271
        {
272
                telescopeTableModel->moveRowDown(index);
×
273
                plugin->updateLists();
×
274
        }
275
}
×
276

277
void OcularDialog::moveDownSelectedLens()
×
278
{
279
        int index = ui->lensListView->currentIndex().row();
×
280
        if (index >= 0 && index < lensTableModel->rowCount() - 1)
×
281
        {
282
                lensTableModel->moveRowDown(index);
×
283
                plugin->updateLists();
×
284
        }
285
}
×
286

287
void OcularDialog::createDialogContent()
×
288
{
289
        ui->setupUi(dialog);
×
290
        connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
×
291
        ui->ccdListView->setModel(ccdTableModel);
×
292
        ui->ocularListView->setModel(ocularTableModel);
×
293
        ui->telescopeListView->setModel(telescopeTableModel);
×
294
        ui->lensListView->setModel(lensTableModel);
×
295

296
        // Kinetic scrolling
297
        kineticScrollingList << ui->textBrowser << ui->telescopeListView << ui->ccdListView << ui->ocularListView << ui->lensListView;
×
298
        StelGui* gui= dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
299
        if (gui)
×
300
        {
301
                enableKineticScrolling(gui->getFlagUseKineticScrolling());
×
302
                connect(gui, SIGNAL(flagUseKineticScrollingChanged(bool)), this, SLOT(enableKineticScrolling(bool)));
×
303
        }
304
        
305
        //Now the rest of the actions.
306
        connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
×
307
        connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
×
308

309
        connectBoolProperty(ui->checkBoxControlPanel,                "Oculars.flagGuiPanelEnabled");
×
310
        connectIntProperty(ui->guiFontSizeSpinBox,                "Oculars.guiPanelFontSize");
×
311
        connectBoolProperty(ui->checkBoxInitialFOV,                "Oculars.flagInitFOVUsage");
×
312
        connectBoolProperty(ui->checkBoxInitialDirection,        "Oculars.flagInitDirectionUsage");
×
313
        connectBoolProperty(ui->checkBoxResolutionCriterion,        "Oculars.flagShowResolutionCriteria");
×
314
        connectBoolProperty(ui->requireSelectionCheckBox,        "Oculars.flagRequireSelection");
×
315
        connectBoolProperty(ui->limitStellarMagnitudeCheckBox,        "Oculars.flagAutoLimitMagnitude");
×
316
        connectBoolProperty(ui->hideGridsLinesCheckBox,                "Oculars.flagHideGridsLines");
×
317
        connectBoolProperty(ui->scaleImageCircleCheckBox,        "Oculars.flagScaleImageCircle");
×
318
        connectBoolProperty(ui->semiTransparencyCheckBox,        "Oculars.flagSemiTransparency");
×
319
        connectIntProperty(ui->transparencySpinBox,                "Oculars.transparencyMask");
×
320
        connectBoolProperty(ui->checkBoxDMSDegrees,                "Oculars.flagDMSDegrees");
×
321
        connectBoolProperty(ui->checkBoxHorizontalCoordinates,        "Oculars.flagHorizontalCoordinates");
×
322
        connectBoolProperty(ui->checkBoxTypeOfMount,                "Oculars.flagAutosetMountForCCD");
×
323
        connectBoolProperty(ui->checkBoxTelradFOVScaling,        "Oculars.flagScalingFOVForTelrad");
×
324
        connectBoolProperty(ui->checkBoxCCDFOVScaling,                "Oculars.flagScalingFOVForCCD");
×
325
        connectBoolProperty(ui->checkBoxCCDMaxExposureTime,     "Oculars.flagMaxExposureTimeForCCD");
×
326
        connectBoolProperty(ui->checkBoxToolbarButton,                "Oculars.flagShowOcularsButton");
×
327
        connectIntProperty(ui->arrowButtonScaleSpinBox,                "Oculars.arrowButtonScale");
×
328
        connectBoolProperty(ui->checkBoxShowCcdCropOverlay,        "Oculars.flagShowCcdCropOverlay");
×
329
        connectBoolProperty(ui->checkBoxShowCcdCropOverlayPixelGrid,        "Oculars.flagShowCcdCropOverlayPixelGrid");
×
330
        connectIntProperty(ui->guiCcdCropOverlayHSizeSpinBox,        "Oculars.ccdCropOverlayHSize");
×
331
        connectIntProperty(ui->guiCcdCropOverlayVSizeSpinBox,        "Oculars.ccdCropOverlayVSize");
×
332
        connectBoolProperty(ui->contourCheckBox,                "Oculars.flagShowContour");
×
333
        connectBoolProperty(ui->cardinalsCheckBox,                "Oculars.flagShowCardinals");
×
334
        connectBoolProperty(ui->alignCrosshairCheckBox,                "Oculars.flagAlignCrosshair");
×
335
        connectColorButton(ui->textColorToolButton,             "Oculars.textColor", "text_color", "Oculars");
×
336
        connectColorButton(ui->lineColorToolButton,             "Oculars.lineColor", "line_color", "Oculars");
×
337
        connectColorButton(ui->focuserColorToolButton,                "Oculars.focuserColor", "focuser_color", "Oculars");
×
338
        connectBoolProperty(ui->checkBoxShowFocuserOverlay,        "Oculars.flagShowFocuserOverlay");
×
339
        connectBoolProperty(ui->checkBoxUseSmallFocuser,        "Oculars.flagUseSmallFocuserOverlay");
×
340
        connectBoolProperty(ui->checkBoxUseMediumFocuser,        "Oculars.flagUseMediumFocuserOverlay");
×
341
        connectBoolProperty(ui->checkBoxUseLargeFocuser,        "Oculars.flagUseLargeFocuserOverlay");
×
342

343
        setupTelradFOVspins(plugin->getTelradFOV());
×
344
        connect(plugin, SIGNAL(telradFOVChanged(Vec4f)), this, SLOT(setupTelradFOVspins(Vec4f)));
×
345
        connect(ui->doubleSpinBoxTelradFOV1, SIGNAL(valueChanged(double)), this, SLOT(updateTelradCustomFOV()));
×
346
        connect(ui->doubleSpinBoxTelradFOV2, SIGNAL(valueChanged(double)), this, SLOT(updateTelradCustomFOV()));
×
347
        connect(ui->doubleSpinBoxTelradFOV3, SIGNAL(valueChanged(double)), this, SLOT(updateTelradCustomFOV()));
×
348
        connect(ui->doubleSpinBoxTelradFOV4, SIGNAL(valueChanged(double)), this, SLOT(updateTelradCustomFOV()));
×
349
        connect(ui->pushButtonRestoreTelradFOV, &QPushButton::clicked, this, [=] () { plugin->setTelradFOV(Vec4f(0.5f, 2.0f, 4.0f, 0.0f));} );
×
350

351
        // The add & delete buttons
352
        connect(ui->addCCD,          SIGNAL(clicked()), this, SLOT(insertNewCCD()));
×
353
        connect(ui->deleteCCD,       SIGNAL(clicked()), this, SLOT(deleteSelectedCCD()));
×
354
        connect(ui->addOcular,       SIGNAL(clicked()), this, SLOT(insertNewOcular()));
×
355
        connect(ui->deleteOcular,    SIGNAL(clicked()), this, SLOT(deleteSelectedOcular()));
×
356
        connect(ui->addLens,         SIGNAL(clicked()), this, SLOT(insertNewLens()));
×
357
        connect(ui->deleteLens,      SIGNAL(clicked()), this, SLOT(deleteSelectedLens()));
×
358
        connect(ui->addTelescope,    SIGNAL(clicked()), this, SLOT(insertNewTelescope()));
×
359
        connect(ui->deleteTelescope, SIGNAL(clicked()), this, SLOT(deleteSelectedTelescope()));
×
360

361
        // Validators
362
        ui->ccdName->setValidator(validatorName);
×
363
        ui->ocularName->setValidator(validatorName);
×
364
        ui->telescopeName->setValidator(validatorName);
×
365
        ui->lensName->setValidator(validatorName);
×
366

367
        initAboutText();
×
368
        updateSuffixes();
×
369

370
        connect(ui->pushButtonMoveOcularUp,      SIGNAL(pressed()), this, SLOT(moveUpSelectedOcular()));
×
371
        connect(ui->pushButtonMoveOcularDown,    SIGNAL(pressed()), this, SLOT(moveDownSelectedOcular()));
×
372
        connect(ui->pushButtonMoveSensorUp,      SIGNAL(pressed()), this, SLOT(moveUpSelectedSensor()));
×
373
        connect(ui->pushButtonMoveSensorDown,    SIGNAL(pressed()), this, SLOT(moveDownSelectedSensor()));
×
374
        connect(ui->pushButtonMoveTelescopeUp,   SIGNAL(pressed()), this, SLOT(moveUpSelectedTelescope()));
×
375
        connect(ui->pushButtonMoveTelescopeDown, SIGNAL(pressed()), this, SLOT(moveDownSelectedTelescope()));
×
376
        connect(ui->pushButtonMoveLensUp,        SIGNAL(pressed()), this, SLOT(moveUpSelectedLens()));
×
377
        connect(ui->pushButtonMoveLensDown,      SIGNAL(pressed()), this, SLOT(moveDownSelectedLens()));
×
378

379
        // The CCD mapper
380
        ccdMapper = new QDataWidgetMapper();
×
381
        ccdMapper->setModel(ccdTableModel);
×
382
        ccdMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
×
383
        ccdMapper->addMapping(ui->ccdName,       0);
×
384
        ccdMapper->addMapping(ui->ccdChipY,      1);
×
385
        ccdMapper->addMapping(ui->ccdChipX,      2);
×
386
        ccdMapper->addMapping(ui->ccdResX,       3);
×
387
        ccdMapper->addMapping(ui->ccdResY,       4);
×
388
        ccdMapper->addMapping(ui->ccdRotAngle,   5);
×
389
        ccdMapper->addMapping(ui->ccdBinningX,   6);
×
390
        ccdMapper->addMapping(ui->ccdBinningY,   7);
×
391
        ccdMapper->addMapping(ui->OAG_checkBox, 8);
×
392
        ccdMapper->addMapping(ui->OAGPrismH,    9);
×
393
        ccdMapper->addMapping(ui->OAGPrismW,    10);
×
394
        ccdMapper->addMapping(ui->OAGDist,      11);
×
395
        ccdMapper->addMapping(ui->OAGPrismPA,   12);
×
396
        ccdMapper->toFirst();
×
397
        connect(ui->ccdListView->selectionModel() , SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
×
398
                ccdMapper, SLOT(setCurrentModelIndex(QModelIndex)));
×
399
        connect(ui->ccdListView, SIGNAL(doubleClicked(QModelIndex)),
×
400
                     this, SLOT(selectCCD(QModelIndex)));        
401
        ui->ccdListView->setSelectionBehavior(QAbstractItemView::SelectRows);        
×
402
        int index = plugin->getSelectedCCDIndex();
×
403
        ui->ccdListView->setCurrentIndex(ccdTableModel->index(index>0 ? index : 0, 1));
×
404

405
        connect(ui->ccdChipY,    SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
406
        connect(ui->ccdChipX,    SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
407
        connect(ui->ccdResX,     SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
408
        connect(ui->ccdResY,     SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
409
        connect(ui->ccdRotAngle, SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
410
        connect(ui->ccdBinningX, SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
411
        connect(ui->ccdBinningY, SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
412
        connect(ui->OAG_checkBox,SIGNAL(stateChanged(int)), this, SLOT(updateCCD()));
×
413
        connect(ui->OAGPrismH,   SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
414
        connect(ui->OAGPrismW,   SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
415
        connect(ui->OAGDist,     SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
416
        connect(ui->OAGPrismPA,  SIGNAL(editingFinished()), this, SLOT(updateCCD()));
×
417
        connect(plugin, SIGNAL(selectedCCDRotationAngleChanged(double)), this, SLOT(updateCCDRotationAngles()));
×
418
        connect(plugin, SIGNAL(selectedCCDPrismPositionAngleChanged(double)), this, SLOT(updateCCDRotationAngles()));
×
419

420
        // The ocular mapper
421
        ocularMapper = new QDataWidgetMapper();
×
422
        ocularMapper->setModel(ocularTableModel);
×
423
        ocularMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
×
424
        ocularMapper->addMapping(ui->ocularName,                 0);
×
425
        ocularMapper->addMapping(ui->ocularAFov,                 1);
×
426
        ocularMapper->addMapping(ui->ocularFL,                   2);
×
427
        ocularMapper->addMapping(ui->ocularFieldStop,            3);
×
428
        ocularMapper->addMapping(ui->binocularsCheckBox,         4, "checked");
×
429
        ocularMapper->addMapping(ui->permanentCrosshairCheckBox, 5, "checked");        
×
430
        ocularMapper->toFirst();
×
431
        connect(ui->ocularListView->selectionModel() , SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
×
432
                ocularMapper, SLOT(setCurrentModelIndex(QModelIndex)));
×
433
        connect(ui->ocularListView, SIGNAL(doubleClicked(QModelIndex)),
×
434
                     this, SLOT(selectOcular(QModelIndex)));
435
        ui->ocularListView->setSelectionBehavior(QAbstractItemView::SelectRows);
×
436
        index = plugin->getSelectedOcularIndex();
×
437
        ui->ocularListView->setCurrentIndex(ocularTableModel->index(index>0 ? index : 0, 1));
×
438

439
        // We need particular refresh methods to see immediate feedback.
440
        connect(ui->ocularAFov,                 SIGNAL(editingFinished()), this, SLOT(updateOcular()));
×
441
        connect(ui->ocularFL,                   SIGNAL(editingFinished()), this, SLOT(updateOcular()));
×
442
        connect(ui->ocularFieldStop,            SIGNAL(editingFinished()), this, SLOT(updateOcular()));
×
443
        connect(ui->binocularsCheckBox,         SIGNAL(stateChanged(int)), this, SLOT(updateOcular()));
×
444
        connect(ui->permanentCrosshairCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateOcular()));
×
445

446
        // The lens mapper
447
        lensMapper = new QDataWidgetMapper();
×
448
        lensMapper->setModel(lensTableModel);
×
449
        lensMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
×
450
        lensMapper->addMapping(ui->lensName,       0);
×
451
        lensMapper->addMapping(ui->lensMultiplier, 1);
×
452
        lensMapper->toFirst();
×
453
        connect(ui->lensListView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
×
454
                lensMapper, SLOT(setCurrentModelIndex(QModelIndex)));
×
455
        connect(ui->lensListView, SIGNAL(doubleClicked(QModelIndex)),
×
456
                     this, SLOT(selectLens(QModelIndex)));
457
        ui->lensListView->setSelectionBehavior(QAbstractItemView::SelectRows);
×
458
        index = plugin->getSelectedLensIndex();
×
459
        ui->lensListView->setCurrentIndex(lensTableModel->index(index>0 ? index : 0, 1));
×
460

461
        connect(ui->lensMultiplier, SIGNAL(editingFinished()), this, SLOT(updateLens()));
×
462

463
        // The telescope mapper
464
        telescopeMapper = new QDataWidgetMapper();
×
465
        telescopeMapper->setModel(telescopeTableModel);
×
466
        telescopeMapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
×
467
        telescopeMapper->addMapping(ui->telescopeName,     0);
×
468
        telescopeMapper->addMapping(ui->telescopeDiameter, 1);
×
469
        telescopeMapper->addMapping(ui->telescopeFL,       2);
×
470
        telescopeMapper->addMapping(ui->telescopeHFlip,    3, "checked");
×
471
        telescopeMapper->addMapping(ui->telescopeVFlip,    4, "checked");
×
472
        telescopeMapper->addMapping(ui->telescopeEQ,       5, "checked");
×
473
        telescopeMapper->toFirst();
×
474
        connect(ui->telescopeListView->selectionModel() , SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
×
475
                telescopeMapper, SLOT(setCurrentModelIndex(QModelIndex)));
×
476
        connect(ui->telescopeListView, SIGNAL(doubleClicked(QModelIndex)),
×
477
                     this, SLOT(selectTelescope(QModelIndex)));
478
        ui->telescopeListView->setSelectionBehavior(QAbstractItemView::SelectRows);
×
479
        index = plugin->getSelectedTelescopeIndex();
×
480
        ui->telescopeListView->setCurrentIndex(telescopeTableModel->index(index>0 ? index : 0, 1));
×
481

482
        connect(ui->telescopeDiameter, SIGNAL(editingFinished()), this, SLOT(updateTelescope()));
×
483
        connect(ui->telescopeFL,       SIGNAL(editingFinished()), this, SLOT(updateTelescope()));
×
484
        connect(ui->telescopeHFlip,    SIGNAL(stateChanged(int)), this, SLOT(updateTelescope()));
×
485
        connect(ui->telescopeVFlip,    SIGNAL(stateChanged(int)), this, SLOT(updateTelescope()));
×
486
        connect(ui->telescopeEQ,       SIGNAL(stateChanged(int)), this, SLOT(updateTelescope()));
×
487

488
        connect(ui->binocularsCheckBox, SIGNAL(toggled(bool)), this, SLOT(setLabelsDescriptionText(bool)));
×
489
        connect(ui->checkBoxControlPanel, SIGNAL(toggled(bool)), this, SLOT(updateGuiOptions()));
×
490
        connect(ui->semiTransparencyCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateGuiOptions()));
×
491
        connect(ui->checkBoxShowFocuserOverlay, SIGNAL(toggled(bool)), this, SLOT(updateGuiOptions()));
×
492
        connect(ui->checkBoxShowCcdCropOverlay, SIGNAL(toggled(bool)), this, SLOT(updateGuiOptions()));
×
493
        setLabelsDescriptionText(ui->binocularsCheckBox->isChecked());
×
494
        updateGuiOptions();
×
495
}
×
496

497
void OcularDialog::setupTelradFOVspins(Vec4f fov)
×
498
{
499
        ui->doubleSpinBoxTelradFOV1->setValue(static_cast<double>(fov[0]));
×
500
        ui->doubleSpinBoxTelradFOV2->setValue(static_cast<double>(fov[1]));
×
501
        ui->doubleSpinBoxTelradFOV3->setValue(static_cast<double>(fov[2]));
×
502
        ui->doubleSpinBoxTelradFOV4->setValue(static_cast<double>(fov[3]));
×
503
}
×
504

505
void OcularDialog::updateCCDRotationAngles()
×
506
{
507
        if (dialog->isVisible())
×
508
        {
509
                if (plugin->getSelectedCCDIndex()==ccdMapper->currentIndex())
×
510
                {
511
                        ui->ccdRotAngle->setValue(plugin->getSelectedCCDRotationAngle());
×
512
                        ui->OAGPrismPA->setValue(plugin->getSelectedCCDPrismPositionAngle());
×
513
                }
514
        }
515
}
×
516

517
void OcularDialog::updateTelradCustomFOV()
×
518
{
519
        Vec4f fov(static_cast<float>(ui->doubleSpinBoxTelradFOV1->value()),
×
520
                  static_cast<float>(ui->doubleSpinBoxTelradFOV2->value()),
×
521
                  static_cast<float>(ui->doubleSpinBoxTelradFOV3->value()),
×
522
                  static_cast<float>(ui->doubleSpinBoxTelradFOV4->value()));
×
523
        plugin->setTelradFOV(fov);
×
524
}
×
525

526
// We need particular refresh methods to see immediate feedback.
527
void OcularDialog::updateOcular()
×
528
{
529
        ocularMapper->submit();
×
530
        plugin->selectOcularAtIndex(plugin->getSelectedOcularIndex());
×
531
}
×
532

533
void OcularDialog::selectOcular(const QModelIndex)
×
534
{
535
        plugin->selectOcularAtIndex(ocularMapper->currentIndex());
×
536
        plugin->updateLists();
×
537
}
×
538

539
void OcularDialog::updateLens()
×
540
{
541
        lensMapper->submit();
×
542
        plugin->selectLensAtIndex(plugin->getSelectedLensIndex());
×
543
}
×
544

545
void OcularDialog::selectLens(const QModelIndex)
×
546
{
547
        plugin->selectLensAtIndex(lensMapper->currentIndex());
×
548
        plugin->updateLists();
×
549
}
×
550

551
void OcularDialog::updateCCD()
×
552
{
553
        ccdMapper->submit();
×
554
        plugin->selectCCDAtIndex(plugin->getSelectedCCDIndex());
×
555
}
×
556

557
void OcularDialog::selectCCD(const QModelIndex)
×
558
{
559
        plugin->selectCCDAtIndex(ccdMapper->currentIndex());
×
560
        plugin->updateLists();
×
561
}
×
562

563
void OcularDialog::updateTelescope()
×
564
{
565
        telescopeMapper->submit();
×
566
        plugin->selectTelescopeAtIndex(plugin->getSelectedTelescopeIndex());
×
567
}
×
568

569
void OcularDialog::selectTelescope(const QModelIndex)
×
570
{
571
        plugin->selectTelescopeAtIndex(telescopeMapper->currentIndex());
×
572
        plugin->updateLists();
×
573
}
×
574

575
void OcularDialog::setLabelsDescriptionText(bool state)
×
576
{
577
        if (state)
×
578
        {
579
                // TRANSLATORS: tFOV for binoculars (tFOV = True Field of View)
580
                ui->labelFOV->setText(q_("tFOV:"));
×
581
                // TRANSLATORS: Magnification factor for binoculars
582
                ui->labelFL->setText(q_("Magnification factor:"));
×
583
                ui->labelFS->setText(q_("Diameter:"));
×
584
                ui->ocularFL->setSuffix("x");
×
585
        }
586
        else
587
        {
588
                ui->labelFOV->setText(q_("aFOV:"));
×
589
                ui->labelFL->setText(q_("Focal length:"));
×
590
                ui->labelFS->setText(q_("Field stop:"));
×
591
                ui->ocularFL->setSuffix(QString(" %1").arg(qc_("mm","millimeters")));
×
592
        }
593
}
×
594

595
void OcularDialog::updateSuffixes()
×
596
{
597
        const QString qMM = QString(" %1").arg(qc_("mm","millimeters"));
×
598
        const QString qPX = QString(" %1").arg(qc_("px", "pixels"));
×
599
        const QString qDG = QChar(0x00B0);
×
600
        ui->telescopeFL->setSuffix(qMM);
×
601
        ui->telescopeDiameter->setSuffix(qMM);
×
602
        ui->ccdChipX->setSuffix(qMM);
×
603
        ui->ccdChipY->setSuffix(qMM);
×
604
        ui->OAGDist->setSuffix(qMM);
×
605
        ui->OAGPrismH->setSuffix(qMM);
×
606
        ui->OAGPrismW->setSuffix(qMM);
×
607
        ui->ocularFieldStop->setSuffix(qMM);
×
608

609
        ui->ccdResX->setSuffix(qPX);
×
610
        ui->ccdResY->setSuffix(qPX);
×
611

612
        ui->ccdRotAngle->setSuffix(qDG);
×
613
        ui->OAGPrismPA->setSuffix(qDG);
×
614
        ui->ocularAFov->setSuffix(qDG);
×
615

616
        ui->lensMultiplier->setSuffix("x");
×
617
}
×
618

619
void OcularDialog::initAboutText()
×
620
{
621
        //BM: Most of the text for now is the original contents of the About widget.
622
        QString html = "<html><head><title></title></head><body>";
×
623

624
        html += "<h2>" + q_("Oculars Plug-in") + "</h2><table width=\"90%\">";
×
625
        html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</strong></td><td>" + OCULARS_PLUGIN_VERSION + "</td></tr>";
×
626
        html += "<tr><td><strong>" + q_("License") + ":</strong></td><td>" + OCULARS_PLUGIN_LICENSE + "</td></tr>";
×
627
        html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Timothy Reaves &lt;treaves@silverfieldstech.com&gt;</td></tr>";
×
628
        html += "<tr><td rowspan=\"7\"><strong>" + q_("Contributors") + ":</strong></td><td>Bogdan Marinov</td></tr>";
×
629
        html += "<tr><td>Alexander Wolf</td></tr>";
×
630
        html += "<tr><td>Georg Zotti</td></tr>";
×
631
        html += "<tr><td>Rumen G. Bogdanovski &lt;rumen@skyarchive.org&gt;</td></tr>";
×
632
        html += "<tr><td>Pawel Stolowski (" + q_("Barlow lens feature") + ")</td></tr>";                
×
633
        html += "<tr><td>Matt Hughes (" + q_("Sensor crop overlay feature") + ")</td></tr>";
×
634
        html += "<tr><td>Dhia Moakhar (" + q_("Pixel grid feature") + ")</td></tr>";
×
635
        html += "</table>";
×
636

637
        // Overview
638
        html += "<h3>" + q_("Overview") + "</h3>";
×
639

640
        html += "<p>" + q_("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 you started.") + "</p>";
×
641
        html += "<p>" + q_("You can choose to scale the image you see on the screen.") + " ";
×
642
        html +=         q_("This is intended to show you a better comparison of what one eyepiece/telescope combination will be like when compared to another.") + " ";
×
643
        html +=         q_("The same eyepiece in two different telescopes of differing focal length will produce two different exit pupils, changing the view somewhat.") + " ";
×
644
        html +=         q_("The trade-off of this is that, with the image scaled, a large part of the screen can be wasted.") + " ";
×
645
        html +=         q_("Therefore we recommend that you leave it off, unless you feel you have a need for it.") + "</p>";
×
646
        html += "<p>" + q_("You can toggle a crosshair in the view.") + "</p>";
×
647
        html += "<p>" + QString(q_("You can toggle a Telrad finder. 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.")).arg(QChar(0x00B0));
×
648
        html +=         q_("You can adjust the diameters or even add a fourth circle if you have a different finder, or revert to the Telrad standard sizes.") + "</p>";
×
649
        html += "<p>" + q_("If you find any issues, please let me know. Enjoy!") + "</p>";
×
650

651
        // Keys
652
        html += "<h3>" + q_("Hot Keys") + "</h3>";
×
653
        html += "<p>" + q_("The plug-in's key bindings can be edited in the Keyboard shortcuts editor (F7).") + "</p>";
×
654

655
        // Notes
656
        html += "<h3>" + q_("Notes") + "</h3>";
×
657
        html += "<p>" +  q_("The sensor view has a feature to show a sensor crop overlay with information about the crop size. The size of this rectangle may be adjusted when binning is active (e.g. crop size of 100px will be adjusted to 99px by binning 3).") + " ";
×
658
        html +=          q_("In this case, information about crop size overlay will be marked by %1.").arg("[*]") + " ";
×
659
        html +=          q_("This mark is also displayed if the crop size is larger than the sensor size.") + "</p>";
×
660
        html += "<p>" + q_("The sensor view has also a feature to show a max time of exposure for selected solar system objects (the mount has sidereal speed enabled) to avoid a movement of more than 1 pixel width.") + "</p>";
×
661

662
        html += StelApp::getInstance().getModuleMgr().getStandardSupportLinksInfo("Oculars plugin");
×
663
        html += "</body></html>";
×
664

665
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
666
        if (gui)
×
667
                ui->textBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
×
668

669
        ui->textBrowser->setHtml(html);
×
670
}
×
671

672
void OcularDialog::updateGuiOptions()
×
673
{
674
        bool flag = ui->checkBoxControlPanel->isChecked();
×
675
        ui->guiFontSizeLabel->setEnabled(flag);
×
676
        ui->guiFontSizeSpinBox->setEnabled(flag);
×
677

678
        ui->transparencySpinBox->setEnabled(ui->semiTransparencyCheckBox->isChecked());
×
679

680
        flag = ui->checkBoxShowFocuserOverlay->isChecked();
×
681
        ui->labelFocuserOverlay->setEnabled(flag);
×
682
        ui->checkBoxUseSmallFocuser->setEnabled(flag);
×
683
        ui->checkBoxUseMediumFocuser->setEnabled(flag);
×
684
        ui->checkBoxUseLargeFocuser->setEnabled(flag);
×
685

686
        flag = ui->checkBoxShowCcdCropOverlay->isChecked();
×
687
        ui->guiCcdCropOverlaySizeLabel->setEnabled(flag);
×
688
        ui->guiCcdCropOverlayHSizeSpinBox->setEnabled(flag);
×
689
        ui->guiCcdCropOverlayVSizeSpinBox->setEnabled(flag);
×
690
        ui->checkBoxShowCcdCropOverlayPixelGrid->setEnabled(flag);
×
691
}
×
692

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc