686 changes: 375 additions & 311 deletions i18n/qgis_gl_ES.ts

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<file>themes/default/mActionFileSmall.png</file>
<file>themes/default/mActionFolder.png</file>
<file>themes/default/mActionFormAnnotation.png</file>
<file>themes/default/mActionFreezeLabels.png</file>
<file>themes/default/mActionFreezeLabels.svg</file>
<file>themes/default/mActionFromSelectedFeature.png</file>
<file>themes/default/mActionFullCumulativeCutStretch.png</file>
<file>themes/default/mActionFullHistogramStretch.png</file>
Expand Down Expand Up @@ -149,7 +149,7 @@
<file>themes/default/mActionSelectRectangle.png</file>
<file>themes/default/mActionShowAllLayers.png</file>
<file>themes/default/mActionShowBookmarks.png</file>
<file>themes/default/mActionShowFrozenLabels.png</file>
<file>themes/default/mActionShowFrozenLabels.svg</file>
<file>themes/default/mActionShowPluginManager.png</file>
<file>themes/default/mActionSimplify.png</file>
<file>themes/default/mActionSplitFeatures.png</file>
Expand Down Expand Up @@ -294,6 +294,7 @@
<file>themes/gis/mActionFileSave.png</file>
<file>themes/gis/mActionFolder.png</file>
<file>themes/gis/mActionFormAnnotation.png</file>
<file>themes/gis/mActionFreezeLabels.svg</file>
<file>themes/gis/mActionGroupItems.png</file>
<file>themes/gis/mActionHelpContents.png</file>
<file>themes/gis/mActionHideAllLayers.png</file>
Expand Down Expand Up @@ -346,6 +347,7 @@
<file>themes/gis/mActionSelectRectangle.png</file>
<file>themes/gis/mActionShowAllLayers.png</file>
<file>themes/gis/mActionShowBookmarks.png</file>
<file>themes/gis/mActionShowFrozenLabels.svg</file>
<file>themes/gis/mActionSimplify.png</file>
<file>themes/gis/mActionSplitFeatures.png</file>
<file>themes/gis/mActionSplitFeatures.svg</file>
Expand Down
105 changes: 105 additions & 0 deletions images/themes/default/mActionFreezeLabels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions images/themes/default/mActionShowFrozenLabels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
570 changes: 570 additions & 0 deletions images/themes/gis/mActionFreezeLabels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
600 changes: 600 additions & 0 deletions images/themes/gis/mActionShowFrozenLabels.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,8 +1626,8 @@ void QgisApp::setTheme( QString theThemeName )
mActionFormAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionFormAnnotation.png" ) );
mActionTextAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionTextAnnotation.png" ) );
mActionLabeling->setIcon( QgsApplication::getThemeIcon( "/mActionLabeling.png" ) );
mActionShowFrozenLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowFrozenLabels.png" ) );
mActionFreezeLabels->setIcon( QgsApplication::getThemeIcon( "/mActionFreezeLabels.png" ) );
mActionShowFrozenLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowFrozenLabels.svg" ) );
mActionFreezeLabels->setIcon( QgsApplication::getThemeIcon( "/mActionFreezeLabels.svg" ) );
mActionMoveLabel->setIcon( QgsApplication::getThemeIcon( "/mActionMoveLabel.png" ) );
mActionRotateLabel->setIcon( QgsApplication::getThemeIcon( "/mActionRotateLabel.svg" ) );
mActionChangeLabelProperties->setIcon( QgsApplication::getThemeIcon( "/mActionChangeLabelProperties.png" ) );
Expand Down
6 changes: 4 additions & 2 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,12 @@ QIcon QgsSymbolLayerV2Utils::colorRampPreviewIcon( QgsVectorColorRampV2* ramp, Q
QPixmap QgsSymbolLayerV2Utils::colorRampPreviewPixmap( QgsVectorColorRampV2* ramp, QSize size )
{
QPixmap pixmap( size );
pixmap.fill( Qt::transparent );
// pixmap.fill( Qt::white ); // this makes the background white instead of transparent
QPainter painter;
painter.begin( &pixmap );
painter.setRenderHint( QPainter::Antialiasing );
painter.eraseRect( QRect( QPoint( 0, 0 ), size ) );
// antialising makes the colors duller, and no point in antialiasing a color ramp
// painter.setRenderHint( QPainter::Antialiasing );
for ( int i = 0; i < size.width(); i++ )
{
QPen pen( ramp->color(( double ) i / size.width() ) );
Expand Down
153 changes: 107 additions & 46 deletions src/core/symbology-ng/qgsvectorcolorrampv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ static QColor _interpolate( QColor c1, QColor c2, double value )
int r = ( int )( c1.red() + value * ( c2.red() - c1.red() ) );
int g = ( int )( c1.green() + value * ( c2.green() - c1.green() ) );
int b = ( int )( c1.blue() + value * ( c2.blue() - c1.blue() ) );
int a = ( int )( c1.alpha() + value * ( c2.alpha() - c1.alpha() ) );

return QColor::fromRgb( r, g, b );
return QColor::fromRgb( r, g, b, a );
}

QColor QgsVectorGradientColorRampV2::color( double value ) const
Expand Down Expand Up @@ -269,7 +270,7 @@ QMap< QString, QString > QgsCptCityColorRampV2::mCollectionNames;
QMap< QString, QStringList > QgsCptCityColorRampV2::mCollectionSelections;

QgsCptCityColorRampV2::QgsCptCityColorRampV2( QString schemeName, QString variantName )
: mSchemeName( schemeName ), mVariantName( variantName ), mContinuous( false )
: mSchemeName( schemeName ), mVariantName( variantName ), mGradientType( Continuous )
{
// TODO replace this with hard-coded data in the default case
loadFile();
Expand All @@ -289,7 +290,7 @@ QgsVectorColorRampV2* QgsCptCityColorRampV2::create( const QgsStringMap& props )
}



#if 0
QColor QgsCptCityColorRampV2::color( double value ) const
{
if ( mPalette.isEmpty() || value < 0 || value > 1 )
Expand Down Expand Up @@ -333,6 +334,45 @@ QColor QgsCptCityColorRampV2::color( double value ) const
return upper == lower ? c1 : _interpolate( c1, c2, ( value - lower ) / ( upper - lower ) );
}
}
#endif

QColor QgsCptCityColorRampV2::color( double value ) const
{
if ( mPalette.isEmpty() || value < 0 || value > 1 )
return QColor( 255, 0, 0 ); // red color as a warning :)

int numStops = mPalette.count();
if ( numStops < 2 )
return QColor( 255, 0, 0 ); // red color as a warning :)

double lower = 0, upper = 0;
QColor c1, c2;
c1 = mPalette[0].second;
for ( int i = 0; i < numStops; i++ )
{
if ( mPalette[i].first >= value )
{
if ( mGradientType == Discrete )
return c1;

upper = mPalette[i].first;
c2 = mPalette[i].second;

return upper == lower ? c1 : _interpolate( c1, c2, ( value - lower ) / ( upper - lower ) );
}

lower = mPalette[i].first;
c1 = mPalette[i].second;
}

if ( mGradientType == Discrete )
return c1;

upper = 1;
c2 = mPalette[ numStops - 1 ].second;

return upper == lower ? c1 : _interpolate( c1, c2, ( value - lower ) / ( upper - lower ) );
}

QgsVectorColorRampV2* QgsCptCityColorRampV2::clone() const
{
Expand Down Expand Up @@ -390,30 +430,25 @@ QStringList QgsCptCityColorRampV2::listSchemeNames( QString collectionName )
return entries;
}

QList<int> QgsCptCityColorRampV2::listSchemeVariants( QString schemeName )
QString QgsCptCityColorRampV2::getBaseDir()
{
QList<int> variants;
// if was set with setBaseDir, return that value
QString baseDir = mBaseDir;

QString palette( brewerString );
QStringList list = palette.split( QChar( '\n' ) );
foreach ( QString entry, list )
// use CptCity/baseDir setting if set
if ( baseDir.isNull() )
{
QStringList items = entry.split( QChar( '-' ) );
if ( items.count() != 3 || items[0] != schemeName )
continue;
variants << items[1].toInt();
QSettings settings;
baseDir = settings.value( "CptCity/baseDir", QString() ).toString();
if ( ! baseDir.isNull() )
baseDir += "/cpt-city";
}

return variants;
}
// fallback to user setting dir
if ( baseDir.isNull() )
baseDir = QgsApplication::qgisSettingsDirPath() + "/" + "cpt-city";

QString QgsCptCityColorRampV2::getBaseDir()
{
// currently hard-coded, but could be also in QGis install path and/or configurable
if ( mBaseDir.isNull() )
return QgsApplication::qgisSettingsDirPath() + "/" + "cpt-city";
else
return mBaseDir;
return baseDir;
}

QString QgsCptCityColorRampV2::getFilename() const
Expand All @@ -436,7 +471,6 @@ bool QgsCptCityColorRampV2::loadFile( QString filename )
// QgsDebugMsg("filename= "+filename);

mPalette.clear();
mPaletteStops.clear();

QString mErrorString = QString();

Expand Down Expand Up @@ -478,40 +512,38 @@ bool QgsCptCityColorRampV2::loadFile( QString filename )
return false;
}

