Skip to content

Commit f7af2de

Browse files
committedSep 22, 2012
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 2b1443f + 1b95cdc commit f7af2de

35 files changed

+751
-386
lines changed
 

‎python/console_sci.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def clearConsole(self):
124124
self.setFocus()
125125

126126
def commandConsole(self, command):
127+
if not self.is_cursor_on_last_line():
128+
self.move_cursor_to_end()
127129
line, pos = self.getCurLine()
128130
selCmd= self.text(line).length()
129131
self.setSelection(line, 4, line, selCmd)
@@ -324,7 +326,6 @@ def showPrevious(self):
324326
self.move_cursor_to_end()
325327
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
326328

327-
328329
def showNext(self):
329330
if self.historyIndex > 0 and not self.history.isEmpty():
330331
line, pos = self.getCurLine()
@@ -365,7 +366,6 @@ def keyPressEvent(self, e):
365366
QsciScintilla.keyPressEvent(self, e)
366367
elif e.key() == Qt.Key_Delete:
367368
if self.hasSelectedText():
368-
self.check_selection()
369369
self.removeSelectedText()
370370
elif self.is_cursor_on_last_line():
371371
self.SendScintilla(QsciScintilla.SCI_CLEAR)
@@ -405,13 +405,6 @@ def keyPressEvent(self, e):
405405
self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
406406
else:
407407
self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
408-
elif e.key() == Qt.Key_Delete:
409-
if self.hasSelectedText():
410-
self.check_selection()
411-
self.removeSelectedText()
412-
elif self.is_cursor_on_last_line():
413-
self.SendScintilla(QsciScintilla.SCI_CLEAR)
414-
event.accept()
415408
## TODO: press event for auto-completion file directory
416409
#elif e.key() == Qt.Key_Tab:
417410
#self.show_file_completion()
@@ -423,28 +416,29 @@ def keyPressEvent(self, e):
423416
def paste(self):
424417
"""Reimplement QScintilla method"""
425418
stringPaste = unicode(QApplication.clipboard().text())
419+
if self.hasSelectedText():
420+
self.removeSelectedText()
426421
self.insertFromDropPaste(stringPaste)
427422

428423
## Drag and drop
429-
def dragEnterEvent(self, e):
430-
if e.mimeData().hasFormat('text/plain'):
424+
def dropEvent(self, e):
425+
if e.mimeData().hasText():
426+
stringDrag = e.mimeData().text()
427+
self.insertFromDropPaste(stringDrag)
428+
e.setDropAction(Qt.MoveAction)
431429
e.accept()
432430
else:
433-
e.ignore()
431+
QsciScintillaCompat.dropEvent(self, e)
434432

435-
def dropEvent(self, e):
436-
stringDrag = e.mimeData().text()
437-
self.insertFromDropPaste(stringDrag)
438-
439433
def insertFromDropPaste(self, textDP):
440434
pasteList = QStringList()
441435
pasteList = textDP.split("\n")
442436
for line in pasteList[:-1]:
443-
self.append(line)
437+
self.insert(line)
444438
self.move_cursor_to_end()
445439
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
446440
self.runCommand(unicode(self.currentCommand()))
447-
self.append(unicode(pasteList[-1]))
441+
self.insert(unicode(pasteList[-1]))
448442
self.move_cursor_to_end()
449443

450444
def getTextFromEditor(self):

‎python/core/qgsdiagramrendererv2.sip

Lines changed: 132 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,108 @@ struct QgsDiagramLayerSettings
33
%TypeHeaderCode
44
#include <qgsdiagramrendererv2.h>
55
%End
6+
//avoid inclusion of QgsPalLabeling
7+
enum Placement
8+
{
9+
AroundPoint, // Point / Polygon
10+
OverPoint, // Point / Polygon
11+
Line, // Line / Polygon
12+
Curved, // Line
13+
Horizontal, // Polygon
14+
Free // Polygon
15+
};
16+
17+
enum LinePlacementFlags
18+
{
19+
OnLine = 1,
20+
AboveLine = 2,
21+
BelowLine = 4,
22+
MapOrientation = 8
23+
};
24+
25+
QgsDiagramLayerSettings();
26+
27+
//pal placement properties
28+
Placement placement;
29+
LinePlacementFlags placementFlags;
30+
int priority; // 0 = low, 10 = high
31+
bool obstacle; // whether it's an obstacle
32+
double dist; // distance from the feature (in mm)
33+
QgsDiagramRendererV2* renderer;
34+
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
35+
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
636

