• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • skycomponents
milkyway.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  milkyway.cpp - K Desktop Planetarium
3  -------------------
4  begin : 12 Nov. 2005
5  copyright : (C) 2005 by Jason Harris
6  email : kstars@30doradus.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "milkyway.h"
19 
20 #include <QList>
21 #include <QPointF>
22 #include <QPolygonF>
23 
24 #include <klocale.h>
25 
26 #include "kstarsdata.h"
27 #include "skymap.h"
28 #include "skyobjects/skypoint.h"
29 #include "dms.h"
30 #include "Options.h"
31 #include "ksfilereader.h"
32 #include "skycomponents/skiplist.h"
33 
34 #include "skymesh.h"
35 
36 #include "skypainter.h"
37 
38 
39 MilkyWay::MilkyWay( SkyComposite *parent ) :
40  LineListIndex( parent, i18n("Milky Way") )
41 {
42  intro();
43  // Milky way
44  loadContours("milkyway.dat", i18n("Loading Milky Way"));
45  // Magellanic clouds
46  loadContours("lmc.dat", i18n("Loading Large Magellanic Clouds"));
47  loadContours("smc.dat", i18n("Loading Small Magellanic Clouds"));
48  summary();
49 }
50 
51 const IndexHash& MilkyWay::getIndexHash(LineList* lineList ) {
52  // FIXME: EVIL!
53  SkipList* skipList = (SkipList*) lineList;
54  return skyMesh()->indexLine( skipList->points(), skipList->skipHash() );
55 }
56 
57 SkipList* MilkyWay::skipList( LineList* lineList ) {
58  // FIXME: EVIL!
59  SkipList* skipList = (SkipList*) lineList;
60  return skipList;
61 }
62 
63 bool MilkyWay::selected()
64 {
65  return Options::showMilkyWay() &&
66  ! ( Options::hideOnSlew() && Options::hideMilkyWay() && SkyMap::IsSlewing() );
67 }
68 
69 void MilkyWay::draw( SkyPainter *skyp )
70 {
71  if ( !selected() )
72  return;
73 
74  QColor color = KStarsData::Instance()->colorScheme()->colorNamed( "MWColor" );
75  skyp->setPen( QPen( color, 3, Qt::SolidLine ) );
76  skyp->setBrush( QBrush( color ) );
77 
78  if( Options::fillMilkyWay() ) {
79  drawFilled(skyp);
80  } else {
81  drawLines(skyp);
82  }
83 }
84 
85 void MilkyWay::loadContours(QString fname, QString greeting) {
86 
87  KSFileReader fileReader;
88  if ( !fileReader.open( fname ) )
89  return;
90  fileReader.setProgress( greeting, 2136, 5 );
91 
92  SkipList *skipList = 0;
93  int iSkip = 0;
94  while ( fileReader.hasMoreLines() ) {
95  QString line = fileReader.readLine();
96  fileReader.showProgress();
97 
98  QChar firstChar = line.at( 0 );
99  if ( firstChar == '#' )
100  continue;
101 
102  bool okRA, okDec;
103  double ra = line.mid( 2, 8 ).toDouble(&okRA);
104  double dec = line.mid( 11, 8 ).toDouble(&okDec);
105  if( !okRA || !okDec) {
106  kDebug() << QString("%1: conversion error on line: %2\n").arg(fname).arg(fileReader.lineNumber());
107  continue;
108  }
109 
110  if ( firstChar == 'M' ) {
111  if( skipList )
112  appendBoth( skipList );
113  skipList = 0;
114  iSkip = 0;
115  }
116 
117  if( !skipList )
118  skipList = new SkipList();
119 
120  skipList->append( new SkyPoint(ra, dec) );
121  if ( firstChar == 'S' )
122  skipList->setSkip( iSkip );
123  iSkip++;
124  }
125  if ( skipList )
126  appendBoth( skipList );
127 }
KSFileReader::hasMoreLines
bool hasMoreLines()
Definition: ksfilereader.h:108
SkyPainter::setBrush
virtual void setBrush(const QBrush &brush)=0
Set the brush of the painter.
Options::hideMilkyWay
static bool hideMilkyWay()
Get Hide Milky Way contour while moving?
Definition: Options.h:1208
skiplist.h
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
MilkyWay::skipList
virtual SkipList * skipList(LineList *lineList)
Returns a boolean indicating whether to skip the i-th line segment in the SkipList skipList...
Definition: milkyway.cpp:57
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
MilkyWay::draw
virtual void draw(SkyPainter *skyp)
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
Definition: milkyway.cpp:69
Options::showMilkyWay
static bool showMilkyWay()
Get Draw Milky Way contour in the sky map?
Definition: Options.h:1892
SkipList::setSkip
void setSkip(int i)
Definition: skiplist.h:46
ColorScheme::colorNamed
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:97
skypainter.h
MilkyWay::selected
virtual bool selected()
Definition: milkyway.cpp:63
Options::hideOnSlew
static bool hideOnSlew()
Get Hide objects while moving?
Definition: Options.h:1094
LineList
Definition: linelist.h:35
LineListIndex::intro
void intro()
Definition: linelistindex.cpp:224
dms.h
KSFileReader::open
bool open(const QString &fname)
Definition: ksfilereader.cpp:46
LineList::points
SkyList * points()
Definition: linelist.h:53
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
Options::fillMilkyWay
static bool fillMilkyWay()
Get Fill Milky Way contour? (false means use outline only)
Definition: Options.h:1911
MilkyWay::getIndexHash
const IndexHash & getIndexHash(LineList *skipList)
Returns an IndexHash from the SkyMesh that contains the set of trixels that cover the SkipList lineLi...
Definition: milkyway.cpp:51
skymap.h
KSFileReader::showProgress
void showProgress()
Definition: ksfilereader.cpp:83
LineListIndex::drawLines
void drawLines(SkyPainter *skyp)
Definition: linelistindex.cpp:177
SkyComposite
SkyComposite is a kind of container class for SkyComponent objects.
Definition: skycomposite.h:43
skypoint.h
SkyPainter::setPen
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
Options.h
ksfilereader.h
KSFileReader::readLine
QString readLine()
Definition: ksfilereader.h:113
milkyway.h
KSFileReader
Definition: ksfilereader.h:65
LineListIndex
Definition: linelistindex.h:39
MilkyWay::loadContours
void loadContours(QString fname, QString greeting)
Load skiplists from file.
Definition: milkyway.cpp:85
LineListIndex::skyMesh
SkyMesh * skyMesh()
Definition: linelistindex.h:92
LineListIndex::drawFilled
void drawFilled(SkyPainter *skyp)
Definition: linelistindex.cpp:198
KSFileReader::setProgress
void setProgress(QString label, unsigned int lastLine, unsigned int numUpdates=10)
Definition: ksfilereader.cpp:69
SkyMap::IsSlewing
static bool IsSlewing()
Definition: skymap.h:91
LineListIndex::appendBoth
void appendBoth(LineList *lineList, int debug=0)
Definition: linelistindex.cpp:110
SkyMesh::indexLine
const IndexHash & indexLine(SkyList *points)
Definition: skymesh.cpp:159
IndexHash
QHash< Trixel, bool > IndexHash
Definition: skycomponents/typedef.h:46
LineListIndex::summary
void summary()
Definition: linelistindex.cpp:232
LineList::append
void append(SkyPoint *p)
Definition: linelist.h:55
kstarsdata.h
skymesh.h
MilkyWay::MilkyWay
MilkyWay(SkyComposite *parent)
Constructor parent pointer to the parent SkyComposite.
Definition: milkyway.cpp:39
SkipList::skipHash
IndexHash * skipHash()
Definition: skiplist.h:41
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
KSFileReader::lineNumber
int lineNumber()
Definition: ksfilereader.h:120
SkipList
Definition: SkipList.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal