Skip to content
Permalink
Browse files
When in Editing mode, the overview window no longer shows vertex mark…
…ers. 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
  • Loading branch information
morb_au committed Jul 14, 2006
1 parent 8c38434 commit 8645462bf2cd961e9e451834d7c890eaefbdd3fb
Showing with 159 additions and 64 deletions.
  1. +4 −4 src/composer/qgscomposermap.cpp
  2. +26 −17 src/gui/qgsmaplayer.cpp
  3. +1 −1 src/gui/qgsmaplayer.h
  4. +2 −2 src/gui/qgsmaprender.cpp
  5. +71 −20 src/gui/qgsvectorlayer.cpp
  6. +38 −12 src/gui/qgsvectorlayer.h
  7. +5 −4 src/raster/qgsrasterlayer.cpp
  8. +12 −4 src/raster/qgsrasterlayer.h
@@ -126,11 +126,11 @@ void QgsComposerMap::draw ( QPainter *painter, QgsRect *extent, QgsMapToPixel *t
QgsRect r1, r2;
r1 = *extent;
bool split = layer->projectExtent(r1, r2);
vector->draw( painter, &r1, transform, widthScale, symbolScale);
vector->draw( painter, &r1, transform, FALSE, widthScale, symbolScale);

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

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

painter->restore();
}
else
{
layer->draw( painter, extent, transform);
layer->draw( painter, extent, transform, FALSE);
}
}
}
@@ -161,7 +161,7 @@ void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform)
// std::cout << "In QgsMapLayer::draw" << std::endl;
}

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

void QgsMapLayer::updateItemPixmap()
{
if (mLegendLayerFile)
if (mLegendLayerFile)
{
QPixmap originalPix=mLegendLayerFile->getOriginalPixmap();

if(mShowInOverview)
{
QPixmap pix=mLegendLayerFile->getOriginalPixmap();
if(mShowInOverview)
{
//add overview glasses to the pixmap
QPainter p(&pix);
p.drawPixmap(0,0,mInOverviewPixmap);
}
if(isEditable())
{
//add editing icon to the pixmap
QPainter p(&pix);
p.drawPixmap(30,0,mEditablePixmap);
}
mLegendLayerFile->setLegendPixmap(pix);
//add overview glasses to the pixmap
mLegendLayerFile->setOverviewPixmap(mInOverviewPixmap);
}
else
{
mLegendLayerFile->setOverviewPixmap( QPixmap() );
}

if(isEditable())
{
//add editing icon to the pixmap
mLegendLayerFile->setEditingPixmap(mEditablePixmap);
}
else
{
mLegendLayerFile->setEditingPixmap( QPixmap() );
}

mLegendLayerFile->setLegendPixmap(originalPix);
}
}

void QgsMapLayer::invalidTransformInput()
@@ -477,7 +486,7 @@ void QgsMapLayer::invalidTransformInput()
QPixmap pix=mLegendLayerFile->getOriginalPixmap();
if(mShowInOverview)
{
//add overview glasses to the pixmap
//add project error icon to the pixmap
QPainter p(&pix);
p.drawPixmap(60,0,mProjectionErrorPixmap);
}
@@ -103,7 +103,7 @@ class QgsMapLayer : public QObject
virtual void draw(QPainter *, QgsRect *, int);

//! Returns FALSE if an error occurred during drawing
virtual bool draw(QPainter *, QgsRect *, QgsMapToPixel *);
virtual bool draw(QPainter *, QgsRect *, QgsMapToPixel *, bool);
virtual void drawLabels(QPainter *, QgsRect *, QgsMapToPixel *);

/*!Select features on the map canvas by dragging a rectangle */
@@ -259,12 +259,12 @@ void QgsMapRender::render(QPainter* painter)
// Now do the call to the layer that actually does
// the rendering work!
//
if (!ml->draw(painter, &r1, mCoordXForm))
if (!ml->draw(painter, &r1, mCoordXForm, !mOverview))
emit drawError(ml);

