Skip to content

Commit

Permalink
Merge branch 'master' into qgsexpression_DA
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Nov 28, 2012
2 parents a448f6a + a4484b2 commit 69308d3
Show file tree
Hide file tree
Showing 33 changed files with 633 additions and 121 deletions.
1 change: 0 additions & 1 deletion python/console/console.py
Expand Up @@ -360,7 +360,6 @@ def openHelp(self):
self.helpDlg.activateWindow()

def openSettings(self):
#options = optionsDialog()
self.options.exec_()

def prefChanged(self):
Expand Down
15 changes: 5 additions & 10 deletions python/console/console_sci.py
Expand Up @@ -72,8 +72,6 @@ def __init__(self, parent=None):
self.setCaretWidth(2)

# Set Python lexer
# Set style for Python comments (style number 1) to a fixed-width
# courier.
self.setLexers()

# Indentation
Expand Down Expand Up @@ -130,19 +128,16 @@ def commandConsole(self, command):
self.setSelection(line, 4, line, selCmdLenght)
self.removeSelectedText()
if command == "iface":
"""Import QgisInterface class"""
# import QgisInterface class
self.append('from qgis.utils import iface')
elif command == "sextante":
"""Import Sextante class"""
self.append('from sextante.core.Sextante import Sextante')
elif command == "cLayer":
"""Retrieve current Layer from map camvas"""
self.append('cLayer = iface.mapCanvas().currentLayer()')
# import Sextante class
self.append('import sextante')
elif command == "qtCore":
"""Import QtCore class"""
# import QtCore class
self.append('from PyQt4.QtCore import *')
elif command == "qtGui":
"""Import QtGui class"""
# import QtGui class
self.append('from PyQt4.QtGui import *')
self.entered()
self.move_cursor_to_end()
Expand Down
2 changes: 2 additions & 0 deletions python/core/qgspallabeling.sip
Expand Up @@ -135,6 +135,8 @@ class QgsPalLayerSettings
bool reverseDirectionSymbol;
DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
unsigned int upsidedownLabels; // whether, or how, to show upsidedown labels
double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
bool fontSizeInMapUnits; //true if font size is in map units (otherwise in points)
bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
Expand Down
5 changes: 3 additions & 2 deletions python/core/symbology-ng/qgssvgcache.sip
Expand Up @@ -34,7 +34,7 @@ class QgsSvgCacheEntry
/**A cache for images / pictures derived from svg files. This class supports parameter replacement in svg files
according to the svg params specification (http://www.w3.org/TR/2009/WD-SVGParamPrimer-20090616/). Supported are
the parameters 'fill-color', 'pen-color', 'outline-width', 'stroke-width'. E.g. <circle fill="param(fill-color red)" stroke="param(pen-color black)" stroke-width="param(outline-width 1)"*/
class QgsSvgCache
class QgsSvgCache : QObject
{
%TypeHeaderCode
#include <qgssvgcache.h>
Expand All @@ -56,7 +56,8 @@ class QgsSvgCache
double& defaultOutlineWidth ) const;

protected:
QgsSvgCache();
//! protected constructor
QgsSvgCache( QObject* parent = 0 );

