Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Sep 22, 2012
2 parents 2b1443f + 1b95cdc commit f7af2de
Show file tree
Hide file tree
Showing 35 changed files with 751 additions and 386 deletions.
30 changes: 12 additions & 18 deletions python/console_sci.py
Expand Up @@ -124,6 +124,8 @@ def clearConsole(self):
self.setFocus()

def commandConsole(self, command):
if not self.is_cursor_on_last_line():
self.move_cursor_to_end()
line, pos = self.getCurLine()
selCmd= self.text(line).length()
self.setSelection(line, 4, line, selCmd)
Expand Down Expand Up @@ -324,7 +326,6 @@ def showPrevious(self):
self.move_cursor_to_end()
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)


def showNext(self):
if self.historyIndex > 0 and not self.history.isEmpty():
line, pos = self.getCurLine()
Expand Down Expand Up @@ -365,7 +366,6 @@ def keyPressEvent(self, e):
QsciScintilla.keyPressEvent(self, e)
elif e.key() == Qt.Key_Delete:
if self.hasSelectedText():
self.check_selection()
self.removeSelectedText()
elif self.is_cursor_on_last_line():
self.SendScintilla(QsciScintilla.SCI_CLEAR)
Expand Down Expand Up @@ -405,13 +405,6 @@ def keyPressEvent(self, e):
self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
else:
self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
elif e.key() == Qt.Key_Delete:
if self.hasSelectedText():
self.check_selection()
self.removeSelectedText()
elif self.is_cursor_on_last_line():
self.SendScintilla(QsciScintilla.SCI_CLEAR)
event.accept()
## TODO: press event for auto-completion file directory
#elif e.key() == Qt.Key_Tab:
#self.show_file_completion()
Expand All @@ -423,28 +416,29 @@ def keyPressEvent(self, e):
def paste(self):
"""Reimplement QScintilla method"""
stringPaste = unicode(QApplication.clipboard().text())
if self.hasSelectedText():
self.removeSelectedText()
self.insertFromDropPaste(stringPaste)

## Drag and drop
def dragEnterEvent(self, e):
if e.mimeData().hasFormat('text/plain'):
def dropEvent(self, e):
if e.mimeData().hasText():
stringDrag = e.mimeData().text()
self.insertFromDropPaste(stringDrag)
e.setDropAction(Qt.MoveAction)
e.accept()
else:
e.ignore()
QsciScintillaCompat.dropEvent(self, e)

def dropEvent(self, e):
stringDrag = e.mimeData().text()
self.insertFromDropPaste(stringDrag)

def insertFromDropPaste(self, textDP):
pasteList = QStringList()
pasteList = textDP.split("\n")
for line in pasteList[:-1]:
self.append(line)
self.insert(line)
self.move_cursor_to_end()
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
self.runCommand(unicode(self.currentCommand()))
self.append(unicode(pasteList[-1]))
self.insert(unicode(pasteList[-1]))
self.move_cursor_to_end()

def getTextFromEditor(self):
Expand Down
190 changes: 132 additions & 58 deletions python/core/qgsdiagramrendererv2.sip
Expand Up @@ -3,70 +3,108 @@ struct QgsDiagramLayerSettings
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
%End
//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};

enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};

QgsDiagramLayerSettings();

//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)

//avoid inclusion of QgsPalLabeling
enum Placement
{
AroundPoint, // Point / Polygon
OverPoint, // Point / Polygon
Line, // Line / Polygon
Curved, // Line
Horizontal, // Polygon
Free // Polygon
};

enum LinePlacementFlags
{
OnLine = 1,
AboveLine = 2,
BelowLine = 4,
MapOrientation = 8
};

QgsDiagramLayerSettings();

//pal placement properties
Placement placement;
LinePlacementFlags placementFlags;
int priority; // 0 = low, 10 = high
bool obstacle; // whether it's an obstacle
double dist; // distance from the feature (in mm)
QgsDiagramRendererV2* renderer;
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
};

