Skip to content

Commit 8645462

Browse files
author
morb_au
committedJul 14, 2006
When in Editing mode, the overview window no longer shows vertex markers. It used to, which generally made it overcrowded. This commit now only shows the vertex markers on the main canvas. In theory, this should also mean that the map composer window also doesn't show vertex markers any more (which should be a good thing), though I haven't tested it.
git-svn-id: http://svn.osgeo.org/qgis/trunk@5593 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8c38434 commit 8645462

File tree

8 files changed

+159
-64
lines changed

8 files changed

+159
-64
lines changed
 

‎src/composer/qgscomposermap.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ void QgsComposerMap::draw ( QPainter *painter, QgsRect *extent, QgsMapToPixel *t
126126
QgsRect r1, r2;
127127
r1 = *extent;
128128
bool split = layer->projectExtent(r1, r2);
129-
vector->draw( painter, &r1, transform, widthScale, symbolScale);
129+
vector->draw( painter, &r1, transform, FALSE, widthScale, symbolScale);
130130

131131
if ( split )
132132
{
133-
vector->draw( painter, &r2, transform, widthScale, symbolScale);
133+
vector->draw( painter, &r2, transform, FALSE, widthScale, symbolScale);
134134
}
135135
} else {
136136
// raster
@@ -147,13 +147,13 @@ void QgsComposerMap::draw ( QPainter *painter, QgsRect *extent, QgsMapToPixel *t
147147
painter->save();
148148
painter->scale( 1./multip, 1./multip);
149149

150-
layer->draw( painter, extent, &trans);
150+
layer->draw( painter, extent, &trans, FALSE);
151151

152152
painter->restore();
153153
}
154154
else
155155
{
156-
layer->draw( painter, extent, transform);
156+
layer->draw( painter, extent, transform, FALSE);
157157
}
158158
}
159159
}

‎src/gui/qgsmaplayer.cpp

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform)
161161
// std::cout << "In QgsMapLayer::draw" << std::endl;
162162
}
163163