/**Creates new cache entry and returns pointer to it*/
QgsSvgCacheEntry* insertSVG( const QString& file, int size, const QColor& fill, const QColor& outline, double outlineWidth,
Expand Down
6 changes: 5 additions & 1 deletion python/gui/qgisinterface.sip
Expand Up @@ -359,12 +359,16 @@ class QgisInterface : QObject
virtual QAction *actionAddPgLayer() = 0;
virtual QAction *actionAddWmsLayer() = 0;
virtual QAction *actionLayerSeparator1() = 0 /Deprecated/;
/** @note added in 1.9 */
virtual QAction *actionCopyLayerStyle() = 0;
/** @note added in 1.9 */
virtual QAction *actionPasteLayerStyle() = 0;
virtual QAction *actionOpenTable() = 0;
virtual QAction *actionToggleEditing() = 0;
virtual QAction *actionLayerSaveAs() = 0;
virtual QAction *actionLayerSelectionSaveAs() = 0;
virtual QAction *actionRemoveLayer() = 0;
/** @note added in 2.0 */
/** @note added in 1.9 */
virtual QAction *actionDuplicateLayer() = 0;
virtual QAction *actionLayerProperties() = 0;
virtual QAction *actionLayerSeparator2() = 0 /Deprecated/;
Expand Down
Expand Up @@ -121,7 +121,7 @@ def fieldTypes(self):
return [
"integer", "bigint", "smallint", # integers
"real", "double", "float", "numeric", # floats
"varchar(n)", "character(n)", "text", # strings
"varchar", "varchar(n)", "character(n)", "text", # strings
"date", "datetime" # date/time
]

Expand Down
12 changes: 8 additions & 4 deletions src/app/qgisapp.h
Expand Up @@ -280,17 +280,21 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionAddOgrLayer() { return mActionAddOgrLayer; }
QAction *actionAddRasterLayer() { return mActionAddRasterLayer; }
QAction *actionAddPgLayer() { return mActionAddPgLayer; }
QAction *actionAddSpatiaLiteLayer() { return mActionAddSpatiaLiteLayer; };
QAction *actionAddSpatiaLiteLayer() { return mActionAddSpatiaLiteLayer; }
QAction *actionAddWmsLayer() { return mActionAddWmsLayer; }
QAction *actionAddWcsLayer() { return mActionAddWcsLayer; }
QAction *actionAddWfsLayer() { return mActionAddWfsLayer; }
/** @note added in 1.9 */
QAction *actionCopyLayerStyle() { return mActionCopyStyle; }
/** @note added in 1.9 */
QAction *actionPasteLayerStyle() { return mActionPasteStyle; }
QAction *actionOpenTable() { return mActionOpenTable; }
QAction *actionToggleEditing() { return mActionToggleEditing; }
QAction *actionSaveEdits() { return mActionSaveEdits; }
QAction *actionLayerSaveAs() { return mActionLayerSaveAs; }
QAction *actionLayerSelectionSaveAs() { return mActionLayerSelectionSaveAs; }
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
/** @note added in 2.0 */
/** @note added in 1.9 */
QAction *actionDuplicateLayer() { return mActionDuplicateLayer; }
QAction *actionSetLayerCRS() { return mActionSetLayerCRS; }
QAction *actionSetProjectCRSFromLayer() { return mActionSetProjectCRSFromLayer; }
Expand Down Expand Up @@ -437,13 +441,13 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
(defaults to the active layer on the legend)
*/
void editPaste( QgsMapLayer * destinationLayer = 0 );

//! copies style of the active layer to the clipboard
/**
\param sourceLayer The layer where the style will be taken from
(defaults to the active layer on the legend)
*/
void copyStyle( QgsMapLayer * sourceLayer = 0 );
//! copies style on the clipboard to the active layer
//! pastes style on the clipboard to the active layer
/**
\param destinatioLayer The layer that the clipboard will be pasted to
(defaults to the active layer on the legend)
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisappinterface.cpp
Expand Up @@ -460,6 +460,8 @@ QAction *QgisAppInterface::actionAddRasterLayer() { return qgis->actionAddRaster
QAction *QgisAppInterface::actionAddPgLayer() { return qgis->actionAddPgLayer(); }
QAction *QgisAppInterface::actionAddWmsLayer() { return qgis->actionAddWmsLayer(); }
QAction *QgisAppInterface::actionLayerSeparator1() { return 0; }
QAction *QgisAppInterface::actionCopyLayerStyle() { return qgis->actionCopyLayerStyle(); }
QAction *QgisAppInterface::actionPasteLayerStyle() { return qgis->actionPasteLayerStyle(); }
QAction *QgisAppInterface::actionOpenTable() { return qgis->actionOpenTable(); }
QAction *QgisAppInterface::actionToggleEditing() { return qgis->actionToggleEditing(); }
QAction *QgisAppInterface::actionLayerSaveAs() { return qgis->actionLayerSaveAs(); }
Expand Down
6 changes: 5 additions & 1 deletion src/app/qgisappinterface.h
Expand Up @@ -308,12 +308,16 @@ class QgisAppInterface : public QgisInterface
virtual QAction *actionAddPgLayer();
virtual QAction *actionAddWmsLayer();
virtual QAction *actionLayerSeparator1();
/** @note added in 1.9 */
virtual QAction *actionCopyLayerStyle();
/** @note added in 1.9 */
virtual QAction *actionPasteLayerStyle();
virtual QAction *actionOpenTable();
virtual QAction *actionToggleEditing();
virtual QAction *actionLayerSaveAs();
virtual QAction *actionLayerSelectionSaveAs();
virtual QAction *actionRemoveLayer();
/** @note added in 2.0 */
/** @note added in 1.9 */
virtual QAction *actionDuplicateLayer();
virtual QAction *actionLayerProperties();
virtual QAction *actionLayerSeparator2();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactiondialog.cpp
Expand Up @@ -340,7 +340,7 @@ void QgsAttributeActionDialog::addDefaultActions()
insertRow( pos++, QgsAction::GenericPython, tr( "Selected field's value (Identify features tool)" ), "QtGui.QMessageBox.information(None, \"Current field's value\", \"[% $currentfield %]\")", false );
insertRow( pos++, QgsAction::GenericPython, tr( "Clicked coordinates (Run feature actions tool)" ), "QtGui.QMessageBox.information(None, \"Clicked coords\", \"layer: [% $layerid %]\\ncoords: ([% $clickx %],[% $clickx %])\")", false );
insertRow( pos++, QgsAction::OpenUrl, tr( "Open file" ), "[% \"PATH\" %]", false );
insertRow( pos++, QgsAction::OpenUrl, tr( "Search on web based on attribute's value" ), "http://www.google.it/?q=[% \"ATTRIBUTE\" %]", false );
insertRow( pos++, QgsAction::OpenUrl, tr( "Search on web based on attribute's value" ), "http://www.google.com/search?q=[% \"ATTRIBUTE\" %]", false );
}