//diagram settings for rendering
struct QgsDiagramSettings
class QgsDiagramSettings
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
%End
public:
enum SizeType
{
MM,
MapUnits
};

enum LabelPlacementMethod
{
Height,
XHeight
};

//! Orientation of histogram
enum DiagramOrientation
{
Up,
Down,
Left,
Right
};

QgsDiagramSettings();
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
QSizeF size; //size
SizeType sizeType; //mm or map units
QColor backgroundColor;
QColor penColor;
double penWidth;
LabelPlacementMethod labelPlacementMethod;
DiagramOrientation diagramOrientation;
double barWidth;
int transparency; // 0 - 100
bool scaleByArea;

//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;

//! Scale diagrams smaller than mMinimumSize to mMinimumSize
double minimumSize;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
};

//additional diagram settings for interpolated size rendering
class QgsDiagramInterpolationSettings
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
%End
enum SizeType
{
MM,
MapUnits
};

QgsDiagramSettings();
QFont font;
QList< QColor > categoryColors;
QList< int > categoryIndices;
QSizeF size; //size
SizeType sizeType; //mm or map units
QColor backgroundColor;
QColor penColor;
double penWidth;

//scale range (-1 if no lower / upper bound )
double minScaleDenominator;
double maxScaleDenominator;

void readXML( const QDomElement& elem );
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
public:
QSizeF lowerSize;
QSizeF upperSize;
double lowerValue;
double upperValue;
/**Index of the classification attribute*/
int classificationAttribute;
};

/**Returns diagram settings for a feature*/
Expand Down Expand Up @@ -98,10 +136,36 @@ class QgsDiagramRendererV2

virtual void readXML( const QDomElement& elem ) = 0;
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc ) const = 0;


protected:

/**Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered). Used internally within renderDiagram()
* @param att attribute map
* @param c render context
* @param s out: diagram settings for the feature
*/
virtual bool diagramSettings( const QgsAttributeMap& att, const QgsRenderContext& c, QgsDiagramSettings& s ) = 0;

/**Returns size of the diagram (in painter units) or an invalid size in case of error*/
virtual QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c ) = 0;

/**Converts size from mm to map units*/
void convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const;

/**Returns the paint device dpi (or -1 in case of error*/
static int dpiPaintDevice( const QPainter* );

//read / write diagram
void _readXML( const QDomElement& elem );
void _writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;

/**Reference to the object that does the real diagram rendering*/
QgsDiagram* mDiagram;
};

/**Renders the diagrams for all features with the same settings*/
class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
Expand All @@ -120,9 +184,14 @@ class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;

protected:
bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );

QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
};

class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
{
%TypeHeaderCode
#include <qgsdiagramrendererv2.h>
Expand Down Expand Up @@ -157,4 +226,9 @@ class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2

void readXML( const QDomElement& elem );
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;

protected:
bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );

QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
};
22 changes: 22 additions & 0 deletions python/gui/qgsscalecombobox.sip
Expand Up @@ -12,6 +12,28 @@ class QgsScaleComboBox : QComboBox
QgsScaleComboBox(QWidget * parent = 0);
~QgsScaleComboBox();

//! Function to read the selected scale as text
// @note added in 2.0
QString scaleString();
//! Function to set the selected scale from text
// @note added in 2.0
bool setScaleString( QString scaleTxt );
//! Function to read the selected scale as double
// @note added in 2.0
double scale();
//! Function to set the selected scale from double
// @note added in 2.0
void setScale( double scale );

//! Helper function to convert a double to scale string
// Performs rounding, so an exact representation is not to
// be expected.
// @note added in 2.0
static QString toString( double scale );
//! Helper function to convert a scale string to double
// @note added in 2.0
static double toDouble( QString scaleString, bool *ok = NULL );

public slots:
void updateScales( const QStringList &scales = QStringList() );
};
Expand Down

0 comments on commit f7af2de

Please sign in to comment.