Пример #1
0
void LayerModel::addLayer(int id, QString name, QColor color, bool visible, bool locked)
{
    // this will create a new layer with not uids
    feather::FLayer l(name.toStdString(),feather::FColorRGB( static_cast<float>(color.red())/255.0, static_cast<float>(color.green())/255.0, static_cast<float>(color.blue())/255.0 ), visible, locked);
    feather::qml::command::add_layer(l);
    updateLayers();
}
QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface* iface , QWidget *parent )
    : QWidget( parent ), mIface( iface )

{
  ui.setupUi( this );
  ui.progressBar->hide();
  ui.labelStatus->hide();
  ui.comboBoxInputLayer->setFilters( QgsMapLayerProxyModel::HasGeometry );
  mRunButton = ui.buttonBox->addButton( tr( "Run" ), QDialogButtonBox::ActionRole );
  mAbortButton = new QPushButton( tr( "Abort" ) );
  mRunButton->setEnabled( false );

  connect( mRunButton, SIGNAL( clicked() ), this, SLOT( runChecks() ) );
  connect( ui.comboBoxInputLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) );
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( updateLayers() ) );
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( updateLayers() ) );
  connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.lineEditOutput, SLOT( setEnabled( bool ) ) );
  connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.pushButtonOutputBrowse, SLOT( setEnabled( bool ) ) );
  connect( ui.buttonGroupOutput, SIGNAL( buttonClicked( int ) ), this, SLOT( validateInput() ) );
  connect( ui.pushButtonOutputBrowse, SIGNAL( clicked() ), this, SLOT( selectOutputFile() ) );
  connect( ui.lineEditOutput, SIGNAL( textChanged( QString ) ), this, SLOT( validateInput() ) );
  connect( ui.checkBoxSliverPolygons, SIGNAL( toggled( bool ) ), ui.widgetSliverThreshold, SLOT( setEnabled( bool ) ) );
  connect( ui.checkBoxSliverArea, SIGNAL( toggled( bool ) ), ui.doubleSpinBoxSliverArea, SLOT( setEnabled( bool ) ) );

  updateLayers();

  Q_FOREACH ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() )
  {
    factory->restorePrevious( ui );
  }
Пример #3
0
void LayerModel::moveLayer(int sid, int tid)
{
    //clear(); 
    feather::qml::command::move_layer(sid,tid);
    /*
    std::cout << "LayerModel\n";
    for(int i=0; i < m_layers.size(); i++){
        std::cout << "layer " << i << " name: " << m_layers[i]->name.toStdString().c_str() << std::endl;
    }
    */
    updateLayers();
}
Пример #4
0
void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAllocationLimitBytes)
{
    ASSERT(m_rendererInitialized);
    ASSERT(memoryAllocationLimitBytes);

    if (!rootLayer())
        return;

    if (layoutViewportSize().isEmpty())
        return;

    m_contentsTextureManager->setMaxMemoryLimitBytes(memoryAllocationLimitBytes);

    updateLayers(rootLayer(), queue);
}
Пример #5
0
QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface *iface, QDialog *checkerDialog, QWidget *parent )
  : QWidget( parent )
  , mIface( iface )
  , mCheckerDialog( checkerDialog )

