mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
legend mods
git-svn-id: http://svn.osgeo.org/qgis/trunk@86 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
de7985e57c
commit
fb6ea02668
@ -84,7 +84,7 @@ install_location=
|
||||
type=HEADER
|
||||
|
||||
[src/Makefile.am]
|
||||
files=src/main.cpp,src/qgisapp.cpp,src/qgscoordinatetransform.cpp,src/qgsdatabaselayer.cpp,src/qgsdatasource.cpp,src/qgsdbsourceselect.cpp,src/qgsmapcanvas.cpp,src/qgsmaplayer.cpp,src/qgsnewconnection.cpp,src/qgspoint.cpp,src/qgsrasterlayer.cpp,src/qgsrect.cpp,src/qgisapp.h,src/qgscoordinatetransform.h,src/qgsdatabaselayer.h,src/qgsdatasource.h,src/qgsdbsourceselect.h,src/qgslinesymbol.h,src/qgsmapcanvas.h,src/qgsmaplayer.h,src/qgsmarkersymbol.h,src/qgsnewconnection.h,src/qgspoint.h,src/qgspolygonsymbol.h,src/qgsrasterlayer.h,src/qgsrect.h,src/qgsshapefilelayer.h,src/qgisappbase.ui,src/qgsdbsourceselectbase.ui,src/qgsnewconnectionbase.ui,src/qgscustomsymbol.cpp,src/qgscustomsymbol.h,src/qgslegend.h,src/qgslegend.cpp,src/qgslegenditem.cpp,src/qgslegenditem.h,src/qgssymbol.h,src/qgstable.h,src/qgsshapefilelayer.cpp
|
||||
files=src/main.cpp,src/qgisapp.cpp,src/qgscoordinatetransform.cpp,src/qgsdatabaselayer.cpp,src/qgsdatasource.cpp,src/qgsdbsourceselect.cpp,src/qgsmapcanvas.cpp,src/qgsmaplayer.cpp,src/qgsnewconnection.cpp,src/qgspoint.cpp,src/qgsrasterlayer.cpp,src/qgsrect.cpp,src/qgisapp.h,src/qgscoordinatetransform.h,src/qgsdatabaselayer.h,src/qgsdatasource.h,src/qgsdbsourceselect.h,src/qgslinesymbol.h,src/qgsmapcanvas.h,src/qgsmaplayer.h,src/qgsmarkersymbol.h,src/qgsnewconnection.h,src/qgspoint.h,src/qgspolygonsymbol.h,src/qgsrasterlayer.h,src/qgsrect.h,src/qgsshapefilelayer.h,src/qgisappbase.ui,src/qgsdbsourceselectbase.ui,src/qgsnewconnectionbase.ui,src/qgscustomsymbol.cpp,src/qgscustomsymbol.h,src/qgslegend.h,src/qgslegend.cpp,src/qgslegenditem.cpp,src/qgslegenditem.h,src/qgssymbol.h,src/qgstable.h,src/qgsshapefilelayer.cpp,src/qgslegenditembase.h
|
||||
sharedlib_LDFLAGS=-version-info 0:0:0
|
||||
sharedlib_rootname=src
|
||||
sub_dirs=
|
||||
@ -204,6 +204,12 @@ install=false
|
||||
install_location=
|
||||
type=HEADER
|
||||
|
||||
[src/qgslegenditembase.h]
|
||||
dist=true
|
||||
install=false
|
||||
install_location=
|
||||
type=HEADER
|
||||
|
||||
[src/qgslinesymbol.h]
|
||||
dist=true
|
||||
install=false
|
||||
|
@ -1,6 +1,6 @@
|
||||
#############################################################################
|
||||
# Makefile for building: qgis
|
||||
# Generated by qmake (1.03a) on: Thu Aug 1 21:00:46 2002
|
||||
# Generated by qmake (1.03a) on: Sat Aug 3 08:26:34 2002
|
||||
# Project: src.pro
|
||||
# Template: app
|
||||
# Command: $(QMAKE) src.pro
|
||||
@ -94,30 +94,36 @@ OBJECTS = main.o \
|
||||
qgslegenditem.o \
|
||||
qgsdbsourceselectbase.o \
|
||||
qgisappbase.o \
|
||||
qgsnewconnectionbase.o
|
||||
qgsnewconnectionbase.o \
|
||||
qgslegenditembase.o
|
||||
FORMS = qgsdbsourceselectbase.ui \
|
||||
qgisappbase.ui \
|
||||
qgsnewconnectionbase.ui
|
||||
qgsnewconnectionbase.ui \
|
||||
qgslegenditembase.ui
|
||||
UICDECLS = qgsdbsourceselectbase.h \
|
||||
qgisappbase.h \
|
||||
qgsnewconnectionbase.h
|
||||
qgsnewconnectionbase.h \
|
||||
qgslegenditembase.h
|
||||
UICIMPLS = qgsdbsourceselectbase.cpp \
|
||||
qgisappbase.cpp \
|
||||
qgsnewconnectionbase.cpp
|
||||
qgsnewconnectionbase.cpp \
|
||||
qgslegenditembase.cpp
|
||||
SRCMOC = moc_qgisapp.cpp \
|
||||
moc_qgsmapcanvas.cpp \
|
||||
moc_qgslegend.cpp \
|
||||
moc_qgslegenditem.cpp \
|
||||
moc_qgsdbsourceselectbase.cpp \
|
||||
moc_qgisappbase.cpp \
|
||||
moc_qgsnewconnectionbase.cpp
|
||||
moc_qgsnewconnectionbase.cpp \
|
||||
moc_qgslegenditembase.cpp
|
||||
OBJMOC = moc_qgisapp.o \
|
||||
moc_qgsmapcanvas.o \
|
||||
moc_qgslegend.o \
|
||||
moc_qgslegenditem.o \
|
||||
moc_qgsdbsourceselectbase.o \
|
||||
moc_qgisappbase.o \
|
||||
moc_qgsnewconnectionbase.o
|
||||
moc_qgsnewconnectionbase.o \
|
||||
moc_qgslegenditembase.o
|
||||
DIST = src.pro
|
||||
QMAKE_TARGET = qgis
|
||||
DESTDIR =
|
||||
@ -193,6 +199,7 @@ qgisapp.o: qgisapp.cpp qgsrect.h \
|
||||
qgslegend.h \
|
||||
qgsdbsourceselect.h \
|
||||
qgsdatabaselayer.h \
|
||||
qgsshapefilelayer.h \
|
||||
qgis.h \
|
||||
qgisapp.h \
|
||||
xpm/qgis.xpm \
|
||||
@ -237,11 +244,12 @@ qgsrasterlayer.o: qgsrasterlayer.cpp qgsrasterlayer.h \
|
||||
qgscoordinatetransform.h \
|
||||
qgssymbol.h
|
||||
|
||||
qgsshapefilelayer.o: qgsshapefilelayer.cpp qgsshapefilelayer.h \
|
||||
qgsshapefilelayer.o: qgsshapefilelayer.cpp qgsrect.h \
|
||||
qgspoint.h \
|
||||
qgscoordinatetransform.h \
|
||||
qgsshapefilelayer.h \
|
||||
qgsmaplayer.h \
|
||||
qgsdatasource.h \
|
||||
qgsrect.h \
|
||||
qgscoordinatetransform.h \
|
||||
qgssymbol.h
|
||||
|
||||
qgsdbsourceselect.o: qgsdbsourceselect.cpp xpm/point_layer.xpm \
|
||||
@ -285,6 +293,12 @@ qgsnewconnectionbase.h: qgsnewconnectionbase.ui
|
||||
qgsnewconnectionbase.cpp: qgsnewconnectionbase.h qgsnewconnectionbase.ui
|
||||
$(UIC) qgsnewconnectionbase.ui -i qgsnewconnectionbase.h -o qgsnewconnectionbase.cpp
|
||||
|
||||
qgslegenditembase.h: qgslegenditembase.ui
|
||||
$(UIC) qgslegenditembase.ui -o qgslegenditembase.h
|
||||
|
||||
qgslegenditembase.cpp: qgslegenditembase.h qgslegenditembase.ui
|
||||
$(UIC) qgslegenditembase.ui -i qgslegenditembase.h -o qgslegenditembase.cpp
|
||||
|
||||
qgsdbsourceselectbase.o: qgsdbsourceselectbase.cpp qgsdbsourceselectbase.ui.h \
|
||||
qgsdbsourceselectbase.h
|
||||
|
||||
@ -293,6 +307,8 @@ qgisappbase.o: qgisappbase.cpp qgisappbase.ui.h \
|
||||
|
||||
qgsnewconnectionbase.o: qgsnewconnectionbase.cpp qgsnewconnectionbase.h
|
||||
|
||||
qgslegenditembase.o: qgslegenditembase.cpp qgslegenditembase.h
|
||||
|
||||
moc_qgisapp.o: moc_qgisapp.cpp qgisapp.h qgisappbase.h
|
||||
|
||||
moc_qgsmapcanvas.o: moc_qgsmapcanvas.cpp qgsmapcanvas.h qgsrect.h \
|
||||
@ -308,6 +324,8 @@ moc_qgisappbase.o: moc_qgisappbase.cpp qgisappbase.h
|
||||
|
||||
moc_qgsnewconnectionbase.o: moc_qgsnewconnectionbase.cpp qgsnewconnectionbase.h
|
||||
|
||||
moc_qgslegenditembase.o: moc_qgslegenditembase.cpp qgslegenditembase.h
|
||||
|
||||
moc_qgisapp.cpp: $(MOC) qgisapp.h
|
||||
$(MOC) qgisapp.h -o moc_qgisapp.cpp
|
||||
|
||||
@ -329,6 +347,9 @@ moc_qgisappbase.cpp: $(MOC) qgisappbase.h
|
||||
moc_qgsnewconnectionbase.cpp: $(MOC) qgsnewconnectionbase.h
|
||||
$(MOC) qgsnewconnectionbase.h -o moc_qgsnewconnectionbase.cpp
|
||||
|
||||
moc_qgslegenditembase.cpp: $(MOC) qgslegenditembase.h
|
||||
$(MOC) qgslegenditembase.h -o moc_qgslegenditembase.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install: all
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <qlayout.h>
|
||||
#include <qwmatrix.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qvbox.h>
|
||||
#include <libpq++.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
@ -65,6 +66,9 @@ QgisApp::QgisApp (QWidget * parent, const char *name,
|
||||
mapCanvas->setMinimumWidth (400);
|
||||
FrameLayout->addWidget (split, 0, 0);
|
||||
mapLegend->setBackgroundColor (QColor (192, 192, 192));
|
||||
mapLegend->setMapCanvas(mapCanvas);
|
||||
|
||||
|
||||
connect (mapCanvas, SIGNAL (xyCoordinates (QgsPoint &)), this,
|
||||
SLOT (showMouseCoordinate (QgsPoint &)));
|
||||
|
||||
@ -76,7 +80,7 @@ QgisApp::~QgisApp ()
|
||||
void QgisApp::addLayer ()
|
||||
{
|
||||
QStringList files =
|
||||
QFileDialog::getOpenFileNames (0, 0, this, "open files dialog",
|
||||
QFileDialog::getOpenFileNames ("Shapefiles (*.shp);;All files (*.*)", 0, this, "open files dialog",
|
||||
"Select one or more layers to add");
|
||||
QStringList::Iterator it = files.begin ();
|
||||
while (it != files.end ())
|
||||
@ -107,6 +111,7 @@ void QgisApp::addLayer ()
|
||||
// update legend
|
||||
/*! \todo Need legend scrollview and legenditem classes */
|
||||
// draw the map
|
||||
mapLegend->update();
|
||||
mapCanvas->render2 ();
|
||||
statusBar ()->message (mapCanvas->extent ().stringRep ());
|
||||
|
||||
@ -143,6 +148,7 @@ void QgisApp::addDatabaseLayer ()
|
||||
qApp->processEvents ();
|
||||
// update legend
|
||||
/*! \todo Need legend scrollview and legenditem classes */
|
||||
mapLegend->update();
|
||||
// draw the map
|
||||
mapCanvas->render2 ();
|
||||
statusBar ()->message (mapCanvas->extent ().stringRep ());
|
||||
|
@ -23,6 +23,7 @@ class QCanvasView;
|
||||
class QStringList;
|
||||
class QgsPoint;
|
||||
class QgsLegend;
|
||||
class QVBox;
|
||||
#include "qgisappbase.h"
|
||||
|
||||
class QgsMapCanvas;
|
||||
@ -71,7 +72,7 @@ QgsLegend *mapLegend;
|
||||
QRect *mapWindow;
|
||||
//! Current map tool
|
||||
int mapTool;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -15,14 +15,66 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <map>
|
||||
#include <qstring.h>
|
||||
#include <qpainter.h>
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgslegenditem.h"
|
||||
#include "qgslegend.h"
|
||||
|
||||
QgsLegend::QgsLegend (QWidget * parent, const char *name):QScrollView (parent,
|
||||
name)
|
||||
{
|
||||
//legendContainer = new QVBox(viewport());
|
||||
// addChild(legendContainer);
|
||||
|
||||
}
|
||||
|
||||
QgsLegend::~QgsLegend ()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsLegend::drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph){
|
||||
// Calculate the coordinates...
|
||||
int x1 = 0;
|
||||
int y1 = 0;
|
||||
int x2 = width();
|
||||
int y2 = height();//map->layerCount() * 35;
|
||||
|
||||
// Clip the coordinates so X/Windows will not have problems...
|
||||
if (x1 < clipx) x1=clipx;
|
||||
if (y1 < clipy) y1=clipy;
|
||||
if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
|
||||
if (y2 > clipy+cliph-1) y2=clipy+cliph-1;
|
||||
|
||||
// Paint using the small coordinates...
|
||||
if ( x2 >= x1 && y2 >= y1 )
|
||||
p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
|
||||
|
||||
|
||||
}
|
||||
void QgsLegend::setMapCanvas(QgsMapCanvas *canvas){
|
||||
map = canvas;
|
||||
}
|
||||
|
||||
void QgsLegend::update(){
|
||||
resizeContents(width(),height());
|
||||
QPainter *p = new QPainter(this);
|
||||
drawContents(p, 0,0,width(),height());
|
||||
enableClipper(true);
|
||||
|
||||
// clear the legend
|
||||
|
||||
|
||||
// Get the list of layers in order from the
|
||||
// map canvas and add legenditems to the legend
|
||||
|
||||
for(int idx=0; idx < map->layerCount(); idx++){
|
||||
QgsMapLayer *lyr = map->getZpos(idx);
|
||||
QgsLegendItem *li = new QgsLegendItem(lyr, this);
|
||||
addChild(li,0,idx*60);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
#ifndef QGSLEGEND_H
|
||||
#define QGSLEGEND_H
|
||||
#include <qscrollview.h>
|
||||
|
||||
class QgsMapCanvas;
|
||||
class QVBox;
|
||||
class QPainter;
|
||||
/**
|
||||
*@author Gary E.Sherman
|
||||
*/
|
||||
@ -29,6 +31,15 @@ class QgsLegend : public QScrollView{
|
||||
public:
|
||||
QgsLegend(QWidget *parent=0, const char *name=0);
|
||||
~QgsLegend();
|
||||
//! Set the pointer to the map canvas
|
||||
void setMapCanvas(QgsMapCanvas *canvas);
|
||||
//! Update the legend
|
||||
void update();
|
||||
void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
|
||||
private:
|
||||
QgsMapCanvas *map;
|
||||
// child of legend control that contains the legenditems
|
||||
QVBox *legendContainer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -15,11 +15,18 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include <qlabel.h>
|
||||
#include <qcheckbox.h>
|
||||
#include "qgssymbol.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgslegenditem.h"
|
||||
|
||||
QgsLegendItem::QgsLegendItem ()
|
||||
|
||||
QgsLegendItem::QgsLegendItem (QgsMapLayer *lyr, QWidget * parent, const char *name)
|
||||
: QgsLegendItemBase(parent, name), layer(lyr)
|
||||
{
|
||||
chkVisible->setChecked(lyr->visible());
|
||||
lblLayerName->setText(lyr->name());
|
||||
}
|
||||
|
||||
QgsLegendItem::~QgsLegendItem ()
|
||||
|
@ -19,16 +19,17 @@
|
||||
#ifndef QGSLEGENDITEM_H
|
||||
#define QGSLEGENDITEM_H
|
||||
#include <qwidget.h>
|
||||
|
||||
#include "qgslegenditembase.h"
|
||||
class QgsMapLayer;
|
||||
class QgsSymbol;
|
||||
/**
|
||||
*@author Gary E.Sherman
|
||||
*/
|
||||
|
||||
class QgsLegendItem : public QWidget{
|
||||
class QgsLegendItem : public QgsLegendItemBase{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QgsLegendItem();
|
||||
QgsLegendItem(QgsMapLayer *lyr=0, QWidget * parent=0, const char *name=0);
|
||||
~QgsLegendItem();
|
||||
/** Write property of QString layerName. */
|
||||
virtual void setLayerName( const QString& _newVal);
|
||||
@ -36,6 +37,8 @@ public:
|
||||
virtual void setDisplayName( const QString& _newVal);
|
||||
private: // Private attributes
|
||||
/** */
|
||||
/** */
|
||||
QgsMapLayer * layer;
|
||||
QgsSymbol * symbol;
|
||||
public: // Public attributes
|
||||
/** */
|
||||
|
101
qgis/src/qgslegenditembase.ui
Normal file
101
qgis/src/qgslegenditembase.ui
Normal file
File diff suppressed because one or more lines are too long
@ -55,10 +55,21 @@ void QgsMapCanvas::addLayer (QgsMapLayer * lyr)
|
||||
|
||||
}
|
||||
updateFullExtent (lyr->extent ());
|
||||
// set zpos to something...
|
||||
// increment zpos for all layers in the map
|
||||
incrementZpos();
|
||||
lyr->setZ(layers.size()-1);
|
||||
updateZpos();
|
||||
zOrder.push_back(lyr->name());
|
||||
//lyr->zpos = 0;
|
||||
}
|
||||
|
||||
void QgsMapCanvas::incrementZpos(){
|
||||
}
|
||||
void QgsMapCanvas::updateZpos(){
|
||||
}
|
||||
QgsMapLayer * QgsMapCanvas::getZpos(int index){
|
||||
QString name = zOrder[index];
|
||||
return layers[name];
|
||||
}
|
||||
void QgsMapCanvas::render2 ()
|
||||
{
|
||||
QPainter *paint = new QPainter ();
|
||||
@ -353,3 +364,11 @@ void QgsMapCanvas::updateFullExtent (QgsRect r)
|
||||
if (r.yMax () > fullExtent.yMax ())
|
||||
fullExtent.setYmax (r.yMax ());
|
||||
}
|
||||
/*const std::map<QString,QgsMapLayer *> * QgsMapCanvas::mapLayers(){
|
||||
return &layers;
|
||||
}
|
||||
*/
|
||||
int QgsMapCanvas::layerCount(){
|
||||
int numLayers = layers.size();
|
||||
return layers.size();
|
||||
}
|
@ -61,6 +61,10 @@ public:
|
||||
virtual void setbgColor( const QColor& _newVal);
|
||||
/** Updates the full extent to include the mbr of the rectangle r */
|
||||
void updateFullExtent(QgsRect r);
|
||||
//! return the map layer at postion index in the layer stack
|
||||
QgsMapLayer * getZpos(int index);
|
||||
//! return number of layers on the map
|
||||
int layerCount();
|
||||
signals:
|
||||
void xyCoordinates(QgsPoint &p);
|
||||
private:
|
||||
@ -70,6 +74,8 @@ public:
|
||||
void paintEvent(QPaintEvent *pe);
|
||||
//! map containing the layers by name
|
||||
std::map<QString,QgsMapLayer *>layers;
|
||||
//! vector containing the names of layers in zorder
|
||||
std::vector<QString> zOrder;
|
||||
//! Full extent of the map canvas
|
||||
QgsRect fullExtent;
|
||||
//! Current extent
|
||||
@ -95,6 +101,8 @@ public:
|
||||
/** Flag to indicate a map canvas drag operation is taking place */
|
||||
bool dragging;
|
||||
std::vector<QColor> initialColor;
|
||||
void incrementZpos();
|
||||
void updateZpos();
|
||||
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,7 @@ layerName (lyrname), layerType (type)
|
||||
// assume the layer is valid (data source exists and can be used)
|
||||
// until we learn otherwise
|
||||
valid = true;
|
||||
m_visible = true;
|
||||
}
|
||||
|
||||
QgsMapLayer::~QgsMapLayer ()
|
||||
@ -104,4 +105,7 @@ void QgsMapLayer::setZ (int zorder)
|
||||
}
|
||||
bool QgsMapLayer::isValid(){
|
||||
return valid;
|
||||
}
|
||||
}
|
||||
bool QgsMapLayer::visible(){
|
||||
return m_visible;
|
||||
}
|
@ -79,7 +79,8 @@ class QgsMapLayer : public QgsDataSource {
|
||||
void setZ(int zorder);
|
||||
/** No descriptions */
|
||||
int z();
|
||||
|
||||
//! Visibility of the layer
|
||||
bool visible();
|
||||
public: // Public attributes
|
||||
//! Layers enum defining the types of layers that can be added to a map
|
||||
enum LAYERS {
|
||||
@ -104,7 +105,7 @@ class QgsMapLayer : public QgsDataSource {
|
||||
QString tag;
|
||||
/** */
|
||||
QgsSymbol * m_symbol;
|
||||
|
||||
bool m_visible;
|
||||
public: // Public attributes
|
||||
/** */
|
||||
QString m_labelField;
|
||||
|
@ -86,7 +86,7 @@ void
|
||||
if (result == OGRERR_NONE)
|
||||
{
|
||||
|
||||
ogrLayer->SetSpatialFilter (filter);
|
||||
ogrLayer->SetSpatialFilter (filter);
|
||||
int featureCount = 0;
|
||||
while (OGRFeature * fet = ogrLayer->GetNextFeature ())
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ HEADERS += qgsdbsourceselectbase.ui.h \
|
||||
qgslegend.h \
|
||||
qgslegenditem.h
|
||||
|
||||
INTERFACES += qgsdbsourceselectbase.ui qgisappbase.ui qgsnewconnectionbase.ui
|
||||
INTERFACES += qgsdbsourceselectbase.ui qgisappbase.ui qgsnewconnectionbase.ui qgslegenditembase.ui
|
||||
SOURCES += main.cpp \
|
||||
qgisapp.cpp \
|
||||
qgsdatabaselayer.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user