Skip to content
Permalink
Browse files

Embedded symbol selector directly to the renderer properties dialog f…

…or single symbol renderer.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11159 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 23, 2009
1 parent cac0f15 commit 019e73f89d81c261305a9e69c4eed0a48ac58476
@@ -72,7 +72,7 @@ class QgsSymbolV2SelectorDialog : QDialog //, private Ui::QgsSymbolV2SelectorDia
%End

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

protected:
void populateSymbolView();
@@ -89,4 +89,7 @@ public slots:
void setMarkerSize(double size);
void setLineWidth(double width);

signals:
void symbolModified();

};
@@ -47,10 +47,17 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* lay
connect(radCategorized, SIGNAL(clicked()), this, SLOT(updateRenderer()));
connect(radGraduated, SIGNAL(clicked()), this, SLOT(updateRenderer()));

//connect(btnSymbolLevels, SIGNAL(clicked()), this, SLOT(setSymbolLevels()));

// simple symbol page
connect(btnChangeSingleSymbol, SIGNAL(clicked()), this, SLOT(changeSingleSymbol()));
if (mRenderer->type() == QgsFeatureRendererV2::RendererSingleSymbol)
mSingleSymbol = ((QgsSingleSymbolRendererV2*)mRenderer)->symbol()->clone();
else
mSingleSymbol = QgsSymbolV2::defaultSymbol(mLayer->geometryType());

stackedWidget->removeWidget(pageSingleSymbol);
delete pageSingleSymbol;
pageSingleSymbol = new QgsSymbolV2SelectorDialog(mSingleSymbol, mStyle, NULL, true);
stackedWidget->addWidget( pageSingleSymbol );
connect(pageSingleSymbol, SIGNAL(symbolModified()), this, SLOT(changeSingleSymbol()));

// categorized symbol page

@@ -95,6 +102,9 @@ QgsRendererV2PropertiesDialog::~QgsRendererV2PropertiesDialog()
{
// delete the temporary renderer (if exists)
delete mRenderer;

delete mSingleSymbol;
// TODO: delete categorized, graduated symbol?
}

void QgsRendererV2PropertiesDialog::apply()
@@ -129,26 +139,16 @@ QgsGraduatedSymbolRendererV2* QgsRendererV2PropertiesDialog::rendererGraduated()

void QgsRendererV2PropertiesDialog::changeSingleSymbol()
{

QgsSymbolV2SelectorDialog dlg(rendererSingle()->symbol(), mStyle, this);
if (!dlg.exec())
return;

updateSingleSymbolIcon();
}

void QgsRendererV2PropertiesDialog::updateSingleSymbolIcon()
{
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon(rendererSingle()->symbol(), btnChangeSingleSymbol->iconSize());
btnChangeSingleSymbol->setIcon(icon);
// update symbol from the GUI
rendererSingle()->setSymbol( mSingleSymbol->clone() );
}

void QgsRendererV2PropertiesDialog::updateRenderer()
{
delete mRenderer;

if (radSingleSymbol->isChecked())
mRenderer = new QgsSingleSymbolRendererV2( QgsSymbolV2::defaultSymbol(mLayer->geometryType()) );
mRenderer = new QgsSingleSymbolRendererV2( mSingleSymbol->clone() );
else if (radCategorized->isChecked())
mRenderer = new QgsCategorizedSymbolRendererV2(-1, QgsCategoryList());
else if (radGraduated->isChecked())
@@ -167,7 +167,7 @@ void QgsRendererV2PropertiesDialog::updateUiFromRenderer()
radSingleSymbol->setChecked(true);

stackedWidget->setCurrentWidget(pageSingleSymbol);
updateSingleSymbolIcon();
//updateSingleSymbolIcon();
break;

case QgsFeatureRendererV2::RendererCategorizedSymbol:
@@ -46,7 +46,6 @@ public slots:
//! update UI to reflect changes in renderer
void updateUiFromRenderer();

void updateSingleSymbolIcon();
void updateCategorizedSymbolIcon();
void updateGraduatedSymbolIcon();

@@ -82,6 +81,7 @@ public slots:

QgsStyleV2* mStyle;

QgsSymbolV2* mSingleSymbol;
QgsSymbolV2* mGraduatedSymbol;
QgsSymbolV2* mCategorizedSymbol;
};
@@ -11,13 +11,19 @@
#include <QPainter>
#include <QStandardItemModel>

QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent)
QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent)
{
mStyle = style;
mSymbol = symbol;

setupUi(this);

// can be embedded in renderer properties dialog
if (embedded)
{
buttonBox->hide();
}

connect(btnSymbolProperties, SIGNAL(clicked()), this, SLOT(changeSymbolProperties()));

@@ -91,6 +97,7 @@ void QgsSymbolV2SelectorDialog::setSymbolFromStyle(const QModelIndex & index)

updateSymbolPreview();
updateSymbolInfo();
emit symbolModified();
}

void QgsSymbolV2SelectorDialog::updateSymbolPreview()
@@ -131,6 +138,7 @@ void QgsSymbolV2SelectorDialog::changeSymbolProperties()

updateSymbolPreview();
updateSymbolInfo();
emit symbolModified();
}


@@ -143,6 +151,7 @@ void QgsSymbolV2SelectorDialog::setSymbolColor()
mSymbol->setColor(color);
updateSymbolColor();
updateSymbolPreview();
emit symbolModified();
}

void QgsSymbolV2SelectorDialog::setMarkerAngle(double angle)
@@ -152,6 +161,7 @@ void QgsSymbolV2SelectorDialog::setMarkerAngle(double angle)
return;
markerSymbol->setAngle(angle);
updateSymbolPreview();
emit symbolModified();
}

void QgsSymbolV2SelectorDialog::setMarkerSize(double size)
@@ -161,6 +171,7 @@ void QgsSymbolV2SelectorDialog::setMarkerSize(double size)
return;
markerSymbol->setSize(size);
updateSymbolPreview();
emit symbolModified();
}

void QgsSymbolV2SelectorDialog::setLineWidth(double width)
@@ -170,4 +181,5 @@ void QgsSymbolV2SelectorDialog::setLineWidth(double width)
return;
lineSymbol->setWidth(width);
updateSymbolPreview();
emit symbolModified();
}
@@ -14,7 +14,7 @@ class QgsSymbolV2SelectorDialog : public QDialog, private Ui::QgsSymbolV2Selecto
Q_OBJECT

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

protected:
void populateSymbolView();
@@ -31,6 +31,9 @@ public slots:
void setMarkerSize(double size);
void setLineWidth(double width);

signals:
void symbolModified();

protected:
QgsStyleV2* mStyle;
QgsSymbolV2* mSymbol;

0 comments on commit 019e73f

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