{
  ui.setupUi( this );
  ui.progressBar->hide();
  ui.labelStatus->hide();
  mRunButton = ui.buttonBox->addButton( tr( "Run" ), QDialogButtonBox::ActionRole );
  mAbortButton = new QPushButton( tr( "Abort" ) );
  mRunButton->setEnabled( false );

  QMap<QString, QString> filterFormatMap = QgsVectorFileWriter::supportedFiltersAndFormats();
  for ( const QString &filter : filterFormatMap.keys() )
  {
    QString driverName = filterFormatMap.value( filter );
    ui.comboBoxOutputFormat->addItem( driverName );
    if ( driverName == QLatin1String( "ESRI Shapefile" ) )
    {
      ui.comboBoxOutputFormat->setCurrentIndex( ui.comboBoxOutputFormat->count() - 1 );
    }
  }
  ui.listWidgetInputLayers->setIconSize( QSize( 16, 16 ) );

  ui.lineEditFilenamePrefix->setText( QSettings().value( "/geometry_checker/previous_values/filename_prefix", tr( "checked_" ) ).toString() );

  connect( mRunButton, &QAbstractButton::clicked, this, &QgsGeometryCheckerSetupTab::runChecks );
  connect( ui.listWidgetInputLayers, &QListWidget::itemChanged, this, &QgsGeometryCheckerSetupTab::validateInput );
  connect( QgsProject::instance(), &QgsProject::layersAdded, this, &QgsGeometryCheckerSetupTab::updateLayers );
  connect( QgsProject::instance(), static_cast<void ( QgsProject::* )( const QStringList & )>( &QgsProject::layersRemoved ), this, &QgsGeometryCheckerSetupTab::updateLayers );
  connect( ui.radioButtonOutputNew, &QAbstractButton::toggled, ui.frameOutput, &QWidget::setEnabled );
  connect( ui.buttonGroupOutput, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsGeometryCheckerSetupTab::validateInput );
  connect( ui.pushButtonOutputDirectory, &QAbstractButton::clicked, this, &QgsGeometryCheckerSetupTab::selectOutputDirectory );
  connect( ui.lineEditOutputDirectory, &QLineEdit::textChanged, this, &QgsGeometryCheckerSetupTab::validateInput );
  connect( ui.checkBoxSliverPolygons, &QAbstractButton::toggled, ui.widgetSliverThreshold, &QWidget::setEnabled );
  connect( ui.checkBoxSliverArea, &QAbstractButton::toggled, ui.doubleSpinBoxSliverArea, &QWidget::setEnabled );
  connect( ui.checkLineLayerIntersection, &QAbstractButton::toggled, ui.comboLineLayerIntersection, &QComboBox::setEnabled );
  connect( ui.checkBoxFollowBoundaries, &QAbstractButton::toggled, ui.comboBoxFollowBoundaries, &QComboBox::setEnabled );

  for ( const QgsGeometryCheckFactory *factory : QgsGeometryCheckFactoryRegistry::getCheckFactories() )
  {
    factory->restorePrevious( ui );
  }
  updateLayers();
}
Пример #6
0
bool CCLayerTreeHost::updateLayers(CCTextureUpdater& updater)
{
    if (!m_layerRendererInitialized) {
        initializeLayerRenderer();
        // If we couldn't initialize, then bail since we're returning to software mode.
        if (!m_layerRendererInitialized)
            return false;
    }
    if (m_contextLost) {
        if (recreateContext() != RecreateSucceeded)
            return false;
    }

    if (!rootLayer())
        return true;

    if (viewportSize().isEmpty())
        return true;

    updateLayers(rootLayer(), updater);
    return true;
}
Пример #7
0
void CCLayerTreeHost::updateLayers(CCTextureUpdater& updater)
{
    ASSERT(m_layerRendererInitialized);
    // The visible state and memory allocation are set independently and in
    // arbitrary order, so do not change the memory allocation used for the
    // current commit until both values match intentions.
    // FIXME: These two states should be combined into a single action so we
    // need a single commit to change visible state, and this can be removed.
    bool memoryAllocationStateMatchesVisibility = m_visible == m_memoryAllocationIsForDisplay;
    if (memoryAllocationStateMatchesVisibility) {
        m_contentsTextureManager->setMemoryAllocationLimitBytes(m_memoryAllocationBytes);
        m_frameIsForDisplay = m_memoryAllocationIsForDisplay;
    }

    if (!rootLayer())
        return;

    if (viewportSize().isEmpty())
        return;

    updateLayers(rootLayer(), updater);
}
QgsGeometrySnapperDialog::QgsGeometrySnapperDialog( QgisInterface* iface ):
    mIface( iface )
{
  ui.setupUi( this );
  mRunButton = ui.buttonBox->addButton( tr( "Run" ), QDialogButtonBox::ActionRole );
  ui.buttonBox->button( QDialogButtonBox::Abort )->hide();
  mRunButton->setEnabled( false );
  ui.progressBar->hide();
  setFixedSize( sizeHint() );
  setWindowModality( Qt::ApplicationModal );

  connect( mRunButton, SIGNAL( clicked() ), this, SLOT( run() ) );
  connect( ui.comboBoxInputLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) );
  connect( ui.comboBoxReferenceLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) );
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( updateLayers() ) );
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( updateLayers() ) );
  connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.lineEditOutput, SLOT( setEnabled( bool ) ) );
  connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.pushButtonOutputBrowse, SLOT( setEnabled( bool ) ) );
  connect( ui.buttonGroupOutput, SIGNAL( buttonClicked( int ) ), this, SLOT( validateInput() ) );
  connect( ui.pushButtonOutputBrowse, SIGNAL( clicked() ), this, SLOT( selectOutputFile() ) );
  connect( ui.lineEditOutput, SIGNAL( textChanged( QString ) ), this, SLOT( validateInput() ) );

  updateLayers();
}
Пример #9
0
void GlobePlugin::run()
{
  if ( mViewerWidget != 0 )
  {
    return;
  }
#ifdef GLOBE_SHOW_TILE_STATS
  QgsGlobeTileStatistics* tileStats = new QgsGlobeTileStatistics();
  connect( tileStats, SIGNAL( changed( int, int ) ), this, SLOT( updateTileStats( int, int ) ) );
#endif
  QSettings settings;

//    osgEarth::setNotifyLevel( osg::DEBUG_INFO );

  mOsgViewer = new osgViewer::Viewer();
  mOsgViewer->setThreadingModel( osgViewer::Viewer::SingleThreaded );
  mOsgViewer->setRunFrameScheme( osgViewer::Viewer::ON_DEMAND );
  // Set camera manipulator with default home position
  osgEarth::Util::EarthManipulator* manip = new osgEarth::Util::EarthManipulator();
  mOsgViewer->setCameraManipulator( manip );
  osgEarth::Util::Viewpoint viewpoint;
  viewpoint.focalPoint() = osgEarth::GeoPoint( osgEarth::SpatialReference::get( "wgs84" ), -90., 0., 0. );
  viewpoint.heading() = 0.;
  viewpoint.pitch() = -90.;
  viewpoint.range() = 2e7;

  manip->setHomeViewpoint( viewpoint, 1. );
  manip->home( 0 );

  setupProxy();

  // Tile stats label
#ifdef GLOBE_SHOW_TILE_STATS
  mStatsLabel = new osgEarth::Util::Controls::LabelControl( "", 10 );
  mStatsLabel->setPosition( 0, 0 );
  osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer )->addControl( mStatsLabel.get() );
