[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/kstars/kstars
From:       Akarsh Simha <akarshsimha () gmail ! com>
Date:       2011-01-01 4:27:54
Message-ID: 20110101042754.9C00BAC8AE () svn ! kde ! org
[Download RAW message or body]

SVN commit 1210565 by asimha:

SkyPainters should really take the dimensions of the widget that they
are drawing on. Fixing this.

+ A pointer to the SkyMap need not be passed to the children.

+ A pointer to the QWidget / QGLWidget that drawing is being done in
  is passed instead, to obtain the dimensions.

 M  +8 -7      skyglpainter.cpp  
 M  +4 -1      skyglpainter.h  
 M  +1 -1      skymapgldraw.cpp  
 M  +1 -1      skymapqdraw.cpp  
 M  +3 -4      skypainter.cpp  
 M  +5 -2      skypainter.h  
 M  +8 -6      skyqpainter.cpp  
 M  +4 -2      skyqpainter.h  


--- trunk/KDE/kdeedu/kstars/kstars/skyglpainter.cpp #1210564:1210565
@@ -25,6 +25,7 @@
 using Eigen::Rotation2Df;
 
 #include <GL/gl.h>
+#include <QGLWidget>
 
 #include "skymap.h"
 #include "kstarsdata.h"
@@ -48,9 +49,9 @@
 int      SkyGLPainter::m_idx[NUMTYPES];
 bool     SkyGLPainter::m_init = false;
 
-SkyGLPainter::SkyGLPainter(SkyMap* sm)
-    : SkyPainter(sm)
+SkyGLPainter::SkyGLPainter( const QGLWidget *widget ) : SkyPainter()
 {
+    m_widget = widget;
     if( !m_init ) {
         printf("Initializing texcoord arrays...\n");
         for(int i = 0; i < NUMTYPES; ++i) {
@@ -366,9 +367,9 @@
         glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
         glBegin(GL_QUADS);
         glVertex2f(0,0);
-        glVertex2f(0,m_sm->height());
-        glVertex2f(m_sm->width(),m_sm->height());
-        glVertex2f(m_sm->width(),0);
+        glVertex2f(0,m_widget->height());
+        glVertex2f(m_widget->width(),m_widget->height());
+        glVertex2f(m_widget->width(),0);
         glEnd();
         glDisable(GL_STENCIL_TEST);
     } else {
@@ -523,10 +524,10 @@
     m_proj = m_sm->projector();
     
     //Load ortho projection
-    glViewport(0,0,m_sm->width(),m_sm->height());
+    glViewport(0,0,m_widget->width(),m_widget->height());
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
-    glOrtho(0,m_sm->width(), m_sm->height(),0, -1,1);
+    glOrtho(0,m_widget->width(), m_widget->height(),0, -1,1);
 
     //reset modelview matrix
     glMatrixMode(GL_MODELVIEW);
--- trunk/KDE/kdeedu/kstars/kstars/skyglpainter.h #1210564:1210565
@@ -27,10 +27,12 @@
 #include "skyobjects/skyobject.h"
 #include "projections/projector.h"
 
+class QGLWidget;
+
 class SkyGLPainter : public SkyPainter
 {
 public:
-    SkyGLPainter(SkyMap* sm);
+    SkyGLPainter( const QGLWidget *widget );
     virtual bool drawPlanet(KSPlanetBase* planet);
     virtual bool drawDeepSkyObject(DeepSkyObject* obj, bool drawImage = false);
     virtual bool drawPointSource(SkyPoint* loc, float mag, char sp = 'A');
@@ -60,6 +62,7 @@
     static Vector3f m_color[NUMTYPES][6*BUFSIZE];
     static int m_idx[NUMTYPES];
     static bool m_init; ///< keep track of whether we have filled the texcoord array
+    const QGLWidget* m_widget; // Pointer to (GL) widget on which we are painting
 };
 
 #endif // SKYGLPAINTER_H
--- trunk/KDE/kdeedu/kstars/kstars/skymapgldraw.cpp #1210564:1210565
@@ -55,7 +55,7 @@
 
     makeCurrent();
 
-    SkyGLPainter psky( m_SkyMap );
+    SkyGLPainter psky( this );
     //FIXME: we may want to move this into the components.
     psky.begin();
 
--- trunk/KDE/kdeedu/kstars/kstars/skymapqdraw.cpp #1210564:1210565
@@ -58,7 +58,7 @@
     m_SkyMap->showFocusCoords();
     m_SkyMap->setupProjector();
     
-    SkyQPainter psky(m_SkyMap, m_SkyPixmap); // FIXME: Again, we shouldn't be passing m_SkyMap, but \
rather, we should pass this widget instead. +    SkyQPainter psky(this, m_SkyPixmap); 
     //FIXME: we may want to move this into the components.
     psky.begin();
     
--- trunk/KDE/kdeedu/kstars/kstars/skypainter.cpp #1210564:1210565
@@ -31,11 +31,10 @@
 #include "skyobjects/ksplanetbase.h"
 #include "skyobjects/trailobject.h"
 
-SkyPainter::SkyPainter(SkyMap* sm)
-    : m_sm(sm),
-      m_sizeMagLim(10.)
+SkyPainter::SkyPainter()
+    : m_sizeMagLim(10.)
 {
-
+    m_sm = SkyMap::Instance();
 }
 
 SkyPainter::~SkyPainter()
--- trunk/KDE/kdeedu/kstars/kstars/skypainter.h #1210564:1210565
@@ -46,9 +46,12 @@
 {
 public:
     /** @short Constructor.
-        @param sm A pointer to SkyMap object on which to paint.
         */
-    SkyPainter(SkyMap *sm);
+    SkyPainter();
+
+    /**
+     *@short Destructor
+     */
     virtual ~SkyPainter();
     
     /** @short Get the SkyMap on which the painter operates */
--- trunk/KDE/kdeedu/kstars/kstars/skyqpainter.cpp #1210564:1210565
@@ -19,6 +19,7 @@
 #include "skyqpainter.h"
 
 #include <QMap>
+#include <QWidget>
 
 #include "kstarsdata.h"
 #include "Options.h"
@@ -67,11 +68,12 @@
     QPixmap* imageCache[nSPclasses][nStarSizes] = {{0}};
 }
 
-SkyQPainter::SkyQPainter(SkyMap* sm, QPaintDevice *pd)
-    : SkyPainter(sm), QPainter()
+SkyQPainter::SkyQPainter( QWidget *widget, QPaintDevice *pd )
+    : SkyPainter(), QPainter()
 {
-    //Set paint device pointer to pd or sm if pd = 0
-    m_pd = (pd ? pd : sm);
+    // Set paint device pointer to pd or to the widget if pd = 0
+    m_pd = ( pd ? pd : widget );
+    m_widget = widget;
 }
 
 SkyQPainter::~SkyQPainter()
@@ -94,8 +96,8 @@
 
 void SkyQPainter::drawSkyBackground()
 {
-    //FIXME use projctor
-    fillRect( 0, 0, m_sm->width(), m_sm->height(), KStarsData::Instance()->colorScheme()->colorNamed( \
"SkyColor" ) ); +    //FIXME use projector
+    fillRect( 0, 0, m_widget->width(), m_widget->height(), \
KStarsData::Instance()->colorScheme()->colorNamed( "SkyColor" ) );  }
 
 void SkyQPainter::setPen(const QPen& pen)
--- trunk/KDE/kdeedu/kstars/kstars/skyqpainter.h #1210564:1210565
@@ -23,6 +23,7 @@
 #include "skypainter.h"
 
 class Projector;
+class QWidget;
 
 /** @short The QPainter-based painting backend.
     This class implements the SkyPainter interface using a QPainter.
@@ -31,10 +32,10 @@
 {
 public:
     /** Constructor.
-        @param sm the SkyMap pointer
+        @param widget the QWidget that provides the paint device (used to query height, width etc)
         @param pd the painting device. If 0, then @p sm will be used.
         */
-    SkyQPainter(SkyMap *sm, QPaintDevice *pd = 0);
+    SkyQPainter( QWidget *widget, QPaintDevice *pd = 0 );
     virtual ~SkyQPainter();
     virtual void setPen(const QPen& pen);
     virtual void setBrush(const QBrush& brush);
@@ -65,6 +66,7 @@
                                          float positionAngle);
     QPaintDevice *m_pd;
     const Projector* m_proj;
+    const QWidget *m_widget;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic