mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Possible workaround for ticket #83. Adds a new toggle to the option
dialog that lets the user swap between using a QImage or a QPixmap for rendering the map. May or may not fix things. Committed so that others can try it out. git-svn-id: http://svn.osgeo.org/qgis/trunk@5567 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
4dd9a2b77e
commit
6abc64b58f
@ -1050,6 +1050,7 @@ void QgisApp::createOverview()
|
||||
// moved here to set anti aliasing to both map canvas and overview
|
||||
QSettings mySettings;
|
||||
mMapCanvas->enableAntiAliasing(mySettings.value("/qgis/enable_anti_aliasing",false).toBool());
|
||||
mMapCanvas->useQImageToRender(mySettings.value("/qgis/use_qimage_to_render",false).toBool());
|
||||
}
|
||||
|
||||
|
||||
@ -4048,6 +4049,7 @@ void QgisApp::options()
|
||||
mAddedLayersVisible = optionsDialog->newVisible();
|
||||
QSettings mySettings;
|
||||
mMapCanvas->enableAntiAliasing(mySettings.value("/qgis/enable_anti_aliasing").toBool());
|
||||
mMapCanvas->useQImageToRender(mySettings.value("/qgis/use_qimage_to_render").toBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,11 @@ void QgsMapCanvas::enableAntiAliasing(bool theFlag)
|
||||
mMapOverview->enableAntiAliasing(theFlag);
|
||||
} // anti aliasing
|
||||
|
||||
void QgsMapCanvas::useQImageToRender(bool theFlag)
|
||||
{
|
||||
mMap->useQImageToRender(theFlag);
|
||||
}
|
||||
|
||||
QgsMapCanvasMap* QgsMapCanvas::map()
|
||||
{
|
||||
return mMap;
|
||||
|
@ -185,6 +185,9 @@ class QgsMapCanvas : public Q3CanvasView
|
||||
//! used to determine if anti-aliasing is enabled or not
|
||||
void enableAntiAliasing(bool theFlag);
|
||||
|
||||
//! Select which Qt class to render with
|
||||
void useQImageToRender(bool theFlag);
|
||||
|
||||
// following 2 methods should be moved elsewhere or changed to private
|
||||
// currently used by pan map tool
|
||||
//! Ends pan action and redraws the canvas.
|
||||
|
@ -25,6 +25,7 @@ QgsMapCanvasMap::QgsMapCanvasMap(Q3Canvas *canvas, QgsMapRender* render)
|
||||
setZ(-10);
|
||||
move(0,0);
|
||||
resize(QSize(1,1));
|
||||
mUseQImageToRender = false;
|
||||
}
|
||||
|
||||
|
||||
@ -41,6 +42,13 @@ void QgsMapCanvasMap::resize(QSize size)
|
||||
}
|
||||
|
||||
void QgsMapCanvasMap::render()
|
||||
{
|
||||
// Rendering to a QImage gives incorrectly filled polygons in some
|
||||
// cases (as at Qt4.1.4), but it is the only renderer that supports
|
||||
// anti-aliasing, so we provide the means to swap between QImage and
|
||||
// QPixmap.
|
||||
|
||||
if (mUseQImageToRender)
|
||||
{
|
||||
// use temporary image for rendering
|
||||
QImage image(size(), QImage::Format_RGB32);
|
||||
@ -61,3 +69,12 @@ void QgsMapCanvasMap::render()
|
||||
// convert QImage to QPixmap to acheive faster drawing on screen
|
||||
mPixmap = QPixmap::fromImage(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
mPixmap.fill(mBgColor.rgb());
|
||||
QPainter paint;
|
||||
paint.begin(&mPixmap);
|
||||
mRender->render(&paint);
|
||||
paint.end();
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ class QgsMapCanvasMap : public Q3CanvasRectangle
|
||||
|
||||
void enableAntiAliasing(bool flag) { mAntiAliasing = flag; }
|
||||
|
||||
void useQImageToRender(bool flag) { mUseQImageToRender = flag; }
|
||||
|
||||
QPixmap& pixmap() { return mPixmap; }
|
||||
|
||||
//! renders map using QgsMapRender to mPixmap
|
||||
@ -61,6 +63,9 @@ class QgsMapCanvasMap : public Q3CanvasRectangle
|
||||
//! indicates whether antialiasing will be used for rendering
|
||||
bool mAntiAliasing;
|
||||
|
||||
//! Whether to use a QPixmap or a QImage for the rendering
|
||||
bool mUseQImageToRender;
|
||||
|
||||
QgsMapRender* mRender;
|
||||
|
||||
QColor mBgColor;
|
||||
|
@ -98,6 +98,9 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
|
||||
cmbTheme->setCurrentText(settings.readEntry("/Themes","default"));
|
||||
//set teh state of the checkboxes
|
||||
chkAntiAliasing->setChecked(settings.value("/qgis/enable_anti_aliasing",false).toBool());
|
||||
// Slightly awkard here at the settings value is true to use QImage,
|
||||
// but the checkbox is true to use QPixmap
|
||||
chkUseQPixmap->setChecked(!(settings.value("/qgis/use_qimage_to_render", true).toBool()));
|
||||
chkAddedVisibility->setChecked(settings.value("/qgis/new_layers_visible",true).toBool());
|
||||
cbxHideSplash->setChecked(settings.value("/qgis/hideSplash",false).toBool());
|
||||
//set the colour for selections
|
||||
@ -154,6 +157,7 @@ void QgsOptions::saveOptions()
|
||||
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
|
||||
settings.writeEntry("/qgis/new_layers_visible",chkAddedVisibility->isChecked());
|
||||
settings.writeEntry("/qgis/enable_anti_aliasing",chkAntiAliasing->isChecked());
|
||||
settings.writeEntry("/qgis/use_qimage_to_render", !(chkUseQPixmap->isChecked()));
|
||||
settings.setValue("qgis/capitaliseLayerName", capitaliseCheckBox->isChecked());
|
||||
|
||||
if(cmbTheme->currentText().length() == 0)
|
||||
@ -250,6 +254,27 @@ void QgsOptions::on_pbnSelectProjection_clicked()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QgsOptions::on_chkAntiAliasing_stateChanged()
|
||||
{
|
||||
// We can't have the anti-aliasing turned on when QPixmap is being
|
||||
// used (we we can. but it then doesn't do anti-aliasing, and this
|
||||
// will confuse people).
|
||||
if (chkAntiAliasing->isChecked())
|
||||
chkUseQPixmap->setChecked(false);
|
||||
|
||||
}
|
||||
|
||||
void QgsOptions::on_chkUseQPixmap_stateChanged()
|
||||
{
|
||||
// We can't have the anti-aliasing turned on when QPixmap is being
|
||||
// used (we we can. but it then doesn't do anti-aliasing, and this
|
||||
// will confuse people).
|
||||
if (chkUseQPixmap->isChecked())
|
||||
chkAntiAliasing->setChecked(false);
|
||||
|
||||
}
|
||||
|
||||
// Return state of the visibility flag for newly added layers. If
|
||||
|
||||
bool QgsOptions::newVisible()
|
||||
|
@ -47,6 +47,8 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
|
||||
//! Slot called when user chooses to change the project wide projection.
|
||||
void on_pbnSelectProjection_clicked();
|
||||
void on_btnFindBrowser_clicked();
|
||||
void on_chkAntiAliasing_stateChanged();
|
||||
void on_chkUseQPixmap_stateChanged();
|
||||
void saveOptions();
|
||||
//! Slot to change the theme this is handled when the user
|
||||
// activates or highlights a theme name in the drop-down list
|
||||
|
@ -21,15 +21,18 @@
|
||||
<property name="sizeGripEnabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QTabWidget" name="tabWidget" >
|
||||
<property name="currentIndex" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabAppearance" >
|
||||
<attribute name="title" >
|
||||
<string>&Appearance</string>
|
||||
@ -227,71 +230,14 @@
|
||||
<attribute name="title" >
|
||||
<string>&Rendering</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QGroupBox" name="groupBox_8" >
|
||||
<property name="title" >
|
||||
<string>Anti-aliasing</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="chkAntiAliasing" >
|
||||
<property name="text" >
|
||||
<string>Make lines appear less jagged at the expense of some drawing performance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QGroupBox" name="groupBox_4" >
|
||||
<property name="title" >
|
||||
<string>Initial Visibility</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="chkAddedVisibility" >
|
||||
<property name="text" >
|
||||
<string>By default new la&yers added to the map should be displayed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5" >
|
||||
<property name="title" >
|
||||
<string>&Update during drawing</string>
|
||||
@ -343,6 +289,73 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4" >
|
||||
<property name="title" >
|
||||
<string>Initial Visibility</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="chkAddedVisibility" >
|
||||
<property name="text" >
|
||||
<string>By default new la&yers added to the map should be displayed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_8" >
|
||||
<property name="title" >
|
||||
<string>Rendering</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QCheckBox" name="chkUseQPixmap" >
|
||||
<property name="toolTip" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Selecting this will unselect the 'make lines less' jagged toggle</p></body></html></string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Fix problems with incorrectly filled polygons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="chkAntiAliasing" >
|
||||
<property name="text" >
|
||||
<string>Make lines appear less jagged at the expense of some drawing performance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabMap" >
|
||||
@ -631,7 +644,7 @@ identifying features without zooming in very close.
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
|
Loading…
x
Reference in New Issue
Block a user