Skip to content
Permalink
Browse files
Further api consistency cleanups
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9134 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 23, 2008
1 parent 2e5506a commit 841699b1b61698111a9f89b108514ac67187e485
@@ -31,7 +31,7 @@ class QgsMapRenderer : QObject
const QgsMapToPixel* coordinateTransform();

double scale() const;
double mupp() const;
double mapUnitsPerPixel() const;

int width() const;
int height() const;
@@ -12,12 +12,12 @@ class QgsMapToPixel

public:
/* Constructor
* @param mupp Map units per pixel
* @param mapUnitsPerPixel Map units per pixel
* @param ymax Maximum y value of the map canvas
* @param ymin Minimum y value of the map canvas
* @param xmin Minimum x value of the map canvas
*/
QgsMapToPixel(double mupp=0, double ymax = 0, double ymin=0,
QgsMapToPixel(double mapUnitsPerPixel=0, double ymax = 0, double ymin=0,
double xmin = 0);
//! destructor
~QgsMapToPixel();
@@ -61,9 +61,9 @@ class QgsMapToPixel

QgsPoint toMapPoint(int x, int y);
/*! Set map units per pixel
* @param mupp Map units per pixel
* @param mapUnitsPerPixel Map units per pixel
*/
void setMapUnitsPerPixel(double mupp);
void setMapUnitsPerPixel(double mapUnitsPerPixel);

//! Return current map units per pixel
double mapUnitsPerPixel();
@@ -75,12 +75,12 @@ class QgsMapToPixel
//! set minimum x value
void setXMinimum(double xmin);
/*! Set parameters for use in tranfsorming coordinates
* @param mupp Map units per pixel
* @param mapUnitsPerPixel Map units per pixel
* @param xmin Minimum x value
* @param ymin Minimum y value
* @param ymax Maximum y value
*/
void setParameters(double mupp, double xmin, double ymin, double ymax);
void setParameters(double mapUnitsPerPixel, double xmin, double ymin, double ymax);
//! String representation of the parameters used in the transform
QString showParameters();

@@ -62,7 +62,7 @@ public:
void setFilename( const QString & name );

/** returns file name */
QString filename() const;
QString setFilename() const;
//@}


@@ -73,8 +73,8 @@ class QgsMapCanvas : QGraphicsView
//! Clear the map canvas
void clear();

//! Returns the mupp (map units per pixel) for the canvas
double mupp() const;
//! Returns the mapUnitsPerPixel (map units per pixel) for the canvas
double mapUnitsPerPixel() const;

//! Returns the current zoom exent of the map canvas
QgsRect extent() const;
@@ -1795,12 +1795,12 @@ void QgsLegend::legendLayerZoomNative()
if(layer)
{
QgsDebugMsg("Raster units per pixel : " + QString::number(layer->rasterUnitsPerPixel()));
QgsDebugMsg("Mupp before : " + QString::number(mMapCanvas->mupp()));
QgsDebugMsg("MapUnitsPerPixel before : " + QString::number(mMapCanvas->mapUnitsPerPixel()));

mMapCanvas->zoom(fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mupp()));
mMapCanvas->zoom(fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel()));
mMapCanvas->refresh();

QgsDebugMsg("Mupp after : " + QString::number(mMapCanvas->mupp()));
QgsDebugMsg("MapUnitsPerPixel after : " + QString::number(mMapCanvas->mapUnitsPerPixel()));

// notify the project we've made a change
QgsProject::instance()->dirty(true);
@@ -224,14 +224,14 @@ static void setTitleBarText_( QWidget & qgisApp )

if ( QgsProject::instance()->title().isEmpty() )
{
if ( QgsProject::instance()->filename().isEmpty() )
if ( QgsProject::instance()->setFilename().isEmpty() )
{
// no project title nor file name, so just leave caption with
// application name and version
}
else
{
QFileInfo projectFileInfo( QgsProject::instance()->filename() );
QFileInfo projectFileInfo( QgsProject::instance()->setFilename() );
caption += projectFileInfo.baseName();
}
}
@@ -2882,7 +2882,7 @@ bool QgisApp::fileSave()
// the current project file name is empty
bool isNewProject = false;