// initialize self
mContinuous = true; // we will detect later if there are overlapping stops
mPalette.clear();
mPaletteStops.clear();

// loop for all stop tags
QDomElement e = rampsElement.firstChildElement();
// int i = 0;
QMap< double, QColor > map;
QMap< double, QPair<QColor, QColor> > map;

QColor prevColor;
while ( !e.isNull() )
{
// QgsDebugMsg("read "+e.tagName());
if ( e.tagName() == "stop" )
{
//todo integrate this into symbollayerutils, keep here for now...
double offset;
QString offsetStr = e.attribute( "offset" ); // offset="50.00%" | offset="0.5"
QString colorStr = e.attribute( "stop-color", "" ); // stop-color="rgb(222,235,247)"
QString opacityStr = e.attribute( "stop-opacity", "1.0" ); // stop-opacity="1.0000"
if ( offsetStr.endsWith( "%" ) )
offset = offsetStr.remove( offsetStr.size() - 1, 1 ).toDouble() / 100.0;
else
offset = offsetStr.toDouble();

QString colorStr = e.attribute( "stop-color", "" ); // stop-color="rgb(222,235,247)"
QString opacityStr = e.attribute( "stop-opacity", "1.0" ); // stop-opacity="1.0000"
// QColor color( 255, 0, 0 ); // red color as a warning :)
QColor color = QgsSymbolLayerV2Utils::parseColor( colorStr );
if ( color != QColor() )
{
int alpha = opacityStr.toDouble() * 255; // test
color.setAlpha( alpha );
if ( map.contains( offset ) )
mContinuous = false; // assume discrete if at least one stop is repeated
map[offset] = color;
map[offset].second = color;
else
map[offset] = qMakePair( color, color );
}
else
QgsDebugMsg( QString( "at offset=%1 invalid color" ).arg( offset ) );
}
else
{
Expand All @@ -521,18 +553,51 @@ bool QgsCptCityColorRampV2::loadFile( QString filename )
e = e.nextSiblingElement();
}

// if this is a discrete gradient, remove last stop
if ( ! mContinuous )
// add colors to palette
mPalette.clear();
QMap<double, QPair<QColor, QColor> >::const_iterator it, prev;
// first detect if file is gradient is continuous or dicrete
// discrete: stop contains 2 colors and first color is identical to previous second
// multi: stop contains 2 colors and no relation with previous stop
mGradientType = Continuous;
it = prev = map.constBegin();
while ( it != map.constEnd() )
{
if ( map.contains( 1 ) )
map.remove( 1 );
// look for stops that contain multiple values
if ( it != map.constBegin() && ( it.value().first != it.value().second ) )
{
if ( it.value().first == prev.value().second )
{
mGradientType = Discrete;
break;
}
else
{
mGradientType = ContinuousMulti;
break;
}
}
prev = it;
++it;
}
// add colors to palette
QMap<double, QColor>::const_iterator it = map.constBegin();

it = prev = map.constBegin();
while ( it != map.constEnd() )
{
mPaletteStops << it.key();
mPalette << it.value();
if ( mGradientType == Discrete )
{
mPalette << qMakePair( it.key(), it.value().second );
}
else
{
mPalette << qMakePair( it.key(), it.value().first );
if (( mGradientType == ContinuousMulti ) &&
( it.key() != 0.0 && it.key() != 1.0 ) )
{
mPalette << qMakePair( it.key(), it.value().second );
}
}
prev = it;
++it;
}

Expand Down Expand Up @@ -782,7 +847,3 @@ bool QgsCptCityColorRampV2::loadSchemes( QString rootDir, bool reset )
return ( ! mCollections.isEmpty() );
}

