patch_for_1335.diff
python/core/qgsvectorlayer.sip (working copy) | ||
---|---|---|
301 | 301 |
/** \brief Draws the layer labels using coordinate transformation |
302 | 302 |
* \param scale size scale, applied to all values in pixels |
303 | 303 |
*/ |
304 |
void drawLabels(QPainter * p, const QgsRect& viewExtent, const QgsMapToPixel* cXf, const QgsCoordinateTransform* ct, double scale); |
|
304 |
void drawLabels(QPainter * p, const QgsRect& viewExtent, const QgsMapToPixel* cXf, const QgsCoordinateTransform* ct, double scale, double rendererScale );
|
|
305 | 305 | |
306 | 306 |
/** returns list of attributes */ |
307 | 307 |
QList<int> pendingAllAttributesList(); |
src/app/qgslabeldialog.cpp (working copy) | ||
---|---|---|
54 | 54 |
void QgsLabelDialog::init( ) |
55 | 55 |
{ |
56 | 56 |
QgsDebugMsg( "entering." ); |
57 | ||
57 | 58 |
QgsLabelAttributes * myLabelAttributes = mLabel->layerAttributes(); |
58 | 59 |
//populate a string list with all the field names which will be used to set up the |
59 | 60 |
//data bound combos |
... | ... | |
133 | 134 |
cboAngleField->addItems( myFieldStringList ); |
134 | 135 |
cboAngleField->setCurrentIndex( itemNoForField( mLabel->labelField( QgsLabel::Angle ), myFieldStringList ) ); |
135 | 136 | |
137 |
// set up the scale based layer visibility stuff.... |
|
138 |
chkUseScaleDependentRendering->setChecked( mLabel->scaleBasedVisibility() ); |
|
139 |
spinMinimumScale->setValue(( int )mLabel->minScale() ); |
|
140 |
spinMaximumScale->setValue(( int )mLabel->maxScale() ); |
|
136 | 141 | |
137 | 142 |
// |
138 | 143 |
//set the non-databound fields up now |
... | ... | |
197 | 202 |
spinXOffset->setValue( 0 ); |
198 | 203 |
spinYOffset->setValue( 0 ); |
199 | 204 |
} |
200 |
spinAngle->setValue( static_cast<int>( myLabelAttributes->angle() ) ); |
|
205 |
spinAngle->setRange( -1, 360 ); |
|
206 |
spinAngle->setSpecialValueText( tr("Auto") ); |
|
207 |
if( myLabelAttributes->angleIsAuto() ) |
|
208 |
{ |
|
209 |
spinAngle->setValue( -1 ); |
|
210 |
} |
|
211 |
else |
|
212 |
{ |
|
213 |
spinAngle->setValue( static_cast<int>( myLabelAttributes->angle() ) ); |
|
214 |
} |
|
201 | 215 | |
202 | 216 |
//the values here may seem a bit counterintuitive - basically everything |
203 | 217 |
//is the reverse of the way you think it should be... |
... | ... | |
242 | 256 |
spinBufferSize->setValue( static_cast<int>( myLabelAttributes->bufferSize() ) ); |
243 | 257 |
//TODO - transparency attributes for buffers |
244 | 258 | |
259 |
listWidget->setItemSelected( listWidget->item(0), true); |
|
245 | 260 |
} |
246 | 261 | |
247 | 262 | |
... | ... | |
335 | 350 |
myTypeInt = QgsLabelAttributes::MapUnits; |
336 | 351 |
} |
337 | 352 |
myLabelAttributes->setOffset( spinXOffset->value(), spinYOffset->value(), myTypeInt ); |
353 |
myLabelAttributes->setAutoAngle( spinAngle->value() == -1 ); |
|
338 | 354 |
myLabelAttributes->setAngle( spinAngle->value() ); |
339 | ||
355 |
|
|
340 | 356 |
//the values here may seem a bit counterintuitive - basically everything |
341 | 357 |
//is the reverse of the way you think it should be... |
342 | 358 |
//TODO investigate in QgsLabel why this needs to be the case |
... | ... | |
382 | 398 |
mLabel->setLabelField( QgsLabel::Alignment, fieldIndexFromName( cboAlignmentField->currentText() ) ); |
383 | 399 |
mLabel->setLabelField( QgsLabel::Angle, fieldIndexFromName( cboAngleField->currentText() ) ); |
384 | 400 | |
401 |
// set up the scale based layer visibility stuff.... |
|
402 |
mLabel->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() ); |
|
403 |
mLabel->setMinScale( spinMinimumScale->value() ); |
|
404 |
mLabel->setMaxScale( spinMaximumScale->value() ); |
|
385 | 405 |
} |
386 | 406 | |
387 | 407 |
int QgsLabelDialog::fieldIndexFromName( QString name ) |
src/core/qgslabelattributes.cpp (working copy) | ||
---|---|---|
41 | 41 |
mOffsetIsSet( false ), |
42 | 42 |
mAngle( 0.0 ), |
43 | 43 |
mAngleIsSet( false ), |
44 |
mAngleIsAuto( false ), |
|
44 | 45 |
mAlignment( 0 ), |
45 | 46 |
mAlignmentIsSet( false ), |
46 | 47 |
mBufferEnabledFlag( false ), |
... | ... | |
69 | 70 | |
70 | 71 |
setOffset( 0, 0, PointUnits ); |
71 | 72 |
setAngle( 0 ); |
73 |
setAutoAngle(false); |
|
72 | 74 | |
73 | 75 |
setAlignment( Qt::AlignCenter ); |
74 | 76 |
setColor( QColor( 0, 0, 0 ) ); |
... | ... | |
150 | 152 |
return mAngle; |
151 | 153 |
} |
152 | 154 | |
155 |
bool QgsLabelAttributes::angleIsAuto() const |
|
156 |
{ |
|
157 |
return mAngleIsAuto; |
|
158 |
} |
|
159 | ||
160 |
void QgsLabelAttributes::setAutoAngle ( bool state ) |
|
161 |
{ |
|
162 |
mAngleIsAuto = state; |
|
163 |
} |
|
164 | ||
153 | 165 |
/* Alignment */ |
154 | 166 |
void QgsLabelAttributes::setAlignment( int alignment ) |
155 | 167 |
{ |
src/core/qgsvectorlayer.cpp (working copy) | ||
---|---|---|
286 | 286 |
{ |
287 | 287 |
return; |
288 | 288 |
} |
289 |
drawLabels( thePainter, rendererContext.extent(), &( rendererContext.mapToPixel() ), rendererContext.coordinateTransform(), rendererContext.scaleFactor() ); |
|
289 |
drawLabels( thePainter, rendererContext.extent(), &( rendererContext.mapToPixel() ), rendererContext.coordinateTransform(), rendererContext.scaleFactor(), rendererContext.rendererScale() );
|
|
290 | 290 |
} |
291 | 291 | |
292 | 292 |
// NOTE this is a temporary method added by Tim to prevent label clipping |
293 | 293 |
// which was occurring when labeller was called in the main draw loop |
294 | 294 |
// This method will probably be removed again in the near future! |
295 |
void QgsVectorLayer::drawLabels( QPainter * p, const QgsRect& viewExtent, const QgsMapToPixel* theMapToPixelTransform, const QgsCoordinateTransform* ct, double scale ) |
|
295 |
void QgsVectorLayer::drawLabels( QPainter * p, const QgsRect& viewExtent, const QgsMapToPixel* theMapToPixelTransform, const QgsCoordinateTransform* ct, double scale, double rendererScale )
|
|
296 | 296 |
{ |
297 | 297 |
QgsDebugMsg( "Starting draw of labels" ); |
298 | 298 | |
299 |
if ( mRenderer && mLabelOn ) |
|
299 |
if ( mRenderer && mLabelOn && |
|
300 |
(!label()->scaleBasedVisibility() || |
|
301 |
(label()->minScale()<=rendererScale && rendererScale<=label()->maxScale())) ) |
|
300 | 302 |
{ |
301 | 303 |
QgsAttributeList attributes = mRenderer->classificationAttributes(); |
302 | 304 | |
... | ... | |
1967 | 1969 |
return mLabelOn; |
1968 | 1970 |
} |
1969 | 1971 | |
1970 | ||
1971 | ||
1972 | 1972 |
bool QgsVectorLayer::startEditing() |
1973 | 1973 |
{ |
1974 | 1974 |
if ( !mDataProvider ) |
... | ... | |
2057 | 2057 |
setDisplayField( e.text() ); |
2058 | 2058 |
} |
2059 | 2059 | |
2060 |
// use scale dependent visibility flag |
|
2061 |
QDomElement e = layer_node.toElement(); |
|
2062 |
label()->setScaleBasedVisibility( e.attribute( "scaleBasedLabelVisibilityFlag", "0") == "1" ); |
|
2063 |
label()->setMinScale( e.attribute( "minLabelScale", "1" ).toFloat() ); |
|
2064 |
label()->setMaxScale( e.attribute( "maxLabelScale", "100000000" ).toFloat() ); |
|
2065 | ||
2060 | 2066 |
QDomNode editTypesNode = layer_node.namedItem( "edittypes" ); |
2061 | 2067 |
if ( !editTypesNode.isNull() ) |
2062 | 2068 |
{ |
... | ... | |
2224 | 2230 | |
2225 | 2231 |
if ( mapLayerNode.isNull() || ( "maplayer" != mapLayerNode.nodeName() ) ) |
2226 | 2232 |
{ |
2227 |
qDebug( "QgsVectorLayer::writeXML() can't find <maplayer>" );
|
|
2233 |
QgsDebugMsg( "can't find <maplayer>" );
|
|
2228 | 2234 |
return false; |
2229 | 2235 |
} |
2230 | 2236 | |
... | ... | |
2233 | 2239 |
// set the geometry type |
2234 | 2240 |
mapLayerNode.setAttribute( "geometry", QGis::qgisVectorGeometryType[type()] ); |
2235 | 2241 | |
2242 |
// use scale dependent visibility flag |
|
2243 |
mapLayerNode.setAttribute( "scaleBasedLabelVisibilityFlag", label()->scaleBasedVisibility() ? 1 : 0 ); |
|
2244 |
mapLayerNode.setAttribute( "minLabelScale", label()->minScale() ); |
|
2245 |
mapLayerNode.setAttribute( "maxLabelScale", label()->maxScale() ); |
|
2246 | ||
2236 | 2247 |
// add provider node |
2237 | 2248 | |
2238 | 2249 |
QDomElement provider = document.createElement( "provider" ); |
... | ... | |
2353 | 2364 |
layer_node.appendChild( dField ); |
2354 | 2365 |
} |
2355 | 2366 | |
2356 |
std::stringstream labelXML; |
|
2357 | ||
2358 |
myLabel->writeXML( labelXML ); |
|
2359 | ||
2360 |
QDomDocument labelDom; |
|
2361 | ||
2362 |
std::string rawXML; |
|
2363 |
std::string temp_str; |
|
2364 |
QString errorMsg; |
|
2365 |
int errorLine; |
|
2366 |
int errorColumn; |
|
2367 | ||
2368 |
// start with bogus XML header |
|
2369 |
rawXML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; |
|
2370 | ||
2371 |
temp_str = labelXML.str(); |
|
2372 | ||
2373 |
rawXML += temp_str; |
|
2374 | ||
2375 |
#ifdef QGISDEBUG |
|
2376 |
std::cout << rawXML << std::endl << std::flush; // OK |
|
2377 | ||
2378 |
#endif |
|
2379 |
const char * s = rawXML.c_str(); // debugger probe |
|
2380 |
// Use the const char * form of the xml to make non-stl qt happy |
|
2381 |
if ( ! labelDom.setContent( QString::fromUtf8( s ), &errorMsg, &errorLine, &errorColumn ) ) |
|
2382 |
{ |
|
2383 |
qDebug(( "XML import error at line %d column %d " + errorMsg ).toLocal8Bit().data(), errorLine, errorColumn ); |
|
2384 | ||
2385 |
return false; |
|
2386 |
} |
|
2387 | ||
2388 |
// lastChild() because the first two nodes are the <xml> and |
|
2389 |
// <!DOCTYPE> nodes; the label node follows that, and is (hopefully) |
|
2390 |
// the last node. |
|
2391 |
QDomNode labelDomNode = document.importNode( labelDom.lastChild(), true ); |
|
2392 | ||
2393 |
if ( ! labelDomNode.isNull() ) |
|
2394 |
{ |
|
2395 |
layer_node.appendChild( labelDomNode ); |
|
2396 |
} |
|
2397 |
else |
|
2398 |
{ |
|
2399 |
qDebug( "not able to import label Dom node" ); |
|
2400 | ||
2401 |
// XXX return false? |
|
2402 |
} |
|
2403 | ||
2367 |
myLabel->writeXML( layer_node, document ); |
|
2404 | 2368 |
} |
2405 | 2369 | |
2406 | 2370 |
return true; |
... | ... | |
3533 | 3497 | |
3534 | 3498 |
return mRanges[ fields[idx].name()]; |
3535 | 3499 |
} |
3500 |
src/core/qgsrendercontext.h (working copy) | ||
---|---|---|
56 | 56 | |
57 | 57 |
bool drawEditingInformation() const {return mDrawEditingInformation;} |
58 | 58 | |
59 |
double rendererScale() const {return mRendererScale;} |
|
60 | ||
59 | 61 |
//setters |
60 | 62 | |
61 | 63 |
/**Sets coordinate transformation. QgsRenderContext takes ownership and deletes if necessary*/ |
... | ... | |
66 | 68 |
void setRenderingStopped( bool stopped ) {mRenderingStopped = stopped;} |
67 | 69 |
void setScaleFactor( double factor ) {mScaleFactor = factor;} |
68 | 70 |
void setRasterScaleFactor( double factor ) {mRasterScaleFactor = factor;} |
71 |
void setRendererScale( double scale ) {mRendererScale = scale;} |
|
69 | 72 |
void setPainter( QPainter* p ) {mPainter = p;} |
70 | 73 | |
71 | 74 |
private: |
... | ... | |
94 | 97 | |
95 | 98 |
/**Factor to scale rasters*/ |
96 | 99 |
double mRasterScaleFactor; |
100 | ||
101 |
/** renderer scale */ |
|
102 |
double mRendererScale; |
|
97 | 103 |
}; |
98 | 104 | |
99 | 105 |
#endif |
src/core/qgsvectorlayer.h (working copy) | ||
---|---|---|
363 | 363 |
void drawLabels( QPainter * p, const QgsRect& viewExtent, |
364 | 364 |
const QgsMapToPixel* cXf, |
365 | 365 |
const QgsCoordinateTransform* ct, |
366 |
double scale ); |
|
366 |
double scale, |
|
367 |
double rendererScale ); |
|
367 | 368 | |
368 | 369 |
/** returns field list in the to-be-committed state */ |
369 | 370 |
const QgsFieldMap &pendingFields(); |
src/core/qgsmaprenderer.cpp (working copy) | ||
---|---|---|
69 | 69 | |
70 | 70 |
void QgsMapRenderer::updateScale() |
71 | 71 |
{ |
72 | ||
73 | 72 |
mScale = mScaleCalculator->calculate( mExtent, mSize.width() ); |
74 | 73 |
} |
75 | 74 | |
... | ... | |
248 | 247 |
double rasterScaleFactor = ( thePaintDevice->logicalDpiX() + thePaintDevice->logicalDpiY() ) / 2.0 / sceneDpi; |
249 | 248 |
mRenderContext.setScaleFactor( scaleFactor ); |
250 | 249 |
mRenderContext.setRasterScaleFactor( rasterScaleFactor ); |
250 |
mRenderContext.setRendererScale( mScale ); |
|
251 | 251 | |
252 | 252 |
// render all layers in the stack, starting at the base |
253 | 253 |
QListIterator<QString> li( mLayerSet ); |
... | ... | |
289 | 289 |
QgsDebugMsg( " Scale dep. visibility enabled? " + QString( "%1" ).arg( ml->scaleBasedVisibility() ) ); |
290 | 290 |
QgsDebugMsg( " Input extent: " + ml->extent().toString() ); |
291 | 291 | |
292 |
if (( ml->scaleBasedVisibility() && ml->minScale() < mScale && ml->maxScale() > mScale ) |
|
293 |
|| ( !ml->scaleBasedVisibility() ) ) |
|
292 |
if ( !ml->scaleBasedVisibility() || (ml->minScale() < mScale && mScale < ml->maxScale() ) ) |
|
294 | 293 |
{ |
295 | 294 |
connect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) ); |
296 | 295 | |
... | ... | |
390 | 389 |
{ |
391 | 390 |
// only make labels if the layer is visible |
392 | 391 |
// after scale dep viewing settings are checked |
393 |
if (( ml->scaleBasedVisibility() && ml->minScale() < mScale && ml->maxScale() > mScale ) |
|
394 |
|| ( !ml->scaleBasedVisibility() ) ) |
|
392 |
if ( !ml->scaleBasedVisibility() || (ml->minScale() < mScale && mScale < ml->maxScale() )) |
|
395 | 393 |
{ |
396 | 394 |
bool split = false; |
397 | 395 |
src/core/qgslabel.cpp (working copy) | ||
---|---|---|
47 | 47 |
"$Id$"; |
48 | 48 | |
49 | 49 |
QgsLabel::QgsLabel( const QgsFieldMap & fields ) |
50 |
: mMinScale(0 ), |
|
51 |
mMaxScale(100000000), |
|
52 |
mScaleBasedVisibility(false) |
|
50 | 53 |
{ |
51 | 54 |
mField = fields; |
52 | 55 |
mLabelFieldIdx.resize( LabelFieldCount ); |
... | ... | |
353 | 356 |
} |
354 | 357 |
else |
355 | 358 |
{ |
356 |
std::vector<QgsPoint> points;
|
|
359 |
std::vector<labelpoint> points;
|
|
357 | 360 |
labelPoint( points, feature ); |
358 | 361 |
for ( uint i = 0; i < points.size(); ++i ) |
359 | 362 |
{ |
360 |
renderLabel( painter, points[i], coordinateTransform, |
|
363 |
renderLabel( painter, points[i].p, coordinateTransform,
|
|
361 | 364 |
transform, text, font, pen, dx, dy, |
362 |
xoffset, yoffset, ang, width, height, alignment, sizeScale ); |
|
365 |
xoffset, yoffset, mLabelAttributes->angleIsAuto() ? points[i].angle : ang, width, height, alignment, sizeScale );
|
|
363 | 366 |
} |
364 | 367 |
} |
365 | 368 |
} |
... | ... | |
393 | 396 |
double x = point.x(); |
394 | 397 |
double y = point.y(); |
395 | 398 | |
396 |
static const double rad = ang * M_PI / 180;
|
|
399 |
double rad = ang * M_PI / 180; |
|
397 | 400 | |
398 | 401 |
x = x + xoffset * cos( rad ) - yoffset * sin( rad ); |
399 | 402 |
y = y - xoffset * sin( rad ) - yoffset * cos( rad ); |
... | ... | |
504 | 507 |
return mLabelAttributes; |
505 | 508 |
} |
506 | 509 | |
507 |
void QgsLabel::labelPoint( std::vector<QgsPoint>& points, QgsFeature & feature )
|
|
510 |
void QgsLabel::labelPoint( std::vector<labelpoint>& points, QgsFeature & feature )
|
|
508 | 511 |
{ |
509 | 512 |
QgsGeometry *geometry = feature.geometry(); |
510 | 513 |
unsigned char *geom = geometry->wkbBuffer(); |
511 | 514 |
size_t geomlen = geometry->wkbSize(); |
512 | 515 |
QGis::WkbType wkbType = geometry->wkbType(); |
513 |
QgsPoint point;
|
|
516 |
labelpoint point;
|
|
514 | 517 | |
515 | 518 |
switch ( wkbType ) |
516 | 519 |
{ |
... | ... | |
552 | 555 |
} |
553 | 556 |
} |
554 | 557 | |
555 |
unsigned char* QgsLabel::labelPoint( QgsPoint& point, unsigned char *geom, size_t geomlen )
|
|
558 |
unsigned char* QgsLabel::labelPoint( labelpoint& point, unsigned char *geom, size_t geomlen )
|
|
556 | 559 |
{ |
557 | 560 |
// verify that local types match sizes as WKB spec |
558 | 561 |
Q_ASSERT( sizeof( int ) == 4 ); |
... | ... | |
584 | 587 |
{ |
585 | 588 |
Q_ASSERT( geom + 2*sizeof( double ) <= geomend ); |
586 | 589 |
double *pts = ( double * )geom; |
587 |
point.set( pts[0], pts[1] ); |
|
590 |
point.p.set( pts[0], pts[1] ); |
|
591 |
point.angle = 0.0; |
|
588 | 592 |
geom += 2 * sizeof( double ); |
589 | 593 |
} |
590 | 594 |
break; |
... | ... | |
622 | 626 |
{ |
623 | 627 |
double k = ( tl - l ) / dl; |
624 | 628 | |
625 |
point.set( pts[dims*( i-1 )] + k * dx, |
|
626 |
pts[dims*( i-1 )+1] + k * dy ); |
|
629 |
point.p.set( pts[dims*( i-1 )] + k * dx, |
|
630 |
pts[dims*( i-1 )+1] + k * dy ); |
|
631 |
point.angle = atan2(dy,dx)*180.0*M_1_PI; |
|
627 | 632 |
break; |
628 | 633 |
} |
629 | 634 | |
... | ... | |
659 | 664 |
sx += pts[dims*j]; |
660 | 665 |
sy += pts[dims*j+1]; |
661 | 666 |
} |
662 |
point.set( sx / ( nPoints - 1 ), |
|
663 |
sy / ( nPoints - 1 ) ); |
|
667 |
point.p.set( sx / ( nPoints - 1 ), |
|
668 |
sy / ( nPoints - 1 ) ); |
|
669 |
point.angle = 0.0; |
|
664 | 670 |
} |
665 | 671 | |
666 | 672 |
geom += nPoints * sizeof( double ) * dims; |
... | ... | |
871 | 877 |
el = scratchNode.toElement(); |
872 | 878 |
mLabelAttributes->setAngle( el.attribute( "value", "0.0" ).toDouble() ); |
873 | 879 |
setLabelField( Angle, _elementFieldIndex( el ) ); |
880 |
mLabelAttributes->setAutoAngle( el.attribute( "auto", "0" )=="1" ); |
|
874 | 881 |
} |
875 | 882 | |
876 | 883 |
/* Alignment */ |
... | ... | |
954 | 961 | |
955 | 962 | |
956 | 963 | |
957 |
void QgsLabel::writeXML( std::ostream& xml ) |
|
964 |
void QgsLabel::writeXML( QDomNode & layer_node, |
|
965 |
QDomDocument & document ) |
|
958 | 966 |
{ |
967 |
QDomElement labelattributes = document.createElement( "labelattributes" ); |
|
959 | 968 | |
960 |
xml << "\t\t<labelattributes>\n"; |
|
961 | ||
962 | 969 |
// Text |
963 |
if ( mLabelAttributes->textIsSet() ) |
|
970 |
QDomElement label = document.createElement( "label" ); |
|
971 |
label.setAttribute("text", mLabelAttributes->text() ); |
|
972 |
if ( mLabelAttributes->textIsSet() && mLabelFieldIdx[Text] != -1 ) |
|
964 | 973 |
{ |
965 |
if ( mLabelFieldIdx[Text] != -1 ) |
|
966 |
{ |
|
967 |
xml << "\t\t\t<label text=\"" << mLabelAttributes->text().toUtf8().constData() |
|
968 |
<< "\" field=\"" << mLabelFieldIdx[Text] << "\" />\n"; |
|
969 |
} |
|
970 |
else |
|
971 |
{ |
|
972 |
xml << "\t\t\t<label text=\"" << mLabelAttributes->text().toUtf8().constData() |
|
973 |
<< "\" field=\"\" />\n"; |
|
974 |
} |
|
974 |
label.setAttribute("field", mLabelFieldIdx[Text] ); |
|
975 | 975 |
} |
976 | 976 |
else |
977 | 977 |
{ |
978 |
xml << "\t\t\t<label text=\"" << mLabelAttributes->text().toUtf8().constData() |
|
979 |
<< "\" field=\"\" />\n"; |
|
978 |
label.setAttribute("field", "" ); |
|
980 | 979 |
} |
980 |
labelattributes.appendChild(label); |
|
981 | 981 | |
982 | 982 |
// Family |
983 |
QDomElement family = document.createElement( "family" ); |
|
983 | 984 |
if ( mLabelAttributes->familyIsSet() && !mLabelAttributes->family().isNull() ) |
984 | 985 |
{ |
985 | 986 |
if ( mLabelFieldIdx[Family] != -1 ) |
986 | 987 |
{ |
987 |
xml << "\t\t\t<family name=\"" << mLabelAttributes->family().toUtf8().constData()
|
|
988 |
<< "\" field=\"" << mLabelFieldIdx[Family] << "\" />\n";
|
|
988 |
family.setAttribute("name", mLabelAttributes->family() );
|
|
989 |
family.setAttribute("field", mLabelFieldIdx[Family] );
|
|
989 | 990 |
} |
990 | 991 |
else |
991 | 992 |
{ |
992 |
xml << "\t\t\t<family name=\"" << mLabelAttributes->family().toUtf8().constData()
|
|
993 |
<< "\" field=\"\" />\n";
|
|
993 |
family.setAttribute("name", mLabelAttributes->family() );
|
|
994 |
family.setAttribute("field", "" );
|
|
994 | 995 |
} |
995 | 996 |
} |
996 | 997 |
else |
997 | 998 |
{ |
998 |
xml << "\t\t\t<family name=\"Arial\" field=\"\" />\n"; |
|
999 |
family.setAttribute("name", "Arial"); |
|
1000 |
family.setAttribute("field", ""); |
|
999 | 1001 |
} |
1002 |
labelattributes.appendChild(family); |
|
1000 | 1003 | |
1001 | 1004 |
// size and units |
1005 |
QDomElement size = document.createElement( "size" ); |
|
1006 |
size.setAttribute("value", mLabelAttributes->size()); |
|
1002 | 1007 |
if ( mLabelAttributes->sizeIsSet() ) |
1003 | 1008 |
{ |
1004 | 1009 |
if ( mLabelFieldIdx[Size] != -1 ) |
1005 | 1010 |
{ |
1006 | 1011 |
if ( mLabelFieldIdx[SizeType] != -1 ) |
1007 | 1012 |
{ |
1008 |
xml << "\t\t\t<size value=\"" << mLabelAttributes->size() |
|
1009 |
<< "\" unitfield=\"" << mLabelFieldIdx[SizeType] |
|
1010 |
<< "\" field=\"" << mLabelFieldIdx[Size] << "\" />\n"; |
|
1013 |
size.setAttribute("unitfield", mLabelFieldIdx[SizeType] ); |
|
1011 | 1014 |
} |
1012 | 1015 |
else |
1013 | 1016 |
{ |
1014 |
xml << "\t\t\t<size value=\"" << mLabelAttributes->size() |
|
1015 |
<< "\" units=\"" << QgsLabelAttributes::unitsName( mLabelAttributes->sizeType() ).toUtf8().constData() |
|
1016 |
<< "\" field=\"" << mLabelFieldIdx[Size] << "\" />\n"; |
|
1017 |
size.setAttribute("units", QgsLabelAttributes::unitsName( mLabelAttributes->sizeType() ) ); |
|
1017 | 1018 |
} |
1019 |
size.setAttribute("field", mLabelFieldIdx[Size] ); |
|
1018 | 1020 |
} |
1019 | 1021 |
else |
1020 | 1022 |
{ |
1021 |
xml << "\t\t\t<size value=\"" << mLabelAttributes->size() |
|
1022 |
<< "\" units=\"" << QgsLabelAttributes::unitsName( mLabelAttributes->sizeType() ).toUtf8().constData() |
|
1023 |
<< "\" field=\"\" />\n"; |
|
1023 |
size.setAttribute("units", QgsLabelAttributes::unitsName( mLabelAttributes->sizeType() ) ); |
|
1024 |
size.setAttribute("field", "" ); |
|
1024 | 1025 |
} |
1025 | 1026 |
} |
1026 | 1027 |
else |
1027 | 1028 |
{ |
1028 |
xml << "\t\t\t<size value=\"12\" units=\"Points\" field=\"\" />\n"; |
|
1029 |
size.setAttribute("value", "12"); |
|
1030 |
size.setAttribute("units", "Points"); |
|
1031 |
size.setAttribute("field", ""); |
|
1029 | 1032 |
} |
1033 |
labelattributes.appendChild(size); |
|
1030 | 1034 | |
1031 | ||
1032 | 1035 |
// bold |
1036 |
QDomElement bold = document.createElement("bold"); |
|
1033 | 1037 |
if ( mLabelAttributes->boldIsSet() ) |
1034 | 1038 |
{ |
1039 |
bold.setAttribute( "on", mLabelAttributes->bold() ); |
|
1035 | 1040 |
if ( mLabelFieldIdx[Bold] != -1 ) |
1036 | 1041 |
{ |
1037 |
xml << "\t\t\t<bold on=\"" << mLabelAttributes->bold() |
|
1038 |
<< "\" field=\"" << mLabelFieldIdx[Bold] << "\" />\n"; |
|
1042 |
bold.setAttribute( "field", mLabelFieldIdx[Bold] ); |
|
1039 | 1043 |
} |
1040 | 1044 |
else |
1041 | 1045 |
{ |
1042 |
xml << "\t\t\t<bold on=\"" << mLabelAttributes->bold() |
|
1043 |
<< "\" field=\"\" />\n"; |
|
1046 |
bold.setAttribute( "field", "" ); |
|
1044 | 1047 |
} |
1045 | 1048 |
} |
1046 | 1049 |
else |
1047 | 1050 |
{ |
1048 |
xml << "\t\t\t<bold on=\"0\" field=\"0\" />\n"; |
|
1051 |
bold.setAttribute("on", 0); |
|
1052 |
bold.setAttribute("field", 0); |
|
1049 | 1053 |
} |
1054 |
labelattributes.appendChild(bold); |
|
1050 | 1055 | |
1051 | 1056 |
// italics |
1057 |
QDomElement italic = document.createElement("italic"); |
|
1052 | 1058 |
if ( mLabelAttributes->italicIsSet() ) |
1053 | 1059 |
{ |
1060 |
italic.setAttribute("on", mLabelAttributes->italic()); |
|
1054 | 1061 |
if ( mLabelFieldIdx[Italic] != -1 ) |
1055 | 1062 |
{ |
1056 |
xml << "\t\t\t<italic on=\"" << mLabelAttributes->italic() |
|
1057 |
<< "\" field=\"" << mLabelFieldIdx[Italic] << "\" />\n"; |
|
1063 |
italic.setAttribute("field", mLabelFieldIdx[Italic]); |
|
1058 | 1064 |
} |
1059 | 1065 |
else |
1060 | 1066 |
{ |
1061 |
xml << "\t\t\t<italic on=\"" << mLabelAttributes->italic() |
|
1062 |
<< "\" field=\"\" />\n"; |
|
1067 |
italic.setAttribute("field", ""); |
|
1063 | 1068 |
} |
1064 | 1069 |
} |
1065 | 1070 |
else |
1066 | 1071 |
{ |
1067 |
xml << "\t\t\t<italic on=\"0\" field=\"\" />\n"; |
|
1072 |
italic.setAttribute("on", "0"); |
|
1073 |
italic.setAttribute("field", ""); |
|
1068 | 1074 |
} |
1075 |
labelattributes.appendChild(italic); |
|
1069 | 1076 | |
1070 | 1077 |
// underline |
1078 |
QDomElement underline = document.createElement("underline"); |
|
1071 | 1079 |
if ( mLabelAttributes->underlineIsSet() ) |
1072 | 1080 |
{ |
1081 |
underline.setAttribute("on", mLabelAttributes->underline()); |
|
1073 | 1082 |
if ( mLabelFieldIdx[Underline] != -1 ) |
1074 | 1083 |
{ |
1075 |
xml << "\t\t\t<underline on=\"" << mLabelAttributes->underline() |
|
1076 |
<< "\" field=\"" << mLabelFieldIdx[Underline] << "\" />\n"; |
|
1084 |
underline.setAttribute("field", mLabelFieldIdx[Underline] ); |
|
1077 | 1085 |
} |
1078 | 1086 |
else |
1079 | 1087 |
{ |
1080 |
xml << "\t\t\t<underline on=\"" << mLabelAttributes->underline() |
|
1081 |
<< "\" field=\"\" />\n"; |
|
1088 |
underline.setAttribute("field", "" ); |
|
1082 | 1089 |
} |
1083 | 1090 |
} |
1084 | 1091 |
else |
1085 | 1092 |
{ |
1086 |
xml << "\t\t\t<underline on=\"0\" field=\"\" />\n"; |
|
1093 |
underline.setAttribute("on", 0 ); |
|
1094 |
underline.setAttribute("field", "" ); |
|
1087 | 1095 |
} |
1096 |
labelattributes.appendChild(underline); |
|
1088 | 1097 | |
1089 | 1098 |
// color |
1099 |
QDomElement color = document.createElement("color"); |
|
1090 | 1100 |
if ( mLabelAttributes->colorIsSet() ) |
1091 | 1101 |
{ |
1102 |
color.setAttribute("red", mLabelAttributes->color().red()); |
|
1103 |
color.setAttribute("green", mLabelAttributes->color().green()); |
|
1104 |
color.setAttribute("blue", mLabelAttributes->color().blue()); |
|
1092 | 1105 |
if ( mLabelFieldIdx[Color] != -1 ) |
1093 | 1106 |
{ |
1094 |
xml << "\t\t\t<color red=\"" << mLabelAttributes->color().red() |
|
1095 |
<< "\" green=\"" << mLabelAttributes->color().green() |
|
1096 |
<< "\" blue=\"" << mLabelAttributes->color().blue() |
|
1097 |
<< "\" field=\"" << mLabelFieldIdx[Color] << "\" />\n"; |
|
1107 |
color.setAttribute("field", mLabelFieldIdx[Color]); |
|
1098 | 1108 |
} |
1099 | 1109 |
else |
1100 | 1110 |
{ |
1101 |
xml << "\t\t\t<color red=\"" << mLabelAttributes->color().red() |
|
1102 |
<< "\" green=\"" << mLabelAttributes->color().green() |
|
1103 |
<< "\" blue=\"" << mLabelAttributes->color().blue() |
|
1104 |
<< "\" field=\"\" />\n"; |
|
1111 |
color.setAttribute("field", ""); |
|
1105 | 1112 |
} |
1106 | 1113 |
} |
1107 | 1114 |
else |
1108 | 1115 |
{ |
1109 |
xml << "\t\t\t<color red=\"0\" green=\"0\" blue=\"0\" field=\"\" />\n"; |
|
1116 |
color.setAttribute("red", 0); |
|
1117 |
color.setAttribute("green", 0); |
|
1118 |
color.setAttribute("blue", 0); |
|
1119 |
color.setAttribute("field", ""); |
|
1110 | 1120 |
} |
1121 |
labelattributes.appendChild(color); |
|
1111 | 1122 | |
1112 | ||
1113 | 1123 |
/* X */ |
1124 |
QDomElement x = document.createElement("x"); |
|
1114 | 1125 |
if ( mLabelFieldIdx[XCoordinate] != -1 ) |
1115 | 1126 |
{ |
1116 |
xml << "\t\t\t<x field=\"" << mLabelFieldIdx[XCoordinate] << "\" />\n";
|
|
1127 |
x.setAttribute("field", mLabelFieldIdx[XCoordinate] );
|
|
1117 | 1128 |
} |
1118 | 1129 |
else |
1119 | 1130 |
{ |
1120 |
xml << "\t\t\t<x field=\"\" />\n";
|
|
1131 |
x.setAttribute("field", "" );
|
|
1121 | 1132 |
} |
1133 |
labelattributes.appendChild(x); |
|
1122 | 1134 | |
1123 | 1135 |
/* Y */ |
1136 |
QDomElement y = document.createElement("y"); |
|
1124 | 1137 |
if ( mLabelFieldIdx[YCoordinate] != -1 ) |
1125 | 1138 |
{ |
1126 |
xml << "\t\t\t<y field=\"" << mLabelFieldIdx[YCoordinate] << "\" />\n";
|
|
1139 |
y.setAttribute("field", mLabelFieldIdx[YCoordinate] );
|
|
1127 | 1140 |
} |
1128 | 1141 |
else |
1129 | 1142 |
{ |
1130 |
xml << "\t\t\t<y field=\"\" />\n";
|
|
1143 |
y.setAttribute("field", "" );
|
|
1131 | 1144 |
} |
1145 |
labelattributes.appendChild(y); |
|
1132 | 1146 | |
1133 | 1147 |
// offset |
1134 | 1148 |
if ( mLabelAttributes->offsetIsSet() ) |
1135 | 1149 |
{ |
1136 |
xml << "\t\t\t<offset units=\"" << QgsLabelAttributes::unitsName( mLabelAttributes->offsetType() ).toUtf8().constData() |
|
1137 |
<< "\" x=\"" << mLabelAttributes->xOffset() << "\" xfield=\"" << mLabelFieldIdx[XOffset] |
|
1138 |
<< "\" y=\"" << mLabelAttributes->yOffset() << "\" yfield=\"" << mLabelFieldIdx[YOffset] |
|
1139 |
<< "\" />\n"; |
|
1150 |
QDomElement offset = document.createElement("offset"); |
|
1151 |
offset.setAttribute("units", QgsLabelAttributes::unitsName( mLabelAttributes->offsetType() ) ); |
|
1152 |
offset.setAttribute("x", mLabelAttributes->xOffset() ); |
|
1153 |
offset.setAttribute("xfield", mLabelFieldIdx[XOffset] ); |
|
1154 |
offset.setAttribute("y", mLabelAttributes->yOffset()); |
|
1155 |
offset.setAttribute("yfield", mLabelFieldIdx[YOffset]); |
|
1156 |
labelattributes.appendChild(offset); |
|
1140 | 1157 |
} |
1141 | 1158 | |
1142 | 1159 |
// Angle |
1160 |
QDomElement angle = document.createElement("angle"); |
|
1143 | 1161 |
if ( mLabelAttributes->angleIsSet() ) |
1144 | 1162 |
{ |
1163 |
angle.setAttribute("value", mLabelAttributes->angle() ); |
|
1145 | 1164 |
if ( mLabelFieldIdx[Angle] != -1 ) |
1146 | 1165 |
{ |
1147 |
xml << "\t\t\t<angle value=\"" << mLabelAttributes->angle() |
|
1148 |
<< "\" field=\"" << mLabelFieldIdx[Angle] << "\" />\n"; |
|
1166 |
angle.setAttribute("field", mLabelFieldIdx[Angle] ); |
|
1149 | 1167 |
} |
1150 | 1168 |
else |
1151 | 1169 |
{ |
1152 |
xml << "\t\t\t<angle value=\"" << mLabelAttributes->angle() << "\" field=\"\" />\n";
|
|
1170 |
angle.setAttribute("field", "" );
|
|
1153 | 1171 |
} |
1154 | 1172 |
} |
1155 | 1173 |
else |
1156 | 1174 |
{ |
1157 |
xml << "\t\t\t<angle value=\"\" field=\"\" />\n"; |
|
1175 |
angle.setAttribute("value", "" ); |
|
1176 |
angle.setAttribute("field", "" ); |
|
1158 | 1177 |
} |
1178 |
angle.setAttribute("auto", mLabelAttributes->angleIsAuto() ? "1" : "0"); |
|
1179 |
labelattributes.appendChild(angle); |
|
1159 | 1180 | |
1160 | 1181 |
// alignment |
1161 | 1182 |
if ( mLabelAttributes->alignmentIsSet() ) |
1162 | 1183 |
{ |
1163 |
xml << "\t\t\t<alignment value=\"" << QgsLabelAttributes::alignmentName( mLabelAttributes->alignment() ).toUtf8().constData() |
|
1164 |
<< "\" field=\"" << mLabelFieldIdx[Alignment] << "\" />\n"; |
|
1184 |
QDomElement alignment = document.createElement("alignment"); |
|
1185 |
alignment.setAttribute("value", QgsLabelAttributes::alignmentName( mLabelAttributes->alignment() ) ); |
|
1186 |
alignment.setAttribute("field", mLabelFieldIdx[Alignment] ); |
|
1187 |
labelattributes.appendChild(alignment); |
|
1165 | 1188 |
} |
1166 | 1189 | |
1167 | 1190 |
// buffer color |
1191 |
QDomElement buffercolor = document.createElement("buffercolor"); |
|
1168 | 1192 |
if ( mLabelAttributes->bufferColorIsSet() ) |
1169 | 1193 |
{ |
1194 |
buffercolor.setAttribute("red", mLabelAttributes->bufferColor().red()); |
|
1195 |
buffercolor.setAttribute("green", mLabelAttributes->bufferColor().green()); |
|
1196 |
buffercolor.setAttribute("blue", mLabelAttributes->bufferColor().blue()); |
|
1170 | 1197 |
if ( mLabelFieldIdx[BufferColor] != -1 ) |
1171 | 1198 |
{ |
1172 |
xml << "\t\t\t<buffercolor red=\"" << mLabelAttributes->bufferColor().red() |
|
1173 |
<< "\" green=\"" << mLabelAttributes->bufferColor().green() |
|
1174 |
<< "\" blue=\"" << mLabelAttributes->bufferColor().blue() |
|
1175 |
<< "\" field=\"" << mLabelFieldIdx[BufferColor] << "\" />\n"; |
|
1199 |
buffercolor.setAttribute("field", mLabelFieldIdx[BufferColor] ); |
|
1176 | 1200 |
} |
1177 | 1201 |
else |
1178 | 1202 |
{ |
1179 |
xml << "\t\t\t<buffercolor red=\"" << mLabelAttributes->bufferColor().red() |
|
1180 |
<< "\" green=\"" << mLabelAttributes->bufferColor().green() |
|
1181 |
<< "\" blue=\"" << mLabelAttributes->bufferColor().blue() |
|
1182 |
<< "\" field=\"\" />\n"; |
|
1203 |
buffercolor.setAttribute("field", "" ); |
|
1183 | 1204 |
} |
1184 | 1205 |
} |
1185 | 1206 |
else |
1186 | 1207 |
{ |
1187 |
xml << "\t\t\t<buffercolor red=\"\" green=\"\" blue=\"\" field=\"\" />\n"; |
|
1208 |
buffercolor.setAttribute("red", "" ); |
|
1209 |
buffercolor.setAttribute("green", "" ); |
|
1210 |
buffercolor.setAttribute("blue", "" ); |
|
1211 |
buffercolor.setAttribute("field", "" ); |
|
1188 | 1212 |
} |
1213 |
labelattributes.appendChild(buffercolor); |
|
1189 | 1214 | |
1190 | 1215 |
// buffer size |
1216 |
QDomElement buffersize = document.createElement("buffersize"); |
|
1191 | 1217 |
if ( mLabelAttributes->bufferSizeIsSet() ) |
1192 | 1218 |
{ |
1219 |
buffersize.setAttribute("value", mLabelAttributes->bufferSize() ); |
|
1220 |
buffersize.setAttribute("units", QgsLabelAttributes::unitsName( mLabelAttributes->bufferSizeType() ) ); |
|
1193 | 1221 |
if ( mLabelFieldIdx[BufferSize] != -1 ) |
1194 | 1222 |
{ |
1195 |
xml << "\t\t\t<buffersize value=\"" << mLabelAttributes->bufferSize() |
|
1196 |
<< "\" units=\"" << QgsLabelAttributes::unitsName( mLabelAttributes->bufferSizeType() ).toUtf8().constData() |
|
1197 |
<< "\" field=\"" << mLabelFieldIdx[BufferSize] << "\" />\n"; |
|
1223 |
buffersize.setAttribute("field", mLabelFieldIdx[BufferSize] ); |
|
1198 | 1224 |
} |
1199 | 1225 |
else |
1200 | 1226 |
{ |
1201 |
xml << "\t\t\t<buffersize value=\"" << mLabelAttributes->bufferSize() |
|
1202 |
<< "\" units=\"" << QgsLabelAttributes::unitsName( mLabelAttributes->bufferSizeType() ).toUtf8().constData() |
|
1203 |
<< "\" field=\"\" />\n"; |
|
1227 |
buffersize.setAttribute("field", "" ); |
|
1204 | 1228 |
} |
1205 | 1229 |
} |
1206 | 1230 |
else |
1207 | 1231 |
{ |
1208 |
xml << "\t\t\t<buffersize value=\"\" units=\"\" field=\"\" />\n"; |
|
1232 |
buffersize.setAttribute("value", ""); |
|
1233 |
buffersize.setAttribute("units", ""); |
|
1234 |
buffersize.setAttribute("field", ""); |
|
1209 | 1235 |
} |
1236 |
labelattributes.appendChild(buffersize); |
|
1210 | 1237 | |
1211 | 1238 |
// buffer enabled |
1239 |
QDomElement bufferenabled = document.createElement("bufferenabled"); |
|
1212 | 1240 |
if ( mLabelAttributes->bufferEnabled() ) |
1213 | 1241 |
{ |
1242 |
bufferenabled.setAttribute("on", mLabelAttributes->bufferEnabled()); |
|
1214 | 1243 |
if ( mLabelFieldIdx[BufferEnabled] != -1 ) |
1215 | 1244 |
{ |
1216 |
xml << "\t\t\t<bufferenabled on=\"" << mLabelAttributes->bufferEnabled() |
|
1217 |
<< "\" field=\"" << mLabelFieldIdx[BufferEnabled] << "\" />\n"; |
|
1245 |
bufferenabled.setAttribute("field", mLabelFieldIdx[BufferEnabled] ); |
|
1218 | 1246 |
} |
1219 | 1247 |
else |
1220 | 1248 |
{ |
1221 |
xml << "\t\t\t<bufferenabled on=\"" << mLabelAttributes->bufferEnabled() |
|
1222 |
<< "\" field=\"\" />\n"; |
|
1249 |
bufferenabled.setAttribute("field", "" ); |
|
1223 | 1250 |
} |
1224 | 1251 |
} |
1225 | 1252 |
else |
1226 | 1253 |
{ |
1227 |
xml << "\t\t\t<bufferenabled on=\"" << "\" field=\"" << "\" />\n"; |
|
1254 |
bufferenabled.setAttribute("on", "" ); |
|
1255 |
bufferenabled.setAttribute("field", "" ); |
|
1228 | 1256 |
} |
1257 |
labelattributes.appendChild( bufferenabled ); |
|
1229 | 1258 | |
1230 | 1259 |
// multiline enabled |
1260 |
QDomElement multilineenabled = document.createElement("multilineenabled"); |
|
1231 | 1261 |
if ( mLabelAttributes->multilineEnabled() ) |
1232 | 1262 |
{ |
1263 |
multilineenabled.setAttribute("on", mLabelAttributes->multilineEnabled()); |
|
1233 | 1264 |
if ( mLabelFieldIdx[MultilineEnabled] != -1 ) |
1234 | 1265 |
{ |
1235 |
xml << "\t\t\t<multilineenabled on=\"" << mLabelAttributes->multilineEnabled() |
|
1236 |
<< "\" field=\"" << mLabelFieldIdx[MultilineEnabled] << "\" />\n"; |
|
1266 |
multilineenabled.setAttribute("field", mLabelFieldIdx[MultilineEnabled] ); |
|
1237 | 1267 |
} |
1238 | 1268 |
else |
1239 | 1269 |
{ |
1240 |
xml << "\t\t\t<multilineenabled on=\"" << mLabelAttributes->multilineEnabled() |
|
1241 |
<< "\" field=\"\" />\n"; |
|
1270 |
multilineenabled.setAttribute("field", "" ); |
|
1242 | 1271 |
} |
1243 | 1272 |
} |
1244 | 1273 |
else |
1245 | 1274 |
{ |
1246 |
xml << "\t\t\t<multilineenabled on=\"" << "\" field=\"" << "\" />\n"; |
|
1275 |
multilineenabled.setAttribute("on", "" ); |
|
1276 |
multilineenabled.setAttribute("field", "" ); |
|
1247 | 1277 |
} |
1278 |
labelattributes.appendChild(multilineenabled); |
|
1248 | 1279 | |
1249 |
xml << "\t\t</labelattributes>\n";
|
|
1280 |
layer_node.appendChild(labelattributes);
|
|
1250 | 1281 |
} |
1251 | 1282 | |
1283 |
void QgsLabel::setScaleBasedVisibility( bool theVisibilityFlag ) |
|
1284 |
{ |
|
1285 |
mScaleBasedVisibility = theVisibilityFlag; |
|
1286 |
} |
|
1287 | ||
1288 |
bool QgsLabel::scaleBasedVisibility() |
|
1289 |
{ |
|
1290 |
return mScaleBasedVisibility; |
|
1291 |
} |
|
1292 | ||
1293 |
void QgsLabel::setMinScale( float theMinScale ) |
|
1294 |
{ |
|
1295 |
mMinScale = theMinScale; |
|
1296 |
} |
|
1297 | ||
1298 |
float QgsLabel::minScale() |
|
1299 |
{ |
|
1300 |
return mMinScale; |
|
1301 |
} |
|
1302 | ||
1303 |
void QgsLabel::setMaxScale( float theMaxScale ) |
|
1304 |
{ |
|
1305 |
mMaxScale = theMaxScale; |
|
1306 |
} |
|
1307 | ||
1308 |
float QgsLabel::maxScale() |
|
1309 |
{ |
|
1310 |
return mMaxScale; |
|
1311 |
} |
src/core/qgslabel.h (working copy) | ||
---|---|---|
23 | 23 |
#include <QList> |
24 | 24 |
#include <QMap> |
25 | 25 | |
26 |
#include "qgspoint.h" |
|
27 | ||
26 | 28 |
class QDomNode; |
29 |
class QDomDocument; |
|
27 | 30 |
class QString; |
28 | 31 |
class QPainter; |
29 | 32 |
class QPaintDevice; |
30 | 33 | |
31 |
class QgsPoint; |
|
32 | 34 |
class QgsFeature; |
33 | 35 |
class QgsField; |
34 | 36 |
class QgsLabelAttributes; |
... | ... | |
82 | 84 |
LabelFieldCount |
83 | 85 |
}; |
84 | 86 | |
87 |
struct labelpoint { |
|
88 |
QgsPoint p; |
|
89 |
double angle; |
|
90 |
}; |
|
91 | ||
85 | 92 |
/** \brief render label |
86 | 93 |
* \param sizeScale global scale factor for size in pixels, labels in map units are not scaled |
87 | 94 |
*/ |
... | ... | |
96 | 103 |
void readXML( const QDomNode& node ); |
97 | 104 | |
98 | 105 |
/** Writes the contents of the renderer to a configuration file */ |
99 |
void writeXML( std::ostream& xml );
|
|
106 |
void writeXML( QDomNode & label_node, QDomDocument & document );
|
|
100 | 107 | |
101 | 108 |
//! add vector of required fields to existing list of fields |
102 | 109 |
void addRequiredFields( QgsAttributeList& fields ); |
... | ... | |
123 | 130 |
*/ |
124 | 131 |
QString fieldValue( int attr, QgsFeature& feature ); |
125 | 132 | |
133 |
/** Accessor and mutator for the minimum scale member */ |
|
134 |
void setMinScale( float theMinScale ); |
|
135 |
float minScale(); |
|
136 | ||
137 |
/** Accessor and mutator for the maximum scale member */ |
|
138 |
void setMaxScale( float theMaxScale ); |
|
139 |
float maxScale(); |
|
140 | ||
141 |
/** Accessor and mutator for the scale based visilibility flag */ |
|
142 |
void setScaleBasedVisibility( bool theVisibilityFlag ); |
|
143 |
bool scaleBasedVisibility(); |
|
144 | ||
126 | 145 |
private: |
127 | 146 |
/** Does the actual rendering of a label at the given point |
128 | 147 |
* |
... | ... | |
137 | 156 |
int width, int height, int alignment, double sizeScale = 1.0 ); |
138 | 157 | |
139 | 158 |
/** Get label point for simple feature in map units */ |
140 |
void labelPoint( std::vector<QgsPoint>&, QgsFeature &feature );
|
|
159 |
void labelPoint( std::vector<labelpoint>&, QgsFeature &feature );
|
|
141 | 160 | |
142 | 161 |
/** Get label point for the given feature in wkb format. */ |
143 |
unsigned char* labelPoint( QgsPoint& point, unsigned char* wkb, size_t wkblen );
|
|
162 |
unsigned char* labelPoint( labelpoint& point, unsigned char* wkb, size_t wkblen );
|
|
144 | 163 | |
145 | 164 |
/** Color to draw selected features */ |
146 | 165 |
QColor mSelectionColor; |
... | ... | |
156 | 175 | |
157 | 176 |
//! Label field indexes |
158 | 177 |
std::vector<int> mLabelFieldIdx; |
178 | ||
179 |
/** Minimum scale at which this label should be displayed */ |
|
180 |
float mMinScale; |
|
181 |
/** Maximum scale at which this label should be displayed */ |
|
182 |
float mMaxScale; |
|
183 |
/** A flag that tells us whether to use the above vars to restrict the label's visibility */ |
|
184 |
bool mScaleBasedVisibility; |
|
159 | 185 |
}; |
160 | 186 | |
161 | 187 |
#endif |
src/core/qgslabelattributes.h (working copy) | ||
---|---|---|
140 | 140 |
bool angleIsSet( void ) const; |
141 | 141 |
double angle( void ) const; |
142 | 142 | |
143 |
bool angleIsAuto( void ) const; |
|
144 |
void setAutoAngle(bool state); |
|
145 | ||
143 | 146 |
/* Alignment */ |
144 | 147 |
void setAlignment( int alignment ); |
145 | 148 |
bool alignmentIsSet( void ) const; |
... | ... | |
207 | 210 |
/** Angle (degrees) */ |
208 | 211 |
double mAngle; |
209 | 212 |
bool mAngleIsSet; |
213 |
bool mAngleIsAuto; |
|
210 | 214 | |
211 | 215 |
/** Alignment */ |
212 | 216 |
int mAlignment; |
src/ui/qgslabeldialogbase.ui (working copy) | ||
---|---|---|
6 | 6 |
<x>0</x> |
7 | 7 |
<y>0</y> |
8 | 8 |
<width>516</width> |
9 |
<height>447</height>
|
|
9 |
<height>487</height>
|
|
10 | 10 |
</rect> |
11 | 11 |
</property> |
12 | 12 |
<property name="sizePolicy" > |
... | ... | |
19 | 19 |
<string>Form1</string> |
20 | 20 |
</property> |
21 | 21 |
<layout class="QGridLayout" > |
22 |
<property name="leftMargin" >
|
|
22 |
<property name="margin" >
|
|
23 | 23 |
<number>0</number> |
24 | 24 |
</property> |
25 |
<property name="topMargin" > |
|
26 |
<number>0</number> |
|
27 |
</property> |
|
28 |
<property name="rightMargin" > |
|
29 |
<number>0</number> |
|
30 |
</property> |
|
31 |
<property name="bottomMargin" > |
|
32 |
<number>0</number> |
|
33 |
</property> |
|
34 | 25 |
<item row="0" column="0" colspan="2" > |
35 | 26 |
<layout class="QHBoxLayout" > |
36 | 27 |
<item> |
... | ... | |
91 | 82 |
</property> |
92 | 83 |
<item> |
93 | 84 |
<property name="text" > |
94 |
<string>Font</string>
|
|
85 |
<string>General</string>
|
|
95 | 86 |
</property> |
96 | 87 |
</item> |
97 | 88 |
<item> |
... | ... | |
135 | 126 |
</sizepolicy> |
136 | 127 |
</property> |
137 | 128 |
<property name="currentIndex" > |
138 |
<number>1</number>
|
|
129 |
<number>0</number>
|
|
139 | 130 |
</property> |
140 | 131 |
<widget class="QWidget" name="page" > |
132 |
<property name="geometry" > |
|
133 |
<rect> |
|
134 |
<x>0</x> |
|
135 |
<y>0</y> |
|
136 |
<width>309</width> |
|
137 |
<height>394</height> |
|
138 |
</rect> |
|
139 |
</property> |
|
141 | 140 |
<layout class="QGridLayout" > |
142 | 141 |
<item row="0" column="0" > |
143 | 142 |
<layout class="QGridLayout" > |
... | ... | |
236 | 235 |
<string>Placement</string> |
237 | 236 |
</property> |
238 | 237 |
<layout class="QGridLayout" > |
239 |
<property name="leftMargin" >
|
|
238 |
<property name="margin" >
|
|
240 | 239 |
<number>11</number> |
241 | 240 |
</property> |
242 |
<property name="topMargin" > |
|
243 |
<number>11</number> |
|
244 |
</property> |
|
245 |
<property name="rightMargin" > |
|
246 |
<number>11</number> |
|
247 |
</property> |
|
248 |
<property name="bottomMargin" > |
|
249 |
<number>11</number> |
|
250 |
</property> |
|
251 | 241 |
<item row="2" column="2" > |
252 | 242 |
<widget class="QRadioButton" name="radioBelowRight" > |
253 | 243 |
<property name="text" > |
... | ... | |
345 | 335 |
<property name="orientation" > |
346 | 336 |
<enum>Qt::Vertical</enum> |
347 | 337 |
</property> |
348 |
<property name="sizeHint" > |
|
338 |
<property name="sizeHint" stdset="0" >
|
|
349 | 339 |
<size> |
350 | 340 |
<width>20</width> |
351 | 341 |
<height>40</height> |
... | ... | |
353 | 343 |
</property> |
354 | 344 |
</spacer> |
355 | 345 |
</item> |
346 |
<item row="4" column="0" > |
|
347 |
<widget class="QGroupBox" name="chkUseScaleDependentRendering" > |
|
348 |
<property name="title" > |
|
349 |
<string>Use scale dependent rendering</string> |
|
350 |
</property> |
|
351 |
<property name="checkable" > |
|
352 |
<bool>true</bool> |
|
353 |
</property> |
|
354 |
<layout class="QGridLayout" > |
|
355 |
<property name="margin" > |
|
356 |
<number>11</number> |
|
357 |
</property> |
|
358 |
<item row="0" column="2" > |
|
359 |
<widget class="QLabel" name="textLabel1_2_2_1" > |
|
360 |
<property name="text" > |
|
361 |
<string>Maximum</string> |
|
362 |
</property> |
|
363 |
<property name="buddy" > |
|
364 |
<cstring>spinMaximumScale</cstring> |
|
365 |
</property> |
|
366 |
</widget> |
|
367 |
</item> |
|
368 |
<item row="0" column="0" > |
|
369 |
<widget class="QLabel" name="textLabel1_1" > |
|
370 |
<property name="text" > |
|
371 |
<string>Minimum</string> |
|
372 |
</property> |
|
373 |
<property name="buddy" > |
|
374 |
<cstring>spinMinimumScale</cstring> |
|
375 |
</property> |
|
376 |
</widget> |
|
377 |
</item> |
|
378 |
<item row="0" column="1" > |
|
379 |
<widget class="QSpinBox" name="spinMinimumScale" > |
|
380 |
<property name="toolTip" > |
|
381 |
<string>Minimum scale at which this layer will be displayed. </string> |
|
382 |
</property> |
|
383 |
<property name="minimum" > |
|
384 |
<number>1</number> |
|
385 |
</property> |
|
386 |
<property name="maximum" > |
|
387 |
<number>100000000</number> |
|
388 |
</property> |
|
389 |
</widget> |
|
390 |
</item> |
|
391 |
<item row="0" column="3" > |
|
392 |
<widget class="QSpinBox" name="spinMaximumScale" > |
|
393 |
<property name="toolTip" > |
|
394 |
<string>Maximum scale at which this layer will be displayed. </string> |
|
395 |
</property> |
|
396 |
<property name="minimum" > |
|
397 |
<number>1</number> |
|
398 |
</property> |
|
399 |
<property name="maximum" > |
|
400 |
<number>100000000</number> |
|
401 |
</property> |
|
402 |
</widget> |
|
403 |
</item> |
|
404 |
</layout> |
|
405 |
</widget> |
|
406 |
</item> |
|
407 |
<item row="5" column="0" > |
|
408 |
<widget class="QCheckBox" name="chkUseMultiline" > |
|
409 |
<property name="text" > |
|
410 |
<string>Multiline labels?</string> |
|
411 |
</property> |
|
412 |
<property name="checked" > |
|
413 |
<bool>true</bool> |
|
414 |
</property> |
|
415 |
</widget> |
|
416 |
</item> |
|
356 | 417 |
</layout> |
357 | 418 |
</widget> |
358 | 419 |
<widget class="QWidget" name="page_2" > |
420 |
<property name="geometry" > |
|
421 |
<rect> |
|
422 |
<x>0</x> |
|
423 |
<y>0</y> |
|
424 |
<width>309</width> |
|
425 |
<height>394</height> |
|
426 |
</rect> |
|
427 |
</property> |
|
359 | 428 |
<layout class="QGridLayout" > |
360 | 429 |
<item row="0" column="0" > |
361 | 430 |
<widget class="QCheckBox" name="chkUseBuffer" > |
... | ... | |
449 | 518 |
</widget> |
450 | 519 |
</item> |
451 | 520 |
<item row="5" column="0" > |
452 |
<widget class="QCheckBox" name="chkUseMultiline" > |
|
453 |
<property name="text" > |
|
454 |
<string>Multiline labels?</string> |
|
455 |
</property> |
|
456 |
<property name="checked" > |
|
457 |
<bool>true</bool> |
|
458 |
</property> |
|
459 |
</widget> |
|
460 |
</item> |
|
461 |
<item row="6" column="0" > |
|
462 | 521 |
<spacer> |
463 | 522 |
<property name="orientation" > |
464 | 523 |
<enum>Qt::Vertical</enum> |
465 | 524 |
</property> |
466 |
<property name="sizeHint" > |
|
525 |
<property name="sizeHint" stdset="0" >
|
|
467 | 526 |
<size> |
468 | 527 |
<width>20</width> |
469 | 528 |
<height>40</height> |
... | ... | |
474 | 533 |
</layout> |
475 | 534 |
</widget> |
476 | 535 |
<widget class="QWidget" name="page_3" > |
536 |
<property name="geometry" > |
|
537 |
<rect> |
|
538 |
<x>0</x> |
|
539 |
<y>0</y> |
|
540 |
<width>100</width> |
|
541 |
<height>30</height> |
|
542 |
</rect> |
|
543 |
</property> |
|
477 | 544 |
<layout class="QGridLayout" > |
478 | 545 |
<item row="0" column="0" > |
479 | 546 |
<widget class="QLabel" name="textLabel1_2_3_2" > |
... | ... | |
531 | 598 |
<property name="orientation" > |
532 | 599 |
<enum>Qt::Vertical</enum> |
533 | 600 |
</property> |
534 |
<property name="sizeHint" > |
|
601 |
<property name="sizeHint" stdset="0" >
|
|
535 | 602 |
<size> |
536 | 603 |
<width>20</width> |
537 | 604 |
<height>181</height> |
... | ... | |
542 | 609 |
</layout> |
543 | 610 |
</widget> |
544 | 611 |
<widget class="QWidget" name="page_4" > |
612 |
<property name="geometry" > |
|
613 |
<rect> |
|
614 |
<x>0</x> |
|
615 |
<y>0</y> |
|
616 |
<width>100</width> |
|
617 |
<height>30</height> |
|
618 |
</rect> |
|
619 |
</property> |
|
545 | 620 |
<layout class="QGridLayout" > |
546 | 621 |
<item row="0" column="0" > |
547 | 622 |
<widget class="QLabel" name="lblFont" > |
... | ... | |
728 | 803 |
</layout> |
729 | 804 |
</widget> |
730 | 805 |
<widget class="QWidget" name="page_5" > |
806 |
<property name="geometry" > |
|
807 |
<rect> |
|
808 |
<x>0</x> |
|
809 |
<y>0</y> |
|
810 |
<width>100</width> |
|
811 |
<height>30</height> |
|
812 |
</rect> |
|
813 |
</property> |
|
731 | 814 |
<layout class="QGridLayout" > |
732 | 815 |
<item row="0" column="0" > |
733 | 816 |
<widget class="QLabel" name="textLabel1_2_2_2_2_3" > |
... | ... | |
764 | 847 |
</layout> |
765 | 848 |
</widget> |
766 | 849 |
<widget class="QWidget" name="page_6" > |
850 |
<property name="geometry" > |
|
851 |
<rect> |
|
852 |
<x>0</x> |
|
853 |
<y>0</y> |
|
854 |
<width>100</width> |
|
855 |
<height>30</height> |
|
856 |
</rect> |
|
857 |
</property> |
|
767 | 858 |
<layout class="QGridLayout" > |
768 | 859 |
<item row="0" column="0" > |
769 | 860 |
<widget class="QLabel" name="textLabel1_3_2_2_2" > |
... | ... | |
819 | 910 |
</layout> |
820 | 911 |
</widget> |
821 | 912 |
<widget class="QWidget" name="page_7" > |
913 |
<property name="geometry" > |
|
914 |
<rect> |
|
915 |
<x>0</x> |
|
916 |
<y>0</y> |
|
917 |
<width>100</width> |
|
918 |
<height>30</height> |
|
919 |
</rect> |
|
920 |
</property> |
|
822 | 921 |
<layout class="QGridLayout" > |
823 | 922 |
<item row="0" column="0" > |
824 | 923 |
<widget class="QLabel" name="textLabel1_2" > |
... | ... | |
900 | 999 |
<string>Preview:</string> |
901 | 1000 |
</property> |
902 | 1001 |
<layout class="QGridLayout" > |
903 |
<property name="leftMargin" >
|
|
1002 |
<property name="margin" >
|
|
904 | 1003 |
<number>11</number> |
905 | 1004 |
</property> |
906 |
<property name="topMargin" > |
|
907 |
<number>11</number> |
|
908 |
</property> |
|
909 |
<property name="rightMargin" > |
|
910 |
<number>11</number> |
|
911 |
</property> |
|
912 |
<property name="bottomMargin" > |
|
913 |
<number>11</number> |
|
914 |
</property> |
|
915 | 1005 |
<item row="0" column="0" > |
916 | 1006 |
<widget class="QLabel" name="lblSample" > |
917 | 1007 |
<property name="text" > |