Exemplo n.º 1
0
bool QgsMapToolLabel::diagramMoveable( QgsMapLayer* ml, int& xCol, int& yCol ) const
{
  QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( ml );
  if ( vlayer && vlayer->diagramRenderer() )
  {
    const QgsDiagramLayerSettings *dls = vlayer->diagramLayerSettings();
    if ( dls && dls->xPosColumn >= 0 && dls->yPosColumn >= 0 )
    {
      xCol = dls->xPosColumn;
      yCol = dls->yPosColumn;
      return true;
    }
  }
  return false;
}
Exemplo n.º 2
0
bool QgsMapToolLabel::diagramCanShowHide( QgsMapLayer* ml, int& showCol ) const
{
  bool rc = false;

  QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( ml );

  if ( vlayer && vlayer->isEditable() && vlayer->diagramsEnabled() )
  {
    const QgsDiagramLayerSettings *dls = vlayer->diagramLayerSettings();

    if ( dls && dls->showColumn >= 0 )
    {
      showCol = dls->showColumn;
      rc = true;
    }
  }

  return rc;
}
Exemplo n.º 3
0
bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsDiagramIndexes &indexes )
{
  bool newAuxiliaryLayer = false;
  QgsVectorLayer *vlayer = details.layer;

  if ( !vlayer )
    return newAuxiliaryLayer;

  if ( !vlayer->auxiliaryLayer() )
  {
    QgsNewAuxiliaryLayerDialog dlg( vlayer );
    dlg.exec();
    newAuxiliaryLayer = true;
  }

  if ( !vlayer->auxiliaryLayer() )
    return false;

  for ( const QgsDiagramLayerSettings::Property &p : qgis::as_const( mDiagramProperties ) )
  {
    int index = -1;

    // always use the default activated property
    QgsProperty prop = vlayer->diagramLayerSettings()->dataDefinedProperties().property( p );
    if ( prop.propertyType() == QgsProperty::FieldBasedProperty && prop.isActive() )
    {
      index = vlayer->fields().lookupField( prop.field() );
    }
    else
    {
      index = QgsAuxiliaryLayer::createProperty( p, vlayer );
    }

    indexes[p] = index;
  }

  return newAuxiliaryLayer;
}