Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option for custom dash-space pattern in simple line symbollayer
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12788 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
mhugent
committed
Jan 18, 2010
1 parent
2405eb8
commit bde0672
Showing
11 changed files
with
438 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/*************************************************************************** | ||
qgsdashspacedialog.cpp | ||
---------------------- | ||
begin : January 2010 | ||
copyright : (C) 2010 by Marco Hugentobler | ||
email : marco at hugis dot net | ||
*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsdashspacedialog.h" | ||
#include "qgsapplication.h" | ||
#include <QFile> | ||
|
||
QString iconPath( QString iconFile ) | ||
{ | ||
// try active theme | ||
QString path = QgsApplication::activeThemePath(); | ||
if ( QFile::exists( path + iconFile ) ) | ||
return path + iconFile; | ||
|
||
// use default theme | ||
return QgsApplication::defaultThemePath() + iconFile; | ||
} | ||
|
||
QgsDashSpaceDialog::QgsDashSpaceDialog( const QVector<qreal>& v, QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f ) | ||
{ | ||
setupUi( this ); | ||
|
||
mAddButton->setIcon( QIcon( iconPath( "symbologyAdd.png" ) ) ); | ||
mRemoveButton->setIcon( QIcon( iconPath( "symbologyRemove.png" ) ) ); | ||
|
||
double dash = 0; | ||
double space = 0; | ||
for ( int i = 0; i < ( v.size() - 1 ); ++i ) | ||
{ | ||
dash = v.at( i ); | ||
++i; | ||
space = v.at( i ); | ||
QTreeWidgetItem* entry = new QTreeWidgetItem(); | ||
entry->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ); | ||
entry->setText( 0, QString::number( dash ) ); | ||
entry->setText( 1, QString::number( space ) ); | ||
mDashSpaceTreeWidget->addTopLevelItem( entry ); | ||
} | ||
} | ||
|
||
QgsDashSpaceDialog::~QgsDashSpaceDialog() | ||
{ | ||
|
||
} | ||
|
||
void QgsDashSpaceDialog::on_mAddButton_clicked() | ||
{ | ||
//add new (default) item | ||
QTreeWidgetItem* entry = new QTreeWidgetItem(); | ||
entry->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ); | ||
entry->setText( 0, "5" ); | ||
entry->setText( 1, "2" ); | ||
mDashSpaceTreeWidget->addTopLevelItem( entry ); | ||
} | ||
|
||
void QgsDashSpaceDialog::on_mRemoveButton_clicked() | ||
{ | ||
//get active item | ||
QTreeWidgetItem* currentItem = mDashSpaceTreeWidget->currentItem(); | ||
if ( currentItem ) | ||
{ | ||
mDashSpaceTreeWidget->takeTopLevelItem( mDashSpaceTreeWidget->indexOfTopLevelItem( currentItem ) ); | ||
} | ||
} | ||
|
||
QVector<qreal> QgsDashSpaceDialog::dashDotVector() const | ||
{ | ||
QVector<qreal> dashVector; | ||
int nTopLevelItems = mDashSpaceTreeWidget->topLevelItemCount(); | ||
for ( int i = 0; i < nTopLevelItems; ++i ) | ||
{ | ||
QTreeWidgetItem* currentItem = mDashSpaceTreeWidget->topLevelItem( i ); | ||
if ( currentItem ) | ||
{ | ||
dashVector << currentItem->text( 0 ).toDouble() << currentItem->text( 1 ).toDouble(); | ||
} | ||
} | ||
return dashVector; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*************************************************************************** | ||
qgsdashspacedialog.h | ||
--------------------- | ||
begin : January 2010 | ||
copyright : (C) 2010 by Marco Hugentobler | ||
email : marco at hugis dot net | ||
*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSDASHSPACEDIALOG_H | ||
#define QGSDASHSPACEDIALOG_H | ||
|
||
#include "ui_qgsdashspacedialogbase.h" | ||
|
||
/**A dialog to enter a custom dash space pattern for lines*/ | ||
class QgsDashSpaceDialog: public QDialog, private Ui::QgsDashSpaceDialogBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsDashSpaceDialog( const QVector<qreal>& v, QWidget * parent = 0, Qt::WindowFlags f = 0 ); | ||
~QgsDashSpaceDialog(); | ||
|
||
QVector<qreal> dashDotVector() const; | ||
|
||
private slots: | ||
void on_mAddButton_clicked(); | ||
void on_mRemoveButton_clicked(); | ||
}; | ||
|
||
#endif // QGSDASHSPACEDIALOG_H |
Oops, something went wrong.