164-
bool QgsMapLayer::draw(QPainter *, QgsRect *, QgsMapToPixel *)
164+
bool QgsMapLayer::draw(QPainter *, QgsRect *, QgsMapToPixel *, bool)
165165
{
166166
// std::cout << "In QgsMapLayer::draw" << std::endl;
167167
return false;
@@ -450,23 +450,32 @@ void QgsMapLayer::inOverview( bool b )
450450

451451
void QgsMapLayer::updateItemPixmap()
452452
{
453-
if (mLegendLayerFile)
453+
if (mLegendLayerFile)
454+
{
455+
QPixmap originalPix=mLegendLayerFile->getOriginalPixmap();
456+
457+
if(mShowInOverview)
454458
{
455-
QPixmap pix=mLegendLayerFile->getOriginalPixmap();
456-
if(mShowInOverview)
457-
{
458-
//add overview glasses to the pixmap
459-
QPainter p(&pix);
460-
p.drawPixmap(0,0,mInOverviewPixmap);
461-
}
462-
if(isEditable())
463-
{
464-
//add editing icon to the pixmap
465-
QPainter p(&pix);
466-
p.drawPixmap(30,0,mEditablePixmap);
467-
}
468-
mLegendLayerFile->setLegendPixmap(pix);
459+
//add overview glasses to the pixmap
460+
mLegendLayerFile->setOverviewPixmap(mInOverviewPixmap);
469461
}
462+
else
463+
{
464+
mLegendLayerFile->setOverviewPixmap( QPixmap() );
465+
}
466+
467+
if(isEditable())
468+
{
469+
//add editing icon to the pixmap
470+
mLegendLayerFile->setEditingPixmap(mEditablePixmap);
471+
}
472+
else
473+
{
474+
mLegendLayerFile->setEditingPixmap( QPixmap() );
475+
}
476+
477+
mLegendLayerFile->setLegendPixmap(originalPix);
478+
}
470479
}
471480

472481
void QgsMapLayer::invalidTransformInput()
@@ -477,7 +486,7 @@ void QgsMapLayer::invalidTransformInput()
477486
QPixmap pix=mLegendLayerFile->getOriginalPixmap();
478487
if(mShowInOverview)
479488
{
480-
//add overview glasses to the pixmap
489+
//add project error icon to the pixmap
481490
QPainter p(&pix);
482491
p.drawPixmap(60,0,mProjectionErrorPixmap);
483492
}

‎src/gui/qgsmaplayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class QgsMapLayer : public QObject
103103
virtual void draw(QPainter *, QgsRect *, int);
104104

105105
//! Returns FALSE if an error occurred during drawing
106-
virtual bool draw(QPainter *, QgsRect *, QgsMapToPixel *);
106+
virtual bool draw(QPainter *, QgsRect *, QgsMapToPixel *, bool);
107107
virtual void drawLabels(QPainter *, QgsRect *, QgsMapToPixel *);
108108

109109
/*!Select features on the map canvas by dragging a rectangle */

‎src/gui/qgsmaprender.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ void QgsMapRender::render(QPainter* painter)
259259
// Now do the call to the layer that actually does
260260
// the rendering work!
261261
//
262-
if (!ml->draw(painter, &r1, mCoordXForm))
262+
if (!ml->draw(painter, &r1, mCoordXForm, !mOverview))
263263
emit drawError(ml);
264264

265265
if (split)
266266
{
267-
if (!ml->draw(painter, &r2, mCoordXForm))
267+
if (!ml->draw(painter, &r2, mCoordXForm, !mOverview))
268268
emit drawError(ml);
269269
}
270270

‎src/gui/qgsvectorlayer.cpp

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ QgsRect QgsVectorLayer::inverseProjectRect(const QgsRect& r) const
431431
unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
432432
QPainter* p,
433433
QgsMapToPixel* mtp,
434-
bool projectionsEnabledFlag)
434+
bool projectionsEnabledFlag,
435+
bool drawingToEditingCanvas)
435436
{
436437
unsigned char *ptr = feature + 5;
437438
unsigned int nPoints = *((int*)ptr);
@@ -503,7 +504,11 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
503504
p->setPen(myTransparentPen);
504505
p->drawPolyline(pa);
505506

506-
if(mEditable)
507+
// draw vertex markers if in editing mode, but only to the main canvas
508+
if (
509+
(mEditable) &&
510+
(drawingToEditingCanvas)
511+
)
507512
{
508513
std::vector<double>::const_iterator xIt;
509514
std::vector<double>::const_iterator yIt;
@@ -522,7 +527,8 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
522527
unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
523528
QPainter* p,
524529
QgsMapToPixel* mtp,
525-
bool projectionsEnabledFlag)
530+
bool projectionsEnabledFlag,
531+
bool drawingToEditingCanvas)
526532
{
527533
typedef std::pair<std::vector<double>, std::vector<double> > ringType;
528534
typedef ringType* ringTypePtr;
@@ -762,7 +768,11 @@ std::cerr << i << ": " << ring->first[i]
762768
for (; ri != ringDetails.end(); ++ri)
763769
p->drawPolygon(pa.constData() + ri->first, ri->second, Qt::OddEvenFill);
764770

765-
if(mEditable)//draw the vertex markers
771+
// draw vertex markers if in editing mode, but only to the main canvas
772+
if (
773+
(mEditable) &&
774+
(drawingToEditingCanvas)
775+
)
766776
{
767777
for(int i = 0; i < pa.size(); ++i)
768778
{
@@ -782,15 +792,27 @@ std::cerr << i << ": " << ring->first[i]
782792
}
783793

784794

785-
bool QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * theMapToPixelTransform)
795+
bool QgsVectorLayer::draw(QPainter * p,
796+
QgsRect * viewExtent,
797+
QgsMapToPixel * theMapToPixelTransform,
798+
bool drawingToEditingCanvas)
786799
{
787-
draw ( p, viewExtent, theMapToPixelTransform, 1., 1.);
800+
draw(p,
801+
viewExtent,
802+
theMapToPixelTransform,
803+
drawingToEditingCanvas,
804+
1.,
805+
1.);
788806

789807
return TRUE; // Assume success always
790808
}
791809

792-
void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * theMapToPixelTransform,
793-
double widthScale, double symbolScale)
810+
void QgsVectorLayer::draw(QPainter * p,
811+
QgsRect * viewExtent,
812+
QgsMapToPixel * theMapToPixelTransform,
813+
bool drawingToEditingCanvas,
814+
double widthScale,
815+
double symbolScale)
794816
{
795817
if(m_renderer)
796818
{
@@ -889,7 +911,13 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th
889911

890912
m_renderer->renderFeature(p, fet, &marker, &markerScaleFactor, sel, widthScale );
891913
double scale = markerScaleFactor * symbolScale;
892-
drawFeature(p,fet,theMapToPixelTransform,&marker, scale, projectionsEnabledFlag);
914+
drawFeature(p,
915+
fet,
916+
theMapToPixelTransform,
917+
&marker,
918+
scale,
919+
projectionsEnabledFlag,
920+
drawingToEditingCanvas);
893921
++featureCount;
894922
delete fet;
895923
}
@@ -909,7 +937,13 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th
909937
//give a deep copy of the geometry to mCachedGeometry because it will be erased at each redraw
910938
QgsGeometry* deepCopy = new QgsGeometry(*((*it)->geometry()));
911939
mCachedGeometries.insert(std::make_pair((*it)->featureId(), deepCopy));
912-
drawFeature(p,*it,theMapToPixelTransform,&marker,scale, projectionsEnabledFlag);
940+
drawFeature(p,
941+
*it,
942+
theMapToPixelTransform,
943+
&marker,
944+
scale,
945+
projectionsEnabledFlag,
946+
drawingToEditingCanvas);
913947
}
914948
}
915949
}
@@ -3191,8 +3225,13 @@ QgsGeometry& snappedGeometry, double tolerance)
31913225
}
31923226

