Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renamed QgsMarkerCatalogue::pixmapMarker() to imageMarker() as now it…
… returns QImage.

Added Python wrappers for QgsSymbologyUtils and QgsMarkerCatalogue.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6866 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 2, 2007
1 parent 961da91 commit d4bac97
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 8 deletions.
2 changes: 2 additions & 0 deletions python/core/core.sip
Expand Up @@ -28,6 +28,7 @@
%Include qgsmaplayerregistry.sip
%Include qgsmaprender.sip
%Include qgsmaptopixel.sip
%Include qgsmarkercatalogue.sip
%Include qgsmessageoutput.sip
%Include qgspoint.sip
%Include qgsproject.sip
Expand All @@ -45,6 +46,7 @@
%Include qgsspatialindex.sip
%Include qgsspatialrefsys.sip
%Include qgssymbol.sip
%Include qgssymbologyutils.sip
%Include qgsuniquevaluerenderer.sip
%Include qgsvectordataprovider.sip
%Include qgsvectorlayer.sip
Expand Down
33 changes: 33 additions & 0 deletions python/core/qgsmarkercatalogue.sip
@@ -0,0 +1,33 @@

/** Catalogue of point symbols */
class QgsMarkerCatalogue /NoDefaultCtors/
{
%TypeHeaderCode
#include <qgsmarkercatalogue.h>
%End

public:
//! Destructor
~QgsMarkerCatalogue();

//! Access to canonical QgsMarkerCatalogue instance
static QgsMarkerCatalogue *instance();

/**List of available markers*/
QStringList list();

/** Returns pixmap of the marker
* \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg
*/
QImage imageMarker (QString fullName, int size, QPen pen, QBrush brush, bool qtBug = true );

/** Returns qpicture of the marker
* \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg
*/
QPicture pictureMarker (QString fullName, int size, QPen pen, QBrush brush, bool qtBug = true );

/** Returns a pixmap given a filename of a svg marker
* NOTE: this method needs to be public static for QgsMarkerDialog::visualizeMarkers */
static void svgMarker (QPainter * thepPainter, QString name, int size );
};

24 changes: 24 additions & 0 deletions python/core/qgssymbologyutils.sip
@@ -0,0 +1,24 @@

/**Namespace containing static methods which are useful for the symbology widgets*/
namespace QgsSymbologyUtils
{
%TypeHeaderCode
#include <qgssymbologyutils.h>
%End

QPixmap qString2LinePixmap(QString string);
QPixmap char2LinePixmap(const char* c);
QPixmap qString2PatternPixmap(QString string);
QPixmap char2PatternPixmap(const char* c);
QString penStyle2QString(Qt::PenStyle penstyle);
const char* penStyle2Char(Qt::PenStyle penstyle);
QPixmap penStyle2Pixmap(Qt::PenStyle penstyle);
Qt::PenStyle qString2PenStyle(QString string);
Qt::PenStyle char2PenStyle(const char* c);
QString brushStyle2QString(Qt::BrushStyle brushstyle);
const char* brushStyle2Char(Qt::BrushStyle brushstyle);
QPixmap brushStyle2Pixmap(Qt::BrushStyle brushstyle);
Qt::BrushStyle qString2BrushStyle(QString string);
Qt::BrushStyle char2BrushStyle(const char* c);
};

2 changes: 1 addition & 1 deletion src/app/qgssinglesymboldialog.cpp
Expand Up @@ -64,7 +64,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer): QDialog(),
for ( QStringList::iterator it = ml.begin(); it != ml.end(); ++it )
{
mMarkers.push_back ( *it );
QPixmap pic = QPixmap::fromImage(QgsMarkerCatalogue::instance()->pixmapMarker ( *it, size, pen, brush ));
QPixmap pic = QPixmap::fromImage(QgsMarkerCatalogue::instance()->imageMarker ( *it, size, pen, brush ));
mPointSymbolComboBox->insertItem ( pic );
if (layer->vectorType() != QGis::Point)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer/qgscontinuouscolorrenderer.cpp
Expand Up @@ -135,7 +135,7 @@ void QgsContinuousColorRenderer::renderFeature(QPainter * p, QgsFeature & f, QIm
}
brush.setStyle ( Qt::SolidPattern );

*img = QgsMarkerCatalogue::instance()->pixmapMarker ( mMinimumSymbol->pointSymbolName(), mMinimumSymbol->pointSize(),
*img = QgsMarkerCatalogue::instance()->imageMarker ( mMinimumSymbol->pointSymbolName(), mMinimumSymbol->pointSize(),
pen, brush);

if ( scalefactor ) *scalefactor = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgsmarkercatalogue.cpp
Expand Up @@ -87,7 +87,7 @@ QgsMarkerCatalogue *QgsMarkerCatalogue::instance()
return QgsMarkerCatalogue::mMarkerCatalogue;
}

QImage QgsMarkerCatalogue::pixmapMarker ( QString fullName, int size, QPen pen, QBrush brush, bool qtBug )
QImage QgsMarkerCatalogue::imageMarker ( QString fullName, int size, QPen pen, QBrush brush, bool qtBug )
{
//std::cerr << "QgsMarkerCatalogue::marker " << fullName.toLocal8Bit().data() << " sice:" << size << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgsmarkercatalogue.h
Expand Up @@ -43,7 +43,7 @@ class CORE_EXPORT QgsMarkerCatalogue
/** Returns pixmap of the marker
* \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg
*/
QImage pixmapMarker (QString fullName, int size, QPen pen, QBrush brush, bool qtBug = true );
QImage imageMarker (QString fullName, int size, QPen pen, QBrush brush, bool qtBug = true );

/** Returns qpicture of the marker
* \param fullName full name, e.g. hard:circle, svg:/home/usr1/marker1.svg
Expand Down
8 changes: 4 additions & 4 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -232,10 +232,10 @@ void QgsSymbol::cache( QColor selectionColor )
// composer. Not sure why...
// brush.setColor ( selectionColor );

mPointSymbolImage = QgsMarkerCatalogue::instance()->pixmapMarker ( mPointSymbolName, mPointSize,
mPointSymbolImage = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, mPointSize,
mPen, mBrush );

mPointSymbolImageSelected = QgsMarkerCatalogue::instance()->pixmapMarker (
mPointSymbolImageSelected = QgsMarkerCatalogue::instance()->imageMarker (
mPointSymbolName, mPointSize, pen, brush );

mSelectionColor = selectionColor;
Expand All @@ -250,14 +250,14 @@ void QgsSymbol::cache2( double widthScale, QColor selectionColor )
pen.setWidth ( (int) ( widthScale * pen.width() ) );


mPointSymbolImage2 = QgsMarkerCatalogue::instance()->pixmapMarker ( mPointSymbolName, mPointSize,
mPointSymbolImage2 = QgsMarkerCatalogue::instance()->imageMarker ( mPointSymbolName, mPointSize,
pen, mBrush, false );

QBrush brush = mBrush;
brush.setColor ( selectionColor );
pen.setColor ( selectionColor );

mPointSymbolImageSelected2 = QgsMarkerCatalogue::instance()->pixmapMarker (
mPointSymbolImageSelected2 = QgsMarkerCatalogue::instance()->imageMarker (
mPointSymbolName, mPointSize, pen, brush, false );

mSelectionColor2 = selectionColor;
Expand Down

0 comments on commit d4bac97

Please sign in to comment.