if (split)
{
if (!ml->draw(painter, &r2, mCoordXForm))
if (!ml->draw(painter, &r2, mCoordXForm, !mOverview))
emit drawError(ml);
}

@@ -431,7 +431,8 @@ QgsRect QgsVectorLayer::inverseProjectRect(const QgsRect& r) const
unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag)
bool projectionsEnabledFlag,
bool drawingToEditingCanvas)
{
unsigned char *ptr = feature + 5;
unsigned int nPoints = *((int*)ptr);
@@ -503,7 +504,11 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
p->setPen(myTransparentPen);
p->drawPolyline(pa);

if(mEditable)
// draw vertex markers if in editing mode, but only to the main canvas
if (
(mEditable) &&
(drawingToEditingCanvas)
)
{
std::vector<double>::const_iterator xIt;
std::vector<double>::const_iterator yIt;
@@ -522,7 +527,8 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
unsigned char* QgsVectorLayer::drawPolygon(unsigned char* feature,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag)
bool projectionsEnabledFlag,
bool drawingToEditingCanvas)
{
typedef std::pair<std::vector<double>, std::vector<double> > ringType;
typedef ringType* ringTypePtr;
@@ -762,7 +768,11 @@ std::cerr << i << ": " << ring->first[i]
for (; ri != ringDetails.end(); ++ri)
p->drawPolygon(pa.constData() + ri->first, ri->second, Qt::OddEvenFill);

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


bool QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * theMapToPixelTransform)
bool QgsVectorLayer::draw(QPainter * p,
QgsRect * viewExtent,
QgsMapToPixel * theMapToPixelTransform,
bool drawingToEditingCanvas)
{
draw ( p, viewExtent, theMapToPixelTransform, 1., 1.);
draw(p,
viewExtent,
theMapToPixelTransform,
drawingToEditingCanvas,
1.,
1.);

return TRUE; // Assume success always
}

void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * theMapToPixelTransform,
double widthScale, double symbolScale)
void QgsVectorLayer::draw(QPainter * p,
QgsRect * viewExtent,
QgsMapToPixel * theMapToPixelTransform,
bool drawingToEditingCanvas,
double widthScale,
double symbolScale)
{
if(m_renderer)
{
@@ -889,7 +911,13 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th

m_renderer->renderFeature(p, fet, &marker, &markerScaleFactor, sel, widthScale );
double scale = markerScaleFactor * symbolScale;
drawFeature(p,fet,theMapToPixelTransform,&marker, scale, projectionsEnabledFlag);
drawFeature(p,
fet,
theMapToPixelTransform,
&marker,
scale,
projectionsEnabledFlag,
drawingToEditingCanvas);
++featureCount;
delete fet;
}
@@ -909,7 +937,13 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * th
//give a deep copy of the geometry to mCachedGeometry because it will be erased at each redraw
QgsGeometry* deepCopy = new QgsGeometry(*((*it)->geometry()));
mCachedGeometries.insert(std::make_pair((*it)->featureId(), deepCopy));
drawFeature(p,*it,theMapToPixelTransform,&marker,scale, projectionsEnabledFlag);
drawFeature(p,
*it,
theMapToPixelTransform,
&marker,
scale,
projectionsEnabledFlag,
drawingToEditingCanvas);
}
}
}
@@ -3191,8 +3225,13 @@ QgsGeometry& snappedGeometry, double tolerance)
}


void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * theMapToPixelTransform,
QPixmap * marker, double markerScaleFactor, bool projectionsEnabledFlag)
void QgsVectorLayer::drawFeature(QPainter* p,
QgsFeature* fet,
QgsMapToPixel * theMapToPixelTransform,
QPixmap * marker,
double markerScaleFactor,
bool projectionsEnabledFlag,
bool drawingToEditingCanvas)
{
// Only have variables, etc outside the switch() statement that are
// used in all cases of the statement (otherwise they may get
@@ -3274,8 +3313,11 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
}
case WKBLineString:
{
drawLineString(feature, p, theMapToPixelTransform,
projectionsEnabledFlag);
drawLineString(feature,
p,
theMapToPixelTransform,
projectionsEnabledFlag,
drawingToEditingCanvas);
break;
}
case WKBMultiLineString:
@@ -3286,15 +3328,21 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t