31933227

3194-
void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * theMapToPixelTransform,
3195-
QPixmap * marker, double markerScaleFactor, bool projectionsEnabledFlag)
3228+
void QgsVectorLayer::drawFeature(QPainter* p,
3229+
QgsFeature* fet,
3230+
QgsMapToPixel * theMapToPixelTransform,
3231+
QPixmap * marker,
3232+
double markerScaleFactor,
3233+
bool projectionsEnabledFlag,
3234+
bool drawingToEditingCanvas)
31963235
{
31973236
// Only have variables, etc outside the switch() statement that are
31983237
// used in all cases of the statement (otherwise they may get
@@ -3274,8 +3313,11 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
32743313
}
32753314
case WKBLineString:
32763315
{
3277-
drawLineString(feature, p, theMapToPixelTransform,
3278-
projectionsEnabledFlag);
3316+
drawLineString(feature,
3317+
p,
3318+
theMapToPixelTransform,
3319+
projectionsEnabledFlag,
3320+
drawingToEditingCanvas);
32793321
break;
32803322
}
32813323
case WKBMultiLineString:
@@ -3286,15 +3328,21 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
32863328

32873329
for (register unsigned int jdx = 0; jdx < numLineStrings; jdx++)
32883330
{
3289-
ptr = drawLineString(ptr, p, theMapToPixelTransform,
3290-
projectionsEnabledFlag);
3331+
ptr = drawLineString(ptr,
3332+
p,
3333+
theMapToPixelTransform,
3334+
projectionsEnabledFlag,
3335+
drawingToEditingCanvas);
32913336
}
32923337
break;
32933338
}
32943339
case WKBPolygon:
32953340
{
3296-
drawPolygon(feature, p, theMapToPixelTransform,
3297-
projectionsEnabledFlag);
3341+
drawPolygon(feature,
3342+
p,
3343+
theMapToPixelTransform,
3344+
projectionsEnabledFlag,
3345+
drawingToEditingCanvas);
32983346
break;
32993347
}
33003348
case WKBMultiPolygon:
@@ -3303,8 +3351,11 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
33033351
unsigned int numPolygons = *((int*)ptr);
33043352
ptr = feature + 9;
33053353
for (register unsigned int kdx = 0; kdx < numPolygons; kdx++)
3306-
ptr = drawPolygon(ptr, p, theMapToPixelTransform,
3307-
projectionsEnabledFlag);
3354+
ptr = drawPolygon(ptr,
3355+
p,
3356+
theMapToPixelTransform,
3357+
projectionsEnabledFlag,
3358+
drawingToEditingCanvas);
33083359
break;
33093360
}
33103361
default:

‎src/gui/qgsvectorlayer.h

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,12 @@ public slots:
446446
* \param widthScale line width scale
447447
* \param symbolScale symbol scale
448448
*/
449-
void draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf, double widthScale, double symbolScale);
449+
void draw(QPainter * p,
450+
QgsRect * viewExtent,
451+
QgsMapToPixel * cXf,
452+
bool drawingToEditingCanvas,
453+
double widthScale,
454+
double symbolScale);
450455

451456
/** \brief Draws the layer labels using coordinate transformation
452457
* \param scale size scale, applied to all values in pixels
@@ -538,9 +543,17 @@ protected slots:
538543

539544
private: // Private attributes
540545

541-
//! Draws features. May cause projections exceptions to be generated
542-
// (i.e., code that calls this function needs to catch them
543-
void drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * cXf, QPixmap* marker, double markerScaleFactor, bool projectionsEnabledFlag );
546+
//! Draws features.
547+
/** \note May cause projections exceptions to be generated
548+
(i.e., code that calls this function needs to catch them
549+
*/
550+
void drawFeature(QPainter* p,
551+
QgsFeature* fet,
552+
QgsMapToPixel * cXf,
553+
QPixmap* marker,
554+
double markerScaleFactor,
555+
bool projectionsEnabledFlag,
556+
bool drawingToEditingCanvas);
544557

545558
private: // Private attributes
546559