7-
//avoid inclusion of QgsPalLabeling
8-
enum Placement
9-
{
10-
AroundPoint, // Point / Polygon
11-
OverPoint, // Point / Polygon
12-
Line, // Line / Polygon
13-
Curved, // Line
14-
Horizontal, // Polygon
15-
Free // Polygon
16-
};
17-
18-
enum LinePlacementFlags
19-
{
20-
OnLine = 1,
21-
AboveLine = 2,
22-
BelowLine = 4,
23-
MapOrientation = 8
24-
};
25-
26-
QgsDiagramLayerSettings();
27-
28-
//pal placement properties
29-
Placement placement;
30-
LinePlacementFlags placementFlags;
31-
int priority; // 0 = low, 10 = high
32-
bool obstacle; // whether it's an obstacle
33-
double dist; // distance from the feature (in mm)
34-
QgsDiagramRendererV2* renderer;
35-
int xPosColumn; //attribute index for x coordinate (or -1 if position not data defined)
36-
int yPosColumn;//attribute index for y coordinate (or -1 if position not data defined)
37-
38-
void readXML( const QDomElement& elem );
39-
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
37+
void readXML( const QDomElement& elem );
38+
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
4039
};
4140

4241
//diagram settings for rendering
43-
struct QgsDiagramSettings
42+
class QgsDiagramSettings
43+
{
44+
%TypeHeaderCode
45+
#include <qgsdiagramrendererv2.h>
46+
%End
47+
public:
48+
enum SizeType
49+
{
50+
MM,
51+
MapUnits
52+
};
53+
54+
enum LabelPlacementMethod
55+
{
56+
Height,
57+
XHeight
58+
};
59+
60+
//! Orientation of histogram
61+
enum DiagramOrientation
62+
{
63+
Up,
64+
Down,
65+
Left,
66+
Right
67+
};
68+
69+
QgsDiagramSettings();
70+
QFont font;
71+
QList< QColor > categoryColors;
72+
QList< int > categoryIndices;
73+
QSizeF size; //size
74+
SizeType sizeType; //mm or map units
75+
QColor backgroundColor;
76+
QColor penColor;
77+
double penWidth;
78+
LabelPlacementMethod labelPlacementMethod;
79+
DiagramOrientation diagramOrientation;
80+
double barWidth;
81+
int transparency; // 0 - 100
82+
bool scaleByArea;
83+
84+
//scale range (-1 if no lower / upper bound )
85+
double minScaleDenominator;
86+
double maxScaleDenominator;
87+
88+
//! Scale diagrams smaller than mMinimumSize to mMinimumSize
89+
double minimumSize;
90+
91+
void readXML( const QDomElement& elem );
92+
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
93+
};
94+
95+
//additional diagram settings for interpolated size rendering
96+
class QgsDiagramInterpolationSettings
4497
{
4598
%TypeHeaderCode
4699
#include <qgsdiagramrendererv2.h>
47100
%End
48-
enum SizeType
49-
{
50-
MM,
51-
MapUnits
52-
};
53-
54-
QgsDiagramSettings();
55-
QFont font;
56-
QList< QColor > categoryColors;
57-
QList< int > categoryIndices;
58-
QSizeF size; //size
59-
SizeType sizeType; //mm or map units
60-
QColor backgroundColor;
61-
QColor penColor;
62-
double penWidth;
63-
64-
//scale range (-1 if no lower / upper bound )
65-
double minScaleDenominator;
66-
double maxScaleDenominator;
67-
68-
void readXML( const QDomElement& elem );
69-
void writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
101+
public:
102+
QSizeF lowerSize;
103+
QSizeF upperSize;
104+
double lowerValue;
105+
double upperValue;
106+
/**Index of the classification attribute*/
107+
int classificationAttribute;
70108
};
71109