#endif

  mDockWidget = new QgsGlobeWidget( mQGisIface, mQGisIface->mainWindow() );
  connect( mDockWidget, SIGNAL( destroyed( QObject* ) ), this, SLOT( reset() ) );
  connect( mDockWidget, SIGNAL( layersChanged() ), this, SLOT( updateLayers() ) );
  connect( mDockWidget, SIGNAL( showSettings() ), this, SLOT( showSettings() ) );
  connect( mDockWidget, SIGNAL( refresh() ), this, SLOT( updateLayers() ) );
  connect( mDockWidget, SIGNAL( syncExtent() ), this, SLOT( syncExtent() ) );
  mQGisIface->addDockWidget( Qt::RightDockWidgetArea, mDockWidget );

  if ( getenv( "GLOBE_MAPXML" ) )
  {
    char* mapxml = getenv( "GLOBE_MAPXML" );
    QgsDebugMsg( mapxml );
    osg::Node* node = osgDB::readNodeFile( mapxml );
    if ( !node )
    {
      QgsDebugMsg( "Failed to load earth file " );
      return;
    }
    mMapNode = osgEarth::MapNode::findMapNode( node );
    mRootNode = new osg::Group();
    mRootNode->addChild( node );
  }
  else
  {
    QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
    osgEarth::Drivers::FileSystemCacheOptions cacheOptions;
    cacheOptions.rootPath() = cacheDirectory.toStdString();

    osgEarth::MapOptions mapOptions;
    mapOptions.cache() = cacheOptions;
    osgEarth::Map *map = new osgEarth::Map( /*mapOptions*/ );

    // The MapNode will render the Map object in the scene graph.
    osgEarth::MapNodeOptions mapNodeOptions;
    mMapNode = new osgEarth::MapNode( map, mapNodeOptions );

    mRootNode = new osg::Group();
    mRootNode->addChild( mMapNode );

    osgEarth::Registry::instance()->unRefImageDataAfterApply() = false;

    // Add draped layer
    osgEarth::TileSourceOptions opts;
    opts.L2CacheSize() = 0;
    opts.tileSize() = 128;
    mTileSource = new QgsGlobeTileSource( mQGisIface->mapCanvas(), opts );

    osgEarth::ImageLayerOptions options( "QGIS" );
    options.driver()->L2CacheSize() = 0;
    options.cachePolicy() = osgEarth::CachePolicy::USAGE_NO_CACHE;
    mQgisMapLayer = new osgEarth::ImageLayer( options, mTileSource );
    map->addImageLayer( mQgisMapLayer );

    // Add layers to the map
    updateLayers();

    // Create the frustum highlight callback
    mFrustumHighlightCallback = new QgsGlobeFrustumHighlightCallback(
      mOsgViewer, mMapNode->getTerrain(), mQGisIface->mapCanvas(), QColor( 0, 0, 0, 50 ) );
  }

  mRootNode->addChild( osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer ) );

  mAnnotationsGroup = new osg::Group();
  mRootNode->addChild( mAnnotationsGroup );
  foreach ( QgsBillBoardItem* item, QgsProject::instance()->billboardRegistry()->items() )
  {
    addBillboard( item );
  }
