Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 67fb200
Show file tree
Hide file tree
Showing 57 changed files with 238 additions and 238 deletions.
20 changes: 10 additions & 10 deletions python/core/qgsmaplayer.sip
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsrasterdataprovider.sip
Expand Up @@ -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
Expand All @@ -118,7 +118,7 @@ public:
* call a QMessageBox to display the contents.
*
*/
virtual QString errorString() = 0;
virtual QString lastError() = 0;


protected:
Expand Down
6 changes: 3 additions & 3 deletions python/core/qgsrasterlayer.sip
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsvectorlayer.sip
Expand Up @@ -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;
Expand Down
28 changes: 14 additions & 14 deletions python/plugins/mapserver_export/ms_export.py
Expand Up @@ -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 = ''
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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 > '':
Expand Down
4 changes: 2 additions & 2 deletions src/app/legend/qgslegendlayerfilegroup.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmapserverexport.cpp
Expand Up @@ -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" <<
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmaptoolidentify.cpp
Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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
{
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgsserversourceselect.cpp
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposeritem.cpp
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/core/composer/qgscomposeritem.h
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -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 ) );
Expand Down

0 comments on commit 67fb200

Please sign in to comment.