0

在遵循教程的同时,我正在尝试在Marble中创建自定义叠加层。我的代码与示例中的代码相同。

一切似乎都很好,但是生成的图层是可编辑的,我可以单击它并更改其大小。

我希望它在背景上只是静态的,无法与之交互。

似乎没有任何明显的标志要设置或功能要覆盖(这样我就可以忽略所有用户事件)。

有任何想法吗?


要求的代码:

#include <QDebug>
#include <QFileInfo>
#include <QApplication>
#include <QImage>

#include <marble/MarbleWidget.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataGroundOverlay.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/MarbleModel.h>

using namespace Marble;

int main(int argc, char** argv) {

    QApplication app(argc,argv);

    QFileInfo inputFile( app.arguments().last() );
    if ( app.arguments().size() < 2 || !inputFile.exists() ) {
        qWarning() << "Usage: " << app.arguments().first() << "file.png";
        return 1;
    }

    // Create a Marble QWidget without a parent
    MarbleWidget *mapWidget = new MarbleWidget();

    // Load the Satellite map
    mapWidget->setMapThemeId( "earth/bluemarble/bluemarble.dgml" );

    // Create a bounding box from the given corner points
    GeoDataLatLonBox box( 55, 48, 14.5, 6, GeoDataCoordinates::Degree );
    box.setRotation( 0, GeoDataCoordinates::Degree );

    // Create an overlay and assign the image to render and its bounding box to it
    GeoDataGroundOverlay *overlay = new GeoDataGroundOverlay;
    overlay->setLatLonBox( box );
    overlay->setIcon( QImage( inputFile.absoluteFilePath() ) );

    // Create a document as a container for the overlay
    GeoDataDocument *document = new GeoDataDocument();
    document->append( overlay );

    // Add the document to MarbleWidget's tree model
    mapWidget->model()->treeModel()->addDocument( document );

    mapWidget->show();

    return app.exec();
}
4

1 回答 1

0

更新:

RenderPlugin您可以使用和以编程方式启用/禁用插件setVisible

QList<RenderPlugin *> renderPluginList = marbleWidget->renderPlugins();
for (RenderPlugin *renderPlugin : renderPluginList) {
  if (std::find(plugin_list.begin(), plugin_list.end(), renderPlugin->nameId()) != plugin_list.end())
  {
     renderPlugin->setVisible(true);
  }
  else
  {
     renderPlugin->setVisible(false);
  }
}

插件的plugin_list一个在哪里。std::vector<QString>nameId()

要仅禁用 Annotation 插件,您可以使用:

QList<RenderPlugin *> renderPluginList = mapWidget->renderPlugins();
for (RenderPlugin *renderPlugin : renderPluginList) {
  if (renderPlugin->nameId() == "annotation")
  {
     renderPlugin->setVisible(false);
  }
}

如果您仍然遇到此问题,要检查的一件事是目录中是否有AnnotationPlugin.dll如果在 Windows 上)plugins/。该插件允许在MarbleWidget地图上移动和调整各种功能的大小。

于 2020-02-03T19:48:05.407 回答