130 changes: 97 additions & 33 deletions python/console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def activate(self):
QDockWidget.setFocus(self)

def closeEvent(self, event):
self.console.shell.writeHistoryFile()
self.console.saveSettingsConsole()
QWidget.closeEvent(self, event)

class PythonConsoleWidget(QWidget):
Expand Down Expand Up @@ -109,27 +109,44 @@ def __init__(self, parent=None):
self.splitter.addWidget(self.shellOut)
self.splitter.addWidget(self.shell)
#self.splitterEditor.addWidget(self.tabEditorWidget)

self.widgetEditor = QWidget(self.splitterEditor)

self.splitterObj = QSplitter(self.splitterEditor)
self.splitterObj.setHandleWidth(3)
self.splitterObj.setOrientation(Qt.Horizontal)
#self.splitterObj.setSizes([0, 0])
#self.splitterObj.setStretchFactor(0, 1)

self.widgetEditor = QWidget(self.splitterObj)

self.listClassMethod = QTreeWidget(self.splitterObj)
self.listClassMethod.setColumnCount(2)
self.listClassMethod.setHeaderLabels(['Object', 'Line'])
self.listClassMethod.setColumnHidden(1, True)
self.listClassMethod.setAlternatingRowColors(True)


#self.splitterEditor.addWidget(self.widgetEditor)
#self.splitterObj.addWidget(self.listClassMethod)
#self.splitterObj.addWidget(self.widgetEditor)

# Hide side editor on start up
self.widgetEditor.hide()

# List for tab script
self.settings = QSettings()
storedTabScripts = self.settings.value("pythonConsole/tabScripts")
self.tabListScript = storedTabScripts.toList()
self.listClassMethod.hide()

sizes = self.splitter.sizes()
self.splitter.setSizes(sizes)

##----------------Restore Settings------------------------------------

self.restoreSettingsConsole()

##------------------Toolbar Editor-------------------------------------

## Action for Open File
openFileBt = QCoreApplication.translate("PythonConsole", "Open file")
self.openFileButton = QAction(parent)
self.openFileButton.setCheckable(False)
self.openFileButton.setEnabled(False)
self.openFileButton.setEnabled(True)
self.openFileButton.setIcon(QgsApplication.getThemeIcon("console/iconOpenConsole.png"))
self.openFileButton.setMenuRole(QAction.PreferencesRole)
self.openFileButton.setIconVisibleInMenu(True)
Expand All @@ -139,7 +156,7 @@ def __init__(self, parent=None):
saveFileBt = QCoreApplication.translate("PythonConsole", "Save")
self.saveFileButton = QAction(parent)
self.saveFileButton.setCheckable(False)
self.saveFileButton.setEnabled(False)
self.saveFileButton.setEnabled(True)
self.saveFileButton.setIcon(QgsApplication.getThemeIcon("console/iconSaveConsole.png"))
self.saveFileButton.setMenuRole(QAction.PreferencesRole)
self.saveFileButton.setIconVisibleInMenu(True)
Expand All @@ -149,7 +166,7 @@ def __init__(self, parent=None):
saveAsFileBt = QCoreApplication.translate("PythonConsole", "Save As..")
self.saveAsFileButton = QAction(parent)
self.saveAsFileButton.setCheckable(False)
self.saveAsFileButton.setEnabled(False)
self.saveAsFileButton.setEnabled(True)
self.saveAsFileButton.setIcon(QgsApplication.getThemeIcon("console/iconSaveAsConsole.png"))
self.saveAsFileButton.setMenuRole(QAction.PreferencesRole)
self.saveAsFileButton.setIconVisibleInMenu(True)
Expand Down Expand Up @@ -215,13 +232,22 @@ def __init__(self, parent=None):
self.uncommentEditorButton.setIconVisibleInMenu(True)
self.uncommentEditorButton.setToolTip(uncommentEditorBt)
self.uncommentEditorButton.setText(uncommentEditorBt)
## Action for Object browser
objList = QCoreApplication.translate("PythonConsole", "Object browser")
self.objectListButton = QAction(parent)
self.objectListButton.setCheckable(True)
self.objectListButton.setEnabled(True)
self.objectListButton.setIcon(QgsApplication.getThemeIcon("console/iconClassBrowserConsole.png"))
self.objectListButton.setMenuRole(QAction.PreferencesRole)
self.objectListButton.setIconVisibleInMenu(True)
self.objectListButton.setToolTip(objList)
self.objectListButton.setText(objList)

##----------------Toolbar Console-------------------------------------

## Action Show Editor
showEditor = QCoreApplication.translate("PythonConsole", "Show editor")
self.showEditorButton = QAction(parent)
self.showEditorButton.setCheckable(False)
self.showEditorButton.setEnabled(True)
self.showEditorButton.setCheckable(True)
self.showEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconShowEditorConsole.png"))
Expand Down Expand Up @@ -328,10 +354,17 @@ def __init__(self, parent=None):
self.toolBar.addAction(self.optionsButton)
self.toolBar.addAction(self.helpButton)

if sys.platform.startswith('win'):
bkgrcolor = ['170', '170', '170']
bordercl = ['125', '125', '125']
else:
bkgrcolor = ['200', '200', '200']
bordercl = ['155', '155', '155']

self.toolBarEditor = QToolBar()
self.toolBarEditor.setStyleSheet('QToolBar{background-color: rgb(200, 200, 200);\
border-right: 1px solid rgb(155, 155, 155);}')
self.toolBarEditor.setEnabled(True)
self.toolBarEditor.setStyleSheet('QToolBar{background-color: rgb(%s, %s, %s' % tuple(bkgrcolor) + ');\
border-right: 1px solid rgb(%s, %s, %s' % tuple(bordercl) + ');}')
self.toolBarEditor.setEnabled(False)
self.toolBarEditor.setFocusPolicy(Qt.NoFocus)
self.toolBarEditor.setContextMenuPolicy(Qt.DefaultContextMenu)
self.toolBarEditor.setLayoutDirection(Qt.LeftToRight)
Expand All @@ -351,6 +384,8 @@ def __init__(self, parent=None):
self.toolBarEditor.addAction(self.commentEditorButton)
self.toolBarEditor.addAction(self.uncommentEditorButton)
self.toolBarEditor.addSeparator()
self.toolBarEditor.addAction(self.objectListButton)
self.toolBarEditor.addSeparator()
self.toolBarEditor.addAction(self.runScriptEditorButton)

## Menu Import Class
Expand All @@ -369,7 +404,7 @@ def __init__(self, parent=None):
sizePolicy.setHeightForWidth(self.widgetButton.sizePolicy().hasHeightForWidth())
self.widgetButton.setSizePolicy(sizePolicy)

self.widgetButtonEditor = QWidget(self.splitterEditor)
self.widgetButtonEditor = QWidget(self.widgetEditor)
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand Down Expand Up @@ -414,6 +449,7 @@ def __init__(self, parent=None):

##------------ Signal -------------------------------

self.objectListButton.toggled.connect(self.toggleObjectListWidget)
self.commentEditorButton.triggered.connect(self.commentCode)
self.uncommentEditorButton.triggered.connect(self.uncommentCode)
self.runScriptEditorButton.triggered.connect(self.runScriptEditor)
Expand All @@ -431,8 +467,15 @@ def __init__(self, parent=None):
self.saveFileButton.triggered.connect(self.saveScriptFile)
self.saveAsFileButton.triggered.connect(self.saveAsScriptFile)
self.helpButton.triggered.connect(self.openHelp)
QObject.connect(self.options.buttonBox, SIGNAL("accepted()"),
self.prefChanged)
self.connect(self.options.buttonBox, SIGNAL("accepted()"),
self.prefChanged)
self.connect(self.listClassMethod, SIGNAL('itemClicked(QTreeWidgetItem*, int)'),
self.onClickGoToLine)

def onClickGoToLine(self, item, column):
linenr = int(item.text(1))
objName = item.text(0)
self.tabEditorWidget.currentWidget().newEditor.goToLine(objName, linenr)

def sextante(self):
self.shell.commandConsole('sextante')
Expand All @@ -445,9 +488,10 @@ def qtGui(self):

def toggleEditor(self, checked):
self.widgetEditor.show() if checked else self.widgetEditor.hide()
self.openFileButton.setEnabled(checked)
self.saveFileButton.setEnabled(checked)
self.saveAsFileButton.setEnabled(checked)
self.tabEditorWidget.enableToolBarEditor(checked)

def toggleObjectListWidget(self, checked):
self.listClassMethod.show() if checked else self.listClassMethod.hide()

def pasteEditor(self):
self.tabEditorWidget.currentWidget().newEditor.paste()
Expand Down Expand Up @@ -542,9 +586,10 @@ def saveAsScriptFile(self):
return
filename = QFileDialog.getSaveFileName(self,
"Save File As",
"*.py", "Script file (*.py)")
tabWidget.path, "Script file (*.py)")
if not filename.isEmpty():
self.tabListScript.remove(tabWidget.path)
#print tabWidget.path
self.tabListScript.remove(unicode(tabWidget.path))
tabWidget.path = filename
self.saveScriptFile()

Expand All @@ -558,7 +603,7 @@ def openSettings(self):
def prefChanged(self):
self.shell.refreshLexerProperties()
self.shellOut.refreshLexerProperties()
self.tabEditorWidget.currentWidget().changeFont()
self.tabEditorWidget.changeFont()

