mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
qgsgrassedit.h:
- added include for <vector>
qgis.h:
- added WKBUnknown to enumerated list to be used as error state
qgisapp.cpp:
- fixed a for loop
qgisapp.h, qgisiface.h, qgslegend.h, qgslegenditem.h, qgsmapcanvs.h, qgsvectorlayer.h:
- made copy ctor and assignment operator private since we won't be copying
any of these
qgsattributetable.cpp, qgsrasterlayer.cpp, qgssymbologyutils.cpp:
- functions that say they return something should actually return something
*renderer.h:
- made dtors virtual
qgscoordinatetransform.h:
- added initializer for xMax
qgsgeomtypedialog.cpp:
- added return of WKBUnknown when given bad data
qgslabel.cpp, qgslabeldialog.cpp:
- used static_cast to stomp compiler warning
qgsmapcanvas.cpp:
- made CanvasProperties a class form struct, partly to find work-around for
gcc bug and partly to ensure that ctor and assignment operator were
disabled
- ensured that members were in the same order in initializer list as they
were declared
- now use QgsScaleCalculator::units
qgsproject.cpp:
- now read and write map units; still need to tie it in with more code
qgsprojectproperties.cpp:
- now use canonical map units stored in QgsProject singleton object
qgsscalecalculator:
- now prefer to use QgsScaleCalculator::units instead of int
And many minor formatting changes.
git-svn-id: http://svn.osgeo.org/qgis/trunk@2175 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
2a55f171db
commit
5a3869e3b3
@ -3,6 +3,10 @@ ChangeLog,v 1.200 2004/10/21 17:27:35 mcoletti Exp
|
||||
------------------------------------------------------------------------------
|
||||
Version 0.6 'Simon' .... development version
|
||||
|
||||
2004-10-26 [mcoletti] 0.5.0devel13
|
||||
** regarding saving and restoring units in project files.
|
||||
** made many minor bug fixes and tidying up
|
||||
|
||||
2004-10-22 [larsl] 0.5.0devel12
|
||||
** Removed more unused code in the GPS plugin, changed the GPS plugin source
|
||||
to follow the coding standards better
|
||||
|
||||
@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
|
||||
MAJOR_VERSION=0
|
||||
MINOR_VERSION=5
|
||||
MICRO_VERSION=0
|
||||
EXTRA_VERSION=12
|
||||
EXTRA_VERSION=13
|
||||
if test $EXTRA_VERSION -eq 0; then
|
||||
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
|
||||
else
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#ifndef QGSGRASSEDIT_H
|
||||
#define QGSGRASSEDIT_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <qpointarray.h>
|
||||
#include <qcursor.h>
|
||||
#include <qpen.h>
|
||||
|
||||
@ -65,7 +65,8 @@ namespace QGis
|
||||
WKBPolygon,
|
||||
WKBMultiPoint,
|
||||
WKBMultiLineString,
|
||||
WKBMultiPolygon
|
||||
WKBMultiPolygon,
|
||||
WKBUnknown
|
||||
};
|
||||
enum VectorType
|
||||
{
|
||||
|
||||
@ -1493,7 +1493,7 @@ void QgisApp::saveMapAsImage()
|
||||
// get a list of supported output image types
|
||||
int myCounterInt=0;
|
||||
QString myFilters;
|
||||
for (myCounterInt;myCounterInt < QImageIO::outputFormats().count(); myCounterInt++ )
|
||||
for ( ; myCounterInt < QImageIO::outputFormats().count(); myCounterInt++ )
|
||||
{
|
||||
QString myFormat=QString(QImageIO::outputFormats().at( myCounterInt ));
|
||||
QString myFilter = createFileFilter_(myFormat + " format", "*."+myFormat);
|
||||
|
||||
@ -341,6 +341,13 @@ public slots:
|
||||
void setLayerOverviewStatus(QString theLayerId, bool theVisibilityFlag);
|
||||
void drawExtentRectangle(QPainter *);
|
||||
private:
|
||||
|
||||
/// QgisApp aren't copyable
|
||||
QgisApp( QgisApp const & );
|
||||
|
||||
/// QgisApp aren't copyable
|
||||
QgisApp & operator=( QgisApp const & );
|
||||
|
||||
//! A central registry that keeps track of all loaded layers.
|
||||
// prefer QgsMapLayerRegistry::instance() to emphasize Singleton
|
||||
///QgsMapLayerRegistry * mMapLayerRegistry;
|
||||
|
||||
@ -86,6 +86,13 @@ class QgisIface : public QgisInterface{
|
||||
/** Return a pointer to the map layer registry */
|
||||
QgsMapLayerRegistry * getLayerRegistry();
|
||||
private:
|
||||
|
||||
/// QgisIface aren't copied
|
||||
QgisIface( QgisIface const & );
|
||||
|
||||
/// QgisIface aren't copied
|
||||
QgisIface & operator=( QgisIface const & );
|
||||
|
||||
//! Pointer to the QgisApp object
|
||||
QgisApp *qgis;
|
||||
};
|
||||
|
||||
@ -159,6 +159,10 @@ void QgsAttributeTable::sortColumn(int col, bool ascending, bool wholeRows)
|
||||
repaintContents();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
XXX Doesn't QString have something ilke this already?
|
||||
*/
|
||||
int QgsAttributeTable::compareItems(QString s1, QString s2, bool ascending, bool alphanumeric)
|
||||
{
|
||||
if (alphanumeric)
|
||||
@ -212,6 +216,9 @@ int QgsAttributeTable::compareItems(QString s1, QString s2, bool ascending, bool
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // XXX has to return something; is this reasonable?
|
||||
|
||||
}
|
||||
|
||||
void QgsAttributeTable::qsort(int lower, int upper, int col, bool ascending, bool alphanumeric)
|
||||
|
||||
@ -33,7 +33,7 @@ class QgsContinuousColRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsContinuousColRenderer();
|
||||
~QgsContinuousColRenderer();
|
||||
virtual ~QgsContinuousColRenderer();
|
||||
/**Sets the initial symbology configuration for a layer. Besides of applying default symbology settings, an instance of the corresponding renderer dialog is created and associated with the layer (or with the property dialog, if pr is not 0). Finally, a pixmap for the legend is drawn (or, if pr is not 0, it is stored in the property dialog, until the settings are applied).
|
||||
@param layer the vector layer associated with the renderer
|
||||
@param pr the property dialog. This is only needed if the renderer is created from the property dialog and not yet associated with the vector layer, otherwise 0*/
|
||||
|
||||
@ -92,8 +92,15 @@ class QgsCoordinateTransform{
|
||||
|
||||
};
|
||||
|
||||
inline QgsCoordinateTransform::QgsCoordinateTransform(double mupp, double ymax,
|
||||
double ymin, double xmin):mapUnitsPerPixel(mupp), yMax(ymax), yMin(ymin), xMin(xmin)
|
||||
inline QgsCoordinateTransform::QgsCoordinateTransform(double mupp,
|
||||
double ymax,
|
||||
double ymin,
|
||||
double xmin)
|
||||
: mapUnitsPerPixel(mupp),
|
||||
yMax(ymax),
|
||||
yMin(ymin),
|
||||
xMin(xmin),
|
||||
xMax(0) // XXX wasn't originally specified? Why?
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -44,4 +44,6 @@ QGis::WKBTYPE QgsGeomTypeDialog::selectedType()
|
||||
{
|
||||
return QGis::WKBPolygon;
|
||||
}
|
||||
|
||||
return QGis::WKBUnknown;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ class QgsGraduatedMaRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsGraduatedMaRenderer();
|
||||
~QgsGraduatedMaRenderer();
|
||||
virtual ~QgsGraduatedMaRenderer();
|
||||
/**Adds a new item
|
||||
\param ri a pointer to the QgsRangeRenderItem to be inserted. It has to be created using the new operator and is automatically destroyed when 'removeItems' is called or when the instance is destroyed*/
|
||||
void addItem(QgsRangeRenderItem* ri);
|
||||
|
||||
@ -35,7 +35,7 @@ class QgsGraduatedSymRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsGraduatedSymRenderer();
|
||||
~QgsGraduatedSymRenderer();
|
||||
virtual ~QgsGraduatedSymRenderer();
|
||||
/**Adds a new item
|
||||
\param ri a pointer to the QgsRangeRenderItem to be inserted. It has to be created using the new operator and is automatically destroyed when 'removeItems' is called or when the instance is destroyed*/
|
||||
void addItem(QgsRangeRenderItem* ri);
|
||||
|
||||
@ -253,7 +253,7 @@ void QgsLabel::renderLabel( QPainter * painter, QgsRect *viewExtent,
|
||||
//
|
||||
if (mLabelAttributes->bufferSizeIsSet())
|
||||
{
|
||||
int myBufferSize = mLabelAttributes->bufferSize() ;
|
||||
int myBufferSize = static_cast<int>(mLabelAttributes->bufferSize());
|
||||
if (mLabelAttributes->bufferColorIsSet())
|
||||
{
|
||||
painter->setPen( mLabelAttributes->bufferColor());
|
||||
|
||||
@ -152,7 +152,7 @@ void QgsLabelDialog::init ( void )
|
||||
mFont.setFamily(myLabelAttributes->family());
|
||||
if (myLabelAttributes->sizeIsSet())
|
||||
{
|
||||
mFont.setPointSize(myLabelAttributes->size());
|
||||
mFont.setPointSize(static_cast<int>(myLabelAttributes->size()));
|
||||
|
||||
int myTypeInt = myLabelAttributes->sizeType();
|
||||
if (myTypeInt == QgsLabelAttributes::PointUnits)
|
||||
@ -166,7 +166,7 @@ void QgsLabelDialog::init ( void )
|
||||
}
|
||||
else //defaults for when no size has been set
|
||||
{
|
||||
mFont.setPointSize(myLabelAttributes->size());
|
||||
mFont.setPointSize(static_cast<int>(myLabelAttributes->size()));
|
||||
radioFontSizeUnitsPoints->setChecked(true);
|
||||
}
|
||||
|
||||
@ -200,15 +200,15 @@ void QgsLabelDialog::init ( void )
|
||||
{
|
||||
radioOffsetUnitsMap->setChecked(true);
|
||||
}
|
||||
spinXOffset->setValue(myLabelAttributes->xOffset());
|
||||
spinYOffset->setValue(myLabelAttributes->yOffset());
|
||||
spinXOffset->setValue(static_cast<int>(myLabelAttributes->xOffset()));
|
||||
spinYOffset->setValue(static_cast<int>(myLabelAttributes->yOffset()));
|
||||
}
|
||||
else //defaults for when no offset is defined
|
||||
{
|
||||
spinXOffset->setValue(0);
|
||||
spinYOffset->setValue(0);
|
||||
}
|
||||
spinAngle->setValue(myLabelAttributes->angle());
|
||||
spinAngle->setValue(static_cast<int>(myLabelAttributes->angle()));
|
||||
|
||||
//the values here may seem a bit counterintuitive - basically everything
|
||||
//is the reverse of the way you think it should be...
|
||||
@ -237,14 +237,14 @@ void QgsLabelDialog::init ( void )
|
||||
{
|
||||
radioBufferUnitsMap->setChecked(true);
|
||||
}
|
||||
spinBufferSize->setValue(myLabelAttributes->bufferSize());
|
||||
spinBufferSize->setValue(static_cast<int>(myLabelAttributes->bufferSize()));
|
||||
}
|
||||
else //defaults for when no offset is defined
|
||||
{
|
||||
spinBufferSize->setValue(0);
|
||||
}
|
||||
|
||||
spinBufferSize->setValue(myLabelAttributes->bufferSize());
|
||||
spinBufferSize->setValue(static_cast<int>(myLabelAttributes->bufferSize()));
|
||||
//TODO - transparency attributes for buffers
|
||||
|
||||
}
|
||||
|
||||
@ -92,6 +92,12 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
/// QgsLegends aren't copied
|
||||
QgsLegend( QgsLegend const & );
|
||||
|
||||
/// QgsLegends aren't copied
|
||||
QgsLegend & operator=( QgsLegend const & );
|
||||
|
||||
/** handle to main QgisApp
|
||||
Necessary for binding properly binding context menu to new layers
|
||||
*/
|
||||
|
||||
@ -46,7 +46,9 @@ public:
|
||||
* @param parent The parent listview
|
||||
* @param actionInOverview QgisApp's actionInOverview
|
||||
*/
|
||||
QgsLegendItem(QgsMapLayer * lyr = 0, QListView * parent = 0, QAction * actionInOverview = 0);
|
||||
QgsLegendItem(QgsMapLayer * lyr = 0,
|
||||
QListView * parent = 0,
|
||||
QAction * actionInOverview = 0);
|
||||
|
||||
//! Destructor
|
||||
virtual ~QgsLegendItem();
|
||||
@ -76,6 +78,12 @@ public:
|
||||
|
||||
private: // Private attributes
|
||||
|
||||
/// QgsLegendItem aren't copied
|
||||
QgsLegendItem( QgsLegendItem const & );
|
||||
|
||||
/// QgsLegendItem aren't copied
|
||||
QgsLegendItem & operator=( QgsLegendItem const & );
|
||||
|
||||
/** */
|
||||
QgsMapLayer * m_layer;
|
||||
|
||||
|
||||
@ -16,102 +16,163 @@
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
#include <iostream>
|
||||
#include <cfloat>
|
||||
#include "qgsmapcanvas.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qpainter.h>
|
||||
#include <qrect.h>
|
||||
#include <qevent.h>
|
||||
// added double sentinals to take load off gcc 3.3.3 pre-processor, which was dying
|
||||
|
||||
// XXX actually that wasn't the problem, but left double sentinals in anyway as they
|
||||
// XXX don't hurt anything
|
||||
|
||||
// #ifndef QGUARDEDPTR_H
|
||||
// #include <qguardedptr.h>
|
||||
// #endif
|
||||
|
||||
#ifndef QLISTVIEW_H
|
||||
#include <qlistview.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qsettings.h>
|
||||
#include <qpaintdevicemetrics.h>
|
||||
#include <qguardedptr.h>
|
||||
#endif
|
||||
|
||||
#ifndef QMESSAGEBOX_H
|
||||
#include <qmessagebox.h>
|
||||
#endif
|
||||
|
||||
#ifndef QPAINTDEVICE_H
|
||||
#include <qpaintdevice.h>
|
||||
#endif
|
||||
|
||||
#ifndef QPAINTDEVICEMETRICS_H
|
||||
#include <qpaintdevicemetrics.h>
|
||||
#endif
|
||||
|
||||
#ifndef QPAINTER_H
|
||||
#include <qpainter.h>
|
||||
#endif
|
||||
|
||||
#ifndef QPIXMAP_H
|
||||
#include <qpixmap.h>
|
||||
#endif
|
||||
|
||||
#ifndef QRECT_H
|
||||
#include <qrect.h>
|
||||
#endif
|
||||
|
||||
#ifndef QSETTINGS_H
|
||||
#include <qsettings.h>
|
||||
#endif
|
||||
|
||||
#ifndef QSTRING_H
|
||||
#include <qstring.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "qgsrect.h"
|
||||
#include "qgis.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgsrect.h"
|
||||
#include "qgsacetaterectangle.h"
|
||||
#include "qgsattributedialog.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgslegend.h"
|
||||
#include "qgslegenditem.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgslinesymbol.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgsmaplayerinterface.h"
|
||||
#include "qgsmarkersymbol.h"
|
||||
#include "qgspolygonsymbol.h"
|
||||
#include "qgslinesymbol.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsmaplayerinterface.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsscalecalculator.h"
|
||||
#include "qgsacetaterectangle.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsattributedialog.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implementation struct for QgsMapCanvas
|
||||
*/
|
||||
struct QgsMapCanvas::CanvasProperties
|
||||
|
||||
Implementation struct for QgsMapCanvas
|
||||
|
||||
@note
|
||||
|
||||
Changed to class from struct out of desperation to find workaround for g++ bug.
|
||||
|
||||
*/
|
||||
class QgsMapCanvas::CanvasProperties
|
||||
{
|
||||
CanvasProperties::CanvasProperties()
|
||||
: mapWindow( new QRect ),
|
||||
coordXForm( new QgsCoordinateTransform ),
|
||||
bgColor( Qt::white ),
|
||||
drawing( false ),
|
||||
dirty( true ),
|
||||
pmCanvas( new QPixmap),
|
||||
scaleCalculator( new QgsScaleCalculator)
|
||||
public:
|
||||
|
||||
{
|
||||
CanvasProperties( int width, int height )
|
||||
: mapWindow( 0x0 ),
|
||||
mapLegend( 0 ),
|
||||
coordXForm( 0x0 ),
|
||||
pmCanvas( 0x0 ),
|
||||
bgColor( Qt::white ),
|
||||
dragging( false ),
|
||||
drawing( false ),
|
||||
frozen( false ),
|
||||
dirty( true ),
|
||||
scaleCalculator( 0x0 )
|
||||
{
|
||||
mapWindow = new QRect;
|
||||
coordXForm = new QgsCoordinateTransform;
|
||||
pmCanvas = new QPixmap(width, height);
|
||||
scaleCalculator = new QgsScaleCalculator;
|
||||
}
|
||||
|
||||
CanvasProperties::CanvasProperties( int width, int height )
|
||||
: mapWindow( new QRect ),
|
||||
coordXForm( new QgsCoordinateTransform ),
|
||||
bgColor( Qt::white ),
|
||||
drawing( false ),
|
||||
dirty( true ),
|
||||
pmCanvas( new QPixmap(width, height)),
|
||||
scaleCalculator( new QgsScaleCalculator)
|
||||
{
|
||||
CanvasProperties()
|
||||
: mapWindow( 0x0 ),
|
||||
mapLegend( 0 ),
|
||||
coordXForm( 0x0 ),
|
||||
pmCanvas( 0x0 ),
|
||||
bgColor( Qt::white ),
|
||||
dragging( false ),
|
||||
drawing( false ),
|
||||
frozen( false ),
|
||||
dirty( true ),
|
||||
scaleCalculator( 0x0 )
|
||||
{
|
||||
mapWindow = new QRect;
|
||||
coordXForm = new QgsCoordinateTransform;
|
||||
pmCanvas = new QPixmap;
|
||||
scaleCalculator = new QgsScaleCalculator;
|
||||
}
|
||||
|
||||
CanvasProperties::~CanvasProperties()
|
||||
|
||||
~CanvasProperties()
|
||||
{
|
||||
delete coordXForm;
|
||||
delete pmCanvas;
|
||||
delete mapWindow;
|
||||
delete scaleCalculator;
|
||||
delete coordXForm;
|
||||
delete pmCanvas;
|
||||
delete mapWindow;
|
||||
delete scaleCalculator;
|
||||
} // ~CanvasProperties
|
||||
|
||||
|
||||
void initMetrics(QPaintDeviceMetrics *pdm)
|
||||
{
|
||||
// set the logical dpi
|
||||
mDpi = pdm->logicalDpiX();
|
||||
scaleCalculator->setDpi(mDpi);
|
||||
|
||||
// set default map units
|
||||
mMapUnits = QgsScaleCalculator::METERS;
|
||||
scaleCalculator->setMapUnits(mMapUnits);
|
||||
}
|
||||
|
||||
void CanvasProperties::initMetrics(QPaintDeviceMetrics *pdm){
|
||||
// set the logical dpi
|
||||
mDpi = pdm->logicalDpiX();
|
||||
scaleCalculator->setDpi(mDpi);
|
||||
// set default map units
|
||||
mMapUnits = QgsScaleCalculator::METERS;
|
||||
scaleCalculator->setMapUnits(mMapUnits);
|
||||
|
||||
}
|
||||
void CanvasProperties::setMapUnits(int units)
|
||||
void setMapUnits(QgsScaleCalculator::units u)
|
||||
{
|
||||
mMapUnits = units;
|
||||
mMapUnits = u;
|
||||
scaleCalculator->setMapUnits(mMapUnits);
|
||||
}
|
||||
int CanvasProperties::mapUnits()
|
||||
|
||||
QgsScaleCalculator::units mapUnits()
|
||||
{
|
||||
return mMapUnits;
|
||||
}
|
||||
|
||||
//! map containing the layers by name
|
||||
std::map < QString, QgsMapLayer * >layers;
|
||||
std::map< QString, QgsMapLayer *> layers;
|
||||
|
||||
//! map containing the acetate objects by key (name)
|
||||
std::map <QString, QgsAcetateObject *> acetateObjects;
|
||||
std::map< QString, QgsAcetateObject *> acetateObjects;
|
||||
|
||||
//! list containing the names of layers in zorder
|
||||
std::list < QString > zOrder;
|
||||
std::list< QString > zOrder;
|
||||
|
||||
//! Full extent of the map canvas
|
||||
QgsRect fullExtent;
|
||||
@ -123,14 +184,17 @@ struct QgsMapCanvas::CanvasProperties
|
||||
QgsRect previousExtent;
|
||||
|
||||
//! Map window rectangle
|
||||
//std::auto_ptr<QRect> mapWindow;
|
||||
QRect * mapWindow;
|
||||
|
||||
//! Pointer to the map legend
|
||||
QGuardedPtr<QgsLegend> mapLegend;
|
||||
//std::auto_ptr<QgsLegend> mapLegend;
|
||||
QgsLegend * mapLegend;
|
||||
|
||||
/** Pointer to the coordinate transform object used to transform
|
||||
coordinates from real world to device coordinates
|
||||
*/
|
||||
//std::auto_ptr<QgsCoordinateTransform> coordXForm;
|
||||
QgsCoordinateTransform * coordXForm;
|
||||
|
||||
/**
|
||||
@ -152,8 +216,9 @@ struct QgsMapCanvas::CanvasProperties
|
||||
QPoint boxStartPoint;
|
||||
|
||||
//! Pixmap used for restoring the canvas.
|
||||
/** @note using QGuardedPtr causes sefault for some reason */
|
||||
/** @note using QGuardedPtr causes sefault for some reason -- XXX trying again */
|
||||
//QGuardedPtr<QPixmap> pmCanvas;
|
||||
//std::auto_ptr<QPixmap> pmCanvas;
|
||||
QPixmap * pmCanvas;
|
||||
|
||||
//! Background color for the map canvas
|
||||
@ -188,33 +253,66 @@ struct QgsMapCanvas::CanvasProperties
|
||||
// TODO - Do we need this?
|
||||
double radiusValue;
|
||||
|
||||
QgsScaleCalculator *scaleCalculator;
|
||||
//std::auto_ptr<QgsScaleCalculator> scaleCalculator;
|
||||
QgsScaleCalculator * scaleCalculator;
|
||||
|
||||
//! DPI of physical display
|
||||
int mDpi;
|
||||
|
||||
//! Map units for the data on the canvas
|
||||
int mMapUnits;
|
||||
QgsScaleCalculator::units mMapUnits;
|
||||
|
||||
//! Map scale of the canvas at its current zool level
|
||||
double mScale;
|
||||
|
||||
private:
|
||||
|
||||
/** not copyable
|
||||
*/
|
||||
CanvasProperties( CanvasProperties const & rhs )
|
||||
{
|
||||
// XXX maybe should be NOP just like operator=() to be consistent
|
||||
std::cerr << __FILE__ << ":" << __LINE__
|
||||
<< " should not be here since CanvasProperties shouldn't be copyable\n";
|
||||
} // CanvasProperties copy ctor
|
||||
|
||||
|
||||
/** not copyable
|
||||
*/
|
||||
CanvasProperties & operator=( CanvasProperties const & rhs )
|
||||
{
|
||||
if ( this == &rhs )
|
||||
{ return *this; }
|
||||
|
||||
std::cerr << __FILE__ << ":" << __LINE__
|
||||
<< " should not be here since CanvasProperties shouldn't be copyable\n";
|
||||
|
||||
return *this;
|
||||
} // CanvasProperties assignment operator
|
||||
|
||||
}; // struct QgsMapCanvas::CanvasProperties
|
||||
|
||||
|
||||
|
||||
/** note this is private and so shouldn't be accessible */
|
||||
QgsMapCanvas::QgsMapCanvas()
|
||||
{}
|
||||
|
||||
QgsMapCanvas::QgsMapCanvas(QWidget * parent, const char *name)
|
||||
: QWidget(parent, name), mCanvasProperties( new CanvasProperties(width(), height()) )
|
||||
|
||||
QgsMapCanvas::QgsMapCanvas(QWidget * parent, const char *name)
|
||||
: QWidget(parent, name),
|
||||
mCanvasProperties( new CanvasProperties(width(), height()) ),
|
||||
mUserInteractionAllowed(true) // by default we allow a user to interact with the canvas
|
||||
{
|
||||
setEraseColor(mCanvasProperties->bgColor);
|
||||
//by default we allow a user to interact with the canvas
|
||||
mUserInteractionAllowed=true;
|
||||
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(QWidget::StrongFocus);
|
||||
|
||||
QPaintDeviceMetrics *pdm = new QPaintDeviceMetrics(this);
|
||||
mCanvasProperties->initMetrics(pdm);
|
||||
delete pdm;
|
||||
|
||||
} // QgsMapCanvas ctor
|
||||
|
||||
|
||||
@ -581,7 +679,10 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
#endif
|
||||
if (ml->visible())
|
||||
{
|
||||
ml->draw(paint, &mCanvasProperties->currentExtent, mCanvasProperties->coordXForm, this);
|
||||
ml->draw(paint,
|
||||
&mCanvasProperties->currentExtent,
|
||||
mCanvasProperties->coordXForm,
|
||||
this);
|
||||
}
|
||||
|
||||
li++;
|
||||
@ -606,7 +707,10 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
|
||||
#endif
|
||||
if (ml->visible() && (ml->type() != QgsMapLayer::RASTER))
|
||||
{
|
||||
ml->drawLabels(paint, &mCanvasProperties->currentExtent, mCanvasProperties->coordXForm, this);
|
||||
ml->drawLabels(paint,
|
||||
&mCanvasProperties->currentExtent,
|
||||
mCanvasProperties->coordXForm,
|
||||
this);
|
||||
}
|
||||
|
||||
li++;
|
||||
@ -811,11 +915,12 @@ void QgsMapCanvas::zoomToSelected()
|
||||
{
|
||||
QgsRect rect = lyr->bBoxOfSelected();
|
||||
|
||||
//no selected features
|
||||
if (rect.xMin() == DBL_MAX &&
|
||||
rect.yMin() == DBL_MAX &&
|
||||
rect.xMax() == -DBL_MAX &&
|
||||
rect.yMax() == -DBL_MAX)
|
||||
// no selected features
|
||||
// XXX where is rectange set to "empty"? Shouldn't we use QgsRect::isEmpty()?
|
||||
if (rect.xMin() == std::numeric_limits<double>::infinity() &&
|
||||
rect.yMin() == std::numeric_limits<double>::infinity() &&
|
||||
rect.xMax() == std::numeric_limits<double>::min() &&
|
||||
rect.yMax() == std::numeric_limits<double>::min())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1165,7 +1270,8 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
--it;
|
||||
--it;
|
||||
QgsPoint lastpoint = mCanvasProperties->coordXForm->transform(it->x(),it->y());
|
||||
paint.drawLine(lastpoint.x(),lastpoint.y(),e->x(),e->y());
|
||||
paint.drawLine(static_cast<int>(lastpoint.x()),static_cast<int>(lastpoint.y()),
|
||||
e->x(),e->y());
|
||||
}
|
||||
if(e->button()==Qt::RightButton)
|
||||
{
|
||||
@ -1616,14 +1722,18 @@ double QgsMapCanvas::mupp() const
|
||||
{
|
||||
return mCanvasProperties->m_mupp;
|
||||
} // mupp
|
||||
void QgsMapCanvas::setMapUnits(int units)
|
||||
|
||||
|
||||
void QgsMapCanvas::setMapUnits(QgsScaleCalculator::units u)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cerr << "Setting map units to " << units << std::endl;
|
||||
std::cerr << "Setting map units to " << static_cast<int>(u) << std::endl;
|
||||
#endif
|
||||
mCanvasProperties->setMapUnits(units);
|
||||
mCanvasProperties->setMapUnits(u);
|
||||
}
|
||||
int QgsMapCanvas::mapUnits()
|
||||
|
||||
|
||||
QgsScaleCalculator::units QgsMapCanvas::mapUnits() const
|
||||
{
|
||||
return mCanvasProperties->mapUnits();
|
||||
}
|
||||
|
||||
@ -19,30 +19,41 @@
|
||||
#ifndef QGSMAPCANVAS_H
|
||||
#define QGSMAPCANVAS_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qevent.h>
|
||||
// double sentinals to get round gcc 3.3.3 pre-processor bug
|
||||
|
||||
#ifndef QWIDGET_H
|
||||
#include <qwidget.h>
|
||||
#endif
|
||||
|
||||
#ifndef QGSRECT_H
|
||||
#include <qgsrect.h>
|
||||
#endif
|
||||
|
||||
#ifndef QGSPOINT_H
|
||||
#include <qgspoint.h>
|
||||
#include <qpaintdevice.h>
|
||||
#endif
|
||||
|
||||
#ifndef QGSSCALECALCULATOR_H
|
||||
#include <qgsscalecalculator.h>
|
||||
#endif
|
||||
|
||||
class QRect;
|
||||
class QColor;
|
||||
class QPaintDevice;
|
||||
class QMouseEvent;
|
||||
|
||||
class QgsCoordinateTransform;
|
||||
class QgsMapLayer;
|
||||
class QgsMapLayerInterface;
|
||||
class QMouseEvent;
|
||||
class QgsLegend;
|
||||
class QgsLegendView;
|
||||
class QColor;
|
||||
class QgsPoint;
|
||||
class QgsScaleCalculator;
|
||||
class QgsAcetateObject;
|
||||
|
||||
|
||||
|
||||
/*! \class QgsMapCanvas
|
||||
* \brief Map canvas class for displaying all GIS data types.
|
||||
*/
|
||||
@ -137,9 +148,10 @@ class QgsMapCanvas : public QWidget
|
||||
std::list < QString > const & zOrders() const;
|
||||
std::list < QString > & zOrders();
|
||||
//! Set map units (needed by project properties dialog)
|
||||
void setMapUnits(int mapUnits);
|
||||
void setMapUnits(QgsScaleCalculator::units mapUnits);
|
||||
//! Get the current canvas map units
|
||||
int mapUnits();
|
||||
|
||||
QgsScaleCalculator::units mapUnits() const;
|
||||
|
||||
//! Get the current coordinate transform
|
||||
QgsCoordinateTransform * getCoordinateTransform();
|
||||
@ -233,12 +245,13 @@ signals:
|
||||
void extentsChanged(QgsRect);
|
||||
|
||||
/** Emitted when the canvas has rendered.
|
||||
/* Passes a pointer to the painter on
|
||||
* which the map was drawn. This is useful for plugins
|
||||
* that wish to draw on the map after it has been rendered.
|
||||
* Passing the painter allows plugins to work when the
|
||||
* map is being rendered onto a pixmap other than the mapCanvas
|
||||
* own pixmap member. */
|
||||
|
||||
Passes a pointer to the painter on which the map was drawn. This is
|
||||
useful for plugins that wish to draw on the map after it has been
|
||||
rendered. Passing the painter allows plugins to work when the map is
|
||||
being rendered onto a pixmap other than the mapCanvas own pixmap member.
|
||||
|
||||
*/
|
||||
void renderComplete(QPainter *);
|
||||
|
||||
/** emitted whenever a layer is added to the map canvas */
|
||||
@ -266,13 +279,22 @@ private:
|
||||
*/
|
||||
QgsMapCanvas( QgsMapCanvas const & );
|
||||
|
||||
/**
|
||||
private to force use of ctor with arguments
|
||||
*/
|
||||
QgsMapCanvas();
|
||||
|
||||
/// implementation struct
|
||||
struct CanvasProperties;
|
||||
class CanvasProperties;
|
||||
|
||||
/// Handle pattern for implementation object
|
||||
std::auto_ptr<CanvasProperties> mCanvasProperties;
|
||||
|
||||
/**List to store the points of digitised lines and polygons*/
|
||||
/**
|
||||
List to store the points of digitised lines and polygons
|
||||
|
||||
@todo XXX shouldn't this be in mCanvasProperties?
|
||||
*/
|
||||
std::list<QgsPoint> mCaptureList;
|
||||
|
||||
//! Overridden mouse move event
|
||||
|
||||
@ -373,6 +373,12 @@ protected:
|
||||
|
||||
private: // Private attributes
|
||||
|
||||
/// QgsMapLayer not copyable
|
||||
QgsMapLayer( QgsMapLayer const & );
|
||||
|
||||
/// QgsMapLayer not copyable
|
||||
QgsMapLayer & operator=( QgsMapLayer const & );
|
||||
|
||||
/** Unique ID of this layer - used to refer to this layer in QGIS code */
|
||||
QString ID;
|
||||
|
||||
|
||||
@ -4,15 +4,18 @@
|
||||
Date : 08-Nov-2003
|
||||
Copyright : (C) 2003 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$ */
|
||||
***************************************************************************
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
#ifndef QGSMAPSERVEREXPORT_H
|
||||
#define QGSMAPSERVEREXPORT_H
|
||||
|
||||
@ -21,7 +21,9 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifndef QSTRING_H
|
||||
#include <qstring.h>
|
||||
#endif
|
||||
|
||||
class QgsPoint
|
||||
{
|
||||
|
||||
@ -62,8 +62,11 @@ struct QgsProject::Imp
|
||||
/// true if project has been modified since it has been read or saved
|
||||
bool dirty;
|
||||
|
||||
/// map units for current project
|
||||
QgsScaleCalculator::units mapUnits;
|
||||
|
||||
Imp()
|
||||
: title(""), dirty(false)
|
||||
: title(""), dirty(false), mapUnits(QgsScaleCalculator::METERS)
|
||||
{}
|
||||
|
||||
}; // struct QgsProject::Imp
|
||||
@ -114,6 +117,20 @@ QString const & QgsProject::title() const
|
||||
|
||||
|
||||
|
||||
QgsScaleCalculator::units QgsProject::mapUnits() const
|
||||
{
|
||||
return imp_->mapUnits;
|
||||
} // QgsScaleCalculator::units QgsProject::mapUnits() const
|
||||
|
||||
|
||||
|
||||
void QgsProject::mapUnits(QgsScaleCalculator::units u)
|
||||
{
|
||||
imp_->mapUnits = u;
|
||||
} // void QgsProject::mapUnits(QgsScaleCalculator::units u)
|
||||
|
||||
|
||||
|
||||
|
||||
bool QgsProject::dirty() const
|
||||
{
|
||||
@ -202,6 +219,54 @@ _getExtents( QDomDocument const & doc, QgsRect & aoi )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the project title
|
||||
|
||||
XML in file has this form:
|
||||
<units>feet</units>
|
||||
*/
|
||||
static
|
||||
bool
|
||||
_getMapUnits( QDomDocument const & doc )
|
||||
{
|
||||
QDomNodeList nl = doc.elementsByTagName("units");
|
||||
|
||||
// since "units" is a new project file type, legacy project files will not
|
||||
// have this element. If we do have such a legacy project file missing
|
||||
// "units", then just return;
|
||||
if ( ! nl.count() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomNode node = nl.item(0); // there should only be one, so zeroth element ok
|
||||
QDomElement element = node.toElement();
|
||||
|
||||
if ( "meters" == element.text() )
|
||||
{
|
||||
QgsProject::instance()->mapUnits( QgsScaleCalculator::METERS );
|
||||
}
|
||||
else if ( "feet" == element.text() )
|
||||
{
|
||||
QgsProject::instance()->mapUnits( QgsScaleCalculator::FEET );
|
||||
}
|
||||
else if ( "degrees" == element.text() )
|
||||
{
|
||||
QgsProject::instance()->mapUnits( QgsScaleCalculator::DEGREES );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << __FILE__ << ":" << __LINE__
|
||||
<< " unknown map unit type " << element.text() << "\n";
|
||||
false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // _getMapUnits
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the project title
|
||||
|
||||
@ -212,7 +277,7 @@ static
|
||||
void
|
||||
_getTitle( QDomDocument const & doc, QString & title )
|
||||
{
|
||||
QDomNodeList nl = doc.elementsByTagName("qgis");
|
||||
QDomNodeList nl = doc.elementsByTagName("title");
|
||||
|
||||
QDomNode node = nl.item(0); // there should only be one, so zeroth element ok
|
||||
QDomElement element = node.toElement();
|
||||
@ -268,6 +333,8 @@ _findQgisApp()
|
||||
|
||||
return 0x0; // XXX some sort of error value? Exception?
|
||||
}
|
||||
|
||||
return qgisApp;
|
||||
} // _findQgisApp
|
||||
|
||||
|
||||
@ -325,7 +392,7 @@ _getMapLayers( QDomDocument const & doc )
|
||||
|
||||
// process the map layer nodes
|
||||
|
||||
for (int i = 0; i < nl.count(); i++)
|
||||
for (size_t i = 0; i < nl.count(); i++)
|
||||
{
|
||||
QDomNode node = nl.item(i);
|
||||
QDomElement element = node.toElement();
|
||||
@ -646,9 +713,13 @@ QgsProject::read( )
|
||||
// now get project title
|
||||
_getTitle( *doc, imp_->title );
|
||||
#ifdef QGISDEBUG
|
||||
qDebug( "Project title: " + imp_->title );
|
||||
qDebug( "Project title: " + imp_->title );
|
||||
#endif
|
||||
|
||||
// now set the map units; note, alters QgsProject::instance().
|
||||
_getMapUnits( *doc );
|
||||
|
||||
|
||||
// XXX insert code for setting the properties
|
||||
|
||||
|
||||
@ -692,7 +763,6 @@ QgsProject::write( )
|
||||
std::auto_ptr<QDomDocument> doc =
|
||||
std::auto_ptr<QDomDocument>( new QDomDocument( documentType ) );
|
||||
|
||||
// XXX add guts from QgsProjectIO write
|
||||
|
||||
QDomElement qgis = doc->createElement( "qgis" );
|
||||
qgis.setAttribute( "projectname", title() );
|
||||
@ -706,6 +776,32 @@ QgsProject::write( )
|
||||
QDomText titleText = doc->createTextNode( title() ); // XXX why have title TWICE?
|
||||
titleNode.appendChild( titleText );
|
||||
|
||||
// units
|
||||
|
||||
QDomElement unitsNode = doc->createElement( "units" );
|
||||
qgis.appendChild( unitsNode );
|
||||
|
||||
QString unitsString;
|
||||
|
||||
switch (instance()->imp_->mapUnits)
|
||||
{
|
||||
case QgsScaleCalculator::METERS :
|
||||
unitsString = "meters";
|
||||
break;
|
||||
case QgsScaleCalculator::FEET :
|
||||
unitsString = "feet";
|
||||
break;
|
||||
case QgsScaleCalculator::DEGREES :
|
||||
unitsString = "degrees";
|
||||
break;
|
||||
default :
|
||||
unitsString = "unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
QDomText unitsText = doc->createTextNode( unitsString );
|
||||
unitsNode.appendChild( unitsText );
|
||||
|
||||
// extent
|
||||
|
||||
// XXX there should eventually be a QgsMapCanvas::writeXML() that does this
|
||||
@ -755,7 +851,8 @@ QgsProject::write( )
|
||||
|
||||
doc->normalize(); // XXX I'm not entirely sure what this does
|
||||
|
||||
QString xml = doc->toString( 8 ); // write to string with indentation of eight characters
|
||||
QString xml = doc->toString( 4 ); // write to string with indentation of four characters
|
||||
// (yes, four is arbitrary)
|
||||
|
||||
// const char * xmlString = xml.ascii(); // debugger probe point
|
||||
// qDebug( "project file output:\n\n" + xml );
|
||||
|
||||
@ -28,11 +28,12 @@
|
||||
#include <qvaluelist.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
#include <qgsscalecalculator.h>
|
||||
|
||||
|
||||
class QFileInfo;
|
||||
|
||||
|
||||
|
||||
/** Reads and writes project states.
|
||||
|
||||
|
||||
@ -74,6 +75,19 @@ public:
|
||||
QString const & title() const;
|
||||
//@}
|
||||
|
||||
/**
|
||||
* Gets the currently select map units
|
||||
* @return int which matches a value in the units enum in QgsScaleCalculator::units
|
||||
*/
|
||||
QgsScaleCalculator::units mapUnits() const;
|
||||
|
||||
|
||||
/**
|
||||
* Set the map units
|
||||
* @param new units type
|
||||
*/
|
||||
void mapUnits(QgsScaleCalculator::units u);
|
||||
|
||||
|
||||
/**
|
||||
the dirty flag is true if the project has been modified since the last
|
||||
|
||||
@ -19,38 +19,41 @@
|
||||
|
||||
#include "qgsprojectproperties.h"
|
||||
|
||||
#include "qgsscalecalculator.h"
|
||||
|
||||
#include <qbuttongroup.h>
|
||||
#include <qlineedit.h>
|
||||
|
||||
#include "qgsproject.h"
|
||||
|
||||
|
||||
QgsProjectProperties::QgsProjectProperties(QWidget *parent, const char *name)
|
||||
: QgsProjectPropertiesBase(parent, name),
|
||||
mMapUnits(QgsScaleCalculator::METERS)
|
||||
{}
|
||||
: QgsProjectPropertiesBase(parent, name)
|
||||
{
|
||||
QgsProject::instance()->mapUnits( QgsScaleCalculator::METERS );
|
||||
}
|
||||
|
||||
QgsProjectProperties::~QgsProjectProperties()
|
||||
{}
|
||||
|
||||
|
||||
int QgsProjectProperties::mapUnits()
|
||||
QgsScaleCalculator::units QgsProjectProperties::mapUnits() const
|
||||
{
|
||||
return mMapUnits;
|
||||
return QgsProject::instance()->mapUnits();
|
||||
}
|
||||
|
||||
|
||||
void QgsProjectProperties::mapUnitChange(int unit)
|
||||
{
|
||||
mMapUnits = unit;
|
||||
QgsProject::instance()->mapUnits(
|
||||
static_cast<QgsScaleCalculator::units>(unit));
|
||||
}
|
||||
|
||||
|
||||
void QgsProjectProperties::setMapUnits(int unit)
|
||||
void QgsProjectProperties::setMapUnits(QgsScaleCalculator::units unit)
|
||||
{
|
||||
// select the button
|
||||
btnGrpMapUnits->setButton(unit);
|
||||
btnGrpMapUnits->setButton(static_cast<int>(unit));
|
||||
QgsProject::instance()->mapUnits(unit);
|
||||
}
|
||||
|
||||
|
||||
@ -63,4 +66,5 @@ QString QgsProjectProperties::title() const
|
||||
void QgsProjectProperties::title( QString const & title )
|
||||
{
|
||||
titleEdit->setText( title );
|
||||
QgsProject::instance()->title( title );
|
||||
} // QgsProjectProperties::title( QString const & title )
|
||||
|
||||
@ -15,34 +15,40 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef WIN32
|
||||
#include "qgsprojectpropertiesbase.h"
|
||||
#include <qgsprojectpropertiesbase.h>
|
||||
#else
|
||||
#include "qgsprojectpropertiesbase.uic.h"
|
||||
#include <qgsprojectpropertiesbase.uic.h>
|
||||
#endif
|
||||
/**
|
||||
* \class QgsProjectProperties
|
||||
* \brief Dialog to set project level properties
|
||||
|
||||
#include <qgsscalecalculator.h>
|
||||
|
||||
/** Dialog to set project level properties
|
||||
|
||||
@note actual state is stored in QgsProject singleton instance
|
||||
|
||||
*/
|
||||
class QgsProjectProperties : public QgsProjectPropertiesBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! Constructor
|
||||
QgsProjectProperties(QWidget *parent=0, const char *name=0);
|
||||
QgsProjectProperties(QWidget *parent = 0, const char * name = 0);
|
||||
|
||||
//! Destructor
|
||||
~QgsProjectProperties();
|
||||
/**
|
||||
* Gets the currently select map units
|
||||
* @return int which matches a value in the units enum in QgsScaleCalculator::units
|
||||
|
||||
/** Gets the currently select map units
|
||||
*/
|
||||
int mapUnits();
|
||||
QgsScaleCalculator::units mapUnits() const;
|
||||
|
||||
/**
|
||||
* Set the map units
|
||||
* @param int specifying units (matches a value in the units enum in QgsScaleCalculator::units)
|
||||
*/
|
||||
void setMapUnits(int);
|
||||
void setMapUnits(QgsScaleCalculator::units);
|
||||
|
||||
/**
|
||||
Every project has a title
|
||||
@ -57,8 +63,5 @@ public slots:
|
||||
* values in QgsScaleCalculator::units
|
||||
*/
|
||||
void mapUnitChange(int);
|
||||
private:
|
||||
//! private member to hold the currently selected map units (so we can fetch them later)
|
||||
int mMapUnits;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -622,6 +622,9 @@ QString QgsRasterLayer::getDrawingStyleAsQString()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QString("INVALID_DRAWING_STYLE"); // XXX I hope this is ok to return
|
||||
|
||||
}
|
||||
|
||||
void QgsRasterLayer::setDrawingStyle(QString theDrawingStyleQString)
|
||||
@ -1785,6 +1788,9 @@ const RasterBandStats QgsRasterLayer::getRasterBandStats(QString theBandNameQStr
|
||||
return myRasterBandStats;
|
||||
}
|
||||
}
|
||||
|
||||
return RasterBandStats(); // return a null one
|
||||
// XXX is this ok? IS there a "null" one?
|
||||
}
|
||||
|
||||
//get the number of a band given its name
|
||||
|
||||
@ -19,11 +19,15 @@
|
||||
#ifndef QGSRECT_H
|
||||
#define QGSRECT_H
|
||||
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
|
||||
#ifndef QSTRING_H
|
||||
#include <qstring.h>
|
||||
#endif
|
||||
|
||||
#ifndef QGSPOINT_H
|
||||
#include <qgspoint.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*! \class QgsRect
|
||||
|
||||
@ -23,21 +23,23 @@
|
||||
#include "qgsrect.h"
|
||||
#include "qgsscalecalculator.h"
|
||||
|
||||
QgsScaleCalculator::QgsScaleCalculator(int dpi, int mapUnits)
|
||||
QgsScaleCalculator::QgsScaleCalculator(int dpi, QgsScaleCalculator::units mapUnits)
|
||||
: mDpi(dpi), mMapUnits(mapUnits)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
QgsScaleCalculator::~QgsScaleCalculator()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void QgsScaleCalculator::setDpi(int dpi)
|
||||
{
|
||||
mDpi = dpi;
|
||||
}
|
||||
void QgsScaleCalculator::setMapUnits(int mapUnits)
|
||||
|
||||
void QgsScaleCalculator::setMapUnits(units mapUnits)
|
||||
{
|
||||
mMapUnits = mapUnits;
|
||||
}
|
||||
|
||||
double QgsScaleCalculator::calculate(QgsRect &mapExtent, int canvasWidth)
|
||||
{
|
||||
double conversionFactor;
|
||||
@ -70,7 +72,9 @@ double QgsScaleCalculator::calculate(QgsRect &mapExtent, int canvasWidth)
|
||||
double scale = (delta * conversionFactor)/(canvasWidth/mDpi);
|
||||
return scale;
|
||||
}
|
||||
double QgsScaleCalculator::calculateGeographicDistance(QgsRect &mapExtent)
|
||||
|
||||
|
||||
double QgsScaleCalculator::calculateGeographicDistance(QgsRect &mapExtent)
|
||||
{
|
||||
// need to calculate the x distance in meters
|
||||
// We'll use the middle latitude for the calculation
|
||||
|
||||
@ -16,36 +16,57 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef QGSSCALECALCULATOR_H
|
||||
#define QGSSCALECALCULATOR_H
|
||||
|
||||
class QString;
|
||||
class QgsRect;
|
||||
|
||||
/**
|
||||
* \class QgsScaleCalculator
|
||||
* \brief Calculates scale for a given combination of canvas size, map extent,
|
||||
* and monitor dpi.
|
||||
*/
|
||||
class QgsScaleCalculator{
|
||||
class QgsScaleCalculator
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Enum for defining map units
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
METERS,
|
||||
FEET,
|
||||
DEGREES
|
||||
} units;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param dpi Monitor resolution in dots per inch
|
||||
* @param mapUnits Units of the data on the map. Must match a value from the
|
||||
* QgsScaleCalculator::units enum (METERS, FEET, DEGREES)
|
||||
*/
|
||||
QgsScaleCalculator(int dpi=0, int mapUnits=0);
|
||||
QgsScaleCalculator(int dpi = 0,
|
||||
units mapUnits = METERS);
|
||||
|
||||
//! Destructor
|
||||
~QgsScaleCalculator();
|
||||
|
||||
/**
|
||||
* Set the dpi to be used in scale calculations
|
||||
* @param dpi Dots per inch of monitor resolution
|
||||
*/
|
||||
void setDpi(int dpi);
|
||||
|
||||
/**
|
||||
* Set the map units
|
||||
* @param mapUnits Units of the data on the map. Must match a value from the
|
||||
*/
|
||||
void setMapUnits(int mapUnits);
|
||||
void setMapUnits(QgsScaleCalculator::units mapUnits);
|
||||
|
||||
/**
|
||||
* Calculate the scale
|
||||
* @param mapExtent QgsRect containing the current map extent
|
||||
@ -53,6 +74,7 @@ class QgsScaleCalculator{
|
||||
* @return scale of current map view
|
||||
*/
|
||||
double calculate(QgsRect &mapExtent, int canvasWidth);
|
||||
|
||||
/**
|
||||
* Calculate the distance between to points in geographic coordinates.
|
||||
* Used to calculate scale for map views with geographic (decimal degree)
|
||||
@ -61,21 +83,13 @@ class QgsScaleCalculator{
|
||||
*/
|
||||
double calculateGeographicDistance(QgsRect &mapExtent);
|
||||
|
||||
/**
|
||||
* Enum for defining map units
|
||||
*/
|
||||
enum units{
|
||||
METERS,
|
||||
FEET,
|
||||
DEGREES
|
||||
};
|
||||
|
||||
private:
|
||||
//! map unit member
|
||||
int mMapUnits;
|
||||
|
||||
//! dpi member
|
||||
int mDpi;
|
||||
|
||||
//! map unit member
|
||||
units mMapUnits;
|
||||
};
|
||||
|
||||
#endif // #ifndef QGSSCALECALCULATOR_H
|
||||
|
||||
@ -28,7 +28,7 @@ class QgsSiMaRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsSiMaRenderer();
|
||||
~QgsSiMaRenderer();
|
||||
virtual ~QgsSiMaRenderer();
|
||||
/**Replaces the current mItem by ri*/
|
||||
void addItem(QgsRenderItem* ri);
|
||||
void initializeSymbology(QgsVectorLayer* layer, QgsDlgVectorLayerProperties* pr=0);
|
||||
|
||||
@ -32,7 +32,7 @@ class QgsSingleSymRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsSingleSymRenderer();
|
||||
~QgsSingleSymRenderer();
|
||||
virtual ~QgsSingleSymRenderer();
|
||||
/**Replaces the current mItem by ri*/
|
||||
void addItem(QgsRenderItem* ri);
|
||||
/**Returns a pointer to mItem*/
|
||||
|
||||
@ -959,6 +959,8 @@ QPixmap QgsSymbologyUtils::qString2LinePixmap(QString string)
|
||||
{
|
||||
return QPixmap(noPenLineData);
|
||||
}
|
||||
|
||||
return QPixmap(); // XXX I hope returning a blank one is ok
|
||||
}
|
||||
|
||||
QPixmap QgsSymbologyUtils::qString2PatternPixmap(QString string)
|
||||
@ -1015,7 +1017,7 @@ QPixmap QgsSymbologyUtils::qString2PatternPixmap(QString string)
|
||||
}
|
||||
}
|
||||
|
||||
const char *QgsSymbologyUtils::penStyle2Char(Qt::PenStyle penstyle)
|
||||
const char * QgsSymbologyUtils::penStyle2Char(Qt::PenStyle penstyle)
|
||||
{
|
||||
if (penstyle == Qt::NoPen)
|
||||
{
|
||||
@ -1357,4 +1359,6 @@ QPixmap QgsSymbologyUtils::brushStyle2Pixmap(Qt::BrushStyle brushstyle)
|
||||
default:
|
||||
qWarning("Warning, no matching pattern found in QgsSymbologyUtils::brushStyle2Pixmap");
|
||||
}
|
||||
|
||||
return QPixmap(); // XXX I hope returning a blank one is ok
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ class QgsUniqueValRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsUniqueValRenderer();
|
||||
~QgsUniqueValRenderer();
|
||||
virtual ~QgsUniqueValRenderer();
|
||||
void initializeSymbology(QgsVectorLayer* layer, QgsDlgVectorLayerProperties* pr=0);
|
||||
void renderFeature(QPainter* p, QgsFeature* f,QPicture* pic, double* scalefactor, bool selected);
|
||||
/**Reads the renderer configuration from an XML file
|
||||
|
||||
@ -28,7 +28,7 @@ class QgsUValMaRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
QgsUValMaRenderer();
|
||||
~QgsUValMaRenderer();
|
||||
virtual ~QgsUValMaRenderer();
|
||||
void initializeSymbology(QgsVectorLayer* layer, QgsDlgVectorLayerProperties* pr=0);
|
||||
void renderFeature(QPainter* p, QgsFeature* f,QPicture* pic, double* scalefactor, bool selected);
|
||||
/**Reads the renderer configuration from an XML file
|
||||
|
||||
@ -668,19 +668,20 @@ void QgsVectorLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTrans
|
||||
}
|
||||
|
||||
}
|
||||
void QgsVectorLayer::table()
|
||||
{
|
||||
|
||||
void QgsVectorLayer::table()
|
||||
{
|
||||
if (tabledisplay)
|
||||
{
|
||||
tabledisplay->raise();
|
||||
tabledisplay->raise();
|
||||
} else
|
||||
{
|
||||
// display the attribute table
|
||||
QApplication::setOverrideCursor(Qt::waitCursor);
|
||||
dataProvider->reset();
|
||||
int numFields = dataProvider->fieldCount();
|
||||
tabledisplay = new QgsAttributeTableDisplay();
|
||||
QObject:connect(tabledisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDisplay()));
|
||||
// display the attribute table
|
||||
QApplication::setOverrideCursor(Qt::waitCursor);
|
||||
dataProvider->reset();
|
||||
int numFields = dataProvider->fieldCount();
|
||||
tabledisplay = new QgsAttributeTableDisplay();
|
||||
connect(tabledisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDisplay()));
|
||||
tabledisplay->table()->setNumRows(dataProvider->featureCount());
|
||||
tabledisplay->table()->setNumCols(numFields + 1); //+1 for the id-column
|
||||
|
||||
@ -692,23 +693,23 @@ QObject:connect(tabledisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDispl
|
||||
//for (int h = 0; h < numFields; h++) {
|
||||
for (int h = 1; h <= numFields; h++)
|
||||
{
|
||||
colHeader->setLabel(h, fields[h - 1].name());
|
||||
colHeader->setLabel(h, fields[h - 1].name());
|
||||
}
|
||||
QgsFeature *fet;
|
||||
while ((fet = dataProvider->getNextFeature(true)))
|
||||
{
|
||||
|
||||
//id-field
|
||||
tabledisplay->table()->setText(row, 0, QString::number(fet->featureId()));
|
||||
tabledisplay->table()->insertFeatureId(fet->featureId(), row); //insert the id into the search tree of qgsattributetable
|
||||
std::vector < QgsFeatureAttribute > attr = fet->attributeMap();
|
||||
for (int i = 0; i < attr.size(); i++)
|
||||
{
|
||||
// get the field values
|
||||
tabledisplay->table()->setText(row, i + 1, attr[i].fieldValue());
|
||||
}
|
||||
row++;
|
||||
delete fet;
|
||||
//id-field
|
||||
tabledisplay->table()->setText(row, 0, QString::number(fet->featureId()));
|
||||
tabledisplay->table()->insertFeatureId(fet->featureId(), row); //insert the id into the search tree of qgsattributetable
|
||||
std::vector < QgsFeatureAttribute > attr = fet->attributeMap();
|
||||
for (int i = 0; i < attr.size(); i++)
|
||||
{
|
||||
// get the field values
|
||||
tabledisplay->table()->setText(row, i + 1, attr[i].fieldValue());
|
||||
}
|
||||
row++;
|
||||
delete fet;
|
||||
}
|
||||
|
||||
// reset the pointer to start of fetabledisplayures so
|
||||
@ -726,9 +727,9 @@ QObject:connect(tabledisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDispl
|
||||
|
||||
for (std::map < int, bool >::iterator it = selected.begin(); it != selected.end(); ++it)
|
||||
{
|
||||
tabledisplay->table()->selectRowWithId(it->first);
|
||||
tabledisplay->table()->selectRowWithId(it->first);
|
||||
#ifdef QGISDEBUG
|
||||
qWarning("selecting row with id " + QString::number(it->first));
|
||||
qWarning("selecting row with id " + QString::number(it->first));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -741,9 +742,11 @@ QObject:connect(tabledisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDispl
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
}
|
||||
} // QgsVectorLayer::table
|
||||
|
||||
void QgsVectorLayer::select(int number)
|
||||
|
||||
|
||||
void QgsVectorLayer::select(int number)
|
||||
{
|
||||
selected[number] = true;
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#ifndef QGSVECTORLAYER_H
|
||||
#define QGSVECTORLAYER_H
|
||||
|
||||
class QPainter;
|
||||
class QgsRect;
|
||||
class QLibrary;
|
||||
@ -33,6 +34,7 @@ class QgsIdentifyResults;
|
||||
class QgsLabel;
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qvaluevector.h"
|
||||
@ -44,7 +46,7 @@ class QgsLabel;
|
||||
* \brief Vector layer backed by a data source provider
|
||||
*/
|
||||
|
||||
class QgsVectorLayer:public QgsMapLayer
|
||||
class QgsVectorLayer : public QgsMapLayer
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
@ -292,6 +294,11 @@ private: // Private methods
|
||||
//! Flag to indicate if scale dependent rendering is in effect
|
||||
bool mScaleDependentRender;
|
||||
|
||||
/// vector layers are not copyable
|
||||
QgsVectorLayer( QgsVectorLayer const & rhs );
|
||||
|
||||
/// vector layers are not copyable
|
||||
QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user