void QgsCptCityColorRampV2::loadPalette()
{
// TODO: IMPLEMENT ME
}
35 changes: 17 additions & 18 deletions src/core/symbology-ng/qgsvectorcolorrampv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ class CORE_EXPORT QgsCptCityColorRampV2 : public QgsVectorColorRampV2
QgsCptCityColorRampV2( QString schemeName = DEFAULT_CPTCITY_SCHEMENAME,
QString variantName = DEFAULT_CPTCITY_VARIANTNAME );


enum GradientType
{
Discrete, //discrete stops, e.g. Color Brewer
Continuous, //continuous, e.g. QgsVectorColorRampV2
ContinuousMulti //continuous with 2 values in intermediate stops
};
typedef QList< QPair < double, QColor > > GradientList;


static QgsVectorColorRampV2* create( const QgsStringMap& properties = QgsStringMap() );

virtual QColor color( double value ) const;
Expand All @@ -183,27 +193,24 @@ class CORE_EXPORT QgsCptCityColorRampV2 : public QgsVectorColorRampV2
QString schemeName() const { return mSchemeName; }
QString variantName() const { return mVariantName; }

/* void setSchemeName( QString schemeName ) { mSchemeName = schemeName; loadPalette(); } */
/* void setVariantName( QString variantName ) { mVariantName = variantName; loadPalette(); } */
/* lazy loading - have to call loadPalette() explicitly */
void setSchemeName( QString schemeName ) { mSchemeName = schemeName; }
void setVariantName( QString variantName ) { mVariantName = variantName; }
void setName( QString schemeName, QString variantName = "" )
{ mSchemeName = schemeName; mVariantName = variantName; loadPalette(); }