def callWidgetMessageBar(self, text):
self.shellOut.widgetMessageBar(iface, text)
Expand All @@ -567,15 +612,34 @@ def callWidgetMessageBarEditor(self, text):
self.tabEditorWidget.widgetMessageBar(iface, text)

def updateTabListScript(self, script, action=None):
if script == 'empty':
self.tabListScript = []
if script is not None and not action and script != 'empty':
self.tabListScript.remove(script)
if action:
if script not in self.tabListScript:
self.tabListScript.append(script)
self.settings.setValue("pythonConsole/tabScripts",
QVariant(self.tabListScript))
if script != '':
settings = QSettings()
if script == 'empty':
self.tabListScript = []
if script is not None and not action and script != 'empty':
self.tabListScript.remove(script)
if action:
if script not in self.tabListScript:
self.tabListScript.append(script)
settings.setValue("pythonConsole/tabScripts",
QVariant(self.tabListScript))

def saveSettingsConsole(self):
settings = QSettings()
#settings.setValue("pythonConsole/geometry", self.saveGeometry())
settings.setValue("pythonConsole/splitterObj", self.splitterObj.saveState())
settings.setValue("pythonConsole/splitterEditor", self.splitterEditor.saveState())

self.shell.writeHistoryFile()

def restoreSettingsConsole(self):
# List for tab script
settings = QSettings()
storedTabScripts = settings.value("pythonConsole/tabScripts")
self.tabListScript = storedTabScripts.toList()
#self.restoreGeometry(settings.value("pythonConsole/geometry").toByteArray())
self.splitterEditor.restoreState(settings.value("pythonConsole/splitterEditor").toByteArray())
self.splitterObj.restoreState(settings.value("pythonConsole/splitterObj").toByteArray())

if __name__ == '__main__':
a = QApplication(sys.argv)
Expand Down
170 changes: 144 additions & 26 deletions python/console/console_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import os
import subprocess
import datetime
import pyclbr
from operator import itemgetter
import traceback

class KeyFilter(QObject):
SHORTCUTS = {
Expand All @@ -56,9 +59,10 @@ def __init__(self, window, tab, *args):
self._handlers[qt_keycode] = handlers

def get_handler(self, key, modifier):
for modifiers, handler in self._handlers.get(key, []):
if modifiers == modifier:
return handler
if self.window.count() > 1:
for modifiers, handler in self._handlers.get(key, []):
if modifiers == modifier:
return handler
return None

def eventFilter(self, obj, event):
Expand All @@ -69,7 +73,6 @@ def eventFilter(self, obj, event):
return QObject.eventFilter(self, obj, event)

class Editor(QsciScintilla):
#ARROW_MARKER_NUM = 4
def __init__(self, parent=None):
super(Editor,self).__init__(parent)
self.parent = parent
Expand Down Expand Up @@ -109,6 +112,7 @@ def __init__(self, parent=None):
# self.ARROW_MARKER_NUM)

self.setMinimumHeight(120)
#self.setMinimumWidth(300)

self.setAutoCompletionThreshold(2)
self.setAutoCompletionSource(self.AcsAPIs)
Expand All @@ -123,9 +127,9 @@ def __init__(self, parent=None):
self.setEdgeColumn(80)
self.setEdgeColor(QColor("#FF0000"))

self.setWrapMode(QsciScintilla.WrapCharacter)
#self.setWrapMode(QsciScintilla.WrapCharacter)
self.setWhitespaceVisibility(QsciScintilla.WsVisibleAfterIndent)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
#self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

# Annotations
#self.setAnnotationDisplay(QsciScintilla.ANNOTATION_BOXED)
Expand Down Expand Up @@ -272,6 +276,9 @@ def contextMenuEvent(self, e):
"Share on codepad",
self.codepad)
menu.addSeparator()
showCodeInspection = menu.addAction("Hide/Show Object list",
self.objectListEditor)
menu.addSeparator()
selectAllAction = menu.addAction("Select All",
self.selectAll,
QKeySequence.SelectAll)
Expand Down Expand Up @@ -301,6 +308,15 @@ def contextMenuEvent(self, e):
pasteAction.setEnabled(True)
action = menu.exec_(self.mapToGlobal(e.pos()))

def objectListEditor(self):
listObj = self.parent.pc.listClassMethod
if listObj.isVisible():
listObj.hide()
self.parent.pc.objectListButton.setChecked(False)
else:
listObj.show()
self.parent.pc.objectListButton.setChecked(True)

def codepad(self):
import urllib2, urllib
listText = self.selectedText().split('\n')
Expand Down Expand Up @@ -336,13 +352,15 @@ def codepad(self):
self.parent.pc.callWidgetMessageBarEditor(msgText + str(e.args))

def hideEditor(self):
Ed = self.parent.pc.widgetEditor
Ed.hide()
self.parent.pc.widgetEditor.hide()
self.parent.pc.listClassMethod.hide()
self.parent.pc.showEditorButton.setChecked(False)

def commentEditorCode(self, commentCheck):
self.beginUndoAction()
if self.hasSelectedText():
startLine, _, endLine, _ = self.getSelection()
self.beginUndoAction()
for line in range(startLine, endLine + 1):
selCmd = self.text(line)
self.setSelection(line, 0, line, selCmd.length())
Expand All @@ -355,9 +373,9 @@ def commentEditorCode(self, commentCheck):
self.insert(selCmd[1:])
else:
self.insert(selCmd)
self.setCursorPosition(endLine, selCmd.length() - 2)
else:
line, pos = self.getCursorPosition()
self.beginUndoAction()
selCmd = self.text(line)
self.setSelection(line, 0, line, selCmd.length())
self.removeSelectedText()
Expand All @@ -369,7 +387,7 @@ def commentEditorCode(self, commentCheck):
self.insert(selCmd[1:])
else:
self.insert(selCmd)
self.setCursorPosition(line, selCmd.length() - 2)
self.endUndoAction()

def runScriptCode(self):
tabWidget = self.parent.mw.currentWidget()
Expand Down Expand Up @@ -432,6 +450,17 @@ def getTextFromEditor(self):
text = self.text()
textList = text.split("\n")
return textList

def goToLine(self, objName, linenr):
self.SendScintilla(QsciScintilla.SCI_GOTOLINE, linenr-1)
self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART, self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS))
self.SendScintilla(QsciScintilla.SCI_SETTARGETEND, len(self.text()))
pos = self.SendScintilla(QsciScintilla.SCI_SEARCHINTARGET, len(objName), objName)
index = pos - self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
#line, _ = self.getCursorPosition()
self.setSelection(linenr - 1, index, linenr - 1, index + len(objName))
self.ensureLineVisible(linenr)
self.setFocus()

class EditorTab(QWidget):
def __init__(self, parent, parentConsole, filename, *args):
Expand All @@ -445,12 +474,13 @@ def __init__(self, parent, parentConsole, filename, *args):

self.newEditor = Editor(self)
self.newEditor.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.newEditor.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.newEditor.modificationChanged.connect(self.modified)
if filename:
self.newEditor.setText(open(filename, "r").read())
self.newEditor.setText(open(unicode(filename), "rt").read())
self.newEditor.setModified(False)
self.path = filename

# Creates layout for message bar
self.layout = QGridLayout(self.newEditor)
self.layout.setContentsMargins(0, 0, 0, 0)
Expand Down Expand Up @@ -483,24 +513,24 @@ def save(self):
'Script was correctly saved.')
self.pc.callWidgetMessageBarEditor(msgText)
# Rename the original file, if it exists
overwrite = os.path.exists(self.path)
path = unicode(self.path)
overwrite = os.path.exists(path)
if overwrite:
temp_path = self.path + "~"
temp_path = path + "~"
if os.path.exists(temp_path):
os.remove(temp_path)
os.rename(self.path, temp_path)
os.rename(path, temp_path)
# Save the new contents
with open(self.path, "w") as f:
with open(path, "w") as f:
f.write(self.newEditor.text())
if overwrite:
os.remove(temp_path)
fN = self.path.split('/')[-1]
fN = path.split('/')[-1]
self.mw.setTabTitle(self, fN)
self.mw.setTabToolTip(self.mw.currentIndex(), path)
self.newEditor.setModified(False)
self.pc.updateTabListScript(self.path, action='append')

def changeFont(self):
self.newEditor.refreshLexerProperties()
self.pc.updateTabListScript(path, action='append')
self.mw.listObject(self)

def modified(self, modified):
self.mw.tabModified(self, modified)
Expand Down Expand Up @@ -570,9 +600,11 @@ def __init__(self, parent):
self.settings = QSettings()
tabScripts = self.settings.value("pythonConsole/tabScripts")
self.restoreTabList = tabScripts.toList()
self.newTabEditor(filename=None)

if self.restoreTabList:
self.topFrame.show()
else:
self.newTabEditor(filename=None)

self.setDocumentMode(True)
self.setMovable(True)
Expand All @@ -593,6 +625,8 @@ def __init__(self, parent):
self.fileTabButton.setMenu(self.fileTabMenu)
self.setCornerWidget(self.fileTabButton, Qt.TopRightCorner)
self.connect(self, SIGNAL("tabCloseRequested(int)"), self._removeTab)
self.connect(self, SIGNAL('currentChanged(int)'), self.listObject)
self.connect(self, SIGNAL('currentChanged(int)'), self.changeLastDirPath)

