Skip to content
Permalink
Browse files
API cleanups
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9529 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 24, 2008
1 parent d979c64 commit 67fb20042ffe00942dc27c54cb6a4c428f88ffc0
Showing with 238 additions and 238 deletions.
  1. +10 −10 python/core/qgsmaplayer.sip
  2. +2 −2 python/core/qgsrasterdataprovider.sip
  3. +3 −3 python/core/qgsrasterlayer.sip
  4. +1 −1 python/core/qgsvectorlayer.sip
  5. +14 −14 python/plugins/mapserver_export/ms_export.py
  6. +2 −2 src/app/legend/qgslegendlayerfilegroup.cpp
  7. +1 −1 src/app/qgisapp.cpp
  8. +4 −4 src/app/qgsmapserverexport.cpp
  9. +4 −4 src/app/qgsmaptoolidentify.cpp
  10. +7 −7 src/app/qgsrasterlayerproperties.cpp
  11. +5 −5 src/app/qgsserversourceselect.cpp
  12. +7 −7 src/app/qgsvectorlayerproperties.cpp
  13. +2 −2 src/core/composer/qgscomposeritem.cpp
  14. +4 −4 src/core/composer/qgscomposeritem.h
  15. +2 −2 src/core/composer/qgscomposerlabel.cpp
  16. +7 −7 src/core/composer/qgscomposerlegend.cpp
  17. +15 −15 src/core/composer/qgscomposerscalebar.cpp
  18. +4 −4 src/core/composer/qgscomposerscalebar.h
  19. +2 −2 src/core/composer/qgscomposition.cpp
  20. +1 −1 src/core/composer/qgsdoubleboxscalebarstyle.cpp
  21. +6 −6 src/core/composer/qgsscalebarstyle.cpp
  22. +1 −1 src/core/composer/qgssingleboxscalebarstyle.cpp
  23. +5 −5 src/core/composer/qgsticksscalebarstyle.cpp
  24. +10 −10 src/core/qgshttptransaction.cpp
  25. +1 −1 src/core/qgshttptransaction.h
  26. +20 −20 src/core/qgsmaplayer.cpp
  27. +11 −11 src/core/qgsmaplayer.h
  28. +7 −7 src/core/qgsmaprenderer.cpp
  29. +4 −4 src/core/qgsmaprenderer.h
  30. +2 −2 src/core/qgsrasterdataprovider.h
  31. +1 −1 src/core/qgsvectorlayer.cpp
  32. +1 −1 src/core/qgsvectorlayer.h
  33. +10 −10 src/core/raster/qgsrasterlayer.cpp
  34. +3 −3 src/core/raster/qgsrasterlayer.h
  35. +4 −4 src/gui/qgsmapcanvas.cpp
  36. +1 −1 src/providers/wfs/qgswfsprovider.cpp
  37. +7 −7 src/providers/wms/qgswmsprovider.cpp
  38. +12 −12 src/providers/wms/qgswmsprovider.h
  39. +1 −1 tests/testdata/landsat_875.qml
  40. +1 −1 tests/testdata/lines.qml
  41. +1 −1 tests/testdata/lines_continuous_symbol.qml
  42. +1 −1 tests/testdata/lines_graduated_symbol.qml
  43. +1 −1 tests/testdata/lines_single_symbol.qml
  44. +1 −1 tests/testdata/lines_uniquevalue_symbol.qml
  45. +1 −1 tests/testdata/maprender_testdata.qml
  46. +1 −1 tests/testdata/points.qml
  47. +1 −1 tests/testdata/points_continuous_symbol.qml
  48. +1 −1 tests/testdata/points_graduated_symbol.qml
  49. +1 −1 tests/testdata/points_single_symbol.qml
  50. +1 −1 tests/testdata/points_uniquevalue_symbol.qml
  51. +1 −1 tests/testdata/polys.qml
  52. +1 −1 tests/testdata/polys_continuous_symbol.qml
  53. +1 −1 tests/testdata/polys_graduated_symbol.qml
  54. +1 −1 tests/testdata/polys_single_symbol.qml
  55. +1 −1 tests/testdata/polys_uniquevalue_symbol.qml
  56. +14 −14 tools/mapserver_export/ms_export.py
  57. +4 −4 tools/mapserver_export/qgsmapserverexport.cpp
