summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelarkode Suresh Adityan <[email protected]>2015-06-21 16:15:49 +0530
committerMelarkode Suresh Adityan <[email protected]>2015-06-21 16:15:49 +0530
commitf9174e3497e7fe06f922341c3bf5b1bc8f54d552 (patch)
treed72a895fab77bf88ed3bb10b1c82fc3a9f1099fb
parent78db2b4a1791ee7bda80972f447c77b2b6a1138d (diff)
Review commit for Jasem
-rw-r--r--kstars/CMakeLists.txt3
-rw-r--r--kstars/data/skycultures/western/constellationsart.txt170
-rw-r--r--kstars/skycomponents/constartcomponent.cpp138
-rw-r--r--kstars/skycomponents/constartcomponent.h59
-rw-r--r--kstars/skycomponents/constellationlines.cpp4
-rw-r--r--kstars/skycomponents/constellationsart.cpp59
-rw-r--r--kstars/skycomponents/skymapcomposite.cpp11
-rw-r--r--kstars/skycomponents/skymapcomposite.h4
-rw-r--r--kstars/skyobjects/constellationsart.cpp49
-rw-r--r--kstars/skyobjects/constellationsart.h (renamed from kstars/skycomponents/constellationsart.h)90
-rw-r--r--kstars/texturemanager.cpp18
11 files changed, 412 insertions, 193 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index eb2a2d4..0bbc9ab 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -253,9 +253,9 @@ set(libkstarscomponents_SRCS
skycomponents/deepstarcomponent.cpp
skycomponents/deepskycomponent.cpp
skycomponents/catalogcomponent.cpp
+ skycomponents/constartcomponent.cpp
skycomponents/constellationboundarylines.cpp
skycomponents/constellationlines.cpp
- skycomponents/constellationsart.cpp
skycomponents/constellationnamescomponent.cpp
skycomponents/supernovaecomponent.cpp
skycomponents/coordinategrid.cpp
@@ -323,6 +323,7 @@ set(kstars_optionsui_SRCS
)
set(kstars_skyobjects_SRCS
+ skyobjects/constellationsart.cpp
skyobjects/deepskyobject.cpp
skyobjects/jupitermoons.cpp
skyobjects/planetmoons.cpp
diff --git a/kstars/data/skycultures/western/constellationsart.txt b/kstars/data/skycultures/western/constellationsart.txt
index 7a436ba..c3a0b8b 100644
--- a/kstars/data/skycultures/western/constellationsart.txt
+++ b/kstars/data/skycultures/western/constellationsart.txt
@@ -13,88 +13,88 @@
# Constellation serial number,x1,y1,HD1,x2,y2,HD2,x3,y3,HD3,Abbrev, Image file
# where xn,yn,HDn stand for x-coordinate of pixel of star n, y-coordinate of pixel of star n, HD number of star n
# x1 y1 hd1 x2 y2 hd2 x3 y3 hd3 Abbrev Image file
-1 198 215 4727 337 136 3627 224 428 12533 And andromeda.png
-2 4 84 90610 72 69 84367 42 120 86629 Ant antlia.png
-3 66 60 149324 76 87 147675 163 110 129078 Aps apus.png
-4 163 232 187642 385 131 176411 397 397 177756 Aql aquila.png
-5 144 464 220321 179 98 209750 465 49 198001 Aqr aquarius.png
-6 98 70 152786 191 93 158094 107 249 165024 Ara ara.png
-7 12 130 17573 58 206 18519 210 47 11502 Ari aries.png
-8 196 189 40312 419 208 34029 290 423 31398 Aur auriga.png
-9 225 222 129989 365 184 127762 207 401 121370 Boo bootes.png
-10 16 231 28873 76 145 29875 199 75 29992 Cae caelum.png
-11 77 46 33564 128 135 30614 219 136 21291 Cam camelopardalis.png
-12 29 166 76756 101 255 69267 206 91 69897 Cnc cancer.png
-13 15 436 207098 403 7 192947 460 438 198542 Cap capricornus.png
-14 202 455 80007 62 216 88955 298 22 67523 Car argonavis.png
-15 390 336 11415 163 156 3712 73 243 432 Cas cassiopeia.png
-16 118 157 123139 194 444 128620 463 412 100841 Cen centaurus.png
-17 60 335 222404 125 170 205021 335 147 210745 Cep cepheus.png
-18 87 63 18883 28 274 17081 412 440 1522 Cet cetus.png
-19 29 214 106911 73 123 92305 184 33 71243 Cha chamaeleon.png
-20 5 36 136415 39 11 135379 235 239 128898 Cir circinus.png
-21 21 347 58350 321 24 50778 318 492 44402 CMa canis-major.png
-22 96 43 62832 101 171 61421 184 124 58715 CMi canis-minor.png
-23 139 29 44762 40 190 40808 204 211 36597 Col columba.png
-24 27 199 114378 38 58 114710 172 64 108381 Com coma-berenices.png
-25 14 142 177474 218 34 170642 195 208 175219 CrA corona-australis.png
-26 16 186 143807 201 203 140436 157 20 138749 CrB corona-borealis.png
-27 45 41 103632 160 149 55282 55 242 97277 Crt crater.png
-28 112 21 108903 42 20 111123 21 106 108248 Cru crux.png
-29 65 59 108767 77 235 109379 213 187 105707 Crv corvus.png
-30 117 113 113797 206 40 109358 207 152 109317 Cvn canes-venatici.png
-31 7 382 206826 474 46 181276 467 453 183913 Cyg cygnus.png
-32 59 31 197964 75 148 198390 211 143 195810 Del delphinus.png
-33 56 197 40409 75 228 39014 219 46 27290 Dor dorado.png
-34 13 411 100029 361 154 159181 449 429 188119 Dra draco.png
-35 17 180 201601 149 86 202448 160 160 203562 Equ equuleus.png
-36 41 95 30211 296 44 18322 493 490 10144 Eri eridanus.png
-37 42 125 20010 128 37 17729 190 129 17652 For fornax.png
-38 14 81 62345 117 252 48737 249 165 41116 Gem gemini.png
-39 49 109 218227 85 206 215789 220 45 207971 Gru grus.png
-40 44 115 147547 254 477 147394 441 102 166014 Her hercules.png
-41 16 235 26967 184 67 16920 235 119 19319 Hor horlogium.png
-42 26 491 115659 111 149 98664 401 33 76294 Hya hydra.png
-43 14 204 12311 201 43 2151 241 215 24512 Hyi hydrus.png
-44 64 143 196171 154 20 198700 175 98 202730 Ind indus.png
-45 249 42 212496 108 123 213420 67 215 211388 Lac lacerta.png
-46 69 411 102647 383 186 87901 321 32 84441 Leo leo.png
-47 21 48 41695 246 62 33802 213 235 32887 Lep lepus.png
-48 41 27 135742 58 170 142198 224 107 133216 Lib libra.png
-49 8 40 94264 214 127 82635 61 155 88960 LMi leo-minor.png
-50 90 257 134505 207 435 126354 425 239 136422 Lup lupus.png
-51 100 216 76943 337 212 58142 472 119 43378 Lyn lynx.png
-52 100 96 175588 157 38 172167 139 162 174638 Lyr lyra.png
-53 100 67 30612 179 136 37763 54 183 43107 Men mensa.png
-54 122 226 202627 168 148 199951 234 115 198232 Mic microscopium.png
-55 20 306 67594 394 80 47839 509 359 43232 Mon monoceros.png
-56 57 52 109026 177 68 110879 129 236 102249 Mus musca.png
-57 17 45 143546 101 38 145397 16 112 147971 Nor norma.png
-58 15 16 124882 236 239 205478 247 140 214846 Oct octans.png
-59 5 183 175638 452 47 141003 238 453 158643 Oph ophiuchus.png
-60 59 11 39587 329 477 38771 421 91 30652 Ori orion.png
-61 55 60 193924 110 208 188228 235 146 160635 Pav pavo.png
-62 164 41 206778 47 283 210459 409 349 886 Peg pegasus.png
-63 164 323 24760 299 175 20902 385 386 17584 Per perseus.png
-64 55 243 11695 209 15 496 229 214 6882 Phe phoenix.png
-65 4 252 50241 148 138 39523 167 38 39060 Pic pictor.png
-66 190 5 216763 82 202 207155 236 92 214748 PsA piscis-austrinus.png
-67 24 104 6118 111 489 12446 481 155 219615 Psc pisces.png
-68 152 220 72227 94 159 74575 44 202 74006 Pyx pyxis.png
-69 47 56 25422 78 88 27256 16 111 27442 Ret reticulum.png
-70 231 39 219784 240 106 221507 32 174 5737 Scl sculptor.png
-71 447 29 144217 62 365 158926 217 462 152334 Sco scorpius.png
-72 52 17 173764 224 124 170296 139 206 175156 Sct scutum.png
-73 26 54 90994 68 36 87887 118 84 85558 Sex sextans.png
-74 6 12 190608 249 213 185758 218 243 185958 Sge sagitta.png
-75 96 82 181577 307 492 181623 506 100 161592 Sgr sagittarius.png
-76 13 92 37202 399 438 21120 382 192 24076 Tau taurus.png
-77 30 66 172128 101 40 169467 106 92 169767 Tel telescopium.png
-78 26 12 141891 108 15 135382 60 106 150798 Tra triangulum-australe.png
-79 16 42 13161 13 70 13869 97 78 11443 Tri triangulum.png
-80 53 121 2884 154 86 219571 224 141 211416 Tuc tucana.png
-81 26 75 120315 452 272 71369 258 394 89021 UMa ursa-major.png
-82 15 20 8890 193 51 106112 93 209 148048 UMi ursa-minor.png
-83 65 389 130109 454 57 102212 338 382 116658 Vir virgo.png
-84 55 85 78045 210 122 57623 207 163 55865 Vol volans.png
-85 35 133 189849 174 111 183439 242 135 180554 Vul vulpecula.png
+1 198 215 4727 337 136 3627 224 428 12533 And andromeda
+2 4 84 90610 72 69 84367 42 120 86629 Ant antlia
+3 66 60 149324 76 87 147675 163 110 129078 Aps apus
+4 163 232 187642 385 131 176411 397 397 177756 Aql aquila
+5 144 464 220321 179 98 209750 465 49 198001 Aqr aquarius
+6 98 70 152786 191 93 158094 107 249 165024 Ara ara
+7 12 130 17573 58 206 18519 210 47 11502 Ari aries
+8 196 189 40312 419 208 34029 290 423 31398 Aur auriga
+9 225 222 129989 365 184 127762 207 401 121370 Boo bootes
+10 16 231 28873 76 145 29875 199 75 29992 Cae caelum
+11 77 46 33564 128 135 30614 219 136 21291 Cam camelopardalis
+12 29 166 76756 101 255 69267 206 91 69897 Cnc cancer
+13 15 436 207098 403 7 192947 460 438 198542 Cap capricornus
+14 202 455 80007 62 216 88955 298 22 67523 Car argonavis
+15 390 336 11415 163 156 3712 73 243 432 Cas cassiopeia
+16 118 157 123139 194 444 128620 463 412 100841 Cen centaurus
+17 60 335 222404 125 170 205021 335 147 210745 Cep cepheus
+18 87 63 18883 28 274 17081 412 440 1522 Cet cetus
+19 29 214 106911 73 123 92305 184 33 71243 Cha chamaeleon
+20 5 36 136415 39 11 135379 235 239 128898 Cir circinus
+21 21 347 58350 321 24 50778 318 492 44402 CMa canis-major
+22 96 43 62832 101 171 61421 184 124 58715 CMi canis-minor
+23 139 29 44762 40 190 40808 204 211 36597 Col columba
+24 27 199 114378 38 58 114710 172 64 108381 Com coma-berenices
+25 14 142 177474 218 34 170642 195 208 175219 CrA corona-australis
+26 16 186 143807 201 203 140436 157 20 138749 CrB corona-borealis
+27 45 41 103632 160 149 55282 55 242 97277 Crt crater
+28 112 21 108903 42 20 111123 21 106 108248 Cru crux
+29 65 59 108767 77 235 109379 213 187 105707 Crv corvus
+30 117 113 113797 206 40 109358 207 152 109317 Cvn canes-venatici
+31 7 382 206826 474 46 181276 467 453 183913 Cyg cygnus
+32 59 31 197964 75 148 198390 211 143 195810 Del delphinus
+33 56 197 40409 75 228 39014 219 46 27290 Dor dorado
+34 13 411 100029 361 154 159181 449 429 188119 Dra draco
+35 17 180 201601 149 86 202448 160 160 203562 Equ equuleus
+36 41 95 30211 296 44 18322 493 490 10144 Eri eridanus
+37 42 125 20010 128 37 17729 190 129 17652 For fornax
+38 14 81 62345 117 252 48737 249 165 41116 Gem gemini
+39 49 109 218227 85 206 215789 220 45 207971 Gru grus
+40 44 115 147547 254 477 147394 441 102 166014 Her hercules
+41 16 235 26967 184 67 16920 235 119 19319 Hor horlogium
+42 26 491 115659 111 149 98664 401 33 76294 Hya hydra
+43 14 204 12311 201 43 2151 241 215 24512 Hyi hydrus
+44 64 143 196171 154 20 198700 175 98 202730 Ind indus
+45 249 42 212496 108 123 213420 67 215 211388 Lac lacerta
+46 69 411 102647 383 186 87901 321 32 84441 Leo leo
+47 21 48 41695 246 62 33802 213 235 32887 Lep lepus
+48 41 27 135742 58 170 142198 224 107 133216 Lib libra
+49 8 40 94264 214 127 82635 61 155 88960 LMi leo-minor
+50 90 257 134505 207 435 126354 425 239 136422 Lup lupus
+51 100 216 76943 337 212 58142 472 119 43378 Lyn lynx
+52 100 96 175588 157 38 172167 139 162 174638 Lyr lyra
+53 100 67 30612 179 136 37763 54 183 43107 Men mensa
+54 122 226 202627 168 148 199951 234 115 198232 Mic microscopium
+55 20 306 67594 394 80 47839 509 359 43232 Mon monoceros
+56 57 52 109026 177 68 110879 129 236 102249 Mus musca
+57 17 45 143546 101 38 145397 16 112 147971 Nor norma
+58 15 16 124882 236 239 205478 247 140 214846 Oct octans
+59 5 183 175638 452 47 141003 238 453 158643 Oph ophiuchus
+60 59 11 39587 329 477 38771 421 91 30652 Ori orion
+61 55 60 193924 110 208 188228 235 146 160635 Pav pavo
+62 164 41 206778 47 283 210459 409 349 886 Peg pegasus
+63 164 323 24760 299 175 20902 385 386 17584 Per perseus
+64 55 243 11695 209 15 496 229 214 6882 Phe phoenix
+65 4 252 50241 148 138 39523 167 38 39060 Pic pictor
+66 190 5 216763 82 202 207155 236 92 214748 PsA piscis-austrinus
+67 24 104 6118 111 489 12446 481 155 219615 Psc pisces
+68 152 220 72227 94 159 74575 44 202 74006 Pyx pyxis
+69 47 56 25422 78 88 27256 16 111 27442 Ret reticulum
+70 231 39 219784 240 106 221507 32 174 5737 Scl sculptor
+71 447 29 144217 62 365 158926 217 462 152334 Sco scorpius
+72 52 17 173764 224 124 170296 139 206 175156 Sct scutum
+73 26 54 90994 68 36 87887 118 84 85558 Sex sextans
+74 6 12 190608 249 213 185758 218 243 185958 Sge sagitta
+75 96 82 181577 307 492 181623 506 100 161592 Sgr sagittarius
+76 13 92 37202 399 438 21120 382 192 24076 Tau taurus
+77 30 66 172128 101 40 169467 106 92 169767 Tel telescopium
+78 26 12 141891 108 15 135382 60 106 150798 Tra triangulum-australe
+79 16 42 13161 13 70 13869 97 78 11443 Tri triangulum
+80 53 121 2884 154 86 219571 224 141 211416 Tuc tucana
+81 26 75 120315 452 272 71369 258 394 89021 UMa ursa-major
+82 15 20 8890 193 51 106112 93 209 148048 UMi ursa-minor
+83 65 389 130109 454 57 102212 338 382 116658 Vir virgo
+84 55 85 78045 210 122 57623 207 163 55865 Vol volans
+85 35 133 189849 174 111 183439 242 135 180554 Vul vulpecula
diff --git a/kstars/skycomponents/constartcomponent.cpp b/kstars/skycomponents/constartcomponent.cpp
new file mode 100644
index 0000000..3c38473
--- /dev/null
+++ b/kstars/skycomponents/constartcomponent.cpp
@@ -0,0 +1,138 @@
+/***************************************************************************
+ constartcomponent.cpp - K Desktop Planetarium
+ -------------------
+ begin : 2015-05-27
+ copyright : (C) 2015 by M.S.Adityan
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "constartcomponent.h"
+#include "kstars/auxiliary/ksfilereader.h"
+
+ConstArtComponent::ConstArtComponent( SkyComposite *parent ):SkyComponent(parent)
+{
+ loadData();
+}
+
+ConstArtComponent::~ConstArtComponent()
+{ while( !m_ConstList.isEmpty() ) {
+ ConstellationsArt *o = m_ConstList.takeFirst();
+ delete o;
+ }
+}
+
+void ConstArtComponent::loadData(){
+
+ int i = 0;
+
+ // Find constellation art file and open it. If it doesn't exist, output an error message.
+ KSFileReader fileReader;
+ if ( ! fileReader.open("constellationsart.txt" ) )
+ {
+ qDebug() << "No constellationsart.txt file found for sky culture";
+ return;
+ }
+
+ while ( fileReader.hasMoreLines() ) {
+ QString line;
+
+ line = fileReader.readLine();
+ if( line.isEmpty() )
+ continue;
+ QChar mode = line.at( 0 );
+ //ignore lines beginning with "#":
+ if( mode == '#' )
+ continue;
+
+ //reads the first column from constellationart.txt
+ m_ConstList[i]->rank = line.mid(0,2).trimmed().toInt();
+
+ //Read pixel coordinates and HD number of star 1
+ m_ConstList[i]->x1 = line.mid( 3, 3 ).trimmed().toInt();
+ m_ConstList[i]->y1 = line.mid( 7, 3 ).trimmed().toInt();
+ m_ConstList[i]->hd1 = line.mid( 11, 6 ).trimmed().toInt();
+
+ //Read pixel coordinates and HD number of star 2
+ m_ConstList[i]->x2 = line.mid( 18, 3 ).trimmed().toInt();
+ m_ConstList[i]->y2 = line.mid( 22, 3 ).trimmed().toInt();
+ m_ConstList[i]->hd2 = line.mid( 26, 6 ).trimmed().toInt();
+
+ //Read pixel coordinates and HD number of star 3
+ m_ConstList[i]->x3 = line.mid( 33, 3 ).trimmed().toInt();
+ m_ConstList[i]->y3 = line.mid( 37, 3 ).trimmed().toInt();
+ m_ConstList[i]->hd3 = line.mid( 41, 6 ).trimmed().toInt();
+
+ //Read abbreviation and image file name
+ m_ConstList[i]->abbrev = line.mid( 48, 3 );
+ m_ConstList[i]->imageFileName = line.mid( 52 ).trimmed();
+
+ //Make a QImage object pointing to constellation image
+ m_ConstList[i]->constart_image = QImage(m_ConstList[i]->imageFileName,0);
+ i++;
+
+ //qDebug()<<i;
+
+ //qDebug()<< "Serial number:"<<rank<<"x1:"<<x1<<"y1:"<<y1<<"HD1:"<<hd1<<"x2:"<<x2<<"y2:"<<y2<<"HD2:"<<hd2<<"x3:"<<x3<<"y3:"<<y3<<"HD3:"<<hd3<<"abbreviation:"<<abbrev<<"name"<<imageFileName;
+ //testing to see if the file opens and outputs the data
+ }
+}
+
+void ConstArtComponent::showList()
+{
+ int i = 0;
+ for(i = 0; i < m_ConstList.size(); i++)
+ {
+ qDebug()<<m_ConstList[i]->rank<<m_ConstList[i]->getAbbrev()<<m_ConstList[i]->getImageFileName();
+ qDebug()<<m_ConstList[i]->getx1()<<m_ConstList[i]->gety1()<<m_ConstList[i]->gethd1();
+ qDebug()<<m_ConstList[i]->getx2()<<m_ConstList[i]->gety2()<<m_ConstList[i]->gethd2();
+ qDebug()<<m_ConstList[i]->getx3()<<m_ConstList[i]->gety3()<<m_ConstList[i]->gethd3();
+
+ }
+}
+
+void ConstArtComponent::draw(SkyPainter *skyp){
+
+ int i = 0;
+ //Loops through the QList containing all data required to draw western constellations.
+ //There are 85 images, so m_ConstList.size() should return 85.
+ for(i=0; i < m_ConstList.size(); i++){
+ drawConstArtImage( skyp, m_ConstList[i]);
+ }
+}
+
+void ConstArtComponent::drawConstArtImage(SkyPainter *skyp, ConstellationsArt *obj, bool drawImage)
+{
+ if(drawImage==false) return;
+
+ SkyMap *map = SkyMap::Instance();
+ const Projector *proj = map->projector();
+
+ KStarsData *data = KStarsData::Instance();
+ UpdateID updateID = data->updateID();
+
+ skyp->setBrush( Qt::NoBrush );
+
+ if ( obj->updateID != updateID ) {
+ obj->updateID = updateID;
+
+ int w = obj->imageWidth();
+ int h = obj->imageHeight();
+
+ QImage::save();
+
+ //How do I define position to translate?
+ QImage::translate(pos);
+ QImage::drawImage( QRect(-0.5*w, -0.5*h, w, h), obj->image() );
+ QImage::restore();
+
+ }
+}
diff --git a/kstars/skycomponents/constartcomponent.h b/kstars/skycomponents/constartcomponent.h
new file mode 100644
index 0000000..9494339
--- /dev/null
+++ b/kstars/skycomponents/constartcomponent.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ constartcomponent.h - K Desktop Planetarium
+ -------------------
+ begin : 2015-05-27
+ copyright : (C) 2015 by M.S.Adityan
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef CONSTARTCOMPONENT_H
+#define CONSTARTCOMPONENT_H
+
+#include "constellationsart.h"
+#include "skycomponent.h"
+#include <QImage>
+
+class ConstellationsArt;
+class QColor;
+class SkyMap;
+class SkyPoint;
+class SkyMesh;
+class QImage;
+
+class ConstArtComponent : public SkyComponent
+{
+public:
+
+ //Constructor
+ explicit ConstArtComponent ( SkyComposite* );
+
+ //Destructor
+ ~ConstArtComponent();
+
+ /*Read the file constellationsart.txt
+ This catalog has the following columns.
+ Constellation serial number,x1,y1,HD1,x2,y2,HD2,x3,y3,HD3,Abbrev,Image file*/
+ void loadData();
+
+ //Outputs details of the QList
+ void showList();
+
+ virtual void draw( SkyPainter *skyp );
+
+ QList<ConstellationsArt*> m_ConstList;
+
+private:
+
+ void drawConstArtImage(SkyPainter *skyp, ConstellationsArt *obj, bool drawImage = true);
+};
+
+#endif // CONSTARTCOMPONENT_H
diff --git a/kstars/skycomponents/constellationlines.cpp b/kstars/skycomponents/constellationlines.cpp
index a68c85f..44b39f2 100644
--- a/kstars/skycomponents/constellationlines.cpp
+++ b/kstars/skycomponents/constellationlines.cpp
@@ -17,7 +17,6 @@
#include "constellationlines.h"
#include "linelist.h"
-#include "constellationsart.h"
#include <QPen>
#include <QDebug>
@@ -33,7 +32,6 @@
#include "skymesh.h"
#include "ksfilereader.h"
-
#include "skypainter.h"
@@ -105,7 +103,6 @@ ConstellationLines::ConstellationLines( SkyComposite *parent, CultureList* cultu
qWarning() << xi18n( "Star HD%1 not found." , HDnum);
}
}
- ConstellationsArt art(57);
//Add the last clc component
if( lineList )
appendLine( lineList );
@@ -113,7 +110,6 @@ ConstellationLines::ConstellationLines( SkyComposite *parent, CultureList* cultu
m_reindexInterval = StarObject::reindexInterval( maxPM );
//printf("CLines: maxPM = %6.1f milliarcsec/year\n", maxPM );
//printf("CLines: Update Interval = %6.1f years\n", m_reindexInterval * 100.0 );
-
summary();
}
diff --git a/kstars/skycomponents/constellationsart.cpp b/kstars/skycomponents/constellationsart.cpp
deleted file mode 100644
index abaf040..0000000
--- a/kstars/skycomponents/constellationsart.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "constellationsart.h"
-#include "kstars/auxiliary/ksfilereader.h"
-
-ConstellationsArt::ConstellationsArt(int serial)
-{
- //artDisplayed(0);
-
- // Find constellation art file and open it. If it doesn't exist, output an error message.
-
- KSFileReader fileReader;
- if ( ! fileReader.open("constellationsart.txt" ) )
- {
- qDebug() << "No constellationsart.txt file found for sky culture";
- return;
- }
-
- while ( fileReader.hasMoreLines() ) {
- QString line;
-
- line = fileReader.readLine();
- if( line.isEmpty() )
- continue;
- QChar mode = line.at( 0 );
- //ignore lines beginning with "#":
- if( mode == '#' )
- continue;
-
- int rank=line.mid(0,2).trimmed().toInt(); //reads the first column from constellationart.txt
-
- //Read pixel coordinates and HD number of star 1
- x1 = line.mid( 3, 3 ).trimmed().toInt();
- y1 = line.mid( 7, 3 ).trimmed().toInt();
- hd1 = line.mid( 11, 6 ).trimmed().toInt();
-
-
- //Read pixel coordinates and HD number of star 2
- x2 = line.mid( 18, 3 ).trimmed().toInt();
- y2 = line.mid( 22, 3 ).trimmed().toInt();
- hd2 = line.mid( 26, 6 ).trimmed().toInt();
-
-
- //Read pixel coordinates and HD number of star
- x3 = line.mid( 33, 3 ).trimmed().toInt();
- y3 = line.mid( 37, 3 ).trimmed().toInt();
- hd3 = line.mid( 41, 6 ).trimmed().toInt();
-
- abbrev = line.mid( 48, 3 );
- imageFileName = line.mid( 52 ).trimmed();
-
- qDebug()<< "Serial number:"<<rank<<"x1:"<<x1<<"y1:"<<y1<<"HD1:"<<hd1<<"x2:"<<x2<<"y2:"<<y2<<"HD2:"<<hd2<<"x3:"<<x3<<"y3:"<<y3<<"HD3:"<<hd3<<"abbreviation:"<<abbrev<<"name"<<imageFileName;
- //testing to see if the file opens and outputs the data
-
- }
-
-}
-
-ConstellationsArt::~ConstellationsArt()
-{
-}
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index 066f6dc..1f72659 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -26,6 +26,7 @@
#include "skyobjects/starobject.h"
#include "skyobjects/deepskyobject.h"
#include "skyobjects/ksplanet.h"
+#include "constellationsart.h"
#include "targetlistcomponent.h"
#include "constellationboundarylines.h"
@@ -46,6 +47,7 @@
#include "flagcomponent.h"
#include "satellitescomponent.h"
#include "supernovaecomponent.h"
+#include "constartcomponent.h"
#include "skymesh.h"
@@ -84,6 +86,7 @@ SkyMapComposite::SkyMapComposite(SkyComposite *parent ) :
addComponent( m_Ecliptic = new Ecliptic( this ));
addComponent( m_Horizon = new HorizonComponent( this ));
addComponent( m_DeepSky = new DeepSkyComponent( this ));
+ addComponent(m_ConstArt = new ConstArtComponent( this ));
m_CustomCatalogs = new SkyComposite( this );
QStringList allcatalogs = Options::showCatalogNames();
@@ -237,6 +240,7 @@ void SkyMapComposite::draw( SkyPainter *skyp )
m_Ecliptic->draw( skyp );
m_DeepSky->draw( skyp );
+ m_ConstArt->draw( skyp );
m_CustomCatalogs->draw( skyp );
@@ -511,6 +515,13 @@ void SkyMapComposite::reloadCNames( ) {
m_CNames = new ConstellationNamesComponent( this, m_Cultures );
}
+void SkyMapComposite::reloadConstArt(){
+ Q_ASSERT( !SkyMapDrawAbstract::drawLock() );
+ SkyMapDrawAbstract::setDrawLock( true );
+ delete m_ConstArt;
+ m_ConstArt = new ConstArtComponent( this );
+}
+
void SkyMapComposite::reloadDeepSky() {
Q_ASSERT( !SkyMapDrawAbstract::drawLock() );
// Deselect object if selected! If not deselected then InfoBox tries to
diff --git a/kstars/skycomponents/skymapcomposite.h b/kstars/skycomponents/skymapcomposite.h
index 31894b7..03ff125 100644
--- a/kstars/skycomponents/skymapcomposite.h
+++ b/kstars/skycomponents/skymapcomposite.h
@@ -48,10 +48,12 @@ class TargetListComponent;
class TargetListComponent;
class SatellitesComponent;
class SupernovaeComponent;
+class ConstArtComponent;
class DeepSkyObject;
class KSPlanetBase;
class KSPlanet;
+class ConstellationsArt;
/** @class SkyMapComposite
*SkyMapComposite is the root object in the object hierarchy of the sky map.
@@ -164,6 +166,7 @@ public:
void reloadComets();
void reloadCLines();
void reloadCNames();
+ void reloadConstArt();
FlagComponent* flags();
SatellitesComponent* satellites();
@@ -206,6 +209,7 @@ private:
ConstellationBoundaryLines *m_CBoundLines;
ConstellationNamesComponent *m_CNames;
ConstellationLines *m_CLines;
+ ConstArtComponent *m_ConstArt;
EquatorialCoordinateGrid *m_EquatorialCoordinateGrid;
HorizontalCoordinateGrid *m_HorizontalCoordinateGrid;
DeepSkyComponent *m_DeepSky;
diff --git a/kstars/skyobjects/constellationsart.cpp b/kstars/skyobjects/constellationsart.cpp
new file mode 100644
index 0000000..6b4e583
--- /dev/null
+++ b/kstars/skyobjects/constellationsart.cpp
@@ -0,0 +1,49 @@
+/***************************************************************************
+ constellationsart.cpp - K Desktop Planetarium
+ -------------------
+ begin : 2015-05-27
+ copyright : (C) 2015 by M.S.Adityan
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "constellationsart.h"
+#include "kstars/texturemanager.h"
+
+ConstellationsArt::ConstellationsArt(int t, int serial, const QString &n){
+
+ setType(t);
+ setName(n);
+}
+
+ConstellationsArt::~ConstellationsArt()
+{
+}
+
+ConstellationsArt::ConstellationsArt(const ConstellationsArt &o){
+
+ x1 = o.getx1();
+ x2 = o.getx2();
+ x3 = o.getx3();
+ y1 = o.gety1();
+ y2 = o.gety2();
+ y3 = o.gety3();
+ hd1 = o.gethd1();
+ hd2 = o.gethd2();
+ hd3 = o.gethd3();
+ abbrev = o.getAbbrev();
+ imageFileName = o.getImageFileName();
+ constart_image = o.image();
+}
+
+void ConstellationsArt::loadImage()
+{
+ constart_image = TextureManager::getImage( imageFileName );
+}
diff --git a/kstars/skycomponents/constellationsart.h b/kstars/skyobjects/constellationsart.h
index b89cf11..ddd157d 100644
--- a/kstars/skycomponents/constellationsart.h
+++ b/kstars/skyobjects/constellationsart.h
@@ -20,82 +20,94 @@
#include <QDebug>
#include <QString>
-#include <QDir>
+#include <QImage>
#include "skycomponent.h"
#include "culturelist.h"
#include "kstars/skypainter.h"
+#include "kstars/skyobjects/skyobject.h"
+#include "constartcomponent.h"
+class QImage;
/** @class ConstellationsArt
* @short Represents images for sky cultures
* @author M.S.Adityan
*/
-class ConstellationsArt
-{
-private:
- QString abbrev, imageFileName;
- int x1,y1,x2,y2,x3,y3,hd1,hd2,hd3;
-
- /* bool artDisplayed;
+class ConstellationsArt: public SkyObject{
- Q_OBJECT
- Q_PROPERTY(bool artDisplayed
- READ getArt
- WRITE setArt
- NOTIFY artDisplayedChanged) */
+ friend class ConstArtComponent;
- /*Draw the constellation art
- void draw( SkyPainter* skyp ) const; */
+private:
+ QString abbrev, imageFileName;
+ int x1,y1,x2,y2,x3,y3,hd1,hd2,hd3,rank;
+ QImage constart_image;
public:
- //Constructor
- explicit ConstellationsArt(int serial);
+ /**
+ *Constructor. Set SkyObject data according to arguments.
+ *@param t Type of object
+ *@param serial Serial number from constellationsart.txt
+ *@param n Primary name
+ */
+ explicit ConstellationsArt(int t=SkyObject::CONSTELLATION, int serial=0, const QString &n=QString());
+
+ /** @short Copy constructor.
+ * @param o SkyObject from which to copy data
+ */
+ ConstellationsArt (const ConstellationsArt &o );
//Destructor
virtual ~ConstellationsArt();
- //@return the object's x1
+ /** @return an object's image */
+ const QImage& image() const { return constart_image; }
+
+ /** Load the object's image */
+ void loadImage();
+
+ /** @return an object image's width */
+ inline int imageWidth() const{ return constart_image.width(); }
+
+ /** @return an object image's height */
+ inline int imageHeight() const{ return constart_image.height(); }
+
+ /** @return an object's abbreviation */
+ inline QString getAbbrev() const { return abbrev;}
+
+ /** @return an object's image file name*/
+ inline QString getImageFileName() const {return imageFileName;}
+
+ /** @return an object's x1 */
inline int getx1() const { return x1; }
- //@return the object's y1
+ /** @return an object's y1 */
inline int gety1() const { return y1; }
- //@return the object's x2
+ /** @return an object's x2 */
inline int getx2() const { return x2; }
- //@return the object's y2
+ /** @return an object's y2 */
inline int gety2() const { return y2; }
- //@return the object's x3
+ /** @return an object's x3 */
inline int getx3() const { return x3; }
- //@return the object's y3
+ /** @return an object's y3 */
inline int gety3() const { return y3; }
- //@return the object's hd1
+ /** @return an object's hd1 */
inline int gethd1() const { return hd1; }
- //@return the object's hd2
+ /** @return an object's hd2 */
inline int gethd2() const { return hd2; }
- //@return the object's hd3
+ /** @return an object's hd3 */
inline int gethd3() const { return hd3; }
-
- /* //Getters and setters
-public slots:
- //Sets whether constellation art is be displayed
- void setArt(const bool displayed);
-
- //Gets if constellation art is displayed
- bool getArt(void) const;
-
-signals:
-
- void artDisplayedChanged(const bool displayed) const; */
-
+ //UpdateID which would be compared with the global updateID to know when to redraw a skyobject in a draw cycle
+ quint64 updateID;
};
#endif // CONSTELLATIONSART_H
diff --git a/kstars/texturemanager.cpp b/kstars/texturemanager.cpp
index 5997993..6d09a10 100644
--- a/kstars/texturemanager.cpp
+++ b/kstars/texturemanager.cpp
@@ -68,13 +68,21 @@ TextureManager::CacheIter TextureManager::findTexture(const QString& name)
if( !filename.isNull() ) {
return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename,"PNG") );
} else {
- // Try to load from file in main data directory
- filename = QStandardPaths::locate(QStandardPaths::DataLocation, QString("%1.png").arg(name));
+ //Try to load from the file in 'skycultures/western' subdirectory for western constellation art
+ QString filename = QStandardPaths::locate(QStandardPaths::DataLocation, QString("skycultures/western/%1.png").arg(name));
if( !filename.isNull() ) {
return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename,"PNG") );
- } else {
- return m_p->m_textures.constEnd();
- }
+ } else {
+ // Try to load from file in main data directory
+ filename = QStandardPaths::locate(QStandardPaths::DataLocation, QString("%1.png").arg(name));
+ if( !filename.isNull() ) {
+ return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename,"PNG") );
+ } else {
+ return m_p->m_textures.constEnd();
+ }
+
+ }
+
}
}
}