# Open button
self.newTabButton = QToolButton(self)
Expand All @@ -602,6 +636,11 @@ def __init__(self, parent):
self.setCornerWidget(self.newTabButton, Qt.TopLeftCorner)
self.connect(self.newTabButton, SIGNAL('clicked()'), self.newTabEditor)

def enableToolBarEditor(self, enable):
if self.topFrame.isVisible():
enable = False
self.parent.toolBarEditor.setEnabled(enable)

def newTabEditor(self, tabName=None, filename=None):
nr = self.count()
if not tabName:
Expand All @@ -615,6 +654,10 @@ def newTabEditor(self, tabName=None, filename=None):
self.iconTab = QgsApplication.getThemeIcon('console/iconTabEditorConsole.png')
self.addTab(self.tab, self.iconTab, tabName)
self.setCurrentWidget(self.tab)
if filename:
self.setTabToolTip(self.currentIndex(), unicode(filename))
else:
self.setTabToolTip(self.currentIndex(), tabName)

def tabModified(self, tab, modified):
index = self.indexOf(tab)
Expand Down Expand Up @@ -680,15 +723,20 @@ def closeCurrentWidget(self):

def restoreTabs(self):
for script in self.restoreTabList:
pathFile = str(script.toString())
if os.path.exists(pathFile):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
pathFile = unicode(script.toString())
if os.path.exists(pathFile):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
else:
self.newTabEditor(filename=None)
self.topFrame.close()
self.enableToolBarEditor(True)

def closeRestore(self):
self.parent.updateTabListScript('empty')
self.topFrame.close()
self.newTabEditor(filename=None)
self.enableToolBarEditor(True)

def showFileTabMenu(self):
self.fileTabMenu.clear()
Expand All @@ -701,6 +749,76 @@ def showFileTabMenuTriggered(self, action):
if ok:
self.setCurrentIndex(index)

def listObject(self, tab):
self.parent.listClassMethod.clear()
if isinstance(tab, EditorTab):
tabWidget = self.widget(self.indexOf(tab))
else:
tabWidget = self.widget(tab)
if tabWidget.path:
pathFile, file = os.path.split(unicode(tabWidget.path))
module, ext = os.path.splitext(file)
if pathFile not in sys.path:
sys.path.append(pathFile)
try:
reload(pyclbr)
dictObject = {}
superClassName = []
readModule = pyclbr.readmodule(module)
readModuleFunction = pyclbr.readmodule_ex(module)
for name, class_data in sorted(readModule.items(), key=lambda x:x[1].lineno):
if class_data.file == tabWidget.path:
for superClass in class_data.super:
if superClass == 'object':
continue
if isinstance(superClass, basestring):
superClassName.append(superClass)
else:
superClassName.append(superClass.name)
classItem = QTreeWidgetItem()
if superClassName:
for i in superClassName: super = i
classItem.setText(0, name + ' [' + super + ']')
classItem.setToolTip(0, name + ' [' + super + ']')
else:
classItem.setText(0, name)
classItem.setToolTip(0, name)
classItem.setText(1, str(class_data.lineno))
classItem.setIcon(0, QgsApplication.getThemeIcon("console/iconClassTreeWidgetConsole.png"))
dictObject[name] = class_data.lineno
for meth, lineno in sorted(class_data.methods.items(), key=itemgetter(1)):
methodItem = QTreeWidgetItem()
methodItem.setText(0, meth)
methodItem.setText(1, str(lineno))
methodItem.setToolTip(0, meth)
methodItem.setIcon(0, QgsApplication.getThemeIcon("console/iconMethodTreeWidgetConsole.png"))
classItem.addChild(methodItem)
dictObject[meth] = lineno
self.parent.listClassMethod.addTopLevelItem(classItem)
for func_name, data in sorted(readModuleFunction.items(), key=lambda x:x[1].lineno):
if isinstance(data, pyclbr.Function) and data.file == tabWidget.path:
funcItem = QTreeWidgetItem()
funcItem.setText(0, func_name)
funcItem.setText(1, str(data.lineno))
funcItem.setToolTip(0, func_name)
funcItem.setIcon(0, QgsApplication.getThemeIcon("console/iconFunctionTreeWidgetConsole.png"))
dictObject[func_name] = data.lineno
self.parent.listClassMethod.addTopLevelItem(funcItem)
except:
s = traceback.format_exc()
print '## Error: '
sys.stderr.write(s)

def changeFont(self):
countTab = self.count()
for i in range(countTab):
self.widget(i).newEditor.refreshLexerProperties()

def changeLastDirPath(self, tab):
tabWidget = self.widget(tab)
settings = QSettings()
settings.setValue("pythonConsole/lastDirPath", QVariant(tabWidget.path))

def widgetMessageBar(self, iface, text):
timeout = iface.messageTimeout()
currWidget = self.currentWidget()
Expand Down
14 changes: 14 additions & 0 deletions python/core/composer/qgscomposeritem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ class QgsComposerItem: QObject, QGraphicsRectItem
@note this method was added in version 2.0
@note there is not setter since one can't manually set the id*/
QString uuid() const;

/* Returns the current blending mode for the composer item
@note added in version 1.9*/
const QPainter::CompositionMode blendMode() const;
/* Sets the composer item's blending mode
@note added in version 1.9*/
void setBlendMode( const QPainter::CompositionMode blendMode );

/** Returns the composer item's transparency
@note added in version 1.9*/
const int transparency() const;
/** Sets the composer item's transparency
@note added in version 1.9*/
void setTransparency( const int transparency );

public slots:
virtual void setRotation( double r );
Expand Down
1 change: 0 additions & 1 deletion python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
%Include gps/qgsqtlocationconnection.sip

%Include raster/qgscliptominmaxenhancement.sip
%Include raster/qgsfreakoutshader.sip
%Include raster/qgscolorrampshader.sip
%Include raster/qgscontrastenhancement.sip
%Include raster/qgscontrastenhancementfunction.sip
Expand Down
8 changes: 7 additions & 1 deletion python/core/qgsfield.sip
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ public:
void remove( int fieldIdx );

bool isEmpty() const;
int count() const /__len__/;
// __len__ annotation since sip 4.10.3
//int count() const /__len__/;
int count() const;
int __len__() const;
%MethodCode
sipRes = sipCpp->count();
%End
int size() const;
//const QgsField& operator[](int i) const;
//QgsField& operator[](int i);
Expand Down
7 changes: 7 additions & 0 deletions python/core/qgsmaplayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ class QgsMapLayer : QObject
* @note This method was added in QGIS 1.4 **/
void setCacheImage( QImage * thepImage /Transfer/ );

/* Returns the current blending mode for a layer
@note added in version 1.9*/
const QPainter::CompositionMode blendMode() const;
/* Sets the blending mode for a layer
@note added in version 1.9*/
void setBlendMode( const QPainter::CompositionMode blendMode );

public slots:

/** Event handler for when a coordinate transform fails due to bad vertex error */
Expand Down
220 changes: 140 additions & 80 deletions python/core/qgsmaplayerregistry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -28,104 +28,164 @@ class QgsMapLayerRegistry : QObject
//! Retrieve the mapLayers collection (mainly intended for use by projection)
QMap<QString, QgsMapLayer*> & mapLayers();

/** Add a list of layers to the map of loaded layers
@returns QList<QgsMapLayer *> - a list of the map layers that were added
successfully. If a layer is invalid, or already exists in the registry,
it will not be part of the returned QList.
@note added in QGIS 1.8

As a side-effect QgsProject is made dirty.

If theEmitSignal is true (by default), a layersAdded( QList<QgsMapLayer *>)
signal will be emitted indicating that a batch of layers were added.
Not emitting signal is useful when you want to use registry for layers
on a different canvas and don't want them added to the main canvas automatically.
*/
QList<QgsMapLayer *> addMapLayers( QList<QgsMapLayer *> theMapLayers /Transfer/,
bool theEmitSignal = true );

/** Add a layer to the map of loaded layers
@returns NULL if unable to add layer, otherwise pointer to newly added layer
@see addMapLayers
@note Use addMapLayers if adding more than one layer at a time
*/
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true );

/** Remove a set of layers from qgis
@note As a side-effect QgsProject is made dirty.
Any canvases using the affected layers will need to remove them

If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
signal will be emitted indicating to any listeners that the layers are being removed.

The layer being removed is deleted as well as the registry
table entry.
*/
void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );

/** Remove a layer from qgis
@note As a side-effect QgsProject is made dirty.
Any canvases using the affected layers will need to remove them

If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
signal will be emitted indicating to any listeners that the layers are being removed.

The layer being removed is deleted as well as the registry
table entry.
*/
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );

