mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -04:00
changes to support identify and attribute display functions
git-svn-id: http://svn.osgeo.org/qgis/trunk@147 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
c13d055a8c
commit
2c85d6985a
66
src/Makefile
66
src/Makefile
@ -1,6 +1,6 @@
|
||||
#############################################################################
|
||||
# Makefile for building: qgis
|
||||
# Generated by qmake (1.03a) on: Fri Oct 25 15:00:41 2002
|
||||
# Generated by qmake (1.03a) on: Sat Nov 23 15:07:42 2002
|
||||
# Project: src.pro
|
||||
# Template: app
|
||||
# Command: $(QMAKE) src.pro
|
||||
@ -63,7 +63,9 @@ HEADERS = qgsdbsourceselectbase.ui.h \
|
||||
qgslegend.h \
|
||||
qgslegenditem.h \
|
||||
qgslayerproperties.h \
|
||||
qgsidentifyresults.h
|
||||
qgsidentifyresults.h \
|
||||
qgsattributetable.h \
|
||||
qgsattributetabledisplay.h
|
||||
SOURCES = main.cpp \
|
||||
qgisapp.cpp \
|
||||
qgsdatabaselayer.cpp \
|
||||
@ -84,7 +86,9 @@ SOURCES = main.cpp \
|
||||
qgslinesymbol.cpp \
|
||||
qgspolygonsymbol.cpp \
|
||||
qgslayerproperties.cpp \
|
||||
qgsidentifyresults.cpp
|
||||
qgsidentifyresults.cpp \
|
||||
qgsattributetable.cpp \
|
||||
qgsattributetabledisplay.cpp
|
||||
OBJECTS = main.o \
|
||||
qgisapp.o \
|
||||
qgsdatabaselayer.o \
|
||||
@ -106,34 +110,40 @@ OBJECTS = main.o \
|
||||
qgspolygonsymbol.o \
|
||||
qgslayerproperties.o \
|
||||
qgsidentifyresults.o \
|
||||
qgsattributetable.o \
|
||||
qgsattributetabledisplay.o \
|
||||
qgsdbsourceselectbase.o \
|
||||
qgisappbase.o \
|
||||
qgsnewconnectionbase.o \
|
||||
qgslegenditembase.o \
|
||||
qgsabout.o \
|
||||
qgslayerpropertiesbase.o \
|
||||
qgsidentifyresultsbase.o
|
||||
qgsidentifyresultsbase.o \
|
||||
qgsattributetablebase.o
|
||||
FORMS = qgsdbsourceselectbase.ui \
|
||||
qgisappbase.ui \
|
||||
qgsnewconnectionbase.ui \
|
||||
qgslegenditembase.ui \
|
||||
qgsabout.ui \
|
||||
qgslayerpropertiesbase.ui \
|
||||
qgsidentifyresultsbase.ui
|
||||
qgsidentifyresultsbase.ui \
|
||||
qgsattributetablebase.ui
|
||||
UICDECLS = qgsdbsourceselectbase.h \
|
||||
qgisappbase.h \
|
||||
qgsnewconnectionbase.h \
|
||||
qgslegenditembase.h \
|
||||
qgsabout.h \
|
||||
qgslayerpropertiesbase.h \
|
||||
qgsidentifyresultsbase.h
|
||||
qgsidentifyresultsbase.h \
|
||||
qgsattributetablebase.h
|
||||
UICIMPLS = qgsdbsourceselectbase.cpp \
|
||||
qgisappbase.cpp \
|
||||
qgsnewconnectionbase.cpp \
|
||||
qgslegenditembase.cpp \
|
||||
qgsabout.cpp \
|
||||
qgslayerpropertiesbase.cpp \
|
||||
qgsidentifyresultsbase.cpp
|
||||
qgsidentifyresultsbase.cpp \
|
||||
qgsattributetablebase.cpp
|
||||
SRCMOC = moc_qgisapp.cpp \
|
||||
moc_qgsdatabaselayer.cpp \
|
||||
moc_qgsmapcanvas.cpp \
|
||||
@ -141,13 +151,15 @@ SRCMOC = moc_qgisapp.cpp \
|
||||
moc_qgsrasterlayer.cpp \
|
||||
moc_qgsshapefilelayer.cpp \
|
||||
moc_qgslegend.cpp \
|
||||
moc_qgsattributetable.cpp \
|
||||
moc_qgsdbsourceselectbase.cpp \
|
||||
moc_qgisappbase.cpp \
|
||||
moc_qgsnewconnectionbase.cpp \
|
||||
moc_qgslegenditembase.cpp \
|
||||
moc_qgsabout.cpp \
|
||||
moc_qgslayerpropertiesbase.cpp \
|
||||
moc_qgsidentifyresultsbase.cpp
|
||||
moc_qgsidentifyresultsbase.cpp \
|
||||
moc_qgsattributetablebase.cpp
|
||||
OBJMOC = moc_qgisapp.o \
|
||||
moc_qgsdatabaselayer.o \
|
||||
moc_qgsmapcanvas.o \
|
||||
@ -155,13 +167,15 @@ OBJMOC = moc_qgisapp.o \
|
||||
moc_qgsrasterlayer.o \
|
||||
moc_qgsshapefilelayer.o \
|
||||
moc_qgslegend.o \
|
||||
moc_qgsattributetable.o \
|
||||
moc_qgsdbsourceselectbase.o \
|
||||
moc_qgisappbase.o \
|
||||
moc_qgsnewconnectionbase.o \
|
||||
moc_qgslegenditembase.o \
|
||||
moc_qgsabout.o \
|
||||
moc_qgslayerpropertiesbase.o \
|
||||
moc_qgsidentifyresultsbase.o
|
||||
moc_qgsidentifyresultsbase.o \
|
||||
moc_qgsattributetablebase.o
|
||||
DIST = src.pro
|
||||
QMAKE_TARGET = qgis
|
||||
DESTDIR =
|
||||
@ -260,11 +274,13 @@ qgsdatabaselayer.o: qgsdatabaselayer.cpp qgis.h \
|
||||
qgspoint.h \
|
||||
qgsdatabaselayer.h \
|
||||
qgsidentifyresults.h \
|
||||
qgsattributetabledisplay.h \
|
||||
qgsmaplayer.h \
|
||||
qgsdatasource.h \
|
||||
qgscoordinatetransform.h \
|
||||
qgssymbol.h \
|
||||
qgsidentifyresultsbase.h
|
||||
qgsidentifyresultsbase.h \
|
||||
qgsattributetablebase.h
|
||||
|
||||
qgsdatasource.o: qgsdatasource.cpp qgsdatasource.h
|
||||
|
||||
@ -301,10 +317,12 @@ qgsshapefilelayer.o: qgsshapefilelayer.cpp qgsrect.h \
|
||||
qgspoint.h \
|
||||
qgscoordinatetransform.h \
|
||||
qgsshapefilelayer.h \
|
||||
qgsidentifyresults.h \
|
||||
qgsmaplayer.h \
|
||||
qgsdatasource.h \
|
||||
qgis.h \
|
||||
qgssymbol.h
|
||||
qgssymbol.h \
|
||||
qgsidentifyresultsbase.h
|
||||
|
||||
qgsdbsourceselect.o: qgsdbsourceselect.cpp xpm/point_layer.xpm \
|
||||
xpm/line_layer.xpm \
|
||||
@ -367,6 +385,11 @@ qgslayerproperties.o: qgslayerproperties.cpp qgsmaplayer.h \
|
||||
qgsidentifyresults.o: qgsidentifyresults.cpp qgsidentifyresults.h \
|
||||
qgsidentifyresultsbase.h
|
||||
|
||||
qgsattributetable.o: qgsattributetable.cpp qgsattributetable.h
|
||||
|
||||
qgsattributetabledisplay.o: qgsattributetabledisplay.cpp qgsattributetabledisplay.h \
|
||||
qgsattributetablebase.h
|
||||
|
||||
qgsdbsourceselectbase.h: qgsdbsourceselectbase.ui
|
||||
$(UIC) qgsdbsourceselectbase.ui -o qgsdbsourceselectbase.h
|
||||
|
||||
@ -409,11 +432,16 @@ qgsidentifyresultsbase.h: qgsidentifyresultsbase.ui
|
||||
qgsidentifyresultsbase.cpp: qgsidentifyresultsbase.h qgsidentifyresultsbase.ui
|
||||
$(UIC) qgsidentifyresultsbase.ui -i qgsidentifyresultsbase.h -o qgsidentifyresultsbase.cpp
|
||||
|
||||
qgsattributetablebase.h: qgsattributetablebase.ui
|
||||
$(UIC) qgsattributetablebase.ui -o qgsattributetablebase.h
|
||||
|
||||
qgsattributetablebase.cpp: qgsattributetablebase.h qgsattributetablebase.ui
|
||||
$(UIC) qgsattributetablebase.ui -i qgsattributetablebase.h -o qgsattributetablebase.cpp
|
||||
|
||||
qgsdbsourceselectbase.o: qgsdbsourceselectbase.cpp qgsdbsourceselectbase.ui.h \
|
||||
qgsdbsourceselectbase.h
|
||||
|
||||
qgisappbase.o: qgisappbase.cpp qgisappbase.ui.h \
|
||||
qgisappbase.h
|
||||
qgisappbase.o: qgisappbase.cpp qgisappbase.h
|
||||
|
||||
qgsnewconnectionbase.o: qgsnewconnectionbase.cpp qgsnewconnectionbase.h
|
||||
|
||||
@ -426,6 +454,8 @@ qgslayerpropertiesbase.o: qgslayerpropertiesbase.cpp qgslayerpropertiesbase.h
|
||||
|
||||
qgsidentifyresultsbase.o: qgsidentifyresultsbase.cpp qgsidentifyresultsbase.h
|
||||
|
||||
qgsattributetablebase.o: qgsattributetablebase.cpp qgsattributetablebase.h
|
||||
|
||||
moc_qgisapp.o: moc_qgisapp.cpp qgisapp.h qgisappbase.h
|
||||
|
||||
moc_qgsdatabaselayer.o: moc_qgsdatabaselayer.cpp qgsdatabaselayer.h qgsmaplayer.h \
|
||||
@ -460,6 +490,8 @@ moc_qgsshapefilelayer.o: moc_qgsshapefilelayer.cpp qgsshapefilelayer.h qgsmaplay
|
||||
|
||||
moc_qgslegend.o: moc_qgslegend.cpp qgslegend.h
|
||||
|
||||
moc_qgsattributetable.o: moc_qgsattributetable.cpp qgsattributetable.h
|
||||
|
||||
moc_qgsdbsourceselectbase.o: moc_qgsdbsourceselectbase.cpp qgsdbsourceselectbase.h
|
||||
|
||||
moc_qgisappbase.o: moc_qgisappbase.cpp qgisappbase.h
|
||||
@ -474,6 +506,8 @@ moc_qgslayerpropertiesbase.o: moc_qgslayerpropertiesbase.cpp qgslayerpropertiesb
|
||||
|
||||
moc_qgsidentifyresultsbase.o: moc_qgsidentifyresultsbase.cpp qgsidentifyresultsbase.h
|
||||
|
||||
moc_qgsattributetablebase.o: moc_qgsattributetablebase.cpp qgsattributetablebase.h
|
||||
|
||||
moc_qgisapp.cpp: $(MOC) qgisapp.h
|
||||
$(MOC) qgisapp.h -o moc_qgisapp.cpp
|
||||
|
||||
@ -495,6 +529,9 @@ moc_qgsshapefilelayer.cpp: $(MOC) qgsshapefilelayer.h
|
||||
moc_qgslegend.cpp: $(MOC) qgslegend.h
|
||||
$(MOC) qgslegend.h -o moc_qgslegend.cpp
|
||||
|
||||
moc_qgsattributetable.cpp: $(MOC) qgsattributetable.h
|
||||
$(MOC) qgsattributetable.h -o moc_qgsattributetable.cpp
|
||||
|
||||
moc_qgsdbsourceselectbase.cpp: $(MOC) qgsdbsourceselectbase.h
|
||||
$(MOC) qgsdbsourceselectbase.h -o moc_qgsdbsourceselectbase.cpp
|
||||
|
||||
@ -516,6 +553,9 @@ moc_qgslayerpropertiesbase.cpp: $(MOC) qgslayerpropertiesbase.h
|
||||
moc_qgsidentifyresultsbase.cpp: $(MOC) qgsidentifyresultsbase.h
|
||||
$(MOC) qgsidentifyresultsbase.h -o moc_qgsidentifyresultsbase.cpp
|
||||
|
||||
moc_qgsattributetablebase.cpp: $(MOC) qgsattributetablebase.h
|
||||
$(MOC) qgsattributetablebase.h -o moc_qgsattributetablebase.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install: all
|
||||
|
38
src/qgis.h
38
src/qgis.h
@ -1,5 +1,5 @@
|
||||
#ifndef QGIS_H
|
||||
#define QGIS_H
|
||||
#define QGIS_H
|
||||
/*! \mainpage Quantum GIS
|
||||
*
|
||||
* \section about About QGis
|
||||
@ -10,23 +10,27 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace QGis {
|
||||
enum MapTools {
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
Pan,
|
||||
Distance,
|
||||
Identify
|
||||
};
|
||||
namespace QGis
|
||||
{
|
||||
enum MapTools
|
||||
{
|
||||
ZoomIn,
|
||||
ZoomOut,
|
||||
Pan,
|
||||
Distance,
|
||||
Identify,
|
||||
Table
|
||||
};
|
||||
//! Used for symbology operations
|
||||
enum WKBTYPE{
|
||||
WKBPoint=1,
|
||||
WKBLineString,
|
||||
WKBPolygon,
|
||||
WKBMultiPoint,
|
||||
WKBMultiLineString,
|
||||
WKBMultiPolygon
|
||||
};
|
||||
enum WKBTYPE
|
||||
{
|
||||
WKBPoint = 1,
|
||||
WKBLineString,
|
||||
WKBPolygon,
|
||||
WKBMultiPoint,
|
||||
WKBMultiLineString,
|
||||
WKBMultiPolygon
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -36,7 +36,7 @@ User Interface=*.kdevdlg,*.ui,*.rc,*.dlg
|
||||
groups=Headers,Sources,User Interface,Others
|
||||
|
||||
[Makefile.am]
|
||||
files=main.cpp,qgisapp.cpp,qgscoordinatetransform.cpp,qgsdatabaselayer.cpp,qgsdatasource.cpp,qgsdbsourceselect.cpp,qgsmapcanvas.cpp,qgsmaplayer.cpp,qgsnewconnection.cpp,qgspoint.cpp,qgsrasterlayer.cpp,qgsrect.cpp,qgisapp.h,qgscoordinatetransform.h,qgsdatabaselayer.h,qgsdatasource.h,qgsdbsourceselect.h,qgslinesymbol.h,qgsmapcanvas.h,qgsmaplayer.h,qgsmarkersymbol.h,qgsnewconnection.h,qgspoint.h,qgspolygonsymbol.h,qgsrasterlayer.h,qgsrect.h,qgsshapefilelayer.h,qgisappbase.ui,qgsdbsourceselectbase.ui,qgsnewconnectionbase.ui,qgscustomsymbol.cpp,qgscustomsymbol.h,qgslegend.h,qgslegend.cpp,qgslegenditem.cpp,qgslegenditem.h,qgssymbol.h,qgstable.h,qgsshapefilelayer.cpp,qgslegenditembase.h,qgsabout.ui,qgsabout.ui.h,QgsSymbol.cpp,qgsmarkersymbol.cpp,qgslinesymbol.cpp,qgspolygonsymbol.cpp,qgslayerproperties.cpp,qgslayerproperties.h,qgis.h,qgsidentifyresults.cpp,qgsidentifyresults.h
|
||||
files=main.cpp,qgisapp.cpp,qgscoordinatetransform.cpp,qgsdatabaselayer.cpp,qgsdatasource.cpp,qgsdbsourceselect.cpp,qgsmapcanvas.cpp,qgsmaplayer.cpp,qgsnewconnection.cpp,qgspoint.cpp,qgsrasterlayer.cpp,qgsrect.cpp,qgisapp.h,qgscoordinatetransform.h,qgsdatabaselayer.h,qgsdatasource.h,qgsdbsourceselect.h,qgslinesymbol.h,qgsmapcanvas.h,qgsmaplayer.h,qgsmarkersymbol.h,qgsnewconnection.h,qgspoint.h,qgspolygonsymbol.h,qgsrasterlayer.h,qgsrect.h,qgsshapefilelayer.h,qgisappbase.ui,qgsdbsourceselectbase.ui,qgsnewconnectionbase.ui,qgscustomsymbol.cpp,qgscustomsymbol.h,qgslegend.h,qgslegend.cpp,qgslegenditem.cpp,qgslegenditem.h,qgssymbol.h,qgstable.h,qgsshapefilelayer.cpp,qgslegenditembase.h,qgsabout.ui,qgsabout.ui.h,QgsSymbol.cpp,qgsmarkersymbol.cpp,qgslinesymbol.cpp,qgspolygonsymbol.cpp,qgslayerproperties.cpp,qgslayerproperties.h,qgis.h,qgsidentifyresults.cpp,qgsidentifyresults.h,qgsattributetable.cpp,qgsattributetable.h
|
||||
sharedlib_LDFLAGS=-version-info 0:0:0
|
||||
sharedlib_rootname=src
|
||||
sub_dirs=
|
||||
@ -104,6 +104,18 @@ install=false
|
||||
install_location=
|
||||
type=HEADER
|
||||
|
||||
[qgsattributetable.cpp]
|
||||
dist=true
|
||||
install=false
|
||||
install_location=
|
||||
type=SOURCE
|
||||
|
||||
[qgsattributetable.h]
|
||||
dist=true
|
||||
install=false
|
||||
install_location=
|
||||
type=HEADER
|
||||
|
||||
[qgscoordinatetransform.cpp]
|
||||
dist=true
|
||||
install=false
|
||||
|
@ -148,14 +148,14 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
|
||||
|
||||
// create the layer popup menu
|
||||
popMenu = new QPopupMenu();
|
||||
popMenu->insertItem("&Zoom to extent of selected layer", this, SLOT(zoomToLayerExtent()));
|
||||
popMenu->insertItem("&Zoom to extent of selected layer", this, SLOT(zoomToLayerExtent()));
|
||||
popMenu->insertItem("&Remove", this, SLOT(removeLayer()));
|
||||
popMenu->insertItem("&Properties", this, SLOT(layerProperties()));
|
||||
mapCursor = 0;
|
||||
|
||||
// set the legend control for the map canvas
|
||||
mapCanvas->setLegend(mapLegend);
|
||||
|
||||
// set the legend control for the map canvas
|
||||
mapCanvas->setLegend(mapLegend);
|
||||
|
||||
// connect the "cleanup" slot
|
||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveWindowState()));
|
||||
restoreWindowState();
|
||||
@ -176,7 +176,8 @@ void QgisApp::about()
|
||||
watsNew += qgisVersion;
|
||||
watsNew += "\n*Improved handling/management of PostGIS connections\n"
|
||||
"*Password prompt if the password is not stored with a connection\n"
|
||||
"*Windows size and postion and toolbar docking state is saved/restored\n";
|
||||
"*Windows size and position and toolbar docking state is saved/restored\n"
|
||||
"*Identify function for layers\n" "*Duplicate layers (layers with same name) are now handled properly\n";
|
||||
|
||||
abt->setWhatsNew(watsNew);
|
||||
abt->exec();
|
||||
@ -361,6 +362,18 @@ void QgisApp::identify()
|
||||
mapCanvas->setCursor(*mapCursor);
|
||||
}
|
||||
|
||||
void QgisApp::attributeTable()
|
||||
{
|
||||
QListViewItem *li = legendView->currentItem();
|
||||
QgsMapLayer *lyr = ((QgsLegendItem *) li)->layer();
|
||||
if (lyr) {
|
||||
lyr->table();
|
||||
|
||||
} else {
|
||||
QMessageBox::information(this, "No Layer Selected", "To open an attribute table, you must select a layer in the legend");
|
||||
}
|
||||
}
|
||||
|
||||
//void QgisApp::readWKB (const char *connInfo, QStringList tables)
|
||||
//{
|
||||
// PgCursor pgc (connInfo, "testcursor");
|
||||
@ -548,15 +561,16 @@ void QgisApp::removeLayer()
|
||||
|
||||
}
|
||||
|
||||
void QgisApp::zoomToLayerExtent(){
|
||||
|
||||
void QgisApp::zoomToLayerExtent()
|
||||
{
|
||||
|
||||
// get the selected item
|
||||
QListViewItem *li = legendView->currentItem();
|
||||
QgsMapLayer *lyr = ((QgsLegendItem *) li)->layer();
|
||||
mapCanvas->setExtent(lyr->extent());
|
||||
mapCanvas->clear();
|
||||
mapCanvas->render2();
|
||||
|
||||
mapCanvas->setExtent(lyr->extent());
|
||||
mapCanvas->clear();
|
||||
mapCanvas->render2();
|
||||
|
||||
}
|
||||
|
||||
void QgisApp::rightClickLegendMenu(QListViewItem * lvi, const QPoint & pt, int)
|
||||
@ -585,8 +599,8 @@ void QgisApp::testPluginFunctions()
|
||||
std::cout << "Plugin name: " << pl->name() << std::endl;
|
||||
std::cout << "Plugin version: " << pl->version() << std::endl;
|
||||
std::cout << "Plugin description: " << pl->description() << std::endl;
|
||||
QMessageBox::information(this,"Plugin Information","QGis loaded the following plugin:\nName: "
|
||||
+ pl->name() + "\nVersion: " + pl->version() + "\nDescription: " + pl->description());
|
||||
QMessageBox::information(this, "Plugin Information", "QGis loaded the following plugin:\nName: "
|
||||
+ pl->name() + "\nVersion: " + pl->version() + "\nDescription: " + pl->description());
|
||||
// unload the plugin (delete it)
|
||||
std::cout << "Attempting to resolve the unload function" << std::endl;
|
||||
unload_t *ul = (unload_t *) myLib.resolve("unload");
|
||||
@ -594,13 +608,14 @@ void QgisApp::testPluginFunctions()
|
||||
ul(pl);
|
||||
std::cout << "Unloaded the plugin\n";
|
||||
} else {
|
||||
std::cout << "Unable to resolve unload function. Plugin was not unloaded\n";
|
||||
std::cout << "Unable to resolve unload function. Plugin was not unloaded\n";
|
||||
}
|
||||
}
|
||||
} else{
|
||||
QMessageBox::warning(this,"Unable to Load Plugin","QGis was unable to load the plugin from: ../plugins/libqgisplugin.so.1.0.0");
|
||||
std::cout << "Unable to load library" << std::endl;
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(this, "Unable to Load Plugin",
|
||||
"QGis was unable to load the plugin from: ../plugins/libqgisplugin.so.1.0.0");
|
||||
std::cout << "Unable to load library" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void QgisApp::saveWindowState()
|
||||
@ -644,4 +659,3 @@ void QgisApp::restoreWindowState()
|
||||
int y = settings.readNumEntry("/qgis/Geometry/y", (dh - 400) / 2);
|
||||
setGeometry(x, y, w, h);
|
||||
}
|
||||
|
||||
|
@ -35,13 +35,13 @@ class QgsMapCanvas;
|
||||
/*! \class QgisApp
|
||||
* \brief Main window for the Qgis application
|
||||
*/
|
||||
class QgisApp : public QgisAppBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
class QgisApp:public QgisAppBase
|
||||
{
|
||||
Q_OBJECT public:
|
||||
//! Constructor
|
||||
QgisApp(QWidget *parent=0, const char * name=0, WFlags fl = WType_TopLevel );
|
||||
|
||||
~QgisApp();
|
||||
QgisApp(QWidget * parent = 0, const char *name = 0, WFlags fl = WType_TopLevel);
|
||||
|
||||
~QgisApp();
|
||||
//public slots:
|
||||
//! Add a layer to the map
|
||||
void addLayer();
|
||||
@ -50,16 +50,19 @@ public:
|
||||
//! Exit Qgis
|
||||
void fileExit();
|
||||
//! Set map tool to Zoom out
|
||||
void zoomOut();
|
||||
void zoomOut();
|
||||
//! Set map tool to Zoom in
|
||||
void zoomIn();
|
||||
void zoomIn();
|
||||
//! Zoom to full extent
|
||||
void zoomFull();
|
||||
//! Zoom to the previous extent
|
||||
void zoomPrevious();
|
||||
//! Zoom to the previous extent
|
||||
void zoomPrevious();
|
||||
//! Set map tool to pan
|
||||
void pan();
|
||||
//! Identify feature(s) on the currently selected layer
|
||||
void identify();
|
||||
//! show the attribute table for the currently selected layer
|
||||
void attributeTable();
|
||||
//! Read Well Known Binary stream from PostGIS
|
||||
//void readWKB(const char *, QStringList tables);
|
||||
//! Draw a point on the map canvas
|
||||
@ -70,8 +73,8 @@ public:
|
||||
void testButton();
|
||||
//! About QGis
|
||||
void about();
|
||||
|
||||
public slots:
|
||||
|
||||
public slots:
|
||||
//! Slot to show the map coordinate position of the mouse cursor
|
||||
void showMouseCoordinate(QgsPoint &);
|
||||
//! Show layer properties for the selected layer
|
||||
@ -79,34 +82,34 @@ public slots:
|
||||
//! Show layer properties for selected layer (called by right-click menu)
|
||||
void layerProperties();
|
||||
//! Show the right-click menu for the legend
|
||||
void rightClickLegendMenu(QListViewItem *, const QPoint &, int );
|
||||
void rightClickLegendMenu(QListViewItem *, const QPoint &, int);
|
||||
//! Remove a layer from the map and legend
|
||||
void removeLayer();
|
||||
//! zoom to extent of layer
|
||||
void zoomToLayerExtent();
|
||||
//! test plugin functionality
|
||||
void testPluginFunctions();
|
||||
//! Save window state
|
||||
void saveWindowState();
|
||||
//! Restore the window and toolbar state
|
||||
void restoreWindowState();
|
||||
private:
|
||||
//! zoom to extent of layer
|
||||
void zoomToLayerExtent();
|
||||
//! test plugin functionality
|
||||
void testPluginFunctions();
|
||||
//! Save window state
|
||||
void saveWindowState();
|
||||
//! Restore the window and toolbar state
|
||||
void restoreWindowState();
|
||||
private:
|
||||
//! Popup menu
|
||||
QPopupMenu *popMenu;
|
||||
QPopupMenu * popMenu;
|
||||
//! Legend list view control
|
||||
QListView *legendView;
|
||||
QListView *legendView;
|
||||
//! Map canvas
|
||||
QgsMapCanvas *mapCanvas;
|
||||
QgsMapCanvas *mapCanvas;
|
||||
//! Table of contents (legend) for the map
|
||||
QgsLegend *mapLegend;
|
||||
QCursor *mapCursor;
|
||||
QgsLegend *mapLegend;
|
||||
QCursor *mapCursor;
|
||||
//! scale factor
|
||||
double scaleFactor;
|
||||
//! Current map window extent in real-world coordinates
|
||||
QRect *mapWindow;
|
||||
//! Current map tool
|
||||
int mapTool;
|
||||
QCursor *cursorZoomIn;
|
||||
double scaleFactor;
|
||||
//! Current map window extent in real-world coordinates
|
||||
QRect *mapWindow;
|
||||
//! Current map tool
|
||||
int mapTool;
|
||||
QCursor *cursorZoomIn;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -456,26 +456,30 @@
|
||||
<receiver>QgisAppBase</receiver>
|
||||
<slot>testPluginFunctions()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionOpenTable</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>QgisAppBase</receiver>
|
||||
<slot>attributeTable()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">qgisappbase.ui.h</include>
|
||||
</includes>
|
||||
<slots>
|
||||
<slot>about()</slot>
|
||||
<slot>addDatabaseLayer()</slot>
|
||||
<slot>addLayer()</slot>
|
||||
<slot>drawLayers()</slot>
|
||||
<slot>fileExit()</slot>
|
||||
<slot>fileOpen()</slot>
|
||||
<slot>addDatabaseLayer()</slot>
|
||||
<slot>identify()</slot>
|
||||
<slot>init()</slot>
|
||||
<slot>attributeTable()</slot>
|
||||
<slot>pan()</slot>
|
||||
<slot>testButton()</slot>
|
||||
<slot>testPluginFunctions()</slot>
|
||||
<slot>zoomFull()</slot>
|
||||
<slot>zoomIn()</slot>
|
||||
<slot>zoomOut()</slot>
|
||||
<slot>init()</slot>
|
||||
<slot>drawLayers()</slot>
|
||||
<slot>zoomFull()</slot>
|
||||
<slot>pan()</slot>
|
||||
<slot>about()</slot>
|
||||
<slot>testButton()</slot>
|
||||
<slot>addLayer()</slot>
|
||||
<slot>identify()</slot>
|
||||
<slot>zoomPrevious()</slot>
|
||||
<slot>testPluginFunctions()</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
|
@ -85,6 +85,11 @@ void QgisAppBase::identify()
|
||||
|
||||
}
|
||||
|
||||
void QgisAppBase::attributeTable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QgisAppBase::zoomPrevious()
|
||||
{
|
||||
|
||||
|
@ -15,11 +15,14 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include <iostream>
|
||||
#include <qapplication.h>
|
||||
#include <qcursor.h>
|
||||
#include <qstring.h>
|
||||
#include <qpainter.h>
|
||||
#include <qpen.h>
|
||||
#include <qpointarray.h>
|
||||
#include <qbrush.h>
|
||||
|
||||
#include "qgis.h"
|
||||
#include "qgsrect.h"
|
||||
#include "qgspoint.h"
|
||||
@ -27,9 +30,11 @@
|
||||
#include <qmessagebox.h>
|
||||
#include "qgsdatabaselayer.h"
|
||||
#include "qgsidentifyresults.h"
|
||||
#include "qgsattributetable.h"
|
||||
#include "qgsattributetabledisplay.h"
|
||||
|
||||
QgsDatabaseLayer::QgsDatabaseLayer(const char *conninfo, QString table):
|
||||
QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table)
|
||||
QgsDatabaseLayer::QgsDatabaseLayer(const char *conninfo, QString table):QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo),
|
||||
tableName(table)
|
||||
{
|
||||
// create the database layer and get the needed information
|
||||
// about it from the database
|
||||
@ -420,14 +425,14 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTra
|
||||
void QgsDatabaseLayer::identify(QgsRect * r)
|
||||
{
|
||||
// create a search filter for identifying records
|
||||
|
||||
QString sql = "select * from " + tableName;
|
||||
sql += " where " + geometryColumn;
|
||||
|
||||
QString sql = "select * from " + tableName;
|
||||
sql += " where " + geometryColumn;
|
||||
sql += " && GeometryFromText('BOX3D(" + r->stringRep();
|
||||
sql += ")'::box3d,-1)";
|
||||
qWarning(sql);
|
||||
// select the features
|
||||
PgCursor pgs(dataSource, "identifyCursor");
|
||||
qWarning(sql);
|
||||
// select the features
|
||||
PgCursor pgs(dataSource, "identifyCursor");
|
||||
|
||||
pgs.Declare((const char *) sql, false);
|
||||
int res = pgs.Fetch();
|
||||
@ -435,28 +440,74 @@ void QgsDatabaseLayer::identify(QgsRect * r)
|
||||
QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl;
|
||||
// qWarning(msg);
|
||||
// std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl;
|
||||
// create the results window
|
||||
if(pgs.Tuples() > 0){
|
||||
QgsIdentifyResults *ir = new QgsIdentifyResults();
|
||||
// just show one result - modify this later
|
||||
int numFields = pgs.Fields();
|
||||
for(int i = 0; i < numFields; i++){
|
||||
QString fld = pgs.FieldName(i);
|
||||
int fldType = pgs.FieldType(i);
|
||||
QString val;
|
||||
if(fldType == 16604 ) // geometry
|
||||
val = "(geometry column)";
|
||||
else
|
||||
val = pgs.GetValue(0,i);
|
||||
ir->addAttribute(fld, val);
|
||||
}
|
||||
ir->show();
|
||||
// create the results window
|
||||
if (pgs.Tuples() > 0) {
|
||||
QgsIdentifyResults *ir = new QgsIdentifyResults();
|
||||
// just show one result - modify this later
|
||||
int numFields = pgs.Fields();
|
||||
for (int i = 0; i < numFields; i++) {
|
||||
QString fld = pgs.FieldName(i);
|
||||
int fldType = pgs.FieldType(i);
|
||||
QString val;
|
||||
if (fldType == 16604) // geometry
|
||||
val = "(geometry column)";
|
||||
else
|
||||
val = pgs.GetValue(0, i);
|
||||
ir->addAttribute(fld, val);
|
||||
}
|
||||
ir->setTitle(name());
|
||||
ir->show();
|
||||
|
||||
} else {
|
||||
QMessageBox::information(0, "No features found", "No features were found in the active layer at the point you clicked");
|
||||
}
|
||||
|
||||
}else{
|
||||
QMessageBox::information(0,"No features found","No features were found in the active layer at the point you clicked");
|
||||
}
|
||||
int foo = 0;
|
||||
}
|
||||
void QgsDatabaseLayer::table()
|
||||
{
|
||||
// display the attribute table
|
||||
QString sql = "select * from " + tableName;
|
||||
qWarning(sql);
|
||||
// select the features
|
||||
PgCursor pgs(dataSource, "attributeCursor");
|
||||
|
||||
pgs.Declare((const char *) sql, false);
|
||||
int res = pgs.Fetch();
|
||||
QString msg;
|
||||
QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl;
|
||||
// create the results window
|
||||
if (pgs.Tuples() > 0) {
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
QgsAttributeTableDisplay *at = new QgsAttributeTableDisplay();
|
||||
at->table()->setNumRows(pgs.Tuples());
|
||||
at->table()->setNumCols(pgs.Fields());
|
||||
// set the column headers
|
||||
QHeader *colHeader = at->table()->horizontalHeader();
|
||||
for (int h = 0; h < pgs.Fields(); h++) {
|
||||
colHeader->setLabel(h, pgs.FieldName(h));
|
||||
}
|
||||
// add the data to the rows
|
||||
for (int ir = 0; ir < pgs.Tuples(); ir++) {
|
||||
for (int ic = 0; ic < pgs.Fields(); ic++) {
|
||||
int fldType = pgs.FieldType(ic);
|
||||
QString val;
|
||||
if (fldType == 16604) // geometry -- naughty -- shouldnt code to a value
|
||||
val = "(geometry column)";
|
||||
else
|
||||
val = pgs.GetValue(ir, ic);
|
||||
at->table()->setText(ir, ic, val);
|
||||
}
|
||||
|
||||
}
|
||||
at->table()->setSorting(true);
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
at->setTitle("Attribute table - " + name());
|
||||
at->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int QgsDatabaseLayer::endian()
|
||||
{
|
||||
char *chkEndian = new char[4];
|
||||
|
@ -27,46 +27,52 @@ class QgsRect;
|
||||
*
|
||||
* At present Qgis supports PostGIS "layers" in PostgresQL.
|
||||
*/
|
||||
class QgsDatabaseLayer : public QgsMapLayer {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*! Constructor
|
||||
* @param conninfo Pointer to the connection information required to
|
||||
* connect to PostgresQL
|
||||
*@param table Name of the table in the database that this layer
|
||||
* represents
|
||||
*/
|
||||
QgsDatabaseLayer(const char *conninfo=0, QString table=QString::null);
|
||||
//! Destructor
|
||||
~QgsDatabaseLayer();
|
||||
virtual void draw(QPainter *, QgsRect *, int );
|
||||
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform *cFx);
|
||||
void identify(QgsRect *);
|
||||
private:
|
||||
//! Calculates extent of the layer using SQL and PostGIS functions
|
||||
QgsRect calculateExtent();
|
||||
//! Type geometry contained in the layer. This corresponds to one of the OGIS Simple geometry types
|
||||
QString type;
|
||||
//! WKB type
|
||||
int wkbType;
|
||||
//! Name of the database containing the layer (table)
|
||||
QString database;
|
||||
//! Name of the table containing the features
|
||||
QString tableName;
|
||||
//! Name of the column in the table that contains the geometry for the features
|
||||
QString geometryColumn;
|
||||
//OGIS WKB types
|
||||
|
||||
enum ENDIAN{
|
||||
NDR=1,
|
||||
XDR=0
|
||||
};
|
||||
//! Returns the endian type for the client
|
||||
int endian();
|
||||
/*! Endian type as string
|
||||
* @return XDR or NDR
|
||||
*/
|
||||
QString endianString();
|
||||
class QgsDatabaseLayer:public QgsMapLayer
|
||||
{
|
||||
Q_OBJECT public:
|
||||
/*! Constructor
|
||||
* @param conninfo Pointer to the connection information required to
|
||||
* connect to PostgresQL
|
||||
*@param table Name of the table in the database that this layer
|
||||
* represents
|
||||
*/
|
||||
QgsDatabaseLayer(const char *conninfo = 0, QString table = QString::null);
|
||||
//! Destructor
|
||||
~QgsDatabaseLayer();
|
||||
//! Deprecated draw function
|
||||
virtual void draw(QPainter *, QgsRect *, int);
|
||||
//! Draws the layer using coordinate transformation
|
||||
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cFx);
|
||||
//! Identify the feature found within the search rectangle
|
||||
void identify(QgsRect *);
|
||||
//! Display the attribute table
|
||||
void table();
|
||||
private:
|
||||
//! Calculates extent of the layer using SQL and PostGIS functions
|
||||
QgsRect calculateExtent();
|
||||
//! Type geometry contained in the layer. This corresponds to one of the OGIS Simple geometry types
|
||||
QString type;
|
||||
//! WKB type
|
||||
int wkbType;
|
||||
//! Name of the database containing the layer (table)
|
||||
QString database;
|
||||
//! Name of the table containing the features
|
||||
QString tableName;
|
||||
//! Name of the column in the table that contains the geometry for the features
|
||||
QString geometryColumn;
|
||||
//OGIS WKB types
|
||||
|
||||
enum ENDIAN
|
||||
{
|
||||
NDR = 1,
|
||||
XDR = 0
|
||||
};
|
||||
//! Returns the endian type for the client
|
||||
int endian();
|
||||
/*! Endian type as string
|
||||
* @return XDR or NDR
|
||||
*/
|
||||
QString endianString();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -18,11 +18,21 @@
|
||||
#include <qlistview.h>
|
||||
#include "qgsidentifyresults.h"
|
||||
|
||||
QgsIdentifyResults::QgsIdentifyResults(){
|
||||
QgsIdentifyResults::QgsIdentifyResults()
|
||||
{
|
||||
}
|
||||
QgsIdentifyResults::~QgsIdentifyResults(){
|
||||
|
||||
QgsIdentifyResults::~QgsIdentifyResults()
|
||||
{
|
||||
}
|
||||
|
||||
/** add an attribute and its value to the list */
|
||||
void QgsIdentifyResults::addAttribute(QString field, QString value){
|
||||
QListViewItem *lvi = new QListViewItem(lstResults, field, value);
|
||||
void QgsIdentifyResults::addAttribute(QString field, QString value)
|
||||
{
|
||||
QListViewItem *lvi = new QListViewItem(lstResults, field, value);
|
||||
}
|
||||
|
||||
void QgsIdentifyResults::setTitle(QString title)
|
||||
{
|
||||
setCaption("Identify Results - " + title);
|
||||
}
|
||||
|
@ -25,12 +25,14 @@
|
||||
*@author Gary E.Sherman
|
||||
*/
|
||||
|
||||
class QgsIdentifyResults : public QgsIdentifyResultsBase {
|
||||
public:
|
||||
class QgsIdentifyResults:public QgsIdentifyResultsBase
|
||||
{
|
||||
public:
|
||||
QgsIdentifyResults();
|
||||
~QgsIdentifyResults();
|
||||
/** No descriptions */
|
||||
void addAttribute(QString field, QString value);
|
||||
void addAttribute(QString field, QString value);
|
||||
void setTitle(QString title);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -40,13 +40,28 @@ void QgsLegend::setMapCanvas(QgsMapCanvas * canvas)
|
||||
map = canvas;
|
||||
}
|
||||
|
||||
QString QgsLegend::currentLayer(){
|
||||
QListViewItem *li = listView->currentItem();
|
||||
if(li)
|
||||
return li->text(0);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
QgsMapLayer *QgsLegend::currentLayer()
|
||||
{
|
||||
QgsLegendItem *li = (QgsLegendItem *) listView->currentItem();
|
||||
|
||||
if (li)
|
||||
return li->layer();
|
||||
else
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
QString QgsLegend::currentLayerName()
|
||||
{
|
||||
QListViewItem *li = listView->currentItem();
|
||||
if (li)
|
||||
return li->text(0);
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QgsLegend::update()
|
||||
{
|
||||
// clear the legend
|
||||
|
@ -32,26 +32,28 @@ class QPainter;
|
||||
*@author Gary E.Sherman
|
||||
*/
|
||||
|
||||
class QgsLegend : public QWidget{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class QgsLegend:public QWidget
|
||||
{
|
||||
Q_OBJECT public:
|
||||
/*! Constructor.
|
||||
* @param lv ListView control containing legend items
|
||||
* @param parent Parent widget
|
||||
* @param name Name of the widget
|
||||
*/
|
||||
QgsLegend(QListView *lv, QWidget *parent=0, const char *name=0);
|
||||
QgsLegend(QListView * lv, QWidget * parent = 0, const char *name = 0);
|
||||
//! Destructor
|
||||
~QgsLegend();
|
||||
~QgsLegend();
|
||||
//! Set the pointer to the map canvas
|
||||
void setMapCanvas(QgsMapCanvas *canvas);
|
||||
void setMapCanvas(QgsMapCanvas * canvas);
|
||||
//! Update the legend
|
||||
void update();
|
||||
QString currentLayer();
|
||||
|
||||
private:
|
||||
QListView* listView;
|
||||
QgsMapCanvas *map;
|
||||
QString currentLayerName();
|
||||
|
||||
QgsMapLayer *currentLayer();
|
||||
|
||||
private:
|
||||
QListView * listView;
|
||||
QgsMapCanvas *map;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -413,9 +413,8 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
switch (mapTool) {
|
||||
case QGis::Identify:
|
||||
// call identify method for selected layer
|
||||
QString lyrName = mapLegend->currentLayer();
|
||||
if (!lyrName.isEmpty()) {
|
||||
QgsMapLayer *lyr = layers[lyrName];
|
||||
QgsMapLayer * lyr = mapLegend->currentLayer();
|
||||
if (lyr) {
|
||||
// create the search rectangle
|
||||
double searchRadius = extent().width() * .005;
|
||||
QgsRect *search = new QgsRect();
|
||||
@ -432,6 +431,8 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
"To identify features, you must choose an layer active by clicking on its name in the legend");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ QgsMapLayer::QgsMapLayer(int type, QString lyrname, QString source):layerName(ly
|
||||
valid = true;
|
||||
m_visible = true;
|
||||
// create a default symbol
|
||||
|
||||
|
||||
// Generate the unique ID of this layer
|
||||
QDateTime dt = QDateTime::currentDateTime();
|
||||
ID = lyrname + dt.toString("yyyyMMddhhmmsszzz");
|
||||
@ -148,3 +148,7 @@ void QgsMapLayer::setFeatureType(const int &_newVal)
|
||||
void QgsMapLayer::identify(QgsRect * r)
|
||||
{
|
||||
}
|
||||
|
||||
void QgsMapLayer::table()
|
||||
{
|
||||
}
|
||||
|
@ -34,8 +34,7 @@
|
||||
*/
|
||||
class QgsMapLayer:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_OBJECT public:
|
||||
/*! Constructor
|
||||
* @param type Type of layer as defined in LAYERS enum
|
||||
* @param lyrname Display Name of the layer
|
||||
@ -64,9 +63,12 @@ class QgsMapLayer:public QObject
|
||||
virtual QgsRect calculateExtent();
|
||||
virtual void draw(QPainter *, QgsRect *, int);
|
||||
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cXf);
|
||||
/*! Identify the feature(s) in this layer that are contained in the search rectangle
|
||||
*/
|
||||
virtual void identify(QgsRect *);
|
||||
/*! Identify the feature(s) in this layer that are contained in the search rectangle
|
||||
*/
|
||||
virtual void identify(QgsRect *);
|
||||
/*! Display the attribute table for the layer
|
||||
*/
|
||||
virtual void table();
|
||||
/*! Return the extent of the layer as a QRect
|
||||
*/
|
||||
const QgsRect extent();
|
||||
@ -105,8 +107,7 @@ class QgsMapLayer:public QObject
|
||||
RASTER,
|
||||
DATABASE
|
||||
};
|
||||
signals:
|
||||
void visibilityChanged(void);
|
||||
signals:void visibilityChanged(void);
|
||||
protected:
|
||||
//! Extent of the layer
|
||||
QgsRect layerExtent;
|
||||
@ -118,10 +119,10 @@ class QgsMapLayer:public QObject
|
||||
int feature;
|
||||
private: // Private attributes
|
||||
/** Unique ID of this layer - used to refer to this layer in QGIS code */
|
||||
QString ID;
|
||||
|
||||
QString ID;
|
||||
|
||||
/** Name of the layer - used for display */
|
||||
QString layerName;
|
||||
QString layerName;
|
||||
/** Type of the layer (eg. vector, raster, database */
|
||||
int layerType;
|
||||
|
||||
|
@ -17,13 +17,19 @@
|
||||
***************************************************************************/
|
||||
#include <iostream>
|
||||
#include <strstream>
|
||||
#include <qapplication.h>
|
||||
#include <qcursor.h>
|
||||
#include <qpainter.h>
|
||||
#include <qpointarray.h>
|
||||
#include <qstring.h>
|
||||
#include <qmessagebox.h>
|
||||
#include "qgsrect.h"
|
||||
#include "qgspoint.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsshapefilelayer.h"
|
||||
#include "qgsidentifyresults.h"
|
||||
#include "qgsattributetable.h"
|
||||
#include "qgsattributetabledisplay.h"
|
||||
#include <ogrsf_frmts.h>
|
||||
#include <ogr_geometry.h>
|
||||
|
||||
@ -267,4 +273,89 @@ int QgsShapeFileLayer::endian()
|
||||
|
||||
void QgsShapeFileLayer::identify(QgsRect * r)
|
||||
{
|
||||
OGRGeometry *filter = 0;
|
||||
filter = new OGRPolygon();
|
||||
std::ostrstream wktExtent;
|
||||
wktExtent << "POLYGON ((" << r->stringRep() << "))" << ends;
|
||||
char *wktText = wktExtent.str();
|
||||
|
||||
OGRErr result = ((OGRPolygon *) filter)->importFromWkt(&wktText);
|
||||
if (result == OGRERR_NONE) {
|
||||
|
||||
ogrLayer->SetSpatialFilter(filter);
|
||||
int featureCount = 0;
|
||||
// just id the first feature for now
|
||||
//while (OGRFeature * fet = ogrLayer->GetNextFeature()) {
|
||||
//}
|
||||
|
||||
OGRFeature *fet = ogrLayer->GetNextFeature();
|
||||
if (fet) {
|
||||
// found feature - show it in the identify box
|
||||
QgsIdentifyResults *ir = new QgsIdentifyResults();
|
||||
// just show one result - modify this later
|
||||
int numFields = fet->GetFieldCount();
|
||||
for (int i = 0; i < numFields; i++) {
|
||||
// get the field definition
|
||||
OGRFieldDefn *fldDef = fet->GetFieldDefnRef(i);
|
||||
QString fld = fldDef->GetNameRef();
|
||||
OGRFieldType fldType = fldDef->GetType();
|
||||
QString val;
|
||||
//if(fldType == 16604 ) // geometry
|
||||
val = "(geometry column)";
|
||||
// else
|
||||
val = fet->GetFieldAsString(i);
|
||||
ir->addAttribute(fld, val);
|
||||
}
|
||||
ir->setTitle(name());
|
||||
ir->show();
|
||||
|
||||
} else {
|
||||
QMessageBox::information(0, "No features found", "No features were found in the active layer at the point you clicked");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void QgsShapeFileLayer::table()
|
||||
{
|
||||
// display the attribute table
|
||||
QApplication::setOverrideCursor(Qt::waitCursor);
|
||||
ogrLayer->SetSpatialFilter(0);
|
||||
OGRFeature *fet = ogrLayer->GetNextFeature();
|
||||
int numFields = fet->GetFieldCount();
|
||||
QgsAttributeTableDisplay *at = new QgsAttributeTableDisplay();
|
||||
at->table()->setNumRows(ogrLayer->GetFeatureCount(true));
|
||||
at->table()->setNumCols(numFields);
|
||||
|
||||
int row = 0;
|
||||
// set up the column headers
|
||||
QHeader *colHeader = at->table()->horizontalHeader();
|
||||
for (int h = 0; h < numFields; h++) {
|
||||
OGRFieldDefn *fldDef = fet->GetFieldDefnRef(h);
|
||||
QString fld = fldDef->GetNameRef();
|
||||
colHeader->setLabel(h, fld);
|
||||
}
|
||||
while (fet) {
|
||||
for (int i = 0; i < numFields; i++) {
|
||||
// get the field values
|
||||
QString val;
|
||||
//if(fldType == 16604 ) // geometry
|
||||
val = "(geometry column)";
|
||||
// else
|
||||
val = fet->GetFieldAsString(i);
|
||||
|
||||
at->table()->setText(row, i, val);
|
||||
|
||||
}
|
||||
row++;
|
||||
delete fet;
|
||||
fet = ogrLayer->GetNextFeature();
|
||||
|
||||
}
|
||||
at->table()->setSorting(true);
|
||||
|
||||
|
||||
at->setTitle("Attribute table - " + name());
|
||||
QApplication::restoreOverrideCursor();
|
||||
at->show();
|
||||
|
||||
}
|
||||
|
@ -29,46 +29,52 @@ class OGRDataSource;
|
||||
* \brief Shapefile layer
|
||||
*/
|
||||
|
||||
class QgsShapeFileLayer : public QgsMapLayer {
|
||||
Q_OBJECT
|
||||
public:
|
||||
class QgsShapeFileLayer:public QgsMapLayer
|
||||
{
|
||||
Q_OBJECT public:
|
||||
|
||||
//! Constructor
|
||||
QgsShapeFileLayer( QString baseName=0, QString path=0);
|
||||
//! Constructor
|
||||
QgsShapeFileLayer(QString baseName = 0, QString path = 0);
|
||||
//! Destructor
|
||||
~QgsShapeFileLayer();
|
||||
void identify(QgsRect *);
|
||||
|
||||
enum SHAPETYPE {
|
||||
Point,
|
||||
Line,
|
||||
Polygon
|
||||
};
|
||||
~QgsShapeFileLayer();
|
||||
//! Identify feature found within the search rectangle
|
||||
void identify(QgsRect *);
|
||||
//! Display the attribute table
|
||||
void table();
|
||||
enum SHAPETYPE
|
||||
{
|
||||
Point,
|
||||
Line,
|
||||
Polygon
|
||||
};
|
||||
|
||||
private: // Private attributes
|
||||
void draw(QPainter *p, QgsRect *viewExtent, QgsCoordinateTransform *cXf);
|
||||
OGRDataSource *ogrDataSource;
|
||||
|
||||
OGRLayer *ogrLayer;
|
||||
private: // Private attributes
|
||||
//! Draws the layer using coordinate transformation
|
||||
void draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf);
|
||||
OGRDataSource *ogrDataSource;
|
||||
|
||||
OGRLayer *ogrLayer;
|
||||
/** */
|
||||
bool registered;
|
||||
enum ENDIAN{
|
||||
NDR=1,
|
||||
XDR=0
|
||||
};
|
||||
enum WKBTYPE{
|
||||
WKBPoint=1,
|
||||
WKBLineString,
|
||||
WKBPolygon,
|
||||
WKBMultiPoint,
|
||||
WKBMultiLineString,
|
||||
WKBMultiPolygon
|
||||
};
|
||||
private: // Private methods
|
||||
bool registered;
|
||||
enum ENDIAN
|
||||
{
|
||||
NDR = 1,
|
||||
XDR = 0
|
||||
};
|
||||
enum WKBTYPE
|
||||
{
|
||||
WKBPoint = 1,
|
||||
WKBLineString,
|
||||
WKBPolygon,
|
||||
WKBMultiPoint,
|
||||
WKBMultiLineString,
|
||||
WKBMultiPolygon
|
||||
};
|
||||
private: // Private methods
|
||||
/** No descriptions */
|
||||
void registerFormats();
|
||||
int endian();
|
||||
|
||||
void registerFormats();
|
||||
int endian();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
13
src/src.pro
13
src/src.pro
@ -30,7 +30,9 @@ HEADERS += qgsdbsourceselectbase.ui.h \
|
||||
qgslegend.h \
|
||||
qgslegenditem.h \
|
||||
qgslayerproperties.h \
|
||||
qgsidentifyresults.h
|
||||
qgsidentifyresults.h \
|
||||
qgsattributetable.h \
|
||||
qgsattributetabledisplay.h
|
||||
|
||||
INTERFACES += qgsdbsourceselectbase.ui \
|
||||
qgisappbase.ui \
|
||||
@ -38,7 +40,8 @@ INTERFACES += qgsdbsourceselectbase.ui \
|
||||
qgslegenditembase.ui \
|
||||
qgsabout.ui \
|
||||
qgslayerpropertiesbase.ui \
|
||||
qgsidentifyresultsbase.ui
|
||||
qgsidentifyresultsbase.ui \
|
||||
qgsattributetablebase.ui
|
||||
SOURCES += main.cpp \
|
||||
qgisapp.cpp \
|
||||
qgsdatabaselayer.cpp \
|
||||
@ -46,7 +49,7 @@ SOURCES += main.cpp \
|
||||
qgsmapcanvas.cpp \
|
||||
qgsmaplayer.cpp \
|
||||
qgsrasterlayer.cpp \
|
||||
qgsshapefilelayer.cpp \
|
||||
qgsshapefilelayer.cpp \
|
||||
qgsdbsourceselect.cpp \
|
||||
qgsnewconnection.cpp \
|
||||
qgsrect.cpp \
|
||||
@ -59,4 +62,6 @@ SOURCES += main.cpp \
|
||||
qgslinesymbol.cpp \
|
||||
qgspolygonsymbol.cpp \
|
||||
qgslayerproperties.cpp \
|
||||
qgsidentifyresults.cpp
|
||||
qgsidentifyresults.cpp \
|
||||
qgsattributetable.cpp \
|
||||
qgsattributetabledisplay.cpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user