Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/Quantum-GIS

  • Loading branch information
blazek committed Jun 16, 2011
2 parents 728de00 + 608d394 commit 59992b06582a49304dd411eced7045072ad8dc70
@@ -22,7 +22,7 @@ def name():
def description():
return "Integrate gdal tools into qgis"
def version():
return "Version 1.2.26"
return "Version 1.2.27"
def qgisMinimumVersion():
return "1.0"
def icon():
@@ -19,6 +19,8 @@ def __init__(self, iface):

gdalVersion = Utils.GdalConfig.version()
self.useDirAsOutput = gdalVersion < "1.7.0"
if self.useDirAsOutput:
self.label_2.setText( QApplication.translate("GdalToolsWidget", "&Output directory for contour lines (shapefile)") )

self.outSelector.setType( self.outSelector.FILE )

@@ -35,7 +35,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Output directory for contour lines (shapefile)</string>
<string>&amp;Output file for contour lines (vector)</string>
</property>
<property name="buddy">
<cstring>outSelector</cstring>
@@ -442,16 +442,21 @@ void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()
return;
}

QModelIndex currentIndex = mItemTreeView->currentIndex();
if ( !currentIndex.isValid() )
mLegend->beginCommand( "Legend item removed" );

QItemSelectionModel* selectionModel = mItemTreeView->selectionModel();
if( !selectionModel )
{
return;
}

QModelIndex parentIndex = currentIndex.parent();
QModelIndexList selection = selectionModel->selectedIndexes();
for( int i = selection.size() - 1; i >= 0; --i )
{
QModelIndex parentIndex = selection.at( i ).parent();
itemModel->removeRow( selection.at( i ).row(), parentIndex );
}

mLegend->beginCommand( "Legend item removed" );
itemModel->removeRow( currentIndex.row(), parentIndex );
mLegend->adjustBoxSize();
mLegend->update();
mLegend->endCommand();
@@ -699,7 +699,7 @@ QgsLegendGroup* QgsLegend::addEmbeddedGroup( const QString& groupName, const QSt
QString layerId = childElem.firstChildElement( "filegroup" ).firstChildElement( "legendlayerfile" ).attribute( "layerid" );
QgsProject::instance()->createEmbeddedLayer( layerId, projectFilePath, brokenNodes, vectorLayerList, false );
QTreeWidgetItem* cItem = 0;
if( settings.value("/qgis/addNewLayersToCurrentGroup", false ).toBool() )
if ( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() )
{
cItem = group->takeChild( 0 );
}
@@ -776,8 +776,8 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
}

setItemExpanded( llayer, true );

refreshLayerSymbology( layer->id() );
//don't expand raster items by default, there could be too many
refreshLayerSymbology( layer->id(), layer->type() != QgsMapLayer::RasterLayer );

updateMapCanvasLayerSet();

@@ -1723,10 +1723,7 @@ void QgsLegend::refreshLayerSymbology( QString key, bool expandItem )
//restore the current item again
setCurrentIndex( currentItemIndex );
adjustIconSize();
if ( expandItem )
{
setItemExpanded( theLegendLayer, true );//make sure the symbology items are visible
}
setItemExpanded( theLegendLayer, expandItem );//make sure the symbology items are visible
}


@@ -307,9 +307,14 @@ void QgsLegendLayer::vectorLayerSymbologyV2( QgsVectorLayer* layer )
void QgsLegendLayer::rasterLayerSymbology( QgsRasterLayer* layer )
{
SymbologyList itemList;
QPixmap legendpixmap = layer->legendAsPixmap( true ).scaled( 20, 20, Qt::KeepAspectRatio );
itemList.append( qMakePair( QString(), legendpixmap ) );

QList< QPair< QString, QColor > > rasterItemList = layer->legendSymbologyItems();
QList< QPair< QString, QColor > >::const_iterator itemIt = rasterItemList.constBegin();
for(; itemIt != rasterItemList.constEnd(); ++itemIt )
{
QPixmap itemPixmap( treeWidget()->iconSize() );
itemPixmap.fill( itemIt->second );
itemList.append( qMakePair( itemIt->first, itemPixmap ) );
}
changeSymbologySettings( layer, itemList );
}

@@ -2406,6 +2406,7 @@ void QgsRasterLayerProperties::on_mClassifyButton_clicked()
QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget );
newItem->setText( 0, QString::number( *value_it, 'f' ) );
newItem->setBackground( 1, QBrush( *color_it ) );
newItem->setText( 2, QString::number( *value_it, 'f' ) );
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
}
}
@@ -125,8 +125,12 @@ class CORE_EXPORT QgsComposerRasterSymbolItem: public QgsComposerLegendItem
QString layerID() const { return mLayerID; }
ItemType itemType() const { return RasterSymbolItem; }

void setColor( const QColor& c ){ mColor = c; }
QColor color() const { return mColor; }

private:
QString mLayerID;
QColor mColor;
};

class CORE_EXPORT QgsComposerLayerItem: public QgsComposerLegendItem
@@ -223,7 +223,7 @@ int QgsLegendModel::addVectorLayerItems( QStandardItem* layerItem, QgsVectorLaye
return 0;
}