/** Remove all registered layers
@note raises removedAll()
As a side-effect QgsProject is made dirty.
@note The layers are deleted as the registry is cleared!
*/
/**
* @brief
* Add a list of layers to the map of loaded layers
*
* The layersAdded() and layersWasAdded() signals will be emitted in any case.
* The legendLayersAdded() signal only if addToLegend is true.
*
* @param theMapLayers A list of layer which should be added to the registry
* @param addToLegend If true (by default), the layers will be added to the
* legend and to the main canvas. If you have a private
* layer, you can set this parameter to false to hide it.
*
* @return QList<QgsMapLayer *> - a list of the map layers that were added
* successfully. If a layer is invalid, or already exists in the registry,
* it will not be part of the returned QList.
*
* @note As a side-effect QgsProject is made dirty.
* @note Added in QGIS 1.8
*/
QList<QgsMapLayer *> addMapLayers(QList<QgsMapLayer *> theMapLayers /Transfer/,
bool addToLegend = true );

/**
* @brief
* Add a layer to the map of loaded layers
*
* The layersAdded() and layersWasAdded() signals will be emitted in any case.
* The legendLayersAdded() signal only if addToLegend is true.
* If you are adding multiple layers at once, you should use
* {@link addMapLayers()} instead.
*
* @param theMapLayer A layer to add to the registry
* @param addToLegend If true (by default), the layer will be added to the
* legend and to the main canvas. If you have a private
* you can set this parameter to false to hide it.
*
* @return NULL if unable to add layer, otherwise pointer to newly added layer
*
* @see addMapLayers
*
* @note As a side-effect QgsProject is made dirty.
* @note Use addMapLayers if adding more than one layer at a time
*/
QgsMapLayer* addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool addToLegend = true );

/**
* @brief
* Remove a set of layers from the registry
*
* Any canvases using the affected layers will need to remove them
*
* The layers being removed are deleted as well as the registry
* table entries.
*
* @param theLayerIds The ids of the layers to remove
*
* @note As a side-effect QgsProject is made dirty.
*/
void removeMapLayers(QStringList theLayerIds );

/**
* @brief
* Remove a layer from qgis
*
* Any canvases using the affected layers will need to remove them
*
* The layer being removed is deleted as well as the registry
* table entry.
*
* @param theLayerId The id of the layer to remove
*
* @note As a side-effect QgsProject is made dirty.
*/
void removeMapLayer( const QString& theLayerId );

/**
* Remove all registered layers
*
* @note As a side-effect QgsProject is made dirty.
* @note The layers are deleted as the registry is cleared!
*/
void removeAllMapLayers();

/* Clears all layer caches, resetting them to zero and
/**
* Clears all layer caches, resetting them to zero and
* freeing up any memory they may have been using. Layer
* caches are used to speed up rendering in certain situations
* see ticket #1974 for more details.
* @note this method was added in QGIS 1.4
*
* @note Added in QGIS 1.4
*/
void clearAllLayerCaches();

/**Reload all provider data caches (currently used for WFS and WMS providers)
@note: this method was added in QGIS 1.6*/
/**
* Reload all provider data caches (currently used for WFS and WMS providers)
*
* @note Added in QGIS 1.6
*/
void reloadAllLayers();

signals:
/** Emitted when one or more layers are removed from the registry
@note intended to replace layerWillBeRemoved in QGIS 1.8
*/
/**
* Emitted when one or more layers are removed from the registry
*
* @param theLayerIds A list of ids of the layers which are removed.
*/
void layersWillBeRemoved( QStringList theLayerIds );

/** emitted when a layer is removed from the registry
connected to main map canvas and overview map canvas remove()
@note we should deprecate this at some stage
*/
/**
* Emitted when a layer is removed from the registry
*
* @param theLayerId The id of the layer being removed
*
* @note Consider using {@link layersWillBeRemoved()} instead
*/
void layerWillBeRemoved( QString theLayerId );

/** Emitted when one or more layers are added to the registry
@note intended to replace layerWasAdded in QGIS 1.8
*/
/**
* Emitted, when all layers are removed, before {@link layersWillBeRemoved()} and
* {@link layerWillBeRemoved()} signals are emitted. You will still get these signals
* in any case.
* You can use this signal to do easy (and fast) cleanup.
*
* @note Added in 2.0
*/
void removeAll();

/**
* Emitted when one or more layers are added to the registry.
* This signal is also emitted for layers added to the registry,
* but not to the legend and canvas.
*
* @param theMapLayers The layers which have been added
*
* @see legendLayersAdded()
*/
void layersAdded( QList<QgsMapLayer *> theMapLayers );

/** emitted when a layer is added to the registry
connected to main map canvas and overview map canvas addLayer()
@note we should deprecate this at some stage
*/
void layerWasAdded( QgsMapLayer * theMapLayer );

/** emitted when ALL layers are removed at once
This could have been implemented by iteratively signalling
layerWillBeRemoved() for each layer as it is removed. However, this
generally causes a cascade of effects that are unnecessary if we're
ultimately removing all layers. E.g., removing the legend item
corresponding to the layer. Why bother doing that when you're just going
to clear everything anyway?
/**
* Emitted when a layer is added to the registry.
*
* @param theMapLayer The id of the layer which has been added
*
* @note Consider using {@link layersAdded()} instead
*/
void layerWasAdded( QgsMapLayer* theMapLayer );

/**
* Emitted, when a layer is added to the registry and the legend.
* Plugins are allowed to have private layers, which are signalled by
* {@link layersAdded()} and {@link layerWasAdded()} but will not be
* advertised by this signal.
*
* @param theMapLayers The {@link QgsMapLayer}s which are added to the legend.
*
* @note Added in 2.0
*/
void removedAll();
void legendLayersAdded( QList<QgsMapLayer*> theMapLayers );

protected:
//! protected constructor
Expand Down
16 changes: 16 additions & 0 deletions python/core/qgspallabeling.sip
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ class QgsPalLayerSettings
*/
int sizeToPixel( double size, const QgsRenderContext& c , SizeUnit unit, bool rasterfactor = false ) const;

/** Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
* @param size size to convert
* @param c rendercontext
* @param unit SizeUnit enum value of size
* @param rasterfactor whether to consider oversampling
* @return size that will render, as double
* @note added in 1.9, as a better precision replacement for sizeToPixel
*/
double scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false ) const;

/** List of data defined enum names
* @note adding in 1.9
*/
Expand Down Expand Up @@ -297,6 +307,9 @@ class QgsLabelComponent
double rotation() const;
void setRotation( double rotation );

double rotationOffset() const;
void setRotationOffset( double rotation );

bool useRotation() const;
void setUseRotation( bool use );

Expand All @@ -317,6 +330,9 @@ class QgsLabelComponent

double pictureBuffer() const;
void setPictureBuffer( double buffer );

double dpiRatio() const;
void setDpiRatio( double ratio );
};

class QgsPalLabeling : QgsLabelingEngineInterface
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsvectordataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class QgsVectorDataProvider : QgsDataProvider
RandomSelectGeometryAtId = 1024,
SequentialSelectGeometryAtId = 2048,
CreateAttributeIndex = 4096,
SetEncoding = 8192,
SelectEncoding = 8192,
};

/** bitmask of all provider's editing capabilities */
Expand Down
30 changes: 0 additions & 30 deletions python/core/raster/qgsfreakoutshader.sip

This file was deleted.

166 changes: 2 additions & 164 deletions python/core/raster/qgsrasterlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,6 @@ class QgsRasterLayer : QgsMapLayer
ContrastEnhancementCumulativeCut
};

/** \brief A list containing on ContrastEnhancement object per raster band in this raster layer */
typedef QList<QgsContrastEnhancement> ContrastEnhancementList;

/** \brief A list containing one RasterPyramid struct per raster band in this raster layer.
* POTENTIAL pyramid layer. This works by dividing the height
* and width of the raster by an incrementing number. As soon as the result
* of the division is <=256 we stop allowing RasterPyramid structs
* to be added to the list. Each time a RasterPyramid is created
* we will check to see if a pyramid matching these dimensions already exists
* in the raster layer, and if so mark the exists flag as true */
/* typedef QList<QgsRasterPyramid> RasterPyramidList; */

/** \brief A list containing one RasterBandStats struct per raster band in this raster layer.
* Note that while every RasterBandStats element will have the name and number of its associated
* band populated, any additional stats are calculated on a need to know basis.*/
/* typedef QList<QgsRasterBandStats> RasterStatsList; */

//
// Static methods:
//
Expand All @@ -128,69 +111,30 @@ class QgsRasterLayer : QgsMapLayer
*/
static bool isValidRasterFileName( const QString & theFileNameQString, QString &retError );
static bool isValidRasterFileName( const QString & theFileNameQString );
//static QStringList subLayers( GDALDatasetH dataset );

/** Return time stamp for given file name */
static QDateTime lastModified( const QString & name );

// Keep this for now, it is used by Python interface!!!
/** \brief ensures that GDAL drivers are registered, but only once */
static void registerGdalDrivers();

//
// Non Static inline methods
//

/** \brief Initialize default values */
void init();

/** [ data provider interface ] Set the data provider */
void setDataProvider( const QString & provider );

/** \brief Accessor for blue band name mapping */
QString blueBandName() const;

/** \brief Accessor for color shader algorithm */
QgsRasterLayer::ColorShadingAlgorithm colorShadingAlgorithm() const;

/** \brief Accessor for contrast enhancement algorithm */
QgsContrastEnhancement::ContrastEnhancementAlgorithm contrastEnhancementAlgorithm();

/** \brief Returns contrast enhancement algorithm as a string */
QString contrastEnhancementAlgorithmAsString() const;

/** \brief Accessor for drawing style */
DrawingStyle drawingStyle();

