Skip to content
Permalink
Browse files

Added a checkbox to options dialog to enable/disable symbology-ng

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11157 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 23, 2009
1 parent b075404 commit f808b53cb07c517d42cee7436c737ff63c8aca82
@@ -41,6 +41,9 @@ public:
// TODO: user type?
};

//! return a new renderer - used by default in vector layers
static QgsFeatureRendererV2* defaultRenderer(QGis::GeometryType geomType) /Factory/;

RendererType type() const;

virtual QgsSymbolV2* symbolForFeature(QgsFeature& feature)=0;
@@ -397,6 +400,9 @@ public:

virtual ~QgsSymbolV2();

//! return new default symbol for specified geometry type
static QgsSymbolV2* defaultSymbol(QGis::GeometryType geomType) /Factory/;

SymbolType type() const;

// symbol layers handling
@@ -132,6 +132,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
//set the state of the checkboxes
chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", false ).toBool() );

chkUseSymbologyNG->setChecked( settings.value( "/qgis/use_symbology_ng", false ).toBool() );

// Slightly awkard here at the settings value is true to use QImage,
// but the checkbox is true to use QPixmap
chkUseQPixmap->setChecked( !( settings.value( "/qgis/use_qimage_to_render", true ).toBool() ) );
@@ -342,6 +344,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/new_layers_visible", chkAddedVisibility->isChecked() );
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
settings.setValue( "/qgis/use_qimage_to_render", !( chkUseQPixmap->isChecked() ) );
settings.setValue( "/qgis/use_symbology_ng", chkUseSymbologyNG->isChecked() );
settings.setValue( "qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() );
settings.setValue( "qgis/askToSaveProjectChanges", chbAskToSaveProjectChanges->isChecked() );
settings.setValue( "qgis/warnOldProjectVersion", chbWarnOldProjectVersion->isChecked() );
@@ -123,24 +123,31 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
}
if ( mValid )
{
setCoordinateSystem();

// check if there is a default style / propertysheet defined
// for this layer and if so apply it
//
if ( loadDefaultStyleFlag )
QSettings settings;
if ( settings.value( "/qgis/use_symbology_ng", false ).toBool() )
{
// using symbology-ng!
setUsingRendererV2(true);
setRendererV2( QgsFeatureRendererV2::defaultRenderer( geometryType() ) );
}
else if ( loadDefaultStyleFlag )
{
bool defaultLoadedFlag = false;
loadDefaultStyle( defaultLoadedFlag );
if ( !defaultLoadedFlag )
{
setCoordinateSystem();
// add single symbol renderer as default
QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer( geometryType() );
setRenderer( renderer );
}
}
else // Otherwise use some very basic defaults
{
setCoordinateSystem();
// add single symbol renderer as default
QgsSingleSymbolRenderer *renderer = new QgsSingleSymbolRenderer( geometryType() );
setRenderer( renderer );
@@ -2468,6 +2475,9 @@ bool QgsVectorLayer::writeXml( QDomNode & layer_node,

bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage )
{
// TODO: load symbology-ng renderers
setUsingRendererV2(false);

// process the attribute actions
mActions->readXML( node );

@@ -115,6 +115,11 @@ QgsFeatureRendererV2::QgsFeatureRendererV2(RendererType type)
{
}

QgsFeatureRendererV2* QgsFeatureRendererV2::defaultRenderer(QGis::GeometryType geomType)
{
return new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol(geomType) );
}


void QgsFeatureRendererV2::renderFeature(QgsFeature& feature, QgsRenderContext& context, int layer)
{
@@ -2,6 +2,8 @@
#ifndef QGSRENDERERV2_H
#define QGSRENDERERV2_H

#include "qgis.h"

#include <QList>
#include <QHash>
#include <QString>
@@ -49,6 +51,9 @@ class QgsFeatureRendererV2
RendererGraduatedSymbol
// TODO: user type?
};

//! return a new renderer - used by default in vector layers
static QgsFeatureRendererV2* defaultRenderer(QGis::GeometryType geomType);

RendererType type() const { return mType; }

@@ -6,6 +6,7 @@
#include "qgsmarkersymbollayerv2.h"
#include "qgsfillsymbollayerv2.h"

#include "qgslogger.h"
#include "qgsrendercontext.h" // for bigSymbolPreview

#include <QColor>
@@ -40,6 +41,17 @@ QgsSymbolV2::~QgsSymbolV2()
delete *it;
}

QgsSymbolV2* QgsSymbolV2::defaultSymbol(QGis::GeometryType geomType)
{
switch (geomType)
{
case QGis::Point: return new QgsMarkerSymbolV2();
case QGis::Line: return new QgsLineSymbolV2();
case QGis::Polygon: return new QgsFillSymbolV2();
default: QgsDebugMsg("unknown layer's geometry type"); return NULL;
}
}


QgsSymbolLayerV2* QgsSymbolV2::symbolLayer(int layer)
{
@@ -2,6 +2,7 @@
#ifndef QGSSYMBOLV2_H
#define QGSSYMBOLV2_H

#include "qgis.h"
#include <QList>

class QColor;
@@ -30,6 +31,9 @@ class QgsSymbolV2

virtual ~QgsSymbolV2();

//! return new default symbol for specified geometry type
static QgsSymbolV2* defaultSymbol(QGis::GeometryType geomType);

SymbolType type() const { return mType; }

// symbol layers handling
@@ -25,7 +25,7 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* lay
// if the layer doesn't use renderer V2, let's start using it!
if (!mLayer->isUsingRendererV2())
{
mLayer->setRendererV2(new QgsSingleSymbolRendererV2( createDefaultSymbol() ));
mLayer->setRendererV2( QgsFeatureRendererV2::defaultRenderer(mLayer->geometryType()) );
mLayer->setUsingRendererV2(true);
}

@@ -61,7 +61,7 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* lay
m->setHorizontalHeaderLabels(labels);
viewCategories->setModel(m);

mCategorizedSymbol = createDefaultSymbol();
mCategorizedSymbol = QgsSymbolV2::defaultSymbol(mLayer->geometryType());

connect(cboCategorizedColumn, SIGNAL(currentIndexChanged(int)), this, SLOT(categoryColumnChanged()));

@@ -80,7 +80,7 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* lay
mg->setHorizontalHeaderLabels(labels);
viewGraduated->setModel(mg);

mGraduatedSymbol = createDefaultSymbol();
mGraduatedSymbol = QgsSymbolV2::defaultSymbol(mLayer->geometryType());

connect(viewGraduated, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(rangesDoubleClicked(const QModelIndex &)));

@@ -148,7 +148,7 @@ void QgsRendererV2PropertiesDialog::updateRenderer()
delete mRenderer;

if (radSingleSymbol->isChecked())
mRenderer = new QgsSingleSymbolRendererV2( createDefaultSymbol() );
mRenderer = new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol(mLayer->geometryType()) );
else if (radCategorized->isChecked())
mRenderer = new QgsCategorizedSymbolRendererV2(-1, QgsCategoryList());
else if (radGraduated->isChecked())
@@ -221,17 +221,6 @@ void QgsRendererV2PropertiesDialog::updateUiFromRenderer()
}


QgsSymbolV2* QgsRendererV2PropertiesDialog::createDefaultSymbol()
{
switch (mLayer->geometryType())
{
case QGis::Point: return new QgsMarkerSymbolV2();
case QGis::Line: return new QgsLineSymbolV2();
case QGis::Polygon: return new QgsFillSymbolV2();
default: QgsDebugMsg("unknown layer's geometry type"); return NULL;
}
}

void QgsRendererV2PropertiesDialog::changeCategorizedSymbol()
{
QgsSymbolV2SelectorDialog dlg(mCategorizedSymbol, mStyle, this);
@@ -50,9 +50,6 @@ public slots:
void updateCategorizedSymbolIcon();
void updateGraduatedSymbolIcon();

//! create default symbol for the layer's geometry type (point/line/polygon)
QgsSymbolV2* createDefaultSymbol();

//! populate categories view
void populateCategories();

0 comments on commit f808b53

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