for (register unsigned int jdx = 0; jdx < numLineStrings; jdx++)
{
ptr = drawLineString(ptr, p, theMapToPixelTransform,
projectionsEnabledFlag);
ptr = drawLineString(ptr,
p,
theMapToPixelTransform,
projectionsEnabledFlag,
drawingToEditingCanvas);
}
break;
}
case WKBPolygon:
{
drawPolygon(feature, p, theMapToPixelTransform,
projectionsEnabledFlag);
drawPolygon(feature,
p,
theMapToPixelTransform,
projectionsEnabledFlag,
drawingToEditingCanvas);
break;
}
case WKBMultiPolygon:
@@ -3303,8 +3351,11 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
unsigned int numPolygons = *((int*)ptr);
ptr = feature + 9;
for (register unsigned int kdx = 0; kdx < numPolygons; kdx++)
ptr = drawPolygon(ptr, p, theMapToPixelTransform,
projectionsEnabledFlag);
ptr = drawPolygon(ptr,
p,
theMapToPixelTransform,
projectionsEnabledFlag,
drawingToEditingCanvas);
break;
}
default:
@@ -446,7 +446,12 @@ public slots:
* \param widthScale line width scale
* \param symbolScale symbol scale
*/
void draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf, double widthScale, double symbolScale);
void draw(QPainter * p,
QgsRect * viewExtent,
QgsMapToPixel * cXf,
bool drawingToEditingCanvas,
double widthScale,
double symbolScale);

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

private: // Private attributes

//! Draws features. May cause projections exceptions to be generated
// (i.e., code that calls this function needs to catch them
void drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * cXf, QPixmap* marker, double markerScaleFactor, bool projectionsEnabledFlag );
//! Draws features.
/** \note May cause projections exceptions to be generated
(i.e., code that calls this function needs to catch them
*/
void drawFeature(QPainter* p,
QgsFeature* fet,
QgsMapToPixel * cXf,
QPixmap* marker,
double markerScaleFactor,
bool projectionsEnabledFlag,
bool drawingToEditingCanvas);

private: // Private attributes

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

// Draw the polygon as given in the WKB format. Returns a pointer to
// the byte after the end of the polygon binary data stream (WKB).
unsigned char* drawPolygon(unsigned char* WKBpolygon, QPainter* p,
QgsMapToPixel* mtp, bool projectionsEnabledFlag);
unsigned char* drawPolygon(unsigned char* WKBpolygon,
QPainter* p,
QgsMapToPixel* mtp,
bool projectionsEnabledFlag,
bool drawingToEditingCanvas);

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

//! Draws the layer using coordinate transformation
//! Returns FALSE if an error occurred during drawing
bool draw(QPainter * p, QgsRect * viewExtent, QgsMapToPixel * cXf);
/**
\param drawingToEditingCanvas Are we drawing to an editable canvas?
\return FALSE if an error occurred during drawing
*/
bool draw(QPainter * p,
QgsRect * viewExtent,
QgsMapToPixel * cXf,
bool drawingToEditingCanvas);

//! Pointer to data provider derived from the abastract base class QgsDataProvider
QgsVectorDataProvider *dataProvider;
@@ -609,7 +634,8 @@ protected slots:
void cacheGeometries();
/**Deletes the geometries in mCachedGeometries*/
void deleteCachedGeometries();
/**Draws a vertex symbol at (screen) coordinates x, y*/

/** Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.) */
void drawVertexMarker(int x, int y, QPainter& p);

// pointer for loading the provider library

0 comments on commit 8645462

Please sign in to comment.