void loadPalette();
bool isContinuous() const { return mContinuous; }
void loadPalette() { loadFile(); }
/* bool isContinuous() const { return mContinuous; } */
GradientType gradientType() const { return mGradientType; }

QString getFilename() const;
bool loadFile( QString filename = "" );

/* static QList<QColor> listSchemeColors( QString schemeName, int colors ); */
static QList<int> listSchemeVariants( QString schemeName );

static QString getBaseDir();
static void setBaseDir( QString dirName ) { mBaseDir = dirName; }
static bool loadSchemes( QString rootDir = "", bool reset = false );
/** Is the minimal (free to distribute) set of schemes available? Currently returns hasAllSchemes, because we don't have a minimal set yet. */
/** Is the minimal (free to distribute) set of schemes available?
* Currently returns hasAllSchemes, because we don't have a minimal set yet. */
static bool hasBasicSchemes();
/** Is the entire archive available? Currently tests that there is at least one scheme. */
static bool hasAllSchemes();
Expand All @@ -213,27 +220,19 @@ class CORE_EXPORT QgsCptCityColorRampV2 : public QgsVectorColorRampV2
static QgsCptCityColorRampV2* colorRampFromSVGString( QString svgString );

static const QMap< QString, QStringList > schemeMap() { return mSchemeMap; }
/* static const QMap< QString, int > schemeNumColors() { return mSchemeNumColors; } */
static const QMap< QString, QStringList > schemeVariants() { return mSchemeVariants; }
static const QMap< QString, QString > collectionNames() { return mCollectionNames; }
static const QMap< QString, QStringList > collectionSelections() { return mCollectionSelections; }

protected:

typedef QMap<double, QColor> StopsMap;

QString mSchemeName;
QString mVariantName;
bool mContinuous;
QList< QColor > mPalette;
QList< double > mPaletteStops;
/* QMap< double, QColor > mPalette; */