if ( QgsProject::instance()->filename().isNull() )
if ( QgsProject::instance()->setFilename().isNull() )
{
isNewProject = true;

@@ -2925,7 +2925,7 @@ bool QgisApp::fileSave()
if ( QgsProject::instance()->write() )
{
setTitleBarText_(*this); // update title bar
statusBar()->showMessage(tr("Saved project to:") + " " + QgsProject::instance()->filename() );
statusBar()->showMessage(tr("Saved project to:") + " " + QgsProject::instance()->setFilename() );

if (isNewProject)
{
@@ -2938,13 +2938,13 @@ bool QgisApp::fileSave()
{
QMessageBox::critical(this,
tr("Unable to save project"),
tr("Unable to save project to ") + QgsProject::instance()->filename() );
tr("Unable to save project to ") + QgsProject::instance()->setFilename() );
}
}
catch ( std::exception & e )
{
QMessageBox::critical( this,
tr("Unable to save project ") + QgsProject::instance()->filename(),
tr("Unable to save project ") + QgsProject::instance()->setFilename(),
QString::fromLocal8Bit( e.what() ) );
}
return true;
@@ -3008,21 +3008,21 @@ void QgisApp::fileSaveAs()
if ( QgsProject::instance()->write() )
{
setTitleBarText_(*this); // update title bar
statusBar()->showMessage(tr("Saved project to:") + " " + QgsProject::instance()->filename() );
statusBar()->showMessage(tr("Saved project to:") + " " + QgsProject::instance()->setFilename() );
// add this to the list of recently used project files
saveRecentProjectPath(fullPath.filePath(), settings);
}
else
{
QMessageBox::critical(this,
tr("Unable to save project"),
tr("Unable to save project to ") + QgsProject::instance()->filename() );
tr("Unable to save project to ") + QgsProject::instance()->setFilename() );
}
}
catch ( std::exception & e )
{
QMessageBox::critical( 0x0,
tr("Unable to save project ") + QgsProject::instance()->filename(),
tr("Unable to save project ") + QgsProject::instance()->setFilename(),
QString::fromLocal8Bit( e.what() ),
QMessageBox::Ok,
Qt::NoButton );
@@ -4618,8 +4618,8 @@ void QgisApp::updateMouseCoordinatePrecision()
// coordinates with the aim of always having enough decimal places
// to show the difference in position between adjacent pixels.
// Also avoid taking the log of 0.
if (getMapCanvas()->mupp() != 0.0)
dp = static_cast<int> (ceil(-1.0*log10(getMapCanvas()->mupp())));
if (getMapCanvas()->mapUnitsPerPixel() != 0.0)
dp = static_cast<int> (ceil(-1.0*log10(getMapCanvas()->mapUnitsPerPixel())));
}
else
dp = QgsProject::instance()->readNumEntry("PositionPrecision","/DecimalPlaces");
@@ -180,8 +180,8 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(const QgsPoint& point)
//we need to map the view pixel coordinates
//to WMS layer pixel coordinates
QgsRect viewExtent = mCanvas->extent();
double mupp = mCanvas->mupp();
if(mupp == 0)
double mapUnitsPerPixel = mCanvas->mapUnitsPerPixel();
if(mapUnitsPerPixel == 0)
{
return;
}
@@ -196,7 +196,7 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(const QgsPoint& point)