@@ -160,7 +160,7 @@ public:
virtual bool copySymbologySettings(const QgsMapLayer& other) = 0;

/** Returns true if this layer can be in the same symbology group with another layer */
virtual bool isSymbologyCompatible(const QgsMapLayer& other) const = 0;
virtual bool hasCompatibleSymbology(const QgsMapLayer& other) const = 0;

/** Accessor for transparency level. */
unsigned int getTransparency();
@@ -174,21 +174,21 @@ public:
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
virtual QString errorCaptionString();
virtual QString lastErrorTitle();

/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
virtual QString errorString();
virtual QString lastError();

/** Returns layer's spatial reference system */
const QgsCoordinateReferenceSystem& srs();

/** Sets layer's spatial reference system */
void setSrs(const QgsCoordinateReferenceSystem& srs);
void setCrs(const QgsCoordinateReferenceSystem& srs);

/** A convenience function to capitalise the layer name */
static QString capitaliseLayerName(const QString name);
@@ -251,16 +251,16 @@ public slots:
virtual void invalidTransformInput();

/** Accessor and mutator for the minimum scale member */
void setMinScale(float theMinScale);
float minScale();
void setMinimumScale(float theMinScale);
float minimumScale();

/** Accessor and mutator for the maximum scale member */
void setMaxScale(float theMaxScale);
float maxScale();
void setMaximumScale(float theMaxScale);
float maximumScale();

/** Accessor and mutator for the scale based visilibility flag */
void setScaleBasedVisibility( bool theVisibilityFlag);
bool scaleBasedVisibility();
void toggleScaleBasedVisibility( bool theVisibilityFlag);
bool hasScaleBasedVisibility();

signals:

@@ -107,7 +107,7 @@ public:
* call a QMessageBox to display the contents.
*
*/
virtual QString errorCaptionString() = 0;
virtual QString lastErrorTitle() = 0;

/**
* \brief Returns the verbose error text for the last error in this provider
@@ -118,7 +118,7 @@ public:
* call a QMessageBox to display the contents.
*
*/
virtual QString errorString() = 0;
virtual QString lastError() = 0;


protected:
@@ -400,23 +400,23 @@ public:
/**Copies the symbology settings from another layer. Returns true in case of success*/
bool copySymbologySettings(const QgsMapLayer& other);

bool isSymbologyCompatible(const QgsMapLayer& other) const;
bool hasCompatibleSymbology(const QgsMapLayer& other) const;

/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
QString errorCaptionString();
QString lastErrorTitle();

/**
* If an operation returns 0 (e.g. draw()), this function
* returns the text of the error associated with the failure.
* Interactive users of this provider can then, for example,
* call a QMessageBox to display the contents.
*/
QString errorString();
QString lastError();

/** Returns the data provider
*
@@ -86,7 +86,7 @@ public:
bool copySymbologySettings(const QgsMapLayer& other);

/** Returns true if this layer can be in the same symbology group with another layer */
bool isSymbologyCompatible(const QgsMapLayer& other) const;
bool hasCompatibleSymbology(const QgsMapLayer& other) const;