GradientType mGradientType;
GradientList mPalette;
static QString mBaseDir;
static QStringList mCollections;
static QMap< QString, QStringList > mSchemeMap; //key is collection, value is schemes
/* mSchemeNumColors removed, instead read on demand */
/* static QMap< QString, int > mSchemeNumColors; //key is scheme, value is # colors (if no variants) */
static QMap< QString, QStringList > mSchemeVariants; //key is scheme, value is variants
static QMap< QString, QString > mCollectionNames; //key is name, value is description
static QMap< QString, QStringList > mCollectionSelections;
Expand Down
34 changes: 29 additions & 5 deletions src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ QgsCptCityColorRampV2Dialog::QgsCptCityColorRampV2Dialog( QgsCptCityColorRampV2*
setupUi( this );

QgsCptCityColorRampV2::loadSchemes( "" );
// QgsCptCityColorRampV2::loadSchemes( "cb" );

// show information on how to install cpt-city files if none are found
if ( ! QgsCptCityColorRampV2::hasAllSchemes() )
Expand All @@ -49,7 +48,11 @@ QgsCptCityColorRampV2Dialog::QgsCptCityColorRampV2Dialog( QgsCptCityColorRampV2*
edit->setReadOnly( true );
// not sure if we want this long string to be translated
QString helpText = tr( "Error - cpt-city gradient files not found.\n\n"
"Please download the complete collection (in svg format) "
"You have two means of installing them:\n\n"
"1) Install the \"Color Ramp Manager\" python plugin "
"(you must enable Experimental plugins in the plugin manager) "
"and use it to download latest cpt-city package.\n\n"
"2) Download the complete collection (in svg format) "
"and unzip it to your QGis settings directory [%1] .\n\n"
"This file can be found at [%2]\nand current file is [%3]"
).arg( QgsApplication::qgisSettingsDirPath()
Expand All @@ -67,6 +70,7 @@ QgsCptCityColorRampV2Dialog::QgsCptCityColorRampV2Dialog( QgsCptCityColorRampV2*
populateVariants();
cboVariantName->setCurrentIndex( cboVariantName->findData( ramp->variantName(), Qt::UserRole ) );
connect( cboVariantName, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setVariantName() ) );

updatePreview();
}

Expand Down Expand Up @@ -265,9 +269,12 @@ void QgsCptCityColorRampV2Dialog::on_treeWidget_itemExpanded( QTreeWidgetItem *
if ( ramp.loadFile() )
{
itemDesc = QString::number( ramp.count() ) + " " + tr( "colors" ) + " - ";
if ( ramp.isContinuous() )
QgsCptCityColorRampV2::GradientType type = ramp.gradientType();
if ( type == QgsCptCityColorRampV2::Continuous )
itemDesc += tr( "continuous" );
else
else if ( type == QgsCptCityColorRampV2::ContinuousMulti )
itemDesc += tr( "continuous (multi)" );
else if ( type == QgsCptCityColorRampV2::Discrete )
itemDesc += tr( "discrete" );
}
childItem->setText( 1, " " + itemDesc );
Expand Down Expand Up @@ -295,7 +302,24 @@ void QgsCptCityColorRampV2Dialog::updatePreview()
{
QSize size( 300, 40 );
mRamp->loadFile();
lblPreview->setPixmap( QgsSymbolLayerV2Utils::colorRampPreviewPixmap( mRamp, size ) );
// TODO draw checker-board/transparent background
// for transparent, add [ pixmap.fill( Qt::transparent ); ] to QgsSymbolLayerV2Utils::colorRampPreviewPixmap

QPixmap pixmap = QgsSymbolLayerV2Utils::colorRampPreviewPixmap( mRamp, size );
lblPreview->setPixmap( pixmap );

// this is for testing purposes only
// you need to install a mirror of cpt-city files in $HOME/.qgis/cpt-city-state with just the .png files
QString basefile = QgsApplication::qgisSettingsDirPath() + "/" + "cpt-city-site" + "/" + mRamp->schemeName() + mRamp->variantName() + ".png";
QFileInfo info( basefile );
QString pngfile = info.path() + "/tn/" + info.fileName();
if ( QFile::exists( pngfile ) )
{
QPixmap pixmap2( pngfile );
lblPreview2->setPixmap( pixmap2.scaled( size ) );
}
lblPreview2->setText( "" );

}

void QgsCptCityColorRampV2Dialog::setSchemeName()
Expand Down
1 change: 0 additions & 1 deletion src/gui/symbology-ng/qgscptcitycolorrampv2dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class GUI_EXPORT QgsCptCityColorRampV2Dialog : public QDialog, private Ui::QgsCp
void updatePreview();
QTreeWidgetItem* findPath( QString path );
QTreeWidgetItem * makeCollectionItem( const QString& path );
// TODO rename Scheme to something else, maybe data
void makeSchemeItem( QTreeWidgetItem *item, const QString& path, const QString& schemeName );

QgsCptCityColorRampV2* mRamp;
Expand Down
14 changes: 12 additions & 2 deletions src/ui/qgscptcitycolorrampv2dialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>807</width>
<height>503</height>
<height>736</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -211,7 +211,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
<height>10</height>
</size>
</property>
</spacer>
Expand All @@ -235,6 +235,16 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblPreview2">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
114 changes: 66 additions & 48 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<property name="iconSize">
<size>
Expand Down Expand Up @@ -567,18 +567,15 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="mDisplayPage">
<attribute name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/gis/mActionMapTips.png</normaloff>:/images/themes/gis/mActionMapTips.png</iconset>
</attribute>
<attribute name="title">
<string>Display</string>
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="textLabel3">
<property name="text">
Expand All @@ -594,36 +591,8 @@
<property name="title">
<string>Map Tip display text</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QRadioButton" name="fieldComboRadio">
<property name="text">
<string>Field</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="displayFieldComboBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="htmlRadio">
<property name="text">
<string>HTML</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="htmlMapTip">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QGridLayout" name="gridLayout_18">
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QPushButton" name="insertExpressionButton">
Expand Down Expand Up @@ -691,6 +660,55 @@
</item>
</layout>
</item>
<item row="2" column="2">
<widget class="QTextEdit" name="htmlMapTip">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="htmlRadio">
<property name="text">
<string>HTML</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="fieldComboRadio">
<property name="text">
<string>Field</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="displayFieldComboBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -721,8 +739,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>722</width>
<height>530</height>
<width>98</width>
<height>231</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -833,8 +851,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>722</width>
<height>530</height>
<width>106</width>
<height>129</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
Expand Down Expand Up @@ -926,8 +944,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>704</width>
<height>627</height>
<width>590</width>
<height>626</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_16">
Expand Down Expand Up @@ -1492,8 +1510,8 @@
<y>152</y>
</hint>
<hint type="destinationlabel">
<x>660</x>
<y>350</y>
<x>705</x>
<y>571</y>
</hint>
</hints>
</connection>
Expand All @@ -1508,8 +1526,8 @@
<y>157</y>
</hint>
<hint type="destinationlabel">
<x>306</x>
<y>361</y>
<x>606</x>
<y>571</y>
</hint>
</hints>
</connection>
Expand All @@ -1524,8 +1542,8 @@
<y>151</y>
</hint>
<hint type="destinationlabel">
<x>142</x>
<y>349</y>
<x>247</x>
<y>571</y>
</hint>
</hints>
</connection>
Expand Down
3 changes: 2 additions & 1 deletion tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ void TestQgsRasterLayer::colorRamp2()

void TestQgsRasterLayer::colorRamp3()
{
// cpt-city ramp
// cpt-city ramp, small selection available in <testdir>/cpt-city
QgsCptCityColorRampV2::setBaseDir( mTestDataDir + "cpt-city" );
QVERIFY( testColorRamp( "raster_colorRamp3",
new QgsCptCityColorRampV2( "gmt/GMT_panoply", "" ),
QgsColorRampShader::DISCRETE, 10 ) );
Expand Down
52 changes: 27 additions & 25 deletions tests/src/core/testqgsstylev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TestStyleV2: public QObject
private:

QgsStyleV2 *mStyle;
QString mTestDataDir;

bool testValidColor( QgsVectorColorRampV2 *ramp, double value, QColor expected );

Expand All @@ -58,9 +59,10 @@ class TestStyleV2: public QObject
// slots
void TestStyleV2::initTestCase()
{
// initialize with test directory so we don't mess with user's stuff
// initialize with test settings directory so we don't mess with user's stuff
QgsApplication::init( QDir::homePath() + QString( "/.qgis_test" ) );
QgsApplication::initQgis();
mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt

// output test environment
QgsApplication::showSettings();
Expand All @@ -79,6 +81,10 @@ void TestStyleV2::initTestCase()
}
mStyle = QgsStyleV2::defaultStyle();
// mStyle->clear();

// cpt-city ramp, small selection available in <testdir>/cpt-city
QgsCptCityColorRampV2::setBaseDir( mTestDataDir + "cpt-city" );
QgsCptCityColorRampV2::loadSchemes( "" );
}

void TestStyleV2::cleanupTestCase()
Expand Down Expand Up @@ -119,21 +125,17 @@ void TestStyleV2::testCreateColorRamps()
QgsVectorColorBrewerColorRampV2* cb2Ramp = new QgsVectorColorBrewerColorRampV2( "RdYlGn", 6 );
QVERIFY( mStyle->addColorRamp( "test_cb2", cb2Ramp ) == true );

// cpt-city ramp - use gradients that are free to distribute
// set base dir because we are using a test home path - change this if we distribute a minimal set with qgis
QgsCptCityColorRampV2::setBaseDir( QDir::homePath() + QString( "/.qgis/cpt-city" ) );
QgsCptCityColorRampV2::loadSchemes( "" );
if ( QgsCptCityColorRampV2::hasBasicSchemes() )
{
QgsCptCityColorRampV2* cc1Ramp = new QgsCptCityColorRampV2( "jjg/misc/temperature", "" );
QVERIFY( mStyle->addColorRamp( "test_cc1", cc1Ramp ) == true );
QgsCptCityColorRampV2* cc2Ramp = new QgsCptCityColorRampV2( "cb/div/PiYG", "_10" );
QVERIFY( mStyle->addColorRamp( "test_cc2", cc2Ramp ) == true );
}
else
{
QWARN( "cpt-city support files not found - skipping cpt-city color ramp tests" );
}
// if ( QgsCptCityColorRampV2::hasBasicSchemes() )
// {
QgsCptCityColorRampV2* cc1Ramp = new QgsCptCityColorRampV2( "jjg/misc/temperature", "" );
QVERIFY( mStyle->addColorRamp( "test_cc1", cc1Ramp ) == true );
QgsCptCityColorRampV2* cc2Ramp = new QgsCptCityColorRampV2( "cb/div/PiYG", "_10" );
QVERIFY( mStyle->addColorRamp( "test_cc2", cc2Ramp ) == true );
// }
// else
// {
// QWARN( "cpt-city support files not found - skipping cpt-city color ramp tests" );
// }
}

void TestStyleV2::testLoadColorRamps()
Expand All @@ -154,15 +156,15 @@ void TestStyleV2::testLoadColorRamps()
colorTests.insert( "test_cb2", qMakePair( 0.66, QColor( "#d9ef8b" ) ) );

// cpt-city
if ( QgsCptCityColorRampV2::hasAllSchemes() )
{
colorRampsTest << "test_cc1";
colorTests.insert( "test_cc1", qMakePair( 0.25, QColor( "#466fcf" ) ) );
colorTests.insert( "test_cc1", qMakePair( 0.66, QColor( "#dbc85b" ) ) );
colorRampsTest << "test_cc2";
colorTests.insert( "test_cc2", qMakePair( 0.25, QColor( "#de77ae" ) ) );
colorTests.insert( "test_cc2", qMakePair( 0.66, QColor( "#b8e186" ) ) );
}
// if ( QgsCptCityColorRampV2::hasAllSchemes() )
// {
colorRampsTest << "test_cc1";
colorTests.insert( "test_cc1", qMakePair( 0.25, QColor( "#466fcf" ) ) );
colorTests.insert( "test_cc1", qMakePair( 0.66, QColor( "#dbc85b" ) ) );
colorRampsTest << "test_cc2";
colorTests.insert( "test_cc2", qMakePair( 0.25, QColor( "#de77ae" ) ) );
colorTests.insert( "test_cc2", qMakePair( 0.66, QColor( "#b8e186" ) ) );
// }

foreach ( QString name, colorRampsTest )
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions tests/testdata/cpt-city/cb/COPYING.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<copying>
<authors>
<author href="http://www.personal.psu.edu/cab38/">
<name>Cynthia Brewer</name>
<org>Pennsylvania State University</org>
</author>
<author href="http://www.geography.wisc.edu/~harrower/">
<name>Mark Harrower</name>
<org>University of Wisconsin-Madison</org>
</author>
</authors>
<license>
<informal>Apache-style</informal>
<year>2002</year>
<text>
Apache-Style Software License for ColorBrewer software and ColorBrewer
Color Schemes

Version 1.1

Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania
State University. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions as source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. The end-user documentation included with the redistribution, if any,
must include the following acknowledgment:

"This product includes color specifications and designs developed by
Cynthia Brewer (http://colorbrewer.org/)."

Alternately, this acknowledgment may appear in the software
itself, if and wherever such third-party acknowledgments normally appear.

4. The name "ColorBrewer" must not be used to endorse or promote products derived
from this software without prior written permission. For written permission, please
contact Cynthia Brewer at cbrewer@psu.edu.

5. Products derived from this software may not be called "ColorBrewer", nor may "ColorBrewer"
appear in their name, without prior written permission of Cynthia Brewer.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CYNTHIA BREWER, MARK HARROWER, OR THE
PENNSYLVANIA STATE UNIVERSITY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</text>
</license>
<src>
<format>Excel spreadsheet</format>
<link href="http://colorbrewer2.org/">ColorBrewer site</link>
<link href="http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_RGB.html">
Excel spreadsheet download</link>
</src>
</copying>
11 changes: 11 additions & 0 deletions tests/testdata/cpt-city/cb/DESC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>cb</dir>
<name>Colour schemes by Cynthia Brewer</name>
<full>
Colour schemes were designed by Cynthia Brewer,
Associate Professor of Geography at the Pennsylvania
State University.
</full>
<date>01/08/2012</date>
</description>
9 changes: 9 additions & 0 deletions tests/testdata/cpt-city/cb/div/DESC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>div</dir>
<name>Diverging</name>
<full>
Diverging colour schemes designed by Cynthia Brewer
</full>
<date>01/08/2012</date>
</description>
15 changes: 15 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_03.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_04.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_05.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_06.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_07.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_08.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_09.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_10.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions tests/testdata/cpt-city/cb/div/PiYG_11.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions tests/testdata/cpt-city/gmt/COPYING.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: COPYING.xml,v 1.4 2011/11/16 20:51:07 jjg Exp $ -->
<copying>
<authors>
<author href="http://www.soest.hawaii.edu/pwessel/">
<name>Paul Wessel</name>
<org>SOEST</org>
</author>
<author href="http://www.star.nesdis.noaa.gov/star/Smith_WHF.php">
<name>Walter Smith</name>
<org>NOAA</org>
</author>
<author>
<name>Andreas Trawoeger</name>
</author>
</authors>
<license>
<informal>GPLv2</informal>
<year>2004, 2010</year>
<text href="http://www.gnu.org/licenses/gpl-2.0.html"/>
</license>
<src>
<format>GMT cpt</format>
<link href="http://gmt.soest.hawaii.edu/gmt/gmt_download.html">GMT
downloads</link>
<remark>Files included in the GMT distribution</remark>
</src>
</copying>
9 changes: 9 additions & 0 deletions tests/testdata/cpt-city/gmt/DESC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>gmt</dir>
<name>Generic Mapping Tools palettes</name>
<full>
The palettes distributed with the Generic Mapping Tools (GMT).
</full>
<date>01/08/2012</date>
</description>
41 changes: 41 additions & 0 deletions tests/testdata/cpt-city/gmt/GMT_panoply.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions tests/testdata/cpt-city/jjg/DESC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>jjg</dir>
<name>Technical gradients by J.J. Green</name>
<full>
Palettes mainly for technical illustration.
</full>
<date>01/08/2012</date>
</description>
16 changes: 16 additions & 0 deletions tests/testdata/cpt-city/jjg/misc/COPYING.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: COPYING.xml,v 1.1 2010/01/05 18:51:51 jjg Exp $ -->
<copying>
<authors>
<author href="http://soliton.vm.bytemark.co.uk/pub/jjg/">
<name>J.J. Green</name>
</author>
</authors>
<license>
<informal>Public domain</informal>
<year>2004</year>
</license>
<src>
<format>GMT colour palette (cpt)</format>
</src>
</copying>
9 changes: 9 additions & 0 deletions tests/testdata/cpt-city/jjg/misc/DESC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<description>
<dir>misc</dir>
<name>Miscellany</name>
<full>
Miscellaneous gradients.
</full>
<date>01/08/2012</date>
</description>
55 changes: 55 additions & 0 deletions tests/testdata/cpt-city/jjg/misc/temperature.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.