Skip to content

Commit

Permalink
Some refactoring to prepare the way for reinstating qpicture based sy…
Browse files Browse the repository at this point in the history
…mbo drawing for composer

git-svn-id: http://svn.osgeo.org/qgis/trunk@5533 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jun 18, 2006
1 parent 03dcacf commit 9320b44
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/core/qgsmarkercatalogue.cpp
Expand Up @@ -87,21 +87,21 @@ QgsMarkerCatalogue *QgsMarkerCatalogue::instance()
return QgsMarkerCatalogue::mMarkerCatalogue;
}

QPixmap QgsMarkerCatalogue::marker ( QString fullName, int size, QPen pen, QBrush brush, bool qtBug )
QPixmap QgsMarkerCatalogue::pixmapMarker ( QString fullName, int size, QPen pen, QBrush brush, bool qtBug )
{
//std::cerr << "QgsMarkerCatalogue::marker " << fullName.toLocal8Bit().data() << " sice:" << size << std::endl;
if ( fullName.left(5) == "hard:" )
{
return hardMarker ( fullName.mid(5), size, pen, brush, qtBug );
return hardPixmapMarker ( fullName.mid(5), size, pen, brush, qtBug );
}
else if ( fullName.left(4) == "svg:" )
{
return svgMarker ( fullName.mid(4), size );
return svgPixmapMarker ( fullName.mid(4), size );
}
return QPixmap(); // empty
}

QPixmap QgsMarkerCatalogue::svgMarker ( QString filename, int scaleFactor)
QPixmap QgsMarkerCatalogue::svgPixmapMarker ( QString filename, int scaleFactor)
{
QSvgRenderer mySVG;
mySVG.load(filename);
Expand Down Expand Up @@ -139,7 +139,7 @@ QPixmap QgsMarkerCatalogue::svgMarker ( QString filename, int scaleFactor)
return myPixmap;
}

QPixmap QgsMarkerCatalogue::hardMarker ( QString name, int s, QPen pen, QBrush brush, bool qtBug )
QPixmap QgsMarkerCatalogue::hardPixmapMarker ( QString name, int s, QPen pen, QBrush brush, bool qtBug )
{
//Note teh +1 offset below is required because the
//scaling to odd numbers below will cause clipping otherwise
Expand Down
11 changes: 6 additions & 5 deletions src/core/qgsmarkercatalogue.h
Expand Up @@ -38,13 +38,14 @@ class QgsMarkerCatalogue{
/**List of available markers*/
QStringList list();

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

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

/**Constructor*/
Expand All @@ -56,7 +57,7 @@ class QgsMarkerCatalogue{
QStringList mList;

/** Hard coded */
QPixmap hardMarker ( QString name, int size, QPen pen, QBrush brush, bool qtBug = true );
QPixmap hardPixmapMarker ( QString name, int size, QPen pen, QBrush brush, bool qtBug = true );

};

Expand Down
8 changes: 4 additions & 4 deletions src/core/qgssymbol.cpp
Expand Up @@ -229,10 +229,10 @@ void QgsSymbol::cache( QColor selectionColor )
// composer. Not sure why...
// brush.setColor ( selectionColor );

mPointSymbolPixmap = QgsMarkerCatalogue::instance()->marker ( mPointSymbolName, mPointSize,
mPointSymbolPixmap = QgsMarkerCatalogue::instance()->pixmapMarker ( mPointSymbolName, mPointSize,
mPen, mBrush );

mPointSymbolPixmapSelected = QgsMarkerCatalogue::instance()->marker (
mPointSymbolPixmapSelected = QgsMarkerCatalogue::instance()->pixmapMarker (
mPointSymbolName, mPointSize, pen, brush );

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


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

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

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

mSelectionColor2 = selectionColor;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscontinuouscolorrenderer.cpp
Expand Up @@ -138,7 +138,7 @@ void QgsContinuousColorRenderer::renderFeature(QPainter * p, QgsFeature * f, QPi
}
brush.setStyle ( Qt::SolidPattern );

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

if ( scalefactor ) *scalefactor = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmarkerdialog.cpp
Expand Up @@ -88,7 +88,7 @@ void QgsMarkerDialog::visualizeMarkers(QString directory)
qWarning((*it).toLocal8Bit().data());

//render the SVG file to a pixmap and put it into mIconView
QPixmap pix = QgsMarkerCatalogue::svgMarker(mCurrentDir + "/" +
QPixmap pix = QgsMarkerCatalogue::svgPixmapMarker(mCurrentDir + "/" +
(*it), 1);
Q3IconViewItem* ivi=new Q3IconViewItem(mIconView,*it,pix);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgssinglesymboldialog.cpp
Expand Up @@ -63,7 +63,7 @@ QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer): QDialog(),
for ( QStringList::iterator it = ml.begin(); it != ml.end(); ++it )
{
mMarkers.push_back ( *it );
QPixmap pic = QgsMarkerCatalogue::instance()->marker ( *it, size,
QPixmap pic = QgsMarkerCatalogue::instance()->pixmapMarker ( *it, size,
pen, brush );
mPointSymbolComboBox->insertItem ( pic );
if (layer->vectorType() != QGis::Point)
Expand Down

0 comments on commit 9320b44

Please sign in to comment.