Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix for crash when opening the attribute table for postgis layers aft…
…er commiting. Added a first version of marker visualisation for line/polygon digitising

git-svn-id: http://svn.osgeo.org/qgis/trunk@5507 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 6, 2006
1 parent 2e95fe1 commit fc5ee8d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/gui/qgsattributetable.cpp
Expand Up @@ -499,6 +499,11 @@ void QgsAttributeTable::fillTable(QgsVectorLayer* layer)

void QgsAttributeTable::putFeatureInTable(int row, QgsFeature* fet)
{
if(row >= numRows())//prevent a crash if a provider doesn't update the feature count properly
{
setNumRows(row+1);
}

//id-field
int id = fet->featureId();
setText(row, 0, QString::number(id));
Expand Down
30 changes: 29 additions & 1 deletion src/gui/qgsvectorlayer.cpp
Expand Up @@ -182,7 +182,6 @@ QgsVectorLayer::~QgsVectorLayer()
delete (*it).second;
}
mCachedGeometries.clear();

}

QString QgsVectorLayer::storageType() const
Expand Down Expand Up @@ -502,6 +501,17 @@ unsigned char* QgsVectorLayer::drawLineString(unsigned char* feature,
myTransparentPen.setColor(myColor);
p->setPen(myTransparentPen);
p->drawPolyline(pa);

if(mEditable)
{
std::vector<double>::const_iterator xIt;
std::vector<double>::const_iterator yIt;
for(xIt = x.begin(), yIt = y.begin(); xIt != x.end(); ++xIt, ++yIt)
{
drawVertexMarker((int)(*xIt), (int)(*yIt), *p);
}
}

//restore the pen
p->setPen(pen);

Expand Down Expand Up @@ -751,6 +761,14 @@ 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
{
for(int i = 0; i < pa.size(); ++i)
{
drawVertexMarker((int)(pa[i].x()), (int)(pa[i].y()), *p);
}
}

//
//restore brush and pen to original
//
Expand Down Expand Up @@ -940,6 +958,14 @@ void QgsVectorLayer::deleteCachedGeometries()
mCachedGeometries.clear();
}

void QgsVectorLayer::drawVertexMarker(int x, int y, QPainter& p)
{
int size = 15;
int m = (size-1)/2;
p.drawLine(x-m, y+m, x+m, y-m);
p.drawLine(x-m, y-m, x+m, y+m);
}

void QgsVectorLayer::table()
{
if (tabledisplay)
Expand Down Expand Up @@ -1848,6 +1874,7 @@ void QgsVectorLayer::startEditing()
{
mToggleEditingAction->setChecked(true);
}
triggerRepaint();
}
}
}
Expand All @@ -1872,6 +1899,7 @@ void QgsVectorLayer::stopEditing()
else
{
dataProvider->updateExtents();
dataProvider->updateFeatureCount();
//hide and delete the table because it is not up to date any more
if (tabledisplay)
{
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsvectorlayer.h
Expand Up @@ -564,6 +564,8 @@ protected slots:
void cacheGeometries();
/**Deletes the geometries in mCachedGeometries*/
void deleteCachedGeometries();
/**Draws a vertex symbol at (screen) coordinates x, y*/
void drawVertexMarker(int x, int y, QPainter& p);

// pointer for loading the provider library
QLibrary *myLib;
Expand Down

0 comments on commit fc5ee8d

Please sign in to comment.