Kstars

constellationartcomponent.cpp
1/*
2 SPDX-FileCopyrightText: 2015 M.S.Adityan <msadityan@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "constellationartcomponent.h"
8
9#include "constellationsart.h"
10#include "culturelist.h"
11#include "kspaths.h"
12#include "Options.h"
13#ifndef KSTARS_LITE
14#include "skymap.h"
15#include "skypainter.h"
16#endif
17
18#include <QSqlError>
19#include <QSqlQuery>
20
22{
23 cultureName = cultures->current();
24 records = 0;
25 loadData();
26}
27
32
34{
35 qDeleteAll(m_ConstList);
36 m_ConstList.clear();
37}
38
40{
41 if (m_ConstList.isEmpty())
42 {
43 QSqlDatabase skydb = QSqlDatabase::addDatabase("QSQLITE", "skycultures");
44 QString dbfile = KSPaths::locate(QStandardPaths::AppLocalDataLocation, "skycultures.sqlite");
45
46 skydb.setDatabaseName(dbfile);
47 if (skydb.open() == false)
48 {
49 qWarning() << "Unable to open sky cultures database file " << dbfile;
50 return;
51 }
53
54 if (cultureName == "Western")
55 {
56 if (!get_query.exec("SELECT * FROM western"))
57 {
58 qDebug() << Q_FUNC_INFO << get_query.lastError();
59 return;
60 }
61 }
62 if (cultureName == "Inuit")
63 {
64 if (!get_query.exec("SELECT * FROM inuit"))
65 {
66 qDebug() << Q_FUNC_INFO << get_query.lastError();
67 return;
68 }
69 }
70
71 while (get_query.next())
72 {
73 QString abbreviation = get_query.value("Abbreviation").toString();
74 QString filename = get_query.value("Filename").toString();
75 QString midpointRA = get_query.value("MidpointRA").toString();
76 QString midpointDEC = get_query.value("MidpointDEC").toString();
77 double pa = get_query.value("Position Angle").toDouble();
78 double w = get_query.value("Width").toDouble();
79 double h = get_query.value("Height").toDouble();
80
83
84 // appends constellation info
85 ConstellationsArt *ca = new ConstellationsArt(midpointra, midpointdec, pa, w, h, abbreviation, filename);
86 m_ConstList.append(ca);
87 //qDebug()<<"Successfully read skyculture.sqlite"<<abbreviation<<filename<<midpointRA<<midpointDEC<<pa<<w<<h;
88 records++;
89 }
90 //qDebug()<<"Successfully processed"<<records<<"records for"<<cultureName<<"sky culture";
91 skydb.close();
92 }
93}
94
96{
97 int i = 0;
98 for (i = 0; i < m_ConstList.size(); i++)
99 {
100 qDebug() << Q_FUNC_INFO << m_ConstList[i]->getAbbrev() << m_ConstList[i]->getImageFileName();
101 qDebug() << Q_FUNC_INFO << m_ConstList[i]->pa();
102 }
103}
104
106{
108#ifndef KSTARS_LITE
109 if (Options::showConstellationArt() && SkyMap::IsSlewing() == false)
110 {
111 for (int i = 0; i < records; i++)
112 skyp->drawConstellationArtImage(m_ConstList[i]);
113 }
114
115//Loops through the QList containing all data required to draw constellations.
116#endif
117}
void showList()
Shows the details of the constellations selected skyculture.
~ConstellationArtComponent() override
Destructor.
void loadData()
Read the skycultures.sqlite database file.
void deleteData()
deletes all created ConstellationsArt objects.
ConstellationArtComponent(SkyComposite *, CultureList *cultures)
Constructor.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Information about a ConstellationsArt object.
A list of all cultures FIXME: Why not use a QStringList?
Definition culturelist.h:17
SkyComponent represents an object on the sky map.
SkyComposite is a kind of container class for SkyComponent objects.
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
static dms fromString(const QString &s, bool deg)
Static function to create a DMS object from a QString.
Definition dms.cpp:429
void append(QList< T > &&value)
void clear()
bool isEmpty() const const
qsizetype size() const const
QSqlDatabase addDatabase(QSqlDriver *driver, const QString &connectionName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.