7#include "oal/equipmentwriter.h"
8#include "ui_equipmentwriter.h"
12#include "kstarsdata.h"
15#include "oal/dslrlens.h"
16#include "oal/eyepiece.h"
18#include "oal/filter.h"
21#include <config-kstars.h>
24#include "indi/drivermanager.h"
27EquipmentWriter::EquipmentWriter()
31 ui.tabWidget->setCurrentIndex(0);
56 connect(ui.NewScope, SIGNAL(clicked()),
this, SLOT(slotNewScope()));
57 connect(ui.NewEyepiece, SIGNAL(clicked()),
this, SLOT(slotNewEyepiece()));
58 connect(ui.NewLens, SIGNAL(clicked()),
this, SLOT(slotNewLens()));
59 connect(ui.NewFilter, SIGNAL(clicked()),
this, SLOT(slotNewFilter()));
60 connect(ui.AddScope, SIGNAL(clicked()),
this, SLOT(slotSave()));
61 connect(ui.AddEyepiece, SIGNAL(clicked()),
this, SLOT(slotSave()));
62 connect(ui.AddLens, SIGNAL(clicked()),
this, SLOT(slotSave()));
63 connect(ui.AddFilter, SIGNAL(clicked()),
this, SLOT(slotSave()));
68 connect(ui.RemoveScope, SIGNAL(clicked()),
this, SLOT(slotRemoveScope()));
69 connect(ui.RemoveEyepiece, SIGNAL(clicked()),
this, SLOT(slotRemoveEyepiece()));
70 connect(ui.RemoveLens, SIGNAL(clicked()),
this, SLOT(slotRemoveLens()));
71 connect(ui.RemoveFilter, SIGNAL(clicked()),
this, SLOT(slotRemoveFilter()));
79void EquipmentWriter::slotAddScope()
83 ui.Type->currentText(),
85 ui.FocalLength->value());
90 ui.Aperture->setValue(0);
91 ui.FocalLength->setValue(0);
94void EquipmentWriter::slotRemoveScope()
99 ui.Aperture->setValue(0);
100 ui.FocalLength->setValue(0);
104void EquipmentWriter::slotSaveScope()
108 ui.Type->currentText(),
109 ui.Aperture->value(),
110 ui.FocalLength->value(),
116void EquipmentWriter::slotSetScope(
QString name)
122 ui.Id->setText(s->id());
123 ui.Model->setText(s->model());
124 ui.Vendor->setText(s->vendor());
125 ui.Type->setCurrentIndex(ui.Type->findText(s->type()));
126 ui.Aperture->setValue(s->aperture());
127 ui.FocalLength->setValue(s->focalLength());
131void EquipmentWriter::slotNewScope()
136 ui.FocalLength->setValue(0);
137 ui.ScopeList->selectionModel()->clear();
145void EquipmentWriter::slotAddDSLRLens()
148 ui.DSLR_model->text(),
149 ui.DSLR_vendor->text(),
150 ui.DSLRFocalLength->value(),
151 ui.DSLRFocalRatio->value());
153 ui.DSLR_model->clear();
154 ui.DSLR_vendor->clear();
155 ui.DSLRFocalLength->setValue(24);
156 ui.DSLRFocalRatio->setValue(2.8);
159void EquipmentWriter::slotRemoveDSLRLens()
162 ui.DSLR_model->clear();
163 ui.DSLR_vendor->clear();
164 ui.DSLRFocalLength->setValue(24);
165 ui.DSLRFocalRatio->setValue(2.8);
169void EquipmentWriter::slotSaveDSLRLens()
172 ui.DSLR_model->text(),
173 ui.DSLR_vendor->text(),
174 ui.DSLRFocalLength->value(),
175 ui.DSLRFocalRatio->value(),
181void EquipmentWriter::slotSetDSLRLens(
QString name)
186 ui.DSLR_id->setText(s->id());
187 ui.DSLR_model->setText(s->model());
188 ui.DSLR_vendor->setText(s->vendor());
189 ui.DSLRFocalLength->setValue(s->focalLength());
190 ui.DSLRFocalRatio->setValue(s->focalRatio());
195void EquipmentWriter::slotNewDSLRLens()
198 ui.DSLR_model->clear();
199 ui.DSLR_vendor->clear();
200 ui.DSLRFocalLength->setValue(24);
201 ui.DSLRFocalRatio->setValue(2.8);
202 ui.DSLRLensList->selectionModel()->clear();
210void EquipmentWriter::slotAddEyepiece()
212 KStarsData::Instance()->
userdb()->
AddEyepiece(ui.e_Vendor->text(), ui.e_Model->text(), ui.e_focalLength->value(),
213 ui.Fov->value(), ui.FovUnit->currentText());
217 ui.e_Vendor->clear();
219 ui.e_focalLength->setValue(0);
222void EquipmentWriter::slotRemoveEyepiece()
228 ui.e_Vendor->clear();
230 ui.e_focalLength->setValue(0);
231 ui.EyepieceList->clear();
232 foreach (OAL::Eyepiece *e, *(KStarsData::Instance()->logObject()->eyepieceList()))
233 ui.EyepieceList->addItem(e->name());
235void EquipmentWriter::slotSaveEyepiece()
237 KStarsData::Instance()->
userdb()->
AddEyepiece(ui.e_Vendor->text(), ui.e_Model->text(), ui.e_focalLength->value(),
238 ui.Fov->value(), ui.FovUnit->currentText(), ui.e_Id->text());
242void EquipmentWriter::slotSetEyepiece(
QString name)
246 e = KStarsData::Instance()->
logObject()->findEyepieceByName(name);
249 ui.e_Id->setText(e->id());
250 ui.e_Model->setText(e->model());
251 ui.e_Vendor->setText(e->vendor());
252 ui.Fov->setValue(e->appFov());
253 ui.e_focalLength->setValue(e->focalLength());
258void EquipmentWriter::slotNewEyepiece()
262 ui.e_Vendor->clear();
264 ui.e_focalLength->setValue(0);
265 ui.EyepieceList->selectionModel()->clear();
269void EquipmentWriter::slotAddLens()
271 KStarsData::Instance()->
userdb()->
AddLens(ui.l_Vendor->text(), ui.l_Model->text(), ui.l_Factor->value());
275 ui.l_Vendor->clear();
276 ui.l_Factor->setValue(0);
279void EquipmentWriter::slotRemoveLens()
285 ui.l_Vendor->clear();
286 ui.l_Factor->setValue(0);
287 ui.LensList->clear();
288 foreach (
OAL::Lens *l, *(KStarsData::Instance()->logObject()->lensList()))
289 ui.LensList->addItem(l->name());
291void EquipmentWriter::slotSaveLens()
293 KStarsData::Instance()->
userdb()->
AddLens(ui.l_Vendor->text(), ui.l_Model->text(), ui.l_Factor->value(),
298void EquipmentWriter::slotSetLens(
QString name)
301 l = KStarsData::Instance()->
logObject()->findLensByName(name);
304 ui.l_Id->setText(l->id());
305 ui.l_Model->setText(l->model());
306 ui.l_Vendor->setText(l->vendor());
307 ui.l_Factor->setValue(l->factor());
312void EquipmentWriter::slotNewLens()
316 ui.l_Vendor->clear();
317 ui.l_Factor->setValue(0);
318 ui.LensList->selectionModel()->clear();
322void EquipmentWriter::slotAddFilter()
324 filterProperties *fp =
new filterProperties(ui.f_Vendor->text(), ui.f_Model->text(), ui.f_Type->text(),
325 ui.f_Color->text(), ui.f_Offset->value(), ui.f_Exposure->value(), ui.f_UseAutoFocus->isChecked(),
326 ui.f_LockedFilter->text(), 0, Ekos::INVALID_VALUE, Ekos::INVALID_VALUE, ui.f_FocusTicksPerTemp->value(),
327 ui.f_FocusTicksPerAlt->value(), ui.f_Wavelength->value());
333 ui.f_Vendor->clear();
335 ui.f_Offset->setValue(0);
337 ui.f_Exposure->setValue(1);
338 ui.f_LockedFilter->setText(NULL_FILTER);
339 ui.f_UseAutoFocus->setChecked(
false);
340 ui.f_FocusTemperature->setValue(Ekos::INVALID_VALUE);
341 ui.f_FocusAltitude->setValue(Ekos::INVALID_VALUE);
342 ui.f_FocusTicksPerTemp->setValue(0.0);
343 ui.f_FocusTicksPerAlt->setValue(0.0);
344 ui.f_Wavelength->setValue(500.0);
348void EquipmentWriter::slotRemoveFilter()
354 ui.f_Vendor->clear();
356 ui.f_Offset->setValue(0);
358 ui.f_Exposure->setValue(0);
359 ui.f_LockedFilter->setText(NULL_FILTER);
360 ui.f_UseAutoFocus->setChecked(
false);
361 ui.f_FocusTemperature->setValue(Ekos::INVALID_VALUE);
362 ui.f_FocusAltitude->setValue(Ekos::INVALID_VALUE);
363 ui.f_FocusTicksPerTemp->setValue(0.0);
364 ui.f_FocusTicksPerAlt->setValue(0.0);
365 ui.f_Wavelength->setValue(500.0);
366 ui.FilterList->clear();
367 foreach (
OAL::Filter *f, *(KStarsData::Instance()->logObject()->filterList()))
368 ui.FilterList->addItem(f->name());
371void EquipmentWriter::slotSaveFilter()
373 filterProperties *fp =
new filterProperties(ui.f_Vendor->text(), ui.f_Model->text(), ui.f_Type->text(),
374 ui.f_Color->text(), ui.f_Offset->value(), ui.f_Exposure->value(), ui.f_UseAutoFocus->isChecked(),
375 ui.f_LockedFilter->text(), ui.f_AbsoluteFocusPosition->value(), ui.f_FocusTemperature->value(),
376 ui.f_FocusAltitude->value(), ui.f_FocusTicksPerTemp->value(), ui.f_FocusTicksPerAlt->value(),
377 ui.f_Wavelength->value());
379 if (ui.f_Id->text().isEmpty())
388void EquipmentWriter::slotSetFilter(
QString name)
391 f = KStarsData::Instance()->
logObject()->findFilterByName(name);
394 ui.f_Id->setText(f->id());
395 ui.f_Model->setText(f->model());
396 ui.f_Vendor->setText(f->vendor());
397 ui.f_Type->setText(f->type());
398 ui.f_Color->setText(f->color());
399 ui.f_Offset->setValue(f->offset());
400 ui.f_Exposure->setValue(f->exposure());
401 ui.f_LockedFilter->setText(f->lockedFilter());
402 ui.f_UseAutoFocus->setChecked(f->useAutoFocus());
403 ui.f_AbsoluteFocusPosition->setValue(f->absoluteFocusPosition());
404 ui.f_FocusTemperature->setValue(f->focusTemperature());
405 ui.f_FocusAltitude->setValue(f->focusAltitude());
406 ui.f_FocusTicksPerTemp->setValue(f->focusTicksPerTemp());
407 ui.f_FocusTicksPerAlt->setValue(f->focusTicksPerAlt());
408 ui.f_Wavelength->setValue(f->wavelength());
413void EquipmentWriter::slotNewFilter()
417 ui.f_Vendor->clear();
421 ui.f_Offset->setValue(0);
422 ui.f_Exposure->setValue(1);
423 ui.f_LockedFilter->setText(NULL_FILTER);
424 ui.f_UseAutoFocus->setChecked(
false);
425 ui.f_AbsoluteFocusPosition->setValue(0);
426 ui.f_FocusTemperature->setValue(Ekos::INVALID_VALUE);
427 ui.f_FocusAltitude->setValue(Ekos::INVALID_VALUE);
428 ui.f_FocusTicksPerTemp->setValue(0.0);
429 ui.f_FocusTicksPerAlt->setValue(0.0);
430 ui.f_Wavelength->setValue(500.0);
431 ui.FilterList->selectionModel()->clear();
435void EquipmentWriter::loadEquipment()
437 KStarsData::Instance()->
logObject()->readScopes();
438 KStarsData::Instance()->
logObject()->readEyepieces();
439 KStarsData::Instance()->
logObject()->readLenses();
440 KStarsData::Instance()->
logObject()->readFilters();
441 KStarsData::Instance()->
logObject()->readDSLRLenses();
442 ui.ScopeList->clear();
443 ui.EyepieceList->clear();
444 ui.LensList->clear();
445 ui.FilterList->clear();
446 ui.DSLRLensList->clear();
447 foreach (
OAL::Scope *s, *(KStarsData::Instance()->logObject()->scopeList()))
448 ui.ScopeList->addItem(s->name());
449 foreach (OAL::Eyepiece *e, *(KStarsData::Instance()->logObject()->eyepieceList()))
450 ui.EyepieceList->addItem(e->name());
451 foreach (
OAL::Lens *l, *(KStarsData::Instance()->logObject()->lensList()))
452 ui.LensList->addItem(l->name());
453 foreach (
OAL::Filter *f, *(KStarsData::Instance()->logObject()->filterList()))
454 ui.FilterList->addItem(f->name());
455 foreach (
OAL::DSLRLens *l, *(KStarsData::Instance()->logObject()->dslrLensList()))
456 ui.DSLRLensList->addItem(l->name());
459 DriverManager::Instance()->updateCustomDrivers();
463void EquipmentWriter::slotSave()
465 switch (ui.tabWidget->currentIndex())
473 ui.ScopeList->clear();
474 foreach (
OAL::Scope *s, *(KStarsData::Instance()->logObject()->scopeList()))
475 ui.ScopeList->addItem(s->name());
484 ui.EyepieceList->clear();
485 foreach (OAL::Eyepiece *e, *(KStarsData::Instance()->logObject()->eyepieceList()))
486 ui.EyepieceList->addItem(e->name());
495 ui.DSLRLensList->clear();
496 for (
const auto &l : * (KStarsData::Instance()->logObject()->dslrLensList()))
497 ui.DSLRLensList->addItem(l->name());
506 ui.LensList->clear();
507 foreach (
OAL::Lens *l, *(KStarsData::Instance()->logObject()->lensList()))
508 ui.LensList->addItem(l->name());
517 ui.FilterList->clear();
518 foreach (
OAL::Filter *f, *(KStarsData::Instance()->logObject()->filterList()))
519 ui.FilterList->addItem(f->name());
525void EquipmentWriter::slotClose()
bool AddFilter(const filterProperties *fp)
Add a new filter to the database.
bool AddLens(const QString &vendor, const QString &model, const double &factor)
Add a new lens to the database.
bool AddDSLRLens(const QString &model, const QString &vendor, const double focalLength, const double focalRatio)
Appends the DSLR lens with given details in the database.
bool AddScope(const QString &model, const QString &vendor, const QString &type, const double &aperture, const double &focalLength)
Appends the scope with given details in the database.
bool DeleteEquipment(const QString &type, const QString &id)
Erase the equipment with given type and unique id Valid equipment types: "telescope",...
bool AddEyepiece(const QString &vendor, const QString &model, const double &focalLength, const double &fov, const QString &fovunit)
Add new eyepiece to database.
OAL::Log * logObject()
Return log object.
Information on DSLR lens used in astrophotography.
Information of user filters.
Information of lens utilized in the observation.
Information on telescope used in observation.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void currentTextChanged(const QString ¤tText)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)