/** \brief Accessor for mHasPyramids (READ ONLY) */
/* bool hasPyramids(); */

/** \brief Accessor for mUserDefinedGrayMinimumMaximum */
bool hasUserDefinedGrayMinimumMaximum() const;

/** \brief Accessor for mUserDefinedRGBMinimumMaximum */
bool hasUserDefinedRGBMinimumMaximum() const;
/** \brief Accessor that returns the width of the (unclipped) raster */
int width();

/** \brief Accessor that returns the height of the (unclipped) raster */
int height();

/** \brief Accessor for raster layer type (which is a read only property) */
LayerType rasterType();


/** \brief Mutator for drawing style */
void setDrawingStyle( const DrawingStyle & theDrawingStyle );
/**Sets corresponding renderer for style*/
void setRendererForDrawingStyle( const DrawingStyle & theDrawingStyle );

/** \brief Mutator to alter the number of standard deviations that should be plotted */
void setStandardDeviations( double theStandardDeviations );

/** \brief Mutator for mUserDefinedGrayMinimumMaximum */
void setUserDefinedGrayMinimumMaximum( bool theBool );

/** \brief Mutator for mUserDefinedRGBMinimumMaximum */
void setUserDefinedRGBMinimumMaximum( bool theBool );

/**Set raster renderer. Takes ownership of the renderer object*/
void setRenderer( QgsRasterRenderer* theRenderer /Transfer/ );
Expand All @@ -203,12 +147,6 @@ class QgsRasterLayer : QgsMapLayer
/** Get raster pipe */
QgsRasterPipe * pipe();

/** \brief Accessor to find out how many standard deviations are being plotted */
double standardDeviations() const;

/** \brief Accessor that returns the width of the (unclipped) raster */
int width();

//
// Non Static methods
//
Expand All @@ -218,33 +156,6 @@ class QgsRasterLayer : QgsMapLayer
/** \brief Get the name of a band given its number */
const QString bandName( int theBandNoInt );

/** \brief Get the number of a band given its name. The name is the rewritten name set
* up in the constructor, and will not necessarily be the same as the name retrieved directly from gdal!
* If no matching band is found zero will be returned! */
int bandNumber( const QString & theBandName ) const;

/** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
* POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
* ACTUALLY exists you need to look at the existsFlag member in each struct stored in the
* list.
*/
// RasterPyramidList buildPyramidList();

/** \brief Accessor for color shader algorithm */
QString colorShadingAlgorithmAsString() const;

/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent
\note added in v1.6 */
//void computeMinimumMaximumFromLastExtent( int theBand, double& theMin /Out/, double& theMax /Out/ );

/** \brief Get a pointer to the contrast enhancement for the selected band */
QgsContrastEnhancement* contrastEnhancement( unsigned int theBand );

const QgsContrastEnhancement* constContrastEnhancement( unsigned int theBand ) const;

/** \brief Get a pointer to the color table */
QList<QgsColorRampShader::ColorRampItem> colorTable( int theBandNoInt );

/** Returns the data provider */
QgsRasterDataProvider* dataProvider();

Expand All @@ -266,33 +177,6 @@ class QgsRasterLayer : QgsMapLayer
QgsRasterViewPort * myRasterViewPort,
const QgsMapToPixel* theQgsMapToPixel = 0 );

/** \brief Returns a string representation of drawing style
*
* Implemented mainly for serialisation / deserialisation of settings to xml.
* NOTE: May be deprecated in the future!. DrawingStyle drawingStyle() instead.
* */
QString drawingStyleAsString() const;

/** \brief Identify raster value(s) found on the point position */
//bool identify( const QgsPoint & point, QMap<QString, QString>& results /Out/ );

/** \brief Identify raster value(s) found on the point position */
// bool identifyMap( const QgsPoint & point, QMap<int, QString>& results /Out/ );
//%MethodCode
// sipRes = sipCpp->identify( *a0, *a1 );
//%End

/** \brief Identify arbitrary details from the WMS server found on the point position */
//QString identifyAsText( const QgsPoint & point );

/** \brief Identify arbitrary details from the WMS server found on the point position
* @note added in 1.5
*/
//QString identifyAsHtml( const QgsPoint & point );

/** \brief Currently returns always false */
bool isEditable() const;

/** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */
QString lastError();

Expand All @@ -303,21 +187,9 @@ class QgsRasterLayer : QgsMapLayer
@note this method was added in version 1.8*/
QList< QPair< QString, QColor > > legendSymbologyItems() const;

/** \brief Accessor for maximum value user for contrast enhancement */
double maximumValue( unsigned int theBand );

/** \brief Accessor for maximum value user for contrast enhancement */
double maximumValue( QString theBand );

/** \brief Obtain GDAL Metadata for this layer */
QString metadata();

/** \brief Accessor for minimum value user for contrast enhancement */
double minimumValue( unsigned int theBand );

/** \brief Accessor for minimum value user for contrast enhancement */
double minimumValue( QString theBand );

/** \brief Get an 100x100 pixmap of the color palette. If the layer has no palette a white pixmap will be returned */
QPixmap paletteAsPixmap( int theBandNumber = 1 );

Expand All @@ -329,20 +201,9 @@ class QgsRasterLayer : QgsMapLayer
/** \brief Returns the number of raster units per each raster pixel. In a world file, this is normally the first row (without the sign) */
double rasterUnitsPerPixel();

/** \brief Read color table from GDAL raster band */
// bool readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList );

/** \brief Simple reset function that set the noDataValue back to the value stored in the first raster band */
//void resetNoDataValue();

static QString contrastEnhancementLimitsAsString( QgsRasterLayer::ContrastEnhancementLimits theLimits );
static ContrastEnhancementLimits contrastEnhancementLimitsFromString( QString theLimits );

/** \brief Mutator for contrast enhancement algorithm using min/max */
// TODO: remove in 2.0, replaced by following
// void setContrastEnhancementAlgorithm( QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm,
// bool theGenerateLookupTableFlag = true );

/** \brief Mutator for contrast enhancement algorithm
* @param theAlgorithm Contrast enhancement algorithm
* @param theLimits Limits
Expand All @@ -357,30 +218,12 @@ class QgsRasterLayer : QgsMapLayer
int theSampleSize = QgsRasterLayer::SAMPLE_SIZE,
bool theGenerateLookupTableFlag = true );

/** \brief Mutator for contrast enhancement algorithm */
void setContrastEnhancementAlgorithm( QString theAlgorithm, bool theGenerateLookupTableFlag = true );

/** \brief Mutator for contrast enhancement function */
void setContrastEnhancementFunction( QgsContrastEnhancementFunction* theFunction );

/** \brief Set default contrast enhancement */
void setDefaultContrastEnhancement();

/** \brief Overloaded version of the above function for convenience when restoring from xml */
void setDrawingStyle( const QString & theDrawingStyleQString );

/** \brief Mutator for setting the maximum value for contrast enhancement */
void setMaximumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );

/** \brief Sets the minimum and maximum values for the band(s) currently
* being displayed using the only pixel values from the last/current extent
* */
void setMinimumMaximumUsingLastExtent();

/** \brief Sets the minimum and maximum values for the band(s) currently
* being displayed using the only pixel values from the dataset min/max */
void setMinimumMaximumUsingDataset();

/** \brief [ data provider interface ] A wrapper function to emit a progress update signal */
void showProgress( int theValue );

Expand Down Expand Up @@ -413,11 +256,6 @@ class QgsRasterLayer : QgsMapLayer
virtual QDateTime timestamp() const;

public slots:
/** \brief Create GDAL pyramid overviews */
// QString buildPyramids( const RasterPyramidList &,
// const QString & theResamplingMethod = "NEAREST",
// bool theTryInternalFlag = false );

void showStatusMessage( const QString & theMessage );

/** \brief Propagate progress updates from GDAL up to the parent app */
Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasterresamplefilter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class QgsRasterResampleFilter : QgsRasterInterface
void setMaxOversampling( double os );
double maxOversampling() const;

void writeXML( QDomDocument& doc, QDomElement& parentElem );
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;

/**Sets base class members from xml. Usually called from create() methods of subclasses*/
void readXML( const QDomElement& resamplefilterElem );
Expand Down
3 changes: 0 additions & 3 deletions python/core/raster/qgsrastershaderfunction.sip
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ class QgsRasterShaderFunction
%TypeHeaderCode
#include <qgsrastershaderfunction.h>
#include <qgscolorrampshader.h>
#include <qgsfreakoutshader.h>
#include <qgspseudocolorshader.h>
%End

%ConvertToSubClassCode
if (dynamic_cast<QgsColorRampShader*>(sipCpp) != NULL)
sipClass = sipClass_QgsColorRampShader;
else if (dynamic_cast<QgsFreakOutShader*>(sipCpp) != NULL)
sipClass = sipClass_QgsFreakOutShader;
else if (dynamic_cast<QgsPseudoColorShader*>(sipCpp) != NULL)
sipClass = sipClass_QgsPseudoColorShader;
else
Expand Down
12 changes: 12 additions & 0 deletions python/core/symbology-ng/qgsellipsesymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
void setOutlineColor( const QColor& c );
QColor outlineColor() const;

void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit symbolWidthUnit() const;

void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit symbolHeightUnit() const;

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