void LayerRendererChromium::updateAndDrawLayers()
{
    // FIXME: use the frame begin time from the overall compositor scheduler.
    // This value is currently inaccessible because it is up in Chromium's
    // RenderWidget.
    m_headsUpDisplay->onFrameBegin(currentTime());
    ASSERT(m_hardwareCompositing);

    if (!m_rootLayer)
        return;

    updateRootLayerContents();

    // Recheck that we still have a root layer. This may become null if
    // compositing gets turned off during a paint operation.
    if (!m_rootLayer)
        return;

    {
        TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0);
        m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get());
    }

    LayerList renderSurfaceLayerList;

    updateLayers(renderSurfaceLayerList);

    // Before drawLayers:
    if (hardwareCompositing() && m_contextSupportsLatch) {
        // FIXME: The multithreaded compositor case will not work as long as
        // copyTexImage2D resolves to the parent texture, because the main
        // thread can execute WebGL calls on the child context at any time,
        // potentially clobbering the parent texture that is being renderered
        // by the compositor thread.
        if (m_childContextsWereCopied) {
            Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_context->getExtensions());
            // For each child context:
            //   glWaitLatch(Offscreen->Compositor);
            ChildContextMap::iterator i = m_childContexts.begin();
            for (; i != m_childContexts.end(); ++i) {
                Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(i->first->getExtensions());
                GC3Duint latchId;
                childExt->getChildToParentLatchCHROMIUM(&latchId);
                parentExt->waitLatchCHROMIUM(latchId);
            }
        }
        // Reset to false to indicate that we have consumed the dirty child
        // contexts' parent textures. (This is only useful when the compositor
        // is multithreaded.)
        m_childContextsWereCopied = false;
    }

    drawLayers(renderSurfaceLayerList);

    m_textureManager->unprotectAllTextures();

    // After drawLayers:
    if (hardwareCompositing() && m_contextSupportsLatch) {
        Extensions3DChromium* parentExt = static_cast<Extensions3DChromium*>(m_context->getExtensions());
        // For each child context:
        //   glSetLatch(Compositor->Offscreen);
        ChildContextMap::iterator i = m_childContexts.begin();
        for (; i != m_childContexts.end(); ++i) {
            Extensions3DChromium* childExt = static_cast<Extensions3DChromium*>(i->first->getExtensions());
            GC3Duint latchId;
            childExt->getParentToChildLatchCHROMIUM(&latchId);
            parentExt->setLatchCHROMIUM(latchId);
        }
    }

    if (isCompositingOffscreen())
        copyOffscreenTextureToDisplay();
}
Пример #11
0
void LayerModel::removeLayer(int id)
{
    feather::qml::command::remove_layer(id);
    updateLayers();
}