• 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
skymapqdraw.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  skymapqdraw.cpp - K Desktop Planetarium
3  -------------------
4  begin : Tue Dec 21 2010 08:36 AM UTC-6
5  copyright : (C) 2010 Akarsh Simha
6  email : akarsh.simha@kdemail.net
7  ***************************************************************************/
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "skymapqdraw.h"
18 #include "skymapcomposite.h"
19 #include "skyqpainter.h"
20 #include "skymap.h"
21 #include "printing/legend.h"
22 
23 SkyMapQDraw::SkyMapQDraw( SkyMap *sm ) : QWidget( sm ), SkyMapDrawAbstract( sm ) {
24  m_SkyPixmap = new QPixmap( width(), height() );
25 }
26 
27 SkyMapQDraw::~SkyMapQDraw() {
28  delete m_SkyPixmap;
29 }
30 
31 void SkyMapQDraw::paintEvent( QPaintEvent *event ) {
32  Q_UNUSED(event);
33  // This is machinery to prevent multiple concurrent paint events / recursive paint events
34  if( m_DrawLock ) {
35  kDebug() << "I just prevented a recursive / concurrent draw!";
36  return;
37  }
38  setDrawLock( true );
39 
40  calculateFPS();
41 
42 
43  //If computeSkymap is false, then we just refresh the window using the stored sky pixmap
44  //and draw the "overlays" on top. This lets us update the overlay information rapidly
45  //without needing to recompute the entire skymap.
46  //use update() to trigger this "short" paint event; to force a full "recompute"
47  //of the skymap, use forceUpdate().
48 
49  if (!m_SkyMap->computeSkymap)
50  {
51  QPainter p;
52  p.begin( this );
53  p.drawLine(0,0,1,1); // Dummy operation to circumvent bug. TODO: Add details
54  p.drawPixmap( 0, 0, *m_SkyPixmap );
55  drawOverlays(p);
56  p.end();
57 
58  setDrawLock( false );
59  return ; // exit because the pixmap is repainted and that's all what we want
60  }
61 
62  // FIXME: used to to notify infobox about possible change of object coordinates
63  // Not elegant at all. Should find better option
64  m_SkyMap->showFocusCoords();
65  m_SkyMap->setupProjector();
66 
67  SkyQPainter psky(this, m_SkyPixmap);
68  //FIXME: we may want to move this into the components.
69  psky.begin();
70 
71  //Draw all sky elements
72  psky.drawSkyBackground();
73  m_KStarsData->skyComposite()->draw( &psky );
74  //Finish up
75  psky.end();
76 
77  QPainter psky2;
78  psky2.begin( this );
79  psky2.drawLine(0,0,1,1); // Dummy op.
80  psky2.drawPixmap( 0, 0, *m_SkyPixmap );
81  drawOverlays(psky2);
82  psky2.end();
83 
84  if(m_SkyMap->m_previewLegend)
85  {
86  m_SkyMap->m_legend.paintLegend(m_SkyPixmap);
87  }
88 
89  m_SkyMap->computeSkymap = false; // use forceUpdate() to compute new skymap else old pixmap will be shown
90 
91  setDrawLock( false );
92 
93 }
94 
95 void SkyMapQDraw::resizeEvent( QResizeEvent *e ) {
96  Q_UNUSED(e);
97  delete m_SkyPixmap;
98  m_SkyPixmap = new QPixmap( width(), height() );
99 }
SkyQPainter::drawSkyBackground
virtual void drawSkyBackground()
Draw the sky background.
Definition: skyqpainter.cpp:124
SkyMapDrawAbstract::setDrawLock
static void setDrawLock(bool state)
Acquire / release a draw lock.
Definition: skymapdrawabstract.cpp:346
legend.h
SkyMapDrawAbstract::m_KStarsData
KStarsData * m_KStarsData
Definition: skymapdrawabstract.h:149
QWidget
SkyMapDrawAbstract::drawOverlays
void drawOverlays(QPainter &p, bool drawFov=true)
Draw the overlays on top of the sky map.
Definition: skymapdrawabstract.cpp:67
SkyMapComposite::draw
virtual void draw(SkyPainter *skyp)
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint...
Definition: skymapcomposite.cpp:170
SkyMapQDraw::SkyMapQDraw
SkyMapQDraw(SkyMap *parent)
Constructor.
Definition: skymapqdraw.cpp:23
SkyQPainter::begin
virtual void begin()
Begin painting.
Definition: skyqpainter.cpp:110
SkyMap::setupProjector
void setupProjector()
Call to set up the projector before a draw cycle.
Definition: skymap.cpp:1010
SkyQPainter
The QPainter-based painting backend.
Definition: skyqpainter.h:32
SkyMapQDraw::m_SkyPixmap
QPixmap * m_SkyPixmap
Definition: skymapqdraw.h:53
SkyMap::showFocusCoords
void showFocusCoords()
Update object name and coordinates in the Focus InfoBox.
Definition: skymap.cpp:331
SkyMapQDraw::resizeEvent
virtual void resizeEvent(QResizeEvent *e)
Definition: skymapqdraw.cpp:95
skymapcomposite.h
SkyMapDrawAbstract::m_SkyMap
SkyMap * m_SkyMap
Definition: skymapdrawabstract.h:150
SkyMapQDraw::~SkyMapQDraw
~SkyMapQDraw()
Destructor.
Definition: skymapqdraw.cpp:27
SkyMapDrawAbstract::m_DrawLock
static bool m_DrawLock
Definition: skymapdrawabstract.h:151
SkyMapQDraw::paintEvent
virtual void paintEvent(QPaintEvent *e)
Overridden paintEvent method.
Definition: skymapqdraw.cpp:31
skymapqdraw.h
skymap.h
KStarsData::skyComposite
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:146
SkyMapDrawAbstract::calculateFPS
void calculateFPS()
Calculate FPS and dump result to stderr using kDebug.
Definition: skymapdrawabstract.cpp:335
SkyMapDrawAbstract
This class defines the methods that both rendering engines (GLPainter and QPainter) must implement...
Definition: skymapdrawabstract.h:40
skyqpainter.h
SkyMap
This is the canvas on which the sky is painted.
Definition: skymap.h:72
Legend::paintLegend
void paintLegend(QPaintDevice *pd)
Paint legend on passed QPaintDevice at selected position.
Definition: legend.cpp:162
SkyQPainter::end
virtual void end()
End and finalize painting.
Definition: skyqpainter.cpp:119
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 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