QSet<QString> usedAttributes() const;

};
49 changes: 49 additions & 0 deletions python/core/symbology-ng/qgsfillsymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2

void setOffset( QPointF offset );
QPointF offset();

void setBorderWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit borderWidthUnit() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
};

/**Base class for polygon renderers generating texture images*/
Expand All @@ -62,6 +71,9 @@ class QgsImageFillSymbolLayer: QgsFillSymbolLayerV2

virtual QgsSymbolV2* subSymbol();
virtual bool setSubSymbol( QgsSymbolV2* symbol );

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
};

/**A class for svg fill patterns. The class automatically scales the pattern to
Expand Down Expand Up @@ -105,6 +117,16 @@ class QgsSVGFillSymbolLayer: QgsImageFillSymbolLayer
QColor svgOutlineColor() const;
void setSvgOutlineWidth( double w );
double svgOutlineWidth() const;

void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit patternWidthUnit() const;

void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

};

class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer
Expand Down Expand Up @@ -142,6 +164,18 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer
QColor color() const;
void setOffset( double offset );
double offset() const;

void setDistanceUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit distanceUnit() const;

void setLineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit lineWidthUnit() const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
};

class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer
Expand Down Expand Up @@ -183,6 +217,21 @@ class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer

bool setSubSymbol( QgsSymbolV2* symbol );
virtual QgsSymbolV2* subSymbol();

void setDistanceXUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit distanceXUnit() const;

void setDistanceYUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit distanceYUnit() const;

void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit displacementXUnit() const;

void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit displacementYUnit() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
};

class QgsCentroidFillSymbolLayerV2 : QgsFillSymbolLayerV2
Expand Down
18 changes: 18 additions & 0 deletions python/core/symbology-ng/qgslinesymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2
double offset() const;
void setOffset( double offset );

QgsSymbolV2::OutputUnit offsetUnit() const;
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );

bool useCustomDashPattern() const;
void setUseCustomDashPattern( bool b );

QgsSymbolV2::OutputUnit customDashPatternUnit() const;
void setCustomDashPatternUnit( QgsSymbolV2::OutputUnit unit );

QVector<qreal> customDashVector() const;
void setCustomDashVector( const QVector<qreal>& vector );
};
Expand Down Expand Up @@ -114,6 +120,15 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
double offset() const;
void setOffset( double offset );

QgsSymbolV2::OutputUnit intervalUnit() const;
void setIntervalUnit( QgsSymbolV2::OutputUnit unit );

QgsSymbolV2::OutputUnit offsetUnit() const;
void setOffsetUnit( QgsSymbolV2::OutputUnit unit );

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;

Placement placement() const;
void setPlacement( Placement p );

Expand Down Expand Up @@ -157,4 +172,7 @@ class QgsLineDecorationSymbolLayerV2 : QgsLineSymbolLayerV2
QgsSymbolLayerV2* clone() const /Factory/;

void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
};
12 changes: 12 additions & 0 deletions python/core/symbology-ng/qgsmarkersymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
QColor borderColor() const;
void setBorderColor( QColor color );

double outlineWidth() const;
void setOutlineWidth( double w );

QgsSymbolV2::OutputUnit outlineWidthUnit() const;
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit u );

protected:

void drawMarker( QPainter* p, QgsSymbolV2RenderContext& context );
Expand Down Expand Up @@ -92,6 +98,12 @@ class QgsSvgMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2

double outlineWidth() const;
void setOutlineWidth( double w );

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
};

class QgsFontMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
Expand Down
28 changes: 28 additions & 0 deletions python/core/symbology-ng/qgssymbollayerv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,31 @@ class QgsSymbolLayerV2
void setLocked( bool locked );
bool isLocked() const;

virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit );
virtual QgsSymbolV2::OutputUnit outputUnit() const;

// used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...)
void setRenderingPass( int renderingPass );
int renderingPass() const;

// symbol layers normally only use additional attributes to provide data defined settings
virtual QSet<QString> usedAttributes() const;

virtual const QgsExpression* dataDefinedProperty( const QString& property ) const;
virtual QString dataDefinedPropertyString( const QString& property ) const;
virtual void setDataDefinedProperty( const QString& property, const QString& expressionString );
virtual void removeDataDefinedProperty( const QString& property );
virtual void removeDataDefinedProperties();

protected:
QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false );

virtual void prepareExpressions( const QgsVectorLayer* vl );
virtual QgsExpression* expression( const QString& property );
/**Saves data defined properties to string map*/
void saveDataDefinedProperties( QgsStringMap& stringMap ) const;
/**Copies data defined properties of this layer to another symbol layer*/
void copyDataDefinedProperties( QgsSymbolLayerV2* destLayer ) const;
};

//////////////////////
Expand Down Expand Up @@ -130,6 +146,15 @@ class QgsMarkerSymbolLayerV2 : QgsSymbolLayerV2

virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

void setOffsetUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit offsetUnit() const;

void setSizeUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit sizeUnit() const;

virtual void setOutputUnit( QgsSymbolV2::OutputUnit unit );
virtual QgsSymbolV2::OutputUnit outputUnit() const;

protected:
QgsMarkerSymbolLayerV2( bool locked = false );
};
Expand All @@ -149,6 +174,9 @@ class QgsLineSymbolLayerV2 : QgsSymbolLayerV2
virtual void setWidth( double width );
virtual double width() const;

void setWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit widthUnit() const;

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

protected:
Expand Down
7 changes: 7 additions & 0 deletions python/gui/qgsrubberband.sip
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class QgsRubberBand: QgsMapCanvasItem
//! geometryIndex is the index of the feature part (in case of multipart geometries)
void addPoint( const QgsPoint & p, bool update = true, int geometryIndex = 0 );

/**Remove a vertex from the rubberband and (optionally) update canvas.
@param index The index of the vertex/point to remove, negative indexes start at end
@param doUpdate Should the map canvas be updated immediately?
@param geometryIndex The index of the feature part (in case of multipart geometries)
*/
void removePoint( int index = 0, bool doUpdate = true, int geometryIndex = 0 );

//!Removes the last point. Most useful in connection with undo operations
void removeLastPoint( int geometryIndex = 0 );

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/tools/GdalTools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(self):

LayerRegistry.layers = self.getAllLayers()
LayerRegistry._instance = self
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("removedAll()"), self.removeAllLayers)
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("removeAll()"), self.removeAllLayers)
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWasAdded(QgsMapLayer *)"), self.layerAdded)
self.connect(QgsMapLayerRegistry.instance(), SIGNAL("layerWillBeRemoved(QString)"), self.removeLayer)

Expand Down
22 changes: 9 additions & 13 deletions python/plugins/sextante/algs/ftools/Dissolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -52,7 +53,6 @@ def processAlgorithm(self, progress):
fieldname = self.getParameterValue(Dissolve.FIELD)
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(Dissolve.INPUT))
field = vlayerA.fieldNameIndex(fieldname)
GEOS_EXCEPT = True
vproviderA = vlayerA.dataProvider()
fields = vproviderA.fields()
writer = self.getOutputFromName(Dissolve.OUTPUT).getVectorWriter(fields, vproviderA.geometryType(), vproviderA.crs() )
Expand All @@ -77,8 +77,7 @@ def processAlgorithm(self, progress):
tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
outFeat.setGeometry( tmpOutGeom )
except:
GEOS_EXCEPT = False
continue
raise GeoAlgorithmExecutionException("Geometry exception while dissolving")
outFeat.setAttributes( attrs )
writer.addFeature( outFeat )
else:
Expand All @@ -100,21 +99,18 @@ def processAlgorithm(self, progress):
outFeat.setGeometry( tmpInGeom )
first = False
attrs = inFeat.attributes()
else:
else:
tmpInGeom = QgsGeometry( inFeat.geometry() )
tmpOutGeom = QgsGeometry( outFeat.geometry() )
try:
tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
outFeat.setGeometry( tmpOutGeom )
except:
GEOS_EXCEPT = False
add = False
tmpOutGeom = QgsGeometry( outFeat.geometry() )
try:
tmpOutGeom = QgsGeometry( tmpOutGeom.combine( tmpInGeom ) )
outFeat.setGeometry( tmpOutGeom )
except:
raise GeoAlgorithmExecutionException("Geometry exception while dissolving")
if add:
outFeat.setAttributes( attrs )
writer.addFeature( outFeat )
del writer
if not GEOS_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Geometry exception while dissolving")

def defineCharacteristics(self):
self.name = "Dissolve"
Expand Down
12 changes: 6 additions & 6 deletions python/plugins/sextante/core/SextanteConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
from PyQt4 import QtGui

class SextanteConfig():

USE_CATEGORIES = "USE_CATEGORIES"

