Skip to content
Permalink
Browse files
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/qgis@5507 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 6, 2006
1 parent d18462a commit d890c358a259b7df5f217bf0a7a1f834ac65603b
Showing with 36 additions and 1 deletion.
  1. +5 −0 src/gui/qgsattributetable.cpp
  2. +29 −1 src/gui/qgsvectorlayer.cpp
  3. +2 −0 src/gui/qgsvectorlayer.h
@@ -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));
@@ -182,7 +182,6 @@ QgsVectorLayer::~QgsVectorLayer()
delete (*it).second;
}
mCachedGeometries.clear();

}

QString QgsVectorLayer::storageType() const
@@ -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);

@@ -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
//
@@ -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)
@@ -1848,6 +1874,7 @@ void QgsVectorLayer::startEditing()
{
mToggleEditingAction->setChecked(true);
}
triggerRepaint();
}
}
}
@@ -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)
{
@@ -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;

0 comments on commit d890c35

Please sign in to comment.