-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ae371d
commit 551ebd0
Showing
17 changed files
with
1,324 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
/*************************************************************************** | ||
AzimuthDistanceCalculator | ||
A QGIS plugin | ||
Calculates azimuths and distances | ||
------------------- | ||
begin : 2014-09-24 | ||
copyright : (C) 2014 by Luiz Andrade | ||
email : [email protected] | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
This script initializes the plugin, making it known to QGIS. | ||
""" | ||
|
||
def classFactory(iface): | ||
# load AzimuthDistanceCalculator class from file AzimuthDistanceCalculator | ||
from azimuthdistancecalculator import AzimuthDistanceCalculator | ||
return AzimuthDistanceCalculator(iface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
/*************************************************************************** | ||
AzimuthDistanceCalculator | ||
A QGIS plugin | ||
Calculates azimuths and distances | ||
------------------- | ||
begin : 2014-09-24 | ||
copyright : (C) 2014 by Luiz Andrade | ||
email : [email protected] | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
import os | ||
|
||
from PyQt4.QtCore import QCoreApplication | ||
from PyQt4.QtGui import QIcon, QAction | ||
from PyQt4.QtCore import QSettings, QTranslator, qVersion | ||
|
||
import resources_rc | ||
|
||
from azimuthdistancecalculatordialog import AzimuthDistanceCalculatorDialog | ||
|
||
try: | ||
import ptvsd | ||
ptvsd.enable_attach(secret='my_secret', address = ('localhost', 5679)) | ||
except: | ||
pass | ||
|
||
class AzimuthDistanceCalculator: | ||
def __init__(self, iface): | ||
# Save reference to the QGIS interface | ||
self.iface = iface | ||
# initialize plugin directory | ||
self.plugin_dir = os.path.dirname(__file__) | ||
# initialize locale | ||
locale = QSettings().value("locale/userLocale")[0:2] | ||
localePath = os.path.join(self.plugin_dir, 'i18n', 'azimuthdistancecalculator_{}.qm'.format(locale)) | ||
|
||
if os.path.exists(localePath): | ||
self.translator = QTranslator() | ||
self.translator.load(localePath) | ||
|
||
if qVersion() > '4.3.3': | ||
QCoreApplication.installTranslator(self.translator) | ||
|
||
# Create the dialog (after translation) and keep reference | ||
self.dlg = AzimuthDistanceCalculatorDialog(self.iface) | ||
|
||
# Obtaining the map canvas | ||
self.canvas = iface.mapCanvas() | ||
|
||
# noinspection PyMethodMayBeStatic | ||
def tr(self, message): | ||
"""Get the translation for a string using Qt translation API. | ||
|
||
We implement this ourselves since we do not inherit QObject. | ||
|
||
:param message: String for translation. | ||
:type message: str, QString | ||
|
||
:returns: Translated version of message. | ||
:rtype: QString | ||
""" | ||
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass | ||
return QCoreApplication.translate('azimuthdistancecalculator', message) | ||
|
||
def initGui(self): | ||
# Create action that will start plugin configuration | ||
self.action = QAction( | ||
QIcon(":/plugins/azimuthdistancecalculator/north.png"), | ||
self.tr("Calculator"), self.iface.mainWindow()) | ||
# connect the action to the run method | ||
self.action.triggered.connect(self.run) | ||
|
||
# Add toolbar button and menu item | ||
self.iface.addToolBarIcon(self.action) | ||
self.iface.addPluginToMenu(self.tr("Azimuth and Distance Calculator"), self.action) | ||
|
||
def unload(self): | ||
# Remove the plugin menu item and icon | ||
self.iface.removePluginMenu(self.tr("Azimuth and Distance Calculator"), self.action) | ||
self.iface.removeToolBarIcon(self.action) | ||
|
||
# run method that performs all the real work | ||
def run(self): | ||
# show the dialog | ||
self.dlg.show() | ||
# Run the dialog event loop | ||
result = self.dlg.exec_() | ||
# See if OK was pressed | ||
if result == 1: | ||
# do something useful (delete the line containing pass and | ||
# substitute with your code) | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
/*************************************************************************** | ||
AzimuthDistanceCalculatorDialog | ||
A QGIS plugin | ||
Calculates azimuths and distances | ||
------------------- | ||
begin : 2014-09-24 | ||
copyright : (C) 2014 by Luiz Andrade | ||
email : [email protected] | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
import os | ||
|
||
from PyQt4 import uic | ||
from PyQt4.QtGui import QMessageBox, QDialog | ||
|
||
FORM_CLASS, _ = uic.loadUiType(os.path.join( | ||
os.path.dirname(__file__), 'ui_azimuthdistancecalculator.ui')) | ||
|
||
# Import specific modules | ||
from AzimuthDistanceCalculator.kappaAndConvergence.calculateKappaAndConvergence import CalculateKappaAndConvergenceDialog | ||
from AzimuthDistanceCalculator.azimuthsAndDistances.azimuthsAndDistances import AzimuthsAndDistancesDialog | ||
|
||
class AzimuthDistanceCalculatorDialog(QDialog, FORM_CLASS): | ||
def __init__(self, iface): | ||
QDialog.__init__(self) | ||
# Set up the user interface from Designer. | ||
# After setupUI you can access any designer object by doing | ||
# self.<objectname>, and you can use autoconnect slots - see | ||
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html | ||
# #widgets-and-dialogs-with-auto-connect | ||
self.setupUi(self) | ||
|
||
self.iface = iface | ||
|
||
# Connecting SIGNAL/SLOTS for the Output button | ||
self.kappaAndConvergenceButton.clicked.connect(self.calculateKappa) | ||
|
||
# Connecting SIGNAL/SLOTS for the Output button | ||
self.azimuthsAndDistancesButton.clicked.connect(self.calculateAzimuths) | ||
|
||
def calculateKappa(self): | ||
currentLayer = self.iface.mapCanvas().currentLayer() | ||
if currentLayer: | ||
d = CalculateKappaAndConvergenceDialog(self.iface) | ||
d.exec_() | ||
else: | ||
QMessageBox.warning(self.iface.mainWindow(), self.tr("Warning!"), self.tr("Please, open a layer and select a line or polygon feature.")) | ||
|
||
def calculateAzimuths(self): | ||
currentLayer = self.iface.mapCanvas().currentLayer() | ||
if currentLayer: | ||
selectedFeatures = len(currentLayer.selectedFeatures()) | ||
if selectedFeatures == 1: | ||
selectedFeature = currentLayer.selectedFeatures()[0] | ||
d = AzimuthsAndDistancesDialog(self.iface, selectedFeature.geometry()) | ||
d.exec_() | ||
else: | ||
QMessageBox.warning(self.iface.mainWindow(), self.tr("Warning!"), self.tr("One and only one feature must be selected to perform the calculations.")) | ||
else: | ||
QMessageBox.warning(self.iface.mainWindow(), self.tr("Warning!"), self.tr("Please, open a layer and select a line or polygon feature.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.