bug297fix.diff

Jürgen Fischer, 2007-12-10 01:40 PM

Download (6.55 KB)

View differences:

src/app/qgsoptions.cpp (Arbeitskopie)
142 142

  
143 143
  cbxSplitterRedraw->setChecked(settings.value("/qgis/splitterRedraw", QVariant(true)).toBool());
144 144

  
145
  cbxInteriorLabels->setChecked(settings.value("/qgis/interiorLabels", QVariant(false)).toBool());
146

  
145 147
  //
146 148
  // Locale settings 
147 149
  //
......
262 264
  settings.writeEntry("/qgis/zoom_factor", spinZoomFactor->value());
263 265

  
264 266
  settings.setValue("/qgis/splitterRedraw", cbxSplitterRedraw->isChecked());  
267
  settings.setValue("/qgis/interiorLabels", cbxInteriorLabels->isChecked());  
268

  
265 269
  //
266 270
  // Locale settings 
267 271
  //
src/core/qgsgeometry.cpp (Arbeitskopie)
2276 2276
  return sqrDist;
2277 2277
}                 
2278 2278

  
2279
void QgsGeometry::interiorPoints(std::vector<QgsPoint> &points)
2280
{
2281
  exportWkbToGeos();
2282

  
2283
  points.clear();
2284

  
2285
  for(size_t i=0; i<mGeos->getNumGeometries(); i++) {
2286
    GEOS_GEOM::Point *p = mGeos->getGeometryN(i)->getInteriorPoint();
2287
    points.push_back( QgsPoint( p->getX(), p->getY() ) );
2288
  }
2289
}
2290

  
2279 2291
int QgsGeometry::addRing(const QList<QgsPoint>& ring)
2280 2292
{
2281 2293
  //bail out if this geometry is not polygon/multipolygon
......
3159 3171

  
3160 3172
bool QgsGeometry::exportWkbToGeos()
3161 3173
{
3162
  QgsDebugMsg("QgsGeometry::exportWkbToGeos: entered.");
3174
  // QgsDebugMsg("QgsGeometry::exportWkbToGeos: entered.");
3163 3175

  
3164 3176
  if (!mDirtyGeos)
3165 3177
  {
......
3238 3250
      hasZValue = true;
3239 3251
    case QGis::WKBLineString:
3240 3252
      {
3241
        QgsDebugMsg("QgsGeometry::geosGeometry: Linestring found");
3253
        // QgsDebugMsg("QgsGeometry::geosGeometry: Linestring found");
3242 3254

  
3243 3255
        GEOS_GEOM::DefaultCoordinateSequence* sequence=new GEOS_GEOM::DefaultCoordinateSequence();
3244 3256
        ptr = mGeometry + 5;
......
3299 3311
      hasZValue = true;
3300 3312
    case QGis::WKBPolygon: 
3301 3313
      {
3302
        QgsDebugMsg("Polygon found");
3314
        // QgsDebugMsg("Polygon found");
3303 3315

  
3304 3316
        // get number of rings in the polygon
3305 3317
        numRings = (int *) (mGeometry + 1 + sizeof(int));
......
3349 3361
      hasZValue = true;
3350 3362
    case QGis::WKBMultiPolygon:
3351 3363
      {
3352
        QgsDebugMsg("Multipolygon found");
3364
        //QgsDebugMsg("Multipolygon found");
3353 3365

  
3354 3366
        std::vector<GEOS_GEOM::Geometry *> *polygons=new std::vector<GEOS_GEOM::Geometry *>;
3355 3367
        // get the number of polygons
src/core/qgslabel.cpp (Arbeitskopie)
19 19
#include <QString>
20 20
#include <QFont>
21 21
#include <QFontMetrics>
22
#include <QSettings>
22 23

  
23 24
#include <QPainter>
24 25
#include <QDomNode>
......
457 458

  
458 459
void QgsLabel::labelPoint ( std::vector<QgsPoint>& points, QgsFeature & feature )
459 460
{
460
  QgsGeometry* geometry = feature.geometry();
461
  unsigned char *geom = geometry->wkbBuffer();
462
  QGis::WKBTYPE wkbType = geometry->wkbType();
461
  QSettings settings;
462
  if( settings.value("/qgis/interiorLabels").toBool() )
463
  {
464
    feature.geometry()->interiorPoints(points);
465
  }
466
  else
467
  {
468
    QgsGeometry* geometry = feature.geometry();
469
    unsigned char *geom = geometry->wkbBuffer();
470
    QGis::WKBTYPE wkbType = geometry->wkbType();
463 471
  
464
  QgsPoint point;
472
    QgsPoint point;
465 473

  
466
  switch (wkbType)
467
  {
468
  case QGis::WKBPoint25D:
469
  case QGis::WKBPoint:
470
  case QGis::WKBLineString25D:
471
  case QGis::WKBLineString:
472
  case QGis::WKBPolygon25D:
473
  case QGis::WKBPolygon:
474
    switch (wkbType)
474 475
    {
475
      labelPoint(point, geom);
476
      points.push_back(point);
477
    }
478
    break;
479
  case QGis::WKBMultiPoint25D:
480
  case QGis::WKBMultiPoint:
481
  case QGis::WKBMultiLineString25D:
482
  case QGis::WKBMultiLineString:
483
  case QGis::WKBMultiPolygon25D:
484
  case QGis::WKBMultiPolygon:
485
    // Return a position for each individual in the multi-feature
486
    {
487
      int numFeatures = (int)(*(geom + 5));
488
      geom += 9; // now points to start of array of WKB's
489
      for (int i = 0; i < numFeatures; ++i)
476
    case QGis::WKBPoint25D:
477
    case QGis::WKBPoint:
478
    case QGis::WKBLineString25D:
479
    case QGis::WKBLineString:
480
    case QGis::WKBPolygon25D:
481
    case QGis::WKBPolygon:
490 482
      {
491
        geom = labelPoint(point, geom);
483
        labelPoint(point, geom);
492 484
        points.push_back(point);
493 485
      }
486
      break;
487
    case QGis::WKBMultiPoint25D:
488
    case QGis::WKBMultiPoint:
489
    case QGis::WKBMultiLineString25D:
490
    case QGis::WKBMultiLineString:
491
    case QGis::WKBMultiPolygon25D:
492
    case QGis::WKBMultiPolygon:
493
      // Return a position for each individual in the multi-feature
494
      {
495
        int numFeatures = (int)(*(geom + 5));
496
        geom += 9; // now points to start of array of WKB's
497
        for (int i = 0; i < numFeatures; ++i)
498
        {
499
          geom = labelPoint(point, geom);
500
          points.push_back(point);
501
        }
502
      }
503
      break;
504
    default:
505
      QgsDebugMsg("Unknown geometry type of " + QString::number(wkbType));
494 506
    }
495
    break;
496
  default:
497
    QgsDebugMsg("Unknown geometry type of " + QString::number(wkbType));
498 507
  }
499 508
}
500 509

  
src/core/qgsgeometry.h (Arbeitskopie)
236 236
                                     QgsPoint& minDistPoint,
237 237
                                     QgsGeometryVertexIndex& beforeVertex);
238 238

  
239
    /**
240
     * Get interior points (e.g. for labels)
241
     */
242
    void interiorPoints(std::vector<QgsPoint>& points);
243

  
239 244
    /**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
240 245
     @return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed, \
241 246
     3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/
src/ui/qgsoptionsbase.ui (Arbeitskopie)
427 427
            </property>
428 428
           </widget>
429 429
          </item>
430
          <item>
431
           <widget class="QCheckBox" name="cbxInteriorLabels" >
432
            <property name="text" >
433
             <string>Render labels inside areas (slower)</string>
434
            </property>
435
           </widget>
436
          </item>
430 437
         </layout>
431 438
        </widget>
432 439
       </item>