/** Returns a pointer to the renderer */
const QgsRenderer* renderer() const;
@@ -42,8 +42,8 @@ def __init__(self, projectFile, mapFile):
self.mapName = ''
self.width = ''
self.height = ''
self.minScale = ''
self.maxScale = ''
self.minimumScale = ''
self.maximumScale = ''
self.template = ''
self.header = ''
self.footer = ''
@@ -57,8 +57,8 @@ def setOptions(self, units, image, mapname, width, height, template, header, foo
self.mapName = mapname
self.width = width
self.height = height
#self.minScale = minscale
#self.maxScale = maxscale
#self.minimumScale = minscale
#self.maximumScale = maxscale
self.template = template
self.header = header
self.footer = footer
@@ -218,10 +218,10 @@ def writeWebSection(self):
self.outFile.write(" END\n\n")

self.outFile.write(" #Scale range at which web interface will operate\n")
if self.minScale != "":
self.outFile.write(" MINSCALE " + self.minScale + "\n")
if self.maxScale != "":
self.outFile.write(" MAXSCALE " + self.maxScale + "\n")
if self.minimumScale != "":
self.outFile.write(" MINSCALE " + self.minimumScale + "\n")
if self.maximumScale != "":
self.outFile.write(" MAXSCALE " + self.maximumScale + "\n")

self.outFile.write(" # Template and header/footer settings\n")
self.outFile.write(" # Only the template parameter is required to display a map. See MapServer documentation\n")
@@ -304,9 +304,9 @@ def writeMapLayers(self):
layer_def += " TYPE " + lyr.getAttribute("type").encode('utf-8').upper() + "\n"

# Set min/max scales
if lyr.getAttribute('scaleBasedVisibilityFlag').encode('utf-8') == 1:
layer_def += " MINSCALE " + lyr.getAttribute('minScale').encode('utf-8') + "\n"
layer_def += " MAXSCALE " + lyr.getAttribute('maxScale').encode('utf-8') + "\n"
if lyr.getAttribute('hasScaleBasedVisibilityFlag').encode('utf-8') == 1:
layer_def += " MINSCALE " + lyr.getAttribute('minimumScale').encode('utf-8') + "\n"
layer_def += " MAXSCALE " + lyr.getAttribute('maximumScale').encode('utf-8') + "\n"

# data
dataString = lyr.getElementsByTagName("datasource")[0].childNodes[0].nodeValue.encode('utf-8')
@@ -383,11 +383,11 @@ def writeMapLayers(self):
# the proj4 text string needs to be reformatted to make mapserver happy
layer_def += self.formatProj4(proj4Text)
layer_def += " END\n"
scaleDependent = lyr.getAttribute("scaleBasedVisibilityFlag").encode('utf-8')
scaleDependent = lyr.getAttribute("hasScaleBasedVisibilityFlag").encode('utf-8')
if scaleDependent == '1':
# get the min and max scale settings
minscale = lyr.getAttribute("minScale").encode('utf-8')
maxscale = lyr.getAttribute("maxScale").encode('utf-8')
minscale = lyr.getAttribute("minimumScale").encode('utf-8')
maxscale = lyr.getAttribute("maximumScale").encode('utf-8')
if minscale > '':
layer_def += " MINSCALE " + minscale + "\n"
if maxscale > '':
@@ -60,7 +60,7 @@ QgsLegendItem::DRAG_ACTION QgsLegendLayerFileGroup::accept( const QgsLegendItem*
{
QgsMapLayer* childlayer = llf->layer();
const QgsMapLayer* newlayer = ( dynamic_cast<const QgsLegendLayerFile*>( li ) )->layer();
if ( newlayer->isSymbologyCompatible( *childlayer ) )
if ( newlayer->hasCompatibleSymbology( *childlayer ) )
{
return INSERT;
}
@@ -101,7 +101,7 @@ bool QgsLegendLayerFileGroup::insert( QgsLegendItem* newItem )
return false;
}
QgsMapLayer* newLayer = ( dynamic_cast<QgsLegendLayerFile*>( newItem ) )->layer();
if ( newLayer->isSymbologyCompatible( *thelayer ) )
if ( newLayer->hasCompatibleSymbology( *thelayer ) )
{
insertChild( childCount(), newItem );
return true;
@@ -5296,7 +5296,7 @@ bool QgisApp::addRasterLayer( QgsRasterLayer * theRasterLayer )
SLOT( showProgress( int, int ) ) );
// connect up any request the raster may make to update the statusbar message
QObject::connect( theRasterLayer,
SIGNAL( setStatus( QString ) ),
SIGNAL( statusChanged( QString ) ),
this,
SLOT( showStatusMessage( QString ) ) );
// notify the project we've made a change
@@ -149,11 +149,11 @@ void QgsMapserverExport::writeMapFile()
{
mapFile << " FOOTER " << txtWebFooter->text().toLocal8Bit().data() << std::endl;
}
QString minScale = txtMinScale->text().isEmpty() ? "#MINSCALE" : "MINSCALE";
QString maxScale = txtMinScale->text().isEmpty() ? " #MAXSCALE " : " MAXSCALE ";
QString minimumScale = txtMinScale->text().isEmpty() ? "#MINSCALE" : "MINSCALE";
QString maximumScale = txtMinScale->text().isEmpty() ? " #MAXSCALE " : " MAXSCALE ";
// write min and maxscale
mapFile << minScale.toLocal8Bit().data() << txtMinScale->text().toLocal8Bit().data() << std::endl;
mapFile << maxScale.toLocal8Bit().data() << txtMaxScale->text().toLocal8Bit().data() << std::endl;
mapFile << minimumScale.toLocal8Bit().data() << txtMinScale->text().toLocal8Bit().data() << std::endl;
mapFile << maximumScale.toLocal8Bit().data() << txtMaxScale->text().toLocal8Bit().data() << std::endl;
// write comments about the imagepath and image url
mapFile << "# Set IMAGEPATH to the path where mapserver should\n" <<
"# write its output\n" <<
@@ -412,16 +412,16 @@ void QgsMapToolIdentify::showError()
{
// QMessageBox::warning(
// this,
// mapLayer->errorCaptionString(),
// mapLayer->lastErrorTitle(),
// tr("Could not draw") + " " + mapLayer->name() + " " + tr("because") + ":\n" +
// mapLayer->errorString()
// mapLayer->lastError()
// );

QgsMessageViewer * mv = new QgsMessageViewer();
mv->setWindowTitle( mLayer->errorCaptionString() );
mv->setWindowTitle( mLayer->lastErrorTitle() );
mv->setMessageAsPlainText(
QObject::tr( "Could not identify objects on" ) + " " + mLayer->name() + " " + QObject::tr( "because" ) + ":\n" +
mLayer->errorString()
mLayer->lastError()
);
mv->exec(); // deletes itself on close
}
@@ -95,9 +95,9 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QWidget *p
connect( mColormapTreeWidget, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( handleColormapTreeWidgetDoubleClick( QTreeWidgetItem*, int ) ) );

// set up the scale based layer visibility stuff....
chkUseScaleDependentRendering->setChecked( lyr->scaleBasedVisibility() );
spinMinimumScale->setValue(( int )lyr->minScale() );
spinMaximumScale->setValue(( int )lyr->maxScale() );
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
spinMinimumScale->setValue(( int )lyr->minimumScale() );
spinMaximumScale->setValue(( int )lyr->maximumScale() );

// build GUI components
cboxColorMap->addItem( tr( "Grayscale" ) );
@@ -1439,9 +1439,9 @@ void QgsRasterLayerProperties::apply()


// set up the scale based layer visibility stuff....
mRasterLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
mRasterLayer->setMinScale( spinMinimumScale->value() );
mRasterLayer->setMaxScale( spinMaximumScale->value() );
mRasterLayer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
mRasterLayer->setMinimumScale( spinMinimumScale->value() );
mRasterLayer->setMaximumScale( spinMaximumScale->value() );

//update the legend pixmap
pixmapLegend->setPixmap( mRasterLayer->getLegendQPixmap() );
@@ -1688,7 +1688,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
mRasterLayer->setSrs( srs );
mRasterLayer->setCrs( srs );
}
else
{
@@ -334,7 +334,7 @@ void QgsServerSourceSelect::on_btnConnect_clicked()

if ( mWmsProvider )
{
connect( mWmsProvider, SIGNAL( setStatus( QString ) ), this, SLOT( showStatusMessage( QString ) ) );
connect( mWmsProvider, SIGNAL( statusChanged( QString ) ), this, SLOT( showStatusMessage( QString ) ) );

// WMS Provider all set up; let's get some layers

@@ -622,18 +622,18 @@ void QgsServerSourceSelect::showError( QgsWmsProvider * wms )
{
// QMessageBox::warning(
// this,
// wms->errorCaptionString(),
// wms->lastErrorTitle(),
// tr("Could not understand the response. The") + " " + wms->name() + " " +
// tr("provider said") + ":\n" +
// wms->errorString()
// wms->lastError()
// );

QgsMessageViewer * mv = new QgsMessageViewer( this );
mv->setWindowTitle( wms->errorCaptionString() );
mv->setWindowTitle( wms->lastErrorTitle() );
mv->setMessageAsPlainText(
tr( "Could not understand the response. The" ) + " " + wms->name() + " " +
tr( "provider said" ) + ":\n" +
wms->errorString()
wms->lastError()
);
mv->showMessage( true ); // Is deleted when closed
}
@@ -383,9 +383,9 @@ void QgsVectorLayerProperties::reset( void )
layer->displayField() ) );

// set up the scale based layer visibility stuff....
chkUseScaleDependentRendering->setChecked( layer->scaleBasedVisibility() );
spinMinimumScale->setValue(( int )layer->minScale() );
spinMaximumScale->setValue(( int )layer->maxScale() );
chkUseScaleDependentRendering->setChecked( layer->hasScaleBasedVisibility() );
spinMinimumScale->setValue(( int )layer->minimumScale() );
spinMaximumScale->setValue(( int )layer->maximumScale() );

// symbology initialization
if ( legendtypecombobox->count() == 0 )
@@ -484,9 +484,9 @@ void QgsVectorLayerProperties::apply()
}
#endif
// set up the scale based layer visibility stuff....
layer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
layer->setMinScale( spinMinimumScale->value() );
layer->setMaxScale( spinMaximumScale->value() );
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
layer->setMinimumScale( spinMinimumScale->value() );
layer->setMaximumScale( spinMaximumScale->value() );