void QgsAttributeActionDialog::itemSelectionChanged()
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgslabelinggui.cpp
Expand Up @@ -213,6 +213,9 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
mUpsidedownRadioOff->setChecked( true );
break;
}
mMaxCharAngleInDSpinBox->setValue( lyr.maxCurvedCharAngleIn );
// lyr.maxCurvedCharAngleOut must be negative, but it is shown as positive spinbox in GUI
mMaxCharAngleOutDSpinBox->setValue( qAbs( lyr.maxCurvedCharAngleOut ) );

wrapCharacterEdit->setText( lyr.wrapChar );
mFontLineHeightSpinBox->setValue( lyr.multilineHeight );
Expand Down Expand Up @@ -502,6 +505,10 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
{
lyr.upsidedownLabels = QgsPalLayerSettings::ShowAll;
}
lyr.maxCurvedCharAngleIn = mMaxCharAngleInDSpinBox->value();
// lyr.maxCurvedCharAngleOut must be negative, but it is shown as positive spinbox in GUI
lyr.maxCurvedCharAngleOut = -mMaxCharAngleOutDSpinBox->value();

lyr.minFeatureSize = mMinSizeSpinBox->value();
lyr.limitNumLabels = mLimitLabelChkBox->isChecked();
lyr.maxNumLabels = mLimitLabelSpinBox->value();
Expand Down Expand Up @@ -966,6 +973,8 @@ void QgsLabelingGui::updateOptions()
|| ( stackedPlacement->currentWidget() == pageLine && radLineCurved->isChecked() ) )
{
stackedOptions->setCurrentWidget( pageOptionsLine );
mMaxCharAngleFrame->setVisible(( stackedPlacement->currentWidget() == pageLine
&& radLineCurved->isChecked() ) );
}
else
{
Expand Down
25 changes: 15 additions & 10 deletions src/app/qgsmaptoolidentify.cpp
Expand Up @@ -205,7 +205,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
return false;
}

QMap< QString, QString > attributes, derivedAttributes;
QMap< QString, QString > derivedAttributes;

QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y );

Expand Down Expand Up @@ -260,6 +260,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
calc.setEllipsoid( ellipsoid );
calc.setSourceCrs( layer->crs().srsid() );
}

QgsFeatureList::iterator f_it = featureList.begin();

bool filter = false;
Expand All @@ -281,8 +282,6 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int

featureCount++;

QMap<QString, QString> derivedAttributes;

