[Marble-bugs] [Bug 299527] Red line does not shown

marbledeveloper at gmail.com marbledeveloper at gmail.com
Wed May 23 21:10:09 UTC 2012


https://bugs.kde.org/show_bug.cgi?id=299527

--- Comment #6 from marbledeveloper at gmail.com ---
Hi Dennis,

Yes, your code works properly because you are adding the points in one time.

Have you tried to add the points in each update of Marble clock? If you try it,
you will get the bug.

For example:

#include <QtGui/QApplication>
#include "marblemanager.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    MarbleManager w;
    w.show();
    return a.exec();
}

#ifndef MARBLEMANAGER_H
#define MARBLEMANAGER_H

#include <MarbleWidget.h>

#include <GeoDataTreeModel.h>
#include <GeoDataLineString.h>
#include <GeoDataTrack.h>

using namespace Marble;

class MarbleManager: public MarbleWidget
{
    Q_OBJECT

public:
    MarbleManager(QWidget* parent = 0);

private slots:
    void update();

private:
    int lon;
    GeoDataTrack*           m_track;
};

#endif // MARBLEMANAGER_H

#include "marblemanager.h"

#include <MarbleModel.h>
#include <MarbleClock.h>
#include <RenderPlugin.h>
#include <QtGui/QTreeView>

#include <GeoDataStyle.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>

#include <QDebug>

MarbleManager::MarbleManager(QWidget* parent) :
    MarbleWidget(parent),
    lon(0)
{
    // Load the OpenStreetMap map
    setMapThemeId("earth/bluemarble/bluemarble.dgml");
    // Sets the camera fixed by default
    setShowSunInZenith(true);
    // Sets default distance
    setDistance(12000);
    // Sets default zoom
    zoomView(800);
    // Sets default simulation speed
    int speed(1000);
    model()->clock()->setSpeed(speed);
    // Sets initial time
    Qt::DateFormat format = Qt::ISODate;
    QString dateString("2000-01-01T00:00:00");
    QDateTime dateTime = QDateTime::fromString(dateString, format);
    model()->clock()->setDateTime(dateTime);
    // Sets update interval
    int updateInterval(20);
    model()->clock()->setUpdateInterval(updateInterval);
    // Filters the default plugins: satellites, stars and sun
    for (int i = 0; i < renderPlugins().count(); i++){
        if ("stars" == renderPlugins().at(i)->nameId().toAscii() ||
            "sun" == renderPlugins().at(i)->nameId().toAscii() ) {
            renderPlugins().at(i)->setVisible(true);
            renderPlugins().at(i)->setEnabled(true);
        }
        else {
            renderPlugins().at(i)->setVisible(false);
            renderPlugins().at(i)->setEnabled(false);
        }
    }
    show();
    connect(model()->clock(), SIGNAL(timeChanged()), this, SLOT(update()));

    m_track = new GeoDataTrack();
    QString satelliteName("test");
    GeoDataPlacemark* geoDataPlacemark = new GeoDataPlacemark(satelliteName);

    geoDataPlacemark->setVisualCategory( GeoDataFeature::Satellite );
    geoDataPlacemark->setGeometry( m_track );
    GeoDataStyle *style = new GeoDataStyle( *geoDataPlacemark->style() );
    geoDataPlacemark->setStyle( style );
    geoDataPlacemark->style()->lineStyle().setColor( oxygenBrickRed4 );
    geoDataPlacemark->style()->lineStyle().setPenStyle( Qt::SolidLine );
    geoDataPlacemark->style()->labelStyle().setGlow( true );


    GeoDataDocument *geoDataContainer = new GeoDataDocument();
    geoDataContainer->setFileName("container_" + satelliteName);
    geoDataContainer->append( geoDataPlacemark );
    model()->treeModel()->addDocument(geoDataContainer);
}

void MarbleManager::update()
{
    if (360 < lon)
        return;
    GeoDataCoordinates coordinates = GeoDataCoordinates( lon, 0, 20000.0 *
1000, GeoDataCoordinates::Degree );
    m_track->addPoint(model()->clock()->dateTime(), coordinates);
    lon++;
}

Try it please.

Regards!

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Marble-bugs mailing list