// update the display field
layer->setDisplayField( displayFieldComboBox->currentText() );
@@ -867,7 +867,7 @@ void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
if ( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
layer->setSrs( srs );
layer->setCrs( srs );
}
else
{
@@ -554,14 +554,14 @@ void QgsComposerItem::drawText( QPainter* p, const QRectF& rect, const QString&
p->restore();
}

double QgsComposerItem::textWidthMM( const QFont& font, const QString& text ) const
double QgsComposerItem::textWidthMillimeters( const QFont& font, const QString& text ) const
{
QFont metricsFont = scaledFontPixelSize( font );
QFontMetrics fontMetrics( metricsFont );
return ( fontMetrics.width( text ) / FONT_WORKAROUND_SCALE );
}

double QgsComposerItem::fontAscentMM( const QFont& font ) const
double QgsComposerItem::fontAscentMillimeters( const QFont& font ) const
{
QFont metricsFont = scaledFontPixelSize( font );
QFontMetrics fontMetrics( metricsFont );
@@ -123,11 +123,11 @@ class CORE_EXPORT QgsComposerItem: public QGraphicsRectItem
/**Like the above, but with a rectangle for multiline text*/
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font ) const;

/**Returns the font width in MM (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double textWidthMM( const QFont& font, const QString& text ) const;
/**Returns the font width in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double textWidthMillimeters( const QFont& font, const QString& text ) const;

/**Returns the font ascent in MM (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double fontAscentMM( const QFont& font ) const;
/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double fontAscentMillimeters( const QFont& font ) const;

/**Calculates font to from point size to pixel size*/
double pixelFontSize( double pointSize ) const;
@@ -68,8 +68,8 @@ void QgsComposerLabel::setFont( const QFont& f )

void QgsComposerLabel::adjustSizeToText()
{
double textWidth = textWidthMM( mFont, mText );
double fontAscent = fontAscentMM( mFont );
double textWidth = textWidthMillimeters( mFont, mText );
double fontAscent = fontAscentMillimeters( mFont );

setSceneRect( QRectF( transform().dx(), transform().dy(), textWidth + 2 * mMargin + 2 * pen().widthF() + 1, \
fontAscent + 2 * mMargin + 2 * pen().widthF() + 1 ) );
Loading

0 comments on commit 67fb200

Please sign in to comment.