Skip to content
Permalink
Browse files

[FEATURE] Reworked symbol selector/properties dialog, greatly improve…

…d style manager

This is merge of Arun's GSoC 2012 work.

Merge remote-tracking branch 'arun/gsoc'

Conflicts:
	src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
  • Loading branch information
wonder-sk committed Aug 14, 2012
2 parents da5609c + d2f08ee commit 21253f99e9a5075658320b5c1efc5240241c6c5e
Showing with 5,038 additions and 1,941 deletions.
  1. +1 −1 python/core/symbology-ng-core.sip
  2. +25 −46 python/gui/symbology-ng-gui.sip
  3. +1 −1 resources/CMakeLists.txt
  4. BIN resources/symbology-ng-style.db
  5. +105 −0 scripts/symbol_xml2db.py
  6. +2 −3 src/app/qgsdecorationgriddialog.cpp
  7. +2 −2 src/core/qgsapplication.cpp
  8. +26 −0 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  9. +3 −0 src/core/symbology-ng/qgsmarkersymbollayerv2.h
  10. +1,087 −45 src/core/symbology-ng/qgsstylev2.cpp
  11. +102 −0 src/core/symbology-ng/qgsstylev2.h
  12. +20 −17 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  13. +1 −1 src/core/symbology-ng/qgssymbollayerv2utils.h
  14. +6 −2 src/gui/CMakeLists.txt
  15. +189 −0 src/gui/symbology-ng/qgslayerpropertieswidget.cpp
  16. +59 −0 src/gui/symbology-ng/qgslayerpropertieswidget.h
  17. +208 −0 src/gui/symbology-ng/qgssmartgroupeditordialog.cpp
  18. +114 −0 src/gui/symbology-ng/qgssmartgroupeditordialog.h
  19. +230 −17 src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp
  20. +21 −1 src/gui/symbology-ng/qgsstylev2exportimportdialog.h
  21. +723 −45 src/gui/symbology-ng/qgsstylev2managerdialog.cpp
  22. +63 −3 src/gui/symbology-ng/qgsstylev2managerdialog.h
  23. +112 −70 src/gui/symbology-ng/qgssymbollayerv2widget.cpp
  24. +2 −10 src/gui/symbology-ng/qgssymbollayerv2widget.h
  25. +350 −0 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  26. +70 −0 src/gui/symbology-ng/qgssymbolslistwidget.h
  27. +0 −458 src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
  28. +0 −86 src/gui/symbology-ng/qgssymbolv2propertiesdialog.h
  29. +387 −207 src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
  30. +45 −21 src/gui/symbology-ng/qgssymbolv2selectordialog.h
  31. +1 −28 src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp
  32. +0 −2 src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.h
  33. +74 −0 src/ui/qgssmartgroupconditionwidget.ui
  34. +82 −0 src/ui/qgssmartgroupeditordialogbase.ui
  35. +50 −5 src/ui/qgsstylev2exportimportdialogbase.ui
  36. +161 −60 src/ui/qgsstylev2managerdialogbase.ui
  37. +0 −278 src/ui/qgssymbolv2propertiesdialogbase.ui
  38. +67 −309 src/ui/qgssymbolv2selectordialogbase.ui
  39. +1 −24 src/ui/symbollayer/widget_centroidfill.ui
  40. +5 −2 src/ui/symbollayer/widget_ellipse.ui
  41. +3 −0 src/ui/symbollayer/widget_fontmarker.ui
  42. +66 −0 src/ui/symbollayer/widget_layerproperties.ui
  43. +4 −1 src/ui/symbollayer/widget_linedecoration.ui
  44. +5 −2 src/ui/symbollayer/widget_linepatternfill.ui
  45. +16 −44 src/ui/symbollayer/widget_markerline.ui
  46. +29 −43 src/ui/symbollayer/widget_pointpatternfill.ui
  47. +4 −1 src/ui/symbollayer/widget_simplefill.ui
  48. +4 −1 src/ui/symbollayer/widget_simpleline.ui
  49. +3 −0 src/ui/symbollayer/widget_simplemarker.ui
  50. +41 −17 src/ui/symbollayer/widget_svgfill.ui
  51. +17 −4 src/ui/symbollayer/widget_svgmarker.ui
  52. +360 −0 src/ui/symbollayer/widget_symbolslist.ui
  53. +91 −84 src/ui/symbollayer/widget_vectorfield.ui
@@ -1265,7 +1265,7 @@ class QgsSymbolLayerV2Utils