TABLE_LIKE_PARAM_PANEL = "TABLE_LIKE_PARAM_PANEL"
OUTPUT_FOLDER = "OUTPUT_FOLDER"
RASTER_STYLE = "RASTER_STYLE"
Expand All @@ -55,14 +54,13 @@ class SextanteConfig():
def initialize():
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
SextanteConfig.settingIcons["General"] = icon
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_THREADS, "Run algorithms in a new thread (still unstable)", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_DEBUG_IN_DIALOG, "Show debug information and commands executed in the execution dialog's Log panel (threaded execution only)", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_THREADS, "Run algorithms in a new thread", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_DEBUG_IN_DIALOG, "Show extra info in Log panel (threaded execution only)", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.KEEP_DIALOG_OPEN, "Keep dialog open after running an algorithm", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_SELECTED, "Use only selected features", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.TABLE_LIKE_PARAM_PANEL, "Show table-like parameter panels", False))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_FILENAME_AS_LAYER_NAME, "Use filename as layer name", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.USE_CATEGORIES, "Use categories to classify algorithms, instead of providers", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_RECENT_ALGORITHMS, "Show recently executed algorithms", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.OUTPUT_FOLDER, "Output folder", SextanteUtils.tempFolder()))
SextanteConfig.addSetting(Setting("General", SextanteConfig.SHOW_CRS_DEF, "Show layer CRS definition in selection boxes", True))
SextanteConfig.addSetting(Setting("General", SextanteConfig.WARN_UNMATCHING_CRS, "Warn before executing if layer CRS's do not match", True))
Expand All @@ -82,6 +80,8 @@ def setGroupIcon(group, icon):

@staticmethod
def getGroupIcon(group):
if group == "General":
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/toolbox.png")
if group in SextanteConfig.settingIcons:
return SextanteConfig.settingIcons[group]
else:
Expand Down
25 changes: 10 additions & 15 deletions python/plugins/sextante/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from sextante.core.SextanteLog import SextanteLog
import stat
import shutil
import plugin_installer

class GrassUtils:

Expand Down Expand Up @@ -76,16 +75,14 @@ def grassPath():

folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
if folder == None:
if SextanteUtils.isWindows():
folder = plugin_installer.__file__
idx = folder.find('qgis')
folder = folder[:idx] + "grass"
if not os.path.isdir(folder):
return ""
for subfolder in os.listdir(folder):
if subfolder.startswith("grass"):
folder = folder + os.sep + subfolder
break
if SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "grass")
if os.path.isdir(testfolder):
for subfolder in os.listdir(testfolder):
if subfolder.startswith("grass"):
folder = os.path.join(testfolder, subfolder)
break
else:
folder = os.path.join(str(QgsApplication.prefixPath()), "grass")
if not os.path.isdir(folder):
Expand All @@ -97,10 +94,8 @@ def grassPath():
def grassWinShell():
folder = SextanteConfig.getSetting(GrassUtils.GRASS_WIN_SHELL)
if folder == None:
folder = plugin_installer.__file__
idx = folder.find('qgis')
folder = folder[:idx] + "msys"

folder = os.path.dirname(str(QgsApplication.prefixPath()))
folder = os.path.join(folder, "msys")
return folder

@staticmethod
Expand Down
44 changes: 36 additions & 8 deletions python/plugins/sextante/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* *
***************************************************************************
"""
import os
from PyQt4 import QtGui

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand All @@ -34,9 +36,7 @@ class ConfigDialog(QDialog, Ui_DlgConfig):
def __init__(self, toolbox):
QDialog.__init__(self)
self.setupUi(self)

self.toolbox = toolbox

self.groupIcon = QIcon()
self.groupIcon.addPixmap(self.style().standardPixmap(QStyle.SP_DirClosedIcon),
QIcon.Normal, QIcon.Off)
Expand All @@ -47,15 +47,21 @@ def __init__(self, toolbox):
self.searchBox.setPlaceholderText(self.tr("Search..."))

self.searchBox.textChanged.connect(self.fillTree)

self.fillTree()
self.tree.itemClicked.connect(self.edit)
self.tree.itemDoubleClicked.connect(self.edit)

def edit(self, item, column):
if column > 0:
self.tree.editItem(item, column)

def fillTree(self):
self.items = {}
self.tree.clear()
text = str(self.searchBox.text())
settings = SextanteConfig.getSettings()
for group in settings.keys():
priorityKeys = ['General', "Models", "Scripts"]
for group in priorityKeys:
groupItem = QTreeWidgetItem()
groupItem.setText(0,group)
icon = SextanteConfig.getGroupIcon(group)
Expand All @@ -70,10 +76,32 @@ def fillTree(self):
self.tree.addTopLevelItem(groupItem)
if text != "":
groupItem.setExpanded(True)

providersItem = QTreeWidgetItem()
providersItem.setText(0, "Providers")
icon = QtGui.QIcon(os.path.dirname(__file__) + "/../images/alg.png")
providersItem.setIcon(0, icon)
for group in settings.keys():
if group in priorityKeys:
continue
groupItem = QTreeWidgetItem()
groupItem.setText(0,group)
icon = SextanteConfig.getGroupIcon(group)
groupItem.setIcon(0, icon)
for setting in settings[group]:
if setting.hidden:
continue
if text =="" or text.lower() in setting.description.lower():
settingItem = TreeSettingItem(setting, icon)
self.items[setting]=settingItem
groupItem.addChild(settingItem)
if text != "":
groupItem.setExpanded(True)
providersItem.addChild(groupItem)
self.tree.addTopLevelItem(providersItem)

self.tree.sortItems(0, Qt.AscendingOrder)
self.tree.resizeColumnToContents(0)
self.tree.resizeColumnToContents(1)
self.tree.setColumnWidth(0, 400)

def accept(self):
for setting in self.items.keys():
Expand Down Expand Up @@ -103,13 +131,13 @@ class TreeSettingItem(QTreeWidgetItem):
def __init__(self, setting, icon):
QTreeWidgetItem.__init__(self)
self.setting = setting
self.setText(0, setting.description)
self.setFlags(self.flags() | Qt.ItemIsEditable)
self.setText(0, setting.description)
if isinstance(setting.value,bool):
if setting.value:
self.setCheckState(1, Qt.Checked)
else:
self.setCheckState(1, Qt.Unchecked)
else:
self.setFlags(self.flags() | Qt.ItemIsEditable)
self.setText(1, unicode(setting.value))
self.setIcon(0, icon)
7 changes: 0 additions & 7 deletions python/plugins/sextante/gui/ParametersPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.parameters.ParameterString import ParameterString

from sextante.outputs.OutputHTML import OutputHTML
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputTable import OutputTable
from sextante.outputs.OutputVector import OutputVector
Expand Down Expand Up @@ -168,12 +167,6 @@ def initGUI(self):
self.verticalLayout.addStretch(1000)
self.setLayout(self.verticalLayout)

#=======================================================================
# for param in self.alg.parameters:
# if isinstance(param, ParameterExtent):
# self.widgets[param.name].useMinCovering()
#=======================================================================

def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced
if self.showAdvanced:
Expand Down
33 changes: 31 additions & 2 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand Down Expand Up @@ -46,12 +47,28 @@
_fromUtf8 = lambda s: s

class SextanteToolbox(QDockWidget, Ui_SextanteToolbox):

USE_CATEGORIES = "/SextanteQGIS/UseCategories"


def __init__(self, iface):
QDockWidget.__init__(self, None)
self.setupUi(self)
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)

self.iface=iface

self.modeComboBox.clear()
self.modeComboBox.addItems(['Simplified interface', 'Advanced interface'])
settings = QSettings()
if not settings.contains(self.USE_CATEGORIES):
settings.setValue(self.USE_CATEGORIES, True)
useCategories = settings.value(self.USE_CATEGORIES).toBool()
if useCategories:
self.modeComboBox.setCurrentIndex(0)
else:
self.modeComboBox.setCurrentIndex(1)
self.modeComboBox.currentIndexChanged.connect(self.modeHasChanged)

self.externalAppsButton.clicked.connect(self.configureProviders)
self.searchBox.textChanged.connect(self.fillTree)
Expand All @@ -62,6 +79,16 @@ def __init__(self, iface):
self.searchBox.setPlaceholderText(self.tr("Search..."))

self.fillTree()

def modeHasChanged(self):
idx = self.modeComboBox.currentIndex()
settings = QSettings()
if idx == 0: #simplified
settings.setValue(self.USE_CATEGORIES, True)
else:
settings.setValue(self.USE_CATEGORIES, False)

self.fillTree()

def algsListHasChanged(self):
self.fillTree()
Expand Down Expand Up @@ -145,7 +172,8 @@ def executeAlgorithm(self):
action.execute()

def fillTree(self):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
settings = QSettings()
useCategories = settings.value(self.USE_CATEGORIES).toBool()
if useCategories:
self.fillTreeUsingCategories()
else:
Expand Down Expand Up @@ -334,7 +362,8 @@ def fillTreeUsingProviders(self):
class TreeAlgorithmItem(QTreeWidgetItem):

def __init__(self, alg):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
settings = QSettings()
useCategories = settings.value(SextanteToolbox.USE_CATEGORIES)
QTreeWidgetItem.__init__(self)
self.alg = alg
icon = alg.getIcon()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/modeler/ModelerAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ModelerAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.actions = [CreateNewModelAction()]
#self.actions = [CreateNewModelAction()]
self.contextMenuActions = [EditModelAction(), DeleteModelAction(), SaveAsPythonScriptAction()]

def initializeSettings(self):
Expand All @@ -56,7 +56,7 @@ def modelsFolder(self):
return ModelerUtils.modelsFolder()

def getDescription(self):
return "Modeler"
return "Models"

def getName(self):
return "model"
Expand Down
18 changes: 10 additions & 8 deletions python/plugins/sextante/modeler/ModelerDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
* *
***************************************************************************
"""
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.gui.AlgorithmClassification import AlgorithmDecorator

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand All @@ -33,21 +30,25 @@
import pickle

