void QgsMapLayerComboBox::rowsChanged()
{
  if ( count() == 1 )
  {
    //currently selected layer item has changed
    emit layerChanged( currentLayer() );
  }
  else if ( count() == 0 )
  {
    emit layerChanged( nullptr );
  }
}
Example #2
0
int Tiled::Internal::MapScene::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsScene::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: setGridVisible((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: refreshScene(); break;
        case 2: repaintRegion((*reinterpret_cast< const QRegion(*)>(_a[1]))); break;
        case 3: currentLayerIndexChanged(); break;
        case 4: mapChanged(); break;
        case 5: tilesetChanged((*reinterpret_cast< Tileset*(*)>(_a[1]))); break;
        case 6: layerAdded((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: layerRemoved((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: layerChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: objectsAdded((*reinterpret_cast< const QList<MapObject*>(*)>(_a[1]))); break;
        case 10: objectsRemoved((*reinterpret_cast< const QList<MapObject*>(*)>(_a[1]))); break;
        case 11: objectsChanged((*reinterpret_cast< const QList<MapObject*>(*)>(_a[1]))); break;
        case 12: updateSelectedObjectItems(); break;
        default: ;
        }
        _id -= 13;
    }
    return _id;
}
Example #3
0
void QgsSymbolSelectorWidget::setContext( const QgsSymbolWidgetContext &context )
{
  mContext = context;

  if ( mContext.expressionContext() )
  {
    mPreviewExpressionContext = *mContext.expressionContext();
    if ( mVectorLayer )
      mPreviewExpressionContext.appendScope( QgsExpressionContextUtils::layerScope( mVectorLayer ) );

    mPreviewExpressionContext.setFeature( mPreviewFeature );
  }

  QWidget *widget = stackedWidget->currentWidget();
  QgsLayerPropertiesWidget *layerProp = dynamic_cast< QgsLayerPropertiesWidget * >( widget );
  QgsSymbolsListWidget *listWidget = dynamic_cast< QgsSymbolsListWidget * >( widget );

  if ( layerProp )
    layerProp->setContext( context );
  if ( listWidget )
    listWidget->setContext( context );

  layerChanged();
  updatePreview();
}
Example #4
0
void QgsMapLayerComboBox::setLayer( QgsMapLayer *layer )
{
  QModelIndex idx = mProxyModel->sourceLayerModel()->indexFromLayer( layer );
  if ( idx.isValid() )
  {
    QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
    if ( proxyIdx.isValid() )
    {
      setCurrentIndex( proxyIdx.row() );
      emit layerChanged( currentLayer() );
      return;
    }
  }
  setCurrentIndex( -1 );
  emit layerChanged( currentLayer() );
}
Example #5
0
void QgsSymbolSelectorWidget::changeLayer( QgsSymbolLayer *newLayer )
{
  SymbolLayerItem *item = currentLayerItem();
  QgsSymbolLayer *layer = item->layer();

  if ( layer->subSymbol() )
  {
    item->removeRow( 0 );
  }
  // update symbol layer item
  item->setLayer( newLayer );
  // When it is a marker symbol
  if ( newLayer->subSymbol() )
  {
    loadSymbol( newLayer->subSymbol(), item );
    layersTree->setExpanded( item->index(), true );
  }

  // Change the symbol at last to avoid deleting item's layer
  QgsSymbol *symbol = static_cast<SymbolLayerItem *>( item->parent() )->symbol();
  int layerIdx = item->parent()->rowCount() - item->row() - 1;
  symbol->changeSymbolLayer( layerIdx, newLayer );

  item->updatePreview();
  updatePreview();
  // Important: This lets the layer have its own layer properties widget
  layerChanged();
}
Example #6
0
void QgsFieldValuesLineEdit::setLayer( QgsVectorLayer* layer )
{
  if ( mLayer == layer )
    return;

  mLayer = layer;
  emit layerChanged( layer );
}
void QAbstractTextureImage::setLayer(int layer)
{
    Q_D(QAbstractTextureImage);
    if (layer != d->m_layer) {
        d->m_layer = layer;
        emit layerChanged(layer);
    }
}
QMenu* QgsSymbolV2SelectorDialog::advancedMenu()
{
  if ( mAdvancedMenu == NULL )
  {
    mAdvancedMenu = new QMenu( this );
    // Brute force method to activate the Advanced menu
    layerChanged();
  }
  return mAdvancedMenu;
}
QgsTileScaleWidget::QgsTileScaleWidget( QgsMapCanvas * mapCanvas, QWidget * parent, Qt::WindowFlags f )
    : QWidget( parent, f )
    , mMapCanvas( mapCanvas )
{
  setupUi( this );

  connect( mMapCanvas, SIGNAL( scaleChanged( double ) ), this, SLOT( scaleChanged( double ) ) );

  layerChanged( mMapCanvas->currentLayer() );
}
Example #10
0
QgsTileScaleWidget::QgsTileScaleWidget( QgsMapCanvas *mapCanvas, QWidget *parent, Qt::WindowFlags f )
  : QWidget( parent, f )
  , mMapCanvas( mapCanvas )
{
  setupUi( this );

  connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, &QgsTileScaleWidget::scaleChanged );

  layerChanged( mMapCanvas->currentLayer() );
}
Example #11
0
QMenu *QgsSymbolSelectorWidget::advancedMenu()
{
  if ( !mAdvancedMenu )
  {
    mAdvancedMenu = new QMenu( this );
    // Brute force method to activate the Advanced menu
    layerChanged();
  }
  return mAdvancedMenu;
}
Example #12
0
void QgsSymbolSelectorWidget::setContext( const QgsSymbolWidgetContext& context )
{
  mContext = context;

  QWidget* widget = stackedWidget->currentWidget();
  QgsLayerPropertiesWidget* layerProp = dynamic_cast< QgsLayerPropertiesWidget* >( widget );
  QgsSymbolsListWidget* listWidget = dynamic_cast< QgsSymbolsListWidget* >( widget );

  if ( layerProp )
    layerProp->setContext( context );
  if ( listWidget )
    listWidget->setContext( context );

  layerChanged();
  updatePreview();
}
Example #13
0
/**
 * Called when the color has changed. This method 
 * sets the current color to the value chosen or even
 * offers a dialog to the user that allows him/ her to
 * choose an individual color.
 */
void QG_LayerBox::slotLayerChanged(int index) {
    //currentLayer.resetFlags();

	if (index==0 && showUnchanged) {
		unchanged = true;
	}
	else {
		unchanged = false;
	}

    currentLayer = layerList->find(itemText(index));

    //printf("Current color is (%d): %s\n",
    //       index, currentLayer.name().latin1());

    emit layerChanged(currentLayer);
}
Example #14
0
RectTool::RectTool(AddingType type, Canvas *canvas) :
	Tool(canvas),
	d(new Data)
{
	d->layerController = canvas->findChild<LayerUIController *>();
	d->updateManager = new CanvasUpdateManager(this);
	connect(d->updateManager, SIGNAL(updateTilesRequested(QPointSet)), this, SIGNAL(requestUpdate(QPointSet)));
	
	// set modes
	
	d->addingType = type;
	
	if (d->addingType == NoAdding)
		d->selectingMode = SelectImmediately;
	else
		d->selectingMode = SelectLater;
	
	// create graphics items
	{
		auto group = new QGraphicsItemGroup();
		group->setHandlesChildEvents(false);
		setGraphicsItem(group);
		
		{
			auto frame = new FrameGraphicsItem(group);
			d->frameItem = frame;
		}
	}
	
	addHandle(Top | Left, 1);
	addHandle(Top | Right, 1);
	addHandle(Bottom | Left, 1);
	addHandle(Bottom | Right, 1);
	addHandle(Top, 0);
	addHandle(Bottom, 0);
	addHandle(Left, 0);
	addHandle(Right, 0);
	
	connect(layerScene(), SIGNAL(selectionChanged(QList<LayerConstRef>,QList<LayerConstRef>)), this, SLOT(updateSelected()));
	connect(layerScene(), SIGNAL(layerChanged(LayerConstRef)), this, SLOT(updateLayer(LayerConstRef)));
	connect(canvas, SIGNAL(transformsChanged(SP<const CanvasTransforms>)), this, SLOT(updateGraphicsItems()));
	updateSelected();
}
Example #15
0
bool MipData::loadMy4DImage(const My4DImage* img, const My4DImage* maskImg)
{
    // Validate data in this thread
    if (!img) return false;

    benchmark.start();

    dataMin = 1e9;
    dataMax = -1e9;

    data.assign(img->getXDim(), MipData::Column(img->getYDim(), MipData::Pixel(img->getCDim()))); // 50 ms

    // qDebug() << "size = " << data.size();
    // qDebug() << "nColumns = " << nColumns();
    // MipData& t = *this;
    volume4DImage = img;
    My4DImage * mutable_img = const_cast<My4DImage*>(img);
    Image4DProxy<My4DImage> imgProxy(mutable_img);

    numNeurons = 0;

    NeuronChannelIntegratorList neuronColors;
    // First loop "quickly" updates intensity, without updating neuron masks
    for (int x = 0; x < nColumns(); ++x) {
        for (int y = 0; y < nRows(); ++y) {
            for (int z = 0; z < img->getZDim(); ++z)
            {
                int neuronIndex = -1;
                if (maskImg) {
                    neuronIndex = maskImg->at(x, y, z);
                    if (neuronIndex >= numNeurons) {
                        numNeurons = neuronIndex + 1;
                        neuronColors.resize(numNeurons, NeuronChannelIntegrator(nChannels(), 0.0));
                    }
                }
                float intensity = 0.0;
                for (int c = 0; c < nChannels(); ++c) {
                    float val = (float)imgProxy.value_at(x,y,z,c);
                    // Update minimum and maximum values
                    if (val > dataMax) dataMax = val;
                    if (val < dataMin) dataMin = val;
                    // Update current voxel intensity
                    intensity += val;
                    if (neuronIndex >= 0)
                        neuronColors[neuronIndex][c] += val;
                }
                assert(intensity >= 0.0);
                // Maximum intensity projection - regardless of neuron masks
                if (intensity > data[x][y].intensity) {
                    for (int c = 0; c < nChannels(); ++c)
                        data[x][y][c] = (float)imgProxy.value_at(x,y,z,c);
                    data[x][y].z = z; // remember z-value of max intensity pixel
                    data[x][y].intensity = intensity;
                    if (maskImg) {
                        data[x][y].neuronIndex = (int) maskImg->at(x, y, z);
                    }
                }
            }
        }
        if (! (x % 10))
            emit processedXColumn(x + 1);
        // qDebug() << "processed column " << x + 1;
    }
    qDebug() << "Computing MIP took " << benchmark.restart() << " milliseconds";
    for (int n = 0; n < neuronColors.size(); ++n)
    {
        NeuronChannelIntegrator& neuronColor = neuronColors[n];
        // find maximum
        double maxCount = -1e9;
        for (int c = 0; c < neuronColor.size(); ++c) {
            double channelCount = neuronColor[c];
            if (channelCount > maxCount)
                maxCount = channelCount;
        }
        // scale by maximum
        for (int c = 0; c < neuronColor.size(); ++c) {
            neuronColor[c] /= maxCount;
        }
    }
    qDebug() << "Computing neuron colors took " << benchmark.restart() << " milliseconds";
    // TODO - actually use the color information

    emit intensitiesUpdated();

    // Populate individual neuron mip layers
    if (maskImg && (numNeurons > 0))
    {
        if (neuronLayers) delete [] neuronLayers;
        neuronLayers = new MipLayer*[numNeurons];
        for (int i = 0; i < numNeurons; ++i)
            neuronLayers[i] = new MipLayer(QSize(nColumns(), nRows()), this);

        qDebug() << "processing MIP masks";
        for (int x = 0; x < nColumns(); ++x) {
            for (int y = 0; y < nRows(); ++y) {
                for (int z = 0; z < img->getZDim(); ++z)
                {
                    int neuronMaskId = maskImg->at(x,y,z);
                    if (neuronMaskId < 0) continue;
                    float intensity = 0.0;
                    for (int c = 0; c < nChannels(); ++c)
                        intensity += (float)imgProxy.value_at(x,y,z,c);
                    assert(intensity >= 0.0);
                    MipLayer::Pixel& currentPixel = neuronLayers[neuronMaskId]->getPixel(x, y);
                    if (   (currentPixel.neuronIndex != neuronMaskId) // no data for this neuron so far
                        || (intensity > currentPixel.intensity) ) // brightest intensity seen so far
                    {
                        currentPixel.neuronIndex = neuronMaskId;
                        currentPixel.zCoordinate = z;
                        currentPixel.intensity = intensity;
                    }
                }
            }
        }
        qDebug() << "finished creating MIP masks; took " << benchmark.restart() << " milliseconds";
        // TODO create binary tree of mip layers leading to combined image
        std::vector<MipLayer*> layers;
        for (int n = 0; n < numNeurons; ++n) {
            layers.push_back(neuronLayers[n]);
        }
        while (layers.size() > 1) {
            std::vector<MipLayer*> nextLevel;
            while (layers.size() > 0) {
                MipLayer* node1 = layers.back(); layers.pop_back();
                MipLayer* node2 = NULL;
                if (layers.size() > 0) {
                    node2 = layers.back();
                    layers.pop_back();
                }
                nextLevel.push_back(new MipLayer(node1, node2, this));
            }
            layers = nextLevel;
            qDebug() << "layers size = " << layers.size();
        }
        assert(layers.size() == 1);
        combinedMipLayer = layers.back();
        connect(combinedMipLayer, SIGNAL(layerChanged()),
                this, SLOT(onCombinedMipLayerUpdated()));
        qDebug() << "Creating MIP layer binary tree took " << benchmark.restart() << " milliseconds";
    }

    return true;
}
void QgsMapLayerComboBox::indexChanged( int i )
{
  Q_UNUSED( i );
  QgsMapLayer *layer = currentLayer();
  emit layerChanged( layer );
}
void QgsPasteTransformations::destinationChanged( const QString& layerName )
{
  QgsDebugMsg( QString( "Destination changed to %1." ).arg( layerName ) );
  layerChanged( layerName, &mDestinationFields );
}
void QgsPasteTransformations::sourceChanged( const QString& layerName )
{
  QgsDebugMsg( QString( "Source changed to %1." ).arg( layerName ) );
  layerChanged( layerName, &mSourceFields );
}
Example #19
0
            this,
            SLOT(redrawMap()));
    connect(m_view->verticalScrollBar(),
            SIGNAL(valueChanged(int)),
            this,
            SLOT(on_view_V_Scroll()));
    connect(m_view->horizontalScrollBar(),
            SIGNAL(valueChanged(int)),
            this,
            SLOT(on_view_H_Scroll()));
    connect(mCore,
            SIGNAL(toolChanged()),
            this,
            SLOT(onToolChanged()));
    connect(mCore,
            SIGNAL(layerChanged()),
            this,
            SLOT(onLayerChanged()));
    m_view->verticalScrollBar()->setValue(n_mapInfo.scrollbar_y*m_scale);
    m_view->horizontalScrollBar()->setValue(n_mapInfo.scrollbar_x*m_scale);
    m_init = true;
    redrawMap();
}

float QGraphicsMapScene::scale() const
{
    return m_scale;
}

QString QGraphicsMapScene::mapName() const
{
Example #20
0
void QgsSymbolV2SelectorWidget::setExpressionContext( QgsExpressionContext *context )
{
  mPresetExpressionContext.reset( context );
  layerChanged();
  updatePreview();
}