if(xMinView < xMinLayer)
{
i = (int)(point.x() - (xMinLayer - xMinView) / mupp);
i = (int)(point.x() - (xMinLayer - xMinView) / mapUnitsPerPixel);
}
else
{
@@ -205,7 +205,7 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(const QgsPoint& point)

if(yMaxView > yMaxLayer)
{
j = (int)(point.y() - (yMaxView - yMaxLayer) / mupp);
j = (int)(point.y() - (yMaxView - yMaxLayer) / mapUnitsPerPixel);
}
else
{
@@ -147,10 +147,10 @@ void QgsComposerMap::cache ( void )
}

mCachePixmap = QPixmap( w, h );
double mupp = mExtent.width() / w;
double mapUnitsPerPixel = mExtent.width() / w;

// WARNING: ymax in QgsMapToPixel is device height!!!
QgsMapToPixel transform(mupp, h, mExtent.yMin(), mExtent.xMin() );
QgsMapToPixel transform(mapUnitsPerPixel, h, mExtent.yMin(), mExtent.xMin() );

mCachePixmap.fill(QColor(255,255,255));

@@ -111,14 +111,14 @@ class CORE_EXPORT QgsComposerMap : /*public QWidget , private Ui::QgsComposerMap
/**Sets offset values to shift image (useful for live updates when moving item content)*/
void setOffset(double xOffset, double yOffset);

/** stores state in DOM node
* @param elem is DOM element corresponding to 'Composer' tag
/** stores state in Dom node
* @param elem is Dom element corresponding to 'Composer' tag
* @param temp write template file
*/
bool writeXML(QDomElement& elem, QDomDocument & doc);

/** sets state from DOM document
* @param itemElem is DOM node corresponding to 'ComposerMap' tag
/** sets state from Dom document
* @param itemElem is Dom node corresponding to 'ComposerMap' tag
*/
bool readXML(const QDomElement& itemElem, const QDomDocument& doc);

@@ -214,12 +214,12 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
*/
QString toWkt() const;

/*! Restores state from the given DOM node.
/*! Restores state from the given Dom node.
* @param theNode The node from which state will be restored
* @return bool True on success, False on failure
*/
bool readXML( QDomNode & theNode );
/*! Stores state to the given DOM node in the given document.
/*! Stores state to the given Dom node in the given document.
* Below is an example of the generated tag.
* <spatialrefsys>
* <proj4>+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs </proj4>
@@ -481,7 +481,7 @@ QString QgsMapLayer::loadNamedStyle ( const QString theURI, bool &theResultFlag)
}
else
{
QFileInfo project( QgsProject::instance()->filename() );
QFileInfo project( QgsProject::instance()->setFilename() );
QgsDebugMsg( QString("project filename: %1").arg( project.absoluteFilePath() ) );

QString qml;
@@ -140,36 +140,36 @@ void QgsMapRenderer::adjustExtentToSize()
}

// calculate the translation and scaling parameters
// mupp = map units per pixel
double muppY = static_cast<double>(mExtent.height())
// mapUnitsPerPixel = map units per pixel
double mapUnitsPerPixelY = static_cast<double>(mExtent.height())
/ static_cast<double>(myHeight);
double muppX = static_cast<double>(mExtent.width())
double mapUnitsPerPixelX = static_cast<double>(mExtent.width())
/ static_cast<double>(myWidth);
mMupp = muppY > muppX ? muppY : muppX;
mMapUnitsPerPixel = mapUnitsPerPixelY > mapUnitsPerPixelX ? mapUnitsPerPixelY : mapUnitsPerPixelX;

// calculate the actual extent of the mapCanvas
double dxmin, dxmax, dymin, dymax, whitespace;

if (muppY > muppX)
if (mapUnitsPerPixelY > mapUnitsPerPixelX)
{
dymin = mExtent.yMin();
dymax = mExtent.yMax();
whitespace = ((myWidth * mMupp) - mExtent.width()) * 0.5;
whitespace = ((myWidth * mMapUnitsPerPixel) - mExtent.width()) * 0.5;
dxmin = mExtent.xMin() - whitespace;
dxmax = mExtent.xMax() + whitespace;
}
else
{
dxmin = mExtent.xMin();
dxmax = mExtent.xMax();
whitespace = ((myHeight * mMupp) - mExtent.height()) * 0.5;
whitespace = ((myHeight * mMapUnitsPerPixel) - mExtent.height()) * 0.5;
dymin = mExtent.yMin() - whitespace;
dymax = mExtent.yMax() + whitespace;
}

#ifdef QGISDEBUG
QString myMessage = "+-------------------MapRenderer--------------------------------+\n";
myMessage += QString("Map units per pixel (x,y) : %1, %2\n").arg(muppX).arg(muppY);
myMessage += QString("Map units per pixel (x,y) : %1, %2\n").arg(mapUnitsPerPixelX).arg(mapUnitsPerPixelY);
myMessage += QString("Pixmap dimensions (x,y) : %1, %2\n").arg(myWidth).arg(myHeight);
myMessage += QString("Extent dimensions (x,y) : %1, %2\n").arg(mExtent.width()).arg(mExtent.height());
myMessage += mExtent.toString();
@@ -191,7 +191,7 @@ void QgsMapRenderer::adjustExtentToSize()
QgsLogger::debug("Scale (assuming meters as map units) = 1", mScale, 1, __FILE__, __FUNCTION__, __LINE__);
#endif

newCoordXForm.setParameters(mMupp, dxmin, dymin, myHeight);
newCoordXForm.setParameters(mMapUnitsPerPixel, dxmin, dymin, myHeight);
mRenderContext.setMapToPixel(newCoordXForm);
mRenderContext.setExtent(mExtent);
}
@@ -65,7 +65,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
/**Sets scale for scale based visibility. Normally, the scale is calculated automatically. This
function is only used to force a preview scale (e.g. for print composer)*/
void setScale(double scale) {mScale = scale;}
double mupp() const { return mMupp; }
double mapUnitsPerPixel() const { return mMapUnitsPerPixel; }

int width() const { return mSize.width(); };
int height() const { return mSize.height(); };
@@ -172,7 +172,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
bool mDrawing;

//! map units per pixel
double mMupp;
double mMapUnitsPerPixel;

//! Map scale at its current zool level
double mScale;
@@ -19,11 +19,11 @@
#include <QPoint>
#include <QTextStream>

QgsMapToPixel::QgsMapToPixel(double mupp,
QgsMapToPixel::QgsMapToPixel(double mapUnitsPerPixel,
double ymax,
double ymin,
double xmin)
: mMapUnitsPerPixel(mupp),
: mMapUnitsPerPixel(mapUnitsPerPixel),
yMax(ymax),
yMin(ymin),
xMin(xmin),
@@ -53,9 +53,9 @@ QgsPoint QgsMapToPixel::toMapCoordinates(int x, int y) const
return toMapPoint(x, y);
}

void QgsMapToPixel::setMapUnitsPerPixel(double mupp)
void QgsMapToPixel::setMapUnitsPerPixel(double mapUnitsPerPixel)
{
mMapUnitsPerPixel = mupp;
mMapUnitsPerPixel = mapUnitsPerPixel;
}

double QgsMapToPixel::mapUnitsPerPixel() const
@@ -78,9 +78,9 @@ void QgsMapToPixel::setXMinimum(double xmin)
xMin = xmin;
}

void QgsMapToPixel::setParameters(double mupp, double xmin, double ymin, double ymax)
void QgsMapToPixel::setParameters(double mapUnitsPerPixel, double xmin, double ymin, double ymax)
{
mMapUnitsPerPixel = mupp;
mMapUnitsPerPixel = mapUnitsPerPixel;
xMin = xmin;
yMin = ymin;
yMax = ymax;

0 comments on commit 841699b

Please sign in to comment.