from sextante.core.SextanteUtils import SextanteUtils

from sextante.gui.HelpEditionDialog import HelpEditionDialog
from sextante.gui.ParametersDialog import ParametersDialog

from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.gui.AlgorithmClassification import AlgorithmDecorator
#from sextante.gui.SextanteToolbox import SextanteToolbox
from sextante.modeler.ModelerParameterDefinitionDialog import ModelerParameterDefinitionDialog
from sextante.modeler.ModelerAlgorithm import ModelerAlgorithm
from sextante.modeler.ModelerParametersDialog import ModelerParametersDialog
from sextante.modeler.ModelerUtils import ModelerUtils
from sextante.modeler.WrongModelException import WrongModelException
from sextante.modeler.ModelerScene import ModelerScene
from sextante.modeler.Providers import Providers

from sextante.ui.ui_DlgModeler import Ui_DlgModeler

class ModelerDialog(QDialog, Ui_DlgModeler):

USE_CATEGORIES = "/SextanteQGIS/UseCategories"

def __init__(self, alg=None):
QDialog.__init__(self)

Expand Down Expand Up @@ -257,7 +258,8 @@ def addAlgorithm(self):
self.view.ensureVisible(self.scene.getLastAlgorithmItem())

def fillAlgorithmTree(self):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
settings = QSettings()
useCategories = settings.value(self.USE_CATEGORIES).toBool()
if useCategories:
self.fillAlgorithmTreeUsingCategories()
else:
Expand Down Expand Up @@ -400,7 +402,7 @@ def fillAlgorithmTreeUsingProviders(self):
class TreeAlgorithmItem(QTreeWidgetItem):

def __init__(self, alg):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
useCategories = SextanteConfig.getSetting(ModelerDialog.USE_CATEGORIES)
QTreeWidgetItem.__init__(self)
self.alg = alg
icon = alg.getIcon()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/otb/OTBAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OTBAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.activate = True
self.createAlgsList()


Expand Down
21 changes: 17 additions & 4 deletions python/plugins/sextante/otb/OTBUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def otbPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
if folder == None:
folder = ""

#try to configure the path automatically
if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "otbcli")):
Expand All @@ -51,6 +51,13 @@ def otbPath():
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "otbcli")):
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.dirname(testfolder)
testfolder = os.path.join(testfolder, "bin")
path = os.path.join(testfolder, "otbcli.bat")
if os.path.exists(path):
folder = testfolder
else:
testfolder = "/usr/bin"
if os.path.exists(os.path.join(testfolder, "otbcli")):
Expand All @@ -62,19 +69,25 @@ def otbLibPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
if folder == None:
folder =""

#try to configure the path automatically
if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "lib/otb/applications")
if os.path.exists(testfolder):
folder = testfolder
else:
testfolder = "/usr/local/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "orfeotoolbox")
testfolder = os.path.join(testfolder, "applications")
if os.path.exists(testfolder):
folder = testfolder
else:
testfolder = "/usr/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
folder = testfolder
return folder

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/r/RAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RAlgorithmProvider(AlgorithmProvider):
def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.actions.append(CreateNewRScriptAction())
#self.actions.append(CreateNewRScriptAction())
self.contextMenuActions = [EditRScriptAction(), DeleteRScriptAction()]

def initializeSettings(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SagaAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.activate = True
self.createAlgsList() #preloading algorithms to speed up

def initializeSettings(self):
Expand Down
21 changes: 13 additions & 8 deletions python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from sextante.tests.TestData import points

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand All @@ -28,6 +27,7 @@
import stat
import traceback
import subprocess
from sextante.tests.TestData import points
from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.SextanteLog import SextanteLog
Expand Down Expand Up @@ -63,15 +63,20 @@ def sagaPath():
folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
if folder == None:
folder =""

if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
folder = testfolder
else:
testfolder = "/usr/local/bin"
#try to auto-configure the folder
if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
folder = testfolder
else:
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "saga")
if os.path.exists(os.path.join(testfolder, "saga_cmd.exe")):
folder = testfolder
return folder

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/script/ScriptAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ScriptAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.actions.append(CreateNewScriptAction())
#self.actions.append(CreateNewScriptAction())
self.contextMenuActions = [EditScriptAction(), DeleteScriptAction()]

def initializeSettings(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
A_script_that_returns_a_number.py
---------------------
Date : March 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'March 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

##[Test scripts]=group
##number=output number
number = 10
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Create_tiling_from_vector_layer.py
---------------------
Date : January 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'January 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

##[Example scripts]=group
##input=vector
##numpolygons=number 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Hex_grid_from_layer_bounds.py
---------------------
Date : November 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

##[Example scripts]=group
##input=vector
##cellsize=number 1000.0
Expand Down
25 changes: 0 additions & 25 deletions python/plugins/sextante/script/scripts/Load_test_data.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Load_test_data.py
---------------------
Date : March 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'March 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

##[Example scripts]=group

sextante.loadTestData()
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Number_of_unique_values_in_classes.py
---------------------
Date : November 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

#Definition of inputs and outputs
#==================================
##[Example scripts]=group
Expand Down
31 changes: 0 additions & 31 deletions python/plugins/sextante/script/scripts/Save_selected_features.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Save_selected_features.py
---------------------
Date : November 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Split_vector_layer_by_attribute.py
---------------------
Date : November 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

#Definition of inputs and outputs
#==================================
##[Example scripts]=group
Expand Down
25 changes: 0 additions & 25 deletions python/plugins/sextante/script/scripts/Summarize.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Summarize.py
---------------------
Date : April 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'April 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

##[Example scripts]=group
##input=vector
##output=output vector
Expand Down
17 changes: 17 additions & 0 deletions python/plugins/sextante/taudem/TauDEMUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
__revision__ = '$Format:%H$'

import os
from qgis.core import QgsApplication
import subprocess

from sextante.core.SextanteConfig import SextanteConfig
Expand All @@ -43,6 +44,14 @@ def taudemPath():
if folder == None:
folder = ""

if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "slopearea")):
folder = testfolder
else:
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "slopearea")):
folder = testfolder
return folder

@staticmethod
Expand All @@ -51,6 +60,14 @@ def mpiexecPath():
if folder == None:
folder = ""

if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "mpiexec")):
folder = testfolder
else:
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "mpiexec")):
folder = testfolder
return folder

@staticmethod
Expand Down
11 changes: 7 additions & 4 deletions python/plugins/sextante/ui/SextanteToolbox.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>444</height>
<width>289</width>
<height>438</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -24,8 +24,8 @@
<item>
<widget class="QPushButton" name="externalAppsButton">
<property name="text">
<string>Click here to configure
additional algorithm providers</string>
<string>Click here to learn more
about SEXTANTE</string>
</property>
</widget>
</item>
Expand All @@ -51,6 +51,9 @@ additional algorithm providers</string>
</column>
</widget>
</item>
<item>
<widget class="QComboBox" name="modeComboBox"/>
</item>
</layout>
</widget>
</widget>
Expand Down
1 change: 1 addition & 0 deletions scripts/tsstat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
af => 'Hendrik Bosman',
ar => 'Assem Kamal, Latif Jalil',
bg => 'Захари Савов, Jordan Tzvetkov',
bs_BA => 'Almir Karabegovic',
ca_ES => 'Xavier Roijals',
cs_CZ => 'Martin Landa, Peter Antolik, Martin Dzurov, Jan Helebrant',
da_DK => 'Jacob Overgaard Madsen, Preben Lisby',
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgsgraphanalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ANALYSIS_EXPORT QgsGraphAnalyzer
* @param source The source graph
* @param startVertexIdx index of start vertex
* @param criterionNum index of arc property as optimization criterion
* @param treeResult array represents the shortest path tree. resultTree[ vertexIndex ] == inboundingArcIndex if vertex reacheble and resultTree[ vertexIndex ] == -1 others.
* @param resultTree array represents the shortest path tree. resultTree[ vertexIndex ] == inboundingArcIndex if vertex reacheble and resultTree[ vertexIndex ] == -1 others.
* @param resultCost array of cost paths
*/
static void dijkstra( const QgsGraph* source, int startVertexIdx, int criterionNum, QVector<int>* resultTree = NULL, QVector<double>* resultCost = NULL );
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgslinevectorlayerdirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ANALYSIS_EXPORT QgsLineVectorLayerDirector : public QgsGraphDirector
* @param bothDirectionValue value for road
* @param defaultDirection 1 - direct direction, 2 - reverse direction, 3 - both direction
*/
QgsLineVectorLayerDirector( QgsVectorLayer* vl,
QgsLineVectorLayerDirector( QgsVectorLayer* myLayer,
int directionFieldId,
const QString& directDirectionValue,
const QString& reverseDirectionValue,
Expand Down
3 changes: 2 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,12 @@ TARGET_LINK_LIBRARIES(${QGIS_APP_NAME}
)

IF (ANDROID)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} log)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} log)
ENDIF (ANDROID)

IF(WIN32)
ADD_DEFINITIONS(-DQWT_DLL)
TARGET_LINK_LIBRARIES(${QGIS_APP_NAME} DbgHelp)
ENDIF(WIN32)

IF (APPLE)
Expand Down
Loading