Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Jun 16, 2011
2 parents 728de00 + 608d394 commit 59992b0
Show file tree
Hide file tree
Showing 21 changed files with 184 additions and 71 deletions.
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/__init__.py
Expand Up @@ -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():
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/GdalTools/tools/doContour.py
Expand Up @@ -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 )

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/widgetContour.ui
Expand Up @@ -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>
Expand Down
15 changes: 10 additions & 5 deletions src/app/composer/qgscomposerlegendwidget.cpp
Expand Up @@ -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();
Expand Down
11 changes: 4 additions & 7 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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
}


Expand Down
11 changes: 8 additions & 3 deletions src/app/legend/qgslegendlayer.cpp
Expand Up @@ -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 );
}

Expand Down
1 change: 1 addition & 0 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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 );
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/composer/qgscomposerlegenditem.h
Expand Up @@ -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
Expand Down
27 changes: 17 additions & 10 deletions src/core/composer/qgslegendmodel.cpp
Expand Up @@ -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 )
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -304,7 +311,7 @@ void QgsLegendModel::updateLayer( QStandardItem* layerItem )
QgsRasterLayer* rLayer = qobject_cast<QgsRasterLayer*>( mapLayer );
if ( rLayer )
{
addRasterLayerItem( lItem, rLayer );
addRasterLayerItems( lItem, rLayer );
}
}
}
Expand Down Expand Up @@ -362,7 +369,7 @@ void QgsLegendModel::addLayer( QgsMapLayer* theMapLayer )
break;
}
case QgsMapLayer::RasterLayer:
addRasterLayerItem( layerItem, theMapLayer );
addRasterLayerItems( layerItem, theMapLayer );
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgslegendmodel.h
Expand Up @@ -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 );
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgslogger.h
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgscontrastenhancement.h
Expand Up @@ -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; }

/*
*
Expand Down
6 changes: 6 additions & 0 deletions src/core/raster/qgsfreakoutshader.h
Expand Up @@ -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();

Expand Down
6 changes: 6 additions & 0 deletions src/core/raster/qgspseudocolorshader.h
Expand Up @@ -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();

Expand Down
94 changes: 92 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp 100644 → 100755
Expand Up @@ -256,7 +256,7 @@ typedef QgsDataProvider * classFactoryFunction_t( const QString * );
//
/////////////////////////////////////////////////////////

unsigned int QgsRasterLayer::bandCount()
unsigned int QgsRasterLayer::bandCount() const
{
return mBandCount;
}
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 59992b0

Please sign in to comment.