int QgsLegendModel::addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* rlayer )
int QgsLegendModel::addRasterLayerItems( QStandardItem* layerItem, QgsMapLayer* rlayer )
{
if ( !layerItem || !rlayer )
{
@@ -236,15 +236,22 @@ int QgsLegendModel::addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* r
return 2;
}

QgsComposerRasterSymbolItem* currentSymbolItem = new QgsComposerRasterSymbolItem();
//use a vector symbol item without symbol
if ( mHasTopLevelWindow ) //only use QIcon / QPixmap if we have a running x-server
QList< QPair< QString, QColor > > rasterItemList = rasterLayer->legendSymbologyItems();
QList< QPair< QString, QColor > >::const_iterator itemIt = rasterItemList.constBegin();
for(; itemIt != rasterItemList.constEnd(); ++itemIt )
{
currentSymbolItem->setIcon( QIcon( rasterLayer->legendAsPixmap( true ) ) );
QgsComposerRasterSymbolItem* currentSymbolItem = new QgsComposerRasterSymbolItem( itemIt->first );
if( mHasTopLevelWindow )
{
QPixmap itemPixmap( 20, 20 );
itemPixmap.fill( itemIt->second );
currentSymbolItem->setIcon( QIcon( itemPixmap ) );
}
currentSymbolItem->setLayerID( rasterLayer->id() );
currentSymbolItem->setColor( itemIt->second );
int currentRowCount = layerItem->rowCount();
layerItem->setChild( currentRowCount, 0, currentSymbolItem );
}
currentSymbolItem->setLayerID( rasterLayer->id() );
int currentRowCount = layerItem->rowCount();
layerItem->setChild( currentRowCount, 0, currentSymbolItem );

return 0;
}
@@ -304,7 +311,7 @@ void QgsLegendModel::updateLayer( QStandardItem* layerItem )
QgsRasterLayer* rLayer = qobject_cast<QgsRasterLayer*>( mapLayer );
if ( rLayer )
{
addRasterLayerItem( lItem, rLayer );
addRasterLayerItems( lItem, rLayer );
}
}
}
@@ -362,7 +369,7 @@ void QgsLegendModel::addLayer( QgsMapLayer* theMapLayer )
break;
}
case QgsMapLayer::RasterLayer:
addRasterLayerItem( layerItem, theMapLayer );
addRasterLayerItems( layerItem, theMapLayer );
break;
default:
break;
@@ -104,7 +104,7 @@ class CORE_EXPORT QgsLegendModel: public QStandardItemModel

/**Adds item of raster layer
@return 0 in case of success*/
int addRasterLayerItem( QStandardItem* layerItem, QgsMapLayer* rlayer );
int addRasterLayerItems( QStandardItem* layerItem, QgsMapLayer* rlayer );

/**Creates a model item for a vector symbol. The calling function takes ownership*/
QStandardItem* itemFromSymbol( QgsSymbol* s, int opacity, const QString& layerID );
@@ -110,14 +110,14 @@ class CORE_EXPORT QgsLogger
the function returns 1 if QGISDEBUG is defined and 0 if not*/
static int debugLevel();

/** Logs the message passed in to the logfile defined in QGIS_LOG_FILE if any. **/
static const void logMessageToFile( QString theMessage );

private:
/**Reads the environment variable QGIS_LOG_FILE. Returns NULL if the variable is not set,
* otherwise returns a file name for writing log messages to.*/
static const QString logFile();

/** Logs the message passed in to the logfile defined in QGIS_LOG_FILE if any. **/
static const void logMessageToFile( QString theMessage );

/**Reads the environment variable QGIS_DEBUG_FILE. Returns NULL if the variable is not set.
* If set, only messages from this source file will be sent to logs. */
static const char* debugFile();
@@ -94,7 +94,7 @@ class CORE_EXPORT QgsContrastEnhancement
/** \brief Return the minimum value for the contrast enhancement range. */
double minimumValue() const { return mMinimumValue; }

ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }

/*
*
@@ -44,6 +44,12 @@ class CORE_EXPORT QgsFreakOutShader : public QgsRasterShaderFunction
/** \brief Return the minimum value */
void setMinimumValue( double );

double classBreakMin1() const { return mClassBreakMin1; }
double classBreakMax1() const { return mClassBreakMax1; }
double classBreakMin2() const { return mClassBreakMin2; }
double classBreakMax2() const { return mClassBreakMax2; }
double classBreakMin3() const { return mClassBreakMin3; }

private:
void setClassBreaks();

@@ -44,6 +44,12 @@ class CORE_EXPORT QgsPseudoColorShader : public QgsRasterShaderFunction
/** \brief Return the minimum value */
void setMinimumValue( double );

double classBreakMin1() const { return mClassBreakMin1; }
double classBreakMax1() const { return mClassBreakMax1; }
double classBreakMin2() const { return mClassBreakMin2; }
double classBreakMax2() const { return mClassBreakMax2; }
double classBreakMin3() const { return mClassBreakMin3; }

private:
void setClassBreaks();