static QgsSymbolV2* loadSymbol( QDomElement& element ) /Factory/;
static QgsSymbolLayerV2* loadSymbolLayer( QDomElement& element ) /Factory/;
static QDomElement saveSymbol( QString name, QgsSymbolV2* symbol, QDomDocument& doc, QgsSymbolV2Map* subSymbols = NULL );
static QDomElement saveSymbol( QString name, QgsSymbolV2* symbol, QDomDocument& doc );

static QgsStringMap parseProperties( QDomElement& element );
static void saveProperties( QgsStringMap props, QDomDocument& doc, QDomElement& element );
@@ -1,31 +1,4 @@


class QgsSymbolV2PropertiesDialog : QDialog //, private Ui::DlgSymbolV2Properties
{
%TypeHeaderCode
#include <qgssymbolv2propertiesdialog.h>
%End

public:
QgsSymbolV2PropertiesDialog(QgsSymbolV2* symbol, const QgsVectorLayer* vl, QWidget* parent = NULL);


public slots:
void moveLayerDown();
void moveLayerUp();

void addLayer();
void removeLayer();

void lockLayer();

void layerTypeChanged();

void layerChanged();

};


class QgsRendererV2PropertiesDialog : QDialog //, private Ui::QgsRendererV2PropsDialogBase
{
%TypeHeaderCode
@@ -71,27 +44,33 @@ class QgsSymbolV2SelectorDialog : QDialog //, private Ui::QgsSymbolV2SelectorDia
%TypeHeaderCode
#include <qgssymbolv2selectordialog.h>
%End
public:
QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = NULL, bool embedded = false );

public:
QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent = NULL, bool embedded = false);

protected:
void populateSymbolView();
void updateSymbolPreview();
void updateSymbolColor();
void updateSymbolInfo();

QMenu* advancedMenu();

public slots:
void changeSymbolProperties();
void setSymbolFromStyle(const QModelIndex & index);
void setSymbolColor();
void setMarkerAngle(double angle);
void setMarkerSize(double size);
void setLineWidth(double width);

signals:
void symbolModified();
protected:
void keyPressEvent( QKeyEvent * event );

void loadSymbol();
void updateUi();
void updateLockButton();
QgsSymbolLayerV2* currentLayer();
void moveLayerByOffset( int offset );
void setWidget( QWidget* widget );

signals:
void symbolModified();

public slots:
void moveLayerDown();
void moveLayerUp();
void addLayer();
void removeLayer();
void lockLayer();
void layerChanged();
void updateLayerPreview();
void updatePreview();

};