@@ -562,14 +575,19 @@ protected slots:
562575
// Draw the linestring as given in the WKB format. Returns a pointer
563576
// to the byte after the end of the line string binary data stream
564577
// (WKB).
565-
unsigned char* drawLineString(unsigned char* WKBlinestring, QPainter* p,
566-
QgsMapToPixel* mtp,
567-
bool projectionsEnabledFlag);
578+
unsigned char* drawLineString(unsigned char* WKBlinestring,
579+
QPainter* p,
580+
QgsMapToPixel* mtp,
581+
bool projectionsEnabledFlag,
582+
bool drawingToEditingCanvas);
568583

569584
// Draw the polygon as given in the WKB format. Returns a pointer to
570585
// the byte after the end of the polygon binary data stream (WKB).
571-
unsigned char* drawPolygon(unsigned char* WKBpolygon, QPainter* p,
572-
QgsMapToPixel* mtp, bool projectionsEnabledFlag);
586+
unsigned char* drawPolygon(unsigned char* WKBpolygon,
587+
QPainter* p,
588+
QgsMapToPixel* mtp,
589+
bool projectionsEnabledFlag,
590+
bool drawingToEditingCanvas);
573591

574592
/** tailor the right-click context menu with vector layer only stuff
575593
@@ -578,8 +596,15 @@ protected slots:
578596
void initContextMenu_(QgisApp *);
579597

580598
//! Draws the layer using coordinate transformation
581-
//! Returns FALSE if an error occurred during drawing
582-
bool draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf);
599+
/**
600+
\param drawingToEditingCanvas Are we drawing to an editable canvas?
601+
602+
\return FALSE if an error occurred during drawing
603+
*/
604+
bool draw(QPainter * p,
605+
QgsRect * viewExtent,
606+
QgsMapToPixel * cXf,
607+
bool drawingToEditingCanvas);
583608

584609
//! Pointer to data provider derived from the abastract base class QgsDataProvider
585610
QgsVectorDataProvider *dataProvider;
@@ -609,7 +634,8 @@ protected slots:
609634
void cacheGeometries();
610635
/**Deletes the geometries in mCachedGeometries*/
611636
void deleteCachedGeometries();
612-
/**Draws a vertex symbol at (screen) coordinates x, y*/
637+
638+
/** Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.) */
613639
void drawVertexMarker(int x, int y, QPainter& p);
614640

615641
// pointer for loading the provider library

‎src/raster/qgsrasterlayer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,8 @@ QPixmap QgsRasterLayer::getPaletteAsPixmap()
10281028

10291029
bool QgsRasterLayer::draw(QPainter * theQPainter,
10301030
QgsRect * theViewExtent,
1031-
QgsMapToPixel * theQgsMapToPixel)
1031+
QgsMapToPixel * theQgsMapToPixel,
1032+
bool drawingToEditingCanvas)
10321033
{
10331034
QgsDebugMsg("QgsRasterLayer::draw(4 arguments): entered.");
10341035

@@ -1377,9 +1378,9 @@ __FUNCTION__, __LINE__, 1);
13771378

13781379
}
13791380

1380-
void QgsRasterLayer::draw (QPainter * theQPainter,
1381-
QgsRasterViewPort * theRasterViewPort,
1382-
QgsMapToPixel * theQgsMapToPixel)
1381+
void QgsRasterLayer::draw(QPainter * theQPainter,
1382+
QgsRasterViewPort * theRasterViewPort,
1383+
QgsMapToPixel * theQgsMapToPixel)
13831384
{
13841385
QgsDebugMsg("QgsRasterLayer::draw (3 arguments)");
13851386
//

‎src/raster/qgsrasterlayer.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,20 @@ class QgsRasterLayer : public QgsMapLayer
301301
/** \brief Get an 8x8 pixmap of the colour palette. If the layer has no palette a white pixmap will be returned. */
302302
QPixmap getPaletteAsPixmap();
303303

304-
/** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn). */
305-
bool draw(QPainter * theQPainter, QgsRect * theViewExtent,
306-
QgsMapToPixel * theQgsMapToPixel);
304+
/** \brief This is called when the view on the rasterlayer needs to be refreshed (redrawn).
305+
306+
\param drawingToEditingCanvas Are we drawing to an editable canvas?
307+
currently not used, but retain to be similar to
308+
the QgsVectorLayer interface
309+
*/
310+
bool draw(QPainter * theQPainter,
311+
QgsRect * theViewExtent,
312+
QgsMapToPixel * theQgsMapToPixel,
313+
bool drawingToEditingCanvas);
307314

308315
/** \brief This is an overloaded version of the above function that is called by both draw above and drawThumbnail */
309-
void draw(QPainter * theQPainter, QgsRasterViewPort * myRasterViewPort,
316+
void draw(QPainter * theQPainter,
317+
QgsRasterViewPort * myRasterViewPort,
310318
QgsMapToPixel * theQgsMapToPixel = 0);
311319

312320
//

0 commit comments

Comments
 (0)
Please sign in to comment.