[Marble-commits] KDE/kdeedu/marble/src
Andrew Manson
g.real.ate at gmail.com
Wed Jul 15 17:23:32 CEST 2009
SVN commit 997226 by mansona:
Cleaning up the concepts in the OsmAnnotation Plugin, removing redundant
ideas and implementations. Also fix the GeoPointGraphicsItem so that it
builds on KDE version. Class needed a MARBLE_EXPORT
M +2 -1 lib/geodata/graphicsitem/GeoPointGraphicsItem.h
M +23 -65 plugins/render/osmannotate/OsmAnnotatePlugin.cpp
M +9 -8 plugins/render/osmannotate/OsmAnnotatePlugin.h
M +1 -32 plugins/render/osmannotate/TextAnnotation.cpp
M +0 -2 plugins/render/osmannotate/TextAnnotation.h
M +2 -1 plugins/render/osmannotate/osm/OsmNodeGraphicsItem.h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h #997225:997226
@@ -13,11 +13,12 @@
#include "GeoDataPoint.h"
#include "GeoGraphicsItem.h"
+#include "marble_export.h"
namespace Marble
{
-class GeoPointGraphicsItem : public GeoGraphicsItem
+class MARBLE_EXPORT GeoPointGraphicsItem : public GeoGraphicsItem
{
public:
GeoPointGraphicsItem();
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #997225:997226
@@ -82,12 +82,7 @@
void OsmAnnotatePlugin::initialize ()
{
- //initialise the first test widget
- QPushButton * button;
- button = new QPushButton(0);
- but = button;
-
//Setup the model
GeoDataCoordinates madrid( -13.7, 40.4, 0.0, GeoDataCoordinates::Degree );
TextAnnotation* annon = new TextAnnotation();
@@ -97,20 +92,8 @@
//FIXME memory leak withouth a model to do memory management
model.append(annon);
- //Attempted to add a video widget as a tech preview but this needs to
- //be properly considered. Phonon includes in a plugin?
-// video = new Phonon::VideoWidget(0);
-//
-// vid = video;
-//
-// Phonon::VideoWidget * video;
-// Phonon::MediaObject m;
-// QString fileName("/home/foo/bar.ogg");
-//
-// m.setCurrentSource(fileName);
-
widgetInitalised= false;
- tmp_lineString = 0;
+ m_tmp_lineString = 0;
m_itemModel = 0;
}
@@ -138,21 +121,10 @@
}
painter->autoMapQuality();
- //Set the parents if they have not already been set
-
-// if ( vid->parent() == 0 ) {
-// vid->setParent( (QWidget*)painter->device() );
-// //start video
-// }
-
- if ( but->parent() == 0 ) {
-
+ //so the user can keep track of the current polygon drawing
+ if( m_tmp_lineString ) {
+ painter->drawPolyline( *m_tmp_lineString );
}
-
- int x, y;
- bool hidden;
-
- GeoDataCoordinates madrid( -13.7, 40.4, 0.0, GeoDataCoordinates::Degree );
QListIterator<TmpGraphicsItem*> i(model);
@@ -161,24 +133,6 @@
tmp->paint(painter, viewport, renderPos, layer);
}
- if ( tmp_lineString != 0 ) {
- painter->drawPolyline( *tmp_lineString );
- }
-
-
-
-
-// viewport->currentProjection()->screenCoordinates( madrid, viewport, x, y, hidden );
-
-// if( !hidden ) {
-// but->move(QPoint(x, y));
-// but->setVisible(false);
-// } else {
-// but->setVisible(false);
-// }
-
- //Figure out how to add the data parsed to a scene for rendering
- //FIXME: this is a terrible hack intended just to test!
if( m_itemModel ) {
QListIterator<GeoGraphicsItem*> it( *m_itemModel );
@@ -186,9 +140,6 @@
GeoGraphicsItem* i = it.next();
i->paint( painter, viewport, renderPos, layer );
}
-
-// painter->drawPolygon( ring );
-
}
return true;
@@ -204,12 +155,12 @@
m_drawingPolygon = b;
if( !b ) {
//stopped drawing the polygon
- if ( tmp_lineString != 0 ) {
+ if ( m_tmp_lineString != 0 ) {
AreaAnnotation* area = new AreaAnnotation();
GeoDataPolygon poly( Tessellate );
- poly.setOuterBoundary( GeoDataLinearRing(*tmp_lineString) );
- delete tmp_lineString;
- tmp_lineString = 0;
+ poly.setOuterBoundary( GeoDataLinearRing(*m_tmp_lineString) );
+ delete m_tmp_lineString;
+ m_tmp_lineString = 0;
area->setGeometry( poly );
@@ -304,11 +255,11 @@
mouseEvent->pos().y(),
lon, lat, GeoDataCoordinates::Radian);
if ( valid ) {
- if ( tmp_lineString == 0 ) {
- tmp_lineString = new GeoDataLineString( Tessellate );
+ if ( m_tmp_lineString == 0 ) {
+ m_tmp_lineString = new GeoDataLineString( Tessellate );
}
- tmp_lineString->append(GeoDataCoordinates(lon, lat));
+ m_tmp_lineString->append(GeoDataCoordinates(lon, lat));
//FIXME only repaint the line string so far
marbleWidget->repaint();
@@ -362,7 +313,13 @@
QList<QActionGroup*> OsmAnnotatePlugin::setupActions(MarbleWidget* widget)
{
QList<QActionGroup*> result;
+
+ QActionGroup* initial = new QActionGroup(0);
+ initial->setExclusive( false );
+
QActionGroup* group = new QActionGroup(0);
+ group->setExclusive( true );
+
QAction* m_addPlacemark;
QAction* m_drawPolygon;
QAction* m_drawLine;
@@ -393,22 +350,23 @@
m_endSeperator = new QAction ( this );
m_endSeperator->setSeparator( true );
- m_enableInputAction = new QAction(this);
-// m_enableInputAction->setText("Enable Marble Input");
+ m_enableInputAction = new QAction(this);
+ m_enableInputAction->setToolTip(tr("Enable Marble Input"));
m_enableInputAction->setCheckable(true);
m_enableInputAction->setChecked( true );
m_enableInputAction->setIcon( QIcon( MarbleDirs::path("bitmaps/hand.png") ) );
-// m_enableInputAction->set
connect( m_enableInputAction, SIGNAL(toggled(bool)),
widget, SLOT( setInputEnabled(bool)) );
- group->addAction( m_enableInputAction );
- group->addAction( m_beginSeperator );
+ initial->addAction( m_enableInputAction );
+ initial->addAction( m_beginSeperator );
+
group->addAction( m_addPlacemark );
group->addAction( m_drawPolygon );
group->addAction( m_loadOsmFile );
group->addAction( m_endSeperator );
+ result.append( initial );
result.append( group );
return result;
}
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.h #997225:997226
@@ -63,17 +63,13 @@
bool isInitialized () const;
+ //intended to be called from the outside the plugin to replace
+ //the "registerActions" calls.
+ //FIXME: need to guarentee marbleWiget has been initialised before this call
QList<QActionGroup*> actionGroups();
bool render( GeoPainter *painter, ViewportParams *viewport, const QString& renderPos, GeoSceneLayer * layer = 0 );
- //Intended to be replaced by an actual model system
- QList<TmpGraphicsItem*> model;
-
- //Only examples as a preview
- QWidget* vid;
- QWidget* but;
-
bool widgetInitalised;
@@ -89,9 +85,14 @@
private:
QList<QActionGroup*> setupActions(MarbleWidget* m);
- GeoDataLineString* tmp_lineString;
+ //Intended to be replaced by an actual model system
+ //FIXME: Merge the two models once TmpGraphicsItem is eliminated
+ QList<TmpGraphicsItem*> model;
QList<GeoGraphicsItem*>* m_itemModel;
+ //used while creating new polygons
+ GeoDataLineString* m_tmp_lineString;
+
bool m_addingPlacemark;
bool m_drawingPolygon;
};
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextAnnotation.cpp #997225:997226
@@ -40,32 +40,6 @@
return QRect(-5,-5,20,20);
}
-void TextAnnotation::geoBounding(qreal angularResolution)
-{
- //FIXME
- // Remove this method when the QRegion is actually done by the painter
- // it will be preduced in the GeoGraphicsItemPrivate during a paint event
-
-
- qreal lat, lon, alt, width, height;
- coordinate(lon, lat, alt);
-
- //problem with this approach is that the geoBounding is View
- //Dependant. This does not lend well to a good consistant model.
- width = screenBounding().width() * angularResolution;
- height = screenBounding().height() * angularResolution;
- QRect bound( coordinate().longitude() - (width/2),
- coordinate().latitude() - (height/2),
- width, height) ;
-
- QRegion path;
- path = path.united( bound);
- QList<QRegion> list;
- list.append ( path );
- setRegions( list );
-
-}
-
void TextAnnotation::paint( GeoPainter *painter,
ViewportParams *viewport,
const QString& renderPos,
@@ -73,7 +47,7 @@
{
qreal degPix = viewport->angularResolution() * RAD2DEG;
- painter->drawEllipse(coordinate(), screenBounding().width(), screenBounding().height(), isGeoProjected());
+ painter->drawEllipse(coordinate(), screenBounding().width(), screenBounding().height(), true);
//Would it not be useful to have a draw latlongbox?
// painter->drawRect(geoBounding());
qreal north, south, east, west;
@@ -127,11 +101,6 @@
}
-bool TextAnnotation::isGeoProjected()
-{
- return false;
-}
-
QVariant TextAnnotation::itemChange(GeoGraphicsItemChange change, QVariant v )
{
switch ( change ) {
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/TextAnnotation.h #997225:997226
@@ -24,10 +24,8 @@
TextAnnotation();
virtual QRect screenBounding();
- virtual void geoBounding(qreal angularResoluiton);
virtual void paint( GeoPainter *painter, ViewportParams *viewport,
const QString& renderPos, GeoSceneLayer * layer = 0 );
- virtual bool isGeoProjected();
virtual QVariant itemChange(GeoGraphicsItemChange c, QVariant v);
protected:
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmNodeGraphicsItem.h #997225:997226
@@ -14,13 +14,14 @@
#include "GeoDataPoint.h"
#include "GeoGraphicsItem.h"
#include "GeoPointGraphicsItem.h"
+#include "marble_export.h"
#include <QtGui/QPen>
namespace Marble
{
-class OsmNodeGraphicsItem : public GeoPointGraphicsItem
+class MARBLE_EXPORT OsmNodeGraphicsItem : public GeoPointGraphicsItem
{
public:
OsmNodeGraphicsItem();
More information about the Marble-commits
mailing list