@@ -1,4 +1,4 @@
INSTALL(FILES srs.db qgis.db qgis_help.db symbology-ng-style.xml spatialite.db customization.xml
INSTALL(FILES srs.db qgis.db qgis_help.db symbology-ng-style.db spatialite.db customization.xml
DESTINATION ${QGIS_DATA_DIR}/resources)

ADD_SUBDIRECTORY(context_help)
Binary file not shown.
@@ -0,0 +1,105 @@
#!/usr/bin/python
"""
/***************************************************************************
symbol_xml2db.py
-------------------
begin : 26-5-2012
copyright : (C) 2012 by Arunmozhi
email : aruntheguy at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
The script creates a sqlite3 Db for storing the symbols which will be
shipped with QGIS by default. It then converts symbols and colorramps
in the symbology_ng_style.xml to the database table entries.
"""
import sqlite3

from xml.dom.minidom import parse, parseString

xmlfile = "../resources/symbology-ng-style.xml"
dbfile = "../resources/symbology-ng-style.db"

_symbol = "CREATE TABLE symbol("\
"id INTEGER PRIMARY KEY,"\
"name TEXT UNIQUE,"\
"xml TEXT,"\
"groupid INTEGER)"

_colorramp = "CREATE TABLE colorramp("\
"id INTEGER PRIMARY KEY,"\
"name TEXT,"\
"xml TEXT,"\
"groupid INTEGER)"

_tag = "CREATE TABLE tag("\
"id INTEGER PRIMARY KEY,"\
"name TEXT)"

_tagmap = "CREATE TABLE tagmap("\
"tag_id INTEGER NOT NULL,"\
"symbol_id INTEGER)"

_symgroup = "CREATE TABLE symgroup("\
"id INTEGER PRIMARY KEY,"\
"name TEXT,"\
"parent INTEGER)"

_smartgroup = "CREATE TABLE smartgroup("\
"id INTEGER PRIMARY KEY,"\
"name TEXT,"\
"xml TEXT)"

_ctagmap = "CREATE TABLE ctagmap("\
"tag_id INTEGER NOT NULL,"\
"colorramp_id INTEGER)"

create_tables = [ _symbol, _colorramp, _tag, _tagmap, _ctagmap, _symgroup, _smartgroup ]

# Create the DB with required Schema
conn = sqlite3.connect( dbfile )
c = conn.cursor()
print "Creating tables in the Database\n"
for table in create_tables:
try:
c.execute( table )
print table
except sqlite3.OperationalError as e:
pass
conn.commit()

# parse the XML file & write symbol into DB
dom = parse( xmlfile )
symbols = dom.getElementsByTagName( "symbol" )
for symbol in symbols:
symbol_name = symbol.getAttribute( "name" )
if '@' in symbol_name:
parts = symbol_name.split('@')
parent_name = parts[1]
layerno = int(parts[2])
c.execute( "SELECT xml FROM symbol WHERE name=(?)", (parent_name,) )
symdom = parseString( c.fetchone()[0] ).getElementsByTagName( 'symbol' )[0]
symdom.getElementsByTagName( "layer" )[ layerno ].appendChild( symbol )
c.execute( "UPDATE symbol SET xml=? WHERE name=?", ( symdom.toxml(), parent_name ))
else:
c.execute( "INSERT INTO symbol VALUES (?,?,?,?)", ( None, symbol_name, symbol.toxml(), None ) )
conn.commit()


# ColorRamps
colorramps = dom.getElementsByTagName( "colorramp" )
for ramp in colorramps:
ramp_name = ramp.getAttribute( "name" )
c.execute( "INSERT INTO colorramp VALUES (?,?,?,?)", ( None, ramp_name, ramp.toxml(), None ) )
conn.commit()

# Finally close the sqlite cursor
c.close()
@@ -24,7 +24,6 @@
#include "qgsstylev2.h"
#include "qgssymbolv2.h"
#include "qgssymbolv2selectordialog.h"
#include "qgssymbolv2propertiesdialog.h"
#include "qgisapp.h"

#include <QFontDialog>
@@ -212,7 +211,7 @@ void QgsDecorationGridDialog::on_mLineSymbolButton_clicked()
return;

QgsLineSymbolV2* lineSymbol = dynamic_cast<QgsLineSymbolV2*>( mLineSymbol->clone() );
QgsSymbolV2PropertiesDialog dlg( lineSymbol, 0, this );
QgsSymbolV2SelectorDialog dlg( lineSymbol, QgsStyleV2::defaultStyle(), 0, this );
if ( dlg.exec() == QDialog::Rejected )
{
delete lineSymbol;
@@ -235,7 +234,7 @@ void QgsDecorationGridDialog::on_mMarkerSymbolButton_clicked()
return;

QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mMarkerSymbol->clone() );
QgsSymbolV2PropertiesDialog dlg( markerSymbol, 0, this );
QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), 0, this );
if ( dlg.exec() == QDialog::Rejected )
{
delete markerSymbol;
@@ -557,12 +557,12 @@ const QString QgsApplication::svgPath()

const QString QgsApplication::userStyleV2Path()
{
return qgisSettingsDirPath() + QString( "symbology-ng-style.xml" );
return qgisSettingsDirPath() + QString( "symbology-ng-style.db" );
}

const QString QgsApplication::defaultStyleV2Path()
{
return ABISYM( mPkgDataPath ) + QString( "/resources/symbology-ng-style.xml" );
return ABISYM( mPkgDataPath ) + QString( "/resources/symbology-ng-style.db" );
}

const QString QgsApplication::libraryPath()
@@ -794,6 +794,32 @@ QStringList QgsSvgMarkerSymbolLayerV2::listSvgFiles()
return list;
}

// Stripped down version of listSvgFiles() for specified directory
QStringList QgsSvgMarkerSymbolLayerV2::listSvgFilesAt( QString directory )
{
// TODO anything that applies for the listSvgFiles() applies this also

QStringList list;
QStringList svgPaths;
svgPaths.append( directory );

for ( int i = 0; i < svgPaths.size(); i++ )
{
QDir dir( svgPaths[i] );
foreach( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
{
svgPaths.insert( i + 1, dir.path() + "/" + item );
}

foreach( QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) )
{
list.append( dir.path() + "/" + item );
}
}
return list;

}

QString QgsSvgMarkerSymbolLayerV2::symbolNameToPath( QString name )
{
// copied from QgsSymbol::setNamedPointSymbol - TODO: unify
@@ -109,6 +109,9 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
//! Return a list of all available svg files
static QStringList listSvgFiles();

//! Return a list of svg files at the specified directory
static QStringList listSvgFilesAt( QString directory );

//! Get symbol's path from its name
static QString symbolNameToPath( QString name );

0 comments on commit 21253f9

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