94 src/core/raster/qgsrasterlayer.cpp 100644 → 100755
@@ -256,7 +256,7 @@ typedef QgsDataProvider * classFactoryFunction_t( const QString * );
//
/////////////////////////////////////////////////////////

unsigned int QgsRasterLayer::bandCount()
unsigned int QgsRasterLayer::bandCount() const
{
return mBandCount;
}
@@ -274,7 +274,7 @@ const QString QgsRasterLayer::bandName( int theBandNo )
}
}

int QgsRasterLayer::bandNumber( QString const & theBandName )
int QgsRasterLayer::bandNumber( QString const & theBandName ) const
{
for ( int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator )
{
@@ -679,6 +679,16 @@ QgsContrastEnhancement* QgsRasterLayer::contrastEnhancement( unsigned int theBan
return 0;
}

const QgsContrastEnhancement* QgsRasterLayer::constContrastEnhancement( unsigned int theBand ) const
{
if ( 0 < theBand && theBand <= bandCount() )
{
return &mContrastEnhancementList[theBand - 1];
}

return 0;
}

QString QgsRasterLayer::contrastEnhancementAlgorithmAsString() const
{
switch ( mContrastEnhancementAlgorithm )
@@ -1209,6 +1219,86 @@ QString QgsRasterLayer::lastErrorTitle()
return mErrorCaption;
}

QList< QPair< QString, QColor > > QgsRasterLayer::legendSymbologyItems() const
{
QList< QPair< QString, QColor > > symbolList;
if ( mDrawingStyle == SingleBandGray || mDrawingStyle == PalettedSingleBandGray || mDrawingStyle == MultiBandSingleBandGray )
{
//add min/max from contrast enhancement
QString grayBand = grayBandName();
if ( !grayBand.isEmpty() )
{
int grayBandNr = bandNumber( grayBand );
const QgsContrastEnhancement* ceh = constContrastEnhancement( grayBandNr );
if ( ceh )
{
QgsContrastEnhancement::ContrastEnhancementAlgorithm alg = ceh->contrastEnhancementAlgorithm();
if ( alg == QgsContrastEnhancement::NoEnhancement
|| alg == QgsContrastEnhancement::ClipToMinimumMaximum )
{
//diffcult to display a meaningful item
symbolList.push_back( qMakePair( QString::number( ceh->minimumValue() ) + "-" + QString::number( ceh->maximumValue() ), QColor( 125, 125, 125 ) ) );
}
else
{
symbolList.push_back( qMakePair( QString::number( ceh->minimumValue() ), QColor( 0, 0, 0 ) ) );
symbolList.push_back( qMakePair( QString::number( ceh->maximumValue() ), QColor( 255, 255, 255 ) ) );
}
}
}
}
else
{
switch ( mColorShadingAlgorithm )
{
case ColorRampShader:
{
const QgsColorRampShader* crShader = dynamic_cast<QgsColorRampShader*>( mRasterShader->rasterShaderFunction() );
if ( crShader )
{
QList<QgsColorRampShader::ColorRampItem> shaderItems = crShader->colorRampItemList();
QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = shaderItems.constBegin();
for ( ; itemIt != shaderItems.constEnd(); ++itemIt )
{
symbolList.push_back( qMakePair( itemIt->label, itemIt->color ) );
}
}
break;
}
case PseudoColorShader:
{
//class breaks have fixed color for the pseudo color shader
const QgsPseudoColorShader* pcShader = dynamic_cast<QgsPseudoColorShader*>( mRasterShader->rasterShaderFunction() );
if ( pcShader )
{
symbolList.push_back( qMakePair( QString::number( pcShader->classBreakMin1() ), QColor( 0, 0, 255 ) ) );
symbolList.push_back( qMakePair( QString::number( pcShader->classBreakMax1() ), QColor( 0, 255, 255 ) ) );
symbolList.push_back( qMakePair( QString::number( pcShader->classBreakMax2() ), QColor( 255, 255, 0 ) ) );
symbolList.push_back( qMakePair( QString::number( pcShader->maximumValue() ), QColor( 255, 0, 0 ) ) );
}
break;
}
case FreakOutShader:
{
const QgsFreakOutShader* foShader = dynamic_cast<QgsFreakOutShader*>( mRasterShader->rasterShaderFunction() );
if ( foShader )
{
symbolList.push_back( qMakePair( QString::number( foShader->classBreakMin1() ), QColor( 255, 0, 255 ) ) );
symbolList.push_back( qMakePair( QString::number( foShader->classBreakMax1() ), QColor( 0, 255, 255 ) ) );
symbolList.push_back( qMakePair( QString::number( foShader->classBreakMax2() ), QColor( 255, 0, 0 ) ) );
symbolList.push_back( qMakePair( QString::number( foShader->maximumValue() ), QColor( 0, 255, 0 ) ) );
}
break;
}
default:
{
break;
}
}
}
return symbolList;
}

/**
* This is an overloaded version of the legendAsPixmap( bool ) assumes false for the legend name flag.
* @return a pixmap representing a legend image

0 comments on commit 59992b0

Please sign in to comment.
You can’t perform that action at this time.