mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
** Merged Projections_Branch into HEAD
Problems: Polygon outlines are not drawn. This was checked twice and no cause was found. Projections do not work in all circumstances Note that both the proj4 library and sqlite3 are now required. The build system has not been modified to test for these yet. Qt 3.3.x is required to build this source tree. Make sure to increment the EXTRA_VERSION in configure.in when committing changes. Make sure to update the Changelog with each commit git-svn-id: http://svn.osgeo.org/qgis/trunk@3112 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
3bbf810f64
commit
8c64ebf684
47
ChangeLog
47
ChangeLog
@ -1,20 +1,39 @@
|
||||
QGIS Change Log
|
||||
2005-01-29 [gsherman] 0.6.0devel5
|
||||
** Applied patches from M. Loskot for a build error and missing Q_OBJECT
|
||||
macros in qgsspit.h and qgsattributetable.h
|
||||
2005-01-01 [larsl] 0.6.0devel4
|
||||
2005-03-13 [jobi] 0.6.0devel6
|
||||
- fix for building on 64bit architecture
|
||||
- fixed dependencies of designer-plugin/stuff
|
||||
2005-01-01 [larsl] 0.6.0devel4
|
||||
** Fixed a bug that crashed QGIS when loading rasters from a project file, pt 2
|
||||
QGIS Change Log
|
||||
2005-01-01 [larsl] 0.6.0devel3
|
||||
** Fixed a bug that crashed QGIS when loading rasters from a project file
|
||||
QGIS Change Log
|
||||
/* ChangeLog,v 1.214 2004/11/12 00:42:21 gsherman Exp */
|
||||
------------------------------------------------------------------------------
|
||||
Version 0.6 'Simon' .... development version
|
||||
QGIS Change Log
|
||||
2005-04-09 [ges] 0.6.0devel7
|
||||
** Merged Projections_Branch into HEAD
|
||||
Problems:
|
||||
Polygon outlines are not drawn. This was checked twice and no cause
|
||||
was found.
|
||||
|
||||
Projections do not work in all circumstances
|
||||
|
||||
Note that both the proj4 library and sqlite3 are now required. The
|
||||
build system has not been modified to test for these yet.
|
||||
|
||||
Qt 3.3.x is required to build this source tree.
|
||||
|
||||
Make sure to increment the EXTRA_VERSION in configure.in when
|
||||
committing changes.
|
||||
|
||||
Make sure to update the Changelog with each commit
|
||||
|
||||
2005-03-13 [jobi] 0.6.0devel6
|
||||
- fix for building on 64bit architecture
|
||||
- fixed dependencies of designer-plugin/stuff
|
||||
|
||||
2005-01-29 [gsherman] 0.6.0devel5
|
||||
** Applied patches from M. Loskot for a build error and missing Q_OBJECT
|
||||
macros in qgsspit.h and qgsattributetable.h
|
||||
|
||||
2005-01-01 [larsl] 0.6.0devel4
|
||||
** Fixed a bug that crashed QGIS when loading rasters from a project file, pt 2
|
||||
|
||||
2005-01-01 [larsl] 0.6.0devel3
|
||||
** Fixed a bug that crashed QGIS when loading rasters from a project file
|
||||
QGIS Change Log
|
||||
|
||||
2004-12-30 [mcoletti] 0.6.0devel2
|
||||
*** Re-factored endian-handling in data providers
|
||||
|
@ -31,8 +31,7 @@ docdatadir = $(datadir)/$(PACKAGE)/doc
|
||||
docdata_DATA = AUTHORS
|
||||
|
||||
|
||||
SUBDIRS = src providers plugins doc tools i18n
|
||||
|
||||
SUBDIRS = src widgets providers plugins doc tools i18n designer_plugins
|
||||
pkginclude_HEADERS = qgsconfig.h
|
||||
|
||||
UIcheck:
|
||||
|
@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
|
||||
MAJOR_VERSION=0
|
||||
MINOR_VERSION=6
|
||||
MICRO_VERSION=0
|
||||
EXTRA_VERSION=6
|
||||
EXTRA_VERSION=7
|
||||
if test $EXTRA_VERSION -eq 0; then
|
||||
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
|
||||
else
|
||||
@ -314,6 +314,8 @@ AC_CONFIG_FILES([
|
||||
plugins/north_arrow/Makefile
|
||||
plugins/copyright_label/Makefile
|
||||
plugins/scale_bar/Makefile
|
||||
widgets/Makefile
|
||||
widgets/projectionselector/Makefile
|
||||
designer_plugins/Makefile
|
||||
plugins/community_reg_plugin/Makefile
|
||||
])
|
||||
|
@ -17,15 +17,20 @@ plugindir = ${pkglibdir}/designer
|
||||
$(MOC) -o $@ $<
|
||||
|
||||
# name of the designer plugin
|
||||
plugin_LTLIBRARIES = qgsdesignerwidgets.la
|
||||
plugin_LTLIBRARIES = qgisdesignerwidgets.la
|
||||
|
||||
plugin_MOC = qgsdesignerwidgets.moc.cpp
|
||||
plugin_MOC = qgsprojectionselectorplugin.moc.cpp
|
||||
|
||||
|
||||
qgsdesignerwidgets_la_SOURCES = qgsdesignerwidgets.cpp \
|
||||
|
||||
|
||||
qgisdesignerwidgets_la_SOURCES = qgsprojectionselectorplugin.cpp \
|
||||
$(plugin_MOC)
|
||||
BUILT_SOURCES = $(plugin_MOC)
|
||||
|
||||
qgsdesignerwidgets_la_LIBADD = $(QT_LDADD) ../src/libqgis.la $(GDAL_LDADD)
|
||||
qgsdesignerwidgets_la_LDFLAGS = -avoid-version -module
|
||||
qgsdesignerwidgets_la_CXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) $(DEBUG_QGIS) -I../src/
|
||||
#projectionselector_la_LIBADD = ../src/libqgis.la $(QT_LDADD)
|
||||
qgisdesignerwidgets_la_LIBADD = $(QT_LDADD) ../widgets/projectionselector/libqgsprojectionselector.la
|
||||
qgisdesignerwidgets_la_LDFLAGS = -avoid-version -module
|
||||
qgisdesignerwidgets_la_CXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) $(DEBUG_QGIS) -I../src/
|
||||
|
||||
EXTRA_DIST = $(plugin_UIC)
|
||||
|
95
designer_plugins/qgsprojectionselectorplugin.cpp
Normal file
95
designer_plugins/qgsprojectionselectorplugin.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include "qgsprojectionselectorplugin.h"
|
||||
#include "../widgets/projectionselector/qgsprojectionselector.h"
|
||||
|
||||
static const char *projectionselector_pixmap[] = {
|
||||
"22 22 8 1",
|
||||
" c Gray100",
|
||||
". c Gray97",
|
||||
"X c #4f504f",
|
||||
"o c #00007f",
|
||||
"O c Gray0",
|
||||
"+ c none",
|
||||
"@ c Gray0",
|
||||
"# c Gray0",
|
||||
"++++++++++++++++++++++",
|
||||
"++++++++++++++++++++++",
|
||||
"++++++++++++++++++++++",
|
||||
"++++++++++++++++++++++",
|
||||
"+OOOOOOOOOOOOOOOOOOOO+",
|
||||
"OOXXXXXXXXXXXXXXXXXXOO",
|
||||
"OXX. O",
|
||||
"OX. ooooooooo O",
|
||||
"OX. o o .O",
|
||||
"OX o o O",
|
||||
"OX o o O",
|
||||
"O o o O",
|
||||
"OX o o o O",
|
||||
"OX o o o O",
|
||||
"OX o o O",
|
||||
"OX ooooooooo o O",
|
||||
"OO..................OO",
|
||||
"+OOOOOOOOOOOOOOOOOOOO+",
|
||||
"++++++++++++++++++++++",
|
||||
"++++++++++++++++++++++",
|
||||
"++++++++++++++++++++++",
|
||||
"++++++++++++++++++++++"
|
||||
};
|
||||
|
||||
QgsProjectionSelectorPlugin::QgsProjectionSelectorPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QgsProjectionSelectorPlugin::keys() const
|
||||
{
|
||||
QStringList list;
|
||||
list << "QgsProjectionSelector";
|
||||
return list;
|
||||
}
|
||||
|
||||
QWidget* QgsProjectionSelectorPlugin::create( const QString &key, QWidget* parent, const char* name )
|
||||
{
|
||||
if ( key == "QgsProjectionSelector" )
|
||||
return new QgsProjectionSelector( parent, name );
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString QgsProjectionSelectorPlugin::group( const QString& feature ) const
|
||||
{
|
||||
if ( feature == "QgsProjectionSelector" )
|
||||
return "QGIS";
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
QIconSet QgsProjectionSelectorPlugin::iconSet( const QString& ) const
|
||||
{
|
||||
return QIconSet( QPixmap( projectionselector_pixmap ) );
|
||||
}
|
||||
|
||||
QString QgsProjectionSelectorPlugin::includeFile( const QString& feature ) const
|
||||
{
|
||||
if ( feature == "QgsProjectionSelector" )
|
||||
return "qgsprojectionselector.h";
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
QString QgsProjectionSelectorPlugin::toolTip( const QString& feature ) const
|
||||
{
|
||||
if ( feature == "QgsProjectionSelector" )
|
||||
return "QGIS Projection Selector Widget";
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
QString QgsProjectionSelectorPlugin::whatsThis( const QString& feature ) const
|
||||
{
|
||||
if ( feature == "QgsProjectionSelector" )
|
||||
return "A widget to choose a projection name from a list";
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
bool QgsProjectionSelectorPlugin::isContainer( const QString& ) const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Q_EXPORT_PLUGIN( QgsProjectionSelectorPlugin )
|
17
designer_plugins/qgsprojectionselectorplugin.h
Normal file
17
designer_plugins/qgsprojectionselectorplugin.h
Normal file
@ -0,0 +1,17 @@
|
||||
#include <qwidgetplugin.h>
|
||||
|
||||
class QgsProjectionSelectorPlugin : public QWidgetPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsProjectionSelectorPlugin();
|
||||
|
||||
QStringList keys() const;
|
||||
QWidget* create( const QString &classname, QWidget* parent = 0, const char* name = 0 );
|
||||
QString group( const QString& ) const;
|
||||
QIconSet iconSet( const QString& ) const;
|
||||
QString includeFile( const QString& ) const;
|
||||
QString toolTip( const QString& ) const;
|
||||
QString whatsThis( const QString& ) const;
|
||||
bool isContainer( const QString& ) const;
|
||||
};
|
@ -10,5 +10,5 @@
|
||||
# Set software group
|
||||
# The package maintainer (.deb)
|
||||
|
||||
checkinstall --default --pkgname=qgis --pkgversion=0.7.0pre --pkggroup=GIS --maintainer=tim@linfiniti.com
|
||||
checkinstall --exclude ~/.ccache/stats --default --pkgname=qgis --pkgversion=0.7.0pre --pkggroup=GIS --maintainer=tim@linfiniti.com
|
||||
|
||||
|
@ -17,6 +17,7 @@ nodist_i18n_DATA = \
|
||||
qgis_fr.qm \
|
||||
qgis_it.qm \
|
||||
qgis_nl.qm \
|
||||
qgis_pl_PL.qm \
|
||||
qgis_pt_BR.qm \
|
||||
qgis_ru.qm \
|
||||
qgis_se.qm \
|
||||
@ -28,6 +29,7 @@ i18n_SOURCES = \
|
||||
qgis_fr.ts \
|
||||
qgis_it.ts \
|
||||
qgis_nl.ts \
|
||||
qgis_pl_PL.ts \
|
||||
qgis_pt_BR.ts \
|
||||
qgis_ru.ts \
|
||||
qgis_se.ts \
|
||||
|
@ -81,4 +81,6 @@ EXTRA_DIST = $(plugin_UIC) icon.xpm \
|
||||
qgsgpsdevicedialog.h
|
||||
|
||||
|
||||
endif
|
||||
|
||||
|
||||
endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -74,7 +74,7 @@ static const char *pluginVersion = "0.1";
|
||||
* @param theQgisInterFace Pointer to the QGIS interface object
|
||||
*/
|
||||
QgsGrassPlugin::QgsGrassPlugin(QgisApp * theQGisApp, QgisIface * theQgisInterFace):
|
||||
qgisMainWindowPointer(theQGisApp), qGisInterface(theQgisInterFace)
|
||||
qgisMainWindowPointer(theQGisApp), qGisInterface(theQgisInterFace)
|
||||
{
|
||||
/** Initialize the plugin and set the required attributes */
|
||||
pluginNameQString = "GrassVector";
|
||||
@ -107,7 +107,7 @@ QString QgsGrassPlugin::description()
|
||||
|
||||
void QgsGrassPlugin::help()
|
||||
{
|
||||
//TODO
|
||||
//TODO
|
||||
}
|
||||
|
||||
int QgsGrassPlugin::type()
|
||||
@ -120,155 +120,155 @@ int QgsGrassPlugin::type()
|
||||
*/
|
||||
void QgsGrassPlugin::initGui()
|
||||
{
|
||||
menuBarPointer = 0;
|
||||
toolBarPointer = 0;
|
||||
mTools = 0;
|
||||
|
||||
QSettings settings;
|
||||
|
||||
// Require GISBASE to be set. This should point to the location of
|
||||
// the GRASS installation. The GRASS libraries use it to know
|
||||
// where to look for things.
|
||||
|
||||
// Look first to see if GISBASE env var is already set.
|
||||
// This is set when QGIS is run from within GRASS
|
||||
// or when set explicitly by the user.
|
||||
// This value should always take precedence.
|
||||
QString gisBase = getenv("GISBASE");
|
||||
menuBarPointer = 0;
|
||||
toolBarPointer = 0;
|
||||
mTools = 0;
|
||||
|
||||
QSettings settings;
|
||||
|
||||
// Require GISBASE to be set. This should point to the location of
|
||||
// the GRASS installation. The GRASS libraries use it to know
|
||||
// where to look for things.
|
||||
|
||||
// Look first to see if GISBASE env var is already set.
|
||||
// This is set when QGIS is run from within GRASS
|
||||
// or when set explicitly by the user.
|
||||
// This value should always take precedence.
|
||||
QString gisBase = getenv("GISBASE");
|
||||
#ifdef QGISDEBUG
|
||||
qDebug( "%s:%d GRASS gisBase from GISBASE env var is: %s", __FILE__, __LINE__, (const char*)gisBase );
|
||||
qDebug( "%s:%d GRASS gisBase from GISBASE env var is: %s", __FILE__, __LINE__, (const char*)gisBase );
|
||||
#endif
|
||||
if ( !isValidGrassBaseDir(gisBase) ) {
|
||||
// Look for gisbase in QSettings
|
||||
gisBase = settings.readEntry("/qgis/grass/gisbase", "");
|
||||
if ( !isValidGrassBaseDir(gisBase) ) {
|
||||
// Look for gisbase in QSettings
|
||||
gisBase = settings.readEntry("/qgis/grass/gisbase", "");
|
||||
#ifdef QGISDEBUG
|
||||
qDebug( "%s:%d GRASS gisBase from QSettings is: %s", __FILE__, __LINE__, (const char*)gisBase );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( !isValidGrassBaseDir(gisBase) ) {
|
||||
// Use the location specified --with-grass during configure
|
||||
gisBase = GRASS_BASE;
|
||||
}
|
||||
|
||||
if ( !isValidGrassBaseDir(gisBase) ) {
|
||||
// Use the location specified --with-grass during configure
|
||||
gisBase = GRASS_BASE;
|
||||
#ifdef QGISDEBUG
|
||||
qDebug( "%s:%d GRASS gisBase from configure is: %s", __FILE__, __LINE__, (const char*)gisBase );
|
||||
#endif
|
||||
}
|
||||
|
||||
while ( !isValidGrassBaseDir(gisBase) ) {
|
||||
// Keep asking user for GISBASE until we get a valid one
|
||||
//QMessageBox::warning( 0, "Warning", "QGIS can't find your GRASS installation,\nGRASS data "
|
||||
// "cannot be used.\nPlease select your GISBASE.\nGISBASE is full path to the\n"
|
||||
// "directory where GRASS is installed." );
|
||||
// XXX Need to subclass this and add explantory message above to left side
|
||||
gisBase = QFileDialog::getExistingDirectory(
|
||||
gisBase, qgisMainWindowPointer,
|
||||
"get GISBASE" ,
|
||||
"Choose GISBASE ...", TRUE );
|
||||
if (gisBase == QString::null)
|
||||
{
|
||||
// User pressed cancel. No GRASS for you!
|
||||
return;
|
||||
}
|
||||
|
||||
while ( !isValidGrassBaseDir(gisBase) ) {
|
||||
// Keep asking user for GISBASE until we get a valid one
|
||||
//QMessageBox::warning( 0, "Warning", "QGIS can't find your GRASS installation,\nGRASS data "
|
||||
// "cannot be used.\nPlease select your GISBASE.\nGISBASE is full path to the\n"
|
||||
// "directory where GRASS is installed." );
|
||||
// XXX Need to subclass this and add explantory message above to left side
|
||||
gisBase = QFileDialog::getExistingDirectory(
|
||||
gisBase, qgisMainWindowPointer,
|
||||
"get GISBASE" ,
|
||||
"Choose GISBASE ...", TRUE );
|
||||
if (gisBase == QString::null)
|
||||
{
|
||||
// User pressed cancel. No GRASS for you!
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
qDebug( "%s:%d Valid GRASS gisBase is: %s", __FILE__, __LINE__, (const char*)gisBase );
|
||||
qDebug( "%s:%d Valid GRASS gisBase is: %s", __FILE__, __LINE__, (const char*)gisBase );
|
||||
#endif
|
||||
QString gisBaseEnv = "GISBASE=" + gisBase;
|
||||
/* _Correct_ putenv() implementation is not making copy! */
|
||||
char *gisBaseEnvChar = new char[gisBaseEnv.length()+1];
|
||||
strcpy ( gisBaseEnvChar, const_cast<char *>(gisBaseEnv.ascii()) );
|
||||
putenv( gisBaseEnvChar );
|
||||
settings.writeEntry("/qgis/grass/gisbase", gisBase);
|
||||
QString gisBaseEnv = "GISBASE=" + gisBase;
|
||||
/* _Correct_ putenv() implementation is not making copy! */
|
||||
char *gisBaseEnvChar = new char[gisBaseEnv.length()+1];
|
||||
strcpy ( gisBaseEnvChar, const_cast<char *>(gisBaseEnv.ascii()) );
|
||||
putenv( gisBaseEnvChar );
|
||||
settings.writeEntry("/qgis/grass/gisbase", gisBase);
|
||||
|
||||
mCanvas = qGisInterface->getMapCanvas();
|
||||
|
||||
QPopupMenu *pluginMenu = new QPopupMenu(qgisMainWindowPointer);
|
||||
mCanvas = qGisInterface->getMapCanvas();
|
||||
|
||||
int menuId = pluginMenu->insertItem(QIconSet(icon_add_vector),"Add Grass &Vector", this,
|
||||
SLOT(addVector()));
|
||||
pluginMenu->setWhatsThis(menuId, "Add a GRASS vector layer to the map canvas.");
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_add_raster),"Add Grass &Raster", this, SLOT(addRaster()));
|
||||
pluginMenu->setWhatsThis(menuId, "Add a GRASS raster layer to the map canvas.");
|
||||
QPopupMenu *pluginMenu = new QPopupMenu(qgisMainWindowPointer);
|
||||
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_tools),"GRASS &Tools", this, SLOT(openTools()));
|
||||
pluginMenu->setWhatsThis(menuId, "Open GRASS tools.");
|
||||
int menuId = pluginMenu->insertItem(QIconSet(icon_add_vector),"Add Grass &Vector", this,
|
||||
SLOT(addVector()));
|
||||
pluginMenu->setWhatsThis(menuId, "Add a GRASS vector layer to the map canvas.");
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_add_raster),"Add Grass &Raster", this, SLOT(addRaster()));
|
||||
pluginMenu->setWhatsThis(menuId, "Add a GRASS raster layer to the map canvas.");
|
||||
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_region),"Display Current Grass Region", this, SLOT(switchRegion(bool)));
|
||||
pluginMenu->setWhatsThis(menuId, "Display Current Grass Region");
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_region_edit),"Edit Current Grass Region", this, SLOT(changeRegion()));
|
||||
pluginMenu->setWhatsThis(menuId, "Edit Current Grass Region");
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_tools),"GRASS &Tools", this, SLOT(openTools()));
|
||||
pluginMenu->setWhatsThis(menuId, "Open GRASS tools.");
|
||||
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_region),"Display Current Grass Region", this, SLOT(switchRegion(bool)));
|
||||
pluginMenu->setWhatsThis(menuId, "Display Current Grass Region");
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_region_edit),"Edit Current Grass Region", this, SLOT(changeRegion()));
|
||||
pluginMenu->setWhatsThis(menuId, "Edit Current Grass Region");
|
||||
|
||||
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_edit),"&Edit Grass Vector", this, SLOT(edit()));
|
||||
pluginMenu->setWhatsThis(menuId, "Edit a GRASS vector layer");
|
||||
menuId = pluginMenu->insertItem(QIconSet(icon_grass_edit),"&Edit Grass Vector", this, SLOT(edit()));
|
||||
pluginMenu->setWhatsThis(menuId, "Edit a GRASS vector layer");
|
||||
|
||||
menuBarPointer = ((QMainWindow *) qgisMainWindowPointer)->menuBar();
|
||||
menuBarPointer = ((QMainWindow *) qgisMainWindowPointer)->menuBar();
|
||||
|
||||
menuIdInt = qGisInterface->addMenu("&GRASS", pluginMenu);
|
||||
menuIdInt = qGisInterface->addMenu("&GRASS", pluginMenu);
|
||||
|
||||
// Create the action for tool
|
||||
QAction *addVectorAction = new QAction("Add GRASS vector layer", QIconSet(icon_add_vector),
|
||||
"Add GRASS vector layer",0, this, "addVector");
|
||||
addVectorAction->setWhatsThis("Adds a GRASS vector layer to the map canvas");
|
||||
QAction *addRasterAction = new QAction("Add GRASS raster layer", QIconSet(icon_add_raster),
|
||||
"Add GRASS raster layer",0, this, "addRaster");
|
||||
addRasterAction->setWhatsThis("Adds a GRASS raster layer to the map canvas");
|
||||
// Create the action for tool
|
||||
QAction *addVectorAction = new QAction("Add GRASS vector layer", QIconSet(icon_add_vector),
|
||||
"Add GRASS vector layer",0, this, "addVector");
|
||||
addVectorAction->setWhatsThis("Adds a GRASS vector layer to the map canvas");
|
||||
QAction *addRasterAction = new QAction("Add GRASS raster layer", QIconSet(icon_add_raster),
|
||||
"Add GRASS raster layer",0, this, "addRaster");
|
||||
addRasterAction->setWhatsThis("Adds a GRASS raster layer to the map canvas");
|
||||
|
||||
QAction *openToolsAction = new QAction("Open GRASS tools", QIconSet(icon_grass_tools),
|
||||
"Open GRASS tools",0, this, "openTools");
|
||||
addRasterAction->setWhatsThis("Open GRASS tools");
|
||||
QAction *openToolsAction = new QAction("Open GRASS tools", QIconSet(icon_grass_tools),
|
||||
"Open GRASS tools",0, this, "openTools");
|
||||
addRasterAction->setWhatsThis("Open GRASS tools");
|
||||
|
||||
|
||||
mRegionAction = new QAction("Display Current Grass Region", QIconSet(icon_grass_region),
|
||||
"Display Current Grass Region",0, this, "region", true);
|
||||
mRegionAction->setWhatsThis("Displays the current GRASS region as a rectangle on the map canvas");
|
||||
QAction *editRegionAction = new QAction("Edit Current Grass Region", QIconSet(icon_grass_region_edit),
|
||||
"Edit Current Grass Region",0, this, "editRegion");
|
||||
editRegionAction->setWhatsThis("Edit the current GRASS region");
|
||||
QAction *editAction = new QAction("Edit Grass Vector layer", QIconSet(icon_grass_edit),
|
||||
"Edit Grass Vector layer",0, this, "edit");
|
||||
editAction->setWhatsThis("Edit the currently selected GRASS vector layer.");
|
||||
if ( !QgsGrass::activeMode() ) {
|
||||
openToolsAction->setEnabled(false);
|
||||
mRegionAction->setEnabled(false);
|
||||
editRegionAction->setEnabled(false);
|
||||
} else {
|
||||
openToolsAction->setEnabled(true);
|
||||
mRegionAction->setEnabled(true);
|
||||
editRegionAction->setEnabled(true);
|
||||
bool on = settings.readBoolEntry ("/qgis/grass/region/on", true );
|
||||
mRegionAction->setOn(on);
|
||||
}
|
||||
|
||||
// Connect the action
|
||||
connect(addVectorAction, SIGNAL(activated()), this, SLOT(addVector()));
|
||||
connect(addRasterAction, SIGNAL(activated()), this, SLOT(addRaster()));
|
||||
connect(openToolsAction, SIGNAL(activated()), this, SLOT(openTools()));
|
||||
connect(editAction, SIGNAL(activated()), this, SLOT(edit()));
|
||||
connect(mRegionAction, SIGNAL(toggled(bool)), this, SLOT(switchRegion(bool)));
|
||||
connect(editRegionAction, SIGNAL(activated()), this, SLOT(changeRegion()));
|
||||
mRegionAction = new QAction("Display Current Grass Region", QIconSet(icon_grass_region),
|
||||
"Display Current Grass Region",0, this, "region", true);
|
||||
mRegionAction->setWhatsThis("Displays the current GRASS region as a rectangle on the map canvas");
|
||||
QAction *editRegionAction = new QAction("Edit Current Grass Region", QIconSet(icon_grass_region_edit),
|
||||
"Edit Current Grass Region",0, this, "editRegion");
|
||||
editRegionAction->setWhatsThis("Edit the current GRASS region");
|
||||
QAction *editAction = new QAction("Edit Grass Vector layer", QIconSet(icon_grass_edit),
|
||||
"Edit Grass Vector layer",0, this, "edit");
|
||||
editAction->setWhatsThis("Edit the currently selected GRASS vector layer.");
|
||||
if ( !QgsGrass::activeMode() ) {
|
||||
openToolsAction->setEnabled(false);
|
||||
mRegionAction->setEnabled(false);
|
||||
editRegionAction->setEnabled(false);
|
||||
} else {
|
||||
openToolsAction->setEnabled(true);
|
||||
mRegionAction->setEnabled(true);
|
||||
editRegionAction->setEnabled(true);
|
||||
bool on = settings.readBoolEntry ("/qgis/grass/region/on", true );
|
||||
mRegionAction->setOn(on);
|
||||
}
|
||||
|
||||
// Add the toolbar
|
||||
toolBarPointer = new QToolBar((QMainWindow *) qgisMainWindowPointer, "GRASS");
|
||||
toolBarPointer->setLabel("Add GRASS layer");
|
||||
// Connect the action
|
||||
connect(addVectorAction, SIGNAL(activated()), this, SLOT(addVector()));
|
||||
connect(addRasterAction, SIGNAL(activated()), this, SLOT(addRaster()));
|
||||
connect(openToolsAction, SIGNAL(activated()), this, SLOT(openTools()));
|
||||
connect(editAction, SIGNAL(activated()), this, SLOT(edit()));
|
||||
connect(mRegionAction, SIGNAL(toggled(bool)), this, SLOT(switchRegion(bool)));
|
||||
connect(editRegionAction, SIGNAL(activated()), this, SLOT(changeRegion()));
|
||||
|
||||
// Add to the toolbar
|
||||
addVectorAction->addTo(toolBarPointer);
|
||||
addRasterAction->addTo(toolBarPointer);
|
||||
openToolsAction->addTo(toolBarPointer);
|
||||
mRegionAction->addTo(toolBarPointer);
|
||||
editRegionAction->addTo(toolBarPointer);
|
||||
editAction->addTo(toolBarPointer);
|
||||
|
||||
// Connect display region
|
||||
connect( mCanvas, SIGNAL(renderComplete(QPainter *)), this, SLOT(postRender(QPainter *)));
|
||||
// Add the toolbar
|
||||
toolBarPointer = new QToolBar((QMainWindow *) qgisMainWindowPointer, "GRASS");
|
||||
toolBarPointer->setLabel("Add GRASS layer");
|
||||
|
||||
// Init Region symbology
|
||||
mRegionPen.setColor( QColor ( settings.readEntry ("/qgis/grass/region/color", "#ff0000" ) ) );
|
||||
mRegionPen.setWidth( settings.readNumEntry ("/qgis/grass/region/width", 0 ) );
|
||||
// Add to the toolbar
|
||||
addVectorAction->addTo(toolBarPointer);
|
||||
addRasterAction->addTo(toolBarPointer);
|
||||
openToolsAction->addTo(toolBarPointer);
|
||||
mRegionAction->addTo(toolBarPointer);
|
||||
editRegionAction->addTo(toolBarPointer);
|
||||
editAction->addTo(toolBarPointer);
|
||||
|
||||
//openTools(); // debug only
|
||||
// Connect display region
|
||||
connect( mCanvas, SIGNAL(renderComplete(QPainter *)), this, SLOT(postRender(QPainter *)));
|
||||
|
||||
// Init Region symbology
|
||||
mRegionPen.setColor( QColor ( settings.readEntry ("/qgis/grass/region/color", "#ff0000" ) ) );
|
||||
mRegionPen.setWidth( settings.readNumEntry ("/qgis/grass/region/width", 0 ) );
|
||||
|
||||
//openTools(); // debug only
|
||||
}
|
||||
|
||||
/*
|
||||
@ -280,7 +280,7 @@ bool QgsGrassPlugin::isValidGrassBaseDir(QString const gisBase)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
QFileInfo gbi ( gisBase + "/etc/element_list" );
|
||||
if ( gbi.exists() ) {
|
||||
return TRUE;
|
||||
@ -292,280 +292,280 @@ bool QgsGrassPlugin::isValidGrassBaseDir(QString const gisBase)
|
||||
// Slot called when the "Add GRASS vector layer" menu item is activated
|
||||
void QgsGrassPlugin::addVector()
|
||||
{
|
||||
QString uri;
|
||||
QString uri;
|
||||
|
||||
QgsGrassSelect *sel = new QgsGrassSelect(QgsGrassSelect::VECTOR );
|
||||
if ( sel->exec() ) {
|
||||
uri = sel->gisdbase + "/" + sel->location + "/" + sel->mapset + "/" + sel->map + "/" + sel->layer;
|
||||
QgsGrassSelect *sel = new QgsGrassSelect(QgsGrassSelect::VECTOR );
|
||||
if ( sel->exec() ) {
|
||||
uri = sel->gisdbase + "/" + sel->location + "/" + sel->mapset + "/" + sel->map + "/" + sel->layer;
|
||||
}
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "plugin URI: " << uri << std::endl;
|
||||
#endif
|
||||
if ( uri.length() == 0 ) {
|
||||
std::cerr << "Nothing was selected" << std::endl;
|
||||
return;
|
||||
} else {
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Add new vector layer" << std::endl;
|
||||
#endif
|
||||
|
||||
// create vector name: vector layer
|
||||
QString name = sel->map;
|
||||
|
||||
QString field;
|
||||
QString type;
|
||||
|
||||
QRegExp rx ( "(\\d+)_(.+)" );
|
||||
if ( rx.search ( sel->layer ) != -1 )
|
||||
{
|
||||
field = rx.cap(1);
|
||||
type = rx.cap(2);
|
||||
}
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "plugin URI: " << uri << std::endl;
|
||||
#endif
|
||||
if ( uri.length() == 0 ) {
|
||||
std::cerr << "Nothing was selected" << std::endl;
|
||||
return;
|
||||
|
||||
// Set location
|
||||
QgsGrass::setLocation ( sel->gisdbase, sel->location );
|
||||
|
||||
/* Open vector */
|
||||
QgsGrass::resetError();
|
||||
Vect_set_open_level (2);
|
||||
struct Map_info map;
|
||||
int level = Vect_open_old_head (&map, (char *) sel->map.ascii(),
|
||||
(char *) sel->mapset.ascii());
|
||||
|
||||
if ( QgsGrass::getError() != QgsGrass::FATAL )
|
||||
{
|
||||
if ( level >= 2 )
|
||||
{
|
||||
// Count layers
|
||||
int cnt = 0;
|
||||
int ncidx = Vect_cidx_get_num_fields ( &map );
|
||||
|
||||
for ( int i = 0; i < ncidx; i++ )
|
||||
{
|
||||
int field = Vect_cidx_get_field_number ( &map, i);
|
||||
|
||||
if ( Vect_cidx_get_type_count( &map, field, GV_POINT|GV_LINE|GV_AREA) > 0 ||
|
||||
(field > 1 && Vect_cidx_get_type_count( &map, field, GV_BOUNDARY) ) )
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
if( cnt > 1 )
|
||||
{
|
||||
name.append ( " " + field );
|
||||
|
||||
// No need to ad type, the type is obvious from the legend
|
||||
}
|
||||
}
|
||||
|
||||
Vect_close ( &map );
|
||||
} else {
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Add new vector layer" << std::endl;
|
||||
#endif
|
||||
|
||||
// create vector name: vector layer
|
||||
QString name = sel->map;
|
||||
|
||||
QString field;
|
||||
QString type;
|
||||
|
||||
QRegExp rx ( "(\\d+)_(.+)" );
|
||||
if ( rx.search ( sel->layer ) != -1 )
|
||||
{
|
||||
field = rx.cap(1);
|
||||
type = rx.cap(2);
|
||||
}
|
||||
|
||||
// Set location
|
||||
QgsGrass::setLocation ( sel->gisdbase, sel->location );
|
||||
|
||||
/* Open vector */
|
||||
QgsGrass::resetError();
|
||||
Vect_set_open_level (2);
|
||||
struct Map_info map;
|
||||
int level = Vect_open_old_head (&map, (char *) sel->map.ascii(),
|
||||
(char *) sel->mapset.ascii());
|
||||
|
||||
if ( QgsGrass::getError() != QgsGrass::FATAL )
|
||||
{
|
||||
if ( level >= 2 )
|
||||
{
|
||||
// Count layers
|
||||
int cnt = 0;
|
||||
int ncidx = Vect_cidx_get_num_fields ( &map );
|
||||
|
||||
for ( int i = 0; i < ncidx; i++ )
|
||||
{
|
||||
int field = Vect_cidx_get_field_number ( &map, i);
|
||||
|
||||
if ( Vect_cidx_get_type_count( &map, field, GV_POINT|GV_LINE|GV_AREA) > 0 ||
|
||||
(field > 1 && Vect_cidx_get_type_count( &map, field, GV_BOUNDARY) ) )
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
if( cnt > 1 )
|
||||
{
|
||||
name.append ( " " + field );
|
||||
|
||||
// No need to ad type, the type is obvious from the legend
|
||||
}
|
||||
}
|
||||
|
||||
Vect_close ( &map );
|
||||
} else {
|
||||
std::cerr << "Cannot open GRASS vector: " << QgsGrass::getErrorMessage() << std::endl;
|
||||
}
|
||||
|
||||
qGisInterface->addVectorLayer( uri, name, "grass");
|
||||
std::cerr << "Cannot open GRASS vector: " << QgsGrass::getErrorMessage() << std::endl;
|
||||
}
|
||||
|
||||
qGisInterface->addVectorLayer( uri, name, "grass");
|
||||
}
|
||||
}
|
||||
|
||||
// Slot called when the "Add GRASS raster layer" menu item is activated
|
||||
void QgsGrassPlugin::addRaster()
|
||||
{
|
||||
QString uri;
|
||||
QString uri;
|
||||
|
||||
std::cerr << "QgsGrassPlugin::addRaster" << std::endl;
|
||||
std::cerr << "QgsGrassPlugin::addRaster" << std::endl;
|
||||
|
||||
QgsGrassSelect *sel = new QgsGrassSelect(QgsGrassSelect::RASTER );
|
||||
if ( sel->exec() ) {
|
||||
QString element;
|
||||
if ( sel->selectedType == QgsGrassSelect::RASTER ) {
|
||||
QgsGrassSelect *sel = new QgsGrassSelect(QgsGrassSelect::RASTER );
|
||||
if ( sel->exec() ) {
|
||||
QString element;
|
||||
if ( sel->selectedType == QgsGrassSelect::RASTER ) {
|
||||
element = "cellhd";
|
||||
} else { // GROUP
|
||||
} else { // GROUP
|
||||
element = "group";
|
||||
}
|
||||
|
||||
uri = sel->gisdbase + "/" + sel->location + "/" + sel->mapset + "/" + element + "/" + sel->map;
|
||||
}
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "plugin URI: " << uri << std::endl;
|
||||
#endif
|
||||
if ( uri.length() == 0 ) {
|
||||
std::cerr << "Nothing was selected" << std::endl;
|
||||
return;
|
||||
} else {
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Add new raster layer" << std::endl;
|
||||
#endif
|
||||
// create raster name
|
||||
int pos = uri.findRev('/');
|
||||
pos = uri.findRev('/', pos-1);
|
||||
QString name = uri.right( uri.length() - pos - 1 );
|
||||
name.replace('/', ' ');
|
||||
|
||||
qGisInterface->addRasterLayer( uri );
|
||||
}
|
||||
uri = sel->gisdbase + "/" + sel->location + "/" + sel->mapset + "/" + element + "/" + sel->map;
|
||||
}
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "plugin URI: " << uri << std::endl;
|
||||
#endif
|
||||
if ( uri.length() == 0 ) {
|
||||
std::cerr << "Nothing was selected" << std::endl;
|
||||
return;
|
||||
} else {
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Add new raster layer" << std::endl;
|
||||
#endif
|
||||
// create raster name
|
||||
int pos = uri.findRev('/');
|
||||
pos = uri.findRev('/', pos-1);
|
||||
QString name = uri.right( uri.length() - pos - 1 );
|
||||
name.replace('/', ' ');
|
||||
|
||||
qGisInterface->addRasterLayer( uri );
|
||||
}
|
||||
}
|
||||
|
||||
// Open tools
|
||||
void QgsGrassPlugin::openTools()
|
||||
{
|
||||
if ( !mTools )
|
||||
mTools = new QgsGrassTools ( qgisMainWindowPointer, qGisInterface, qgisMainWindowPointer, 0, Qt::WType_Dialog );
|
||||
if ( !mTools )
|
||||
mTools = new QgsGrassTools ( qgisMainWindowPointer, qGisInterface, qgisMainWindowPointer, 0, Qt::WType_Dialog );
|
||||
|
||||
mTools->show();
|
||||
mTools->show();
|
||||
}
|
||||
|
||||
|
||||
// Start vector editing
|
||||
void QgsGrassPlugin::edit()
|
||||
{
|
||||
if ( QgsGrassEdit::isRunning() ) {
|
||||
QMessageBox::warning( 0, "Warning", "GRASS Edit is already running." );
|
||||
return;
|
||||
}
|
||||
if ( QgsGrassEdit::isRunning() ) {
|
||||
QMessageBox::warning( 0, "Warning", "GRASS Edit is already running." );
|
||||
return;
|
||||
}
|
||||
|
||||
QgsGrassEdit *ed = new QgsGrassEdit( qgisMainWindowPointer, qGisInterface, qgisMainWindowPointer, 0, Qt::WType_Dialog );
|
||||
QgsGrassEdit *ed = new QgsGrassEdit( qgisMainWindowPointer, qGisInterface, qgisMainWindowPointer, 0, Qt::WType_Dialog );
|
||||
|
||||
if ( ed->isValid() ) {
|
||||
ed->show();
|
||||
mCanvas->refresh();
|
||||
} else {
|
||||
delete ed;
|
||||
}
|
||||
if ( ed->isValid() ) {
|
||||
ed->show();
|
||||
mCanvas->refresh();
|
||||
} else {
|
||||
delete ed;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGrassPlugin::postRender(QPainter *painter)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::postRender()" << std::endl;
|
||||
#endif
|
||||
|
||||
if ( QgsGrass::activeMode() && mRegionAction->isEnabled() && mRegionAction->isOn() ) {
|
||||
displayRegion(painter);
|
||||
}
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::postRender()" << std::endl;
|
||||
#endif
|
||||
|
||||
if ( QgsGrass::activeMode() && mRegionAction->isEnabled() && mRegionAction->isOn() ) {
|
||||
displayRegion(painter);
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGrassPlugin::displayRegion(QPainter *painter)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::displayRegion()" << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::displayRegion()" << std::endl;
|
||||
#endif
|
||||
|
||||
// Display region of current mapset if in active mode
|
||||
if ( !QgsGrass::activeMode() ) return;
|
||||
|
||||
QString gisdbase = QgsGrass::getDefaultGisdbase();
|
||||
QString location = QgsGrass::getDefaultLocation();
|
||||
QString mapset = QgsGrass::getDefaultMapset();
|
||||
// Display region of current mapset if in active mode
|
||||
if ( !QgsGrass::activeMode() ) return;
|
||||
|
||||
if ( gisdbase.isEmpty() || location.isEmpty() || mapset.isEmpty() ) {
|
||||
QMessageBox::warning( 0, "Warning", "GISDBASE, LOCATION_NAME or MAPSET is not set, "
|
||||
"cannot display current region." );
|
||||
return;
|
||||
}
|
||||
QString gisdbase = QgsGrass::getDefaultGisdbase();
|
||||
QString location = QgsGrass::getDefaultLocation();
|
||||
QString mapset = QgsGrass::getDefaultMapset();
|
||||
|
||||
QgsGrass::setLocation ( gisdbase, location );
|
||||
|
||||
struct Cell_head window;
|
||||
char *err = G__get_window ( &window, "", "WIND", (char *) mapset.latin1() );
|
||||
if ( gisdbase.isEmpty() || location.isEmpty() || mapset.isEmpty() ) {
|
||||
QMessageBox::warning( 0, "Warning", "GISDBASE, LOCATION_NAME or MAPSET is not set, "
|
||||
"cannot display current region." );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( err ) {
|
||||
QMessageBox::warning( 0, "Warning", "Cannot read current region: " + QString(err) );
|
||||
return;
|
||||
}
|
||||
QgsGrass::setLocation ( gisdbase, location );
|
||||
|
||||
std::vector<QgsPoint> points;
|
||||
points.resize(5);
|
||||
|
||||
points[0].setX(window.west); points[0].setY(window.south);
|
||||
points[1].setX(window.east); points[1].setY(window.south);
|
||||
points[2].setX(window.east); points[2].setY(window.north);
|
||||
points[3].setX(window.west); points[3].setY(window.north);
|
||||
points[4].setX(window.west); points[4].setY(window.south);
|
||||
struct Cell_head window;
|
||||
char *err = G__get_window ( &window, "", "WIND", (char *) mapset.latin1() );
|
||||
|
||||
QgsMapToPixel *transform = mCanvas->getCoordinateTransform();
|
||||
QPointArray pointArray(5);
|
||||
if ( err ) {
|
||||
QMessageBox::warning( 0, "Warning", "Cannot read current region: " + QString(err) );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < 5; i++ ) {
|
||||
transform->transform( &(points[i]) );
|
||||
pointArray.setPoint( i,
|
||||
static_cast<int>(points[i].x()),
|
||||
static_cast<int>(points[i].y()) );
|
||||
}
|
||||
std::vector<QgsPoint> points;
|
||||
points.resize(5);
|
||||
|
||||
painter->setPen ( mRegionPen );
|
||||
painter->drawPolyline ( pointArray );
|
||||
points[0].setX(window.west); points[0].setY(window.south);
|
||||
points[1].setX(window.east); points[1].setY(window.south);
|
||||
points[2].setX(window.east); points[2].setY(window.north);
|
||||
points[3].setX(window.west); points[3].setY(window.north);
|
||||
points[4].setX(window.west); points[4].setY(window.south);
|
||||
|
||||
QgsMapToPixel *transform = mCanvas->getCoordinateTransform();
|
||||
QPointArray pointArray(5);
|
||||
|
||||
for ( int i = 0; i < 5; i++ ) {
|
||||
transform->transform( &(points[i]) );
|
||||
pointArray.setPoint( i,
|
||||
static_cast<int>(points[i].x()),
|
||||
static_cast<int>(points[i].y()) );
|
||||
}
|
||||
|
||||
painter->setPen ( mRegionPen );
|
||||
painter->drawPolyline ( pointArray );
|
||||
}
|
||||
|
||||
void QgsGrassPlugin::switchRegion(bool on)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::switchRegion()" << std::endl;
|
||||
#endif
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::switchRegion()" << std::endl;
|
||||
#endif
|
||||
|
||||
QSettings settings;
|
||||
settings.writeEntry ("/qgis/grass/region/on", on );
|
||||
QSettings settings;
|
||||
settings.writeEntry ("/qgis/grass/region/on", on );
|
||||
|
||||
QPixmap *pixmap = mCanvas->canvasPixmap();
|
||||
QPainter p;
|
||||
p.begin(pixmap);
|
||||
|
||||
if ( on ) {
|
||||
displayRegion(&p);
|
||||
} else {
|
||||
// This is not perfect, but user can see reaction and it is fast
|
||||
QPen pen = mRegionPen;
|
||||
mRegionPen.setColor( QColor(255,255,255) ); // TODO: background color
|
||||
displayRegion(&p);
|
||||
mRegionPen = pen;
|
||||
}
|
||||
|
||||
p.end();
|
||||
mCanvas->repaint(false);
|
||||
QPixmap *pixmap = mCanvas->canvasPixmap();
|
||||
QPainter p;
|
||||
p.begin(pixmap);
|
||||
|
||||
if ( on ) {
|
||||
displayRegion(&p);
|
||||
} else {
|
||||
// This is not perfect, but user can see reaction and it is fast
|
||||
QPen pen = mRegionPen;
|
||||
mRegionPen.setColor( QColor(255,255,255) ); // TODO: background color
|
||||
displayRegion(&p);
|
||||
mRegionPen = pen;
|
||||
}
|
||||
|
||||
p.end();
|
||||
mCanvas->repaint(false);
|
||||
}
|
||||
|
||||
void QgsGrassPlugin::changeRegion(void)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::changeRegion()" << std::endl;
|
||||
#endif
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsGrassPlugin::changeRegion()" << std::endl;
|
||||
#endif
|
||||
|
||||
if ( QgsGrassRegion::isRunning() ) {
|
||||
QMessageBox::warning( 0, "Warning", "The Region tool is already running." );
|
||||
return;
|
||||
}
|
||||
if ( QgsGrassRegion::isRunning() ) {
|
||||
QMessageBox::warning( 0, "Warning", "The Region tool is already running." );
|
||||
return;
|
||||
}
|
||||
|
||||
QgsGrassRegion *reg = new QgsGrassRegion(this, qgisMainWindowPointer, qGisInterface,
|
||||
qgisMainWindowPointer, 0,
|
||||
Qt::WType_Dialog );
|
||||
QgsGrassRegion *reg = new QgsGrassRegion(this, qgisMainWindowPointer, qGisInterface,
|
||||
qgisMainWindowPointer, 0,
|
||||
Qt::WType_Dialog );
|
||||
|
||||
reg->show();
|
||||
reg->show();
|
||||
}
|
||||
|
||||
QPen & QgsGrassPlugin::regionPen()
|
||||
{
|
||||
return mRegionPen;
|
||||
return mRegionPen;
|
||||
}
|
||||
|
||||
void QgsGrassPlugin::setRegionPen(QPen & pen)
|
||||
{
|
||||
mRegionPen = pen;
|
||||
|
||||
QSettings settings;
|
||||
settings.writeEntry ("/qgis/grass/region/color", mRegionPen.color().name() );
|
||||
settings.writeEntry ("/qgis/grass/region/width", (int) mRegionPen.width() );
|
||||
mRegionPen = pen;
|
||||
|
||||
QSettings settings;
|
||||
settings.writeEntry ("/qgis/grass/region/color", mRegionPen.color().name() );
|
||||
settings.writeEntry ("/qgis/grass/region/width", (int) mRegionPen.width() );
|
||||
}
|
||||
|
||||
// Unload the plugin by cleaning up the GUI
|
||||
void QgsGrassPlugin::unload()
|
||||
{
|
||||
// remove the GUI
|
||||
if ( menuBarPointer )
|
||||
menuBarPointer->removeItem(menuIdInt);
|
||||
// remove the GUI
|
||||
if ( menuBarPointer )
|
||||
menuBarPointer->removeItem(menuIdInt);
|
||||
|
||||
if ( toolBarPointer )
|
||||
delete toolBarPointer;
|
||||
if ( toolBarPointer )
|
||||
delete toolBarPointer;
|
||||
}
|
||||
/**
|
||||
* Required extern functions needed for every plugin
|
||||
@ -575,36 +575,36 @@ void QgsGrassPlugin::unload()
|
||||
// Class factory to return a new instance of the plugin class
|
||||
extern "C" QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
|
||||
{
|
||||
return new QgsGrassPlugin(theQGisAppPointer, theQgisInterfacePointer);
|
||||
return new QgsGrassPlugin(theQGisAppPointer, theQgisInterfacePointer);
|
||||
}
|
||||
|
||||
// Return the name of the plugin - note that we do not user class members as
|
||||
// the class may not yet be insantiated when this method is called.
|
||||
extern "C" QString name()
|
||||
{
|
||||
return QString("GRASS");
|
||||
return QString("GRASS");
|
||||
}
|
||||
|
||||
// Return the description
|
||||
extern "C" QString description()
|
||||
{
|
||||
return QString("GRASS layer");
|
||||
return QString("GRASS layer");
|
||||
}
|
||||
|
||||
// Return the type (either UI or MapLayer plugin)
|
||||
extern "C" int type()
|
||||
{
|
||||
return QgisPlugin::UI;
|
||||
return QgisPlugin::UI;
|
||||
}
|
||||
|
||||
// Return the version number for the plugin
|
||||
extern "C" QString version()
|
||||
{
|
||||
return pluginVersion;
|
||||
return pluginVersion;
|
||||
}
|
||||
|
||||
// Delete ourself
|
||||
extern "C" void unload(QgisPlugin * thePluginPointer)
|
||||
{
|
||||
delete thePluginPointer;
|
||||
delete thePluginPointer;
|
||||
}
|
||||
|
@ -133,39 +133,55 @@ void GraticuleCreator::generateGraticule(DBFHandle theDbfHandle,
|
||||
//create the arrays for storing the coordinates
|
||||
double * myXArrayDouble;
|
||||
double * myYArrayDouble;
|
||||
myXArrayDouble = (double *)malloc(2 * sizeof(double)); //2=no vertices
|
||||
myYArrayDouble = (double *)malloc(2 * sizeof(double));
|
||||
//we want out graticule to be made of short line segments rather tban
|
||||
//long ones that imply span xmin <-> xmax
|
||||
//so that when reprojecting the graticule will warp properly
|
||||
//so first we need to work out how many intersections there are...
|
||||
//
|
||||
|
||||
long myXIntersectionCount = ((theXEndPointDouble - theXOriginDouble) / theXIntervalDouble)+1;
|
||||
long myYIntersectionCount = ((theYEndPointDouble - theYOriginDouble) / theYIntervalDouble)+1;
|
||||
|
||||
|
||||
//
|
||||
//Longitude loop
|
||||
//
|
||||
myXArrayDouble = (double *)malloc(myYIntersectionCount * sizeof(double));
|
||||
myYArrayDouble = (double *)malloc(myYIntersectionCount * sizeof(double));
|
||||
for (double myXDouble = theXOriginDouble;myXDouble <=theXEndPointDouble;myXDouble+=theXIntervalDouble)
|
||||
{
|
||||
|
||||
myXArrayDouble[0]=myXDouble;
|
||||
myXArrayDouble[1]=myXDouble;
|
||||
myYArrayDouble[0]=theYOriginDouble;
|
||||
myYArrayDouble[1]=theYEndPointDouble;
|
||||
|
||||
long myVertexNo=0;
|
||||
for (double myYDouble=theYOriginDouble;myYDouble<=theYEndPointDouble;myYDouble+=theYIntervalDouble)
|
||||
{
|
||||
myXArrayDouble[myVertexNo]=myXDouble;
|
||||
myYArrayDouble[myVertexNo]=myYDouble;
|
||||
++myVertexNo;
|
||||
}
|
||||
writeDbfRecord(theDbfHandle,myRecordInt,"testing");
|
||||
writeLine(theShapeHandle, myRecordInt, 2, myXArrayDouble, myYArrayDouble); //2=no vertices
|
||||
|
||||
writeLine(theShapeHandle, myRecordInt, myYIntersectionCount, myXArrayDouble, myYArrayDouble);
|
||||
|
||||
++myRecordInt;
|
||||
}
|
||||
delete myXArrayDouble;
|
||||
delete myYArrayDouble;
|
||||
|
||||
//
|
||||
//Latitude loop
|
||||
//
|
||||
myXArrayDouble = (double *)malloc(myXIntersectionCount * sizeof(double));
|
||||
myYArrayDouble = (double *)malloc(myXIntersectionCount * sizeof(double));
|
||||
for (double myYDouble=theYOriginDouble;myYDouble<=theYEndPointDouble;myYDouble+=theYIntervalDouble)
|
||||
{
|
||||
|
||||
myXArrayDouble[0]=theXOriginDouble;
|
||||
myXArrayDouble[1]=theXEndPointDouble;
|
||||
myYArrayDouble[0]=myYDouble;
|
||||
myYArrayDouble[1]=myYDouble;
|
||||
long myVertexNo=0;
|
||||
for (double myXDouble=theXOriginDouble;myXDouble<=theXEndPointDouble;myXDouble+=theXIntervalDouble)
|
||||
{
|
||||
myXArrayDouble[myVertexNo]=myXDouble;
|
||||
myYArrayDouble[myVertexNo]=myYDouble;
|
||||
++myVertexNo;
|
||||
}
|
||||
|
||||
writeDbfRecord(theDbfHandle,myRecordInt,"testing");
|
||||
writeLine(theShapeHandle, myRecordInt, 2, myXArrayDouble, myYArrayDouble); //2=no vertices
|
||||
writeLine(theShapeHandle, myRecordInt,myXIntersectionCount, myXArrayDouble, myYArrayDouble);
|
||||
|
||||
++myRecordInt;
|
||||
}
|
||||
|
@ -215,6 +215,15 @@ public:
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
/** The delimited text provider does not do its own transforms so we return
|
||||
* false for the following three functions to indicate that transforms
|
||||
* should be handled by the QgsCoordinateTransform object. See the
|
||||
* documentation on QgsVectorDataProvider for details on these functions.
|
||||
*/
|
||||
bool supportsNativeTransform(){return false;}
|
||||
bool usesSrid(){return false;}
|
||||
bool usesWKT(){return false;}
|
||||
|
||||
private:
|
||||
|
||||
/** get the next feature, if any
|
||||
|
@ -8,12 +8,12 @@ plugindir = ${pkglibdir}
|
||||
plugin_LTLIBRARIES = gpxprovider.la
|
||||
|
||||
gpxprovider_la_SOURCES = qgsgpxprovider.cpp \
|
||||
gpsdata.cpp \
|
||||
../../src/qgsfeature.cpp \
|
||||
../../src/qgsfeatureattribute.cpp \
|
||||
../../src/qgsrect.cpp \
|
||||
../../src/qgspoint.cpp \
|
||||
../../src/qgsfield.cpp
|
||||
gpsdata.cpp \
|
||||
../../src/qgsfeature.cpp \
|
||||
../../src/qgsfeatureattribute.cpp \
|
||||
../../src/qgsrect.cpp \
|
||||
../../src/qgspoint.cpp \
|
||||
../../src/qgsfield.cpp
|
||||
|
||||
|
||||
gpxprovider_la_LIBADD = $(QT_LDADD) $(GEOS_LDADD)
|
||||
@ -22,4 +22,4 @@ gpxprovider_la_CXXFLAGS = $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) $(DEBUG_QGIS) $(GEOS_
|
||||
|
||||
EXTRA_DIST = qgsgpxprovider.h gpsdata.h
|
||||
|
||||
endif
|
||||
endif
|
||||
|
@ -108,7 +108,7 @@ void Track::writeXML(QTextStream& stream) {
|
||||
stream<<"<trkseg>\n";
|
||||
for (int j = 0; j < segments[i].points.size(); ++j) {
|
||||
stream<<"<trkpt lat=\""<<segments[i].points[j].lat
|
||||
<<"\" lon=\""<<segments[i].points[j].lon<<"\">\n";
|
||||
<<"\" lon=\""<<segments[i].points[j].lon<<"\">\n";
|
||||
segments[i].points[j].writeXML(stream);
|
||||
stream<<"</trkpt>\n";
|
||||
}
|
||||
@ -180,7 +180,7 @@ GPSData::TrackIterator GPSData::tracksEnd() {
|
||||
|
||||
|
||||
GPSData::WaypointIterator GPSData::addWaypoint(double lat, double lon,
|
||||
QString name, double ele) {
|
||||
QString name, double ele) {
|
||||
Waypoint wpt;
|
||||
wpt.lat = lat;
|
||||
wpt.lon = lon;
|
||||
@ -292,7 +292,7 @@ void GPSData::removeTracks(std::list<int> const & ids) {
|
||||
void GPSData::writeXML(QTextStream& stream) {
|
||||
stream.setEncoding(QTextStream::UnicodeUTF8);
|
||||
stream<<"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
<<"<gpx version=\"1.0\" creator=\"Quantum GIS\">\n";
|
||||
<<"<gpx version=\"1.0\" creator=\"Quantum GIS\">\n";
|
||||
for (WaypointIterator wIter = waypoints.begin();
|
||||
wIter != waypoints.end(); ++wIter)
|
||||
wIter->writeXML(stream);
|
||||
@ -326,13 +326,13 @@ GPSData* GPSData::getData(const QString& filename) {
|
||||
while (!file.atEnd()) {
|
||||
long int readBytes = file.readBlock(buffer, bufsize);
|
||||
if (file.atEnd())
|
||||
atEnd = 1;
|
||||
atEnd = 1;
|
||||
if (!XML_Parse(p, buffer, readBytes, atEnd)) {
|
||||
std::cerr<<"Parse error at line "
|
||||
<<XML_GetCurrentLineNumber(p)<<": "
|
||||
<<XML_ErrorString(XML_GetErrorCode(p))<<std::endl;
|
||||
failed = true;
|
||||
break;
|
||||
std::cerr<<"Parse error at line "
|
||||
<<XML_GetCurrentLineNumber(p)<<": "
|
||||
<<XML_ErrorString(XML_GetErrorCode(p))<<std::endl;
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete [] buffer;
|
||||
@ -387,9 +387,9 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
mWpt = Waypoint();
|
||||
for (int i = 0; attr[2*i] != NULL; ++i) {
|
||||
if (!std::strcmp(attr[2*i], "lat"))
|
||||
mWpt.lat = QString(attr[2*i+1]).toDouble();
|
||||
mWpt.lat = QString(attr[2*i+1]).toDouble();
|
||||
else if (!std::strcmp(attr[2*i], "lon"))
|
||||
mWpt.lon = QString(attr[2*i+1]).toDouble();
|
||||
mWpt.lon = QString(attr[2*i+1]).toDouble();
|
||||
}
|
||||
mObj = &mWpt;
|
||||
}
|
||||
@ -407,8 +407,8 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
// common properties
|
||||
else if (!std::strcmp(qName, "name")) {
|
||||
if (parseModes.top() == ParsingWaypoint ||
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
mString = &mObj->name;
|
||||
mCharBuffer = "";
|
||||
parseModes.push(ParsingString);
|
||||
@ -418,8 +418,8 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
}
|
||||
else if (!std::strcmp(qName, "cmt")) {
|
||||
if (parseModes.top() == ParsingWaypoint ||
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
mString = &mObj->cmt;
|
||||
mCharBuffer = "";
|
||||
parseModes.push(ParsingString);
|
||||
@ -429,8 +429,8 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
}
|
||||
else if (!std::strcmp(qName, "desc")) {
|
||||
if (parseModes.top() == ParsingWaypoint ||
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
mString = &mObj->desc;
|
||||
mCharBuffer = "";
|
||||
parseModes.push(ParsingString);
|
||||
@ -440,8 +440,8 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
}
|
||||
else if (!std::strcmp(qName, "src")) {
|
||||
if (parseModes.top() == ParsingWaypoint ||
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
mString = &mObj->src;
|
||||
mCharBuffer = "";
|
||||
parseModes.push(ParsingString);
|
||||
@ -451,8 +451,8 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
}
|
||||
else if (!std::strcmp(qName, "url")) {
|
||||
if (parseModes.top() == ParsingWaypoint ||
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
mString = &mObj->url;
|
||||
mCharBuffer = "";
|
||||
parseModes.push(ParsingString);
|
||||
@ -462,8 +462,8 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
}
|
||||
else if (!std::strcmp(qName, "urlname")) {
|
||||
if (parseModes.top() == ParsingWaypoint ||
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
parseModes.top() == ParsingRoute ||
|
||||
parseModes.top() == ParsingTrack) {
|
||||
mString = &mObj->urlname;
|
||||
mCharBuffer = "";
|
||||
parseModes.push(ParsingString);
|
||||
@ -512,10 +512,10 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
if (parseModes.top() == ParsingRoute) {
|
||||
mRtept = Routepoint();
|
||||
for (int i = 0; attr[2*i] != NULL; ++i) {
|
||||
if (!std::strcmp(attr[2*i], "lat"))
|
||||
mRtept.lat = QString(attr[2*i+1]).toDouble();
|
||||
else if (!std::strcmp(attr[2*i], "lon"))
|
||||
mRtept.lon = QString(attr[2*i+1]).toDouble();
|
||||
if (!std::strcmp(attr[2*i], "lat"))
|
||||
mRtept.lat = QString(attr[2*i+1]).toDouble();
|
||||
else if (!std::strcmp(attr[2*i], "lon"))
|
||||
mRtept.lon = QString(attr[2*i+1]).toDouble();
|
||||
}
|
||||
parseModes.push(ParsingRoutepoint);
|
||||
}
|
||||
@ -536,10 +536,10 @@ bool GPXHandler::startElement(const XML_Char* qName, const XML_Char** attr) {
|
||||
if (parseModes.top() == ParsingTrackSegment) {
|
||||
mTrkpt = Trackpoint();
|
||||
for (int i = 0; attr[2*i] != NULL; ++i) {
|
||||
if (!std::strcmp(attr[2*i], "lat"))
|
||||
mTrkpt.lat = QString(attr[2*i+1]).toDouble();
|
||||
else if (!std::strcmp(attr[2*i], "lon"))
|
||||
mTrkpt.lon = QString(attr[2*i+1]).toDouble();
|
||||
if (!std::strcmp(attr[2*i], "lat"))
|
||||
mTrkpt.lat = QString(attr[2*i+1]).toDouble();
|
||||
else if (!std::strcmp(attr[2*i], "lon"))
|
||||
mTrkpt.lon = QString(attr[2*i+1]).toDouble();
|
||||
}
|
||||
parseModes.push(ParsingTrackpoint);
|
||||
}
|
||||
|
@ -420,6 +420,8 @@ public:
|
||||
int cidxGetMaxCat ( int idx );
|
||||
/** get data source uri (not implemented) */
|
||||
QgsDataSourceURI * getURI(){ return 0;};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
// Layer type (layerType)
|
||||
|
@ -173,6 +173,12 @@ QString QgsOgrProvider::getProjectionWKT()
|
||||
// morph it
|
||||
mySpatialRefSys->morphFromESRI();
|
||||
}
|
||||
// get the proj4 text
|
||||
char * ppszProj4;
|
||||
mySpatialRefSys->exportToProj4 ( &ppszProj4 );
|
||||
std::cout << "vvvvvvvvvvvvvvvvv PROJ4 TEXT vvvvvvvvvvvvvvv" << std::endl;
|
||||
std::cout << ppszProj4 << std::endl;
|
||||
std::cout << "^^^^^^^^^^^^^^^^^ PROJ4 TEXT ^^^^^^^^^^^^^^^" << std::endl;
|
||||
char *pszWKT = NULL;
|
||||
mySpatialRefSys->exportToWkt( &pszWKT );
|
||||
QString myWKTString = QString(pszWKT);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -50,374 +50,390 @@ data residing in a PostgreSQL/PostGIS enabled database.
|
||||
*/
|
||||
class QgsPostgresProvider:public QgsVectorDataProvider
|
||||
{
|
||||
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the provider. The uri must be in the following format:
|
||||
* host=localhost user=gsherman dbname=test password=xxx table=test.alaska (the_geom)
|
||||
* @param uri String containing the required parameters to connect to the database
|
||||
* and query the table.
|
||||
*/
|
||||
QgsPostgresProvider(QString uri = 0);
|
||||
public:
|
||||
/**
|
||||
* Constructor for the provider. The uri must be in the following format:
|
||||
* host=localhost user=gsherman dbname=test password=xxx table=test.alaska (the_geom)
|
||||
* @param uri String containing the required parameters to connect to the database
|
||||
* and query the table.
|
||||
*/
|
||||
QgsPostgresProvider(QString uri = 0);
|
||||
|
||||
//! Destructor
|
||||
virtual ~ QgsPostgresProvider();
|
||||
//! Destructor
|
||||
virtual ~ QgsPostgresProvider();
|
||||
|
||||
/** Used to ask the layer for its projection as a WKT string. Implements
|
||||
* virtual method of same name in QgsDataProvider. */
|
||||
QString getProjectionWKT() {return QString("Not implemented yet");} ;
|
||||
/** Used to ask the layer for its projection as a WKT string. Implements
|
||||
* virtual method of same name in QgsDataProvider. */
|
||||
QString getProjectionWKT() {return QString("Not implemented yet");} ;
|
||||
|
||||
/**
|
||||
* Get the first feature resutling from a select operation
|
||||
* @return QgsFeature
|
||||
/**
|
||||
* Get the first feature resutling from a select operation
|
||||
* @return QgsFeature
|
||||
*/
|
||||
QgsFeature *getFirstFeature(bool fetchAttributes = false);
|
||||
|
||||
/**
|
||||
* Get the next feature resulting from a select operation
|
||||
* @return QgsFeature
|
||||
*/
|
||||
QgsFeature *getNextFeature(bool fetchAttributes = false);
|
||||
bool getNextFeature(QgsFeature &feature, bool fetchAttributes=0);
|
||||
|
||||
/**Get the next feature resulting from a select operation.
|
||||
*@param attlist a list containing the indexes of the attribute fields to copy
|
||||
*@param getnotcommited flag indicating if not commited features should be returned
|
||||
*/
|
||||
QgsFeature* getNextFeature(std::list<int> const & attlist);
|
||||
/** Get the feature type. This corresponds to
|
||||
* WKBPoint,
|
||||
* WKBLineString,
|
||||
* WKBPolygon,
|
||||
* WKBMultiPoint,
|
||||
* WKBMultiLineString or
|
||||
* WKBMultiPolygon
|
||||
* as defined in qgis.h
|
||||
*/
|
||||
|
||||
int geometryType() const;
|
||||
|
||||
/**
|
||||
* Get the number of features in the layer
|
||||
*/
|
||||
long featureCount() const;
|
||||
|
||||
/**
|
||||
* Get the number of fields in the layer
|
||||
*/
|
||||
int fieldCount() const;
|
||||
|
||||
/**
|
||||
* Select features based on a bounding rectangle. Features can be retrieved
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
*/
|
||||
void select(QgsRect * mbr, bool useIntersect=false);
|
||||
|
||||
/**
|
||||
* Get the data source URI structure used by this layer
|
||||
*/
|
||||
QgsDataSourceURI * getURI();
|
||||
|
||||
/**
|
||||
* Set the data source URI used by this layer
|
||||
*/
|
||||
void setURI(QgsDataSourceURI &uri);
|
||||
|
||||
/**
|
||||
* Set the data source specification. This must be a valid database
|
||||
* connection string:
|
||||
* host=localhost user=gsherman dbname=test password=xxx table=test.alaska (the_geom)
|
||||
* @uri data source specification
|
||||
*/
|
||||
// TODO Deprecate this in favor of using the QgsDataSourceURI structure
|
||||
void setDataSourceUri(QString uri);
|
||||
|
||||
/**
|
||||
* Get the data source specification.
|
||||
* @return data source specification as a string containing the host, user,
|
||||
* dbname, password, and table
|
||||
* @see setDataSourceUri
|
||||
*/
|
||||
// TODO Deprecate this in favor of returning the QgsDataSourceURI structure
|
||||
QString getDataSourceUri();
|
||||
|
||||
/**
|
||||
* Identify features within the search radius specified by rect
|
||||
* @param rect Bounding rectangle of search radius
|
||||
* @return std::vector containing QgsFeature objects that intersect rect
|
||||
*/
|
||||
virtual std::vector<QgsFeature>& identify(QgsRect * rect);
|
||||
|
||||
/**
|
||||
* Return a string representation of the endian-ness for the layer
|
||||
*/
|
||||
QString endianString();
|
||||
|
||||
/**
|
||||
* Changes the stored extent for this layer to the supplied extent.
|
||||
* For example, this is called when the extent worker thread has a result.
|
||||
*/
|
||||
void setExtent( QgsRect* newExtent );
|
||||
|
||||
/** Return the extent for this data layer
|
||||
*/
|
||||
QgsFeature *getFirstFeature(bool fetchAttributes = false);
|
||||
virtual QgsRect *extent();
|
||||
|
||||
/**
|
||||
* Get the next feature resulting from a select operation
|
||||
* @return QgsFeature
|
||||
*/
|
||||
QgsFeature *getNextFeature(bool fetchAttributes = false);
|
||||
bool getNextFeature(QgsFeature &feature, bool fetchAttributes=0);
|
||||
/**
|
||||
* Get the attributes associated with a feature
|
||||
*/
|
||||
void getFeatureAttributes(int oid, QgsFeature *f);
|
||||
|
||||
/**Get the next feature resulting from a select operation.
|
||||
*@param attlist a list containing the indexes of the attribute fields to copy
|
||||
*@param getnotcommited flag indicating if not commited features should be returned
|
||||
*/
|
||||
QgsFeature* getNextFeature(std::list<int> const & attlist);
|
||||
/** Get the feature type. This corresponds to
|
||||
* WKBPoint,
|
||||
* WKBLineString,
|
||||
* WKBPolygon,
|
||||
* WKBMultiPoint,
|
||||
* WKBMultiLineString or
|
||||
* WKBMultiPolygon
|
||||
* as defined in qgis.h
|
||||
*/
|
||||
/**Get the attributes with indices contained in attlist*/
|
||||
void getFeatureAttributes(int oid, QgsFeature *f, std::list<int> const& attlist);
|
||||
|
||||
int geometryType() const;
|
||||
/** * Get the name of the primary key for the layer
|
||||
*/
|
||||
QString getPrimaryKey();
|
||||
/**
|
||||
* Get the field information for the layer
|
||||
* @return vector of QgsField objects
|
||||
*/
|
||||
std::vector<QgsField> const & fields() const;
|
||||
|
||||
/**
|
||||
* Get the number of features in the layer
|
||||
*/
|
||||
long featureCount() const;
|
||||
/** Reset the layer - for a PostgreSQL layer, this means clearing the PQresult
|
||||
* pointer and setting it to 0
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Get the number of fields in the layer
|
||||
*/
|
||||
int fieldCount() const;
|
||||
/**Returns the minimum value of an attributs
|
||||
@param position the number of the attribute*/
|
||||
QString minValue(int position);
|
||||
|
||||
/**
|
||||
* Select features based on a bounding rectangle. Features can be retrieved
|
||||
* with calls to getFirstFeature and getNextFeature.
|
||||
* @param mbr QgsRect containing the extent to use in selecting features
|
||||
*/
|
||||
void select(QgsRect * mbr, bool useIntersect=false);
|
||||
/**Returns the maximum value of an attributs
|
||||
@param position the number of the attribute*/
|
||||
QString maxValue(int position);
|
||||
|
||||
/**
|
||||
* Get the data source URI structure used by this layer
|
||||
*/
|
||||
QgsDataSourceURI * getURI();
|
||||
/**Returns true if layer is valid
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Set the data source URI used by this layer
|
||||
*/
|
||||
void setURI(QgsDataSourceURI &uri);
|
||||
//! get postgis version string
|
||||
QString postgisVersion(PGconn *);
|
||||
|
||||
/**
|
||||
* Set the data source specification. This must be a valid database
|
||||
* connection string:
|
||||
* host=localhost user=gsherman dbname=test password=xxx table=test.alaska (the_geom)
|
||||
* @uri data source specification
|
||||
*/
|
||||
// TODO Deprecate this in favor of using the QgsDataSourceURI structure
|
||||
void setDataSourceUri(QString uri);
|
||||
//! get status of GEOS capability
|
||||
bool hasGEOS(PGconn *);
|
||||
|
||||
/**
|
||||
* Get the data source specification.
|
||||
* @return data source specification as a string containing the host, user,
|
||||
* dbname, password, and table
|
||||
* @see setDataSourceUri
|
||||
*/
|
||||
// TODO Deprecate this in favor of returning the QgsDataSourceURI structure
|
||||
QString getDataSourceUri();
|
||||
//! get status of GIST capability
|
||||
bool hasGIST(PGconn *);
|
||||
|
||||
/**
|
||||
* Identify features within the search radius specified by rect
|
||||
* @param rect Bounding rectangle of search radius
|
||||
* @return std::vector containing QgsFeature objects that intersect rect
|
||||
*/
|
||||
virtual std::vector<QgsFeature>& identify(QgsRect * rect);
|
||||
//! get status of PROJ4 capability
|
||||
bool hasPROJ(PGconn *);
|
||||
|
||||
/**
|
||||
* Return a string representation of the endian-ness for the layer
|
||||
*/
|
||||
QString endianString();
|
||||
/**Returns the default value for attribute @c attr for feature @c f. */
|
||||
QString getDefaultValue(const QString& attr, QgsFeature* f);
|
||||
|
||||
/**
|
||||
* Changes the stored extent for this layer to the supplied extent.
|
||||
* For example, this is called when the extent worker thread has a result.
|
||||
*/
|
||||
void setExtent( QgsRect* newExtent );
|
||||
|
||||
/** Return the extent for this data layer
|
||||
*/
|
||||
virtual QgsRect *extent();
|
||||
/**Adds a list of features
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool addFeatures(std::list<QgsFeature*> const flist);
|
||||
|
||||
/**
|
||||
* Get the attributes associated with a feature
|
||||
*/
|
||||
void getFeatureAttributes(int oid, QgsFeature *f);
|
||||
/**Deletes a list of features
|
||||
@param id list of feature ids
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool deleteFeatures(std::list<int> const & id);
|
||||
|
||||
/**Get the attributes with indices contained in attlist*/
|
||||
void getFeatureAttributes(int oid, QgsFeature *f, std::list<int> const& attlist);
|
||||
/**Adds new attributes
|
||||
@param name map with attribute name as key and type as value
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool addAttributes(std::map<QString,QString> const & name);
|
||||
|
||||
/** * Get the name of the primary key for the layer
|
||||
*/
|
||||
QString getPrimaryKey();
|
||||
/**
|
||||
* Get the field information for the layer
|
||||
* @return vector of QgsField objects
|
||||
*/
|
||||
std::vector<QgsField> const & fields() const;
|
||||
/**Deletes existing attributes
|
||||
@param names of the attributes to delete
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool deleteAttributes(std::set<QString> const & name);
|
||||
|
||||
/** Reset the layer - for a PostgreSQL layer, this means clearing the PQresult
|
||||
* pointer and setting it to 0
|
||||
*/
|
||||
void reset();
|
||||
/**Changes attribute values of existing features
|
||||
@param attr_map a map containing the new attributes. The integer is the feature id,
|
||||
the first QString is the attribute name and the second one is the new attribute value
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool changeAttributeValues(std::map<int,std::map<QString,QString> > const & attr_map);
|
||||
|
||||
/**Returns the minimum value of an attributs
|
||||
@param position the number of the attribute*/
|
||||
QString minValue(int position);
|
||||
//! Flag to indicate if the provider can export to shapefile
|
||||
bool supportsSaveAsShapefile() const;
|
||||
|
||||
/**Returns the maximum value of an attributs
|
||||
@param position the number of the attribute*/
|
||||
QString maxValue(int position);
|
||||
/** Accessor for sql where clause used to limit dataset */
|
||||
QString subsetString() {return sqlWhereClause;};
|
||||
|
||||
/**Returns true if layer is valid
|
||||
*/
|
||||
bool isValid();
|
||||
//! Get the postgres connection
|
||||
PGconn * pgConnection() {return connection;};
|
||||
|
||||
//! get postgis version string
|
||||
QString postgisVersion(PGconn *);
|
||||
//! Get the table name associated with this provider instance
|
||||
QString getTableName() {return tableName;};
|
||||
|
||||
//! get status of GEOS capability
|
||||
bool hasGEOS(PGconn *);
|
||||
/** mutator for sql where clause used to limit dataset size */
|
||||
void setSubsetString(QString theSQL); //{sqlWhereClause = theSQL;};
|
||||
|
||||
//! get status of GIST capability
|
||||
bool hasGIST(PGconn *);
|
||||
/**Returns a bitmask containing the supported capabilities*/
|
||||
int capabilities() const;
|
||||
/** The Postgres provider does its own transforms so we return
|
||||
* true for the following three functions to indicate that transforms
|
||||
* should not be handled by the QgsCoordinateTransform object. See the
|
||||
* documentation on QgsVectorDataProvider for details on these functions.
|
||||
*/
|
||||
// XXX For now we have disabled native transforms in the PG provider since
|
||||
// it appears there are problems with some of the projection definitions
|
||||
bool supportsNativeTransform(){return false;}
|
||||
bool usesSrid(){return true;}
|
||||
bool usesWKT(){return false;}
|
||||
|
||||
//! get status of PROJ4 capability
|
||||
bool hasPROJ(PGconn *);
|
||||
/*! Set the SRID of the target (map canvas) SRS.
|
||||
* @parm srid SRID of the map canvas SRS
|
||||
*/
|
||||
void setTargetSrid(int srid);
|
||||
|
||||
/**Returns the default value for attribute @c attr for feature @c f. */
|
||||
QString getDefaultValue(const QString& attr, QgsFeature* f);
|
||||
|
||||
/**Adds a list of features
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool addFeatures(std::list<QgsFeature*> const flist);
|
||||
|
||||
/**Deletes a list of features
|
||||
@param id list of feature ids
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool deleteFeatures(std::list<int> const & id);
|
||||
|
||||
/**Adds new attributes
|
||||
@param name map with attribute name as key and type as value
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool addAttributes(std::map<QString,QString> const & name);
|
||||
|
||||
/**Deletes existing attributes
|
||||
@param names of the attributes to delete
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool deleteAttributes(std::set<QString> const & name);
|
||||
|
||||
/**Changes attribute values of existing features
|
||||
@param attr_map a map containing the new attributes. The integer is the feature id,
|
||||
the first QString is the attribute name and the second one is the new attribute value
|
||||
@return true in case of success and false in case of failure*/
|
||||
bool changeAttributeValues(std::map<int,std::map<QString,QString> > const & attr_map);
|
||||
|
||||
//! Flag to indicate if the provider can export to shapefile
|
||||
bool supportsSaveAsShapefile() const;
|
||||
|
||||
/** Accessor for sql where clause used to limit dataset */
|
||||
QString subsetString() {return sqlWhereClause;};
|
||||
|
||||
//! Get the postgres connection
|
||||
PGconn * pgConnection() {return connection;};
|
||||
|
||||
//! Get the table name associated with this provider instance
|
||||
QString getTableName() {return tableName;};
|
||||
|
||||
/** mutator for sql where clause used to limit dataset size */
|
||||
void setSubsetString(QString theSQL); //{sqlWhereClause = theSQL;};
|
||||
|
||||
/**Returns a bitmask containing the supported capabilities*/
|
||||
int capabilities() const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* This is emitted whenever the worker thread has fully calculated the
|
||||
* PostGIS extents for this layer, and its event has been received by this
|
||||
* provider.
|
||||
*/
|
||||
void fullExtentCalculated();
|
||||
/**
|
||||
* This is emitted whenever the worker thread has fully calculated the
|
||||
* PostGIS extents for this layer, and its event has been received by this
|
||||
* provider.
|
||||
*/
|
||||
void fullExtentCalculated();
|
||||
|
||||
/**
|
||||
* This is emitted when this provider is satisfied that all objects
|
||||
* have had a chance to adjust themselves after they'd been notified that
|
||||
* the full extent is available.
|
||||
*
|
||||
* \note It currently isn't being emitted because we don't have an easy way
|
||||
* for the overview canvas to only be repainted. In the meantime
|
||||
* we are satisfied for the overview to reflect the new extent
|
||||
* when the user adjusts the extent of the main map canvas.
|
||||
*/
|
||||
void repaintRequested();
|
||||
/**
|
||||
* This is emitted when this provider is satisfied that all objects
|
||||
* have had a chance to adjust themselves after they'd been notified that
|
||||
* the full extent is available.
|
||||
*
|
||||
* \note It currently isn't being emitted because we don't have an easy way
|
||||
* for the overview canvas to only be repainted. In the meantime
|
||||
* we are satisfied for the overview to reflect the new extent
|
||||
* when the user adjusts the extent of the main map canvas.
|
||||
*/
|
||||
void repaintRequested();
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
std::vector < QgsFeature > features;
|
||||
std::vector < bool > *selected;
|
||||
std::vector < QgsField > attributeFields;
|
||||
std::map < int, int > attributeFieldsIdMap;
|
||||
std::vector < QgsFeature > features;
|
||||
std::vector < bool > *selected;
|
||||
std::vector < QgsField > attributeFields;
|
||||
std::map < int, int > attributeFieldsIdMap;
|
||||
|
||||
QString dataSourceUri;
|
||||
QString dataSourceUri;
|
||||
|
||||
//! Data source URI struct for this layer
|
||||
QgsDataSourceURI mUri;
|
||||
//! Data source URI struct for this layer
|
||||
QgsDataSourceURI mUri;
|
||||
|
||||
|
||||
//! Child thread for calculating extents.
|
||||
QgsPostgresExtentThread mExtentThread;
|
||||
|
||||
//! Child thread for calculating count.
|
||||
QgsPostgresCountThread mCountThread;
|
||||
//! Child thread for calculating extents.
|
||||
QgsPostgresExtentThread mExtentThread;
|
||||
|
||||
//! Child thread for calculating count.
|
||||
QgsPostgresCountThread mCountThread;
|
||||
|
||||
|
||||
/**
|
||||
* Pointer to the PostgreSQL query result object. If this pointer is 0,
|
||||
* there is no current selection set. Any future getNextFeature requests
|
||||
* will require execution of the select query to recreate the result set.
|
||||
*/
|
||||
PGresult *queryResult;
|
||||
/**
|
||||
* Flag indicating if the layer data source is a valid PostgreSQL layer
|
||||
*/
|
||||
bool valid;
|
||||
/**
|
||||
* Name of the table with no schema
|
||||
*/
|
||||
QString tableName;
|
||||
/**
|
||||
* Name of the table with schema included
|
||||
*/
|
||||
QString schemaTableName;
|
||||
/**
|
||||
* Name of the schema
|
||||
*/
|
||||
QString mSchema;
|
||||
/**
|
||||
* SQL statement used to limit the features retreived
|
||||
*/
|
||||
QString sqlWhereClause;
|
||||
/**
|
||||
* Primary key column for fetching features. If there is no primary key
|
||||
* the oid is used to fetch features.
|
||||
*/
|
||||
QString primaryKey;
|
||||
/**
|
||||
* Data type for the primary key
|
||||
*/
|
||||
QString primaryKeyType;
|
||||
/**
|
||||
* Name of the geometry column in the table
|
||||
*/
|
||||
QString geometryColumn;
|
||||
/**
|
||||
* Geometry type
|
||||
*/
|
||||
int geomType;
|
||||
/**
|
||||
* SQL to select all records in this layer
|
||||
*/
|
||||
QString selectSQL;
|
||||
/**
|
||||
* Connection pointer
|
||||
*/
|
||||
PGconn *connection;
|
||||
/**
|
||||
* Spatial reference id of the layer
|
||||
*/
|
||||
QString srid;
|
||||
/**
|
||||
* Rectangle that contains the extent (bounding box) of the layer
|
||||
*/
|
||||
QgsRect layerExtent;
|
||||
|
||||
/**
|
||||
* Number of features in the layer
|
||||
*/
|
||||
long numberFeatures;
|
||||
/**
|
||||
* Pointer to the PostgreSQL query result object. If this pointer is 0,
|
||||
* there is no current selection set. Any future getNextFeature requests
|
||||
* will require execution of the select query to recreate the result set.
|
||||
*/
|
||||
PGresult *queryResult;
|
||||
/**
|
||||
* Flag indicating if the layer data source is a valid PostgreSQL layer
|
||||
*/
|
||||
bool valid;
|
||||
/**
|
||||
* Name of the table with no schema
|
||||
*/
|
||||
QString tableName;
|
||||
/**
|
||||
* Name of the table with schema included
|
||||
*/
|
||||
QString schemaTableName;
|
||||
/**
|
||||
* Name of the schema
|
||||
*/
|
||||
QString mSchema;
|
||||
/**
|
||||
* SQL statement used to limit the features retreived
|
||||
*/
|
||||
QString sqlWhereClause;
|
||||
/**
|
||||
* Primary key column for fetching features. If there is no primary key
|
||||
* the oid is used to fetch features.
|
||||
*/
|
||||
QString primaryKey;
|
||||
/**
|
||||
* Data type for the primary key
|
||||
*/
|
||||
QString primaryKeyType;
|
||||
/**
|
||||
* Name of the geometry column in the table
|
||||
*/
|
||||
QString geometryColumn;
|
||||
/**
|
||||
* Geometry type
|
||||
*/
|
||||
int geomType;
|
||||
/**
|
||||
* SQL to select all records in this layer
|
||||
*/
|
||||
QString selectSQL;
|
||||
/**
|
||||
* Connection pointer
|
||||
*/
|
||||
PGconn *connection;
|
||||
/**
|
||||
* Spatial reference id of the layer
|
||||
*/
|
||||
QString srid;
|
||||
/**
|
||||
* Rectangle that contains the extent (bounding box) of the layer
|
||||
*/
|
||||
QgsRect layerExtent;
|
||||
|
||||
/**
|
||||
* Flag indicating whether data from binary cursors must undergo an
|
||||
* endian conversion prior to use
|
||||
@note
|
||||
|
||||
XXX Umm, it'd be helpful to know what we're swapping from and to.
|
||||
XXX Presumably this means swapping from big-endian (network) byte order
|
||||
XXX to little-endian; but the inverse transaction is possible, too, and
|
||||
XXX that's not reflected in this variable
|
||||
*/
|
||||
bool swapEndian;
|
||||
/**
|
||||
* Number of features in the layer
|
||||
*/
|
||||
long numberFeatures;
|
||||
|
||||
bool deduceEndian();
|
||||
bool getGeometryDetails();
|
||||
/**
|
||||
* Flag indicating whether data from binary cursors must undergo an
|
||||
* endian conversion prior to use
|
||||
@note
|
||||
|
||||
typedef std::map<QString, std::pair<QString, QString> > tableCols;
|
||||
XXX Umm, it'd be helpful to know what we're swapping from and to.
|
||||
XXX Presumably this means swapping from big-endian (network) byte order
|
||||
XXX to little-endian; but the inverse transaction is possible, too, and
|
||||
XXX that's not reflected in this variable
|
||||
*/
|
||||
bool swapEndian;
|
||||
|
||||
QString chooseViewColumn(const tableCols& cols);
|
||||
bool deduceEndian();
|
||||
bool getGeometryDetails();
|
||||
|
||||
void findTableColumns(QString selectCmd, tableCols& cols);
|
||||
void findColumns(QString selectCmd, tableCols& cols);
|
||||
int findRelationAndColumn(QString relation, QString column,
|
||||
QString& rRelation, QString& rColumn);
|
||||
|
||||
bool ready;
|
||||
std::ofstream pLog;
|
||||
typedef std::map<QString, std::pair<QString, QString> > tableCols;
|
||||
|
||||
//! PostGIS version string
|
||||
QString postgisVersionInfo;
|
||||
QString chooseViewColumn(const tableCols& cols);
|
||||
|
||||
//! GEOS capability
|
||||
bool geosAvailable;
|
||||
void findTableColumns(QString selectCmd, tableCols& cols);
|
||||
void findColumns(QString selectCmd, tableCols& cols);
|
||||
int findRelationAndColumn(QString relation, QString column,
|
||||
QString& rRelation, QString& rColumn);
|
||||
|
||||
//! GIST capability
|
||||
bool gistAvailable;
|
||||
bool ready;
|
||||
std::ofstream pLog;
|
||||
|
||||
//! PROJ4 capability
|
||||
bool projAvailable;
|
||||
//! PostGIS version string
|
||||
QString postgisVersionInfo;
|
||||
|
||||
/**Writes a single feature*/
|
||||
bool addFeature(QgsFeature* f);
|
||||
//! GEOS capability
|
||||
bool geosAvailable;
|
||||
|
||||
/**Deletes a feature*/
|
||||
bool deleteFeature(int id);
|
||||
//! GIST capability
|
||||
bool gistAvailable;
|
||||
|
||||
//! Get the feature count based on the where clause
|
||||
long getFeatureCount();
|
||||
//! PROJ4 capability
|
||||
bool projAvailable;
|
||||
|
||||
//! Calculate the extents of the layer
|
||||
void calculateExtents();
|
||||
/**Writes a single feature*/
|
||||
bool addFeature(QgsFeature* f);
|
||||
|
||||
/**
|
||||
* Event sink for events from threads
|
||||
*/
|
||||
void customEvent ( QCustomEvent * e );
|
||||
/**Deletes a feature*/
|
||||
bool deleteFeature(int id);
|
||||
|
||||
//! Get the feature count based on the where clause
|
||||
long getFeatureCount();
|
||||
|
||||
//! Calculate the extents of the layer
|
||||
void calculateExtents();
|
||||
|
||||
/**
|
||||
* Event sink for events from threads
|
||||
*/
|
||||
void customEvent ( QCustomEvent * e );
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,27 +1,26 @@
|
||||
<?xml version = '1.0'?>
|
||||
<kdevelop>
|
||||
<general>
|
||||
<author>The QGIS Team</author>
|
||||
<email>qgis-developer@lists.sourceforge.net</email>
|
||||
<author>Gary Sherman</author>
|
||||
<email>gsherman at mrcc dot com</email>
|
||||
<version>$VERSION$</version>
|
||||
<projectmanagement>KDevAutoProject</projectmanagement>
|
||||
<primarylanguage>C++</primarylanguage>
|
||||
<ignoreparts/>
|
||||
<projectdirectory>.</projectdirectory>
|
||||
<absoluteprojectpath>false</absoluteprojectpath>
|
||||
<description/>
|
||||
<secondaryLanguages/>
|
||||
<description></description>
|
||||
</general>
|
||||
<kdevautoproject>
|
||||
<general>
|
||||
<activetarget>src/qgis</activetarget>
|
||||
<useconfiguration>default</useconfiguration>
|
||||
<useconfiguration>debug</useconfiguration>
|
||||
</general>
|
||||
<run>
|
||||
<mainprogram>/home/aps02ts/bin/qgis</mainprogram>
|
||||
<mainprogram>/home/gsherman/development/qgis07_dev/debug/src/qgis</mainprogram>
|
||||
<directoryradio>custom</directoryradio>
|
||||
<customdirectory>/home/aps02ts/bin/</customdirectory>
|
||||
<programargs/>
|
||||
<customdirectory>/</customdirectory>
|
||||
<programargs></programargs>
|
||||
<terminal>false</terminal>
|
||||
<autocompile>true</autocompile>
|
||||
<envvars/>
|
||||
@ -35,60 +34,43 @@
|
||||
<cxxflags>-O2 -g0</cxxflags>
|
||||
</optimized>
|
||||
<debug>
|
||||
<configargs>--enable-debug=full --prefix=$HOME</configargs>
|
||||
<configargs>--enable-debug=full --prefix=/home/gsherman/qgis07_head --with-grass=/usr/local/grass-5.7.0_org</configargs>
|
||||
<builddir>debug</builddir>
|
||||
<ccompiler>kdevgccoptions</ccompiler>
|
||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||
<f77compiler>kdevpgf77options</f77compiler>
|
||||
<cxxflags>-O0 -g3</cxxflags>
|
||||
<envvars/>
|
||||
<topsourcedir/>
|
||||
<cppflags/>
|
||||
<ldflags/>
|
||||
<ccompilerbinary/>
|
||||
<cxxcompilerbinary/>
|
||||
<f77compilerbinary/>
|
||||
<cflags/>
|
||||
<f77flags/>
|
||||
<topsourcedir></topsourcedir>
|
||||
<cppflags></cppflags>
|
||||
<ldflags></ldflags>
|
||||
<ccompilerbinary></ccompilerbinary>
|
||||
<cxxcompilerbinary></cxxcompilerbinary>
|
||||
<f77compilerbinary></f77compilerbinary>
|
||||
<cflags></cflags>
|
||||
<f77flags></f77flags>
|
||||
</debug>
|
||||
<default>
|
||||
<envvars/>
|
||||
<configargs>--prefix=$HOME --enable-debug</configargs>
|
||||
<builddir/>
|
||||
<topsourcedir/>
|
||||
<cppflags/>
|
||||
<ldflags/>
|
||||
<ccompiler>kdevgccoptions</ccompiler>
|
||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||
<f77compiler>kdevpgf77options</f77compiler>
|
||||
<ccompilerbinary/>
|
||||
<cxxcompilerbinary/>
|
||||
<f77compilerbinary/>
|
||||
<cflags/>
|
||||
<cxxflags/>
|
||||
<f77flags/>
|
||||
</default>
|
||||
</configurations>
|
||||
<make>
|
||||
<envvars>
|
||||
<envvar value="1" name="WANT_AUTOCONF_2_5" />
|
||||
<envvar value="1" name="WANT_AUTOMAKE_1_6" />
|
||||
</envvars>
|
||||
<abortonerror>false</abortonerror>
|
||||
<abortonerror>true</abortonerror>
|
||||
<numberofjobs>1</numberofjobs>
|
||||
<dontact>false</dontact>
|
||||
<makebin/>
|
||||
<makebin></makebin>
|
||||
<prio>0</prio>
|
||||
</make>
|
||||
</kdevautoproject>
|
||||
<kdevdebugger>
|
||||
<general>
|
||||
<dbgshell>libtool</dbgshell>
|
||||
<programargs/>
|
||||
<gdbpath/>
|
||||
<configGdbScript/>
|
||||
<runShellScript/>
|
||||
<runGdbScript/>
|
||||
<programargs></programargs>
|
||||
<gdbpath></gdbpath>
|
||||
<configGdbScript></configGdbScript>
|
||||
<runShellScript></runShellScript>
|
||||
<runGdbScript></runGdbScript>
|
||||
<breakonloadinglibs>true</breakonloadinglibs>
|
||||
<separatetty>false</separatetty>
|
||||
<floatingtoolbar>false</floatingtoolbar>
|
||||
@ -172,31 +154,26 @@
|
||||
<argumentsHintDelay>400</argumentsHintDelay>
|
||||
<headerCompletionDelay>250</headerCompletionDelay>
|
||||
</codecompletion>
|
||||
<references/>
|
||||
<creategettersetter>
|
||||
<prefixGet></prefixGet>
|
||||
<prefixSet>set</prefixSet>
|
||||
<prefixVariable>m_,_</prefixVariable>
|
||||
<parameterName>theValue</parameterName>
|
||||
<inlineGet>true</inlineGet>
|
||||
<inlineSet>true</inlineSet>
|
||||
</creategettersetter>
|
||||
<references>
|
||||
<pcs>Qt</pcs>
|
||||
</references>
|
||||
</kdevcppsupport>
|
||||
<kdevdocumentation>
|
||||
<projectdoc>
|
||||
<docsystem/>
|
||||
<docurl/>
|
||||
<usermanualurl/>
|
||||
</projectdoc>
|
||||
</kdevdocumentation>
|
||||
<kdevfileview>
|
||||
<groups>
|
||||
<hidenonprojectfiles>false</hidenonprojectfiles>
|
||||
<hidenonlocation>false</hidenonlocation>
|
||||
</groups>
|
||||
<tree>
|
||||
<showvcsfields>false</showvcsfields>
|
||||
<hidenonprojectfiles>false</hidenonprojectfiles>
|
||||
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
|
||||
<hidenonprojectfiles>false</hidenonprojectfiles>
|
||||
</tree>
|
||||
</kdevfileview>
|
||||
<kdevcvsservice>
|
||||
<recursivewhenupdate>true</recursivewhenupdate>
|
||||
<prunedirswhenupdate>true</prunedirswhenupdate>
|
||||
<createdirswhenupdate>true</createdirswhenupdate>
|
||||
<recursivewhencommitremove>true</recursivewhencommitremove>
|
||||
<revertoptions>-C</revertoptions>
|
||||
</kdevcvsservice>
|
||||
</kdevelop>
|
||||
|
161
src/Makefile.am
161
src/Makefile.am
@ -13,7 +13,7 @@ SUBDIRS = svg images themes resources
|
||||
PREFIX=-DPREFIX=\"$(prefix)\"
|
||||
PLUGINPATH=-DPLUGINPATH=\"$(pkglibdir)\"
|
||||
PKGDATAPATH=-DPKGDATAPATH=\"$(pkgdatadir)\"
|
||||
|
||||
WIDGETPATH=../widgets
|
||||
%.moc.cpp: %.h
|
||||
$(MOC) -o $@ $<
|
||||
|
||||
@ -41,6 +41,7 @@ headers = qgisapp.h \
|
||||
qgsacetatelines.h \
|
||||
qgsacetateobject.h \
|
||||
qgsacetaterectangle.h \
|
||||
qgsaddattrdialog.h \
|
||||
qgsattributeaction.h \
|
||||
qgsattributeactiondialog.h \
|
||||
qgsattributedialog.h \
|
||||
@ -68,8 +69,8 @@ headers = qgisapp.h \
|
||||
qgsdatasourceuri.h \
|
||||
qgsdelattrdialog.h \
|
||||
qgsdlgvectorlayerproperties.h \
|
||||
qgsexception.h \
|
||||
qgscsexception.h \
|
||||
qgsexception.h \
|
||||
qgscsexception.h \
|
||||
qgsfeatureattribute.h \
|
||||
qgsfeature.h \
|
||||
qgsfield.h \
|
||||
@ -125,6 +126,8 @@ headers = qgisapp.h \
|
||||
qgssimarenderer.h \
|
||||
qgssinglesymrenderer.h \
|
||||
qgssisydialog.h \
|
||||
qgsspatialrefsys.h \
|
||||
qgsspatialreferences.h \
|
||||
qgssvgcache.h \
|
||||
qgsmarkercatalogue.h \
|
||||
qgssymbol.h \
|
||||
@ -136,6 +139,9 @@ headers = qgisapp.h \
|
||||
qgsvectordataprovider.h \
|
||||
qgsvectorfilewriter.h \
|
||||
qgsvectorlayer.h \
|
||||
splashscreen.h \
|
||||
qgslayerprojectionselector.h \
|
||||
$(WIDGETPATH)/projectionselector/qgsprojectionselector.h \
|
||||
qgspointstylewidget.h \
|
||||
qgslinestylewidget.h \
|
||||
qgsfillstylewidget.h \
|
||||
@ -181,6 +187,8 @@ qgis_UIC = qgisappbase.ui \
|
||||
qgssimadialogbase.ui \
|
||||
qgssisydialogbase.ui \
|
||||
qgsuvaldialogbase.ui \
|
||||
qgslayerprojectionselectorbase.ui \
|
||||
$(WIDGETPATH)/projectionselector/qgsprojectionselectorbase.ui \
|
||||
qgsuvalmadialogbase.ui \
|
||||
qgspointstylewidgetbase.ui \
|
||||
qgsfillstylewidgetbase.ui \
|
||||
@ -204,7 +212,8 @@ qgis_UIH = qgisappbase.ui.h \
|
||||
qgsoptionsbase.ui.h \
|
||||
qgsrasterlayerpropertiesbase.ui.h \
|
||||
qgslabeldialogbase.ui.h \
|
||||
qgsprojectpropertiesbase.ui.h
|
||||
qgslayerprojectionselectorbase.ui.h \
|
||||
qgsprojectpropertiesbase.ui.h
|
||||
|
||||
## these generated files need MOC files, too
|
||||
qgis_UIMOC = $(qgis_UIC:.ui=.moc.uic.cpp)
|
||||
@ -217,21 +226,22 @@ qgis_MOC = qgisapp.moc.cpp \
|
||||
qgsaddattrdialog.moc.cpp \
|
||||
qgsattributeactiondialog.moc.cpp \
|
||||
qgsattributedialog.moc.cpp \
|
||||
qgsattributetable.moc.cpp \
|
||||
qgscomposer.moc.cpp \
|
||||
qgscomposition.moc.cpp \
|
||||
qgscomposermap.moc.cpp \
|
||||
qgscomposervectorlegend.moc.cpp \
|
||||
qgscomposerlabel.moc.cpp \
|
||||
qgscomposerscalebar.moc.cpp \
|
||||
qgscomposerview.moc.cpp \
|
||||
qgsattributetabledisplay.moc.cpp \
|
||||
qgscoordinatetransform.moc.cpp \
|
||||
qgsattributetable.moc.cpp \
|
||||
qgscomposerlabel.moc.cpp \
|
||||
qgscomposermap.moc.cpp \
|
||||
qgscomposer.moc.cpp \
|
||||
qgscomposerscalebar.moc.cpp \
|
||||
qgscomposervectorlegend.moc.cpp \
|
||||
qgscomposerview.moc.cpp \
|
||||
qgscomposition.moc.cpp \
|
||||
qgscontcoldialog.moc.cpp \
|
||||
qgscoordinatetransform.moc.cpp \
|
||||
qgsdataprovider.moc.cpp \
|
||||
qgsdelattrdialog.moc.cpp \
|
||||
qgsdlgvectorlayerproperties.moc.cpp \
|
||||
qgsencodingfiledialog.moc.cpp \
|
||||
qgsfillstylewidget.moc.cpp \
|
||||
qgsgeomtypedialog.moc.cpp \
|
||||
qgsgramadialog.moc.cpp \
|
||||
qgsgramaextensionwidget.moc.cpp \
|
||||
@ -239,7 +249,10 @@ qgis_MOC = qgisapp.moc.cpp \
|
||||
qgshelpviewer.moc.cpp \
|
||||
qgsidentifyresults.moc.cpp \
|
||||
qgslabeldialog.moc.cpp \
|
||||
qgslayerprojectionselector.moc.cpp \
|
||||
qgslegend.moc.cpp \
|
||||
qgslinestyledialog.moc.cpp \
|
||||
qgslinestylewidget.moc.cpp \
|
||||
qgsludialog.moc.cpp \
|
||||
qgsmapcanvas.moc.cpp \
|
||||
qgsmaplayerinterface.moc.cpp \
|
||||
@ -251,6 +264,7 @@ qgis_MOC = qgisapp.moc.cpp \
|
||||
qgsoptions.moc.cpp \
|
||||
qgspatterndialog.moc.cpp \
|
||||
qgspluginmanager.moc.cpp \
|
||||
qgspointstylewidget.moc.cpp \
|
||||
qgsprojectproperties.moc.cpp \
|
||||
qgsrasterlayer.moc.cpp \
|
||||
qgsrasterlayerproperties.moc.cpp \
|
||||
@ -259,12 +273,10 @@ qgis_MOC = qgisapp.moc.cpp \
|
||||
qgssisydialog.moc.cpp \
|
||||
qgsuvaldialog.moc.cpp \
|
||||
qgsuvalmadialog.moc.cpp \
|
||||
qgsvectorlayer.moc.cpp \
|
||||
qgsvectordataprovider.moc.cpp \
|
||||
qgspointstylewidget.moc.cpp \
|
||||
qgsfillstylewidget.moc.cpp \
|
||||
qgslinestylewidget.moc.cpp \
|
||||
splashscreen.moc.cpp
|
||||
qgsvectorlayer.moc.cpp \
|
||||
splashscreen.moc.cpp \
|
||||
$(WIDGETPATH)/projectionselector/qgsprojectionselector.moc.cpp
|
||||
|
||||
# qgsvectorsymbologywidget.moc.cpp
|
||||
|
||||
@ -284,27 +296,26 @@ qgis_SOURCES = main.cpp \
|
||||
qgsclipper.cpp \
|
||||
qgscolortable.cpp \
|
||||
qgscomposer.cpp \
|
||||
qgscomposition.cpp \
|
||||
qgscomposeritem.cpp \
|
||||
qgscomposermap.cpp \
|
||||
qgscomposervectorlegend.cpp \
|
||||
qgscomposerlabel.cpp \
|
||||
qgscomposermap.cpp \
|
||||
qgscomposerscalebar.cpp \
|
||||
qgscomposervectorlegend.cpp \
|
||||
qgscomposerview.cpp \
|
||||
qgscomposition.cpp \
|
||||
qgscontcoldialog.cpp \
|
||||
qgscontinuouscolrenderer.cpp \
|
||||
qgscoordinatetransform.cpp \
|
||||
qgsencodingfiledialog.cpp \
|
||||
qgsmaptopixel.cpp \
|
||||
qgscustomsymbol.cpp \
|
||||
qgsdatasource.cpp \
|
||||
qgsdelattrdialog.cpp \
|
||||
qgsdlgvectorlayerproperties.cpp \
|
||||
qgsencodingfiledialog.cpp \
|
||||
qgsfeatureattribute.cpp \
|
||||
qgsfeature.cpp \
|
||||
qgsfield.cpp \
|
||||
qgsfillstylewidget.cpp \
|
||||
qgsgeomtypedialog.cpp \
|
||||
qgsrenderer.cpp \
|
||||
qgsgraduatedmarenderer.cpp \
|
||||
qgsgraduatedsymrenderer.cpp \
|
||||
qgsgramadialog.cpp \
|
||||
@ -315,14 +326,20 @@ qgis_SOURCES = main.cpp \
|
||||
qgslabelattributes.cpp \
|
||||
qgslabel.cpp \
|
||||
qgslabeldialog.cpp \
|
||||
qgslayerprojectionselector.cpp \
|
||||
qgslegend.cpp \
|
||||
qgslegenditem.cpp \
|
||||
qgsline.cpp \
|
||||
qgslinestyledialog.cpp \
|
||||
qgslinestylewidget.cpp \
|
||||
qgslinesymbol.cpp \
|
||||
qgsludialog.cpp \
|
||||
qgsmapcanvas.cpp \
|
||||
qgsmaplayer.cpp \
|
||||
qgsmaplayerregistry.cpp \
|
||||
qgsmapserverexport.cpp \
|
||||
qgsmaptopixel.cpp \
|
||||
qgsmarkercatalogue.cpp \
|
||||
qgsmarkerdialog.cpp \
|
||||
qgsmarkersymbol.cpp \
|
||||
qgsmeasure.cpp \
|
||||
@ -333,6 +350,7 @@ qgis_SOURCES = main.cpp \
|
||||
qgspluginmetadata.cpp \
|
||||
qgspluginregistry.cpp \
|
||||
qgspoint.cpp \
|
||||
qgspointstylewidget.cpp \
|
||||
qgspolygonsymbol.cpp \
|
||||
qgsproject.cpp \
|
||||
qgsprojectproperties.cpp \
|
||||
@ -345,6 +363,7 @@ qgis_SOURCES = main.cpp \
|
||||
qgsrasterlayer.cpp \
|
||||
qgsrasterlayerproperties.cpp \
|
||||
qgsrect.cpp \
|
||||
qgsrenderer.cpp \
|
||||
qgsrenderitem.cpp \
|
||||
qgsrunprocess.cpp \
|
||||
qgsscalecalculator.cpp \
|
||||
@ -352,8 +371,9 @@ qgis_SOURCES = main.cpp \
|
||||
qgssimarenderer.cpp \
|
||||
qgssinglesymrenderer.cpp \
|
||||
qgssisydialog.cpp \
|
||||
qgsspatialreferences.cpp \
|
||||
qgsspatialrefsys.cpp \
|
||||
qgssvgcache.cpp \
|
||||
qgsmarkercatalogue.cpp \
|
||||
qgssymbol.cpp \
|
||||
qgssymbologyutils.cpp \
|
||||
qgsuniquevalrenderer.cpp \
|
||||
@ -363,10 +383,8 @@ qgis_SOURCES = main.cpp \
|
||||
qgsvectordataprovider.cpp \
|
||||
qgsvectorfilewriter.cpp \
|
||||
qgsvectorlayer.cpp \
|
||||
qgspointstylewidget.cpp \
|
||||
qgslinestylewidget.cpp \
|
||||
qgsfillstylewidget.cpp \
|
||||
splashscreen.cpp
|
||||
splashscreen.cpp \
|
||||
$(WIDGETPATH)/projectionselector/qgsprojectionselector.cpp
|
||||
|
||||
# qgsvectorsymbologywidget.cpp
|
||||
|
||||
@ -406,61 +424,69 @@ BUILT_SOURCES = $(qgis_MOC) $(qgis_UIMOC) $(qgis_UIHEADERS) $(qgis_UISOURCES) \
|
||||
$(postgresMOC) $(postgresUIMOC) $(postgresUIHEADERS) $(postgresUISOURCES)
|
||||
|
||||
|
||||
qgis_LDADD = $(LDADD) $(QT_LDADD) $(GDAL_LDADD) $(PG_LIB) $(GEOS_LDADD) libqgis.la
|
||||
qgis_LDADD = $(LDADD) $(QT_LDADD) $(GDAL_LDADD) $(PG_LIB) $(GEOS_LDADD) -lproj -lsqlite3 libqgis.la
|
||||
qgis_LDFLAGS = -rdynamic
|
||||
qgis_CXXFLAGS = $(PREFIX) $(PLUGINPATH) $(PKGDATAPATH) $(GDAL_CFLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) -I$(PG_INC) $(DEBUG_QGIS) $(GEOS_CFLAGS)
|
||||
qgis_CXXFLAGS = $(PREFIX) $(PLUGINPATH) $(PKGDATAPATH) $(GDAL_CFLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) -I$(PG_INC) $(DEBUG_QGIS) $(GEOS_CFLAGS) -I../widgets/projectionselector/
|
||||
|
||||
libqgis_la_SOURCES = \
|
||||
qgisapp.cpp \
|
||||
qgisapp.moc.cpp \
|
||||
qgisappbase.moc.uic.cpp \
|
||||
qgisappbase.uic.cpp \
|
||||
qgisapp.cpp \
|
||||
qgisapp.moc.cpp \
|
||||
qgsacetateobject.cpp \
|
||||
qgsacetaterectangle.cpp \
|
||||
qgsattributeaction.cpp \
|
||||
qgsclipper.cpp \
|
||||
qgscolortable.cpp \
|
||||
qgscomposer.cpp \
|
||||
qgscomposer.moc.cpp \
|
||||
qgscomposerbase.uic.cpp \
|
||||
qgscomposerbase.moc.uic.cpp \
|
||||
qgscomposerbase.uic.cpp \
|
||||
qgscomposer.cpp \
|
||||
qgscomposeritem.cpp \
|
||||
qgscomposerlabel.cpp \
|
||||
qgscomposerlabel.moc.cpp \
|
||||
qgscomposerlabelbase.uic.cpp \
|
||||
qgscomposerlabelbase.moc.uic.cpp \
|
||||
qgscomposerscalebar.cpp \
|
||||
qgscomposerscalebar.moc.cpp \
|
||||
qgscomposerscalebarbase.uic.cpp \
|
||||
qgscomposerscalebarbase.moc.uic.cpp \
|
||||
qgscomposerlabelbase.uic.cpp \
|
||||
qgscomposerlabel.cpp \
|
||||
qgscomposerlabel.moc.cpp \
|
||||
qgscomposermapbase.moc.uic.cpp \
|
||||
qgscomposermapbase.uic.cpp \
|
||||
qgscomposermap.cpp \
|
||||
qgscomposermap.moc.cpp \
|
||||
qgscomposermapbase.uic.cpp \
|
||||
qgscomposermapbase.moc.uic.cpp \
|
||||
qgscompositionbase.uic.cpp \
|
||||
qgscompositionbase.moc.uic.cpp \
|
||||
qgscomposer.moc.cpp \
|
||||
qgscomposerscalebarbase.moc.uic.cpp \
|
||||
qgscomposerscalebarbase.uic.cpp \
|
||||
qgscomposerscalebar.cpp \
|
||||
qgscomposerscalebar.moc.cpp \
|
||||
qgscomposervectorlegendbase.moc.uic.cpp \
|
||||
qgscomposervectorlegendbase.uic.cpp \
|
||||
qgscomposervectorlegend.cpp \
|
||||
qgscomposervectorlegend.moc.cpp \
|
||||
qgscomposervectorlegendbase.uic.cpp \
|
||||
qgscomposervectorlegendbase.moc.uic.cpp \
|
||||
qgscomposerview.moc.cpp \
|
||||
qgscomposerview.cpp \
|
||||
qgscomposerview.moc.cpp \
|
||||
qgscompositionbase.moc.uic.cpp \
|
||||
qgscompositionbase.uic.cpp \
|
||||
qgscomposition.cpp \
|
||||
qgscomposition.moc.cpp \
|
||||
qgscontinuouscolrenderer.cpp \
|
||||
qgscoordinatetransform.cpp \
|
||||
qgscoordinatetransform.moc.cpp \
|
||||
qgsdataprovider.moc.cpp \
|
||||
qgsfeature.cpp \
|
||||
qgsfeatureattribute.cpp \
|
||||
qgsfeature.cpp \
|
||||
qgsfield.cpp \
|
||||
qgsfillstylewidgetbase.moc.uic.cpp \
|
||||
qgsfillstylewidgetbase.uic.cpp \
|
||||
qgsfillstylewidget.cpp \
|
||||
qgsfillstylewidget.moc.cpp
|
||||
qgsgraduatedmarenderer.cpp \
|
||||
qgsgraduatedsymrenderer.cpp \
|
||||
qgslabel.cpp \
|
||||
qgslegend.cpp \
|
||||
qgslegend.moc.cpp \
|
||||
qgslegenditem.cpp \
|
||||
qgslegenditem.moc.cpp \
|
||||
qgslegend.moc.cpp \
|
||||
qgslinestylewidgetbase.moc.uic.cpp \
|
||||
qgslinestylewidgetbase.uic.cpp \
|
||||
qgslinestylewidget.cpp \
|
||||
qgslinestylewidget.moc.cpp \
|
||||
qgsmapcanvas.cpp \
|
||||
qgsmapcanvas.moc.cpp \
|
||||
qgsmaplayer.cpp \
|
||||
@ -468,9 +494,15 @@ libqgis_la_SOURCES = \
|
||||
qgsmaplayerregistry.cpp \
|
||||
qgsmaplayerregistry.moc.cpp \
|
||||
qgsmaptopixel.cpp \
|
||||
qgsmarkercatalogue.cpp \
|
||||
qgsmarkersymbol.cpp \
|
||||
qgspoint.cpp \
|
||||
qgspoint.moc.cpp \
|
||||
qgspointstylewidgetbase.moc.uic.cpp \
|
||||
qgspointstylewidgetbase.uic.cpp \
|
||||
qgspointstylewidget.cpp \
|
||||
qgspointstylewidget.moc.cpp \
|
||||
qgsprojectproperty.cpp \
|
||||
qgsprojectproperty.cpp \
|
||||
qgsprovidercountcalcevent.cpp \
|
||||
qgsproviderextentcalcevent.cpp \
|
||||
@ -480,13 +512,15 @@ libqgis_la_SOURCES = \
|
||||
qgsrasterlayer.moc.cpp \
|
||||
qgsrect.cpp \
|
||||
qgsrenderer.cpp \
|
||||
qgsrenderer.cpp \
|
||||
qgsrenderitem.cpp \
|
||||
qgsrunprocess.cpp \
|
||||
qgsrunprocess.moc.cpp \
|
||||
qgsscalecalculator.cpp \
|
||||
qgssimarenderer.cpp \
|
||||
qgssinglesymrenderer.cpp \
|
||||
qgsmarkercatalogue.cpp \
|
||||
qgsspatialreferences.cpp \
|
||||
qgsspatialrefsys.cpp \
|
||||
qgssymbol.cpp \
|
||||
qgsuniquevalrenderer.cpp \
|
||||
qgsuvalmarenderer.cpp \
|
||||
@ -494,29 +528,16 @@ libqgis_la_SOURCES = \
|
||||
qgsvectordataprovider.moc.cpp \
|
||||
qgsvectorfilewriter.cpp \
|
||||
qgsvectorlayer.cpp \
|
||||
qgsvectorlayer.moc.cpp \
|
||||
qgspointstylewidgetbase.uic.cpp \
|
||||
qgspointstylewidgetbase.moc.uic.cpp \
|
||||
qgslinestylewidgetbase.uic.cpp \
|
||||
qgslinestylewidgetbase.moc.uic.cpp \
|
||||
qgsfillstylewidgetbase.uic.cpp \
|
||||
qgsfillstylewidgetbase.moc.uic.cpp \
|
||||
qgspointstylewidget.cpp \
|
||||
qgspointstylewidget.moc.cpp \
|
||||
qgslinestylewidget.cpp \
|
||||
qgslinestylewidget.moc.cpp \
|
||||
qgsfillstylewidget.cpp \
|
||||
qgsfillstylewidget.moc.cpp
|
||||
|
||||
qgsvectorlayer.moc.cpp
|
||||
|
||||
if HAVE_POSTGRESQL
|
||||
libqgis_la_SOURCES += $(postgresLIBSOURCES)
|
||||
endif
|
||||
|
||||
libqgis_la_LIBFLAGS = $(QT_LDADD) $(GEOS_LDADD)
|
||||
libqgis_la_LDFLAGS = -version-info $(INTERFACE_VERSION)
|
||||
libqgis_la_CXXFLAGS = $(PREFIX) $(PLUGINPATH) $(PKGDATAPATH) $(GDAL_CFLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) -I$(PG_INC) $(DEBUG_QGIS) $(GEOS_CFLAGS)
|
||||
libqgis_la_LIBFLAGS = $(QT_LDADD) $(GEOS_LDADD) $(GDAL_LDADD)
|
||||
libqgis_la_LDFLAGS = -version-info $(INTERFACE_VERSION) $(QT_LDADD) $(GDAL_LDADD) -lsqlite3
|
||||
|
||||
libqgis_la_CXXFLAGS = $(PREFIX) $(PLUGINPATH) $(PKGDATAPATH) $(GDAL_CFLAGS) $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) -I$(PG_INC) $(DEBUG_QGIS) $(GEOS_CFLAGS) -I../widgets/projectionselector/
|
||||
|
||||
## for installing headers in $(includedir)/qgis
|
||||
pkginclude_HEADERS = $(headers) $(qgis_UIHEADERS) $(qgis_UIH) $(postgresHEADERS) $(postgresUIH)
|
||||
|
@ -80,7 +80,7 @@ bool bundleclicked(int argc, char *argv[])
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Command line options 'behaviour' flag setup
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
@ -109,4 +109,12 @@ namespace QGis
|
||||
};
|
||||
|
||||
}
|
||||
//! Structure for storing a spatial_ref_sys item
|
||||
typedef struct{
|
||||
QString srid; // spatial reference id (ala PostGIS)
|
||||
QString auth_name; // name of the author for this SRS
|
||||
QString auth_srid; // srid used by the author
|
||||
QString srtext; // WKT of the coordinate system
|
||||
QString proj4text; // Proj4 parameter string
|
||||
} SPATIAL_REF_SYS;
|
||||
#endif
|
||||
|
173
src/qgisapp.cpp
173
src/qgisapp.cpp
@ -984,7 +984,7 @@ static void openFilesRememberingFilter_(QString const &filterName,
|
||||
if (openFileDialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
selectedFiles = openFileDialog->selectedFiles();
|
||||
enc = openFileDialog->encoding();
|
||||
enc = openFileDialog->encoding();
|
||||
}
|
||||
|
||||
settings.writeEntry("/qgis/UI/" + filterName, openFileDialog->selectedFilter());
|
||||
@ -1033,7 +1033,7 @@ void QgisApp::addLayer()
|
||||
std::cerr << "Vector file filters: " << fileFilters << std::endl;
|
||||
#endif
|
||||
|
||||
QString enc;
|
||||
QString enc;
|
||||
QString title = tr("Open an OGR Supported Vector Layer");
|
||||
openFilesRememberingFilter_("lastVectorFileFilter", fileFilters, selectedFiles, enc,
|
||||
title);
|
||||
@ -1228,7 +1228,7 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en
|
||||
|
||||
if (layer->isValid())
|
||||
{
|
||||
layer->getDataProvider()->setEncoding(enc);
|
||||
layer->getDataProvider()->setEncoding(enc);
|
||||
//Register the layer with the layer registry
|
||||
QgsMapLayerRegistry::instance()->addMapLayer(layer);
|
||||
// init the context menu so it can connect to slots
|
||||
@ -2200,9 +2200,9 @@ void QgisApp::zoomIn()
|
||||
*/
|
||||
|
||||
if ( mMapCanvas->mapTool() != QGis::ZoomIn && mMapCanvas->mapTool() != QGis::ZoomOut
|
||||
&& mMapCanvas->mapTool() != QGis::Pan )
|
||||
&& mMapCanvas->mapTool() != QGis::Pan )
|
||||
{
|
||||
mPreviousNonZoomMapTool = mMapCanvas->mapTool();
|
||||
mPreviousNonZoomMapTool = mMapCanvas->mapTool();
|
||||
}
|
||||
|
||||
mMapTool = QGis::ZoomIn;
|
||||
@ -2230,9 +2230,9 @@ void QgisApp::zoomIn()
|
||||
void QgisApp::zoomOut()
|
||||
{
|
||||
if ( mMapCanvas->mapTool() != QGis::ZoomIn && mMapCanvas->mapTool() != QGis::ZoomOut
|
||||
&& mMapCanvas->mapTool() != QGis::Pan )
|
||||
&& mMapCanvas->mapTool() != QGis::Pan )
|
||||
{
|
||||
mPreviousNonZoomMapTool = mMapCanvas->mapTool();
|
||||
mPreviousNonZoomMapTool = mMapCanvas->mapTool();
|
||||
}
|
||||
|
||||
mMapTool = QGis::ZoomOut;
|
||||
@ -2262,9 +2262,9 @@ void QgisApp::zoomToSelected()
|
||||
void QgisApp::pan()
|
||||
{
|
||||
if ( mMapCanvas->mapTool() != QGis::ZoomIn && mMapCanvas->mapTool() != QGis::ZoomOut
|
||||
&& mMapCanvas->mapTool() != QGis::Pan )
|
||||
&& mMapCanvas->mapTool() != QGis::Pan )
|
||||
{
|
||||
mPreviousNonZoomMapTool = mMapCanvas->mapTool();
|
||||
mPreviousNonZoomMapTool = mMapCanvas->mapTool();
|
||||
}
|
||||
|
||||
mMapTool = QGis::Pan;
|
||||
@ -2326,30 +2326,31 @@ void QgisApp::stopZoom()
|
||||
actionPan->setOn(false);
|
||||
|
||||
switch ( mPreviousNonZoomMapTool ) {
|
||||
case QGis::Identify:
|
||||
identify();
|
||||
break;
|
||||
case QGis::Select:
|
||||
select();
|
||||
break;
|
||||
case QGis::CapturePoint:
|
||||
capturePoint();
|
||||
break;
|
||||
case QGis::CaptureLine:
|
||||
captureLine();
|
||||
break;
|
||||
case QGis::CapturePolygon:
|
||||
capturePolygon();
|
||||
break;
|
||||
case QGis::EmitPoint:
|
||||
mMapCanvas->setMapTool( QGis::EmitPoint );
|
||||
break;
|
||||
case QGis::Measure:
|
||||
measure();
|
||||
break;
|
||||
case QGis::Identify:
|
||||
identify();
|
||||
break;
|
||||
case QGis::Select:
|
||||
select();
|
||||
break;
|
||||
case QGis::CapturePoint:
|
||||
capturePoint();
|
||||
break;
|
||||
case QGis::CaptureLine:
|
||||
captureLine();
|
||||
break;
|
||||
case QGis::CapturePolygon:
|
||||
capturePolygon();
|
||||
break;
|
||||
case QGis::EmitPoint:
|
||||
mMapCanvas->setMapTool( QGis::EmitPoint );
|
||||
break;
|
||||
case QGis::Measure:
|
||||
measure();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QgisApp::attributeTable()
|
||||
{
|
||||
QListViewItem *li = mMapLegend->currentItem();
|
||||
@ -2412,7 +2413,7 @@ void QgisApp::capturePoint()
|
||||
mMapCursor = new QCursor(mySelectQPixmap, 8, 8);
|
||||
mMapCanvas->setCursor(*mMapCursor);
|
||||
|
||||
actionCapturePoint->setOn(true);
|
||||
actionCapturePoint->setOn(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2426,7 +2427,7 @@ void QgisApp::captureLine()
|
||||
mMapCursor = new QCursor(mySelectQPixmap, 8, 8);
|
||||
mMapCanvas->setCursor(*mMapCursor);
|
||||
|
||||
actionCaptureLine->setOn(true);
|
||||
actionCaptureLine->setOn(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2439,8 +2440,8 @@ void QgisApp::capturePolygon()
|
||||
delete mMapCursor;
|
||||
mMapCursor = new QCursor(mySelectQPixmap, 8, 8);
|
||||
mMapCanvas->setCursor(*mMapCursor);
|
||||
|
||||
actionCapturePolygon->setOn(true);
|
||||
|
||||
actionCapturePolygon->setOn(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2705,7 +2706,11 @@ void QgisApp::zoomToLayerExtent()
|
||||
// get the selected item
|
||||
QListViewItem *li = mMapLegend->currentItem();
|
||||
QgsMapLayer *layer = ((QgsLegendItem *) li)->layer();
|
||||
mMapCanvas->setExtent(layer->extent());
|
||||
// the layer extent has to be transformed to the map canvas
|
||||
// coordinate system
|
||||
QgsCoordinateTransform *ct = layer->coordinateTransform();
|
||||
QgsRect transformedExtent = ct->transform(layer->extent());
|
||||
mMapCanvas->setExtent(transformedExtent);
|
||||
mMapCanvas->clear();
|
||||
mMapCanvas->render();
|
||||
|
||||
@ -2735,10 +2740,10 @@ void QgisApp::currentLayerChanged(QListViewItem * lvi)
|
||||
// disable/enable toolbar buttons as appropriate based on selected
|
||||
// layer type
|
||||
|
||||
toolPopupCapture->setItemEnabled(0,FALSE);
|
||||
toolPopupCapture->setItemEnabled(1,FALSE);
|
||||
toolPopupCapture->setItemEnabled(2,FALSE);
|
||||
toolPopupCapture->setItemEnabled(3,FALSE);
|
||||
toolPopupCapture->setItemEnabled(0,FALSE);
|
||||
toolPopupCapture->setItemEnabled(1,FALSE);
|
||||
toolPopupCapture->setItemEnabled(2,FALSE);
|
||||
toolPopupCapture->setItemEnabled(3,FALSE);
|
||||
|
||||
QgsMapLayer *layer = ((QgsLegendItem *) lvi)->layer();
|
||||
if (layer->type() == QgsMapLayer::RASTER)
|
||||
@ -2760,31 +2765,31 @@ void QgisApp::currentLayerChanged(QListViewItem * lvi)
|
||||
QgsVectorLayer* vlayer=dynamic_cast<QgsVectorLayer*>(((QgsLegendItem *) lvi)->layer());
|
||||
if(vlayer)
|
||||
{
|
||||
QgsVectorDataProvider* provider=vlayer->getDataProvider();
|
||||
if(provider)
|
||||
{
|
||||
int cap=vlayer->getDataProvider()->capabilities();
|
||||
if(cap&QgsVectorDataProvider::DeleteFeatures)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(3,TRUE);
|
||||
}
|
||||
if(cap&QgsVectorDataProvider::AddFeatures)
|
||||
{
|
||||
if(vlayer->vectorType()==QGis::Point)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(0,TRUE);
|
||||
}
|
||||
else if(vlayer->vectorType()==QGis::Line)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(1,TRUE);
|
||||
}
|
||||
else if(vlayer->vectorType()==QGis::Polygon)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(2,TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QgsVectorDataProvider* provider=vlayer->getDataProvider();
|
||||
if(provider)
|
||||
{
|
||||
int cap=vlayer->getDataProvider()->capabilities();
|
||||
if(cap&QgsVectorDataProvider::DeleteFeatures)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(3,TRUE);
|
||||
}
|
||||
if(cap&QgsVectorDataProvider::AddFeatures)
|
||||
{
|
||||
if(vlayer->vectorType()==QGis::Point)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(0,TRUE);
|
||||
}
|
||||
else if(vlayer->vectorType()==QGis::Line)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(1,TRUE);
|
||||
}
|
||||
else if(vlayer->vectorType()==QGis::Polygon)
|
||||
{
|
||||
toolPopupCapture->setItemEnabled(2,TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actionIdentify->setEnabled(TRUE);
|
||||
actionSelect->setEnabled(TRUE);
|
||||
@ -2804,9 +2809,9 @@ void QgisApp::currentLayerChanged(QListViewItem * lvi)
|
||||
}
|
||||
}
|
||||
|
||||
//let the mapcanvas know that the current layer changed
|
||||
//so any remaining digitizing acetates can be removed
|
||||
mMapCanvas->removeEditingAcetates();
|
||||
//let the mapcanvas know that the current layer changed
|
||||
//so any remaining digitizing acetates can be removed
|
||||
mMapCanvas->removeEditingAcetates();
|
||||
|
||||
// notify the project we've made a change
|
||||
QgsProject::instance()->dirty(true);
|
||||
@ -3797,23 +3802,42 @@ void QgisApp::showStatusMessage(QString theMessage)
|
||||
|
||||
void QgisApp::projectProperties()
|
||||
{
|
||||
/* Display the property sheet for the Project */
|
||||
// set wait cursor since construction of the project properties
|
||||
// dialog results in the construction of the spatial reference
|
||||
// system QMap
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
QgsProjectProperties *pp = new QgsProjectProperties(this);
|
||||
|
||||
qApp->processEvents();
|
||||
// Be told if the mouse display precision may have changed by the user
|
||||
// changing things in the project properties dialog box
|
||||
connect(pp, SIGNAL(displayPrecisionChanged()), this, SLOT(updateMouseCoordinatePrecision()));
|
||||
|
||||
connect(pp, SIGNAL(displayPrecisionChanged()), this,
|
||||
SLOT(updateMouseCoordinatePrecision()));
|
||||
QApplication::restoreOverrideCursor();
|
||||
//pass any refresg signals off to canvases
|
||||
connect (pp,SIGNAL(refresh()), mMapCanvas, SLOT(refresh()));
|
||||
connect (pp,SIGNAL(refresh()), mOverviewCanvas, SLOT(refresh()));
|
||||
// Display the modal dialog box.
|
||||
pp->exec();
|
||||
|
||||
// set the map units for the project if they have changed
|
||||
if (mMapCanvas->mapUnits() != pp->mapUnits())
|
||||
{
|
||||
mMapCanvas->setMapUnits(pp->mapUnits());
|
||||
}
|
||||
|
||||
// If the canvas is projected, we need to recalculate the extents in the
|
||||
// new coordinate system
|
||||
if(pp->isProjected())
|
||||
{
|
||||
mMapCanvas->recalculateExtents();
|
||||
}
|
||||
// Set the window title. No way to do a comparison like for the map
|
||||
// units above, so redo it everytime.
|
||||
setTitleBarText_( *this );
|
||||
|
||||
// delete the property sheet object
|
||||
delete pp;
|
||||
} // QgisApp::projectProperties
|
||||
|
||||
|
||||
@ -4357,5 +4381,10 @@ void QgisApp::keyPressEvent ( QKeyEvent * e )
|
||||
std::cout << e->ascii() << " (keypress recevied)" << std::endl;
|
||||
emit keyPressed (e);
|
||||
}
|
||||
|
||||
|
||||
// Debug hook - used to output diagnostic messages when evoked (usually from the menu)
|
||||
void QgisApp::debugHook()
|
||||
{
|
||||
std::cout << "Hello from debug hook" << std::endl;
|
||||
// show the map canvas extent
|
||||
std::cout << mMapCanvas->extent() << std::endl;
|
||||
}
|
||||
|
@ -360,6 +360,7 @@ public slots:
|
||||
void setLayerOverviewStatus(QString theLayerId, bool theVisibilityFlag);
|
||||
void drawExtentRectangle(QPainter *);
|
||||
void updateMouseCoordinatePrecision();
|
||||
void debugHook();
|
||||
void stopZoom();
|
||||
|
||||
signals:
|
||||
|
@ -107,6 +107,9 @@
|
||||
<separator/>
|
||||
<action name="actionHelpAbout"/>
|
||||
</item>
|
||||
<item text="Debug" name="Debug">
|
||||
<action name="actionDebugHook"/>
|
||||
</item>
|
||||
</menubar>
|
||||
<toolbars>
|
||||
<toolbar dock="2">
|
||||
@ -1105,6 +1108,17 @@
|
||||
<string>New Vectorlayer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>actionDebugHook</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DebugHook</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>DebugHook to which random stuff can be attached</string>
|
||||
</property>
|
||||
</action>
|
||||
</actions>
|
||||
<images>
|
||||
<image name="image0">
|
||||
@ -1493,6 +1507,12 @@
|
||||
<receiver>QgisAppBase</receiver>
|
||||
<slot>measure()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionDebugHook</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>QgisAppBase</receiver>
|
||||
<slot>debugHook()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="global" impldecl="in implementation">iostream</include>
|
||||
@ -1548,6 +1568,7 @@
|
||||
<slot>deleteSelected()</slot>
|
||||
<slot>zoomToLayer()</slot>
|
||||
<slot>zoomToLayerExtent()</slot>
|
||||
<slot>debugHook()</slot>
|
||||
<slot>measure()</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
|
@ -303,6 +303,12 @@ void QgisAppBase::zoomToLayerExtent()
|
||||
}
|
||||
|
||||
|
||||
void QgisAppBase::debugHook()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void QgisAppBase::measure()
|
||||
|
@ -32,108 +32,108 @@ class QgsVectorLayer;
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
/**
|
||||
*@author Gary E.Sherman
|
||||
*/
|
||||
*@author Gary E.Sherman
|
||||
*/
|
||||
|
||||
class QgsAttributeTable:public QTable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QgsAttributeTable(QWidget * parent = 0, const char *name = 0);
|
||||
~QgsAttributeTable();
|
||||
public:
|
||||
QgsAttributeTable(QWidget * parent = 0, const char *name = 0);
|
||||
~QgsAttributeTable();
|
||||
|
||||
/**Inserts the feature with the specified id into rowIdMap. This function has to be called (e.g. from QgsShapeFileLayer) when a row is inserted into the table*/
|
||||
void insertFeatureId(int id, int row);
|
||||
/**Selects the row which belongs to the feature with the specified id*/
|
||||
void selectRowWithId(int id);
|
||||
/**Sorts a column. This method replaces the one from QTable to allow numeric sorting*/
|
||||
virtual void sortColumn(int col, bool ascending=true, bool wholeRows=false);
|
||||
/* Use this to give this class the current attribute actions,
|
||||
which are used when the user requests a popup menu */
|
||||
void setAttributeActions(const QgsAttributeAction& actions)
|
||||
{ mActions = actions; }
|
||||
/**Returns if the table contains uncommited changes*/
|
||||
bool edited() const {return mEdited;}
|
||||
/**Switches editing mode on and off*/
|
||||
void setEditable(bool enabled){mEditable=enabled;}
|
||||
/**Adds an attribute to the table (but does not commit it yet)
|
||||
@param name attribute name
|
||||
@param type attribute type
|
||||
@return false in case of a name conflict, true in case of success*/
|
||||
bool addAttribute(const QString& name, const QString& type);
|
||||
/**Deletes an attribute (but does not commit it)
|
||||
@param name attribute name*/
|
||||
void deleteAttribute(const QString& name);
|
||||
/**Delegates to QgsVectorLayer to decide, which changes
|
||||
belong to not commited features or to commited ones*/
|
||||
bool commitChanges(QgsVectorLayer* layer);
|
||||
/**Discard all changes and restore
|
||||
the state before editing was started*/
|
||||
bool rollBack(QgsVectorLayer* layer);
|
||||
/**Fills the contents of a provider into this table*/
|
||||
void fillTable(QgsVectorLayer* layer);
|
||||
/**Swaps the selected rows such that the selected ones are on the top of the table*/
|
||||
void bringSelectedToTop();
|
||||
|
||||
public slots:
|
||||
/**Inserts the feature with the specified id into rowIdMap. This function has to be called (e.g. from QgsShapeFileLayer) when a row is inserted into the table*/
|
||||
void insertFeatureId(int id, int row);
|
||||
/**Selects the row which belongs to the feature with the specified id*/
|
||||
void selectRowWithId(int id);
|
||||
/**Sorts a column. This method replaces the one from QTable to allow numeric sorting*/
|
||||
virtual void sortColumn(int col, bool ascending=true, bool wholeRows=false);
|
||||
/* Use this to give this class the current attribute actions,
|
||||
which are used when the user requests a popup menu */
|
||||
void setAttributeActions(const QgsAttributeAction& actions)
|
||||
{ mActions = actions; }
|
||||
/**Returns if the table contains uncommited changes*/
|
||||
bool edited() const {return mEdited;}
|
||||
/**Switches editing mode on and off*/
|
||||
void setEditable(bool enabled){mEditable=enabled;}
|
||||
/**Adds an attribute to the table (but does not commit it yet)
|
||||
@param name attribute name
|
||||
@param type attribute type
|
||||
@return false in case of a name conflict, true in case of success*/
|
||||
bool addAttribute(const QString& name, const QString& type);
|
||||
/**Deletes an attribute (but does not commit it)
|
||||
@param name attribute name*/
|
||||
void deleteAttribute(const QString& name);
|
||||
/**Delegates to QgsVectorLayer to decide, which changes
|
||||
belong to not commited features or to commited ones*/
|
||||
bool commitChanges(QgsVectorLayer* layer);
|
||||
/**Discard all changes and restore
|
||||
the state before editing was started*/
|
||||
bool rollBack(QgsVectorLayer* layer);
|
||||
/**Fills the contents of a provider into this table*/
|
||||
void fillTable(QgsVectorLayer* layer);
|
||||
/**Swaps the selected rows such that the selected ones are on the top of the table*/
|
||||
void bringSelectedToTop();
|
||||
|
||||
public slots:
|
||||
void columnClicked(int col);
|
||||
// Called when the user requests a popup menu
|
||||
void popupMenu(int row, int col, const QPoint& pos);
|
||||
// Called when the user chooses an item on the popup menu
|
||||
void popupItemSelected(int id);
|
||||
protected slots:
|
||||
void handleChangedSelections();
|
||||
/**Writes changed values to 'mChangedValues'*/
|
||||
void storeChangedValue(int row, int column);
|
||||
// Called when the user requests a popup menu
|
||||
void popupMenu(int row, int col, const QPoint& pos);
|
||||
// Called when the user chooses an item on the popup menu
|
||||
void popupItemSelected(int id);
|
||||
protected slots:
|
||||
void handleChangedSelections();
|
||||
/**Writes changed values to 'mChangedValues'*/
|
||||
void storeChangedValue(int row, int column);
|
||||
|
||||
protected:
|
||||
/**Flag telling if the ctrl-button or the shift-button is pressed*/
|
||||
bool lockKeyPressed;
|
||||
/**Search tree to find a row corresponding to a feature id*/
|
||||
QMap<int,int> rowIdMap;
|
||||
/**Flag indicating, which sorting order should be used*/
|
||||
bool sort_ascending;
|
||||
bool mEditable;
|
||||
/**True if table has been edited and contains uncommited changes*/
|
||||
bool mEdited;
|
||||
/**Map containing the added attributes. The key is the attribute name
|
||||
and the value the attribute type*/
|
||||
std::map<QString,QString> mAddedAttributes;
|
||||
/**Set containing the attribute names of deleted attributes*/
|
||||
std::set<QString> mDeletedAttributes;
|
||||
/**Nested map containing the changed attribute values. The int is the feature id,
|
||||
the first QString the attribute name and the second QString the new value*/
|
||||
std::map<int,std::map<QString,QString> > mChangedValues;
|
||||
/**Compares the content of two cells either alphanumeric or numeric. If 'ascending' is true, -1 means s1 is less, 0 equal, 1 greater. If 'ascending' is false, -1 means s1 is more, 0 equal, 1 greater. This method is used mainly to sort a column*/
|
||||
int compareItems(QString s1, QString s2, bool ascending, bool alphanumeric);
|
||||
void keyPressEvent(QKeyEvent* ev);
|
||||
void keyReleaseEvent(QKeyEvent* ev);
|
||||
/**Method used by sortColumn (implementation of a quicksort)*/
|
||||
void qsort(int lower, int upper, int col, bool ascending, bool alphanumeric);
|
||||
void contentsMouseReleaseEvent(QMouseEvent* e);
|
||||
/**Clears mAddedAttributes, mDeletedAttributes and mChangedValues*/
|
||||
void clearEditingStructures();
|
||||
/**Removes the column belonging to an attribute from the table
|
||||
@name attribut name*/
|
||||
void removeAttrColumn(const QString& name);
|
||||
protected:
|
||||
/**Flag telling if the ctrl-button or the shift-button is pressed*/
|
||||
bool lockKeyPressed;
|
||||
/**Search tree to find a row corresponding to a feature id*/
|
||||
QMap<int,int> rowIdMap;
|
||||
/**Flag indicating, which sorting order should be used*/
|
||||
bool sort_ascending;
|
||||
bool mEditable;
|
||||
/**True if table has been edited and contains uncommited changes*/
|
||||
bool mEdited;
|
||||
/**Map containing the added attributes. The key is the attribute name
|
||||
and the value the attribute type*/
|
||||
std::map<QString,QString> mAddedAttributes;
|
||||
/**Set containing the attribute names of deleted attributes*/
|
||||
std::set<QString> mDeletedAttributes;
|
||||
/**Nested map containing the changed attribute values. The int is the feature id,
|
||||
the first QString the attribute name and the second QString the new value*/
|
||||
std::map<int,std::map<QString,QString> > mChangedValues;
|
||||
/**Compares the content of two cells either alphanumeric or numeric. If 'ascending' is true, -1 means s1 is less, 0 equal, 1 greater. If 'ascending' is false, -1 means s1 is more, 0 equal, 1 greater. This method is used mainly to sort a column*/
|
||||
int compareItems(QString s1, QString s2, bool ascending, bool alphanumeric);
|
||||
void keyPressEvent(QKeyEvent* ev);
|
||||
void keyReleaseEvent(QKeyEvent* ev);
|
||||
/**Method used by sortColumn (implementation of a quicksort)*/
|
||||
void qsort(int lower, int upper, int col, bool ascending, bool alphanumeric);
|
||||
void contentsMouseReleaseEvent(QMouseEvent* e);
|
||||
/**Clears mAddedAttributes, mDeletedAttributes and mChangedValues*/
|
||||
void clearEditingStructures();
|
||||
/**Removes the column belonging to an attribute from the table
|
||||
@name attribut name*/
|
||||
void removeAttrColumn(const QString& name);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
|
||||
/**Is emitted when a row was selected*/
|
||||
void selected(int);
|
||||
/**Is emitted when all rows have been deselected*/
|
||||
void selectionRemoved();
|
||||
/**Is emmited when a set of related selection and deselection signals have been emitted*/
|
||||
void repaintRequested();
|
||||
/**Is emitted when a row was selected*/
|
||||
void selected(int);
|
||||
/**Is emitted when all rows have been deselected*/
|
||||
void selectionRemoved();
|
||||
/**Is emmited when a set of related selection and deselection signals have been emitted*/
|
||||
void repaintRequested();
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
// Data to do with providing a popup menu of actions that
|
||||
std::vector<std::pair<QString, QString> > mActionValues;
|
||||
int mClickedOnValue;
|
||||
QPopupMenu* mActionPopup;
|
||||
QgsAttributeAction mActions;
|
||||
// Data to do with providing a popup menu of actions that
|
||||
std::vector<std::pair<QString, QString> > mActionValues;
|
||||
int mClickedOnValue;
|
||||
QPopupMenu* mActionPopup;
|
||||
QgsAttributeAction mActions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,40 +30,40 @@
|
||||
|
||||
QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer):QgsAttributeTableBase(), mLayer(layer)
|
||||
{
|
||||
//insert editing popup
|
||||
QMenuBar* mMenuBar = new QMenuBar(this, "mMenuBar");
|
||||
mMenuBar->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, mMenuBar->sizePolicy().hasHeightForWidth() ) );
|
||||
mMenuBar->setMinimumSize( QSize( 0, 40 ) );
|
||||
//insert editing popup
|
||||
QMenuBar* mMenuBar = new QMenuBar(this, "mMenuBar");
|
||||
mMenuBar->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, mMenuBar->sizePolicy().hasHeightForWidth() ) );
|
||||
mMenuBar->setMinimumSize( QSize( 0, 40 ) );
|
||||
|
||||
QgsAttributeTableBaseLayout->addMultiCellWidget( mMenuBar, 0, 0, 0, 4 );
|
||||
QgsAttributeTableBaseLayout->addMultiCellWidget( mMenuBar, 0, 0, 0, 4 );
|
||||
|
||||
edit = new QPopupMenu(this);
|
||||
QPopupMenu* selection = new QPopupMenu(this);
|
||||
edit = new QPopupMenu(this);
|
||||
QPopupMenu* selection = new QPopupMenu(this);
|
||||
|
||||
edit->insertItem(tr("&Add Attribute..."), this, SLOT(addAttribute()), CTRL+Key_A,0);
|
||||
edit->insertItem(tr("&Delete Attributes..."), this, SLOT(deleteAttributes()), CTRL+Key_D,1);
|
||||
selection->insertItem(tr("&Bring selection to top"), this, SLOT(selectedToTop()), CTRL+Key_T);
|
||||
selection->insertItem(tr("&Invert selection"), this, SLOT(invertSelection()), CTRL+Key_I);
|
||||
mMenuBar->insertItem(tr("&Edit"), edit);
|
||||
mMenuBar->insertItem(tr("&Selection"),selection);
|
||||
edit->setItemEnabled(0,false);
|
||||
edit->setItemEnabled(1,false);
|
||||
edit->insertItem(tr("&Add Attribute..."), this, SLOT(addAttribute()), CTRL+Key_A,0);
|
||||
edit->insertItem(tr("&Delete Attributes..."), this, SLOT(deleteAttributes()), CTRL+Key_D,1);
|
||||
selection->insertItem(tr("&Bring selection to top"), this, SLOT(selectedToTop()), CTRL+Key_T);
|
||||
selection->insertItem(tr("&Invert selection"), this, SLOT(invertSelection()), CTRL+Key_I);
|
||||
mMenuBar->insertItem(tr("&Edit"), edit);
|
||||
mMenuBar->insertItem(tr("&Selection"),selection);
|
||||
edit->setItemEnabled(0,false);
|
||||
edit->setItemEnabled(1,false);
|
||||
|
||||
btnStopEditing->setEnabled(false);
|
||||
int cap=layer->getDataProvider()->capabilities();
|
||||
if((cap&QgsVectorDataProvider::ChangeAttributeValues)
|
||||
||(cap&QgsVectorDataProvider::AddAttributes)
|
||||
||(cap&QgsVectorDataProvider::DeleteAttributes))
|
||||
{
|
||||
btnStartEditing->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStartEditing->setEnabled(false);
|
||||
}
|
||||
|
||||
QObject::connect(btnStartEditing, SIGNAL(clicked()), this, SLOT(startEditing()));
|
||||
QObject::connect(btnStopEditing, SIGNAL(clicked()), this, SLOT(stopEditing()));
|
||||
btnStopEditing->setEnabled(false);
|
||||
int cap=layer->getDataProvider()->capabilities();
|
||||
if((cap&QgsVectorDataProvider::ChangeAttributeValues)
|
||||
||(cap&QgsVectorDataProvider::AddAttributes)
|
||||
||(cap&QgsVectorDataProvider::DeleteAttributes))
|
||||
{
|
||||
btnStartEditing->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStartEditing->setEnabled(false);
|
||||
}
|
||||
|
||||
QObject::connect(btnStartEditing, SIGNAL(clicked()), this, SLOT(startEditing()));
|
||||
QObject::connect(btnStopEditing, SIGNAL(clicked()), this, SLOT(stopEditing()));
|
||||
}
|
||||
|
||||
QgsAttributeTableDisplay::~QgsAttributeTableDisplay()
|
||||
@ -81,96 +81,96 @@ void QgsAttributeTableDisplay::setTitle(QString title)
|
||||
|
||||
void QgsAttributeTableDisplay::deleteAttributes()
|
||||
{
|
||||
QgsDelAttrDialog dialog(table()->horizontalHeader());
|
||||
if(dialog.exec()==QDialog::Accepted)
|
||||
{
|
||||
const std::list<QString>* attlist=dialog.selectedAttributes();
|
||||
for(std::list<QString>::const_iterator iter=attlist->begin();iter!=attlist->end();++iter)
|
||||
{
|
||||
table()->deleteAttribute(*iter);
|
||||
}
|
||||
}
|
||||
QgsDelAttrDialog dialog(table()->horizontalHeader());
|
||||
if(dialog.exec()==QDialog::Accepted)
|
||||
{
|
||||
const std::list<QString>* attlist=dialog.selectedAttributes();
|
||||
for(std::list<QString>::const_iterator iter=attlist->begin();iter!=attlist->end();++iter)
|
||||
{
|
||||
table()->deleteAttribute(*iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAttributeTableDisplay::addAttribute()
|
||||
{
|
||||
QgsAddAttrDialog dialog(mLayer->getDataProvider());
|
||||
if(dialog.exec()==QDialog::Accepted)
|
||||
QgsAddAttrDialog dialog(mLayer->getDataProvider());
|
||||
if(dialog.exec()==QDialog::Accepted)
|
||||
{
|
||||
if(!table()->addAttribute(dialog.name(),dialog.type()))
|
||||
{
|
||||
if(!table()->addAttribute(dialog.name(),dialog.type()))
|
||||
{
|
||||
QMessageBox::information(0,"Name conflict","The attribute could not be inserted. The name already exists in the table",QMessageBox::Ok);
|
||||
}
|
||||
QMessageBox::information(0,"Name conflict","The attribute could not be inserted. The name already exists in the table",QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAttributeTableDisplay::startEditing()
|
||||
{
|
||||
QgsVectorDataProvider* provider=mLayer->getDataProvider();
|
||||
bool editing=false;
|
||||
QgsVectorDataProvider* provider=mLayer->getDataProvider();
|
||||
bool editing=false;
|
||||
|
||||
if(provider)
|
||||
if(provider)
|
||||
{
|
||||
if(provider->capabilities()&QgsVectorDataProvider::AddAttributes)
|
||||
{
|
||||
if(provider->capabilities()&QgsVectorDataProvider::AddAttributes)
|
||||
{
|
||||
edit->setItemEnabled(0,true);
|
||||
editing=true;
|
||||
}
|
||||
if(provider->capabilities()&QgsVectorDataProvider::DeleteAttributes)
|
||||
{
|
||||
edit->setItemEnabled(1,true);
|
||||
editing=true;
|
||||
}
|
||||
if(provider->capabilities()&QgsVectorDataProvider::ChangeAttributeValues)
|
||||
{
|
||||
table()->setReadOnly(false);
|
||||
table()->setColumnReadOnly(0,true);//id column is not editable
|
||||
editing=true;
|
||||
}
|
||||
if(editing)
|
||||
{
|
||||
btnStartEditing->setEnabled(false);
|
||||
btnStopEditing->setEnabled(true);
|
||||
btnClose->setEnabled(false);
|
||||
}
|
||||
edit->setItemEnabled(0,true);
|
||||
editing=true;
|
||||
}
|
||||
if(provider->capabilities()&QgsVectorDataProvider::DeleteAttributes)
|
||||
{
|
||||
edit->setItemEnabled(1,true);
|
||||
editing=true;
|
||||
}
|
||||
if(provider->capabilities()&QgsVectorDataProvider::ChangeAttributeValues)
|
||||
{
|
||||
table()->setReadOnly(false);
|
||||
table()->setColumnReadOnly(0,true);//id column is not editable
|
||||
editing=true;
|
||||
}
|
||||
if(editing)
|
||||
{
|
||||
btnStartEditing->setEnabled(false);
|
||||
btnStopEditing->setEnabled(true);
|
||||
btnClose->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAttributeTableDisplay::stopEditing()
|
||||
{
|
||||
if(table()->edited())
|
||||
if(table()->edited())
|
||||
{
|
||||
//commit or roll back?
|
||||
int commit=QMessageBox::information(0,"Stop editing","Do you want to save the changes?",QMessageBox::Yes,QMessageBox::No);
|
||||
if(commit==QMessageBox::Yes)
|
||||
{
|
||||
//commit or roll back?
|
||||
int commit=QMessageBox::information(0,"Stop editing","Do you want to save the changes?",QMessageBox::Yes,QMessageBox::No);
|
||||
if(commit==QMessageBox::Yes)
|
||||
{
|
||||
if(!table()->commitChanges(mLayer))
|
||||
{
|
||||
QMessageBox::information(0,"Error","Could not commit changes",QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
table()->rollBack(mLayer);
|
||||
}
|
||||
if(!table()->commitChanges(mLayer))
|
||||
{
|
||||
QMessageBox::information(0,"Error","Could not commit changes",QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
btnStartEditing->setEnabled(true);
|
||||
btnStopEditing->setEnabled(false);
|
||||
btnClose->setEnabled(true);
|
||||
edit->setItemEnabled(0,false);
|
||||
edit->setItemEnabled(1,false);
|
||||
table()->setReadOnly(true);
|
||||
else
|
||||
{
|
||||
table()->rollBack(mLayer);
|
||||
}
|
||||
}
|
||||
btnStartEditing->setEnabled(true);
|
||||
btnStopEditing->setEnabled(false);
|
||||
btnClose->setEnabled(true);
|
||||
edit->setItemEnabled(0,false);
|
||||
edit->setItemEnabled(1,false);
|
||||
table()->setReadOnly(true);
|
||||
}
|
||||
|
||||
void QgsAttributeTableDisplay::selectedToTop()
|
||||
{
|
||||
table()->bringSelectedToTop();
|
||||
table()->bringSelectedToTop();
|
||||
}
|
||||
|
||||
void QgsAttributeTableDisplay::invertSelection()
|
||||
{
|
||||
if(mLayer)
|
||||
{
|
||||
mLayer->invertSelection();
|
||||
}
|
||||
if(mLayer)
|
||||
{
|
||||
mLayer->invertSelection();
|
||||
}
|
||||
}
|
||||
|
@ -35,23 +35,23 @@ class QPopupMenu;
|
||||
|
||||
class QgsAttributeTableDisplay:public QgsAttributeTableBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsAttributeTableDisplay(QgsVectorLayer* layer);
|
||||
~QgsAttributeTableDisplay();
|
||||
QgsAttributeTable *table();
|
||||
void setTitle(QString title);
|
||||
protected:
|
||||
QgsVectorLayer* mLayer;
|
||||
QPopupMenu* edit;
|
||||
QgsAttributeTableDisplay(QgsVectorLayer* layer);
|
||||
~QgsAttributeTableDisplay();
|
||||
QgsAttributeTable *table();
|
||||
void setTitle(QString title);
|
||||
protected:
|
||||
QgsVectorLayer* mLayer;
|
||||
QPopupMenu* edit;
|
||||
|
||||
protected slots:
|
||||
void deleteAttributes();
|
||||
void addAttribute();
|
||||
void startEditing();
|
||||
void stopEditing();
|
||||
void selectedToTop();
|
||||
void invertSelection();
|
||||
protected slots:
|
||||
void deleteAttributes();
|
||||
void addAttribute();
|
||||
void startEditing();
|
||||
void stopEditing();
|
||||
void selectedToTop();
|
||||
void invertSelection();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
1062
src/qgscomposer.cpp
1062
src/qgscomposer.cpp
File diff suppressed because it is too large
Load Diff
@ -125,31 +125,31 @@ void QgsComposerMap::draw ( QPainter *painter, QgsRect *extent, QgsMapToPixel *t
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
|
||||
for ( int i = 0; i < nlayers; i++ ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
|
||||
if ( !layer->visible() ) continue;
|
||||
if ( !layer->visible() ) continue;
|
||||
|
||||
if ( layer->type() == QgsMapLayer::VECTOR ) {
|
||||
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
|
||||
if ( layer->type() == QgsMapLayer::VECTOR ) {
|
||||
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
|
||||
|
||||
double widthScale = mWidthScale * mComposition->scale();
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Render ) {
|
||||
widthScale *= mComposition->viewScale();
|
||||
}
|
||||
double symbolScale = mSymbolScale * mComposition->scale();
|
||||
vector->draw( painter, extent, transform, device, widthScale, symbolScale, 0 );
|
||||
double widthScale = mWidthScale * mComposition->scale();
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Render ) {
|
||||
widthScale *= mComposition->viewScale();
|
||||
}
|
||||
double symbolScale = mSymbolScale * mComposition->scale();
|
||||
vector->draw( painter, extent, transform, device, widthScale, symbolScale, 0 );
|
||||
|
||||
if ( vector->labelOn() ) {
|
||||
double fontScale = 25.4 * mFontScale * mComposition->scale() / 72;
|
||||
if ( plotStyle() == QgsComposition::Postscript ) {
|
||||
// I have no idea why 2.54 - it is an empirical value
|
||||
fontScale = 2.54 * 72.0 / mComposition->resolution();
|
||||
}
|
||||
vector->drawLabels ( painter, extent, transform, device, fontScale );
|
||||
}
|
||||
} else {
|
||||
layer->draw( painter, extent, transform, device );
|
||||
}
|
||||
if ( vector->labelOn() ) {
|
||||
double fontScale = 25.4 * mFontScale * mComposition->scale() / 72;
|
||||
if ( plotStyle() == QgsComposition::Postscript ) {
|
||||
// I have no idea why 2.54 - it is an empirical value
|
||||
fontScale = 2.54 * 72.0 / mComposition->resolution();
|
||||
}
|
||||
vector->drawLabels ( painter, extent, transform, device, fontScale );
|
||||
}
|
||||
} else {
|
||||
layer->draw( painter, extent, transform, device );
|
||||
}
|
||||
}
|
||||
mMapCanvas->freeze(false);
|
||||
}
|
||||
@ -183,7 +183,7 @@ void QgsComposerMap::cache ( void )
|
||||
double scale = mExtent.width() / w;
|
||||
mCacheExtent.setXmax ( mCacheExtent.xMin() + w * scale );
|
||||
mCacheExtent.setYmax ( mCacheExtent.yMin() + h * scale );
|
||||
|
||||
|
||||
mCachePixmap.resize( w, h );
|
||||
|
||||
// WARNING: ymax in QgsMapToPixel is device height!!!
|
||||
@ -208,74 +208,74 @@ void QgsComposerMap::draw ( QPainter & painter )
|
||||
mDrawing = true;
|
||||
|
||||
std::cout << "draw mPlotStyle = " << plotStyle()
|
||||
<< " mPreviewMode = " << mPreviewMode << std::endl;
|
||||
<< " mPreviewMode = " << mPreviewMode << std::endl;
|
||||
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Cache ) { // Draw from cache
|
||||
std::cout << "use cache" << std::endl;
|
||||
|
||||
if ( !mCacheUpdated || mMapCanvas->layerCount() != mNumCachedLayers ) {
|
||||
cache();
|
||||
}
|
||||
|
||||
// Scale so that the cache fills the map rectangle
|
||||
double scale = 1.0 * QCanvasRectangle::width() / mCachePixmap.width();
|
||||
|
||||
|
||||
painter.save();
|
||||
if ( !mCacheUpdated || mMapCanvas->layerCount() != mNumCachedLayers ) {
|
||||
cache();
|
||||
}
|
||||
|
||||
// Scale so that the cache fills the map rectangle
|
||||
double scale = 1.0 * QCanvasRectangle::width() / mCachePixmap.width();
|
||||
|
||||
|
||||
painter.save();
|
||||
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.scale(scale,scale);
|
||||
std::cout << "scale = " << scale << std::endl;
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.scale(scale,scale);
|
||||
std::cout << "scale = " << scale << std::endl;
|
||||
std::cout << "translate: " << QCanvasRectangle::x() << ", " << QCanvasRectangle::y() << std::endl;
|
||||
// Note: drawing only a visible part of the pixmap doesn't make it much faster
|
||||
painter.drawPixmap(0,0, mCachePixmap);
|
||||
// Note: drawing only a visible part of the pixmap doesn't make it much faster
|
||||
painter.drawPixmap(0,0, mCachePixmap);
|
||||
|
||||
painter.restore();
|
||||
painter.restore();
|
||||
|
||||
} else if ( (plotStyle() == QgsComposition::Preview && mPreviewMode == Render) ||
|
||||
plotStyle() == QgsComposition::Print ||
|
||||
plotStyle() == QgsComposition::Postscript )
|
||||
plotStyle() == QgsComposition::Print ||
|
||||
plotStyle() == QgsComposition::Postscript )
|
||||
{
|
||||
std::cout << "render" << std::endl;
|
||||
|
||||
double scale = mExtent.width() / QCanvasRectangle::width();
|
||||
QgsMapToPixel transform(scale, QCanvasRectangle::height(), mExtent.yMin(), mExtent.xMin() );
|
||||
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
|
||||
// Note: CoordDevice doesn't work well
|
||||
painter.setClipRect ( 0, 0, QCanvasRectangle::width(), QCanvasRectangle::height(), QPainter::CoordPainter );
|
||||
|
||||
draw( &painter, &mExtent, &transform, painter.device() );
|
||||
painter.restore();
|
||||
|
||||
double scale = mExtent.width() / QCanvasRectangle::width();
|
||||
QgsMapToPixel transform(scale, QCanvasRectangle::height(), mExtent.yMin(), mExtent.xMin() );
|
||||
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
|
||||
// Note: CoordDevice doesn't work well
|
||||
painter.setClipRect ( 0, 0, QCanvasRectangle::width(), QCanvasRectangle::height(), QPainter::CoordPainter );
|
||||
|
||||
draw( &painter, &mExtent, &transform, painter.device() );
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
// Draw frame around
|
||||
if ( mFrame ) {
|
||||
painter.setPen( QPen(QColor(0,0,0), 1) );
|
||||
painter.setBrush( Qt::NoBrush );
|
||||
painter.setPen( QPen(QColor(0,0,0), 1) );
|
||||
painter.setBrush( Qt::NoBrush );
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.drawRect ( 0, 0, QCanvasRectangle::width()+1, QCanvasRectangle::height()+1 ); // is it right?
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.drawRect ( 0, 0, QCanvasRectangle::width()+1, QCanvasRectangle::height()+1 ); // is it right?
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
// Show selected / Highlight
|
||||
if ( mSelected && plotStyle() == QgsComposition::Preview ) {
|
||||
painter.setPen( mComposition->selectionPen() );
|
||||
painter.setBrush( mComposition->selectionBrush() );
|
||||
int x = (int) QCanvasRectangle::x();
|
||||
int y = (int) QCanvasRectangle::y();
|
||||
int s = mComposition->selectionBoxSize();
|
||||
painter.setPen( mComposition->selectionPen() );
|
||||
painter.setBrush( mComposition->selectionBrush() );
|
||||
int x = (int) QCanvasRectangle::x();
|
||||
int y = (int) QCanvasRectangle::y();
|
||||
int s = mComposition->selectionBoxSize();
|
||||
|
||||
painter.drawRect ( x, y, s, s );
|
||||
x += QCanvasRectangle::width();
|
||||
painter.drawRect ( x-s, y, s, s );
|
||||
y += QCanvasRectangle::height();
|
||||
painter.drawRect ( x-s, y-s, s, s );
|
||||
x -= QCanvasRectangle::width();
|
||||
painter.drawRect ( x, y-s, s, s );
|
||||
painter.drawRect ( x, y, s, s );
|
||||
x += QCanvasRectangle::width();
|
||||
painter.drawRect ( x-s, y, s, s );
|
||||
y += QCanvasRectangle::height();
|
||||
painter.drawRect ( x-s, y-s, s, s );
|
||||
x -= QCanvasRectangle::width();
|
||||
painter.drawRect ( x, y-s, s, s );
|
||||
}
|
||||
|
||||
mDrawing = false;
|
||||
@ -302,14 +302,14 @@ void QgsComposerMap::calculateChanged ( void )
|
||||
mCalculate = mCalculateComboBox->currentItem();
|
||||
|
||||
if ( mCalculate == Scale ) { // return to extent defined by user
|
||||
recalculate();
|
||||
recalculate();
|
||||
|
||||
mCacheUpdated = false;
|
||||
//QCanvasRectangle::canvas()->setAllChanged(); // must be setAllChanged(), not sure why
|
||||
QCanvasRectangle::canvas()->setChanged( QCanvasRectangle::boundingRect() );
|
||||
QCanvasRectangle::canvas()->update();
|
||||
mCacheUpdated = false;
|
||||
//QCanvasRectangle::canvas()->setAllChanged(); // must be setAllChanged(), not sure why
|
||||
QCanvasRectangle::canvas()->setChanged( QCanvasRectangle::boundingRect() );
|
||||
QCanvasRectangle::canvas()->update();
|
||||
|
||||
mComposition->emitMapChanged ( mId );
|
||||
mComposition->emitMapChanged ( mId );
|
||||
}
|
||||
setOptions();
|
||||
writeSettings();
|
||||
@ -320,15 +320,15 @@ double QgsComposerMap::scaleFromUserScale ( double us )
|
||||
double s;
|
||||
|
||||
switch ( QgsProject::instance()->mapUnits() ) {
|
||||
case QgsScaleCalculator::METERS :
|
||||
s = 1000. * mComposition->scale() / us;
|
||||
break;
|
||||
case QgsScaleCalculator::FEET :
|
||||
s = 304.8 * mComposition->scale() / us;
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
s = mComposition->scale() / us;
|
||||
break;
|
||||
case QgsScaleCalculator::METERS :
|
||||
s = 1000. * mComposition->scale() / us;
|
||||
break;
|
||||
case QgsScaleCalculator::FEET :
|
||||
s = 304.8 * mComposition->scale() / us;
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
s = mComposition->scale() / us;
|
||||
break;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -338,15 +338,15 @@ double QgsComposerMap::userScaleFromScale ( double s )
|
||||
double us;
|
||||
|
||||
switch ( QgsProject::instance()->mapUnits() ) {
|
||||
case QgsScaleCalculator::METERS :
|
||||
us = 1000. * mComposition->scale() / s;
|
||||
break;
|
||||
case QgsScaleCalculator::FEET :
|
||||
us = 304.8 * mComposition->scale() / s;
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
us = mComposition->scale() / s;
|
||||
break;
|
||||
case QgsScaleCalculator::METERS :
|
||||
us = 1000. * mComposition->scale() / s;
|
||||
break;
|
||||
case QgsScaleCalculator::FEET :
|
||||
us = 304.8 * mComposition->scale() / s;
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
us = mComposition->scale() / s;
|
||||
break;
|
||||
}
|
||||
|
||||
return us;
|
||||
@ -408,41 +408,41 @@ void QgsComposerMap::recalculate ( void )
|
||||
|
||||
if ( mCalculate == Scale )
|
||||
{
|
||||
// Calculate scale from extent and rectangle
|
||||
double xscale = QCanvasRectangle::width() / mUserExtent.width();
|
||||
double yscale = QCanvasRectangle::height() / mUserExtent.height();
|
||||
// Calculate scale from extent and rectangle
|
||||
double xscale = QCanvasRectangle::width() / mUserExtent.width();
|
||||
double yscale = QCanvasRectangle::height() / mUserExtent.height();
|
||||
|
||||
mExtent = mUserExtent;
|
||||
mExtent = mUserExtent;
|
||||
|
||||
if ( xscale < yscale ) {
|
||||
mScale = xscale;
|
||||
// extend y
|
||||
double d = ( 1. * QCanvasRectangle::height() / mScale - mUserExtent.height() ) / 2 ;
|
||||
mExtent.setYmin ( mUserExtent.yMin() - d );
|
||||
mExtent.setYmax ( mUserExtent.yMax() + d );
|
||||
} else {
|
||||
mScale = yscale;
|
||||
// extend x
|
||||
double d = ( 1.* QCanvasRectangle::width() / mScale - mUserExtent.width() ) / 2 ;
|
||||
mExtent.setXmin ( mUserExtent.xMin() - d );
|
||||
mExtent.setXmax ( mUserExtent.xMax() + d );
|
||||
}
|
||||
if ( xscale < yscale ) {
|
||||
mScale = xscale;
|
||||
// extend y
|
||||
double d = ( 1. * QCanvasRectangle::height() / mScale - mUserExtent.height() ) / 2 ;
|
||||
mExtent.setYmin ( mUserExtent.yMin() - d );
|
||||
mExtent.setYmax ( mUserExtent.yMax() + d );
|
||||
} else {
|
||||
mScale = yscale;
|
||||
// extend x
|
||||
double d = ( 1.* QCanvasRectangle::width() / mScale - mUserExtent.width() ) / 2 ;
|
||||
mExtent.setXmin ( mUserExtent.xMin() - d );
|
||||
mExtent.setXmax ( mUserExtent.xMax() + d );
|
||||
}
|
||||
|
||||
mUserScale = userScaleFromScale ( mScale );
|
||||
mUserScale = userScaleFromScale ( mScale );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate extent
|
||||
double xc = ( mUserExtent.xMax() + mUserExtent.xMin() ) / 2;
|
||||
double yc = ( mUserExtent.yMax() + mUserExtent.yMin() ) / 2;
|
||||
// Calculate extent
|
||||
double xc = ( mUserExtent.xMax() + mUserExtent.xMin() ) / 2;
|
||||
double yc = ( mUserExtent.yMax() + mUserExtent.yMin() ) / 2;
|
||||
|
||||
double width = QCanvasRectangle::width() / mScale;
|
||||
double height = QCanvasRectangle::height() / mScale;
|
||||
|
||||
mExtent.setXmin ( xc - width/2 );
|
||||
mExtent.setXmax ( xc + width/2 );
|
||||
mExtent.setYmin ( yc - height/2 );
|
||||
mExtent.setYmax ( yc + height/2 );
|
||||
double width = QCanvasRectangle::width() / mScale;
|
||||
double height = QCanvasRectangle::height() / mScale;
|
||||
|
||||
mExtent.setXmin ( xc - width/2 );
|
||||
mExtent.setXmax ( xc + width/2 );
|
||||
mExtent.setYmin ( yc - height/2 );
|
||||
mExtent.setYmax ( yc + height/2 );
|
||||
|
||||
}
|
||||
|
||||
@ -479,18 +479,18 @@ void QgsComposerMap::setOptions ( void )
|
||||
|
||||
// Scale
|
||||
switch ( QgsProject::instance()->mapUnits() ) {
|
||||
case QgsScaleCalculator::METERS :
|
||||
case QgsScaleCalculator::FEET :
|
||||
case QgsScaleCalculator::METERS :
|
||||
case QgsScaleCalculator::FEET :
|
||||
mScaleLineEdit->setText ( QString("%1").arg((int)mUserScale) );
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
mScaleLineEdit->setText ( QString("%1").arg(mUserScale,0,'f') );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
if ( mCalculate == Scale ) {
|
||||
mScaleLineEdit->setEnabled(false);
|
||||
mScaleLineEdit->setEnabled(false);
|
||||
} else {
|
||||
mScaleLineEdit->setEnabled(true);
|
||||
mScaleLineEdit->setEnabled(true);
|
||||
}
|
||||
|
||||
mWidthScaleLineEdit->setText ( QString("%1").arg(mWidthScale,0,'g',2) );
|
||||
|
@ -69,7 +69,7 @@
|
||||
#include "qgsmarkercatalogue.h"
|
||||
|
||||
QgsComposerVectorLegend::QgsComposerVectorLegend ( QgsComposition *composition, int id,
|
||||
int x, int y, int fontSize )
|
||||
int x, int y, int fontSize )
|
||||
: QCanvasRectangle(x,y,10,10,0)
|
||||
{
|
||||
std::cout << "QgsComposerVectorLegend::QgsComposerVectorLegend()" << std::endl;
|
||||
@ -86,7 +86,7 @@ QgsComposerVectorLegend::QgsComposerVectorLegend ( QgsComposition *composition,
|
||||
// Set map to the first available if any
|
||||
std::vector<QgsComposerMap*> maps = mComposition->maps();
|
||||
if ( maps.size() > 0 ) {
|
||||
mMap = maps[0]->id();
|
||||
mMap = maps[0]->id();
|
||||
}
|
||||
|
||||
// Calc size and cache
|
||||
@ -153,10 +153,10 @@ void QgsComposerVectorLegend::init ( void )
|
||||
mLayersPopupMenu->insertItem( "Combine selected layers", this, SLOT(groupLayers()) );
|
||||
|
||||
connect ( mLayersListView, SIGNAL(clicked(QListViewItem *)),
|
||||
this, SLOT(layerChanged(QListViewItem *)));
|
||||
this, SLOT(layerChanged(QListViewItem *)));
|
||||
|
||||
connect ( mLayersListView, SIGNAL(rightButtonClicked(QListViewItem *, const QPoint &, int)),
|
||||
this, SLOT( showLayersPopupMenu(QListViewItem *, const QPoint &, int)) );
|
||||
this, SLOT( showLayersPopupMenu(QListViewItem *, const QPoint &, int)) );
|
||||
|
||||
// Plot style
|
||||
setPlotStyle ( QgsComposition::Preview );
|
||||
@ -184,10 +184,10 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
|
||||
QPainter *painter;
|
||||
QPixmap *pixmap;
|
||||
if ( p ) {
|
||||
painter = p;
|
||||
painter = p;
|
||||
} else {
|
||||
pixmap = new QPixmap(1,1);
|
||||
painter = new QPainter( pixmap );
|
||||
pixmap = new QPixmap(1,1);
|
||||
painter = new QPainter( pixmap );
|
||||
}
|
||||
|
||||
std::cout << "mComposition->scale() = " << mComposition->scale() << std::endl;
|
||||
@ -215,9 +215,9 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
|
||||
|
||||
// I have no idea why 2.54 - it is an empirical value
|
||||
if ( plotStyle() == QgsComposition::Postscript) {
|
||||
titleSize = 2.54 * 72.0 * mTitleFont.pointSizeFloat() / mComposition->resolution();
|
||||
sectionSize = 2.54 * 72.0 * mSectionFont.pointSizeFloat() / mComposition->resolution();
|
||||
size = 2.54 * 72.0 * mFont.pointSizeFloat() / mComposition->resolution();
|
||||
titleSize = 2.54 * 72.0 * mTitleFont.pointSizeFloat() / mComposition->resolution();
|
||||
sectionSize = 2.54 * 72.0 * mSectionFont.pointSizeFloat() / mComposition->resolution();
|
||||
size = 2.54 * 72.0 * mFont.pointSizeFloat() / mComposition->resolution();
|
||||
}
|
||||
|
||||
titleFont.setPointSizeFloat ( titleSize );
|
||||
@ -242,216 +242,216 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
|
||||
// Layers
|
||||
QgsComposerMap *map = mComposition->map ( mMap );
|
||||
if ( map ) {
|
||||
std::map<int,int> doneGroups;
|
||||
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
for ( int i = nlayers - 1; i >= 0; i-- ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
if ( !layer->visible() ) continue;
|
||||
if ( layer->type() != QgsMapLayer::VECTOR ) continue;
|
||||
std::map<int,int> doneGroups;
|
||||
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
for ( int i = nlayers - 1; i >= 0; i-- ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
if ( !layer->visible() ) continue;
|
||||
if ( layer->type() != QgsMapLayer::VECTOR ) continue;
|
||||
|
||||
QString layerId = layer->getLayerID();
|
||||
if( ! layerOn(layerId) ) continue;
|
||||
|
||||
int group = layerGroup ( layerId );
|
||||
if ( group > 0 ) {
|
||||
//std::map<int,int>::iterator it= doneGroups.find();
|
||||
if ( doneGroups.find(group) != doneGroups.end() ) {
|
||||
continue;
|
||||
} else {
|
||||
doneGroups.insert(std::make_pair(group,1));
|
||||
}
|
||||
}
|
||||
QString layerId = layer->getLayerID();
|
||||
if( ! layerOn(layerId) ) continue;
|
||||
|
||||
int group = layerGroup ( layerId );
|
||||
if ( group > 0 ) {
|
||||
//std::map<int,int>::iterator it= doneGroups.find();
|
||||
if ( doneGroups.find(group) != doneGroups.end() ) {
|
||||
continue;
|
||||
} else {
|
||||
doneGroups.insert(std::make_pair(group,1));
|
||||
}
|
||||
}
|
||||
|
||||
/* Make list of all layers in the group and count section items */
|
||||
std::vector<int> groupLayers; // vector of layers
|
||||
std::vector<int> itemHeights; // maximum item sizes
|
||||
std::vector<QString> itemLabels; // item labels
|
||||
int sectionItemsCount = 0;
|
||||
QString sectionTitle;
|
||||
/* Make list of all layers in the group and count section items */
|
||||
std::vector<int> groupLayers; // vector of layers
|
||||
std::vector<int> itemHeights; // maximum item sizes
|
||||
std::vector<QString> itemLabels; // item labels
|
||||
int sectionItemsCount = 0;
|
||||
QString sectionTitle;
|
||||
|
||||
for ( int j = nlayers - 1; j >= 0; j-- ) {
|
||||
QgsMapLayer *layer2 = mMapCanvas->getZpos(j);
|
||||
if ( !layer2->visible() ) continue;
|
||||
if ( layer2->type() != QgsMapLayer::VECTOR ) continue;
|
||||
|
||||
QString layerId2 = layer2->getLayerID();;
|
||||
if( ! layerOn(layerId2) ) continue;
|
||||
|
||||
int group2 = layerGroup ( layerId2 );
|
||||
|
||||
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer2);
|
||||
QgsRenderer *renderer = vector->renderer();
|
||||
for ( int j = nlayers - 1; j >= 0; j-- ) {
|
||||
QgsMapLayer *layer2 = mMapCanvas->getZpos(j);
|
||||
if ( !layer2->visible() ) continue;
|
||||
if ( layer2->type() != QgsMapLayer::VECTOR ) continue;
|
||||
|
||||
QString layerId2 = layer2->getLayerID();;
|
||||
if( ! layerOn(layerId2) ) continue;
|
||||
|
||||
int group2 = layerGroup ( layerId2 );
|
||||
|
||||
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer2);
|
||||
QgsRenderer *renderer = vector->renderer();
|
||||
|
||||
// QgsContinuousColRenderer is not supported yet
|
||||
// QgsSiMaRenderer, QgsGraduatedMaRenderer, QgsUValMaRenderer no more
|
||||
if ( typeid (*renderer) == typeid(QgsContinuousColRenderer) ||
|
||||
typeid (*renderer) == typeid(QgsSiMaRenderer) ||
|
||||
typeid (*renderer) == typeid(QgsGraduatedMaRenderer) ||
|
||||
typeid (*renderer) == typeid(QgsUValMaRenderer) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// QgsContinuousColRenderer is not supported yet
|
||||
// QgsSiMaRenderer, QgsGraduatedMaRenderer, QgsUValMaRenderer no more
|
||||
if ( typeid (*renderer) == typeid(QgsContinuousColRenderer) ||
|
||||
typeid (*renderer) == typeid(QgsSiMaRenderer) ||
|
||||
typeid (*renderer) == typeid(QgsGraduatedMaRenderer) ||
|
||||
typeid (*renderer) == typeid(QgsUValMaRenderer) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( (group > 0 && group2 == group) || ( group == 0 && j == i ) ) {
|
||||
groupLayers.push_back(j);
|
||||
if ( (group > 0 && group2 == group) || ( group == 0 && j == i ) ) {
|
||||
groupLayers.push_back(j);
|
||||
|
||||
std::list<QgsRenderItem*> items = renderer->items();
|
||||
std::list<QgsRenderItem*> items = renderer->items();
|
||||
|
||||
if ( sectionTitle.length() == 0 ) {
|
||||
sectionTitle = layer2->name();
|
||||
}
|
||||
|
||||
if ( items.size() > sectionItemsCount ) {
|
||||
sectionItemsCount = items.size();
|
||||
itemHeights.resize(sectionItemsCount);
|
||||
itemLabels.resize(sectionItemsCount);
|
||||
}
|
||||
if ( sectionTitle.length() == 0 ) {
|
||||
sectionTitle = layer2->name();
|
||||
}
|
||||
|
||||
if ( items.size() > sectionItemsCount ) {
|
||||
sectionItemsCount = items.size();
|
||||
itemHeights.resize(sectionItemsCount);
|
||||
itemLabels.resize(sectionItemsCount);
|
||||
}
|
||||
|
||||
double widthScale = map->widthScale() * mComposition->scale();
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Render ) {
|
||||
widthScale *= mComposition->viewScale();
|
||||
}
|
||||
|
||||
double scale = map->symbolScale() * mComposition->scale();
|
||||
double widthScale = map->widthScale() * mComposition->scale();
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Render ) {
|
||||
widthScale *= mComposition->viewScale();
|
||||
}
|
||||
|
||||
double scale = map->symbolScale() * mComposition->scale();
|
||||
|
||||
int icnt = 0;
|
||||
for ( std::list<QgsRenderItem*>::iterator it = items.begin(); it != items.end(); ++it ) {
|
||||
|
||||
QgsRenderItem *ri = (*it);
|
||||
QgsSymbol *sym = ri->getSymbol();
|
||||
|
||||
// height
|
||||
if ( itemHeights[icnt] < mSymbolHeight ) { // init first
|
||||
itemHeights[icnt] = mSymbolHeight;
|
||||
}
|
||||
QPicture pic = sym->getPointSymbolAsPicture(0,widthScale);
|
||||
QRect br = pic.boundingRect();
|
||||
int icnt = 0;
|
||||
for ( std::list<QgsRenderItem*>::iterator it = items.begin(); it != items.end(); ++it ) {
|
||||
|
||||
QgsRenderItem *ri = (*it);
|
||||
QgsSymbol *sym = ri->getSymbol();
|
||||
|
||||
// height
|
||||
if ( itemHeights[icnt] < mSymbolHeight ) { // init first
|
||||
itemHeights[icnt] = mSymbolHeight;
|
||||
}
|
||||
QPicture pic = sym->getPointSymbolAsPicture(0,widthScale);
|
||||
QRect br = pic.boundingRect();
|
||||
|
||||
int h = (int) ( scale * br.height() );
|
||||
if ( h > itemHeights[icnt] ) {
|
||||
itemHeights[icnt] = h;
|
||||
}
|
||||
int h = (int) ( scale * br.height() );
|
||||
if ( h > itemHeights[icnt] ) {
|
||||
itemHeights[icnt] = h;
|
||||
}
|
||||
|
||||
if ( itemLabels[icnt].length() == 0 ) {
|
||||
if ( ri->label().length() > 0 ) {
|
||||
itemLabels[icnt] = ri->label();
|
||||
} else {
|
||||
itemLabels[icnt] = ri->value();
|
||||
}
|
||||
}
|
||||
|
||||
icnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( itemLabels[icnt].length() == 0 ) {
|
||||
if ( ri->label().length() > 0 ) {
|
||||
itemLabels[icnt] = ri->label();
|
||||
} else {
|
||||
itemLabels[icnt] = ri->value();
|
||||
}
|
||||
}
|
||||
|
||||
icnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//std::cout << "group size = " << groupLayers.size() << std::endl;
|
||||
//std::cout << "sectionItemsCount = " << sectionItemsCount << std::endl;
|
||||
|
||||
// Section title
|
||||
if ( sectionItemsCount > 1 ) {
|
||||
height += mSymbolSpace;
|
||||
// Section title
|
||||
if ( sectionItemsCount > 1 ) {
|
||||
height += mSymbolSpace;
|
||||
|
||||
x = (int) ( 2*mMargin );
|
||||
y = (int) ( height + sectionMetrics.height() );
|
||||
painter->setPen ( mPen );
|
||||
painter->setFont ( sectionFont );
|
||||
painter->drawText( x, y, sectionTitle );
|
||||
x = (int) ( 2*mMargin );
|
||||
y = (int) ( height + sectionMetrics.height() );
|
||||
painter->setPen ( mPen );
|
||||
painter->setFont ( sectionFont );
|
||||
painter->drawText( x, y, sectionTitle );
|
||||
|
||||
int w = 3*mMargin + sectionMetrics.width( sectionTitle );
|
||||
if ( w > width ) width = w;
|
||||
height += sectionMetrics.height();
|
||||
height += (int) (0.7*mSymbolSpace);
|
||||
}
|
||||
int w = 3*mMargin + sectionMetrics.width( sectionTitle );
|
||||
if ( w > width ) width = w;
|
||||
height += sectionMetrics.height();
|
||||
height += (int) (0.7*mSymbolSpace);
|
||||
}
|
||||
|
||||
// Draw all layers in group
|
||||
int groupStartHeight = height;
|
||||
for ( int j = groupLayers.size()-1; j >= 0; j-- ) {
|
||||
std::cout << "layer = " << groupLayers[j] << std::endl;
|
||||
// Draw all layers in group
|
||||
int groupStartHeight = height;
|
||||
for ( int j = groupLayers.size()-1; j >= 0; j-- ) {
|
||||
std::cout << "layer = " << groupLayers[j] << std::endl;
|
||||
|
||||
int localHeight = groupStartHeight;
|
||||
|
||||
layer = mMapCanvas->getZpos(groupLayers[j]);
|
||||
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
|
||||
QgsRenderer *renderer = vector->renderer();
|
||||
|
||||
// Symbol
|
||||
std::list<QgsRenderItem*> items = renderer->items();
|
||||
|
||||
int icnt = 0;
|
||||
for ( std::list<QgsRenderItem*>::iterator it = items.begin(); it != items.end(); ++it ) {
|
||||
localHeight += mSymbolSpace;
|
||||
int localHeight = groupStartHeight;
|
||||
|
||||
layer = mMapCanvas->getZpos(groupLayers[j]);
|
||||
QgsVectorLayer *vector = dynamic_cast <QgsVectorLayer*> (layer);
|
||||
QgsRenderer *renderer = vector->renderer();
|
||||
|
||||
// Symbol
|
||||
std::list<QgsRenderItem*> items = renderer->items();
|
||||
|
||||
int icnt = 0;
|
||||
for ( std::list<QgsRenderItem*>::iterator it = items.begin(); it != items.end(); ++it ) {
|
||||
localHeight += mSymbolSpace;
|
||||
|
||||
int symbolHeight = itemHeights[icnt];
|
||||
int symbolHeight = itemHeights[icnt];
|
||||
|
||||
QgsRenderItem *ri = (*it);
|
||||
QgsRenderItem *ri = (*it);
|
||||
|
||||
QgsSymbol *sym = ri->getSymbol();
|
||||
|
||||
QPen pen = sym->pen();
|
||||
double widthScale = map->widthScale() * mComposition->scale();
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Render ) {
|
||||
widthScale *= mComposition->viewScale();
|
||||
}
|
||||
pen.setWidth ( (int) ( widthScale * pen.width() ) );
|
||||
painter->setPen ( pen );
|
||||
painter->setBrush ( sym->brush() );
|
||||
|
||||
if ( vector->vectorType() == QGis::Point ) {
|
||||
double scale = map->symbolScale() * mComposition->scale();
|
||||
QgsSymbol *sym = ri->getSymbol();
|
||||
|
||||
QPen pen = sym->pen();
|
||||
double widthScale = map->widthScale() * mComposition->scale();
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Render ) {
|
||||
widthScale *= mComposition->viewScale();
|
||||
}
|
||||
pen.setWidth ( (int) ( widthScale * pen.width() ) );
|
||||
painter->setPen ( pen );
|
||||
painter->setBrush ( sym->brush() );
|
||||
|
||||
if ( vector->vectorType() == QGis::Point ) {
|
||||
double scale = map->symbolScale() * mComposition->scale();
|
||||
|
||||
// Get the picture of appropriate size directly from catalogue
|
||||
QPicture pic = sym->getPointSymbolAsPicture(0,widthScale);
|
||||
|
||||
QRect br = pic.boundingRect();
|
||||
|
||||
painter->save();
|
||||
painter->scale(scale,scale);
|
||||
painter->drawPicture ( static_cast<int>( (1.*mMargin+mSymbolWidth/2)/scale-br.x()-1.*br.width()/2),
|
||||
static_cast<int>( (1.*localHeight+symbolHeight/2)/scale-br.y()-1.*br.height()/2),
|
||||
pic );
|
||||
painter->restore();
|
||||
// Get the picture of appropriate size directly from catalogue
|
||||
QPicture pic = sym->getPointSymbolAsPicture(0,widthScale);
|
||||
|
||||
QRect br = pic.boundingRect();
|
||||
|
||||
painter->save();
|
||||
painter->scale(scale,scale);
|
||||
painter->drawPicture ( static_cast<int>( (1.*mMargin+mSymbolWidth/2)/scale-br.x()-1.*br.width()/2),
|
||||
static_cast<int>( (1.*localHeight+symbolHeight/2)/scale-br.y()-1.*br.height()/2),
|
||||
pic );
|
||||
painter->restore();
|
||||
|
||||
} else if ( vector->vectorType() == QGis::Line ) {
|
||||
painter->drawLine ( mMargin, localHeight+mSymbolHeight/2,
|
||||
mMargin+mSymbolWidth, localHeight+mSymbolHeight/2 );
|
||||
} else if ( vector->vectorType() == QGis::Polygon ) {
|
||||
painter->drawRect ( mMargin, localHeight, mSymbolWidth, mSymbolHeight );
|
||||
}
|
||||
} else if ( vector->vectorType() == QGis::Line ) {
|
||||
painter->drawLine ( mMargin, localHeight+mSymbolHeight/2,
|
||||
mMargin+mSymbolWidth, localHeight+mSymbolHeight/2 );
|
||||
} else if ( vector->vectorType() == QGis::Polygon ) {
|
||||
painter->drawRect ( mMargin, localHeight, mSymbolWidth, mSymbolHeight );
|
||||
}
|
||||
|
||||
// Label
|
||||
painter->setPen ( mPen );
|
||||
painter->setFont ( font );
|
||||
QString lab;
|
||||
if ( sectionItemsCount == 1 ) {
|
||||
lab = sectionTitle;
|
||||
} else {
|
||||
lab = itemLabels[icnt];
|
||||
}
|
||||
|
||||
// drawText (x, y w, h, ...) was cutting last letter (the box was tto small)
|
||||
QRect br = metrics.boundingRect ( lab );
|
||||
x = (int) ( 2*mMargin + mSymbolWidth );
|
||||
y = (int) ( localHeight + symbolHeight/2 + ( metrics.height()/2 - metrics.descent()) );
|
||||
// Label
|
||||
painter->setPen ( mPen );
|
||||
painter->setFont ( font );
|
||||
QString lab;
|
||||
if ( sectionItemsCount == 1 ) {
|
||||
lab = sectionTitle;
|
||||
} else {
|
||||
lab = itemLabels[icnt];
|
||||
}
|
||||
|
||||
// drawText (x, y w, h, ...) was cutting last letter (the box was tto small)
|
||||
QRect br = metrics.boundingRect ( lab );
|
||||
x = (int) ( 2*mMargin + mSymbolWidth );
|
||||
y = (int) ( localHeight + symbolHeight/2 + ( metrics.height()/2 - metrics.descent()) );
|
||||
|
||||
painter->drawText( x, y, lab );
|
||||
painter->drawText( x, y, lab );
|
||||
|
||||
int w = 3*mMargin + mSymbolWidth + metrics.width(lab);
|
||||
if ( w > width ) width = w;
|
||||
int w = 3*mMargin + mSymbolWidth + metrics.width(lab);
|
||||
if ( w > width ) width = w;
|
||||
|
||||
localHeight += symbolHeight;
|
||||
icnt++;
|
||||
}
|
||||
}
|
||||
/* add height of section items */
|
||||
height = groupStartHeight;
|
||||
for ( int j = 0; j < itemHeights.size(); j++ ) {
|
||||
height += mSymbolSpace + itemHeights[j];
|
||||
}
|
||||
if ( sectionItemsCount > 1 ) { // add more space to separate section from next item
|
||||
height += mSymbolSpace;
|
||||
}
|
||||
}
|
||||
localHeight += symbolHeight;
|
||||
icnt++;
|
||||
}
|
||||
}
|
||||
/* add height of section items */
|
||||
height = groupStartHeight;
|
||||
for ( int j = 0; j < itemHeights.size(); j++ ) {
|
||||
height += mSymbolSpace + itemHeights[j];
|
||||
}
|
||||
if ( sectionItemsCount > 1 ) { // add more space to separate section from next item
|
||||
height += mSymbolSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
height += mMargin;
|
||||
@ -459,8 +459,8 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
|
||||
QCanvasRectangle::setSize ( width, height );
|
||||
|
||||
if ( !p ) {
|
||||
delete painter;
|
||||
delete pixmap;
|
||||
delete painter;
|
||||
delete pixmap;
|
||||
}
|
||||
|
||||
return QRect ( 0, 0, width, height);
|
||||
@ -485,65 +485,65 @@ void QgsComposerVectorLegend::cache ( void )
|
||||
void QgsComposerVectorLegend::draw ( QPainter & painter )
|
||||
{
|
||||
std::cout << "draw mPlotStyle = " << plotStyle()
|
||||
<< " mPreviewMode = " << mPreviewMode << std::endl;
|
||||
<< " mPreviewMode = " << mPreviewMode << std::endl;
|
||||
|
||||
// Draw background rectangle
|
||||
|
||||
if ( mFrame ) {
|
||||
painter.setPen( QPen(QColor(0,0,0), 1) );
|
||||
painter.setBrush( QBrush( QColor(255,255,255), Qt::SolidPattern) );
|
||||
painter.setPen( QPen(QColor(0,0,0), 1) );
|
||||
painter.setBrush( QBrush( QColor(255,255,255), Qt::SolidPattern) );
|
||||
|
||||
painter.save();
|
||||
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.drawRect ( 0, 0, QCanvasRectangle::width()+1, QCanvasRectangle::height()+1 ); // is it right?
|
||||
painter.restore();
|
||||
painter.save();
|
||||
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
painter.drawRect ( 0, 0, QCanvasRectangle::width()+1, QCanvasRectangle::height()+1 ); // is it right?
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
if ( plotStyle() == QgsComposition::Preview && mPreviewMode == Cache ) { // Draw from cache
|
||||
std::cout << "use cache" << std::endl;
|
||||
|
||||
if ( !mCacheUpdated || mMapCanvas->layerCount() != mNumCachedLayers ) {
|
||||
cache();
|
||||
}
|
||||
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
|
||||
if ( !mCacheUpdated || mMapCanvas->layerCount() != mNumCachedLayers ) {
|
||||
cache();
|
||||
}
|
||||
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
std::cout << "translate: " << QCanvasRectangle::x() << ", " << QCanvasRectangle::y() << std::endl;
|
||||
painter.drawPixmap(0,0, mCachePixmap);
|
||||
painter.drawPixmap(0,0, mCachePixmap);
|
||||
|
||||
painter.restore();
|
||||
painter.restore();
|
||||
|
||||
} else if ( (plotStyle() == QgsComposition::Preview && mPreviewMode == Render) ||
|
||||
plotStyle() == QgsComposition::Print ||
|
||||
plotStyle() == QgsComposition::Postscript )
|
||||
plotStyle() == QgsComposition::Print ||
|
||||
plotStyle() == QgsComposition::Postscript )
|
||||
{
|
||||
std::cout << "render" << std::endl;
|
||||
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
render( &painter );
|
||||
painter.restore();
|
||||
|
||||
painter.save();
|
||||
painter.translate ( QCanvasRectangle::x(), QCanvasRectangle::y() );
|
||||
render( &painter );
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
// Show selected / Highlight
|
||||
std::cout << "mSelected = " << mSelected << std::endl;
|
||||
if ( mSelected && plotStyle() == QgsComposition::Preview ) {
|
||||
std::cout << "highlight" << std::endl;
|
||||
std::cout << "highlight" << std::endl;
|
||||
painter.setPen( mComposition->selectionPen() );
|
||||
painter.setBrush( mComposition->selectionBrush() );
|
||||
|
||||
int x = (int) QCanvasRectangle::x();
|
||||
int y = (int) QCanvasRectangle::y();
|
||||
int s = mComposition->selectionBoxSize();
|
||||
|
||||
int x = (int) QCanvasRectangle::x();
|
||||
int y = (int) QCanvasRectangle::y();
|
||||
int s = mComposition->selectionBoxSize();
|
||||
|
||||
painter.drawRect ( x, y, s, s );
|
||||
x += QCanvasRectangle::width();
|
||||
painter.drawRect ( x-s, y, s, s );
|
||||
y += QCanvasRectangle::height();
|
||||
painter.drawRect ( x-s, y-s, s, s );
|
||||
x -= QCanvasRectangle::width();
|
||||
painter.drawRect ( x, y-s, s, s );
|
||||
painter.drawRect ( x, y, s, s );
|
||||
x += QCanvasRectangle::width();
|
||||
painter.drawRect ( x-s, y, s, s );
|
||||
y += QCanvasRectangle::height();
|
||||
painter.drawRect ( x-s, y-s, s, s );
|
||||
x -= QCanvasRectangle::width();
|
||||
painter.drawRect ( x, y-s, s, s );
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,9 +554,9 @@ void QgsComposerVectorLegend::changeFont ( void )
|
||||
mFont = QFontDialog::getFont(&result, mFont, this );
|
||||
|
||||
if ( result ) {
|
||||
recalculate();
|
||||
QCanvasRectangle::update();
|
||||
QCanvasRectangle::canvas()->update();
|
||||
recalculate();
|
||||
QCanvasRectangle::update();
|
||||
QCanvasRectangle::canvas()->update();
|
||||
writeSettings();
|
||||
}
|
||||
}
|
||||
@ -654,18 +654,18 @@ void QgsComposerVectorLegend::setOptions ( void )
|
||||
mMapComboBox->insertItem ( "", 0 );
|
||||
mMaps.push_back ( 0 );
|
||||
for ( int i = 0; i < maps.size(); i++ ) {
|
||||
mMapComboBox->insertItem ( maps[i]->name(), i+1 );
|
||||
mMaps.push_back ( maps[i]->id() );
|
||||
mMapComboBox->insertItem ( maps[i]->name(), i+1 );
|
||||
mMaps.push_back ( maps[i]->id() );
|
||||
|
||||
if ( maps[i]->id() == mMap ) {
|
||||
found = true;
|
||||
mMapComboBox->setCurrentItem ( i+1 );
|
||||
}
|
||||
if ( maps[i]->id() == mMap ) {
|
||||
found = true;
|
||||
mMapComboBox->setCurrentItem ( i+1 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! found ) {
|
||||
mMap = 0;
|
||||
mMapComboBox->setCurrentItem ( 0 );
|
||||
mMap = 0;
|
||||
mMapComboBox->setCurrentItem ( 0 );
|
||||
}
|
||||
|
||||
mFrameCheckBox->setChecked ( mFrame );
|
||||
@ -674,31 +674,31 @@ void QgsComposerVectorLegend::setOptions ( void )
|
||||
mLayersListView->clear();
|
||||
|
||||
if ( mMap != 0 ) {
|
||||
QgsComposerMap *map = mComposition->map ( mMap );
|
||||
QgsComposerMap *map = mComposition->map ( mMap );
|
||||
|
||||
if ( map ) {
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
for ( int i = 0; i < nlayers; i++ ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
|
||||
if ( !layer->visible() ) continue;
|
||||
//if ( layer->type() != QgsMapLayer::VECTOR ) continue;
|
||||
if ( map ) {
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
for ( int i = 0; i < nlayers; i++ ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
|
||||
if ( !layer->visible() ) continue;
|
||||
//if ( layer->type() != QgsMapLayer::VECTOR ) continue;
|
||||
|
||||
QCheckListItem *li = new QCheckListItem ( mLayersListView, layer->name(), QCheckListItem::CheckBox );
|
||||
QCheckListItem *li = new QCheckListItem ( mLayersListView, layer->name(), QCheckListItem::CheckBox );
|
||||
|
||||
QString id = layer->getLayerID();
|
||||
li->setText(2, id );
|
||||
QString id = layer->getLayerID();
|
||||
li->setText(2, id );
|
||||
|
||||
li->setOn ( layerOn(id) );
|
||||
|
||||
int group = layerGroup(id);
|
||||
if ( group > 0 ) {
|
||||
li->setText(1, QString::number(group) );
|
||||
}
|
||||
li->setOn ( layerOn(id) );
|
||||
|
||||
int group = layerGroup(id);
|
||||
if ( group > 0 ) {
|
||||
li->setText(1, QString::number(group) );
|
||||
}
|
||||
|
||||
mLayersListView->insertItem ( li );
|
||||
}
|
||||
}
|
||||
mLayersListView->insertItem ( li );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mPreviewModeComboBox->setCurrentItem( mPreviewMode );
|
||||
@ -727,7 +727,7 @@ bool QgsComposerVectorLegend::layerOn ( QString id )
|
||||
std::map<QString,bool>::iterator it = mLayersOn.find(id);
|
||||
|
||||
if(it != mLayersOn.end() ) {
|
||||
return ( it->second );
|
||||
return ( it->second );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -738,9 +738,9 @@ void QgsComposerVectorLegend::setLayerOn ( QString id, bool on )
|
||||
std::map<QString,bool>::iterator it = mLayersOn.find(id);
|
||||
|
||||
if(it != mLayersOn.end() ) {
|
||||
it->second = on;
|
||||
it->second = on;
|
||||
} else {
|
||||
mLayersOn.insert(std::make_pair(id,on));
|
||||
mLayersOn.insert(std::make_pair(id,on));
|
||||
}
|
||||
}
|
||||
|
||||
@ -749,7 +749,7 @@ int QgsComposerVectorLegend::layerGroup ( QString id )
|
||||
std::map<QString,int>::iterator it = mLayersGroups.find(id);
|
||||
|
||||
if(it != mLayersGroups.end() ) {
|
||||
return ( it->second );
|
||||
return ( it->second );
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -760,9 +760,9 @@ void QgsComposerVectorLegend::setLayerGroup ( QString id, int group )
|
||||
std::map<QString,int>::iterator it = mLayersGroups.find(id);
|
||||
|
||||
if(it != mLayersGroups.end() ) {
|
||||
it->second = group;
|
||||
it->second = group;
|
||||
} else {
|
||||
mLayersGroups.insert(std::make_pair(id,group));
|
||||
mLayersGroups.insert(std::make_pair(id,group));
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,25 +793,25 @@ void QgsComposerVectorLegend::groupLayers ( void )
|
||||
QString id;
|
||||
while ( it.current() ) {
|
||||
if ( it.current()->isSelected() ) {
|
||||
std::cout << "selected: " << it.current()->text(0) << " " << it.current()->text(2) << std::endl;
|
||||
std::cout << "selected: " << it.current()->text(0) << " " << it.current()->text(2) << std::endl;
|
||||
|
||||
id = it.current()->text(2);
|
||||
setLayerGroup ( id, mNextLayerGroup );
|
||||
it.current()->setText(1,QString::number(mNextLayerGroup) );
|
||||
lastItem = it.current();
|
||||
count++;
|
||||
}
|
||||
++it;
|
||||
id = it.current()->text(2);
|
||||
setLayerGroup ( id, mNextLayerGroup );
|
||||
it.current()->setText(1,QString::number(mNextLayerGroup) );
|
||||
lastItem = it.current();
|
||||
count++;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
if ( count == 1 ) { // one item only
|
||||
setLayerGroup ( id, 0 );
|
||||
lastItem->setText(1,"" );
|
||||
lastItem->setText(1,"" );
|
||||
}
|
||||
|
||||
|
||||
std::cout << "Groups:" << std::endl;
|
||||
|
||||
for ( std::map<QString,int>::iterator it3 = mLayersGroups.begin(); it3 != mLayersGroups.end(); ++it3 ) {
|
||||
std::cout << "layer: " << it3->first << " group: " << it3->second << std::endl;
|
||||
std::cout << "layer: " << it3->first << " group: " << it3->second << std::endl;
|
||||
}
|
||||
|
||||
mNextLayerGroup++;
|
||||
@ -855,21 +855,21 @@ bool QgsComposerVectorLegend::writeSettings ( void )
|
||||
QgsProject::instance()->removeEntry ( "Compositions", path );
|
||||
|
||||
if ( mMap != 0 ) {
|
||||
QgsComposerMap *map = mComposition->map ( mMap );
|
||||
QgsComposerMap *map = mComposition->map ( mMap );
|
||||
|
||||
if ( map ) {
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
for ( int i = 0; i < nlayers; i++ ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
|
||||
if ( !layer->visible() ) continue;
|
||||
if ( map ) {
|
||||
int nlayers = mMapCanvas->layerCount();
|
||||
for ( int i = 0; i < nlayers; i++ ) {
|
||||
QgsMapLayer *layer = mMapCanvas->getZpos(i);
|
||||
|
||||
if ( !layer->visible() ) continue;
|
||||
|
||||
QString id = layer->getLayerID();
|
||||
QString id = layer->getLayerID();
|
||||
path.sprintf("/composition_%d/vectorlegend_%d/layers/layer_%s/", mComposition->id(), mId, id.ascii() );
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"on", layerOn(id) );
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"group", layerGroup(id) );
|
||||
}
|
||||
}
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"on", layerOn(id) );
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"group", layerGroup(id) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QgsProject::instance()->writeEntry( "Compositions", path+"previewmode", mPreviewMode );
|
||||
@ -905,17 +905,17 @@ bool QgsComposerVectorLegend::readSettings ( void )
|
||||
QStringList el = QgsProject::instance()->subkeyList ( "Compositions", path );
|
||||
|
||||
for ( QStringList::iterator it = el.begin(); it != el.end(); ++it ) {
|
||||
int idx = (*it).find('_');
|
||||
int idx = (*it).find('_');
|
||||
|
||||
QString id = (*it).right( (*it).length() - (idx+1) );
|
||||
|
||||
path.sprintf("/composition_%d/vectorlegend_%d/layers/layer_%s/", mComposition->id(), mId, id.ascii() );
|
||||
bool on = QgsProject::instance()->readBoolEntry("Compositions", path+"on", true, &ok);
|
||||
int group = QgsProject::instance()->readNumEntry("Compositions", path+"group", 0, &ok);
|
||||
setLayerOn ( id , on );
|
||||
setLayerGroup ( id, group );
|
||||
QString id = (*it).right( (*it).length() - (idx+1) );
|
||||
|
||||
path.sprintf("/composition_%d/vectorlegend_%d/layers/layer_%s/", mComposition->id(), mId, id.ascii() );
|
||||
bool on = QgsProject::instance()->readBoolEntry("Compositions", path+"on", true, &ok);
|
||||
int group = QgsProject::instance()->readNumEntry("Compositions", path+"group", 0, &ok);
|
||||
setLayerOn ( id , on );
|
||||
setLayerGroup ( id, group );
|
||||
|
||||
if ( group >= mNextLayerGroup ) mNextLayerGroup = group+1;
|
||||
if ( group >= mNextLayerGroup ) mNextLayerGroup = group+1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,12 +76,15 @@ class QgsRect;
|
||||
class QgsMapToPixel;
|
||||
class QgsComposition;
|
||||
class QgsComposerMap;
|
||||
class QgsComposerItem;
|
||||
|
||||
/** \class QgsComposerVectorLegend
|
||||
* \brief Object representing map window.
|
||||
*/
|
||||
// NOTE: QgsComposerVectorLegendBase must be first, otherwise does not compile
|
||||
class QgsComposerVectorLegend : public QgsComposerVectorLegendBase, public QCanvasRectangle, public QgsComposerItem
|
||||
class QgsComposerVectorLegend : public QgsComposerVectorLegendBase,
|
||||
public QCanvasRectangle,
|
||||
public QgsComposerItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,21 +15,23 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
#include <cassert>
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsspatialreferences.h"
|
||||
|
||||
QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceWKT, QString theDestWKT ) : QObject()
|
||||
QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceWKT, QString theDestWKT ) : QObject(),
|
||||
mSourceWKT(theSourceWKT), mDestWKT(theDestWKT)
|
||||
{
|
||||
mSourceWKT = theSourceWKT;
|
||||
mDestWKT = theDestWKT;
|
||||
// initialize the coordinate system data structures
|
||||
//XXX Who spells initialize initialise?
|
||||
//XXX A: Its the queen's english....
|
||||
//XXX : Long live the queen! Lets get on with the initialisation...
|
||||
initialise();
|
||||
}
|
||||
|
||||
|
||||
QgsCoordinateTransform::~QgsCoordinateTransform()
|
||||
{
|
||||
delete mSourceToDestXForm;
|
||||
delete mDestToSourceXForm;
|
||||
}
|
||||
|
||||
void QgsCoordinateTransform::setSourceWKT(QString theWKT)
|
||||
@ -45,62 +47,64 @@ void QgsCoordinateTransform::setDestWKT(QString theWKT)
|
||||
mDestWKT = theWKT;
|
||||
initialise();
|
||||
}
|
||||
|
||||
// XXX This whole function is full of multiple return statements!!!
|
||||
void QgsCoordinateTransform::initialise()
|
||||
{
|
||||
mInitialisedFlag=false; //guilty until proven innocent...
|
||||
//default to geo / wgs84 for now .... later we will make this user configurable
|
||||
QString myGeoWKT = "GEOGCS[\"WGS 84\", "
|
||||
" DATUM[\"WGS_1984\", "
|
||||
" SPHEROID[\"WGS 84\",6378137,298.257223563, "
|
||||
" AUTHORITY[\"EPSG\",7030]], "
|
||||
" TOWGS84[0,0,0,0,0,0,0], "
|
||||
" AUTHORITY[\"EPSG\",6326]], "
|
||||
" PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",8901]], "
|
||||
" UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",9108]], "
|
||||
" AXIS[\"Lat\",NORTH], "
|
||||
" AXIS[\"Long\",EAST], "
|
||||
" AUTHORITY[\"EPSG\",4326]]";
|
||||
mInitialisedFlag=false; //guilty until proven innocent...
|
||||
// Default to geo / wgs84 for now ....
|
||||
// Later we will make this user configurable
|
||||
// SRID 4326 is geographic wgs84 - use the SRS singleton to fetch
|
||||
// the WKT for the coordinate system
|
||||
QString defaultWkt = QgsSpatialReferences::instance()->getSrsBySrid("4326")->srText();
|
||||
//default input projection to geo wgs84
|
||||
// XXX Warning - multiple return paths in this block!!
|
||||
if (mSourceWKT.isEmpty())
|
||||
{
|
||||
mSourceWKT = myGeoWKT;
|
||||
//mSourceWKT = defaultWkt;
|
||||
// Pass through with no projection since we have no idea what the layer
|
||||
// coordinates are and projecting them may not be appropriate
|
||||
mShortCircuit = true;
|
||||
return;
|
||||
}
|
||||
//but default output projection to be the same as input proj
|
||||
//whatever that may be...
|
||||
|
||||
if (mDestWKT.isEmpty())
|
||||
{
|
||||
//No destination projection is set so we set the default output projection to
|
||||
//be the same as input proj. This only happens on the first layer loaded
|
||||
//whatever that may be...
|
||||
mDestWKT = mSourceWKT;
|
||||
}
|
||||
|
||||
|
||||
if (mSourceWKT == mDestWKT)
|
||||
{
|
||||
// If the source and destination projection are the same, set the short
|
||||
// circuit flag (no transform takes place)
|
||||
mShortCircuit=true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Transform must take place
|
||||
mShortCircuit=false;
|
||||
}
|
||||
|
||||
OGRSpatialReference myInputSpatialRefSys, myOutputSpatialRefSys;
|
||||
|
||||
//this is really ugly but we need to get a QString to a char**
|
||||
char *mySourceCharArrayPointer = (char *)mSourceWKT.ascii();
|
||||
char *myDestCharArrayPointer = (char *)mDestWKT.ascii();
|
||||
|
||||
/* Here are the possible OGR error codes :
|
||||
typedef int OGRErr;
|
||||
|
||||
#define OGRERR_NONE 0
|
||||
#define OGRERR_NOT_ENOUGH_DATA 1 --> not enough data to deserialize
|
||||
#define OGRERR_NOT_ENOUGH_MEMORY 2
|
||||
#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
|
||||
#define OGRERR_UNSUPPORTED_OPERATION 4
|
||||
#define OGRERR_CORRUPT_DATA 5
|
||||
#define OGRERR_FAILURE 6
|
||||
#define OGRERR_UNSUPPORTED_SRS 7 */
|
||||
|
||||
OGRErr myInputResult = myInputSpatialRefSys.importFromWkt( & mySourceCharArrayPointer );
|
||||
/* Here are the possible OGR error codes :
|
||||
typedef int OGRErr;
|
||||
|
||||
#define OGRERR_NONE 0
|
||||
#define OGRERR_NOT_ENOUGH_DATA 1 --> not enough data to deserialize
|
||||
#define OGRERR_NOT_ENOUGH_MEMORY 2
|
||||
#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
|
||||
#define OGRERR_UNSUPPORTED_OPERATION 4
|
||||
#define OGRERR_CORRUPT_DATA 5
|
||||
#define OGRERR_FAILURE 6
|
||||
#define OGRERR_UNSUPPORTED_SRS 7 */
|
||||
|
||||
OGRErr myInputResult = mSourceOgrSpatialRef.importFromWkt( & mySourceCharArrayPointer );
|
||||
if (myInputResult != OGRERR_NONE)
|
||||
{
|
||||
std::cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"<< std::endl;
|
||||
@ -109,8 +113,10 @@ void QgsCoordinateTransform::initialise()
|
||||
std::cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << std::endl;
|
||||
return;
|
||||
}
|
||||
// always morph from esri as it doesn't hurt anything
|
||||
mSourceOgrSpatialRef.morphFromESRI();
|
||||
|
||||
OGRErr myOutputResult = myOutputSpatialRefSys.importFromWkt( & myDestCharArrayPointer );
|
||||
OGRErr myOutputResult = mDestOgrSpatialRef.importFromWkt( & myDestCharArrayPointer );
|
||||
if (myOutputResult != OGRERR_NONE)
|
||||
{
|
||||
std::cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"<< std::endl;
|
||||
@ -119,13 +125,27 @@ void QgsCoordinateTransform::initialise()
|
||||
std::cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
mSourceToDestXForm = OGRCreateCoordinateTransformation( &myInputSpatialRefSys, &myOutputSpatialRefSys );
|
||||
mDestToSourceXForm = OGRCreateCoordinateTransformation( &myOutputSpatialRefSys, &myInputSpatialRefSys );
|
||||
if ( ! mSourceToDestXForm || ! mDestToSourceXForm)
|
||||
// always morph from esri as it doesn't hurt anything
|
||||
mDestOgrSpatialRef.morphFromESRI();
|
||||
#ifdef QGISDEBUG
|
||||
OGRErr sourceValid = mSourceOgrSpatialRef.Validate();
|
||||
OGRErr destValid = mDestOgrSpatialRef.Validate();
|
||||
#endif
|
||||
// One last test to see if they SRS are the same, despite slightly different
|
||||
// WKT specs
|
||||
// XXX This doesn't seem to work very well -- which means we are going to be
|
||||
// XXX attempting to transform coordinates that are in the same SRS.
|
||||
// XXX What to do? What to do?....
|
||||
if( mSourceOgrSpatialRef.IsSame(&mDestOgrSpatialRef))
|
||||
{
|
||||
mShortCircuit = true;
|
||||
}
|
||||
// Validate the spaital reference systems
|
||||
if ( (mSourceOgrSpatialRef.Validate() != OGRERR_NONE) || (mDestOgrSpatialRef.Validate() != OGRERR_NONE))
|
||||
{
|
||||
std::cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"<< std::endl;
|
||||
std::cout << "The OGR Coordinate transformation for this layer could *** NOT *** be set " << std::endl;
|
||||
std::cout << "The OGR Coordinate transformation for this layer could *** NOT *** be set "
|
||||
<< std::endl;
|
||||
std::cout << "INPUT: " << std::endl << mSourceWKT << std::endl;
|
||||
std::cout << "OUTPUT: " << std::endl << mDestWKT << std::endl;
|
||||
std::cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << std::endl;
|
||||
@ -134,23 +154,181 @@ void QgsCoordinateTransform::initialise()
|
||||
else
|
||||
{
|
||||
mInitialisedFlag = true;
|
||||
// Create the coordinate transform objects so we don't have to
|
||||
// create them each pass through when projecting points
|
||||
forwardTransform = OGRCreateCoordinateTransformation( &mSourceOgrSpatialRef, &mDestOgrSpatialRef);
|
||||
inverseTransform = OGRCreateCoordinateTransformation( &mDestOgrSpatialRef, &mSourceOgrSpatialRef );
|
||||
|
||||
|
||||
std::cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"<< std::endl;
|
||||
std::cout << "The OGR Coordinate transformation for this layer was set to" << std::endl;
|
||||
std::cout << "INPUT: " << std::endl << mSourceWKT << std::endl;
|
||||
char *proj4src;
|
||||
myInputSpatialRefSys.exportToProj4(&proj4src);
|
||||
std::cout << "PROJ4: " << std::endl << proj4src << std::endl;
|
||||
// std::cout << "PROJ4: " << std::endl << mProj4SrcParms << std::endl;
|
||||
std::cout << "OUTPUT: " << std::endl << mDestWKT << std::endl;
|
||||
char *proj4dest;
|
||||
myOutputSpatialRefSys.exportToProj4(&proj4dest);
|
||||
std::cout << "PROJ4: " << std::endl << proj4dest << std::endl;
|
||||
// std::cout << "PROJ4: " << std::endl << mProj4DestParms << std::endl;
|
||||
std::cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << std::endl;
|
||||
}
|
||||
//just a test to see if inverse
|
||||
//inverseTransform(10.0,10.0);
|
||||
// Deactivate GDAL error messages.
|
||||
//CPLSetErrorHandler( errorHandler );
|
||||
|
||||
// Guess if the source o dest CS is in degrees.
|
||||
//Searchf for this phrase in each wkt: "unit[\"degree\""
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// TRANSFORMERS BELOW THIS POINT .........
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
QgsPoint QgsCoordinateTransform::transform(const QgsPoint thePoint,TransformDirection direction) const
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return thePoint;
|
||||
// transform x
|
||||
double x = thePoint.x();
|
||||
double y = thePoint.y();
|
||||
double z = 0.0;
|
||||
try
|
||||
{
|
||||
|
||||
transformCoords(1, x, y, z, direction );
|
||||
}
|
||||
catch(QgsCsException &cse)
|
||||
{
|
||||
//something bad happened....
|
||||
// rethrow the exception
|
||||
throw cse;
|
||||
}
|
||||
#ifdef QGISDEBUG
|
||||
//std::cout << "Point projection...X : " << thePoint.x() << "-->" << x << ", Y: " << thePoint.y() << " -->" << y << std::endl;
|
||||
#endif
|
||||
return QgsPoint(x, y);
|
||||
}
|
||||
|
||||
|
||||
QgsPoint QgsCoordinateTransform::transform(const double theX, const double theY=0,TransformDirection direction) const
|
||||
{
|
||||
transform(QgsPoint(theX, theY), direction);
|
||||
}
|
||||
|
||||
QgsRect QgsCoordinateTransform::transform(const QgsRect theRect,TransformDirection direction) const
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return theRect;
|
||||
// transform x
|
||||
double x1 = theRect.xMin();
|
||||
double y1 = theRect.yMin();
|
||||
double x2 = theRect.xMax();
|
||||
double y2 = theRect.yMax();
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
|
||||
std::cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"<< std::endl;
|
||||
std::cout << "Rect projection..." << std::endl;
|
||||
std::cout << "INPUT: " << std::endl << mSourceWKT << std::endl;
|
||||
//std::cout << "PROJ4: " << std::endl << mProj4SrcParms << std::endl;
|
||||
std::cout << "OUTPUT: " << std::endl << mDestWKT << std::endl;
|
||||
//std::cout << "PROJ4: " << std::endl << mProj4DestParms << std::endl;
|
||||
std::cout << "INPUT RECT: " << std::endl << x1 << "," << y1 << ":" << x2 << "," << y2 << std::endl;
|
||||
std::cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << std::endl;
|
||||
#endif
|
||||
// Number of points to reproject------+
|
||||
// |
|
||||
// V
|
||||
try{
|
||||
double z = 0.0;
|
||||
transformCoords(1, x1, y1, z, direction);
|
||||
transformCoords(1, x2, y2, z, direction);
|
||||
|
||||
}
|
||||
catch(QgsCsException &cse)
|
||||
{
|
||||
// rethrow the exception
|
||||
throw cse;
|
||||
}
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Rect projection..."
|
||||
<< "Xmin : "
|
||||
<< theRect.xMin()
|
||||
<< "-->" << x1
|
||||
<< ", Ymin: "
|
||||
<< theRect.yMin()
|
||||
<< " -->" << y1
|
||||
<< "Xmax : "
|
||||
<< theRect.xMax()
|
||||
<< "-->" << x2
|
||||
<< ", Ymax: "
|
||||
<< theRect.yMax()
|
||||
<< " -->" << y2
|
||||
<< std::endl;
|
||||
#endif
|
||||
return QgsRect(x1, y1, x2 , y2);
|
||||
}
|
||||
|
||||
void QgsCoordinateTransform::transformCoords( const int& numPoints, double& x, double& y, double& z,TransformDirection direction) const
|
||||
{
|
||||
// use OGR to do the transform
|
||||
if(direction == INVERSE)
|
||||
{
|
||||
// transform from destination (map canvas/project) to layer CS
|
||||
inverseTransform->Transform(numPoints, &x, &y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// transform from source layer CS to destination (map canvas/project)
|
||||
forwardTransform->Transform(numPoints, &x, &y);
|
||||
|
||||
}
|
||||
}
|
||||
/* XXX THIS IS BASED ON DIRECT USE OF PROJ4
|
||||
* XXX preserved for future use if we need it
|
||||
*/
|
||||
/*
|
||||
void QgsCoordinateTransform::transformCoords( const int& numPoints, double& x, double& y, double& z,TransformDirection direction) const
|
||||
{
|
||||
assert(mProj4DestParms.length() > 0);
|
||||
assert(mProj4SrcParms.length() > 0);
|
||||
// use proj4 to do the transform
|
||||
QString dir;
|
||||
// if the source/destination projection is lat/long, convert the points to radians
|
||||
// prior to transforming
|
||||
if((pj_is_latlong(mDestinationProjection) && (direction == INVERSE))
|
||||
|| (pj_is_latlong(mSourceProjection) && (direction == FORWARD)))
|
||||
{
|
||||
x *= DEG_TO_RAD;
|
||||
y *= DEG_TO_RAD;
|
||||
z *= DEG_TO_RAD;
|
||||
|
||||
}
|
||||
int projResult;
|
||||
if(direction == INVERSE)
|
||||
{
|
||||
// std::cout << "!!!! INVERSE TRANSFORM !!!!" << std::endl;
|
||||
projResult = pj_transform(mDestinationProjection, mSourceProjection , numPoints, 0, &x, &y, &z);
|
||||
dir = "inverse";
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout << "!!!! FORWARD TRANSFORM !!!!" << std::endl;
|
||||
projResult = pj_transform(mSourceProjection, mDestinationProjection, numPoints, 0, &x, &y, &z);
|
||||
dir = "forward";
|
||||
}
|
||||
|
||||
if (projResult != 0)
|
||||
{
|
||||
//something bad happened....
|
||||
QString msg;
|
||||
QTextOStream pjErr(&msg);
|
||||
|
||||
pjErr << tr("Failed") << " " << dir << " " << tr("transform of") << x << ", " << y
|
||||
<< pj_strerrno(projResult) << "\n";
|
||||
throw QgsCsException(msg);
|
||||
}
|
||||
// if the result is lat/long, convert the results from radians back
|
||||
// to degrees
|
||||
if((pj_is_latlong(mDestinationProjection) && (direction == FORWARD))
|
||||
|| (pj_is_latlong(mSourceProjection) && (direction == INVERSE)))
|
||||
{
|
||||
x *= RAD_TO_DEG;
|
||||
y *= RAD_TO_DEG;
|
||||
z *= RAD_TO_DEG;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -34,85 +34,110 @@
|
||||
//non qt includes
|
||||
#include <iostream>
|
||||
|
||||
extern "C"{
|
||||
#include <proj_api.h>
|
||||
}
|
||||
class QString;
|
||||
|
||||
/*! \class QgsCoordinateTransform
|
||||
* \brief Class for doing transforms between two map coordinate systems.
|
||||
*
|
||||
* This class can convert map coordinates to a different spatial reference system.
|
||||
* It is normally associated with a map layer and is used to transform between the
|
||||
* layer's coordinate system and the coordinate system of the map canvas, although
|
||||
* it can be used in a more general sense to transform coordinates.
|
||||
*
|
||||
* All references to source and destination coordinate systems refer to
|
||||
* layer and map canvas respectively. All operations are from the perspective
|
||||
* of the layer. For example, a forward transformation transforms coordinates from the
|
||||
* layers coordinate system to the map canvas.
|
||||
*/
|
||||
class QgsCoordinateTransform: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*!
|
||||
* Constructs a QgsCoordinateTransform using the Well Known Text representation
|
||||
* of the layer and map canvas coordinate systems
|
||||
* @param theSourceWKT WKT of the layer's coordinate system
|
||||
* @param theSourceWKT WKT of the map canvas coordinate system
|
||||
*/
|
||||
QgsCoordinateTransform(QString theSourceWKT, QString theDestWKT );
|
||||
//! destructor
|
||||
~QgsCoordinateTransform();
|
||||
//! Enum used to indicate the direction (forward or inverse) of the transform
|
||||
enum TransformDirection{
|
||||
FORWARD,
|
||||
INVERSE
|
||||
};
|
||||
|
||||
/*!
|
||||
* Set the source (layer) WKT
|
||||
* @param theWKT WKT representation of the layer's coordinate system
|
||||
*/
|
||||
void setSourceWKT(QString theWKT);
|
||||
/*!
|
||||
* Get the WKT representation of the layer's coordinate system
|
||||
* @return WKT of the layer's coordinate system
|
||||
*/
|
||||
QString sourceWKT() const {return mSourceWKT;};
|
||||
/*!
|
||||
* Get the WKT representation of the map canvas coordinate system
|
||||
* @return WKT of the map canvas coordinate system
|
||||
*/
|
||||
QString destWKT() const {return mDestWKT;};
|
||||
/*!
|
||||
* Flag to indicate whether the coordinate systems have been initialised
|
||||
* @return true if initialised, otherwise false
|
||||
*/
|
||||
bool isInitialised() {return mInitialisedFlag;};
|
||||
|
||||
|
||||
/*! Transform the point from Source Coordinate System to Destination Coordinate System
|
||||
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
|
||||
* otherwise points are transformed from map canvas CS to layerCS.
|
||||
* @param p Point to transform
|
||||
* @param direction TransformDirection (defaults to FORWARD)
|
||||
* @return QgsPoint in Destination Coordinate System
|
||||
*/
|
||||
QgsPoint transform(QgsPoint p);
|
||||
*/
|
||||
QgsPoint transform(const QgsPoint p,TransformDirection direction=FORWARD) const;
|
||||
|
||||
/*! Transform the point specified by x,y from Source Coordinate System to Destination Coordinate System
|
||||
* @param x x cordinate o point to transform
|
||||
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
|
||||
* otherwise points are transformed from map canvas CS to layerCS.
|
||||
* @param x x cordinate of point to transform
|
||||
* @param y y coordinate of point to transform
|
||||
* @param direction TransformDirection (defaults to FORWARD)
|
||||
* @return QgsPoint in Destination Coordinate System
|
||||
*/
|
||||
QgsPoint transform(double x, double y);
|
||||
*/
|
||||
QgsPoint transform(double x, double y,TransformDirection direction=FORWARD) const ;
|
||||
|
||||
/*! Transform a QgsRect to the dest Coordinate system
|
||||
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
|
||||
* otherwise points are transformed from map canvas CS to layerCS.
|
||||
* @param QgsRect rect to transform
|
||||
* @param direction TransformDirection (defaults to FORWARD)
|
||||
* @return QgsRect in Destination Coordinate System
|
||||
*/
|
||||
QgsRect transform(QgsRect theRect);
|
||||
*/
|
||||
QgsRect transform(const QgsRect theRect,TransformDirection direction=FORWARD) const;
|
||||
|
||||
/*! Transform a QgsRect pointer to the dest Coordinate system
|
||||
* @param QgsRect * rect to transform
|
||||
/*! Transform an array of coordinates to a different Coordinate System
|
||||
* If the direction is FORWARD then coordinates are transformed from layer CS --> map canvas CS,
|
||||
* otherwise points are transformed from map canvas CS to layerCS.
|
||||
* @param x x cordinate of point to transform
|
||||
* @param y y coordinate of point to transform
|
||||
* @param direction TransformDirection (defaults to FORWARD)
|
||||
* @return QgsRect in Destination Coordinate System
|
||||
*/
|
||||
QgsRect transform(QgsRect * theRect);
|
||||
|
||||
/*! Inverse Transform the point from Dest Coordinate System to Source Coordinate System
|
||||
* @param p Point to transform (in destination coord system)
|
||||
* @return QgsPoint in Source Coordinate System
|
||||
*/
|
||||
QgsPoint inverseTransform(QgsPoint p);
|
||||
|
||||
/*! Inverse Transform the point specified by x,y from Dest Coordinate System to Source Coordinate System
|
||||
* @param x x cordinate of point to transform (in dest coord sys)
|
||||
* @param y y coordinate of point to transform (in dest coord sys)
|
||||
* @return QgsPoint in Source Coordinate System
|
||||
*/
|
||||
QgsPoint inverseTransform(double x, double y);
|
||||
*/
|
||||
void transformCoords( const int &numPoint, double &x, double &y, double &z,TransformDirection direction=FORWARD) const;
|
||||
|
||||
/*! Inverse Transform a QgsRect to the source Coordinate system
|
||||
* @param QgsRect rect to transform (in dest coord sys)
|
||||
* @return QgsRect in Source Coordinate System
|
||||
*/
|
||||
QgsRect inverseTransform(QgsRect theRect);
|
||||
|
||||
|
||||
/*! Inverse Transform a QgsRect pointer to the source Coordinate system
|
||||
* @param QgsRect * rect to transform (in dest coord sys)
|
||||
* @return QgsRect in Source Coordinate System
|
||||
*/
|
||||
QgsRect inverseTransform(QgsRect * theRect);
|
||||
|
||||
|
||||
QString showParameters();
|
||||
|
||||
//! Accessor and mutator for source WKT
|
||||
void setSourceWKT(QString theWKT);
|
||||
QString sourceWKT() const {return mSourceWKT;};
|
||||
//! Accessor for dest WKT
|
||||
QString destWKT() const {return mDestWKT;};
|
||||
//! Accessor for whether this transoform is properly initialised
|
||||
bool isInitialised() {return mInitialisedFlag;};
|
||||
public slots:
|
||||
/** mutator for dest WKT - slot will usually be fired if proj props change and
|
||||
user selects a different coordinate system */
|
||||
/*!
|
||||
* Mutator for dest WKT - This slot will usually be called if the
|
||||
* project properties change and a different coordinate system is
|
||||
* selected.
|
||||
* @param WKT of the destination coordinate system
|
||||
*/
|
||||
void setDestWKT(QString theWKT);
|
||||
|
||||
private:
|
||||
@ -120,304 +145,42 @@ class QgsCoordinateTransform: public QObject
|
||||
void initialise();
|
||||
//! flag to show whether the transform is properly initialised or not
|
||||
bool mInitialisedFlag;
|
||||
/** Used for forward transform */
|
||||
OGRCoordinateTransformation * mSourceToDestXForm;
|
||||
/** Used for reverse transform */
|
||||
OGRCoordinateTransformation * mDestToSourceXForm;
|
||||
/** Transform definitionsin WKT format */
|
||||
QString mSourceWKT,mDestWKT;
|
||||
/** Dunno if we need this - XXXXX Delete if unused */
|
||||
/*!
|
||||
* WKT of the source (layer) coordinate system
|
||||
*/
|
||||
QString mSourceWKT;
|
||||
/*!
|
||||
* WKT of the destination (map canvas) coordinate system
|
||||
*/
|
||||
QString mDestWKT;
|
||||
/** Dunno if we need this - XXX Delete if unused */
|
||||
bool mInputIsDegrees;
|
||||
//set to true if src cs == dest cs
|
||||
/*!
|
||||
* Flag to indicate that the source and destination coordinate systems are
|
||||
* equal and not transformation needs to be done
|
||||
*/
|
||||
bool mShortCircuit;
|
||||
OGRSpatialReference mSourceOgrSpatialRef;
|
||||
OGRSpatialReference mDestOgrSpatialRef;
|
||||
OGRCoordinateTransformation *forwardTransform;
|
||||
OGRCoordinateTransformation *inverseTransform;
|
||||
/*!
|
||||
* Proj4 parameters for the source (layer) coordinate system
|
||||
*/
|
||||
QString mProj4SrcParms;
|
||||
/*!
|
||||
* Proj4 parameters for the destination (map canvas) coordinate system
|
||||
*/
|
||||
QString mProj4DestParms;
|
||||
/*!
|
||||
* Proj4 data structure of the source projection (layer coordinate system)
|
||||
*/
|
||||
projPJ mSourceProjection;
|
||||
/*!
|
||||
* Proj4 data structure of the destination projection (map canvas coordinate system)
|
||||
*/
|
||||
projPJ mDestinationProjection;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Inlined method implementations for best performance
|
||||
//--------------------------------------------------------
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
// --------------- FORWARD PROJECTIONS ------------------------------
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
inline QgsPoint QgsCoordinateTransform::transform(QgsPoint thePoint)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return thePoint;
|
||||
// transform x
|
||||
double x = thePoint.x();
|
||||
double y = thePoint.y();
|
||||
// Number of points to reproject------+
|
||||
// |
|
||||
// V
|
||||
if ( ! mSourceToDestXForm->Transform( 1, &x, &y ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
//std::cout << "Point projection...X : " << thePoint.x() << "-->" << x << ", Y: " << thePoint.y() << " -->" << y << std::endl;
|
||||
#endif
|
||||
return QgsPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
inline QgsRect QgsCoordinateTransform::transform(QgsRect theRect)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return theRect;
|
||||
// transform x
|
||||
double x1 = theRect.xMin();
|
||||
double y1 = theRect.yMin();
|
||||
double x2 = theRect.xMax();
|
||||
double y2 = theRect.yMax();
|
||||
// Number of points to reproject------+
|
||||
// |
|
||||
// V
|
||||
if ( ! mSourceToDestXForm->Transform( 1, &x1, &y1 ) || ! mSourceToDestXForm->Transform( 1, &x2, &y2 ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Rect projection..."
|
||||
<< "Xmin : "
|
||||
<< theRect.xMin()
|
||||
<< "-->" << x1
|
||||
<< ", Ymin: "
|
||||
<< theRect.yMin()
|
||||
<< " -->" << y1
|
||||
<< "Xmax : "
|
||||
<< theRect.xMax()
|
||||
<< "-->" << x2
|
||||
<< ", Ymax: "
|
||||
<< theRect.yMax()
|
||||
<< " -->" << y2
|
||||
<< std::endl;
|
||||
#endif
|
||||
return QgsRect(x1, y1, x2 , y2);
|
||||
}
|
||||
}
|
||||
|
||||
inline QgsRect QgsCoordinateTransform::transform(QgsRect * theRect)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return QgsRect(theRect->xMin(),theRect->yMin(),theRect->xMax(),theRect->yMax());
|
||||
// transform x
|
||||
double x1 = theRect->xMin();
|
||||
double y1 = theRect->yMin();
|
||||
double x2 = theRect->xMax();
|
||||
double y2 = theRect->yMax();
|
||||
// Number of points to reproject------+
|
||||
// |
|
||||
// V
|
||||
if ( ! mSourceToDestXForm->Transform( 1, &x1, &y1 ) || ! mSourceToDestXForm->Transform( 1, &x2, &y2 ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Rect projection..."
|
||||
<< "Xmin : "
|
||||
<< theRect->xMin()
|
||||
<< "-->" << x1
|
||||
<< ", Ymin: "
|
||||
<< theRect->yMin()
|
||||
<< " -->" << y1
|
||||
<< "Xmax : "
|
||||
<< theRect->xMax()
|
||||
<< "-->" << x2
|
||||
<< ", Ymax: "
|
||||
<< theRect->yMax()
|
||||
<< " -->" << y2
|
||||
<< std::endl;
|
||||
#endif
|
||||
return QgsRect(x1, y1, x2 , y2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline QgsPoint QgsCoordinateTransform::transform(double theX, double theY)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return QgsPoint(theX,theY);
|
||||
// transform x
|
||||
double x = theX;
|
||||
double y = theY;
|
||||
if ( ! mSourceToDestXForm->Transform( 1, &x, &y ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
//std::cout << "Point projection...X : " << theX << "-->" << x << ", Y: " << theY << " -->" << y << std::endl;
|
||||
#endif
|
||||
return QgsPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
// --------------- INVERSE PROJECTIONS ------------------------------
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
inline QgsPoint QgsCoordinateTransform::inverseTransform(QgsPoint thePoint)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return thePoint;
|
||||
// transform x
|
||||
double x = thePoint.x();
|
||||
double y = thePoint.y();
|
||||
// Number of points to reproject------+
|
||||
// |
|
||||
// V
|
||||
if ( ! mDestToSourceXForm->Transform( 1, &x, &y ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate inverse transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
//std::cout << "Point inverse projection...X : " << thePoint.x() << "-->" << x << ", Y: " << thePoint.y() << " -->" << y << std::endl;
|
||||
#endif
|
||||
return QgsPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
inline QgsRect QgsCoordinateTransform::inverseTransform(QgsRect theRect)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return theRect;
|
||||
// transform x
|
||||
double x1 = theRect.xMin();
|
||||
double y1 = theRect.yMin();
|
||||
double x2 = theRect.xMax();
|
||||
double y2 = theRect.yMax();
|
||||
#ifdef QGISDEBUG
|
||||
|
||||
std::cout << "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"<< std::endl;
|
||||
std::cout << "Rect inverse projection..." << std::endl;
|
||||
std::cout << "INPUT: " << std::endl << mSourceWKT << std::endl;
|
||||
// show proj parms too
|
||||
OGRSpatialReference sr(mSourceWKT);
|
||||
char *proj4src;
|
||||
sr.exportToProj4(&proj4src);
|
||||
std::cout << "PROJ4: " << std::endl << proj4src << std::endl;
|
||||
std::cout << "OUTPUT: " << std::endl << mDestWKT << std::endl;
|
||||
char *proj4out;
|
||||
char *pWkt = (char *)mDestWKT.ascii();
|
||||
sr.importFromWkt(&pWkt);
|
||||
sr.exportToProj4(&proj4src);
|
||||
std::cout << "PROJ4: " << std::endl << proj4src << std::endl;
|
||||
|
||||
std::cout << "INPUT RECT: " << std::endl << x1 << "," << y1 << ":" << x2 << "," << y2 << std::endl;
|
||||
std::cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << std::endl;
|
||||
#endif
|
||||
|
||||
//CPLPushErrorHandler( CPLQuietErrorHandler );
|
||||
// Number of points to reproject---------------+
|
||||
// |
|
||||
// V
|
||||
int myResult1 = mDestToSourceXForm->Transform( 1, &x1, &y1 );
|
||||
//int myResult2 = mDestToSourceXForm->Transform( 1, &x2, &y2 );
|
||||
//CPLPopErrorHandler();
|
||||
|
||||
if ( ! myResult1) // || ! myResult2 )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate inverse transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Xmin : "
|
||||
<< theRect.xMin()
|
||||
<< "-->" << x1
|
||||
<< ", Ymin: "
|
||||
<< theRect.yMin()
|
||||
<< " -->" << y1
|
||||
<< "Xmax : "
|
||||
<< theRect.xMax()
|
||||
<< "-->" << x2
|
||||
<< ", Ymax: "
|
||||
<< theRect.yMax()
|
||||
<< " -->" << y2
|
||||
<< std::endl;
|
||||
#endif
|
||||
return QgsRect(x1, y1, x2 , y2);
|
||||
}
|
||||
}
|
||||
|
||||
inline QgsRect QgsCoordinateTransform::inverseTransform(QgsRect * theRect)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return QgsRect(theRect->xMin(),theRect->yMin(),theRect->xMax(),theRect->yMax());
|
||||
// transform x
|
||||
double x1 = theRect->xMin();
|
||||
double y1 = theRect->yMin();
|
||||
double x2 = theRect->xMax();
|
||||
double y2 = theRect->yMax();
|
||||
// Number of points to reproject------+
|
||||
// |
|
||||
// V
|
||||
if ( ! mDestToSourceXForm->Transform( 1, &x1, &y1 ) || ! mDestToSourceXForm->Transform( 1, &x2, &y2 ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Inverse Coordinate transform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Rect pointer inverse projection..."
|
||||
<< "Xmin : "
|
||||
<< theRect->xMin()
|
||||
<< "-->" << x1
|
||||
<< ", Ymin: "
|
||||
<< theRect->yMin()
|
||||
<< " -->" << y1
|
||||
<< "Xmax : "
|
||||
<< theRect->xMax()
|
||||
<< "-->" << x2
|
||||
<< ", Ymax: "
|
||||
<< theRect->yMax()
|
||||
<< " -->" << y2
|
||||
<< std::endl;
|
||||
#endif
|
||||
return QgsRect(x1, y1, x2 , y2);
|
||||
}
|
||||
}
|
||||
|
||||
inline QgsPoint QgsCoordinateTransform::inverseTransform(double theX, double theY)
|
||||
{
|
||||
if (mShortCircuit || !mInitialisedFlag) return QgsPoint(theX,theY);
|
||||
// transform x
|
||||
double x = theX;
|
||||
double y = theY;
|
||||
if ( ! mDestToSourceXForm->Transform( 1, &x, &y ) )
|
||||
{
|
||||
//something bad happened....
|
||||
throw QgsCsException(QString("Coordinate inverseTransform failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
//std::cout << "Point inverse projection...X : " << theX << "-->" << x << ", Y: " << theY << " -->" << y << std::endl;
|
||||
#endif
|
||||
return QgsPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // QGSCOORDINATETRANSFORM_H
|
||||
|
@ -181,29 +181,29 @@ void QgsDbSourceSelect::dbConnect()
|
||||
geomCol details;
|
||||
if (getGeometryColumnInfo(pd, details))
|
||||
{
|
||||
geomCol::const_iterator iter = details.begin();
|
||||
for (; iter != details.end(); ++iter)
|
||||
{
|
||||
QPixmap *p = 0;
|
||||
if (iter->second == "POINT" || iter->second == "MULTIPOINT")
|
||||
p = &pxPoint;
|
||||
else if (iter->second == "MULTIPOLYGON" || iter->second == "POLYGON")
|
||||
p = &pxPoly;
|
||||
else if (iter->second == "LINESTRING" || iter->second == "MULTILINESTRING")
|
||||
p = &pxLine;
|
||||
geomCol::const_iterator iter = details.begin();
|
||||
for (; iter != details.end(); ++iter)
|
||||
{
|
||||
QPixmap *p = 0;
|
||||
if (iter->second == "POINT" || iter->second == "MULTIPOINT")
|
||||
p = &pxPoint;
|
||||
else if (iter->second == "MULTIPOLYGON" || iter->second == "POLYGON")
|
||||
p = &pxPoly;
|
||||
else if (iter->second == "LINESTRING" || iter->second == "MULTILINESTRING")
|
||||
p = &pxLine;
|
||||
|
||||
if (p != 0)
|
||||
{
|
||||
QListViewItem *lItem = new QListViewItem(lstTables);
|
||||
lItem->setText(1,iter->first);
|
||||
lItem->setPixmap(0,*p);
|
||||
lstTables->insertItem(lItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Unknown geometry type of " + iter->second);
|
||||
}
|
||||
}
|
||||
if (p != 0)
|
||||
{
|
||||
QListViewItem *lItem = new QListViewItem(lstTables);
|
||||
lItem->setText(1,iter->first);
|
||||
lItem->setPixmap(0,*p);
|
||||
lstTables->insertItem(lItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("Unknown geometry type of " + iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -212,7 +212,7 @@ void QgsDbSourceSelect::dbConnect()
|
||||
}
|
||||
// BEGIN CHANGES ECOS
|
||||
if (cmbConnections->count() > 0)
|
||||
btnAdd->setEnabled(true);
|
||||
btnAdd->setEnabled(true);
|
||||
// END CHANGES ECOS
|
||||
} else
|
||||
{
|
||||
@ -262,7 +262,7 @@ void QgsDbSourceSelect::addLayer(QListBoxItem * item)
|
||||
}
|
||||
|
||||
bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
|
||||
geomCol& details)
|
||||
geomCol& details)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
@ -287,28 +287,28 @@ bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
|
||||
|
||||
PGresult* exists = PQexec(pg, (const char*)sql);
|
||||
if (PQntuples(exists) == 1)
|
||||
{
|
||||
QString v = "";
|
||||
if (strlen(PQgetvalue(result, idx, PQfnumber(result, "f_table_catalog"))))
|
||||
{
|
||||
v += PQgetvalue(result, idx, PQfnumber(result, "f_table_catalog"));
|
||||
v += ".";
|
||||
}
|
||||
{
|
||||
QString v = "";
|
||||
if (strlen(PQgetvalue(result, idx, PQfnumber(result, "f_table_catalog"))))
|
||||
{
|
||||
v += PQgetvalue(result, idx, PQfnumber(result, "f_table_catalog"));
|
||||
v += ".";
|
||||
}
|
||||
|
||||
if (strlen(PQgetvalue(result, idx, PQfnumber(result, "f_table_schema"))))
|
||||
{
|
||||
v += PQgetvalue(result, idx, PQfnumber(result, "f_table_schema"));
|
||||
v += ".";
|
||||
}
|
||||
if (strlen(PQgetvalue(result, idx, PQfnumber(result, "f_table_schema"))))
|
||||
{
|
||||
v += PQgetvalue(result, idx, PQfnumber(result, "f_table_schema"));
|
||||
v += ".";
|
||||
}
|
||||
|
||||
v += tableName;
|
||||
v += " (";
|
||||
v += PQgetvalue(result, idx, PQfnumber(result, "f_geometry_column"));
|
||||
v += ")";
|
||||
v += tableName;
|
||||
v += " (";
|
||||
v += PQgetvalue(result, idx, PQfnumber(result, "f_geometry_column"));
|
||||
v += ")";
|
||||
|
||||
QString type = PQgetvalue(result, idx, PQfnumber(result, "type"));
|
||||
details.push_back(geomPair(v, type));
|
||||
}
|
||||
QString type = PQgetvalue(result, idx, PQfnumber(result, "type"));
|
||||
details.push_back(geomPair(v, type));
|
||||
}
|
||||
PQclear(exists);
|
||||
}
|
||||
ok = true;
|
||||
@ -353,8 +353,8 @@ bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
|
||||
if (PQresultStatus(gresult) != PGRES_TUPLES_OK)
|
||||
{
|
||||
qDebug(tr("Access to relation ") + table + tr(" using sql;\n") + sql +
|
||||
tr("\nhas failed. The database said:\n") +
|
||||
PQresultErrorMessage(gresult));
|
||||
tr("\nhas failed. The database said:\n") +
|
||||
PQresultErrorMessage(gresult));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -362,7 +362,7 @@ bool QgsDbSourceSelect::getGeometryColumnInfo(PGconn *pg,
|
||||
QString schema = PQgetvalue(gresult, 0, 1); // current_schema
|
||||
QString full_desc = "";
|
||||
if (schema.length() > 0)
|
||||
full_desc = schema + ".";
|
||||
full_desc = schema + ".";
|
||||
full_desc += table + " (" + column + ")";
|
||||
details.push_back(geomPair(full_desc, type));
|
||||
}
|
||||
|
@ -75,80 +75,7 @@ bufferRenderer(layer->
|
||||
renderer())
|
||||
{
|
||||
|
||||
// populate the general information
|
||||
QString source = layer->source();
|
||||
source = source.left(source.find("password"));
|
||||
lblSource->setText(source);
|
||||
txtDisplayName->setText(layer->name());
|
||||
// set whats this stuff
|
||||
QWhatsThis::add(lblSource, tr("The source of the data (path name or database connection information)"));
|
||||
QWhatsThis::add(pbnQueryBuilder, tr("This button opens the PostgreSQL query builder and allows you to create a subset of features to display on the map canvas rather than displaying all features in the layer"));
|
||||
QWhatsThis::add(txtSubsetSQL, tr("The query used to limit the features in the layer is shown here. This is currently only supported for PostgreSQL layers. To enter or modify the query, click on the Query Builder button"));
|
||||
|
||||
//we are dealing with a pg layer here so that we can enable the sql box
|
||||
QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
|
||||
//see if we are dealing with a pg layer here
|
||||
if(layer->providerType() == "postgres")
|
||||
{
|
||||
grpSubset->setEnabled(true);
|
||||
txtSubsetSQL->setText(layer->subsetString());
|
||||
// if the user is allowed to type an adhoc query, the app will crash if the query
|
||||
// is bad. For this reason, the sql box is disabled and the query must be built
|
||||
// using the query builder, either by typing it in by hand or using the buttons, etc
|
||||
// on the builder. If the ability to enter a query directly into the box is required,
|
||||
// a mechanism to check it must be implemented.
|
||||
txtSubsetSQL->setEnabled(false);
|
||||
pbnQueryBuilder->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
grpSubset->setEnabled(false);
|
||||
}
|
||||
|
||||
//get field list for display field combo
|
||||
std::vector<QgsField> myFields = dp->fields();
|
||||
for (int i = 0; i < myFields.size(); i++)
|
||||
{
|
||||
QgsField myField = myFields[i];
|
||||
displayFieldComboBox->insertItem( myField.name() );
|
||||
}
|
||||
|
||||
// set up the scale based layer visibility stuff....
|
||||
chkUseScaleDependentRendering->setChecked(lyr->scaleBasedVisibility());
|
||||
spinMinimumScale->setValue(lyr->minScale());
|
||||
spinMaximumScale->setValue(lyr->maxScale());
|
||||
|
||||
// symbology initialization
|
||||
legendtypecombobox->insertItem(tr("Single Symbol"));
|
||||
legendtypecombobox->insertItem(tr("Graduated Symbol"));
|
||||
legendtypecombobox->insertItem(tr("Continuous Color"));
|
||||
legendtypecombobox->insertItem(tr("Unique Value"));
|
||||
if( layer->vectorType()==QGis::Point )
|
||||
{
|
||||
legendtypecombobox->insertItem(tr("Single Marker"));
|
||||
legendtypecombobox->insertItem(tr("Graduated Marker"));
|
||||
legendtypecombobox->insertItem(tr("Unique Value Marker"));
|
||||
}
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
|
||||
labelDialog = new QgsLabelDialog ( layer->label(),labelOptionsFrame);
|
||||
layout->addWidget( labelDialog );
|
||||
|
||||
QGridLayout *actionLayout = new QGridLayout( actionOptionsFrame );
|
||||
std::vector<QgsField> fields = dp->fields();
|
||||
actionDialog = new QgsAttributeActionDialog ( layer->actions(), fields,
|
||||
actionOptionsFrame );
|
||||
actionLayout->addWidget( actionDialog,0,0 );
|
||||
|
||||
QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, SLOT(alterLayerDialog(const QString &)));
|
||||
|
||||
//insert the renderer dialog of the vector layer into the widget stack
|
||||
widgetStackRenderers->addWidget(bufferDialog);
|
||||
widgetStackRenderers->raiseWidget(bufferDialog);
|
||||
|
||||
//set the metadata contents
|
||||
teMetadata->setText(getMetadata());
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
QgsDlgVectorLayerProperties::~QgsDlgVectorLayerProperties()
|
||||
@ -260,11 +187,85 @@ void QgsDlgVectorLayerProperties::setDisplayField(QString name)
|
||||
displayFieldComboBox->setCurrentText(name);
|
||||
}
|
||||
|
||||
//! @note in raster props, this metho d is called sync()
|
||||
void QgsDlgVectorLayerProperties::reset( void )
|
||||
{
|
||||
actionDialog->init();
|
||||
labelDialog->init();
|
||||
labelCheckBox->setChecked(layer->labelOn());
|
||||
// populate the general information
|
||||
QString source = layer->source();
|
||||
source = source.left(source.find("password"));
|
||||
lblSource->setText(source);
|
||||
txtDisplayName->setText(layer->name());
|
||||
// set whats this stuff
|
||||
QWhatsThis::add(lblSource, tr("The source of the data (path name or database connection information)"));
|
||||
QWhatsThis::add(pbnQueryBuilder, tr("This button opens the PostgreSQL query builder and allows you to create a subset of features to display on the map canvas rather than displaying all features in the layer"));
|
||||
QWhatsThis::add(txtSubsetSQL, tr("The query used to limit the features in the layer is shown here. This is currently only supported for PostgreSQL layers. To enter or modify the query, click on the Query Builder button"));
|
||||
|
||||
//we are dealing with a pg layer here so that we can enable the sql box
|
||||
QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
|
||||
//see if we are dealing with a pg layer here
|
||||
if(layer->providerType() == "postgres")
|
||||
{
|
||||
grpSubset->setEnabled(true);
|
||||
txtSubsetSQL->setText(layer->subsetString());
|
||||
// if the user is allowed to type an adhoc query, the app will crash if the query
|
||||
// is bad. For this reason, the sql box is disabled and the query must be built
|
||||
// using the query builder, either by typing it in by hand or using the buttons, etc
|
||||
// on the builder. If the ability to enter a query directly into the box is required,
|
||||
// a mechanism to check it must be implemented.
|
||||
txtSubsetSQL->setEnabled(false);
|
||||
pbnQueryBuilder->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
grpSubset->setEnabled(false);
|
||||
}
|
||||
|
||||
//get field list for display field combo
|
||||
std::vector<QgsField> myFields = dp->fields();
|
||||
for (int i = 0; i < myFields.size(); i++)
|
||||
{
|
||||
QgsField myField = myFields[i];
|
||||
displayFieldComboBox->insertItem( myField.name() );
|
||||
}
|
||||
|
||||
// set up the scale based layer visibility stuff....
|
||||
chkUseScaleDependentRendering->setChecked(layer->scaleBasedVisibility());
|
||||
spinMinimumScale->setValue(layer->minScale());
|
||||
spinMaximumScale->setValue(layer->maxScale());
|
||||
|
||||
// symbology initialization
|
||||
legendtypecombobox->insertItem(tr("Single Symbol"));
|
||||
legendtypecombobox->insertItem(tr("Graduated Symbol"));
|
||||
legendtypecombobox->insertItem(tr("Continuous Color"));
|
||||
legendtypecombobox->insertItem(tr("Unique Value"));
|
||||
if( layer->vectorType()==QGis::Point )
|
||||
{
|
||||
legendtypecombobox->insertItem(tr("Single Marker"));
|
||||
legendtypecombobox->insertItem(tr("Graduated Marker"));
|
||||
legendtypecombobox->insertItem(tr("Unique Value Marker"));
|
||||
}
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
|
||||
labelDialog = new QgsLabelDialog ( layer->label(),labelOptionsFrame);
|
||||
layout->addWidget( labelDialog );
|
||||
|
||||
QGridLayout *actionLayout = new QGridLayout( actionOptionsFrame );
|
||||
std::vector<QgsField> fields = dp->fields();
|
||||
actionDialog = new QgsAttributeActionDialog ( layer->actions(), fields,
|
||||
actionOptionsFrame );
|
||||
actionLayout->addWidget( actionDialog,0,0 );
|
||||
|
||||
QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, SLOT(alterLayerDialog(const QString &)));
|
||||
|
||||
//insert the renderer dialog of the vector layer into the widget stack
|
||||
widgetStackRenderers->addWidget(bufferDialog);
|
||||
widgetStackRenderers->raiseWidget(bufferDialog);
|
||||
|
||||
//set the metadata contents
|
||||
teMetadata->setText(getMetadata());
|
||||
actionDialog->init();
|
||||
labelDialog->init();
|
||||
labelCheckBox->setChecked(layer->labelOn());
|
||||
}
|
||||
//
|
||||
// methods reimplemented from qt designer base class
|
||||
|
@ -28,13 +28,13 @@
|
||||
#include "qgsidentifyresults.h"
|
||||
|
||||
QgsIdentifyResults::QgsIdentifyResults(const QgsAttributeAction& aa, QWidget *parent,
|
||||
const char * name, WFlags f) :
|
||||
QgsIdentifyResultsBase ( parent, name, f),
|
||||
mActions(aa), mClickedOnValue(0), mActionPopup(0)
|
||||
const char * name, WFlags f) :
|
||||
QgsIdentifyResultsBase ( parent, name, f),
|
||||
mActions(aa), mClickedOnValue(0), mActionPopup(0)
|
||||
{
|
||||
lstResults->setResizeMode(QListView::AllColumns);
|
||||
lstResults->setResizeMode(QListView::AllColumns);
|
||||
|
||||
connect ( lstResults, SIGNAL(clicked(QListViewItem *)), this, SLOT(clicked(QListViewItem *)));
|
||||
connect ( lstResults, SIGNAL(clicked(QListViewItem *)), this, SLOT(clicked(QListViewItem *)));
|
||||
}
|
||||
|
||||
QgsIdentifyResults::~QgsIdentifyResults()
|
||||
@ -61,12 +61,12 @@ void QgsIdentifyResults::closeEvent(QCloseEvent *e)
|
||||
// actions that can be applied to the data in the identify results
|
||||
// dialog box.
|
||||
void QgsIdentifyResults::popupContextMenu(QListViewItem* item,
|
||||
const QPoint& p, int i)
|
||||
const QPoint& p, int i)
|
||||
{
|
||||
// if the user clicked below the end of the attribute list, just return
|
||||
if (item == NULL)
|
||||
return;
|
||||
|
||||
|
||||
// The assumption is made that an instance of QgsIdentifyResults is
|
||||
// created for each new Identify Results dialog box, and that the
|
||||
// contents of the popup menu doesn't change during the time that
|
||||
@ -80,11 +80,11 @@ void QgsIdentifyResults::popupContextMenu(QListViewItem* item,
|
||||
mActionPopup->insertItem(popupLabel);
|
||||
mActionPopup->insertSeparator();
|
||||
|
||||
QgsAttributeAction::aIter iter = mActions.begin();
|
||||
QgsAttributeAction::aIter iter = mActions.begin();
|
||||
for (int j = 0; iter != mActions.end(); ++iter, ++j)
|
||||
{
|
||||
int id = mActionPopup->insertItem(iter->name(), this,
|
||||
SLOT(popupItemSelected(int)));
|
||||
SLOT(popupItemSelected(int)));
|
||||
mActionPopup->setItemParameter(id, j);
|
||||
}
|
||||
}
|
||||
@ -106,20 +106,20 @@ void QgsIdentifyResults::popupContextMenu(QListViewItem* item,
|
||||
mValues.clear();
|
||||
int j = 0;
|
||||
while (child != 0)
|
||||
{
|
||||
if ( child->text(2) != "action" ) {
|
||||
mValues.push_back(std::make_pair(child->text(0), child->text(1)));
|
||||
// Need to do the comparison on the text strings rather than the
|
||||
// pointers because if the user clicked on the parent, we need
|
||||
// to pick up which child that actually is (the parent in the
|
||||
// identify results dialog box is just one of the children
|
||||
// that has been chosen by some method).
|
||||
if (child->text(0) == item->text(0))
|
||||
mClickedOnValue = j;
|
||||
++j;
|
||||
}
|
||||
child = child->nextSibling();
|
||||
{
|
||||
if ( child->text(2) != "action" ) {
|
||||
mValues.push_back(std::make_pair(child->text(0), child->text(1)));
|
||||
// Need to do the comparison on the text strings rather than the
|
||||
// pointers because if the user clicked on the parent, we need
|
||||
// to pick up which child that actually is (the parent in the
|
||||
// identify results dialog box is just one of the children
|
||||
// that has been chosen by some method).
|
||||
if (child->text(0) == item->text(0))
|
||||
mClickedOnValue = j;
|
||||
++j;
|
||||
}
|
||||
child = child->nextSibling();
|
||||
}
|
||||
|
||||
mActionPopup->popup(p);
|
||||
}
|
||||
@ -171,7 +171,7 @@ void QgsIdentifyResults::addAction(QListViewItem * fnode, int id, QString field,
|
||||
#endif
|
||||
|
||||
QString img = appDir + "/share/qgis/themes/default/action.png";
|
||||
|
||||
|
||||
QPixmap pm ( img );
|
||||
item->setPixmap ( 0, pm );
|
||||
}
|
||||
@ -189,7 +189,7 @@ void QgsIdentifyResults::setTitle(QString title)
|
||||
|
||||
void QgsIdentifyResults::setColumnText ( int column, const QString & label )
|
||||
{
|
||||
lstResults->setColumnText ( column, label );
|
||||
lstResults->setColumnText ( column, label );
|
||||
}
|
||||
|
||||
// Run the action that was selected in the popup menu
|
||||
@ -207,51 +207,51 @@ void QgsIdentifyResults::showAllAttributes() {
|
||||
|
||||
void QgsIdentifyResults::clear()
|
||||
{
|
||||
lstResults->clear();
|
||||
lstResults->clear();
|
||||
}
|
||||
|
||||
void QgsIdentifyResults::setMessage( QString shortMsg, QString longMsg )
|
||||
{
|
||||
new QListViewItem(lstResults, shortMsg, longMsg );
|
||||
new QListViewItem(lstResults, shortMsg, longMsg );
|
||||
}
|
||||
|
||||
void QgsIdentifyResults::setActions( const QgsAttributeAction& actions )
|
||||
{
|
||||
mActions = actions;
|
||||
mActions = actions;
|
||||
}
|
||||
|
||||
void QgsIdentifyResults::clicked ( QListViewItem *item )
|
||||
{
|
||||
if ( !item ) return;
|
||||
|
||||
if ( item->text(2) != "action" ) return;
|
||||
|
||||
int id = item->text(3).toInt();
|
||||
|
||||
QListViewItem* parent = item->parent();
|
||||
QListViewItem* child;
|
||||
if ( !item ) return;
|
||||
|
||||
if (item->parent() == 0)
|
||||
child = item->firstChild();
|
||||
else
|
||||
child = parent->firstChild();
|
||||
if ( item->text(2) != "action" ) return;
|
||||
|
||||
mValues.clear();
|
||||
int id = item->text(3).toInt();
|
||||
|
||||
int j = 0;
|
||||
|
||||
while (child != 0)
|
||||
{
|
||||
if ( child->text(2) != "action" ) {
|
||||
mValues.push_back(std::make_pair(child->text(0), child->text(1)));
|
||||
QListViewItem* parent = item->parent();
|
||||
QListViewItem* child;
|
||||
|
||||
if (child->text(0) == item->text(0))
|
||||
mClickedOnValue = j;
|
||||
|
||||
++j;
|
||||
}
|
||||
child = child->nextSibling();
|
||||
if (item->parent() == 0)
|
||||
child = item->firstChild();
|
||||
else
|
||||
child = parent->firstChild();
|
||||
|
||||
mValues.clear();
|
||||
|
||||
int j = 0;
|
||||
|
||||
while (child != 0)
|
||||
{
|
||||
if ( child->text(2) != "action" ) {
|
||||
mValues.push_back(std::make_pair(child->text(0), child->text(1)));
|
||||
|
||||
if (child->text(0) == item->text(0))
|
||||
mClickedOnValue = j;
|
||||
|
||||
++j;
|
||||
}
|
||||
child = child->nextSibling();
|
||||
}
|
||||
|
||||
mActions.doAction(id, mValues, mClickedOnValue);
|
||||
mActions.doAction(id, mValues, mClickedOnValue);
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ class QgsIdentifyResults:public QgsIdentifyResultsBase
|
||||
//! Constructor - takes it own copy of the QgsAttributeAction so
|
||||
// that it is independent of whoever created it.
|
||||
QgsIdentifyResults(const QgsAttributeAction&, QWidget *parent = 0, const char * name = 0,
|
||||
WFlags f = Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title
|
||||
| Qt::WStyle_Dialog | Qt::WStyle_Tool);
|
||||
WFlags f = Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title
|
||||
| Qt::WStyle_Dialog | Qt::WStyle_Tool);
|
||||
|
||||
~QgsIdentifyResults();
|
||||
/** Add an attribute to the feature display node */
|
||||
|
49
src/qgslayerprojectionselector.cpp
Normal file
49
src/qgslayerprojectionselector.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
qgslayerprojectionselector.cpp
|
||||
Set user layerprojectionselector and preferences
|
||||
-------------------
|
||||
begin : May 28, 2004
|
||||
copyright : (C) 2004 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
#include "qgslayerprojectionselector.h"
|
||||
#include "qgsprojectionselector.h"
|
||||
#include <qapplication.h>
|
||||
/**
|
||||
* \class QgsLayerProjectionSelector - Set user layerprojectionselector and preferences
|
||||
* Constructor
|
||||
*/
|
||||
QgsLayerProjectionSelector::QgsLayerProjectionSelector()
|
||||
{
|
||||
|
||||
qApp->restoreOverrideCursor();
|
||||
}
|
||||
//! Destructor
|
||||
QgsLayerProjectionSelector::~QgsLayerProjectionSelector()
|
||||
{}
|
||||
|
||||
void QgsLayerProjectionSelector::pbnOK_clicked()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
||||
void QgsLayerProjectionSelector::setSelectedWKT(QString theWKTName)
|
||||
{
|
||||
projectionSelector->setSelectedWKT(theWKTName);
|
||||
}
|
||||
|
||||
QString QgsLayerProjectionSelector::getCurrentWKT()
|
||||
{
|
||||
//@NOTE dont use getSelectedWKT as that just returns the name part!
|
||||
return projectionSelector->getCurrentWKT();
|
||||
}
|
47
src/qgslayerprojectionselector.h
Normal file
47
src/qgslayerprojectionselector.h
Normal file
@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
qgslayerprojectionselector.h
|
||||
Set user layerprojectionselector and preferences
|
||||
-------------------
|
||||
begin : May 28, 2004
|
||||
copyright : (C) 2004 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
#ifndef QGSLAYERPROJECTIONSELECTOR_H
|
||||
#define QGSLAYERPROJECTIONSELECTOR_H
|
||||
class QString;
|
||||
#ifdef WIN32
|
||||
#include "qgslayerprojectionselectorbase.h"
|
||||
#else
|
||||
#include "qgslayerprojectionselectorbase.uic.h"
|
||||
#endif
|
||||
/**
|
||||
* \class QgsLayerProjectionSelector
|
||||
* \brief Set Projection system for a layer
|
||||
*/
|
||||
class QgsLayerProjectionSelector :public QgsLayerProjectionSelectorBase{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
QgsLayerProjectionSelector();
|
||||
//! Destructor
|
||||
~QgsLayerProjectionSelector();
|
||||
|
||||
public slots:
|
||||
void pbnOK_clicked();
|
||||
QString getCurrentWKT();
|
||||
void setSelectedWKT(QString theWKTName);
|
||||
};
|
||||
|
||||
#endif // #ifndef QGSLAYERPROJECTIONSELECTOR_H
|
95
src/qgslayerprojectionselectorbase.ui
Normal file
95
src/qgslayerprojectionselectorbase.ui
Normal file
@ -0,0 +1,95 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>QgsLayerProjectionSelectorBase</class>
|
||||
<widget class="QDialog">
|
||||
<property name="name">
|
||||
<cstring>QgsLayerProjectionSelectorBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>563</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Layer Projection Selector</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<pixmap>image0</pixmap>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QPushButton" row="2" column="1">
|
||||
<property name="name">
|
||||
<cstring>pbnOK</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>spacer1</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>221</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QgsProjectionSelector" row="1" column="0" rowspan="1" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>projectionSelector</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" row="0" column="0" rowspan="1" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>textEdit1</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style="font-size:12pt;font-family:Bitstream Vera Sans">
|
||||
<p style="margin-top:16px"><span style="font-size:18pt;font-weight:600">Define this layer's projection:</span></p>
|
||||
<p>This layer appears to have no projection specification. By default, this layer will now have its projection set to that of the project, but you may override this by selecting a different projection below.</p>
|
||||
</body></html>
|
||||
</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<enum>WidgetWidth</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<images>
|
||||
<image name="image0">
|
||||
<data format="PNG" length="727">89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000029e49444154388d95925b48530118c7ff3b3bd3b9a6392f9b97b42413a7b912b1de7ab10cc44c3408c5348d0a0c347b29848c2233d0613d1651122a09f950a1f83012ba4b379b28a37969a6a6e7ecd2e6e639673b971e62656e41fddfbeefe3fffbe0ff7dc07f28e63cb2355d7848666277b047fc8b31ba05a99a4edc966b3121aca0849f86189c91e10c2b2b3d09b1b152cd946572879c64f977b639aaa97fb888d049a440830260ffeb3686e92be105a3e3f148b95713a7aca93ba93ffad25a21a61849497d1cdf22f6e205007558f3eaea1d4340b8c6cc398e4975a7b24700a8c80c90fa4ef5bcae8d949a2f1aa623b5f20200f2b0192895dfdb299f55e95b0b60d6ea790380511d41f3b2e84d3b149189fafaeced8d0d79fb81df19fc020c0d9d51f132ba98e1fcf07302a815c6a66e849e88c7d52c2a61ed74e54ea8a31548cf509701880c01e4e64a495cc01311acfd82109027a147a4c11ed6e9879393370100542a790a005508c06c76ba7970120010840c5b8a34e70e64e71516713983b5d5056332990c0060a73916801402282b7be0b2bb58330044a9481c346ccd8f18152d4d5539a5b189e4155e14c171023ebca52700f8c28528be7e4e75b10c0f829061d2b2e4ecbf35599b911ed7ed62a8287f40c0ab67cb6ba6e1857b00fc2100721b88b366d352e7a38f0e3bcda0aa2c8b34ec4a746be33591003035e10cdcb86e36badddc684747d59f678caa8442598c768146efe0a7cf71272e3ffd3231ee98696ddb333063631b045184d7cbfb9c76a18f65efb6aeb1f60684910280565581fb91fbd08d9fdf96f6c4547ac14a554b56aa5a72f95afcbd03e5768582280c9ae4eb0022009f221f0b220d088b1803e059fcca8c7bdcfe54dbec6acce0a065fea6f1fd258fdb6fc2ba67da2842aec3e60d3d128006400c00d9fac10f3d4b18bb5f2121880000000049454e44ae426082</data>
|
||||
</image>
|
||||
</images>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pbnOK</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QgsLayerProjectionSelectorBase</receiver>
|
||||
<slot>pbnOK_clicked()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">qgslayerprojectionselectorbase.ui.h</include>
|
||||
</includes>
|
||||
<slots>
|
||||
<slot>pbnOK_clicked()</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>qgsprojectionselector.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
17
src/qgslayerprojectionselectorbase.ui.h
Normal file
17
src/qgslayerprojectionselectorbase.ui.h
Normal file
@ -0,0 +1,17 @@
|
||||
/****************************************************************************
|
||||
** ui.h extension file, included from the uic-generated form implementation.
|
||||
**
|
||||
** If you want to add, delete, or rename functions or slots, use
|
||||
** Qt Designer to update this file, preserving your code.
|
||||
**
|
||||
** You should not define a constructor or destructor in this file.
|
||||
** Instead, write your code in functions called init() and destroy().
|
||||
** These will automatically be called by the form's constructor and
|
||||
** destructor.
|
||||
*****************************************************************************/
|
||||
#include "../widgets/projectionselector/qgsprojectionselector.h"
|
||||
|
||||
void QgsLayerProjectionSelectorBase::pbnOK_clicked()
|
||||
{
|
||||
|
||||
}
|
@ -498,14 +498,34 @@ void QgsMapCanvas::addLayer(QgsMapLayer * lyr)
|
||||
// update extent if warranted
|
||||
if (mCanvasProperties->layers.size() == 1)
|
||||
{
|
||||
mCanvasProperties->fullExtent = lyr->extent();
|
||||
mCanvasProperties->fullExtent.scale(1.1);
|
||||
// if only 1 layer, set the full extent to its extent
|
||||
|
||||
// the layer extent must be projected to the same coordinate
|
||||
// system as the map canvas prior to updating the canvas extents
|
||||
if(projectionsEnabled())
|
||||
{
|
||||
QgsRect tRect = lyr->coordinateTransform()->transform(lyr->extent());
|
||||
mCanvasProperties->fullExtent = tRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCanvasProperties->fullExtent = lyr->extent();
|
||||
mCanvasProperties->fullExtent.scale(1.1);
|
||||
}
|
||||
// XXX why magic number of 1.1? - TO GET SOME WHITESPACE AT THE EDGES OF THE MAP
|
||||
mCanvasProperties->currentExtent = mCanvasProperties->fullExtent;
|
||||
}
|
||||
else
|
||||
{
|
||||
updateFullExtent(lyr->extent());
|
||||
if(projectionsEnabled())
|
||||
{
|
||||
// project the layer extent and pass it off to update the full extent
|
||||
updateFullExtent(lyr->coordinateTransform()->transform(lyr->extent()));
|
||||
}
|
||||
else
|
||||
{
|
||||
updateFullExtent(lyr->extent());
|
||||
}
|
||||
}
|
||||
|
||||
mCanvasProperties->zOrder.push_back(lyr->getLayerID());
|
||||
@ -650,7 +670,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
{
|
||||
// Go back to the previous extent
|
||||
mCanvasProperties->currentExtent =
|
||||
mCanvasProperties->previousExtent;
|
||||
mCanvasProperties->previousExtent;
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
@ -721,7 +741,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
dymin = mCanvasProperties->currentExtent.yMin();
|
||||
dymax = mCanvasProperties->currentExtent.yMax();
|
||||
whitespace = ((myWidth * mCanvasProperties->m_mupp) -
|
||||
mCanvasProperties->currentExtent.width()) / 2;
|
||||
mCanvasProperties->currentExtent.width()) / 2;
|
||||
dxmin = mCanvasProperties->currentExtent.xMin() - whitespace;
|
||||
dxmax = mCanvasProperties->currentExtent.xMax() + whitespace;
|
||||
}
|
||||
@ -730,7 +750,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
dxmin = mCanvasProperties->currentExtent.xMin();
|
||||
dxmax = mCanvasProperties->currentExtent.xMax();
|
||||
whitespace = ((myHeight * mCanvasProperties->m_mupp) -
|
||||
mCanvasProperties->currentExtent.height()) / 2;
|
||||
mCanvasProperties->currentExtent.height()) / 2;
|
||||
dymin = mCanvasProperties->currentExtent.yMin() - whitespace;
|
||||
dymax = mCanvasProperties->currentExtent.yMax() + whitespace;
|
||||
}
|
||||
@ -742,7 +762,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
// the mupp if we're rendering to an alternative device (it uses the
|
||||
// widget size in its calculations).
|
||||
if (!theQPaintDevice)
|
||||
currentScale(0);
|
||||
currentScale(0);
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
|
||||
@ -797,46 +817,50 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
// QgsDatabaseLayer *dbl = (QgsDatabaseLayer *)&ml;
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsMapCanvas::render: Rendering layer " << ml->name() << '\n'
|
||||
<< "Layer minscale " << ml->minScale()
|
||||
<< ", maxscale " << ml->maxScale() << '\n'
|
||||
<< ". Scale dep. visibility enabled? "
|
||||
<< ml->scaleBasedVisibility() << '\n'
|
||||
<< "Input extent: " << ml->extent().stringRep()
|
||||
<< std::endl;
|
||||
<< "Layer minscale " << ml->minScale()
|
||||
<< ", maxscale " << ml->maxScale() << '\n'
|
||||
<< ". Scale dep. visibility enabled? "
|
||||
<< ml->scaleBasedVisibility() << '\n'
|
||||
<< "Input extent: " << ml->extent().stringRep()
|
||||
<< std::endl;
|
||||
try
|
||||
{
|
||||
std::cout << "Transformed extent"
|
||||
<< ml->coordinateTransform()->transform(ml->extent()).stringRep()
|
||||
<< std::endl;
|
||||
<< ml->coordinateTransform()->transform(ml->extent()).stringRep()
|
||||
<< std::endl;
|
||||
}
|
||||
catch (QgsCsException &e)
|
||||
{
|
||||
qDebug( "Transform error caught in %s line %d:\n%s",
|
||||
__FILE__, __LINE__, e.what());
|
||||
__FILE__, __LINE__, e.what());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ml->visible())
|
||||
{
|
||||
if ((ml->scaleBasedVisibility() && ml->minScale() < mCanvasProperties->mScale
|
||||
&& ml->maxScale() > mCanvasProperties->mScale)
|
||||
&& ml->maxScale() > mCanvasProperties->mScale)
|
||||
|| (!ml->scaleBasedVisibility()))
|
||||
{
|
||||
//we need to find out the extent of the canvas in the layer's
|
||||
//native coordinate system :. inverseProjection of the extent
|
||||
//must be done....
|
||||
// XXX this works as long as the canvas extents are in the canvas
|
||||
// XXX coordinate system -- which is not working at present
|
||||
//
|
||||
QgsRect myProjectedRect;
|
||||
try
|
||||
{
|
||||
std::cout << "Getting extent of canvas in layers CS. Canvas is " << mCanvasProperties->currentExtent.stringRep() << std::endl;
|
||||
myProjectedRect =
|
||||
ml->coordinateTransform()->inverseTransform(
|
||||
mCanvasProperties->currentExtent);
|
||||
ml->coordinateTransform()->transform(
|
||||
mCanvasProperties->currentExtent, QgsCoordinateTransform::INVERSE);
|
||||
|
||||
}
|
||||
catch (QgsCsException &e)
|
||||
{
|
||||
qDebug( "Transform error caught in %s line %d:\n%s",
|
||||
__FILE__, __LINE__, e.what());
|
||||
__FILE__, __LINE__, e.what());
|
||||
}
|
||||
ml->draw(paint,
|
||||
&myProjectedRect,
|
||||
@ -847,7 +871,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
else
|
||||
{
|
||||
std::cout << "Layer not rendered because it is not within "
|
||||
<< "the defined visibility scale range" << std::endl;
|
||||
<< "the defined visibility scale range" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -880,7 +904,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
//only make labels if the layer is visible
|
||||
//after scale dep viewing settings are checked
|
||||
if ((ml->scaleBasedVisibility() && ml->minScale() < mCanvasProperties->mScale
|
||||
&& ml->maxScale() > mCanvasProperties->mScale)
|
||||
&& ml->maxScale() > mCanvasProperties->mScale)
|
||||
|| (!ml->scaleBasedVisibility()))
|
||||
{
|
||||
ml->drawLabels(paint,
|
||||
@ -904,7 +928,7 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
emit renderComplete(paint);
|
||||
// draw the acetate layer
|
||||
std::map <QString, QgsAcetateObject *>::iterator
|
||||
ai = mCanvasProperties->acetateObjects.begin();
|
||||
ai = mCanvasProperties->acetateObjects.begin();
|
||||
while(ai != mCanvasProperties->acetateObjects.end())
|
||||
{
|
||||
QgsAcetateObject *acObj = ai->second;
|
||||
@ -949,20 +973,20 @@ void QgsMapCanvas::currentScale(int thePrecision)
|
||||
std::cout << "------------------------------------------ " << std::endl;
|
||||
|
||||
std::cout << "Current extent is "
|
||||
<< mCanvasProperties->currentExtent.stringRep() << std::endl;
|
||||
<< mCanvasProperties->currentExtent.stringRep() << std::endl;
|
||||
std::cout << "MuppX is: " << muppX << "\n"
|
||||
<< "MuppY is: " << muppY << std::endl;
|
||||
<< "MuppY is: " << muppY << std::endl;
|
||||
std::cout << "Canvas width: " << width()
|
||||
<< ", height: " << height() << std::endl;
|
||||
<< ", height: " << height() << std::endl;
|
||||
std::cout << "Extent width: "
|
||||
<< mCanvasProperties->currentExtent.width() << ", height: "
|
||||
<< mCanvasProperties->currentExtent.height() << std::endl;
|
||||
<< mCanvasProperties->currentExtent.width() << ", height: "
|
||||
<< mCanvasProperties->currentExtent.height() << std::endl;
|
||||
|
||||
QPaintDeviceMetrics pdm(this);
|
||||
std::cout << "dpiX " << pdm.logicalDpiX()
|
||||
<< ", dpiY " << pdm.logicalDpiY() << std::endl;
|
||||
<< ", dpiY " << pdm.logicalDpiY() << std::endl;
|
||||
std::cout << "widthMM " << pdm.widthMM()
|
||||
<< ", heightMM " << pdm.heightMM() << std::endl;
|
||||
<< ", heightMM " << pdm.heightMM() << std::endl;
|
||||
|
||||
#endif
|
||||
// calculate the actual extent of the mapCanvas
|
||||
@ -989,7 +1013,7 @@ void QgsMapCanvas::currentScale(int thePrecision)
|
||||
#ifdef QGISDEBUG
|
||||
|
||||
std::cout << "Scale (assuming meters as map units) = 1:"
|
||||
<< mCanvasProperties->mScale << std::endl;
|
||||
<< mCanvasProperties->mScale << std::endl;
|
||||
#endif
|
||||
// return scale based on geographic
|
||||
//
|
||||
@ -1144,7 +1168,7 @@ void QgsMapCanvas::zoomToSelected()
|
||||
//or two point features with the same x- or y-coordinates
|
||||
if(rect.isEmpty())
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
//zoom to an area
|
||||
else
|
||||
@ -1172,7 +1196,7 @@ void QgsMapCanvas::mousePressEvent(QMouseEvent * e)
|
||||
// right button was pressed in zoom tool, return to previous non zoom tool
|
||||
if ( e->button() == Qt::RightButton &&
|
||||
( mCanvasProperties->mapTool == QGis::ZoomIn || mCanvasProperties->mapTool == QGis::ZoomOut
|
||||
|| mCanvasProperties->mapTool == QGis::Pan ) )
|
||||
|| mCanvasProperties->mapTool == QGis::Pan ) )
|
||||
{
|
||||
emit stopZoom();
|
||||
return;
|
||||
@ -1424,53 +1448,53 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
if(vlayer)
|
||||
{
|
||||
|
||||
QgsPoint idPoint = mCanvasProperties->coordXForm->toMapCoordinates(e->x(), e->y());
|
||||
emit xyClickCoordinates(idPoint);
|
||||
|
||||
//only do the rest for provider with feature addition support
|
||||
//note that for the grass provider, this will return false since
|
||||
//grass provider has its own mechanism of feature addition
|
||||
if(vlayer->getDataProvider()->capabilities()&QgsVectorDataProvider::AddFeatures)
|
||||
{
|
||||
if(!vlayer->isEditable() )
|
||||
{
|
||||
QMessageBox::information(0,"Layer not editable","Cannot edit the vector layer. Use 'Start editing' in the legend item menu",QMessageBox::Ok);
|
||||
break;
|
||||
}
|
||||
QgsPoint idPoint = mCanvasProperties->coordXForm->toMapCoordinates(e->x(), e->y());
|
||||
emit xyClickCoordinates(idPoint);
|
||||
|
||||
//only do the rest for provider with feature addition support
|
||||
//note that for the grass provider, this will return false since
|
||||
//grass provider has its own mechanism of feature addition
|
||||
if(vlayer->getDataProvider()->capabilities()&QgsVectorDataProvider::AddFeatures)
|
||||
{
|
||||
if(!vlayer->isEditable() )
|
||||
{
|
||||
QMessageBox::information(0,"Layer not editable","Cannot edit the vector layer. Use 'Start editing' in the legend item menu",QMessageBox::Ok);
|
||||
break;
|
||||
}
|
||||
|
||||
//snap point to points within the vector layer snapping tolerance
|
||||
vlayer->snapPoint(idPoint,QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0));
|
||||
//snap point to points within the vector layer snapping tolerance
|
||||
vlayer->snapPoint(idPoint,QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0));
|
||||
|
||||
QgsFeature* f = new QgsFeature(0,"WKBPoint");
|
||||
int size=5+2*sizeof(double);
|
||||
unsigned char *wkb = new unsigned char[size];
|
||||
int wkbtype=QGis::WKBPoint;
|
||||
double x=idPoint.x();
|
||||
double y=idPoint.y();
|
||||
memcpy(&wkb[1],&wkbtype, sizeof(int));
|
||||
memcpy(&wkb[5], &x, sizeof(double));
|
||||
memcpy(&wkb[5]+sizeof(double), &y, sizeof(double));
|
||||
f->setGeometry(&wkb[0],size);
|
||||
QgsFeature* f = new QgsFeature(0,"WKBPoint");
|
||||
int size=5+2*sizeof(double);
|
||||
unsigned char *wkb = new unsigned char[size];
|
||||
int wkbtype=QGis::WKBPoint;
|
||||
double x=idPoint.x();
|
||||
double y=idPoint.y();
|
||||
memcpy(&wkb[1],&wkbtype, sizeof(int));
|
||||
memcpy(&wkb[5], &x, sizeof(double));
|
||||
memcpy(&wkb[5]+sizeof(double), &y, sizeof(double));
|
||||
f->setGeometry(&wkb[0],size);
|
||||
|
||||
//add the fields to the QgsFeature
|
||||
std::vector<QgsField> fields=vlayer->fields();
|
||||
for(std::vector<QgsField>::iterator it=fields.begin();it!=fields.end();++it)
|
||||
{
|
||||
f->addAttribute((*it).name(), vlayer->getDefaultValue(it->name(),f));
|
||||
}
|
||||
//add the fields to the QgsFeature
|
||||
std::vector<QgsField> fields=vlayer->fields();
|
||||
for(std::vector<QgsField>::iterator it=fields.begin();it!=fields.end();++it)
|
||||
{
|
||||
f->addAttribute((*it).name(), vlayer->getDefaultValue(it->name(),f));
|
||||
}
|
||||
|
||||
//show the dialog to enter attribute values
|
||||
if(f->attributeDialog())
|
||||
{
|
||||
vlayer->addFeature(f);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Not a vector layer","The current layer is not a vector layer",QMessageBox::Ok);
|
||||
}
|
||||
//show the dialog to enter attribute values
|
||||
if(f->attributeDialog())
|
||||
{
|
||||
vlayer->addFeature(f);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Not a vector layer","The current layer is not a vector layer",QMessageBox::Ok);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1478,126 +1502,126 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
case QGis::CaptureLine:
|
||||
case QGis::CapturePolygon:
|
||||
{
|
||||
QgsVectorLayer* vlayer=dynamic_cast<QgsVectorLayer*>(mCanvasProperties->mapLegend->currentLayer());
|
||||
|
||||
if(vlayer)
|
||||
{
|
||||
if(!vlayer->isEditable())// && (vlayer->providerType().lower() != "grass"))
|
||||
{
|
||||
QMessageBox::information(0,"Layer not editable","Cannot edit the vector layer. Use 'Start editing' in the legend item menu",QMessageBox::Ok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Not a vector layer","The current layer is not a vector layer",QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
QgsPoint digitisedpoint=mCanvasProperties->coordXForm->toMapCoordinates(e->x(), e->y());
|
||||
vlayer->snapPoint(digitisedpoint,QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0));
|
||||
mCaptureList.push_back(digitisedpoint);
|
||||
if(mCaptureList.size()>1)
|
||||
{
|
||||
QPainter paint(this);
|
||||
QColor digitcolor(QgsProject::instance()->readNumEntry("Digitizing","/LineColorRedPart",255),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0));
|
||||
paint.setPen(QPen(digitcolor,QgsProject::instance()->readNumEntry("Digitizing","/LineWidth",1),Qt::SolidLine));
|
||||
std::list<QgsPoint>::iterator it=mCaptureList.end();
|
||||
--it;
|
||||
--it;
|
||||
|
||||
QgsPoint lastpoint = mCanvasProperties->coordXForm->transform(it->x(),it->y());
|
||||
QgsPoint endpoint = mCanvasProperties->coordXForm->transform(digitisedpoint.x(),digitisedpoint.y());
|
||||
paint.drawLine(static_cast<int>(lastpoint.x()),static_cast<int>(lastpoint.y()),
|
||||
endpoint.x(),endpoint.y());
|
||||
//draw it to an acetate layer
|
||||
QgsLine digitline(*it,digitisedpoint);
|
||||
QgsAcetateLines* acetate=new QgsAcetateLines();
|
||||
acetate->add(digitline);
|
||||
addAcetateObject(vlayer->name()+"_##digit##ac"+QString::number(mCaptureList.size()),acetate);
|
||||
QgsVectorLayer* vlayer=dynamic_cast<QgsVectorLayer*>(mCanvasProperties->mapLegend->currentLayer());
|
||||
|
||||
if(vlayer)
|
||||
{
|
||||
if(!vlayer->isEditable())// && (vlayer->providerType().lower() != "grass"))
|
||||
{
|
||||
QMessageBox::information(0,"Layer not editable","Cannot edit the vector layer. Use 'Start editing' in the legend item menu",QMessageBox::Ok);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(0,"Not a vector layer","The current layer is not a vector layer",QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
QgsPoint digitisedpoint=mCanvasProperties->coordXForm->toMapCoordinates(e->x(), e->y());
|
||||
vlayer->snapPoint(digitisedpoint,QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0));
|
||||
mCaptureList.push_back(digitisedpoint);
|
||||
if(mCaptureList.size()>1)
|
||||
{
|
||||
QPainter paint(this);
|
||||
QColor digitcolor(QgsProject::instance()->readNumEntry("Digitizing","/LineColorRedPart",255),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0));
|
||||
paint.setPen(QPen(digitcolor,QgsProject::instance()->readNumEntry("Digitizing","/LineWidth",1),Qt::SolidLine));
|
||||
std::list<QgsPoint>::iterator it=mCaptureList.end();
|
||||
--it;
|
||||
--it;
|
||||
|
||||
QgsPoint lastpoint = mCanvasProperties->coordXForm->transform(it->x(),it->y());
|
||||
QgsPoint endpoint = mCanvasProperties->coordXForm->transform(digitisedpoint.x(),digitisedpoint.y());
|
||||
paint.drawLine(static_cast<int>(lastpoint.x()),static_cast<int>(lastpoint.y()),
|
||||
static_cast<int>(endpoint.x()),static_cast<int>(endpoint.y()));
|
||||
//draw it to an acetate layer
|
||||
QgsLine digitline(*it,digitisedpoint);
|
||||
QgsAcetateLines* acetate=new QgsAcetateLines();
|
||||
acetate->add(digitline);
|
||||
addAcetateObject(vlayer->name()+"_##digit##ac"+QString::number(mCaptureList.size()),acetate);
|
||||
#ifdef QGISDEBUG
|
||||
qWarning("adding "+vlayer->name()+"_##digit##ac"+QString::number(mCaptureList.size()));
|
||||
qWarning("adding "+vlayer->name()+"_##digit##ac"+QString::number(mCaptureList.size()));
|
||||
#endif
|
||||
|
||||
}
|
||||
if(e->button()==Qt::RightButton)
|
||||
{
|
||||
//create QgsFeature with wkb representation
|
||||
QgsFeature* f=new QgsFeature(0,"WKBLineString");
|
||||
unsigned char* wkb;
|
||||
int size;
|
||||
if(mCanvasProperties->mapTool==QGis::CaptureLine)
|
||||
{
|
||||
size=1+2*sizeof(int)+2*mCaptureList.size()*sizeof(double);
|
||||
wkb= new unsigned char[size];
|
||||
int wkbtype=QGis::WKBLineString;
|
||||
int length=mCaptureList.size();
|
||||
memcpy(&wkb[1],&wkbtype, sizeof(int));
|
||||
memcpy(&wkb[5],&length, sizeof(int));
|
||||
int position=1+2*sizeof(int);
|
||||
double x,y;
|
||||
for(std::list<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
|
||||
{
|
||||
x=it->x();
|
||||
memcpy(&wkb[position],&x,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
y=it->y();
|
||||
memcpy(&wkb[position],&y,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
}
|
||||
}
|
||||
else//polygon
|
||||
{
|
||||
size=1+3*sizeof(int)+2*(mCaptureList.size()+1)*sizeof(double);
|
||||
wkb= new unsigned char[size];
|
||||
int wkbtype=QGis::WKBPolygon;
|
||||
int length=mCaptureList.size()+1;//+1 because the first point is needed twice
|
||||
int numrings=1;
|
||||
memcpy(&wkb[1],&wkbtype, sizeof(int));
|
||||
memcpy(&wkb[5],&numrings,sizeof(int));
|
||||
memcpy(&wkb[9],&length, sizeof(int));
|
||||
int position=1+3*sizeof(int);
|
||||
double x,y;
|
||||
std::list<QgsPoint>::iterator it;
|
||||
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)
|
||||
{
|
||||
x=it->x();
|
||||
memcpy(&wkb[position],&x,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
y=it->y();
|
||||
memcpy(&wkb[position],&y,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
}
|
||||
//close the polygon
|
||||
it=mCaptureList.begin();
|
||||
x=it->x();
|
||||
memcpy(&wkb[position],&x,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
y=it->y();
|
||||
memcpy(&wkb[position],&y,sizeof(double));
|
||||
}
|
||||
f->setGeometry(&wkb[0],size);
|
||||
|
||||
//add the fields to the QgsFeature
|
||||
std::vector<QgsField> fields=vlayer->fields();
|
||||
for(std::vector<QgsField>::iterator it=fields.begin();it!=fields.end();++it)
|
||||
{
|
||||
f->addAttribute((*it).name(),vlayer->getDefaultValue(it->name(), f));
|
||||
}
|
||||
|
||||
if(f->attributeDialog())
|
||||
{
|
||||
vlayer->addFeature(f);
|
||||
}
|
||||
|
||||
//delete the acetate objects and the elements of mCaptureList
|
||||
removeEditingAcetates();
|
||||
refresh();
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
if(e->button()==Qt::RightButton)
|
||||
{
|
||||
//create QgsFeature with wkb representation
|
||||
QgsFeature* f=new QgsFeature(0,"WKBLineString");
|
||||
unsigned char* wkb;
|
||||
int size;
|
||||
if(mCanvasProperties->mapTool==QGis::CaptureLine)
|
||||
{
|
||||
size=1+2*sizeof(int)+2*mCaptureList.size()*sizeof(double);
|
||||
wkb= new unsigned char[size];
|
||||
int wkbtype=QGis::WKBLineString;
|
||||
int length=mCaptureList.size();
|
||||
memcpy(&wkb[1],&wkbtype, sizeof(int));
|
||||
memcpy(&wkb[5],&length, sizeof(int));
|
||||
int position=1+2*sizeof(int);
|
||||
double x,y;
|
||||
for(std::list<QgsPoint>::iterator it=mCaptureList.begin();it!=mCaptureList.end();++it)
|
||||
{
|
||||
x=it->x();
|
||||
memcpy(&wkb[position],&x,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
y=it->y();
|
||||
memcpy(&wkb[position],&y,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
}
|
||||
}
|
||||
else//polygon
|
||||
{
|
||||
size=1+3*sizeof(int)+2*(mCaptureList.size()+1)*sizeof(double);
|
||||
wkb= new unsigned char[size];
|
||||
int wkbtype=QGis::WKBPolygon;
|
||||
int length=mCaptureList.size()+1;//+1 because the first point is needed twice
|
||||
int numrings=1;
|
||||
memcpy(&wkb[1],&wkbtype, sizeof(int));
|
||||
memcpy(&wkb[5],&numrings,sizeof(int));
|
||||
memcpy(&wkb[9],&length, sizeof(int));
|
||||
int position=1+3*sizeof(int);
|
||||
double x,y;
|
||||
std::list<QgsPoint>::iterator it;
|
||||
for(it=mCaptureList.begin();it!=mCaptureList.end();++it)
|
||||
{
|
||||
x=it->x();
|
||||
memcpy(&wkb[position],&x,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
y=it->y();
|
||||
memcpy(&wkb[position],&y,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
}
|
||||
//close the polygon
|
||||
it=mCaptureList.begin();
|
||||
x=it->x();
|
||||
memcpy(&wkb[position],&x,sizeof(double));
|
||||
position+=sizeof(double);
|
||||
y=it->y();
|
||||
memcpy(&wkb[position],&y,sizeof(double));
|
||||
}
|
||||
f->setGeometry(&wkb[0],size);
|
||||
|
||||
//add the fields to the QgsFeature
|
||||
std::vector<QgsField> fields=vlayer->fields();
|
||||
for(std::vector<QgsField>::iterator it=fields.begin();it!=fields.end();++it)
|
||||
{
|
||||
f->addAttribute((*it).name(),vlayer->getDefaultValue(it->name(), f));
|
||||
}
|
||||
|
||||
if(f->attributeDialog())
|
||||
{
|
||||
vlayer->addFeature(f);
|
||||
}
|
||||
|
||||
//delete the acetate objects and the elements of mCaptureList
|
||||
removeEditingAcetates();
|
||||
refresh();
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -1605,12 +1629,12 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
{
|
||||
QgsPoint point = mCanvasProperties->coordXForm->toMapCoordinates(e->x(), e->y());
|
||||
|
||||
if ( !mMeasure ) {
|
||||
mMeasure = new QgsMeasure(this, topLevelWidget() );
|
||||
}
|
||||
mMeasure->addPoint(point);
|
||||
mMeasure->show();
|
||||
break;
|
||||
if ( !mMeasure ) {
|
||||
mMeasure = new QgsMeasure(this, topLevelWidget() );
|
||||
}
|
||||
mMeasure->addPoint(point);
|
||||
mMeasure->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1723,7 +1747,7 @@ void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e)
|
||||
{
|
||||
if ( mMeasure ) {
|
||||
QgsPoint point = mCanvasProperties->coordXForm->toMapCoordinates(e->pos().x(), e->pos().y());
|
||||
mMeasure->mouseMove(point);
|
||||
mMeasure->mouseMove(point);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1740,7 +1764,7 @@ void QgsMapCanvas::setMapTool(int tool)
|
||||
{
|
||||
mCanvasProperties->mapTool = tool;
|
||||
if ( tool == QGis::EmitPoint ) {
|
||||
setCursor ( Qt::CrossCursor );
|
||||
setCursor ( Qt::CrossCursor );
|
||||
}
|
||||
} // setMapTool
|
||||
|
||||
@ -2123,7 +2147,7 @@ void QgsMapCanvas::recalculateExtents()
|
||||
std::cout << "Input extent: " << lyr->extent().stringRep() << std::endl;
|
||||
try
|
||||
{
|
||||
std::cout << "Transformed extent" << lyr->coordinateTransform()->transform(lyr->extent()) << std::endl;
|
||||
std::cout << "Transformed extent" << lyr->coordinateTransform()->transform(lyr->extent(), QgsCoordinateTransform::FORWARD) << std::endl;
|
||||
}
|
||||
catch (QgsCsException &e)
|
||||
{
|
||||
|
@ -20,9 +20,14 @@
|
||||
#include <qcombobox.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qspinbox.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qradiobutton.h>
|
||||
#include <qapplication.h>
|
||||
#include <qtextbrowser.h>
|
||||
#include "qgsoptions.h"
|
||||
#include "qgisapp.h"
|
||||
#include "qgssvgcache.h"
|
||||
#include "qgslayerprojectionselector.h"
|
||||
/**
|
||||
* \class QgsOptions - Set user options and preferences
|
||||
* Constructor
|
||||
@ -30,27 +35,41 @@
|
||||
QgsOptions::QgsOptions(QWidget *parent, const char *name) : QgsOptionsBase(parent, name)
|
||||
{
|
||||
qparent = parent;
|
||||
// read the current browser and set it
|
||||
QSettings settings;
|
||||
QString browser = settings.readEntry("/qgis/browser");
|
||||
cmbBrowser->setCurrentText(browser);
|
||||
// set the show splash option
|
||||
int identifyValue = settings.readNumEntry("/qgis/map/identifyRadius");
|
||||
spinBoxIdentifyValue->setValue(identifyValue);
|
||||
bool hideSplashFlag = false;
|
||||
if (settings.readEntry("/qgis/hideSplash")=="true")
|
||||
{
|
||||
hideSplashFlag =true;
|
||||
}
|
||||
cbxHideSplash->setChecked(hideSplashFlag);
|
||||
|
||||
// set the current theme
|
||||
cmbTheme->setCurrentText(settings.readEntry("/qgis/theme"));
|
||||
// set the SVG oversampling factor
|
||||
spbSVGOversampling->setValue(QgsSVGCache::instance().getOversampling());
|
||||
// set the display update threshold
|
||||
spinBoxUpdateThreshold->setValue(settings.readNumEntry("/qgis/map/updateThreshold"));
|
||||
|
||||
// read the current browser and set it
|
||||
QSettings settings;
|
||||
QString browser = settings.readEntry("/qgis/browser");
|
||||
cmbBrowser->setCurrentText(browser);
|
||||
// set the show splash option
|
||||
int identifyValue = settings.readNumEntry("/qgis/map/identifyRadius");
|
||||
spinBoxIdentifyValue->setValue(identifyValue);
|
||||
bool hideSplashFlag = false;
|
||||
if (settings.readEntry("/qgis/hideSplash")=="true")
|
||||
{
|
||||
hideSplashFlag =true;
|
||||
}
|
||||
cbxHideSplash->setChecked(hideSplashFlag);
|
||||
|
||||
// set the current theme
|
||||
cmbTheme->setCurrentText(settings.readEntry("/qgis/theme"));
|
||||
// set the SVG oversampling factor
|
||||
spbSVGOversampling->setValue(QgsSVGCache::instance().getOversampling());
|
||||
// set the display update threshold
|
||||
spinBoxUpdateThreshold->setValue(settings.readNumEntry("/qgis/map/updateThreshold"));
|
||||
//set the default projection behaviour radio buttongs
|
||||
if (settings.readEntry("/qgis/projections/defaultBehaviour")=="prompt")
|
||||
{
|
||||
radPromptForProjection->setChecked(true);
|
||||
}
|
||||
else if (settings.readEntry("/qgis/projections/defaultBehaviour")=="useProject")
|
||||
{
|
||||
radUseProjectProjection->setChecked(true);
|
||||
}
|
||||
else //useGlobal
|
||||
{
|
||||
radUseGlobalProjection->setChecked(true);
|
||||
}
|
||||
mGlobalWKT = settings.readEntry("/qgis/projections/defaultProjectionWKT");
|
||||
txtGlobalWKT->setText(mGlobalWKT);
|
||||
}
|
||||
//! Destructor
|
||||
QgsOptions::~QgsOptions(){}
|
||||
@ -66,6 +85,110 @@ QString QgsOptions::theme()
|
||||
// returns the current theme (as selected in the cmbTheme combo box)
|
||||
return cmbTheme->currentText();
|
||||
}
|
||||
|
||||
void QgsOptions::saveOptions()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.writeEntry("/qgis/browser", cmbBrowser->currentText());
|
||||
settings.writeEntry("/qgis/map/identifyRadius", spinBoxIdentifyValue->value());
|
||||
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
|
||||
settings.writeEntry("/qgis/new_layers_visible",!chkAddedVisibility->isChecked());
|
||||
if(cmbTheme->currentText().length() == 0)
|
||||
{
|
||||
settings.writeEntry("/qgis/theme", "default");
|
||||
}else{
|
||||
settings.writeEntry("/qgis/theme",cmbTheme->currentText());
|
||||
}
|
||||
settings.writeEntry("/qgis/map/updateThreshold", spinBoxUpdateThreshold->value());
|
||||
QgsSVGCache::instance().setOversampling(spbSVGOversampling->value());
|
||||
settings.writeEntry("/qgis/svgoversampling", spbSVGOversampling->value());
|
||||
//check behaviour so default projection when new layer is added with no
|
||||
//projection defined...
|
||||
if (radPromptForProjection->isChecked())
|
||||
{
|
||||
//
|
||||
settings.writeEntry("/qgis/projections/defaultBehaviour", "prompt");
|
||||
}
|
||||
else if(radUseProjectProjection->isChecked())
|
||||
{
|
||||
//
|
||||
settings.writeEntry("/qgis/projections/defaultBehaviour", "useProject");
|
||||
}
|
||||
else //assumes radUseGlobalProjection is checked
|
||||
{
|
||||
//
|
||||
settings.writeEntry("/qgis/projections/defaultBehaviour", "useGlobal");
|
||||
}
|
||||
settings.writeEntry("/qgis/projections/defaultProjectionWKT",mGlobalWKT);
|
||||
|
||||
//all done
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
void QgsOptions::cbxHideSplash_toggled( bool )
|
||||
{
|
||||
|
||||
}
|
||||
void QgsOptions::addTheme(QString item)
|
||||
{
|
||||
cmbTheme->insertItem(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QgsOptions::setCurrentTheme()
|
||||
{
|
||||
QSettings settings;
|
||||
cmbTheme->setCurrentText(settings.readEntry("/qgis/theme","default"));
|
||||
}
|
||||
|
||||
void QgsOptions::findBrowser()
|
||||
{
|
||||
QString filter;
|
||||
#ifdef WIN32
|
||||
filter = "Applications (*.exe)";
|
||||
#else
|
||||
filter = "All Files (*)";
|
||||
#endif
|
||||
QString browser = QFileDialog::getOpenFileName(
|
||||
"./",
|
||||
filter,
|
||||
this,
|
||||
"open file dialog",
|
||||
"Choose a browser" );
|
||||
if(browser.length() > 0)
|
||||
{
|
||||
cmbBrowser->setCurrentText(browser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QgsOptions::pbnSelectProjection_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector();
|
||||
mySelector->setSelectedWKT(mGlobalWKT);
|
||||
if(mySelector->exec())
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "------ Global Default Projection Selection Set ----------" << std::endl;
|
||||
#endif
|
||||
mGlobalWKT = mySelector->getCurrentWKT();
|
||||
txtGlobalWKT->setText(mGlobalWKT);
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "------ Global Default Projection now set to ----------\n" << mGlobalWKT << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "------ Global Default Projection Selection change cancelled ----------" << std::endl;
|
||||
#endif
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
}
|
||||
// Return state of the visibility flag for newly added layers. If
|
||||
|
||||
bool QgsOptions::newVisible()
|
||||
|
@ -44,20 +44,30 @@ class QgsOptions :public QgsOptionsBase{
|
||||
* @return theme name (a directory name in the themes directory)
|
||||
*/
|
||||
QString theme();
|
||||
|
||||
public slots:
|
||||
//! Slot to change the theme this is handled when the user
|
||||
// activates or highlights a theme name in the drop-down list
|
||||
void themeChanged(const QString &);
|
||||
//! Slot called when user chooses to change the project wide projection.
|
||||
void pbnSelectProjection_clicked();
|
||||
void findBrowser();
|
||||
void setCurrentTheme();
|
||||
void addTheme(QString item);
|
||||
void cbxHideSplash_toggled( bool );
|
||||
void saveOptions();
|
||||
|
||||
/**
|
||||
* Return the desired state of newly added layers. If a layer
|
||||
* is to be drawn when added to the map, this function returns
|
||||
* true.
|
||||
*/
|
||||
bool newVisible();
|
||||
|
||||
public slots:
|
||||
//! Slot to change the theme this is handled when the user
|
||||
// activates or highlights a theme name in the drop-down list
|
||||
void themeChanged(const QString &);
|
||||
private:
|
||||
//! Pointer to our parent
|
||||
QWidget *qparent;
|
||||
//!Global default projection used for new layers added that have no projection
|
||||
QString mGlobalWKT;
|
||||
};
|
||||
|
||||
#endif // #ifndef QGSOPTIONS_H
|
||||
|
File diff suppressed because one or more lines are too long
@ -15,38 +15,9 @@
|
||||
|
||||
void QgsOptionsBase::init()
|
||||
{
|
||||
// read the current browser and set it
|
||||
QSettings settings;
|
||||
QString browser = settings.readEntry("/qgis/browser");
|
||||
cmbBrowser->setCurrentText(browser);
|
||||
int identifyValue = settings.readNumEntry("/qgis/map/identifyRadius");
|
||||
spinBoxIdentifyValue->setValue(identifyValue);
|
||||
bool hideSplashFlag = false;
|
||||
if (settings.readEntry("/qgis/hideSplash")=="true")
|
||||
{
|
||||
hideSplashFlag =true;
|
||||
}
|
||||
cbxHideSplash->setChecked(hideSplashFlag);
|
||||
// set the visibility flag for newly added layers
|
||||
chkAddedVisibility->setChecked(!settings.readBoolEntry("/qgis/new_layers_visible", true));
|
||||
}
|
||||
void QgsOptionsBase::saveOptions()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.writeEntry("/qgis/browser", cmbBrowser->currentText());
|
||||
settings.writeEntry("/qgis/map/identifyRadius", spinBoxIdentifyValue->value());
|
||||
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
|
||||
settings.writeEntry("/qgis/new_layers_visible",!chkAddedVisibility->isChecked());
|
||||
if(cmbTheme->currentText().length() == 0)
|
||||
{
|
||||
settings.writeEntry("/qgis/theme", "default");
|
||||
}else{
|
||||
settings.writeEntry("/qgis/theme",cmbTheme->currentText());
|
||||
}
|
||||
settings.writeEntry("/qgis/map/updateThreshold", spinBoxUpdateThreshold->value());
|
||||
QgsSVGCache::instance().setOversampling(spbSVGOversampling->value());
|
||||
settings.writeEntry("/qgis/svgoversampling", spbSVGOversampling->value());
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +27,6 @@ void QgsOptionsBase::cbxHideSplash_toggled( bool )
|
||||
}
|
||||
void QgsOptionsBase::addTheme(QString item)
|
||||
{
|
||||
cmbTheme->insertItem(item);
|
||||
}
|
||||
|
||||
|
||||
@ -67,26 +37,15 @@ void QgsOptionsBase::themeChanged(const QString & )
|
||||
|
||||
void QgsOptionsBase::setCurrentTheme()
|
||||
{
|
||||
QSettings settings;
|
||||
cmbTheme->setCurrentText(settings.readEntry("/qgis/theme","default"));
|
||||
}
|
||||
|
||||
void QgsOptionsBase::findBrowser()
|
||||
{
|
||||
QString filter;
|
||||
#ifdef WIN32
|
||||
filter = "Applications (*.exe)";
|
||||
#else
|
||||
filter = "All Files (*)";
|
||||
#endif
|
||||
QString browser = QFileDialog::getOpenFileName(
|
||||
"./",
|
||||
filter,
|
||||
this,
|
||||
"open file dialog",
|
||||
"Choose a browser" );
|
||||
if(browser.length() > 0)
|
||||
{
|
||||
cmbBrowser->setCurrentText(browser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QgsOptionsBase::pbnSelectProjection_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ mUri(uri)
|
||||
.arg(PQhost(mPgConnection))
|
||||
.arg(PQuser(mPgConnection));
|
||||
mOwnConnection = true; // we own this connection since we created it
|
||||
// tell the DB that we want text encoded in UTF8
|
||||
PQsetClientEncoding(mPgConnection, "UNICODE");
|
||||
lblDataUri->setText(datasource);
|
||||
populateFields();
|
||||
}
|
||||
@ -97,7 +99,7 @@ void QgsPgQueryBuilder::populateFields()
|
||||
// Populate the field vector for this layer. The field vector contains
|
||||
// field name, type, length, and precision (if numeric)
|
||||
QString sql = "select * from " + mUri->schema + "." + mUri->table + " limit 1";
|
||||
PGresult *result = PQexec(mPgConnection, (const char *) sql);
|
||||
PGresult *result = PQexec(mPgConnection, (const char *) (sql.utf8()));
|
||||
qWarning("Query executed: " + sql);
|
||||
if (PQresultStatus(result) == PGRES_TUPLES_OK)
|
||||
{
|
||||
@ -111,22 +113,25 @@ void QgsPgQueryBuilder::populateFields()
|
||||
int fieldModifier = PQfmod(result, i);
|
||||
QString sql = "select typelem from pg_type where typelem = " + typOid + " and typlen = -1";
|
||||
// //--std::cout << sql << std::endl;
|
||||
PGresult *oidResult = PQexec(mPgConnection, (const char *) sql);
|
||||
PGresult *oidResult = PQexec(mPgConnection,
|
||||
(const char *) (sql.utf8()));
|
||||
if (PQresultStatus(oidResult) == PGRES_TUPLES_OK)
|
||||
std::cerr << "Ok fetching typelem using\n" << sql << std::endl;
|
||||
|
||||
// get the oid of the "real" type
|
||||
QString poid = PQgetvalue(oidResult, 0, PQfnumber(oidResult, "typelem"));
|
||||
QString poid = QString::fromUtf8(PQgetvalue(oidResult, 0,
|
||||
PQfnumber(oidResult,
|
||||
"typelem")));
|
||||
std::cerr << "poid is: " << poid << std::endl;
|
||||
PQclear(oidResult);
|
||||
sql = "select typname, typlen from pg_type where oid = " + poid;
|
||||
// //--std::cout << sql << std::endl;
|
||||
oidResult = PQexec(mPgConnection, (const char *) sql);
|
||||
oidResult = PQexec(mPgConnection, (const char *) (sql.utf8()));
|
||||
if (PQresultStatus(oidResult) == PGRES_TUPLES_OK)
|
||||
std::cerr << "Ok fetching typenam,etc\n";
|
||||
|
||||
QString fieldType = PQgetvalue(oidResult, 0, 0);
|
||||
QString fieldSize = PQgetvalue(oidResult, 0, 1);
|
||||
QString fieldType = QString::fromUtf8(PQgetvalue(oidResult, 0, 0));
|
||||
QString fieldSize = QString::fromUtf8(PQgetvalue(oidResult, 0, 1));
|
||||
PQclear(oidResult);
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "Field parms: Name = " + fieldName
|
||||
@ -155,14 +160,14 @@ void QgsPgQueryBuilder::getSampleValues()
|
||||
// determine the field type
|
||||
QgsField field = mFieldMap[lstFields->currentText()];
|
||||
bool isCharField = field.type().find("char") > -1;
|
||||
PGresult *result = PQexec(mPgConnection, (const char *) sql);
|
||||
PGresult *result = PQexec(mPgConnection, (const char *) (sql.utf8()));
|
||||
|
||||
if (PQresultStatus(result) == PGRES_TUPLES_OK)
|
||||
{
|
||||
int rowCount = PQntuples(result);
|
||||
for(int i=0; i < rowCount; i++)
|
||||
{
|
||||
QString value = PQgetvalue(result, i, 0);
|
||||
QString value = QString::fromUtf8(PQgetvalue(result, i, 0));
|
||||
if(isCharField)
|
||||
{
|
||||
lstValues->insertItem("'" + value + "'");
|
||||
@ -191,14 +196,14 @@ void QgsPgQueryBuilder::getAllValues()
|
||||
QgsField field = mFieldMap[lstFields->currentText()];
|
||||
bool isCharField = field.type().find("char") > -1;
|
||||
|
||||
PGresult *result = PQexec(mPgConnection, (const char *) sql);
|
||||
PGresult *result = PQexec(mPgConnection, (const char *) (sql.utf8()));
|
||||
|
||||
if (PQresultStatus(result) == PGRES_TUPLES_OK)
|
||||
{
|
||||
int rowCount = PQntuples(result);
|
||||
for(int i=0; i < rowCount; i++)
|
||||
{
|
||||
QString value = PQgetvalue(result, i, 0);
|
||||
QString value = QString::fromUtf8(PQgetvalue(result, i, 0));
|
||||
|
||||
if(isCharField)
|
||||
{
|
||||
@ -226,10 +231,10 @@ void QgsPgQueryBuilder::testSql()
|
||||
QString numRows;
|
||||
QString sql = "select count(*) from " + mUri->schema + "." + mUri->table
|
||||
+ " where " + txtSQL->text();
|
||||
PGresult *result = PQexec(mPgConnection, (const char *)sql);
|
||||
PGresult *result = PQexec(mPgConnection, (const char *)(sql.utf8()));
|
||||
if (PQresultStatus(result) == PGRES_TUPLES_OK)
|
||||
{
|
||||
numRows = PQgetvalue(result, 0, 0);
|
||||
numRows = QString::fromUtf8(PQgetvalue(result, 0, 0));
|
||||
QMessageBox::information(this, tr("Query Result"),
|
||||
tr("The where clause returned ")
|
||||
+ numRows + tr(" rows."));
|
||||
@ -252,10 +257,10 @@ long QgsPgQueryBuilder::countRecords(QString where)
|
||||
+ " where " + where;
|
||||
|
||||
long numRows;
|
||||
PGresult *result = PQexec(mPgConnection, (const char *)sql);
|
||||
PGresult *result = PQexec(mPgConnection, (const char *)(sql.utf8()));
|
||||
if (PQresultStatus(result) == PGRES_TUPLES_OK)
|
||||
{
|
||||
QString rowCount = PQgetvalue(result, 0, 0);
|
||||
QString rowCount = QString::fromUtf8(PQgetvalue(result, 0, 0));
|
||||
numRows = rowCount.toLong();
|
||||
}
|
||||
else
|
||||
|
@ -45,8 +45,7 @@ using namespace std;
|
||||
|
||||
|
||||
|
||||
static const char *const ident_ =
|
||||
"$Id$";
|
||||
static const char *const ident_ = "$Id$";
|
||||
|
||||
|
||||
|
||||
|
@ -18,6 +18,9 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "qgsprojectproperties.h"
|
||||
#include "qgsspatialreferences.h"
|
||||
#include "qgscsexception.h"
|
||||
#include "qgsprojectionselector.h"
|
||||
|
||||
//qgis includes
|
||||
#include "qgsconfig.h"
|
||||
@ -25,6 +28,7 @@
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgsmaplayerregistry.h"
|
||||
#include "qgsrenderer.h"
|
||||
#include "qgis.h"
|
||||
|
||||
//qt includes
|
||||
#include <qapplication.h>
|
||||
@ -42,111 +46,105 @@
|
||||
#include <qcheckbox.h>
|
||||
#include <qregexp.h>
|
||||
#include <qlistview.h>
|
||||
|
||||
#include <qprogressdialog.h>
|
||||
#include <qapplication.h>
|
||||
|
||||
//stdc++ includes
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
const QString GEOWKT = "GEOGCS[\"WGS 84\", "
|
||||
" DATUM[\"WGS_1984\", "
|
||||
" SPHEROID[\"WGS 84\",6378137,298.257223563, "
|
||||
" AUTHORITY[\"EPSG\",7030]], "
|
||||
" TOWGS84[0,0,0,0,0,0,0], "
|
||||
" AUTHORITY[\"EPSG\",6326]], "
|
||||
" PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",8901]], "
|
||||
" UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",9108]], "
|
||||
" AXIS[\"Lat\",NORTH], "
|
||||
" AXIS[\"Long\",EAST], "
|
||||
" AUTHORITY[\"EPSG\",4326]]";
|
||||
|
||||
QgsProjectProperties::QgsProjectProperties(QWidget *parent, const char *name)
|
||||
: QgsProjectPropertiesBase(parent, name)
|
||||
// set the default coordinate system
|
||||
//XXX this is not needed? : static const char* defaultWktKey = "Lat/Long - WGS 84";
|
||||
QgsProjectProperties::QgsProjectProperties(QWidget *parent, const char *name)
|
||||
: QgsProjectPropertiesBase(parent, name)
|
||||
{
|
||||
// out with the old
|
||||
// QgsProject::instance()->mapUnits( QgsScaleCalculator::METERS );
|
||||
// in with the new...
|
||||
QgsScaleCalculator::units myUnit = QgsProject::instance()->mapUnits();
|
||||
setMapUnits(myUnit);
|
||||
title(QgsProject::instance()->title());
|
||||
|
||||
//see if the user wants on the fly projection enabled
|
||||
int myProjectionEnabledFlag =
|
||||
QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0);
|
||||
if (myProjectionEnabledFlag==0)
|
||||
{
|
||||
cbxProjectionEnabled->setChecked(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cbxProjectionEnabled->setChecked(true);
|
||||
}
|
||||
// set the default wkt to WGS 84
|
||||
// QString defaultWkt = QgsSpatialReferences::instance()->getSrsBySrid(defaultWktKey)->srText();
|
||||
// the /selectedWKT entry stores the wkt entry selected in the list of projections
|
||||
QString srsWkt = QgsProject::instance()->readEntry("SpatialRefSys","/selectedWKT","WGS84");
|
||||
|
||||
projectionSelector->setSelectedWKT(srsWkt);
|
||||
|
||||
|
||||
//
|
||||
// If the user changes the projection for the project, we need to
|
||||
// fire a signal to each layer telling it to change its coordinateTransform
|
||||
// member's output projection. These connects I'm setting up should be
|
||||
// automatically cleaned up when this project props dialog closes
|
||||
std::map<QString, QgsMapLayer *> myMapLayers
|
||||
= QgsMapLayerRegistry::instance()->mapLayers();
|
||||
std::map<QString, QgsMapLayer *>::iterator myMapIterator;
|
||||
for ( myMapIterator = myMapLayers.begin(); myMapIterator != myMapLayers.end(); ++myMapIterator )
|
||||
{
|
||||
QgsMapLayer * myMapLayer = myMapIterator->second;
|
||||
connect(this,
|
||||
SIGNAL(setDestWKT(QString)),
|
||||
myMapLayer->coordinateTransform(),
|
||||
SLOT(setDestWKT(QString)));
|
||||
}
|
||||
|
||||
//for now we are disabling the use of projection related widgets until they are
|
||||
//ready for production use
|
||||
cbxProjectionEnabled->setEnabled(false);
|
||||
lstCoordinateSystems->setEnabled(false);
|
||||
teProjection->setEnabled(false);
|
||||
|
||||
// out with the old
|
||||
// QgsProject::instance()->mapUnits( QgsScaleCalculator::METERS );
|
||||
// in with the new...
|
||||
QgsScaleCalculator::units myUnit = QgsProject::instance()->mapUnits();
|
||||
setMapUnits(myUnit);
|
||||
title(QgsProject::instance()->title());
|
||||
|
||||
//see if the user wants on the fly projection enabled
|
||||
int myProjectionEnabledFlag =
|
||||
QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0);
|
||||
if (myProjectionEnabledFlag==0)
|
||||
{
|
||||
cbxProjectionEnabled->setChecked(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cbxProjectionEnabled->setChecked(true);
|
||||
}
|
||||
|
||||
getProjList();
|
||||
|
||||
//if the user changes the projection for the project, we need to
|
||||
//fire a signal to each layer telling it to change its coordinateTransform
|
||||
//member's output projection. These connects I'm setting up should be
|
||||
//automatically cleaned up when this project props dialog closes
|
||||
std::map<QString, QgsMapLayer *> myMapLayers = QgsMapLayerRegistry::instance()->mapLayers();
|
||||
std::map<QString, QgsMapLayer *>::iterator myMapIterator;
|
||||
for ( myMapIterator = myMapLayers.begin(); myMapIterator != myMapLayers.end(); ++myMapIterator )
|
||||
{
|
||||
QgsMapLayer * myMapLayer = myMapIterator->second;
|
||||
connect(this,
|
||||
SIGNAL(setDestWKT(QString)),
|
||||
myMapLayer->coordinateTransform(),
|
||||
SLOT(setDestWKT(QString)));
|
||||
}
|
||||
// get the manner in which the number of decimal places in the mouse
|
||||
// position display is set (manual or automatic)
|
||||
bool automaticPrecision = QgsProject::instance()->readBoolEntry("PositionPrecision","/Automatic");
|
||||
if (automaticPrecision)
|
||||
btnGrpPrecision->setButton(0);
|
||||
else
|
||||
btnGrpPrecision->setButton(1);
|
||||
|
||||
// get the manner in which the number of decimal places in the mouse
|
||||
// position display is set (manual or automatic)
|
||||
bool automaticPrecision = QgsProject::instance()->readBoolEntry("PositionPrecision","/Automatic");
|
||||
if (automaticPrecision)
|
||||
btnGrpPrecision->setButton(0);
|
||||
else
|
||||
btnGrpPrecision->setButton(1);
|
||||
int dp = QgsProject::instance()->readNumEntry("PositionPrecision", "/DecimalPlaces");
|
||||
spinBoxDP->setValue(dp);
|
||||
|
||||
int dp = QgsProject::instance()->readNumEntry("PositionPrecision", "/DecimalPlaces");
|
||||
spinBoxDP->setValue(dp);
|
||||
//get the snapping tolerance for digitising and set the control accordingly
|
||||
double mySnapTolerance = QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0);
|
||||
//leSnappingTolerance->setInputMask("000000.000000");
|
||||
leSnappingTolerance->setText(QString::number(mySnapTolerance));
|
||||
|
||||
//get the snapping tolerance for digitising and set the control accordingly
|
||||
double mySnapTolerance = QgsProject::instance()->readDoubleEntry("Digitizing","/Tolerance",0);
|
||||
//leSnappingTolerance->setInputMask("000000.000000");
|
||||
leSnappingTolerance->setText(QString::number(mySnapTolerance));
|
||||
//get the line width for digitised lines and set the control accordingly
|
||||
int myLineWidth = QgsProject::instance()->readNumEntry("Digitizing","/LineWidth",0);
|
||||
spinDigitisedLineWidth->setValue(myLineWidth);
|
||||
|
||||
//get the line width for digitised lines and set the control accordingly
|
||||
int myLineWidth = QgsProject::instance()->readNumEntry("Digitizing","/LineWidth",0);
|
||||
spinDigitisedLineWidth->setValue(myLineWidth);
|
||||
|
||||
//get the colour of digitising lines and set the button colour accordingly
|
||||
int myRedInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorRedPart",255);
|
||||
int myGreenInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0);
|
||||
int myBlueInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0);
|
||||
QColor myColour = QColor(myRedInt,myGreenInt,myBlueInt);
|
||||
pbnDigitisedLineColour->setPaletteBackgroundColor (myColour);
|
||||
|
||||
//get the colour selections and set the button colour accordingly
|
||||
myRedInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorRedPart",255);
|
||||
myGreenInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorGreenPart",255);
|
||||
myBlueInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorBluePart",0);
|
||||
myColour = QColor(myRedInt,myGreenInt,myBlueInt);
|
||||
pbnSelectionColour->setPaletteBackgroundColor (myColour);
|
||||
|
||||
//get the colour of digitising lines and set the button colour accordingly
|
||||
int myRedInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorRedPart",255);
|
||||
int myGreenInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0);
|
||||
int myBlueInt = QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0);
|
||||
QColor myColour = QColor(myRedInt,myGreenInt,myBlueInt);
|
||||
pbnDigitisedLineColour->setPaletteBackgroundColor (myColour);
|
||||
|
||||
//get the colour selections and set the button colour accordingly
|
||||
myRedInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorRedPart",255);
|
||||
myGreenInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorGreenPart",255);
|
||||
myBlueInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorBluePart",0);
|
||||
myColour = QColor(myRedInt,myGreenInt,myBlueInt);
|
||||
pbnSelectionColour->setPaletteBackgroundColor (myColour);
|
||||
}
|
||||
|
||||
QgsProjectProperties::~QgsProjectProperties()
|
||||
{}
|
||||
|
||||
|
||||
// return the map units
|
||||
QgsScaleCalculator::units QgsProjectProperties::mapUnits() const
|
||||
{
|
||||
return QgsProject::instance()->mapUnits();
|
||||
@ -156,9 +154,9 @@ QgsScaleCalculator::units QgsProjectProperties::mapUnits() const
|
||||
void QgsProjectProperties::mapUnitChange(int unit)
|
||||
{
|
||||
/*
|
||||
QgsProject::instance()->mapUnits(
|
||||
static_cast<QgsScaleCalculator::units>(unit));
|
||||
*/
|
||||
QgsProject::instance()->mapUnits(
|
||||
static_cast<QgsScaleCalculator::units>(unit));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -172,20 +170,16 @@ void QgsProjectProperties::setMapUnits(QgsScaleCalculator::units unit)
|
||||
|
||||
QString QgsProjectProperties::title() const
|
||||
{
|
||||
return titleEdit->text();
|
||||
return titleEdit->text();
|
||||
} // QgsProjectPropertires::title() const
|
||||
|
||||
|
||||
void QgsProjectProperties::title( QString const & title )
|
||||
{
|
||||
titleEdit->setText( title );
|
||||
QgsProject::instance()->title( title );
|
||||
titleEdit->setText( title );
|
||||
QgsProject::instance()->title( title );
|
||||
} // QgsProjectProperties::title( QString const & title )
|
||||
|
||||
QString QgsProjectProperties::projectionWKT()
|
||||
{
|
||||
return QgsProject::instance()->readEntry("SpatialRefSys","/WKT",GEOWKT);
|
||||
}
|
||||
|
||||
|
||||
//when user clicks apply button
|
||||
@ -197,28 +191,33 @@ void QgsProjectProperties::apply()
|
||||
QgsProject::instance()->mapUnits(
|
||||
static_cast<QgsScaleCalculator::units>(btnGrpMapUnits->id(btnGrpMapUnits->selected())));
|
||||
|
||||
// Set the project title
|
||||
QgsProject::instance()->title( title() );
|
||||
// Set the project title
|
||||
QgsProject::instance()->title( title() );
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Projection changed, notifying all layers" << std::endl;
|
||||
#endif
|
||||
//tell the project if projections are to be used or not...
|
||||
if (cbxProjectionEnabled->isChecked())
|
||||
{
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",1);
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",0);
|
||||
}
|
||||
//notify all layers the output projection has changed
|
||||
//emit setDestWKT(mProjectionsMap[cboProjection->currentText()]);
|
||||
emit setDestWKT(mProjectionsMap[lstCoordinateSystems->currentItem()->text(0)]);
|
||||
//update the project props
|
||||
//QgsProject::instance()->writeEntry("SpatialRefSys","/WKT",mProjectionsMap[cboProjection->currentText()]);
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/WKT",mProjectionsMap[lstCoordinateSystems->currentItem()->text(0)]);
|
||||
|
||||
//tell the project if projections are to be used or not...
|
||||
if (cbxProjectionEnabled->isChecked())
|
||||
{
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",1);
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",0);
|
||||
}
|
||||
// Only change the projection if there is a node in the tree
|
||||
// selected that has an srid. This prevents error if the user
|
||||
// selects a top-level node rather than an actual coordinate
|
||||
// system
|
||||
QString myWkt = projectionSelector->getCurrentWKT();
|
||||
if (myWkt)
|
||||
{
|
||||
emit setDestWKT(myWkt);
|
||||
// write the projection's wkt to the project settings rather
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/WKT",myWkt);
|
||||
// write the currently selected projections name to project settings
|
||||
QgsProject::instance()->writeEntry("SpatialRefSys","/selectedWKT",projectionSelector->getSelectedWKT());
|
||||
// set the mouse display precision method and the
|
||||
// number of decimal places for the manual option
|
||||
// Note. Qt 3.2.3 and greater have a function selectedId() that
|
||||
@ -231,300 +230,51 @@ void QgsProjectProperties::apply()
|
||||
// Announce that we may have a new display precision setting
|
||||
emit displayPrecisionChanged();
|
||||
|
||||
//set the snapping tolerance for digitising (we write as text but read will convert to a num
|
||||
QgsProject::instance()->writeEntry("Digitizing","/Tolerance",leSnappingTolerance->text());
|
||||
|
||||
//set the line width for digitised lines and set the control accordingly
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineWidth",spinDigitisedLineWidth->value());
|
||||
|
||||
//set the colour of digitising lines
|
||||
QColor myColour = pbnDigitisedLineColour->paletteBackgroundColor();
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineColorRedPart",myColour.red());
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineColorGreenPart",myColour.green());
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineColorBluePart",myColour.blue());
|
||||
}
|
||||
|
||||
//set the colour for selections
|
||||
myColour = pbnSelectionColour->paletteBackgroundColor();
|
||||
QgsProject::instance()->writeEntry("Gui","/SelectionColorRedPart",myColour.red());
|
||||
QgsProject::instance()->writeEntry("Gui","/SelectionColorGreenPart",myColour.green());
|
||||
QgsProject::instance()->writeEntry("Gui","/SelectionColorBluePart",myColour.blue());
|
||||
QgsRenderer::mSelectionColor=myColour;
|
||||
|
||||
// set the mouse display precision method and the
|
||||
// number of decimal places for the manual option
|
||||
// Note. Qt 3.2.3 and greater have a function selectedId() that
|
||||
// can be used instead of the two part technique here
|
||||
if (btnGrpPrecision->id(btnGrpPrecision->selected()) == 0)
|
||||
QgsProject::instance()->writeEntry("PositionPrecision","/Automatic", true);
|
||||
else
|
||||
QgsProject::instance()->writeEntry("PositionPrecision","/Automatic", false);
|
||||
QgsProject::instance()->writeEntry("PositionPrecision","/DecimalPlaces", spinBoxDP->value());
|
||||
// Announce that we may have a new display precision setting
|
||||
emit displayPrecisionChanged();
|
||||
|
||||
//set the snapping tolerance for digitising (we write as text but read will convert to a num
|
||||
QgsProject::instance()->writeEntry("Digitizing","/Tolerance",leSnappingTolerance->text());
|
||||
|
||||
//set the line width for digitised lines and set the control accordingly
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineWidth",spinDigitisedLineWidth->value());
|
||||
|
||||
//set the colour of digitising lines
|
||||
QColor myColour = pbnDigitisedLineColour->paletteBackgroundColor();
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineColorRedPart",myColour.red());
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineColorGreenPart",myColour.green());
|
||||
QgsProject::instance()->writeEntry("Digitizing","/LineColorBluePart",myColour.blue());
|
||||
|
||||
//set the colour for selections
|
||||
myColour = pbnSelectionColour->paletteBackgroundColor();
|
||||
QgsProject::instance()->writeEntry("Gui","/SelectionColorRedPart",myColour.red());
|
||||
QgsProject::instance()->writeEntry("Gui","/SelectionColorGreenPart",myColour.green());
|
||||
QgsProject::instance()->writeEntry("Gui","/SelectionColorBluePart",myColour.blue());
|
||||
QgsRenderer::mSelectionColor=myColour;
|
||||
|
||||
emit refresh();
|
||||
}
|
||||
|
||||
//when user clicks ok
|
||||
void QgsProjectProperties::accept()
|
||||
{
|
||||
apply();
|
||||
close();
|
||||
apply();
|
||||
close();
|
||||
}
|
||||
void QgsProjectProperties::getProjList()
|
||||
|
||||
bool QgsProjectProperties::isProjected()
|
||||
{
|
||||
//first some hard coded options in case we cant open the wkt_defs file
|
||||
mProjectionsMap["Lat/Long WGS84"] = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]";
|
||||
mProjectionsMap["Lat/Long 1924 Brazil"] = "GEOGCS[\"1924 ellipsoid\", DATUM[\"Not_specified\", SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]], AUTHORITY[\"EPSG","6022\"]], PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\",0.0174532925199433, AUTHORITY[\"EPSG","9108\"]], AUTHORITY[\"EPSG","4022\"]]";
|
||||
//...etc
|
||||
|
||||
|
||||
|
||||
std::cout << "Getting proj list " << std::endl;
|
||||
#if defined(Q_OS_MACX) || defined(WIN32)
|
||||
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
|
||||
#endif
|
||||
QString theFileNameQString = PKGDATAPATH;
|
||||
theFileNameQString += "/resources/wkt_defs.txt";
|
||||
|
||||
|
||||
QFile myQFile( theFileNameQString );
|
||||
if ( myQFile.open( IO_ReadOnly ) )
|
||||
{
|
||||
//clear the existing entries in the taxon combo first
|
||||
//cboCoordinateSystem->clear();
|
||||
//now we parse the loc file, checking each line for its taxon
|
||||
QTextStream myQTextStream( &myQFile );
|
||||
QString myCurrentLineQString;
|
||||
QStringList myQStringList;
|
||||
// setup the nodes for the list view
|
||||
geoList = new QListViewItem(lstCoordinateSystems,"Geographic Coordinate System");
|
||||
projList = new QListViewItem(lstCoordinateSystems,"Projected Coordinate System");
|
||||
|
||||
// Read the QGIS-supplied CS file
|
||||
while ( !myQTextStream.atEnd() )
|
||||
{
|
||||
myCurrentLineQString = myQTextStream.readLine(); // line of text excluding '\n'
|
||||
#ifdef QGISDEBUG
|
||||
//generates a lot of output to stdout!
|
||||
//std::cout << " Match found:" << myCurrentLineQString.ascii() << std::endl;
|
||||
#endif
|
||||
//get the user friendly name for the WKT
|
||||
QString myShortName = getWKTShortName(myCurrentLineQString);
|
||||
if (!myShortName) continue;
|
||||
mProjectionsMap[myShortName]=myCurrentLineQString;
|
||||
}
|
||||
myQFile.close();
|
||||
|
||||
// Read the users custom coordinate system (CS) file
|
||||
// Get the user home dir. On Unix, this is $HOME. On Windows and MacOSX we
|
||||
// will use the application directory.
|
||||
//
|
||||
// Note that the global cs file must exist or the user file will never
|
||||
// be read.
|
||||
//
|
||||
// XXX Check to make sure this works on OSX
|
||||
|
||||
// construct the path to the users custom CS file
|
||||
#if defined(WIN32) || defined(Q_OS_MACX)
|
||||
customCsFile = PKGDATAPATH + "/share/qgis/user_defined_cs.txt";
|
||||
#else
|
||||
|
||||
customCsFile = getenv("HOME");
|
||||
customCsFile += "/.qgis/user_defined_cs.txt";
|
||||
#endif
|
||||
QFile csQFile( customCsFile );
|
||||
if ( csQFile.open( IO_ReadOnly ) )
|
||||
{
|
||||
QTextStream userCsTextStream( &csQFile );
|
||||
|
||||
// Read the user-supplied CS file
|
||||
while ( !userCsTextStream.atEnd() )
|
||||
{
|
||||
myCurrentLineQString = userCsTextStream.readLine(); // line of text excluding '\n'
|
||||
//get the user friendly name for the WKT
|
||||
QString myShortName = getWKTShortName(myCurrentLineQString);
|
||||
mProjectionsMap[myShortName]=myCurrentLineQString;
|
||||
}
|
||||
csQFile.close();
|
||||
}
|
||||
|
||||
// end of processing users custom CS file
|
||||
|
||||
//determine the current project projection so we can select the correct entry in the combo
|
||||
QString myProjectionName = QgsProject::instance()->readEntry("SpatialRefSys","/WKT",GEOWKT);
|
||||
QString mySelectedKey = getWKTShortName(myProjectionName);
|
||||
QListViewItem * mySelectedItem = 0;
|
||||
//make sure we dont allow duplicate entries into the combo
|
||||
//cboProjection->setDuplicatesEnabled(false);
|
||||
//no add each key to our list view
|
||||
ProjectionWKTMap::Iterator myIterator;
|
||||
QListViewItem *newItem;
|
||||
for ( myIterator = mProjectionsMap.begin(); myIterator != mProjectionsMap.end(); ++myIterator )
|
||||
{
|
||||
//std::cout << "Widget map has: " <<myIterator.key().ascii() << std::endl;
|
||||
//cboProjection->insertItem(myIterator.key());
|
||||
|
||||
//XXX Add to the tree view
|
||||
if(myIterator.key().find("Lat/Long") > -1)
|
||||
{
|
||||
// this is a geographic coordinate system
|
||||
// Add it to the tree
|
||||
newItem = new QListViewItem(geoList, myIterator.key());
|
||||
if (myIterator.key()==mySelectedKey)
|
||||
{
|
||||
// this is the selected item -- store it for future use
|
||||
mySelectedItem = newItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// coordinate system is projected...
|
||||
QListViewItem *node; // node that we will add this cs to...
|
||||
|
||||
// projected coordinate systems are stored by projection type
|
||||
QStringList projectionInfo = QStringList::split(" - ", myIterator.key());
|
||||
if(projectionInfo.size() == 2)
|
||||
{
|
||||
// Get the projection name and strip white space from it so we
|
||||
// don't add empty nodes to the tree
|
||||
QString projName = projectionInfo[1].stripWhiteSpace();
|
||||
if(projName.length() == 0)
|
||||
{
|
||||
// If the projection name is blank, set the node to
|
||||
// 0 so it won't be inserted
|
||||
node = projList;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Replace the underscores with blanks
|
||||
projName = projName.replace('_', ' ');
|
||||
// Get the node for this type and add the projection to it
|
||||
// If the node doesn't exist, create it
|
||||
node = lstCoordinateSystems->findItem(projName, 0);
|
||||
if(node == 0)
|
||||
{
|
||||
// the node doesn't exist -- create it
|
||||
node = new QListViewItem(projList, projName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No projection type is specified so add it to the top-level
|
||||
// projection node
|
||||
//XXX This should never happen
|
||||
node = projList;
|
||||
}
|
||||
|
||||
// now add the coordinate system to the appropriate node
|
||||
|
||||
newItem = new QListViewItem(node, myIterator.key());
|
||||
if (myIterator.key()==mySelectedKey)
|
||||
mySelectedItem = newItem;
|
||||
}
|
||||
} //else = proj coord sys
|
||||
|
||||
|
||||
/**
|
||||
//make sure all the loaded layer WKT's and the active project projection exist in the
|
||||
//combo box too....
|
||||
std::map<QString, QgsMapLayer *> myMapLayers = QgsMapLayerRegistry::instance()->mapLayers();
|
||||
std::map<QString, QgsMapLayer *>::iterator myMapIterator;
|
||||
for ( myMapIterator = myMapLayers.begin(); myMapIterator != myMapLayers.end(); ++myMapIterator )
|
||||
{
|
||||
QgsMapLayer * myMapLayer = myMapIterator->second;
|
||||
QString myWKT = myMapLayer->getProjectionWKT();
|
||||
QString myWKTShortName = getWKTShortName(myWKT);
|
||||
//TODO add check here that CS is not already in the projections map
|
||||
//and if not append to wkt_defs file
|
||||
cboProjection->insertItem(myIterator.key());
|
||||
mProjectionsMap[myWKTShortName]=myWKT;
|
||||
}
|
||||
|
||||
//set the combo entry to the current entry for the project
|
||||
cboProjection->setCurrentText(mySelectedKey);
|
||||
*/
|
||||
lstCoordinateSystems->setCurrentItem(mySelectedItem);
|
||||
lstCoordinateSystems->ensureItemVisible(mySelectedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning( this,tr("QGIS Error"),tr("The projections file is not readable. Check you have the neccessary file permissions and try again. Only a small list of projections is currently availiable."));
|
||||
|
||||
ProjectionWKTMap::Iterator myIterator;
|
||||
for ( myIterator = mProjectionsMap.begin(); myIterator != mProjectionsMap.end(); ++myIterator )
|
||||
{
|
||||
//std::cout << "Widget map has: " <<myIterator.key().ascii() << std::endl;
|
||||
//cboProjection->insertItem(myIterator.key());
|
||||
if(myIterator.key().find("Lat/Long") > -1)
|
||||
{
|
||||
new QListViewItem(geoList, myIterator.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
new QListViewItem(projList, myIterator.key());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void QgsProjectProperties::coordinateSystemSelected( QListViewItem * theItem)
|
||||
{
|
||||
//set the text box to show the full proection spec
|
||||
std::cout << "Item selected : " << theItem->text(0) << std::endl;
|
||||
std::cout << "Item selected full wkt : " << mProjectionsMap[theItem->text(0)] << std::endl;
|
||||
QString myKey = mProjectionsMap[lstCoordinateSystems->currentItem()->text(0)];
|
||||
if (!myKey.isEmpty())
|
||||
{
|
||||
QString myFullWKT = mProjectionsMap[theItem->text(0)];
|
||||
if (!myFullWKT.isEmpty())
|
||||
{
|
||||
teProjection->setText(myFullWKT);
|
||||
}
|
||||
}
|
||||
}
|
||||
QString QgsProjectProperties::getWKTShortName(QString theWKT)
|
||||
{
|
||||
if (!theWKT) return NULL;
|
||||
if (theWKT.isEmpty()) return NULL;
|
||||
/* for example
|
||||
PROJCS["Kertau / Singapore Grid",GEOGCS["Kertau",DATUM["Kertau",SPHEROID["Everest 1830 Modified",6377304.063,300.8017]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Cassini_Soldner"],PARAMETER["latitude_of_origin",1.28764666666667],PARAMETER["central_meridian",103.853002222222],PARAMETER["false_easting",30000],PARAMETER["false_northing",30000],UNIT["metre",1]]
|
||||
|
||||
We want to pull out
|
||||
Kertau / Singapore Grid
|
||||
and
|
||||
Cassini_Soldner
|
||||
*/
|
||||
OGRSpatialReference mySpatialRefSys;
|
||||
//this is really ugly but we need to get a QString to a char**
|
||||
char * mySourceCharArrayPointer = (char*) theWKT.ascii();
|
||||
|
||||
/* Here are the possible OGR error codes :
|
||||
typedef int OGRErr;
|
||||
|
||||
#define OGRERR_NONE 0
|
||||
#define OGRERR_NOT_ENOUGH_DATA 1 --> not enough data to deserialize
|
||||
#define OGRERR_NOT_ENOUGH_MEMORY 2
|
||||
#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3
|
||||
#define OGRERR_UNSUPPORTED_OPERATION 4
|
||||
#define OGRERR_CORRUPT_DATA 5
|
||||
#define OGRERR_FAILURE 6
|
||||
#define OGRERR_UNSUPPORTED_SRS 7 */
|
||||
|
||||
OGRErr myInputResult = mySpatialRefSys.importFromWkt( & mySourceCharArrayPointer );
|
||||
if (myInputResult != OGRERR_NONE)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
//std::cout << theWKT << std::endl;
|
||||
//check if the coordinate system is projected or not
|
||||
|
||||
// if the spatial ref sys starts with GEOGCS, the coordinate
|
||||
// system is not projected
|
||||
QString myProjection,myDatum,myCoordinateSystem,myName;
|
||||
if(theWKT.find(QRegExp("^GEOGCS")) == 0)
|
||||
{
|
||||
myProjection = "Lat/Long";
|
||||
myCoordinateSystem = mySpatialRefSys.GetAttrValue("GEOGCS",0);
|
||||
myName = myProjection + " - " + myCoordinateSystem.replace('_', ' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
myProjection = mySpatialRefSys.GetAttrValue("PROJCS",0);
|
||||
myCoordinateSystem = mySpatialRefSys.GetAttrValue("PROJECTION",0);
|
||||
myName = myProjection + " - " + myCoordinateSystem.replace('_', ' ');
|
||||
}
|
||||
//std::cout << "Projection short name " << myName << std::endl;
|
||||
return myName;
|
||||
return cbxProjectionEnabled->isChecked();
|
||||
}
|
||||
|
@ -25,8 +25,9 @@
|
||||
#endif
|
||||
|
||||
#include <qgsscalecalculator.h>
|
||||
|
||||
/** Dialog to set project level properties
|
||||
#include "qgis.h"
|
||||
|
||||
/*! Dialog to set project level properties
|
||||
|
||||
@note actual state is stored in QgsProject singleton instance
|
||||
|
||||
@ -41,61 +42,51 @@ public:
|
||||
//! Destructor
|
||||
~QgsProjectProperties();
|
||||
|
||||
/** Gets the currently select map units
|
||||
/*! Gets the currently select map units
|
||||
*/
|
||||
QgsScaleCalculator::units mapUnits() const;
|
||||
|
||||
/**
|
||||
/*!
|
||||
* Set the map units
|
||||
*/
|
||||
void setMapUnits(QgsScaleCalculator::units);
|
||||
|
||||
/**
|
||||
/*!
|
||||
Every project has a title
|
||||
*/
|
||||
QString title() const;
|
||||
void title( QString const & title );
|
||||
|
||||
/** Accessor for projection */
|
||||
/*! Accessor for projection */
|
||||
QString projectionWKT();
|
||||
/** Get a short human readable name from a WKT */
|
||||
QString getWKTShortName(QString theWKT);
|
||||
/*! Indicates that the projection switch is on */
|
||||
bool QgsProjectProperties::isProjected();
|
||||
public slots:
|
||||
/**
|
||||
/*!
|
||||
* Slot called when a new button (unit) is selected
|
||||
* @param int specifying which button was selected. The button ids match the enum
|
||||
* values in QgsScaleCalculator::units
|
||||
*/
|
||||
void mapUnitChange(int);
|
||||
/**
|
||||
/*!
|
||||
* Slot called when apply button is pressed
|
||||
*/
|
||||
void apply();
|
||||
/**
|
||||
/*!
|
||||
* Slot called when ok button pressed (inherits from gui base)
|
||||
*/
|
||||
void accept();
|
||||
//! Populate the wkts map with projection names...
|
||||
void getProjList();
|
||||
|
||||
//! Slot called when user selects a different item in the projections tree
|
||||
void coordinateSystemSelected( QListViewItem * );
|
||||
|
||||
|
||||
signals:
|
||||
/** Used to notify all coordinateTransform objects to update their dest wkt because the project
|
||||
output projection system is changed */
|
||||
/*! This signal is used to notify all coordinateTransform objects to update
|
||||
* their dest wkt because the project output projection system is changed
|
||||
* @param SPATIAL_REF_SYS structure containing the parameters for the destination CS
|
||||
*/
|
||||
void setDestWKT(QString);
|
||||
// Used to tell others that the mouse display precision may have changed
|
||||
//! Signal used to inform listeners that the mouse display precision may have changed
|
||||
void displayPrecisionChanged();
|
||||
//! let listening canvases know to refresh
|
||||
void refresh();
|
||||
private:
|
||||
typedef QMap<QString,QString> ProjectionWKTMap; //wkt = well known text (see gdal/ogr)
|
||||
//stores a list of available projection definitions
|
||||
ProjectionWKTMap mProjectionsMap;
|
||||
//XXX List view items for the tree view of projections
|
||||
QListViewItem *geoList;
|
||||
QListViewItem *projList;
|
||||
//! Users custom coordinate system file
|
||||
QString customCsFile;
|
||||
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>QgsProjectPropertiesBase</class>
|
||||
<widget class="QDialog">
|
||||
<property name="name">
|
||||
@ -8,13 +8,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>689</width>
|
||||
<height>482</height>
|
||||
<width>711</width>
|
||||
<height>527</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Project Properties</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<pixmap>image0</pixmap>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -111,43 +114,22 @@
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QSplitter" row="0" column="0">
|
||||
<widget class="QTabWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>splitter1</cstring>
|
||||
<cstring>tabWidget2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>layout8</cstring>
|
||||
<cstring>tab</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QGroupBox">
|
||||
<property name="name">
|
||||
<cstring>titleBox</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Project Title</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLineEdit" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>titleEdit</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default project title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QButtonGroup">
|
||||
<widget class="QButtonGroup" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>btnGrpMapUnits</cstring>
|
||||
</property>
|
||||
@ -193,36 +175,137 @@
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QGroupBox">
|
||||
<widget class="QGroupBox" row="3" column="0">
|
||||
<property name="name">
|
||||
<cstring>groupBox2</cstring>
|
||||
<cstring>groupBox2_2</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Map Appearance</string>
|
||||
<string>Digitising Settings</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<widget class="QLabel" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1</cstring>
|
||||
<cstring>textLabel1_2_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selection Color:</string>
|
||||
<string>Line Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" row="0" column="1">
|
||||
<widget class="QLineEdit" row="0" column="2">
|
||||
<property name="name">
|
||||
<cstring>pbnSelectionColour</cstring>
|
||||
<cstring>leSnappingTolerance</cstring>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Snapping Tolerance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" row="1" column="2">
|
||||
<property name="name">
|
||||
<cstring>spinDigitisedLineWidth</cstring>
|
||||
</property>
|
||||
<property name="minValue">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" row="2" column="2">
|
||||
<property name="name">
|
||||
<cstring>pbnDigitisedLineColour</cstring>
|
||||
</property>
|
||||
<property name="paletteBackgroundColor">
|
||||
<color>
|
||||
<red>111</red>
|
||||
<green>244</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>spacer3</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<spacer row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>spacer4</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>31</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<spacer row="2" column="1">
|
||||
<property name="name">
|
||||
<cstring>spacer5</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QLabel" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Line Colour:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QButtonGroup">
|
||||
<widget class="QButtonGroup" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>btnGrpPrecision</cstring>
|
||||
</property>
|
||||
@ -301,131 +384,119 @@
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QGroupBox">
|
||||
<widget class="QGroupBox" row="4" column="0">
|
||||
<property name="name">
|
||||
<cstring>groupBox2_2</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<cstring>groupBox2</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Digitising Settings</string>
|
||||
<string>Map Appearance</string>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>pbnDigitisedLineColour</cstring>
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>157</x>
|
||||
<y>82</y>
|
||||
<width>177</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="paletteBackgroundColor">
|
||||
<color>
|
||||
<red>111</red>
|
||||
<green>244</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>82</y>
|
||||
<width>140</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Line Colour:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox">
|
||||
<property name="name">
|
||||
<cstring>spinDigitisedLineWidth</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>157</x>
|
||||
<y>53</y>
|
||||
<width>177</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minValue">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>leSnappingTolerance</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>157</x>
|
||||
<y>23</y>
|
||||
<width>177</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>53</y>
|
||||
<width>140</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Line Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2_2_2</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>23</y>
|
||||
<width>140</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Snapping Tolerance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selection Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" row="0" column="2">
|
||||
<property name="name">
|
||||
<cstring>pbnSelectionColour</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>32767</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>spacer6</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</grid>
|
||||
</widget>
|
||||
</vbox>
|
||||
<widget class="QGroupBox" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>titleBox</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Project Title</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>spacer6_2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>9</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>titleEdit</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default project title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QButtonGroup">
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>buttonGroup2</cstring>
|
||||
<cstring>tab</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<attribute name="title">
|
||||
<string>Projection</string>
|
||||
</property>
|
||||
</attribute>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
@ -438,48 +509,9 @@
|
||||
<string>Enable on the fly projection</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListView" row="1" column="0">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Coordinate Systems</string>
|
||||
</property>
|
||||
<property name="clickable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="resizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</column>
|
||||
<widget class="QgsProjectionSelector" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>lstCoordinateSystems</cstring>
|
||||
</property>
|
||||
<property name="showSortIndicator">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>teProjection</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<cstring>projectionSelector</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
@ -487,6 +519,11 @@
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<images>
|
||||
<image name="image0">
|
||||
<data format="PNG" length="593">89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000021849444154388d8d933f6853511487bf4886fb20e00b4478810e062a34e0f092adcfc988430382766bede29f0e5237c716858253079796ec2a594ad3c15a0721298a4fa72ab4f47590c6a1f0de10c8050befa00fae43882135959eed77ef39dfb9f777ef49f9becf79a3fac6332a07510dfc977e0a207daec275cfe00039d011f07db0776154c1c4f891999c3c3217331bc6c96d98d59b55d8571081ea0ce7fe0370dd2393bda479fbbec1b5ca1a4b2bdb142714ca15e880defb0fc0750f8c658584dd5d1a9b01ba23345a01739bdb70a2783056421dabb3019625843f03448420e8f616ef409808d57481fbf34516ee1587007f4d8c4f360c284820164177403d02958362c7e6c97c092b0385717b34a0381113ff8e914400452c1a350612c1f45889acd383abb48c0604fb9a92a35069458c509872c85eb15091e2ee4c1995eea213a1abcf30f146b58ed68224829581cad53caa050b3305f239858880c0e72fe16880effb297f2784a4a7db879a7a2da070d921941050345b21cd7711bedffb8543006fd6338ff75a2cadfb743bc2f4ad0225d7c1b62d0076bf45acad7c456be1d3c7553304a8bcf08c3dd5336c7bff0773cf9a047b5d1697cb44c7402288401881f9f51a918111a9fe30799e6700d46d4083ecf412b69a55caae8d24e064f234b6da3c9c6dd0fc706a98faf7aad63c23d1402f3e9d3595eb59b2399b83c380c67a1b49463c633ff42bc019e8e7cbf554ff74a79b01fc013633ebcd0e2d66c60000000049454e44ae426082</data>
|
||||
</image>
|
||||
</images>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonOk</sender>
|
||||
@ -524,23 +561,18 @@
|
||||
<receiver>QgsProjectPropertiesBase</receiver>
|
||||
<slot>pbnDigitisedLineColour_clicked()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>lstCoordinateSystems</sender>
|
||||
<signal>currentChanged(QListViewItem*)</signal>
|
||||
<receiver>QgsProjectPropertiesBase</receiver>
|
||||
<slot>coordinateSystemSelected(QListViewItem*)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">qgsprojectpropertiesbase.ui.h</include>
|
||||
</includes>
|
||||
<slots>
|
||||
<slot>mapUnitChange( int )</slot>
|
||||
<slot>projectionChanged( const QString & )</slot>
|
||||
<slot>apply()</slot>
|
||||
<slot>pbnSelectionColour_clicked()</slot>
|
||||
<slot>pbnDigitisedLineColour_clicked()</slot>
|
||||
<slot>coordinateSystemSelected( QListViewItem * )</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
<includehints>
|
||||
<includehint>qgsprojectionselector.h</includehint>
|
||||
</includehints>
|
||||
</UI>
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/****************************************************************************
|
||||
** ui.h extension file, included from the uic-generated form implementation.
|
||||
**
|
||||
@ -6,6 +7,7 @@
|
||||
** init() function in place of a constructor, and a destroy() function in
|
||||
** place of a destructor.
|
||||
*****************************************************************************/
|
||||
#include "../widgets/projectionselector/qgsprojectionselector.h"
|
||||
#include <qcolordialog.h>
|
||||
void QgsProjectPropertiesBase::mapUnitChange( int )
|
||||
{
|
||||
@ -13,13 +15,6 @@ void QgsProjectPropertiesBase::mapUnitChange( int )
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QgsProjectPropertiesBase::projectionChanged( const QString & )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QgsProjectPropertiesBase::apply()
|
||||
{
|
||||
|
||||
@ -29,19 +24,15 @@ void QgsProjectPropertiesBase::apply()
|
||||
void QgsProjectPropertiesBase::pbnSelectionColour_clicked()
|
||||
{
|
||||
pbnSelectionColour->setPaletteBackgroundColor(
|
||||
QColorDialog::getColor(pbnSelectionColour->paletteBackgroundColor(),this));
|
||||
QColorDialog::getColor(pbnSelectionColour->paletteBackgroundColor(),this));
|
||||
}
|
||||
|
||||
|
||||
void QgsProjectPropertiesBase::pbnDigitisedLineColour_clicked()
|
||||
{
|
||||
pbnDigitisedLineColour->setPaletteBackgroundColor(
|
||||
QColorDialog::getColor(pbnDigitisedLineColour->paletteBackgroundColor(),this));
|
||||
QColorDialog::getColor(pbnDigitisedLineColour->paletteBackgroundColor(),this));
|
||||
}
|
||||
|
||||
|
||||
void QgsProjectPropertiesBase::coordinateSystemSelected( QListViewItem * )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -290,6 +290,16 @@ void QgsRasterLayer::buildSupportedRasterFileFilter(QString & theFileFiltersStri
|
||||
catchallFilter += QString(myGdalDriver->GetDescription()) + " ";
|
||||
}
|
||||
}
|
||||
|
||||
// A number of drivers support JPEG 2000. Add it in for those.
|
||||
if ( myGdalDriverDescription.startsWith("MrSID")
|
||||
|| myGdalDriverDescription.startsWith("ECW")
|
||||
|| myGdalDriverDescription.startsWith("JPEG2000")
|
||||
|| myGdalDriverDescription.startsWith("JP2KAK") )
|
||||
{
|
||||
QString glob = "*.jp2 *.j2k";
|
||||
theFileFiltersString += "JPEG 2000 (" + glob.lower() + " " + glob.upper() + ");;";
|
||||
}
|
||||
|
||||
// A number of drivers support JPEG 2000. Add it in for those.
|
||||
if ( myGdalDriverDescription.startsWith("MrSID")
|
||||
@ -2367,7 +2377,6 @@ const RasterBandStats QgsRasterLayer::getRasterBandStats(int theBandNoInt)
|
||||
#endif
|
||||
|
||||
CPLFree(myData);
|
||||
|
||||
myRasterBandStats.statsGatheredFlag = true;
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
|
@ -1016,7 +1016,7 @@ private:
|
||||
@todo XXX should consider generalizing this
|
||||
*/
|
||||
QgsRasterLayerProperties * mLayerProperties;
|
||||
|
||||
|
||||
//! Pointer to the identify results dialog
|
||||
QgsIdentifyResults *mIdentifyResults;
|
||||
|
||||
|
@ -903,7 +903,6 @@ void QgsRasterLayerProperties::sync()
|
||||
|
||||
} // QgsRasterLayerProperties::sync()
|
||||
|
||||
|
||||
void QgsRasterLayerProperties::pbnHistRefresh_clicked()
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
|
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>QgsRasterLayerPropertiesBase</class>
|
||||
<widget class="QDialog">
|
||||
<property name="name">
|
||||
|
@ -39,13 +39,13 @@ QgsSingleSymRenderer::QgsSingleSymRenderer(): mItem(new QgsRenderItem())
|
||||
|
||||
QgsSingleSymRenderer::~QgsSingleSymRenderer()
|
||||
{
|
||||
delete mItem;
|
||||
delete mItem;
|
||||
}
|
||||
|
||||
void QgsSingleSymRenderer::addItem(QgsRenderItem* ri)
|
||||
{
|
||||
delete mItem;
|
||||
mItem = ri;
|
||||
delete mItem;
|
||||
mItem = ri;
|
||||
}
|
||||
|
||||
void QgsSingleSymRenderer::renderFeature(QPainter * p, QgsFeature * f, QPicture* pic,
|
||||
@ -84,13 +84,82 @@ void QgsSingleSymRenderer::renderFeature(QPainter * p, QgsFeature * f, QPicture*
|
||||
|
||||
void QgsSingleSymRenderer::initializeSymbology(QgsVectorLayer * layer, QgsDlgVectorLayerProperties * pr)
|
||||
{
|
||||
bool toproperties = false; //if false: rendererDialog is associated with the vector layer and image is rendered, true: rendererDialog is associated with buffer dialog of vector layer properties and no image is rendered
|
||||
if (pr)
|
||||
bool toproperties = false; //if false: rendererDialog is associated with the vector layer and image is rendered, true: rendererDialog is associated with buffer dialog of vector layer properties and no image is rendered
|
||||
if (pr)
|
||||
{
|
||||
toproperties = true;
|
||||
}
|
||||
|
||||
if (layer)
|
||||
{
|
||||
mVectorType = layer->vectorType();
|
||||
QgsSymbol* sy = new QgsSymbol();
|
||||
sy->brush().setStyle(Qt::SolidPattern);
|
||||
sy->pen().setStyle(Qt::SolidLine);
|
||||
sy->pen().setWidth(1);//set width 1 as default instead of width 0
|
||||
|
||||
//random fill colors for points and polygons and pen colors for lines
|
||||
int red = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
|
||||
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
|
||||
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
|
||||
|
||||
//font tor the legend text
|
||||
QFont f("arial", 10, QFont::Normal);
|
||||
QFontMetrics fm(f);
|
||||
|
||||
QPixmap *pixmap;
|
||||
if (toproperties)
|
||||
{
|
||||
toproperties = true;
|
||||
pixmap = pr->getBufferPixmap();
|
||||
}
|
||||
else
|
||||
{
|
||||
pixmap = layer->legendPixmap();
|
||||
}
|
||||
|
||||
if (layer)
|
||||
QString name = layer->name();
|
||||
int width = 40 + fm.width(layer->name());
|
||||
int height = (fm.height() + 10 > 35) ? fm.height() + 10 : 35;
|
||||
|
||||
pixmap->resize(width, height);
|
||||
pixmap->fill();
|
||||
QPainter p(pixmap);
|
||||
p.setPen(sy->pen());
|
||||
|
||||
if (layer->vectorType() == QGis::Line)
|
||||
{
|
||||
sy->pen().setColor(QColor(red, green, blue));
|
||||
//paint the pixmap for the legend
|
||||
p.setPen(sy->pen());
|
||||
p.drawLine(10, pixmap->height() - 25, 25, pixmap->height() - 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
sy->brush().setColor(QColor(red, green, blue));
|
||||
sy->pen().setColor(QColor(0, 0, 0));
|
||||
//paint the pixmap for the legend
|
||||
p.setPen(sy->pen());
|
||||
p.setBrush(sy->brush());
|
||||
if (layer->vectorType() == QGis::Point)
|
||||
{
|
||||
//p.drawRect(20, pixmap->height() - 17, 5, 5);
|
||||
QPixmap pm = sy->getPointSymbolAsPixmap();
|
||||
p.drawPixmap ( (int) (17-pm.width()/2), (int) ((pixmap->height()-pm.height())/2), pm );
|
||||
}
|
||||
else //polygon
|
||||
{
|
||||
p.drawRect(10, pixmap->height() - 25, 20, 15);
|
||||
}
|
||||
}
|
||||
|
||||
p.setPen(Qt::black);
|
||||
p.setFont(f);
|
||||
p.drawText(35, pixmap->height() - 10, name);
|
||||
QgsRenderItem* ri = new QgsRenderItem(sy, "", "");
|
||||
addItem(ri);
|
||||
|
||||
QgsSiSyDialog *dialog = new QgsSiSyDialog(layer);
|
||||
if (toproperties)
|
||||
{
|
||||
mVectorType = layer->vectorType();
|
||||
QgsSymbol* sy = new QgsSymbol();
|
||||
@ -172,8 +241,15 @@ void QgsSingleSymRenderer::initializeSymbology(QgsVectorLayer * layer, QgsDlgVec
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("Warning, null pointer in QgsSingleSymRenderer::initializeSymbology()");
|
||||
layer->setRendererDialog(dialog);
|
||||
QgsLegendItem *item;
|
||||
layer->updateItemPixmap();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("Warning, null pointer in QgsSingleSymRenderer::initializeSymbology()");
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSingleSymRenderer::readXML(const QDomNode& rnode, QgsVectorLayer& vl)
|
||||
@ -181,7 +257,7 @@ void QgsSingleSymRenderer::readXML(const QDomNode& rnode, QgsVectorLayer& vl)
|
||||
mVectorType = vl.vectorType();
|
||||
QgsSymbol* sy = new QgsSymbol();
|
||||
|
||||
QDomNode rinode = rnode.namedItem("renderitem");
|
||||
QDomNode rinode = rnode.namedItem("renderitem");
|
||||
|
||||
QDomNode vnode = rinode.namedItem("value");
|
||||
QDomElement velement = vnode.toElement();
|
||||
@ -210,31 +286,32 @@ void QgsSingleSymRenderer::readXML(const QDomNode& rnode, QgsVectorLayer& vl)
|
||||
|
||||
bool QgsSingleSymRenderer::writeXML( QDomNode & layer_node, QDomDocument & document )
|
||||
{
|
||||
bool returnval=false;
|
||||
QDomElement singlesymbol=document.createElement("singlesymbol");
|
||||
layer_node.appendChild(singlesymbol);
|
||||
if(mItem)
|
||||
{
|
||||
returnval=mItem->writeXML(singlesymbol,document);
|
||||
}
|
||||
return returnval;
|
||||
bool returnval=false;
|
||||
QDomElement singlesymbol=document.createElement("singlesymbol");
|
||||
layer_node.appendChild(singlesymbol);
|
||||
if(mItem)
|
||||
{
|
||||
returnval=mItem->writeXML(singlesymbol,document);
|
||||
}
|
||||
return returnval;
|
||||
}
|
||||
|
||||
|
||||
std::list<int> QgsSingleSymRenderer::classificationAttributes()
|
||||
{
|
||||
std::list<int> list;
|
||||
return list;//return an empty list
|
||||
std::list<int> list;
|
||||
return list;//return an empty list
|
||||
}
|
||||
|
||||
QString QgsSingleSymRenderer::name()
|
||||
{
|
||||
return "Single Symbol";
|
||||
return "Single Symbol";
|
||||
}
|
||||
|
||||
const std::list<QgsRenderItem*> QgsSingleSymRenderer::items() const
|
||||
{
|
||||
std::list<QgsRenderItem*> list;
|
||||
list.push_back(mItem);
|
||||
return list;
|
||||
std::list<QgsRenderItem*> list;
|
||||
list.push_back(mItem);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
135
src/qgsspatialreferences.cpp
Normal file
135
src/qgsspatialreferences.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/***************************************************************************
|
||||
qgspatialreferences.cpp - Singleton class for
|
||||
storing spatial reference systems
|
||||
-------------------
|
||||
begin : 2005-01-22
|
||||
copyright : (C) 2005 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
#include <iostream>
|
||||
#include <qstring.h>
|
||||
#include <qdir.h>
|
||||
#include <qmap.h>
|
||||
#include "qgsspatialreferences.h"
|
||||
|
||||
QgsSpatialReferences *QgsSpatialReferences::_instance = 0;
|
||||
QgsSpatialReferences *QgsSpatialReferences::instance()
|
||||
{
|
||||
if (_instance == 0)
|
||||
{
|
||||
_instance = new QgsSpatialReferences();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
QgsSpatialReferences::QgsSpatialReferences()
|
||||
{
|
||||
// read the spatial reference systems from disk and populate the map
|
||||
#if defined(Q_OS_MACX) || defined(WIN32)
|
||||
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
|
||||
#endif
|
||||
QString theFileNameQString = PKGDATAPATH;
|
||||
theFileNameQString += "/resources/spatial_ref_sys.txt";
|
||||
|
||||
|
||||
QFile myQFile( theFileNameQString );
|
||||
if ( myQFile.open( IO_ReadOnly ) )
|
||||
{
|
||||
QTextStream myQTextStream( &myQFile );
|
||||
QString myCurrentLineQString;
|
||||
|
||||
|
||||
// Read the QGIS-supplied CS file which is actually taken from PostGIS spatial_ref_sys
|
||||
// table. The schema for this table:
|
||||
// Table "public.spatial_ref_sys"
|
||||
// Column | Type | Modifiers
|
||||
// -----------+-------------------------+-----------
|
||||
// 0 srid | integer | not null
|
||||
// 1 auth_name | character varying(256) |
|
||||
// 2 auth_srid | integer |
|
||||
// 3 srtext | character varying(2048) |
|
||||
// 4 proj4text | character varying(2048) |
|
||||
int wktCount = 0;
|
||||
while ( !myQTextStream.atEnd() )
|
||||
{
|
||||
myCurrentLineQString = myQTextStream.readLine(); // line of text excluding '\n'
|
||||
#ifdef QGISDEBUG
|
||||
//generates a lot of output to stdout!
|
||||
//std::cout << " Match found:" << myCurrentLineQString.ascii() << std::endl;
|
||||
#endif
|
||||
|
||||
QStringList wktParts = QStringList::split(QRegExp("\t"), myCurrentLineQString, true);
|
||||
// get the short name for the projection
|
||||
QString wkt = wktParts[3];
|
||||
QString name;
|
||||
bool isGeo;
|
||||
if(wkt.find(QRegExp("^GEOGCS")) == 0)
|
||||
{
|
||||
isGeo = true;
|
||||
name = "Lat/Long - ";
|
||||
// get the name
|
||||
name += wkt.mid(8, wkt.find("\",") - 8);
|
||||
|
||||
// std::cout << name << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
isGeo = false;
|
||||
// get the name and projection type
|
||||
name = wkt.mid(8, wkt.find("\",") - 8) + " - ";
|
||||
int start = wkt.find("PROJECTION[") + 12;
|
||||
name += wkt.mid(start, wkt.find("\"]", start) - start);
|
||||
// std::cout << name << std::endl;
|
||||
|
||||
}
|
||||
// store the parts in a QgsSpatialRefSys object
|
||||
QgsSpatialRefSys *srs = new QgsSpatialRefSys(
|
||||
wktParts[0],
|
||||
wktParts[1],
|
||||
wktParts[2],
|
||||
wktParts[3],
|
||||
wktParts[4],
|
||||
name);
|
||||
srs->setGeographic(isGeo);
|
||||
mSpatialReferences[wktParts[0]] = srs;
|
||||
}
|
||||
}
|
||||
}
|
||||
QgsSpatialRefSys * QgsSpatialReferences::getSrsBySrid(QString srid)
|
||||
{
|
||||
return mSpatialReferences[srid];
|
||||
}
|
||||
|
||||
QgsSpatialRefSys * QgsSpatialReferences::getSrsByWkt(QString &wkt)
|
||||
{
|
||||
// find the srs by looking up the wkt in the map
|
||||
projectionWKTMap_t::Iterator it;
|
||||
|
||||
QgsSpatialRefSys *srs;
|
||||
for ( it = mSpatialReferences.begin(); it != mSpatialReferences.end(); ++it )
|
||||
{
|
||||
srs = *it;
|
||||
if(srs->srText() == wkt)
|
||||
{
|
||||
return srs;
|
||||
}
|
||||
}
|
||||
// if we don't find a match, return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
projectionWKTMap_t QgsSpatialReferences::getMap()
|
||||
{
|
||||
return mSpatialReferences;
|
||||
}
|
67
src/qgsspatialreferences.h
Normal file
67
src/qgsspatialreferences.h
Normal file
@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
qgsspatialreferencesystems.h - Singleton class for
|
||||
Spatial reference systems
|
||||
-------------------
|
||||
begin : 2005-01-22
|
||||
copyright : (C) 2005 by Gary E.Sherman
|
||||
email : sherman at mrcc.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef QGSSPATIALREFERENCESYSTEMS_H
|
||||
#define QGSSPATIALREFERENCESYSTEMS_H
|
||||
#include <qmap.h>
|
||||
#include "qgsspatialrefsys.h"
|
||||
class QString;
|
||||
//! Typedef for map containing spatial reference system objects
|
||||
typedef QMap<QString,QgsSpatialRefSys*> projectionWKTMap_t ; //wkt = well known text (see gdal/ogr)
|
||||
/*!
|
||||
* \class QgsSpatialReferences
|
||||
* \brief Singleton class to manage spatial reference systems
|
||||
*/
|
||||
class QgsSpatialReferences
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Function to return the instance pointer to the singleton QgsSpatialReferences
|
||||
* class. On first call to instance(), the object is constructed and the spatial
|
||||
* references read from the share/qgis/resources/spatial_ref_sys.txt
|
||||
* @return Pointer to the one and only QgsSpatialReferences instance
|
||||
*/
|
||||
static QgsSpatialReferences* instance();
|
||||
/*!
|
||||
* Get a spatial reference system using its spatial reference id (SRID)
|
||||
* @return Pointer to a spatial reference system matching the specified SRID
|
||||
*/
|
||||
QgsSpatialRefSys * getSrsBySrid(QString srid);
|
||||
/*!
|
||||
* Get a spatial reference system using its well known text (WKT) specification.
|
||||
* @return Pointer to a spatial reference system matching the specified WKT
|
||||
*/
|
||||
QgsSpatialRefSys * getSrsByWkt(QString &wkt);
|
||||
/*!
|
||||
* Get the map containing the collection of spatial reference systems
|
||||
* @return The map of spatial reference systems
|
||||
*/
|
||||
projectionWKTMap_t getMap();
|
||||
|
||||
protected:
|
||||
//! Protected constructor
|
||||
QgsSpatialReferences();
|
||||
private:
|
||||
//! Instance member pointer
|
||||
static QgsSpatialReferences* _instance;
|
||||
//! Map containing the spatial reference systems read from the spatial_ref_sys file
|
||||
projectionWKTMap_t mSpatialReferences;
|
||||
};
|
||||
#endif // QGSSPATIALREFERENCESYSTEMS_H
|
||||
|
64
src/qgsspatialrefsys.cpp
Normal file
64
src/qgsspatialrefsys.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "qgsspatialrefsys.h"
|
||||
QgsSpatialRefSys::QgsSpatialRefSys(){}
|
||||
QgsSpatialRefSys::QgsSpatialRefSys(QString srid, QString authName, QString authSrid,
|
||||
QString srtext, QString proj4Text, QString name):mSrid(srid), mAuthName(authName), mAuthSrid(authSrid), mSrtext(srtext), mProj4text(proj4Text), mName(name)
|
||||
{
|
||||
}
|
||||
QString QgsSpatialRefSys::srid() const
|
||||
{
|
||||
return mSrid;
|
||||
}
|
||||
|
||||
QString QgsSpatialRefSys::authName() const
|
||||
{
|
||||
return mAuthName;
|
||||
}
|
||||
QString QgsSpatialRefSys::authSrid() const
|
||||
{
|
||||
return mAuthSrid;
|
||||
}
|
||||
QString QgsSpatialRefSys::srText() const
|
||||
{
|
||||
return mSrtext;
|
||||
}
|
||||
QString QgsSpatialRefSys::proj4Text() const
|
||||
{
|
||||
return mProj4text;
|
||||
}
|
||||
QString QgsSpatialRefSys::name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
void QgsSpatialRefSys::setSrid(QString& srid)
|
||||
{
|
||||
mSrid = srid;
|
||||
}
|
||||
void QgsSpatialRefSys::setAuthName(QString &authname)
|
||||
{
|
||||
mAuthName = authname;
|
||||
}
|
||||
void QgsSpatialRefSys::setAuthSrid(QString &authsrid)
|
||||
{
|
||||
mAuthSrid = authsrid;
|
||||
}
|
||||
void QgsSpatialRefSys::setSrText(QString &srtext)
|
||||
{
|
||||
mSrtext = srtext;
|
||||
}
|
||||
void QgsSpatialRefSys::setProjText(QString &projtext)
|
||||
{
|
||||
mProj4text = projtext;
|
||||
}
|
||||
void QgsSpatialRefSys::setName(QString &shortname)
|
||||
{
|
||||
mName = shortname;
|
||||
}
|
||||
bool QgsSpatialRefSys::isGeographic()
|
||||
{
|
||||
return mGeographic;
|
||||
}
|
||||
void QgsSpatialRefSys::setGeographic(bool isGeogCS)
|
||||
{
|
||||
mGeographic = isGeogCS;
|
||||
}
|
135
src/qgsspatialrefsys.h
Normal file
135
src/qgsspatialrefsys.h
Normal file
@ -0,0 +1,135 @@
|
||||
#ifndef QGSSPATIALREFSYS_H
|
||||
#define QGSSPATIALREFSYS_H
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
#include <qstring.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qregexp.h>
|
||||
/*!
|
||||
* \class QgsSpatialRefSys
|
||||
* \brief Class for storing a spatial reference system (SRS)
|
||||
*/
|
||||
class QgsSpatialRefSys
|
||||
{
|
||||
public:
|
||||
//! Default constructor
|
||||
|
||||
QgsSpatialRefSys();
|
||||
/*!
|
||||
* Constructs a SRS object from the five component parts
|
||||
* @param srid Spatial reference id (SRID)
|
||||
* @param authName Name of the authority for the SRS
|
||||
* @param authSrid SRID of the SRS assigned by the authority
|
||||
* @param srtext Well known text (WKT) of the SRS
|
||||
* @param proj4text Proj4 parameter string
|
||||
*/
|
||||
QgsSpatialRefSys(QString srid, QString authName, QString authSrid, QString srtext, QString proj4text, QString name);
|
||||
/*!
|
||||
* Get the SRID
|
||||
* @return SRID of the SRS
|
||||
*/
|
||||
QString srid() const;
|
||||
/*!
|
||||
* Get the authority name
|
||||
* @return authority name of the SRS creator
|
||||
*/
|
||||
QString authName() const;
|
||||
/*!
|
||||
* Get the SRID assigned by the SRS creator
|
||||
* @return SRID
|
||||
*/
|
||||
QString authSrid() const;
|
||||
/*!
|
||||
* Get the WKT of the SRS
|
||||
* @return Well known text of the SRS
|
||||
*/
|
||||
QString srText() const;
|
||||
/*!
|
||||
* Get the proj4 parameter string for the SRS
|
||||
* @return proj4 parameters
|
||||
*/
|
||||
QString proj4Text() const;
|
||||
/*!
|
||||
* Get the short name of the projection
|
||||
* @return name including the projection system
|
||||
*/
|
||||
QString name() const;
|
||||
/*!
|
||||
* Test to see if the SRS is geographic
|
||||
* @return true if geographic or false if the SRS is projected
|
||||
*/
|
||||
bool isGeographic();
|
||||
/*!
|
||||
* Set the flag to indicate if the SRS is geographic
|
||||
* @param isGeo true if the SRS is geographic; false if its projected
|
||||
*/
|
||||
void setGeographic(bool isGeo);
|
||||
/*!
|
||||
* Set the SRID
|
||||
* @param srid Spatial reference id to assign to the object
|
||||
*/
|
||||
void setSrid(QString &srid);
|
||||
/*!
|
||||
* Set the authority name
|
||||
* @param authname Authority name
|
||||
*/
|
||||
void setAuthName(QString &authname);
|
||||
/*!
|
||||
* Set the authority assigned SRID
|
||||
* @param authsrid Authority assigned SRID
|
||||
*/
|
||||
void setAuthSrid(QString &authsrid);
|
||||
/*!
|
||||
* Set the WKT
|
||||
* @param srtext Well known text of the SRS
|
||||
*/
|
||||
void setSrText(QString &srtext);
|
||||
/*!
|
||||
* Set the Proj4 parameters
|
||||
* @param projtext Proj4 parameter string
|
||||
*/
|
||||
void setProjText(QString &projtext);
|
||||
/*!
|
||||
* Set the short name
|
||||
* @param shortname Short name of the SRS
|
||||
*/
|
||||
void setName(QString &shortname);
|
||||
private:
|
||||
//! SRID
|
||||
QString mSrid;
|
||||
//! Authority name
|
||||
QString mAuthName;
|
||||
//! Authority assigned SRID
|
||||
QString mAuthSrid;
|
||||
//! WKT for the SRS
|
||||
QString mSrtext;
|
||||
//! Proj4 paramters
|
||||
QString mProj4text;
|
||||
//! Short name
|
||||
QString mName;
|
||||
//! Flag to indicate if the SRS is geographic (unprojected)
|
||||
bool mGeographic;
|
||||
};
|
||||
//! Output stream operator
|
||||
inline std::ostream& operator << (std::ostream& os, const QgsSpatialRefSys &r)
|
||||
{
|
||||
return os << r.srid() << "\t" << r.authName() << "\t" << r.authSrid()
|
||||
<< "\t" << r.srText() << "\t" << r.proj4Text() << "\t" << r.name() << std::endl;
|
||||
}
|
||||
//! Input stream operator
|
||||
inline std::istream& operator>> (std::istream& str, QgsSpatialRefSys& r)
|
||||
{
|
||||
std::string s;
|
||||
str >> s;
|
||||
QString srs = s.c_str();
|
||||
// split the string into the parts to created the object
|
||||
QStringList parts = QStringList::split(QRegExp("\t"),srs);
|
||||
r.setSrid(parts[0]);
|
||||
r.setAuthName(parts[1]);
|
||||
r.setAuthSrid(parts[2]);
|
||||
r.setSrText(parts[3]);
|
||||
r.setProjText(parts[4]);
|
||||
r.setName(parts[5]);
|
||||
return str;
|
||||
}
|
||||
#endif // QGSSPATIALREFSYS_H
|
@ -26,31 +26,31 @@ QgsVectorDataProvider::QgsVectorDataProvider(): mEncoding(QTextCodec::codecForLo
|
||||
|
||||
bool QgsVectorDataProvider::addFeatures(std::list<QgsFeature*> flist)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsVectorDataProvider::deleteFeatures(std::list<int> const & id)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsVectorDataProvider::addAttributes(std::map<QString,QString> const & name)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsVectorDataProvider::deleteAttributes(std::set<QString> const & name)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QgsVectorDataProvider::changeAttributeValues(std::map<int,std::map<QString,QString> > const & attr_map)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QgsVectorDataProvider::getDefaultValue(const QString& attr,
|
||||
QgsFeature* f) {
|
||||
QgsFeature* f) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -181,6 +181,39 @@ class QgsVectorDataProvider : public QgsDataProvider
|
||||
void setEncoding(const QString& e);
|
||||
QString encoding() const;
|
||||
|
||||
/*! Indicates if the provider does its own coordinate transforms
|
||||
* @return true if the provider transforms its coordinates, otherwise false
|
||||
*/
|
||||
virtual bool supportsNativeTransform(){return false;};
|
||||
/*! Used to determine if the provider supports transformation using the
|
||||
* SRID of the target SRS.
|
||||
* @return true if SRID is used, otherwise false
|
||||
*/
|
||||
virtual bool usesSrid(){return false;};
|
||||
/*! Used to determine if the provider supports transformation using the
|
||||
* WKT of the target SRS.
|
||||
* @return true if WKT is used, otherwise false
|
||||
*/
|
||||
virtual bool usesWKT(){return false;};
|
||||
/*! Set the SRID of the target SRS.
|
||||
* This is only implemented if the provider supports native
|
||||
* transformation of its coordinates
|
||||
* @param srid Spatial reference id of the target (map canvas)
|
||||
*/
|
||||
virtual void setSrid(int srid){};
|
||||
/*! Get the SRID of the target SRS
|
||||
* If the provider isn't capable of reporting the SRID of
|
||||
* the projection, ti will return 0
|
||||
*/
|
||||
virtual int getSrid(){return 0;};
|
||||
/*! Set the WKT of the target SRS.
|
||||
* This is only implemented if the provider supports native
|
||||
* transformation of its coordinates
|
||||
*
|
||||
* @param wkt Well known text of the target (map canvas) SRS
|
||||
*/
|
||||
virtual void setWKT(QString wkt){};
|
||||
|
||||
|
||||
protected:
|
||||
/**Encoding*/
|
||||
@ -189,6 +222,17 @@ protected:
|
||||
std::list<QString> mNonNumericalTypes;
|
||||
/**List of type names for numerical types*/
|
||||
std::list<QString> mNumericalTypes;
|
||||
/** The spatial reference id of the map canvas. This is the
|
||||
* SRID the provider should transform its coordinates to if
|
||||
* supportsNativeTransform is true. Otherwise this member is unused.
|
||||
*/
|
||||
int mTargetSrid;
|
||||
/** The WKT of the SRS of the map canvas. This is the
|
||||
* SRS the provider should transform its coordinates to if
|
||||
* supportsNativeTransform is true. Otherwise this member is unused.
|
||||
* The provider may choose to support transformation using SRID or WKT.
|
||||
*/
|
||||
int mTargetWKT;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -96,12 +96,19 @@ const QString displayField() const { return fieldIndex; }
|
||||
@todo XXX should this return bool? Throw exceptions?
|
||||
*/
|
||||
void setDataProvider( QString const & provider );
|
||||
|
||||
//! Setup the coordinate system tranformation for the layer
|
||||
void setCoordinateSystem();
|
||||
|
||||
QgsVectorDataProvider * getDataProvider();
|
||||
|
||||
/** \brief Query data provider to find out the WKT projection string for this layer. This implements the virtual method of the same name defined in QgsMapLayer*/
|
||||
QString getProjectionWKT();
|
||||
|
||||
/*!
|
||||
* Gets the SRID of the layer by querying the underlying data provider
|
||||
* @return The SRID if the provider is able to provide it, otherwise 0
|
||||
*/
|
||||
int getProjectionSrid();
|
||||
QgsLabel *label();
|
||||
|
||||
QgsAttributeAction* actions() { return &mActions; }
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
resourcedir = ${pkgdatadir}/resources
|
||||
|
||||
resource_DATA = wkt_defs.txt
|
||||
resource_DATA = spatial_ref_sys.txt srs.db
|
||||
|
||||
EXTRA_DIST = $(resource_DATA)
|
||||
|
||||
|
2672
src/resources/spatial_ref_sys.txt
Normal file
2672
src/resources/spatial_ref_sys.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/resources/srs.db
Normal file
BIN
src/resources/srs.db
Normal file
Binary file not shown.
@ -13,7 +13,7 @@
|
||||
class ProjectionCsHandlingTest : public CppUnit::TestCase {
|
||||
public:
|
||||
ProjectionCsHandlingTest(){}
|
||||
|
||||
|
||||
ProjectionCsHandlingTest( std::string name ) : CppUnit::TestCase( name ) { }
|
||||
|
||||
static CppUnit::Test *suite()
|
||||
@ -42,10 +42,12 @@ class ProjectionCsHandlingTest : public CppUnit::TestCase {
|
||||
&ProjectionCsHandlingTest::testAkAlbersExportToProj4NoMorph ) );
|
||||
suiteOfTests->addTest( new CppUnit::TestCaller<ProjectionCsHandlingTest>(
|
||||
"testAkAlbersExportToProj4Morph",
|
||||
&ProjectionCsHandlingTest::testAkAlbersExportToProj4Morph ) );
|
||||
suiteOfTests->addTest( new CppUnit::TestCaller<ProjectionCsHandlingTest>(
|
||||
&ProjectionCsHandlingTest::testAkAlbersExportToProj4Morph ) ); suiteOfTests->addTest( new CppUnit::TestCaller<ProjectionCsHandlingTest>(
|
||||
"testWktFromFile",
|
||||
&ProjectionCsHandlingTest::testWktFromFile ) );
|
||||
suiteOfTests->addTest( new CppUnit::TestCaller<ProjectionCsHandlingTest>(
|
||||
"testOgrTransform",
|
||||
&ProjectionCsHandlingTest::testOgrTransform ) );
|
||||
return suiteOfTests;
|
||||
}
|
||||
//
|
||||
@ -67,11 +69,11 @@ class ProjectionCsHandlingTest : public CppUnit::TestCase {
|
||||
" AUTHORITY[\"EPSG\",4326]]";
|
||||
wktDest = "GEOGCS[\"GCS_North_American_1927\",DATUM[\"D_North_American_1927\",SPHEROID[\"Clarke_1866\",6378206.4,294.9786982]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]";
|
||||
wktDestNad83 = "GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";
|
||||
wktEpsg = "GEOGCS[\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]";
|
||||
wktEpsg = "GEOGCS[\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]";
|
||||
|
||||
wktAkAlbers = "PROJCS[\"Alaska_Albers_Equal_Area_Conic\",GEOGCS[\"GCS_North_American_1927\",DATUM[\"D_North_American_1927\",SPHEROID[\"Clarke_1866\",6378206.4,294.9786982]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Albers\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-154.0],PARAMETER[\"Standard_Parallel_1\",55.0],PARAMETER[\"Standard_Parallel_2\",65.0],PARAMETER[\"Latitude_Of_Origin\",50.0],UNIT[\"Meter\",1.0]]";
|
||||
wktAkAlbers = "PROJCS[\"Alaska_Albers_Equal_Area_Conic\",GEOGCS[\"GCS_North_American_1927\",DATUM[\"D_North_American_1927\",SPHEROID[\"Clarke_1866\",6378206.4,294.9786982]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Albers\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-154.0],PARAMETER[\"Standard_Parallel_1\",55.0],PARAMETER[\"Standard_Parallel_2\",65.0],PARAMETER[\"Latitude_Of_Origin\",50.0],UNIT[\"Meter\",1.0]]";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Test creation of a OGRSpatialReference object from wkt
|
||||
//
|
||||
@ -216,25 +218,63 @@ wktAkAlbers = "PROJCS[\"Alaska_Albers_Equal_Area_Conic\",GEOGCS[\"GCS_North_Amer
|
||||
//
|
||||
void testWktFromFile()
|
||||
{
|
||||
std::ifstream wktIn("./wkt.txt");
|
||||
char *buf = new char[16384];
|
||||
wktIn.getline(buf, 16384);
|
||||
wktIn.close();
|
||||
std::ifstream wktIn("./wkt.txt");
|
||||
char *buf = new char[16384];
|
||||
wktIn.getline(buf, 16384);
|
||||
wktIn.close();
|
||||
std::cout << "\n\nGetting proj4 parameters from wkt.txt" << std::endl;
|
||||
std::cout << buf << std::endl;
|
||||
// set up the spatial ref
|
||||
OGRSpatialReference myInputSpatialRefSys;
|
||||
CPPUNIT_ASSERT(myInputSpatialRefSys.importFromWkt(&buf)== OGRERR_NONE);
|
||||
// std::cout << "\tGetting proj4 paramters with morph to ESRI form" << std::endl;
|
||||
// CPPUNIT_ASSERT(myInputSpatialRefSys.morphFromESRI() == OGRERR_NONE);
|
||||
// std::cout << "\tGetting proj4 paramters with morph to ESRI form" << std::endl;
|
||||
// CPPUNIT_ASSERT(myInputSpatialRefSys.morphFromESRI() == OGRERR_NONE);
|
||||
// get the proj4 for the unmorphed projection
|
||||
char *proj4src;
|
||||
CPPUNIT_ASSERT(myInputSpatialRefSys.exportToProj4(&proj4src) == OGRERR_NONE);
|
||||
std::cout << "\tPROJ4: " << proj4src << std::endl;
|
||||
// morph it then spew it
|
||||
myInputSpatialRefSys.morphFromESRI();
|
||||
myInputSpatialRefSys.exportToProj4(&proj4src);
|
||||
std::cout << "\tMorphed PROJ4: " << proj4src << std::endl;
|
||||
CPPUNIT_ASSERT(QString(proj4src).find("datum") > -1);
|
||||
|
||||
|
||||
}
|
||||
void testOgrTransform()
|
||||
{
|
||||
std::cout << "\n\nTesting OGR transform of kodiak.prj to WGS 84 Geographic" << std::endl;
|
||||
// set up the spatial ref
|
||||
OGRSpatialReference myInputSpatialRefSys;
|
||||
char *pWkt = (char*)wktAkAlbers.ascii();
|
||||
CPPUNIT_ASSERT(myInputSpatialRefSys.importFromWkt(&pWkt)== OGRERR_NONE);
|
||||
std::cout << "\tGetting proj4 paramters with morph to ESRI form" << std::endl;
|
||||
CPPUNIT_ASSERT(myInputSpatialRefSys.morphFromESRI() == OGRERR_NONE);
|
||||
OGRSpatialReference oTargetSRS;
|
||||
char *pWgs84 = (char *)wkt.ascii();
|
||||
oTargetSRS.importFromWkt(&pWgs84);
|
||||
OGRCoordinateTransformation *poCT;
|
||||
poCT = OGRCreateCoordinateTransformation( &myInputSpatialRefSys,
|
||||
&oTargetSRS );
|
||||
double x = 0.0;
|
||||
double y = 0.0;
|
||||
poCT->Transform(1, &x, &y);
|
||||
std::cout << "Transformed 0,0 albers point = " << x << ", " << y << std::endl;
|
||||
CPPUNIT_ASSERT((x == -154.0) || (y == 50.0));
|
||||
// get the proj4 for the morphed projection
|
||||
char *proj4src;
|
||||
CPPUNIT_ASSERT(myInputSpatialRefSys.exportToProj4(&proj4src) == OGRERR_NONE);
|
||||
std::cout << "\tPROJ4: " << proj4src << std::endl;
|
||||
|
||||
std::cout << "Testing inverse transform" << std::endl;
|
||||
poCT = OGRCreateCoordinateTransformation( &oTargetSRS, &myInputSpatialRefSys);
|
||||
x = -154.0;
|
||||
y = 50.0;
|
||||
poCT->Transform(1, &x, &y);
|
||||
CPPUNIT_ASSERT((x == 0) || (y == 0));
|
||||
std::cout << "Transformed -154,50 geographic point = " << x << ", " << y << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
// WKT for default projection hardcoded in QgsCoordinateTransform class
|
||||
QString wkt;
|
||||
|
@ -12,7 +12,8 @@ CONFIG += debug
|
||||
# get gdal info
|
||||
GDAL_LIBS = $$system(gdal-config --libs)
|
||||
GDAL_DEPS = $$system(gdal-config --dep-libs)
|
||||
LIBS = $$GDAL_LIBS $$GDAL_DEPS -lcppunit -ldl
|
||||
PG_LIBS = $$system(pg_config --libdir)
|
||||
LIBS = $$GDAL_LIBS $$GDAL_DEPS -L$$PG_LIBS -lcppunit -ldl
|
||||
# Input
|
||||
HEADERS += projectioncshandlingtest.h
|
||||
SOURCES += main.cpp
|
||||
|
4
widgets/Makefile.am
Normal file
4
widgets/Makefile.am
Normal file
@ -0,0 +1,4 @@
|
||||
## Makefile.in generated from automake
|
||||
|
||||
SUBDIRS = projectionselector
|
||||
|
51
widgets/projectionselector/Makefile.am
Normal file
51
widgets/projectionselector/Makefile.am
Normal file
@ -0,0 +1,51 @@
|
||||
# Copyright (C) 2005 Tim Sutton <tim at linfiniti.com>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
plugindir = ${pkglibdir}
|
||||
PKGDATAPATH=-DPKGDATAPATH=\"$(pkgdatadir)\"
|
||||
|
||||
|
||||
%.moc.cpp: %.h
|
||||
$(MOC) -o $@ $<
|
||||
|
||||
%.h: %.ui
|
||||
$(UIC) -o $@ $<
|
||||
|
||||
%.cpp: %.ui
|
||||
$(UIC) -o $@ -impl $*.h $<
|
||||
|
||||
|
||||
# name of the qgis library widget
|
||||
plugin_LTLIBRARIES = libqgsprojectionselector.la
|
||||
|
||||
plugin_MOC = qgsprojectionselector.moc.cpp \
|
||||
qgsprojectionselectorbase.moc.cpp
|
||||
|
||||
|
||||
plugin_UI = qgsprojectionselectorbase.h \
|
||||
qgsprojectionselectorbase.cpp
|
||||
|
||||
plugin_UIC = qgsprojectionselectorbase.ui
|
||||
|
||||
libqgsprojectionselector_la_SOURCES = qgsprojectionselector.cpp \
|
||||
$(plugin_UI) \
|
||||
$(plugin_MOC)
|
||||
|
||||
BUILT_SOURCES = $(plugin_MOC) $(plugin_UI)
|
||||
|
||||
|
||||
|
||||
libqgsprojectionselector_la_LIBADD = ../../src/libqgis.la $(LDADD) $(QT_LDADD) $(GDAL_LDADD) -lsqlite3
|
||||
libqgsprojectionselector_la_LDFLAGS = -avoid-version
|
||||
libqgsprojectionselector_la_CXXFLAGS = $(PKGDATAPATH) $(CXXFLAGS) $(GDAL_CFLAGS) $(EXTRA_CXXFLAGS) $(QT_CXXFLAGS) $(DEBUG_QGIS) -I../../src/
|
||||
|
||||
EXTRA_DIST = $(plugin_UIC)
|
343
widgets/projectionselector/qgsprojectionselector.cpp
Normal file
343
widgets/projectionselector/qgsprojectionselector.cpp
Normal file
@ -0,0 +1,343 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tim Sutton *
|
||||
* tim@linfiniti.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
#include "qgsprojectionselector.h"
|
||||
|
||||
//standard includes
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <sqlite3.h>
|
||||
|
||||
//qgis includes
|
||||
#include "qgscsexception.h"
|
||||
#include "qgsconfig.h"
|
||||
|
||||
//qt includes
|
||||
#include <qapplication.h>
|
||||
#include <qfile.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qbuttongroup.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qregexp.h>
|
||||
#include <qprogressdialog.h>
|
||||
#include <qapplication.h>
|
||||
|
||||
//stdc++ includes
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
//gdal and ogr includes
|
||||
// XXX DO WE NEED THESE?
|
||||
#include <ogr_api.h>
|
||||
#include <ogr_spatialref.h>
|
||||
#include <cpl_error.h>
|
||||
|
||||
// set the default coordinate system
|
||||
static const char* defaultWktKey = "4326";
|
||||
|
||||
QgsProjectionSelector::QgsProjectionSelector( QWidget* parent , const char* name , WFlags fl )
|
||||
: QgsProjectionSelectorBase( parent, "Projection Selector", fl )
|
||||
{
|
||||
// Get the package data path and set the full path name to the sqlite3 spatial reference
|
||||
// database.
|
||||
#if defined(Q_OS_MACX) || defined(WIN32)
|
||||
QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";
|
||||
#endif
|
||||
srsDatabaseFileName = PKGDATAPATH;
|
||||
srsDatabaseFileName += "/resources/srs.db";
|
||||
// Populate the projection list view
|
||||
getProjList();
|
||||
}
|
||||
|
||||
QgsProjectionSelector::~QgsProjectionSelector()
|
||||
{
|
||||
}
|
||||
void QgsProjectionSelector::setSelectedWKT(QString theWKT)
|
||||
{
|
||||
//get the srid given the wkt so we can pick the correct list item
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "QgsProjectionSelector::setSelectedWKT called with \n" << theWKT << std::endl;
|
||||
#endif
|
||||
//now delegate off to the rest of the work
|
||||
QListViewItemIterator myIterator (lstCoordinateSystems);
|
||||
while (myIterator.current())
|
||||
{
|
||||
if (myIterator.current()->text(0)==theWKT)
|
||||
{
|
||||
lstCoordinateSystems->setCurrentItem(myIterator.current());
|
||||
lstCoordinateSystems->ensureItemVisible(myIterator.current());
|
||||
return;
|
||||
}
|
||||
++myIterator;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsProjectionSelector::setSelectedSRID(QString theSRID)
|
||||
{
|
||||
QListViewItemIterator myIterator (lstCoordinateSystems);
|
||||
while (myIterator.current())
|
||||
{
|
||||
if (myIterator.current()->text(1)==theSRID)
|
||||
{
|
||||
lstCoordinateSystems->setCurrentItem(myIterator.current());
|
||||
lstCoordinateSystems->ensureItemVisible(myIterator.current());
|
||||
return;
|
||||
}
|
||||
++myIterator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//note this line just returns the projection name!
|
||||
QString QgsProjectionSelector::getSelectedWKT()
|
||||
{
|
||||
// return the selected wkt name from the list view
|
||||
QListViewItem *lvi = lstCoordinateSystems->currentItem();
|
||||
if(lvi)
|
||||
{
|
||||
return lvi->text(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString::null;
|
||||
}
|
||||
}
|
||||
// Returns the whole wkt for the selected projection node
|
||||
QString QgsProjectionSelector::getCurrentWKT()
|
||||
{
|
||||
// Only return the projection if there is a node in the tree
|
||||
// selected that has an srid. This prevents error if the user
|
||||
// selects a top-level node rather than an actual coordinate
|
||||
// system
|
||||
//
|
||||
// Get the selected node
|
||||
QListViewItem *lvi = lstCoordinateSystems->currentItem();
|
||||
if(lvi)
|
||||
{
|
||||
// Make sure the selected node is a srs and not a top-level projection node
|
||||
std::cout << lvi->text(1) << std::endl;
|
||||
if(lvi->text(1).length() > 0)
|
||||
{
|
||||
// set up the database
|
||||
// XXX We could probabaly hold the database open for the life of this object,
|
||||
// assuming that it will never be used anywhere else. Given the low overhead,
|
||||
// opening it each time seems to be a reasonable approach at this time.
|
||||
sqlite3 *db;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
rc = sqlite3_open(srsDatabaseFileName, &db);
|
||||
if(rc)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
|
||||
// XXX This will likely never happen since on open, sqlite creates the
|
||||
// database if it does not exist.
|
||||
assert(rc == 0);
|
||||
}
|
||||
// prepare the sql statement
|
||||
const char *pzTail;
|
||||
sqlite3_stmt *ppStmt;
|
||||
char *pzErrmsg;
|
||||
QString sql = "select srtext from spatial_ref_sys where srid = ";
|
||||
sql += lvi->text(1);
|
||||
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Finding selected wkt using : " << sql << std::endl;
|
||||
#endif
|
||||
rc = sqlite3_prepare(db, (const char *)sql, sql.length(), &ppStmt, &pzTail);
|
||||
// XXX Need to free memory from the error msg if one is set
|
||||
QString wkt;
|
||||
if(rc == SQLITE_OK)
|
||||
{
|
||||
// get the first row of the result set
|
||||
if(sqlite3_step(ppStmt) == SQLITE_ROW)
|
||||
{
|
||||
// get the wkt
|
||||
wkt = (char*)sqlite3_column_text(ppStmt, 0);
|
||||
}
|
||||
}
|
||||
// close the statement
|
||||
sqlite3_finalize(ppStmt);
|
||||
// close the database
|
||||
sqlite3_close(db);
|
||||
// return the srs wkt
|
||||
return wkt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No node is selected, return null
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString QgsProjectionSelector::getCurrentSRID()
|
||||
{
|
||||
if(lstCoordinateSystems->currentItem()->text(1).length() > 0)
|
||||
{
|
||||
return lstCoordinateSystems->currentItem()->text(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsProjectionSelector::getProjList()
|
||||
{
|
||||
// Create the top-level nodes for the list view of projections
|
||||
//
|
||||
// Geographic coordinate system node
|
||||
geoList = new QListViewItem(lstCoordinateSystems,"Geographic Coordinate System");
|
||||
// Projected coordinate system node
|
||||
projList = new QListViewItem(lstCoordinateSystems,"Projected Coordinate System");
|
||||
|
||||
|
||||
// open the database containing the spatial reference data
|
||||
sqlite3 *db;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
rc = sqlite3_open(srsDatabaseFileName, &db);
|
||||
if(rc)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
|
||||
// XXX This will likely never happen since on open, sqlite creates the
|
||||
// database if it does not exist.
|
||||
assert(rc == 0);
|
||||
}
|
||||
// prepare the sql statement
|
||||
const char *pzTail;
|
||||
sqlite3_stmt *ppStmt;
|
||||
char *pzErrmsg;
|
||||
// get total count of records in the projection table
|
||||
QString sql = "select count(*) from srs_name";
|
||||
|
||||
rc = sqlite3_prepare(db, sql, sql.length(), &ppStmt, &pzTail);
|
||||
assert(rc == SQLITE_OK);
|
||||
sqlite3_step(ppStmt);
|
||||
// Set the max for the progress dialog to the number of entries in the srs_name table
|
||||
int myEntriesCount = sqlite3_column_int(ppStmt, 0);
|
||||
sqlite3_finalize(ppStmt);
|
||||
|
||||
// Set up the query to retreive the projection information needed to populate the list
|
||||
sql = "select * from srs_name order by name";
|
||||
rc = sqlite3_prepare(db, (const char *)sql, sql.length(), &ppStmt, &pzTail);
|
||||
// XXX Need to free memory from the error msg if one is set
|
||||
if(rc == SQLITE_OK)
|
||||
{
|
||||
QListViewItem *newItem;
|
||||
// set up the progress dialog
|
||||
int myProgress = 1;
|
||||
QProgressDialog myProgressBar( "Building Projections List...", 0, myEntriesCount,
|
||||
this, "progress", TRUE );
|
||||
// set initial value to 1
|
||||
myProgressBar.setProgress(myProgress);
|
||||
while(sqlite3_step(ppStmt) == SQLITE_ROW)
|
||||
{
|
||||
// only update the progress dialog every 10 records
|
||||
if((myProgress++ % 10) == 0)
|
||||
{
|
||||
myProgressBar.setProgress(myProgress++);
|
||||
}
|
||||
// check to see if the srs is geographic
|
||||
int isGeo = sqlite3_column_int(ppStmt, 3);
|
||||
if(isGeo)
|
||||
{
|
||||
// this is a geographic coordinate system
|
||||
// Add it to the tree
|
||||
newItem = new QListViewItem(geoList, (char *)sqlite3_column_text(ppStmt,1));
|
||||
|
||||
// display the spatial reference id in the second column of the list view
|
||||
newItem->setText(1,(char *)sqlite3_column_text(ppStmt, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a projected srs
|
||||
|
||||
QListViewItem *node;
|
||||
// Fine the node for this type and add the projection to it
|
||||
// If the node doesn't exist, create it
|
||||
node = lstCoordinateSystems->findItem(QString((char*)sqlite3_column_text(ppStmt, 2)),0);
|
||||
if(node == 0)
|
||||
{
|
||||
// the node doesn't exist -- create it
|
||||
node = new QListViewItem(projList, (char*)sqlite3_column_text(ppStmt, 2));
|
||||
}
|
||||
|
||||
// add the item, setting the projection name in the first column of the list view
|
||||
newItem = new QListViewItem(node, (char *)sqlite3_column_text(ppStmt,1));
|
||||
// set the srid in the second column on the list view
|
||||
newItem->setText(1,(char *)sqlite3_column_text(ppStmt, 0));
|
||||
}
|
||||
}
|
||||
// update the progress bar to 100% -- just for eye candy purposes (some people hate to
|
||||
// see a progress dialog end at 99%)
|
||||
myProgressBar.setProgress(myEntriesCount);
|
||||
}
|
||||
// close the sqlite3 statement
|
||||
sqlite3_finalize(ppStmt);
|
||||
// close the database
|
||||
sqlite3_close(db);
|
||||
}
|
||||
|
||||
// New coordinate system selected from the list
|
||||
void QgsProjectionSelector::coordinateSystemSelected( QListViewItem * theItem)
|
||||
{
|
||||
if(theItem->text(1).length() > 0)
|
||||
{
|
||||
sqlite3 *db;
|
||||
char *zErrMsg = 0;
|
||||
int rc;
|
||||
rc = sqlite3_open(srsDatabaseFileName, &db);
|
||||
if(rc)
|
||||
{
|
||||
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
|
||||
// XXX This will likely never happen since on open, sqlite creates the
|
||||
// database if it does not exist.
|
||||
assert(rc == 0);
|
||||
}
|
||||
// prepare the sql statement
|
||||
const char *pzTail;
|
||||
sqlite3_stmt *ppStmt;
|
||||
char *pzErrmsg;
|
||||
QString sql = "select srtext from spatial_ref_sys where srid = ";
|
||||
sql += theItem->text(1);
|
||||
|
||||
rc = sqlite3_prepare(db, (const char *)sql, sql.length(), &ppStmt, &pzTail);
|
||||
// XXX Need to free memory from the error msg if one is set
|
||||
QString wkt;
|
||||
if(rc == SQLITE_OK)
|
||||
{
|
||||
if(sqlite3_step(ppStmt) == SQLITE_ROW)
|
||||
{
|
||||
wkt = (char*)sqlite3_column_text(ppStmt, 0);
|
||||
}
|
||||
}
|
||||
// close the statement
|
||||
sqlite3_finalize(ppStmt);
|
||||
// close the database
|
||||
sqlite3_close(db);
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Item selected : " << theItem->text(0) << std::endl;
|
||||
std::cout << "Item selected full wkt : " << wkt << std::endl;
|
||||
#endif
|
||||
assert(wkt.length() > 0);
|
||||
// reformat the wkt to improve the display in the textedit
|
||||
// box
|
||||
wkt = wkt.replace(",", ", ");
|
||||
teProjection->setText(wkt);
|
||||
// let anybody who's listening know about the change
|
||||
// XXX Is this appropriate here if the dialog is cancelled??
|
||||
emit wktSelected(wkt);
|
||||
|
||||
}
|
||||
}
|
||||
|
67
widgets/projectionselector/qgsprojectionselector.h
Normal file
67
widgets/projectionselector/qgsprojectionselector.h
Normal file
@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tim Sutton *
|
||||
* tim@linfiniti.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
#ifndef QGSPROJECTIONSELECTOR_H
|
||||
#define QGSPROJECTIONSELECTOR_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include "qgsprojectionselectorbase.uic.h"
|
||||
#else
|
||||
#include "qgsprojectionselectorbase.h"
|
||||
#endif
|
||||
|
||||
#include <qgis.h>
|
||||
#include <qstring.h>
|
||||
#include <qlistview.h>
|
||||
|
||||
|
||||
/**
|
||||
@author Tim Sutton
|
||||
*/
|
||||
class QgsProjectionSelector: public QgsProjectionSelectorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsProjectionSelector( QWidget* parent , const char* name ,WFlags fl =0 );
|
||||
~QgsProjectionSelector();
|
||||
//! Populate the wkts map with projection names...
|
||||
void getProjList();
|
||||
|
||||
|
||||
public slots:
|
||||
void setSelectedWKT(QString theWKT);
|
||||
QString getSelectedWKT();
|
||||
void setSelectedSRID(QString theSRID);
|
||||
QString getCurrentWKT();
|
||||
QString getCurrentSRID();
|
||||
private:
|
||||
|
||||
// List view nodes for the tree view of projections
|
||||
//! GEOGCS node
|
||||
QListViewItem *geoList;
|
||||
//! PROJCS node
|
||||
QListViewItem *projList;
|
||||
//! Users custom coordinate system file
|
||||
// XXX This has to change to a sqlite3 database installed in user home dir
|
||||
QString customCsFile;
|
||||
//! File name of the sqlite3 database
|
||||
QString srsDatabaseFileName;
|
||||
|
||||
//private handler for when user selects a cs
|
||||
//it will cause wktSelected and sridSelected events to be spawned
|
||||
void coordinateSystemSelected(QListViewItem*);
|
||||
|
||||
signals:
|
||||
void wktSelected(QString theWKT);
|
||||
void sridSelected(QString theSRID);
|
||||
//! Refresh any listening canvases
|
||||
void refresh();
|
||||
};
|
||||
|
||||
#endif
|
116
widgets/projectionselector/qgsprojectionselectorbase.ui
Normal file
116
widgets/projectionselector/qgsprojectionselectorbase.ui
Normal file
@ -0,0 +1,116 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>QgsProjectionSelectorBase</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>QgsProjectionSelectorBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Projection Selector</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<pixmap>image0</pixmap>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QButtonGroup" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>buttonGroup2</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Projection</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QListView" row="1" column="0">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Coordinate Systems</string>
|
||||
</property>
|
||||
<property name="clickable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="resizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Spatial Reference Id</string>
|
||||
</property>
|
||||
<property name="clickable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="resizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</column>
|
||||
<property name="name">
|
||||
<cstring>lstCoordinateSystems</cstring>
|
||||
</property>
|
||||
<property name="showSortIndicator">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>teProjection</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>76</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<images>
|
||||
<image name="image0">
|
||||
<data format="PNG" length="593">89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff610000021849444154388d8d933f6853511487bf4886fb20e00b4478810e062a34e0f092adcfc988430382766bede29f0e5237c716858253079796ec2a594ad3c15a0721298a4fa72ab4f47590c6a1f0de10c8050befa00fae43882135959eed77ef39dfb9f777ef49f9becf79a3fac6332a07510dfc977e0a207daec275cfe00039d011f07db0776154c1c4f891999c3c3217331bc6c96d98d59b55d8571081ea0ce7fe0370dd2393bda479fbbec1b5ca1a4b2bdb142714ca15e880defb0fc0750f8c658584dd5d1a9b01ba23345a01739bdb70a2783056421dabb3019625843f03448420e8f616ef409808d57481fbf34516ee1587007f4d8c4f360c284820164177403d02958362c7e6c97c092b0385717b34a0381113ff8e914400452c1a350612c1f45889acd383abb48c0604fb9a92a35069458c509872c85eb15091e2ee4c1995eea213a1abcf30f146b58ed68224829581cad53caa050b3305f239858880c0e72fe16880effb297f2784a4a7db879a7a2da070d921941050345b21cd7711bedffb8543006fd6338ff75a2cadfb743bc2f4ad0225d7c1b62d0076bf45acad7c456be1d3c7553304a8bcf08c3dd5336c7bff0773cf9a047b5d1697cb44c7402288401881f9f51a918111a9fe30799e6700d46d4083ecf412b69a55caae8d24e064f234b6da3c9c6dd0fc706a98faf7aad63c23d1402f3e9d3595eb59b2399b83c380c67a1b49463c633ff42bc019e8e7cbf554ff74a79b01fc013633ebcd0e2d66c60000000049454e44ae426082</data>
|
||||
</image>
|
||||
</images>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>lstCoordinateSystems</sender>
|
||||
<signal>currentChanged(QListViewItem*)</signal>
|
||||
<receiver>QgsProjectionSelectorBase</receiver>
|
||||
<slot>coordinateSystemSelected(QListViewItem*)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">qgsprojectionselectorbase.ui.h</include>
|
||||
</includes>
|
||||
<slots>
|
||||
<slot>projectionChanged( const QString & )</slot>
|
||||
<slot>coordinateSystemSelected( QListViewItem * )</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
24
widgets/projectionselector/qgsprojectionselectorbase.ui.h
Normal file
24
widgets/projectionselector/qgsprojectionselectorbase.ui.h
Normal file
@ -0,0 +1,24 @@
|
||||
/****************************************************************************
|
||||
** ui.h extension file, included from the uic-generated form implementation.
|
||||
**
|
||||
** If you wish to add, delete or rename functions or slots use
|
||||
** Qt Designer which will update this file, preserving your code. Create an
|
||||
** init() function in place of a constructor, and a destroy() function in
|
||||
** place of a destructor.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
void QgsProjectionSelectorBase::projectionChanged( const QString & )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void QgsProjectionSelectorBase::coordinateSystemSelected( QListViewItem * )
|
||||
{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user