mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
fixed multiple repaint bug
git-svn-id: http://svn.osgeo.org/qgis/trunk@100 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
b7dcf9d076
commit
62ee8cb764
@ -118,6 +118,8 @@ void QgisApp::about()
|
||||
|
||||
void QgisApp::addLayer()
|
||||
{
|
||||
qApp->processEvents();
|
||||
mapCanvas->freeze();
|
||||
QStringList files = QFileDialog::getOpenFileNames("Shapefiles (*.shp);;All files (*.*)", 0, this, "open files dialog",
|
||||
"Select one or more layers to add");
|
||||
QStringList::Iterator it = files.begin();
|
||||
@ -144,10 +146,11 @@ void QgisApp::addLayer()
|
||||
|
||||
++it;
|
||||
}
|
||||
qApp->processEvents();
|
||||
//qApp->processEvents();
|
||||
// update legend
|
||||
/*! \todo Need legend scrollview and legenditem classes */
|
||||
// draw the map
|
||||
mapCanvas->freeze(false);
|
||||
mapLegend->update();
|
||||
mapCanvas->render2();
|
||||
statusBar()->message(mapCanvas->extent().stringRep());
|
||||
@ -160,9 +163,13 @@ void QgisApp::addDatabaseLayer()
|
||||
{
|
||||
// only supports postgis layers at present
|
||||
// show the postgis dialog
|
||||
mapCanvas->setEnabled(false);
|
||||
|
||||
|
||||
QgsDbSourceSelect *dbs = new QgsDbSourceSelect();
|
||||
if (dbs->exec()) {
|
||||
// repaint the canvas if it was covered by the dialog
|
||||
qApp->processEvents();
|
||||
mapCanvas->freeze();
|
||||
// add files to the map canvas
|
||||
QStringList tables = dbs->selectedTables();
|
||||
QString connInfo = dbs->connInfo();
|
||||
@ -181,16 +188,18 @@ void QgisApp::addDatabaseLayer()
|
||||
|
||||
++it;
|
||||
}
|
||||
qApp->processEvents();
|
||||
// qApp->processEvents();
|
||||
// update legend
|
||||
/*! \todo Need legend scrollview and legenditem classes */
|
||||
mapLegend->update();
|
||||
mapCanvas->freeze(false);
|
||||
// draw the map
|
||||
mapCanvas->render2();
|
||||
statusBar()->message(mapCanvas->extent().stringRep());
|
||||
|
||||
}
|
||||
mapCanvas->setEnabled(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void QgisApp::fileExit()
|
||||
|
@ -112,7 +112,11 @@ QgsMapLayer *QgsMapCanvas::getZpos(int index)
|
||||
|
||||
void QgsMapCanvas::render2()
|
||||
{
|
||||
QString msg = frozen?"frozen":"thawed";
|
||||
std::cout << "Map canvas is " << msg << std::endl;
|
||||
if(!frozen){
|
||||
if (!drawing) {
|
||||
std::cout << "IN RENDER 2" << std::endl;
|
||||
drawing = true;
|
||||
QPainter *paint = new QPainter();
|
||||
paint->begin(this);
|
||||
@ -163,7 +167,7 @@ void QgsMapCanvas::render2()
|
||||
paint->end();
|
||||
drawing = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapCanvas::render()
|
||||
@ -209,8 +213,10 @@ void QgsMapCanvas::render()
|
||||
}
|
||||
void QgsMapCanvas::paintEvent(QPaintEvent * pe)
|
||||
{
|
||||
// if (!drawing)
|
||||
//render2();
|
||||
if (!drawing)
|
||||
render2();
|
||||
else
|
||||
std::cout << "Can't paint in paint event -- drawing = true" << std::endl;
|
||||
}
|
||||
|
||||
QgsRect QgsMapCanvas::extent()
|
||||
@ -250,7 +256,10 @@ void QgsMapCanvas::mousePressEvent(QMouseEvent * e)
|
||||
case QGis::Pan:
|
||||
// create a pixmap to use in panning the map canvas
|
||||
tempPanImage = new QPixmap();
|
||||
|
||||
*tempPanImage = QPixmap::grabWidget(this);
|
||||
|
||||
|
||||
backgroundFill = new QPixmap(tempPanImage->width(), tempPanImage->height());
|
||||
backgroundFill->fill(bgColor);
|
||||
break;
|
||||
@ -332,6 +341,7 @@ void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e)
|
||||
QPainter paint;
|
||||
QPen pen(Qt::gray);
|
||||
// this is a drag-type operation (zoom, pan or other maptool)
|
||||
|
||||
switch (mapTool) {
|
||||
case QGis::ZoomIn:
|
||||
// draw the rubber band box as the user drags the mouse
|
||||
@ -406,6 +416,12 @@ int QgsMapCanvas::layerCount()
|
||||
|
||||
void QgsMapCanvas::layerStateChange()
|
||||
{
|
||||
if(!frozen){
|
||||
clear();
|
||||
render2();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapCanvas::freeze(bool frz){
|
||||
frozen = frz;
|
||||
}
|
@ -65,6 +65,8 @@ public:
|
||||
QgsMapLayer * getZpos(int index);
|
||||
//! return number of layers on the map
|
||||
int layerCount();
|
||||
void freeze(bool frz=true);
|
||||
|
||||
public slots:
|
||||
void render2();
|
||||
//! This slot is connected to the visibility change of one or more layers
|
||||
@ -109,6 +111,7 @@ public slots:
|
||||
void updateZpos();
|
||||
//! Flag indicating a map refresh is in progress
|
||||
bool drawing;
|
||||
bool frozen;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user