72110
/**Returns diagram settings for a feature*/
@@ -98,10 +136,36 @@ class QgsDiagramRendererV2
98136

99137
virtual void readXML( const QDomElement& elem ) = 0;
100138
virtual void writeXML( QDomElement& layerElem, QDomDocument& doc ) const = 0;
139+
140+
141+
protected:
142+
143+
/**Returns diagram settings for a feature (or false if the diagram for the feature is not to be rendered). Used internally within renderDiagram()
144+
* @param att attribute map
145+
* @param c render context
146+
* @param s out: diagram settings for the feature
147+
*/
148+
virtual bool diagramSettings( const QgsAttributeMap& att, const QgsRenderContext& c, QgsDiagramSettings& s ) = 0;
149+
150+
/**Returns size of the diagram (in painter units) or an invalid size in case of error*/
151+
virtual QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c ) = 0;
152+
153+
/**Converts size from mm to map units*/
154+
void convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const;
155+
156+
/**Returns the paint device dpi (or -1 in case of error*/
157+
static int dpiPaintDevice( const QPainter* );
158+
159+
//read / write diagram
160+
void _readXML( const QDomElement& elem );
161+
void _writeXML( QDomElement& rendererElem, QDomDocument& doc ) const;
162+
163+
/**Reference to the object that does the real diagram rendering*/
164+
QgsDiagram* mDiagram;
101165
};
102166

103167
/**Renders the diagrams for all features with the same settings*/
104-
class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
168+
class QgsSingleCategoryDiagramRenderer : QgsDiagramRendererV2
105169
{
106170
%TypeHeaderCode
107171
#include <qgsdiagramrendererv2.h>
@@ -120,9 +184,14 @@ class QgsSingleCategoryDiagramRenderer: QgsDiagramRendererV2
120184

121185
void readXML( const QDomElement& elem );
122186
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
187+
188+
protected:
189+
bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );
190+
191+
QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
123192
};
124193

125-
class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
194+
class QgsLinearlyInterpolatedDiagramRenderer : QgsDiagramRendererV2
126195
{
127196
%TypeHeaderCode
128197
#include <qgsdiagramrendererv2.h>
@@ -157,4 +226,9 @@ class QgsLinearlyInterpolatedDiagramRenderer: QgsDiagramRendererV2
157226

158227
void readXML( const QDomElement& elem );
159228
void writeXML( QDomElement& layerElem, QDomDocument& doc ) const;
229+
230+
protected:
231+
bool diagramSettings( const QgsAttributeMap&, const QgsRenderContext& c, QgsDiagramSettings& s );
232+
233+
QSizeF diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c );
160234
};

‎python/gui/qgsscalecombobox.sip

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ class QgsScaleComboBox : QComboBox
1212
QgsScaleComboBox(QWidget * parent = 0);
1313
~QgsScaleComboBox();
1414

15+
//! Function to read the selected scale as text
16+
// @note added in 2.0
17+
QString scaleString();
18+
//! Function to set the selected scale from text
19+
// @note added in 2.0
20+
bool setScaleString( QString scaleTxt );
21+
//! Function to read the selected scale as double
22+
// @note added in 2.0
23+
double scale();
24+
//! Function to set the selected scale from double
25+
// @note added in 2.0
26+
void setScale( double scale );
27+
28+
//! Helper function to convert a double to scale string
29+
// Performs rounding, so an exact representation is not to
30+
// be expected.
31+
// @note added in 2.0
32+
static QString toString( double scale );
33+
//! Helper function to convert a scale string to double
34+
// @note added in 2.0
35+
static double toDouble( QString scaleString, bool *ok = NULL );
36+
1537
public slots:
1638
void updateScales( const QStringList &scales = QStringList() );
1739
};

0 commit comments

Comments
 (0)
Please sign in to comment.