// Calculate derived attributes and insert:
// measure distance or area depending on geometry type
if ( layer->geometryType() == QGis::Line )
Expand All @@ -296,33 +295,39 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
f_it->geometry()->wkbType() == QGis::WKBLineString25D )
{
// Add the start and end points in as derived attributes
str = QLocale::system().toString( f_it->geometry()->asPolyline().first().x(), 'g', 10 );
QgsPoint pnt = mCanvas->mapRenderer()->layerToMapCoordinates( layer, f_it->geometry()->asPolyline().first() );
str = QLocale::system().toString( pnt.x(), 'g', 10 );
derivedAttributes.insert( tr( "firstX", "attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
str = QLocale::system().toString( f_it->geometry()->asPolyline().first().y(), 'g', 10 );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( tr( "firstY" ), str );
str = QLocale::system().toString( f_it->geometry()->asPolyline().last().x(), 'g', 10 );
pnt = mCanvas->mapRenderer()->layerToMapCoordinates( layer, f_it->geometry()->asPolyline().last() );
str = QLocale::system().toString( pnt.x(), 'g', 10 );
derivedAttributes.insert( tr( "lastX", "attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
str = QLocale::system().toString( f_it->geometry()->asPolyline().last().y(), 'g', 10 );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( tr( "lastY" ), str );
}
}
else if ( layer->geometryType() == QGis::Polygon )
{
double area = calc.measure( f_it->geometry() );
double perimeter = calc.measurePerimeter( f_it->geometry() );
QGis::UnitType myDisplayUnits;
convertMeasurement( calc, area, myDisplayUnits, true ); // area and myDisplayUnits are out params
QString str = calc.textUnit( area, 3, myDisplayUnits, true );
derivedAttributes.insert( tr( "Area" ), str );
convertMeasurement( calc, perimeter, myDisplayUnits, false ); // area and myDisplayUnits are out params
str = calc.textUnit( perimeter, 3, myDisplayUnits, false );
derivedAttributes.insert( tr( "Perimeter" ), str );
}
else if ( layer->geometryType() == QGis::Point &&
( f_it->geometry()->wkbType() == QGis::WKBPoint ||
f_it->geometry()->wkbType() == QGis::WKBPoint25D ) )
{
// Include the x and y coordinates of the point as a derived attribute
QString str;
str = QLocale::system().toString( f_it->geometry()->asPoint().x(), 'g', 10 );
QgsPoint pnt = mCanvas->mapRenderer()->layerToMapCoordinates( layer, f_it->geometry()->asPoint() );
QString str = QLocale::system().toString( pnt.x(), 'g', 10 );
derivedAttributes.insert( "X", str );
str = QLocale::system().toString( f_it->geometry()->asPoint().y(), 'g', 10 );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( "Y", str );
}

Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -320,6 +320,7 @@ SET(QGIS_CORE_MOC_HDRS
gps/qgsgpsdconnection.h

symbology-ng/qgscptcityarchive.h
symbology-ng/qgssvgcache.h
)

IF (WITH_INTERNAL_QEXTSERIALPORT)
Expand Down
7 changes: 0 additions & 7 deletions src/core/composer/qgscomposerlegend.h
Expand Up @@ -232,13 +232,6 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
/**Draws a layer item and all subitems*/
QSizeF drawLayerItemTitle( QgsComposerLayerItem* layerItem, QPainter* painter = 0, QPointF point = QPointF() );

/**Draws child items of a layer item
@param p painter
@param layerItem parent model item (layer)
@param currentPosition in/out: current y position of legend item
@param layerOpacity opacity of the corresponding map layer
*/

Nucleon drawSymbolItem( QgsComposerLegendItem* symbolItem, QPainter* painter = 0, QPointF point = QPointF(), double labelXOffset = 0. );

/**Draws a symbol at the current y position and returns the new x position. Returns real symbol height, because for points,
Expand Down
5 changes: 4 additions & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -837,7 +837,10 @@ namespace pal
// normalise between -180 and 180
while ( angle_delta > M_PI ) angle_delta -= 2 * M_PI;
while ( angle_delta < -M_PI ) angle_delta += 2 * M_PI;
if ( f->labelInfo->max_char_angle_delta > 0 && fabs( angle_delta ) > f->labelInfo->max_char_angle_delta*( M_PI / 180 ) )
if (( f->labelInfo->max_char_angle_inside > 0 && angle_delta > 0
&& angle_delta > f->labelInfo->max_char_angle_inside*( M_PI / 180 ) )
|| ( f->labelInfo->max_char_angle_outside < 0 && angle_delta < 0
&& angle_delta < f->labelInfo->max_char_angle_outside*( M_PI / 180 ) ) )
{
delete slp;
return NULL;
Expand Down
9 changes: 6 additions & 3 deletions src/core/pal/feature.h
Expand Up @@ -58,16 +58,19 @@ namespace pal
double width;
} CharacterInfo;

LabelInfo( int num, double height )
LabelInfo( int num, double height, double maxinangle = 20.0, double maxoutangle = -20.0 )
{
max_char_angle_delta = 20;
max_char_angle_inside = maxinangle;
// outside angle should be negative
max_char_angle_outside = maxoutangle > 0 ? -maxoutangle : maxoutangle;
label_height = height;
char_num = num;
char_info = new CharacterInfo[num];
}
~LabelInfo() { delete [] char_info; }

double max_char_angle_delta;
double max_char_angle_inside;
double max_char_angle_outside;
double label_height;
int char_num;
CharacterInfo* char_info;
Expand Down

0 comments on commit 69308d3

Please sign in to comment.