flake8
This commit is contained in:
parent
1cd816c706
commit
7a3814a429
@ -11,7 +11,7 @@ from qgis.utils import iface
|
|||||||
import qgis
|
import qgis
|
||||||
|
|
||||||
|
|
||||||
#include <QSettings>
|
# include <QSettings>
|
||||||
'''
|
'''
|
||||||
from pg_metadata.connection_manager import (
|
from pg_metadata.connection_manager import (
|
||||||
store_connections,
|
store_connections,
|
||||||
@ -24,8 +24,9 @@ from pg_metadata.processing.provider import PgMetadataProvider
|
|||||||
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
|
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
|
||||||
'''
|
'''
|
||||||
import os
|
import os
|
||||||
|
from qgis.PyQt.QtCore import QSettings
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
plugin_path,
|
# plugin_path,
|
||||||
resources_path,
|
resources_path,
|
||||||
pyperclip,
|
pyperclip,
|
||||||
maj_verif,
|
maj_verif,
|
||||||
@ -37,9 +38,6 @@ from .style_invoke import AutoMap_Style
|
|||||||
from .about_form import AboutDialog
|
from .about_form import AboutDialog
|
||||||
|
|
||||||
|
|
||||||
from qgis.PyQt.QtCore import *
|
|
||||||
|
|
||||||
|
|
||||||
class PgAutoMap:
|
class PgAutoMap:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
""" Constructor. """
|
""" Constructor. """
|
||||||
@ -51,18 +49,18 @@ class PgAutoMap:
|
|||||||
self.dock_action = None
|
self.dock_action = None
|
||||||
self.help_action = None
|
self.help_action = None
|
||||||
plugin_dir = os.path.dirname(__file__)
|
plugin_dir = os.path.dirname(__file__)
|
||||||
end_find = plugin_dir.rfind('\\')+1
|
end_find = plugin_dir.rfind('\\') + 1
|
||||||
global NAME
|
global NAME
|
||||||
NAME = plugin_dir[end_find:]
|
NAME = plugin_dir[end_find:]
|
||||||
maj_verif(NAME)
|
maj_verif(NAME)
|
||||||
|
|
||||||
# Display About window on first use
|
# Display About window on first use
|
||||||
version = qgis.utils.pluginMetadata('CenRa_AUTOMAP','version')
|
version = qgis.utils.pluginMetadata('CenRa_AUTOMAP', 'version')
|
||||||
s = QSettings()
|
s = QSettings()
|
||||||
versionUse = s.value("automap/version", 1, type=str)
|
versionUse = s.value("automap/version", 1, type=str)
|
||||||
if str(versionUse) != str(version) :
|
if str(versionUse) != str(version):
|
||||||
s.setValue("automap/version", str(version))
|
s.setValue("automap/version", str(version))
|
||||||
print(versionUse,version)
|
print(versionUse, version)
|
||||||
self.open_about_dialog()
|
self.open_about_dialog()
|
||||||
|
|
||||||
def initGui(self):
|
def initGui(self):
|
||||||
@ -80,7 +78,7 @@ class PgAutoMap:
|
|||||||
if not self.canvas_editor:
|
if not self.canvas_editor:
|
||||||
self.canvas_editor = AutoMap_Editor()
|
self.canvas_editor = AutoMap_Editor()
|
||||||
|
|
||||||
self.automap_action = QAction(icon, 'CenRa_AutoMap',None)
|
self.automap_action = QAction(icon, 'CenRa_AutoMap', None)
|
||||||
self.toolBar.addAction(self.automap_action)
|
self.toolBar.addAction(self.automap_action)
|
||||||
self.automap_action.triggered.connect(self.open_editor)
|
self.automap_action.triggered.connect(self.open_editor)
|
||||||
|
|
||||||
@ -129,6 +127,7 @@ class PgAutoMap:
|
|||||||
"""
|
"""
|
||||||
dialog = AboutDialog(iface)
|
dialog = AboutDialog(iface)
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
def open_help():
|
def open_help():
|
||||||
""" Open the online help. """
|
""" Open the online help. """
|
||||||
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
||||||
@ -140,7 +139,7 @@ class PgAutoMap:
|
|||||||
def unload(self):
|
def unload(self):
|
||||||
""" Unload the plugin. """
|
""" Unload the plugin. """
|
||||||
if self.canvas_editor:
|
if self.canvas_editor:
|
||||||
iface.removePluginMenu('CenRa_AutoMap',self.automap_action)
|
iface.removePluginMenu('CenRa_AutoMap', self.automap_action)
|
||||||
|
|
||||||
if self.provider:
|
if self.provider:
|
||||||
QgsApplication.processingRegistry().removeProvider(self.provider)
|
QgsApplication.processingRegistry().removeProvider(self.provider)
|
||||||
|
|||||||
@ -44,7 +44,7 @@ from qgis.core import (
|
|||||||
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
|
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
|
||||||
from qgis.PyQt.QtPrintSupport import QPrinter
|
from qgis.PyQt.QtPrintSupport import QPrinter
|
||||||
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
# from qgis.PyQt.QtWebKitWidgets import QWebPage
|
||||||
from qgis.PyQt.QtWidgets import (
|
from qgis.PyQt.QtWidgets import (
|
||||||
QDialog,
|
QDialog,
|
||||||
QAction,
|
QAction,
|
||||||
@ -55,14 +55,13 @@ from qgis.PyQt.QtWidgets import (
|
|||||||
QInputDialog,
|
QInputDialog,
|
||||||
QMenu,
|
QMenu,
|
||||||
QToolButton,
|
QToolButton,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
)
|
)
|
||||||
|
|
||||||
from qgis.PyQt.QtCore import QSettings
|
from qgis.PyQt.QtCore import QSettings
|
||||||
from qgis.PyQt import QtGui
|
from qgis.PyQt import QtGui, QtWidgets
|
||||||
from qgis.PyQt import QtWidgets
|
|
||||||
|
|
||||||
|
|
||||||
from qgis.PyQt.QtXml import QDomDocument
|
from qgis.PyQt.QtXml import QDomDocument
|
||||||
@ -71,7 +70,7 @@ import glob
|
|||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
resources_path,
|
resources_path,
|
||||||
send_issues,
|
# send_issues,
|
||||||
)
|
)
|
||||||
from .issues import CenRa_Issues
|
from .issues import CenRa_Issues
|
||||||
|
|
||||||
@ -84,48 +83,48 @@ url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&
|
|||||||
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
||||||
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
|
||||||
data_source = [
|
data_source = [
|
||||||
'CENRA',
|
'CENRA',
|
||||||
'IGN',
|
'IGN',
|
||||||
'CRAIG',
|
'CRAIG',
|
||||||
'OpenStreetMap',
|
'OpenStreetMap',
|
||||||
'Sandre',
|
'Sandre',
|
||||||
'BRGM',
|
'BRGM',
|
||||||
'MUSÉUM NATIONAL D’HISTOIRE NATURELLE',
|
'MUSÉUM NATIONAL D’HISTOIRE NATURELLE',
|
||||||
"Muséum national d'Histoire naturelle",
|
"Muséum national d'Histoire naturelle",
|
||||||
'ONF',
|
'ONF',
|
||||||
'20xx LPO',
|
'20xx LPO',
|
||||||
'ofb.gouv.fr',
|
'ofb.gouv.fr',
|
||||||
'Stamen Design',
|
'Stamen Design',
|
||||||
'MTES',
|
'MTES',
|
||||||
'MTES',
|
'MTES',
|
||||||
'FEDER',
|
'FEDER',
|
||||||
'DREAL Auvergne-Rhône-Alpes',
|
'DREAL Auvergne-Rhône-Alpes',
|
||||||
'INSEE',
|
'INSEE',
|
||||||
'DGFiP',
|
'DGFiP',
|
||||||
'Fédération des Conservatoires d’espaces naturels',
|
'Fédération des Conservatoires d’espaces naturels',
|
||||||
'Plan cadastral informatisé - Etalab - juillet 202X',
|
'Plan cadastral informatisé - Etalab - juillet 202X',
|
||||||
'Parcellaire Express - IGN - 202X',
|
'Parcellaire Express - IGN - 202X',
|
||||||
]
|
]
|
||||||
A4_size = {'Portrait':{'RIGHT':210,'LEFT':0,'TOP':0,'BOTTOM':297},'Landscape':{'RIGHT':297,'LEFT':0,'TOP':0,'BOTTOM':210}}
|
A4_size = {'Portrait': {'RIGHT': 210, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 297}, 'Landscape': {'RIGHT': 297, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 210}}
|
||||||
A3_size = {'Portrait':{'RIGHT':298,'LEFT':0,'TOP':0,'BOTTOM':420},'Landscape':{'RIGHT':420,'LEFT':0,'TOP':0,'BOTTOM':298}}
|
A3_size = {'Portrait': {'RIGHT': 298, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 420}, 'Landscape': {'RIGHT': 420, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 298}}
|
||||||
|
|
||||||
|
|
||||||
class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
_ = parent
|
_ = parent
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.settings = QgsSettings()
|
self.settings = QgsSettings()
|
||||||
self.s = QSettings()
|
self.s = QSettings()
|
||||||
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png')))
|
self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
|
||||||
|
|
||||||
path = ''
|
path = ''
|
||||||
ix = 0
|
ix = 0
|
||||||
plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep)
|
plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep)
|
||||||
for i in plugin_dir[1:]:
|
for i in plugin_dir[1:]:
|
||||||
ix = ix+1
|
ix = ix + 1
|
||||||
path = path+'/'+i
|
path = path + '/' + i
|
||||||
#self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);')
|
# self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);')
|
||||||
|
|
||||||
self.verticalScrollBar.hide()
|
self.verticalScrollBar.hide()
|
||||||
self.commandLinkButton.clicked.connect(self.chargement_qpt)
|
self.commandLinkButton.clicked.connect(self.chargement_qpt)
|
||||||
@ -140,13 +139,12 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.CustomeLogo.clicked.connect(self.deflogoteck)
|
self.CustomeLogo.clicked.connect(self.deflogoteck)
|
||||||
self.verticalScrollBar.valueChanged.connect(self.moveFrame)
|
self.verticalScrollBar.valueChanged.connect(self.moveFrame)
|
||||||
|
|
||||||
## On ajoute le nom des templates à la liste déroulante de l'onglet "mises en page" :
|
# On ajoute le nom des templates à la liste déroulante de l'onglet "mises en page" :
|
||||||
mises_en_page = []
|
mises_en_page = []
|
||||||
|
|
||||||
for filename in glob.glob(resources_path("mises_en_pages","*.py")):
|
for filename in glob.glob(resources_path("mises_en_pages", "*.py")):
|
||||||
mises_en_page.append(filename)
|
mises_en_page.append(filename)
|
||||||
|
|
||||||
|
|
||||||
for i, filename in enumerate(mises_en_page):
|
for i, filename in enumerate(mises_en_page):
|
||||||
nom_fichier = os.path.basename(filename)
|
nom_fichier = os.path.basename(filename)
|
||||||
self.comboBox.addItem(nom_fichier)
|
self.comboBox.addItem(nom_fichier)
|
||||||
@ -154,35 +152,35 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
self.template_parameters = {
|
self.template_parameters = {
|
||||||
'Carte_size': None,
|
'Carte_size': None,
|
||||||
'Carte_locals' : None,
|
'Carte_locals': None,
|
||||||
'Carte_rotate':None,
|
'Carte_rotate': None,
|
||||||
'Carte_2_size' : None,
|
'Carte_2_size': None,
|
||||||
'Carte_2_locals' : None,
|
'Carte_2_locals': None,
|
||||||
'Carte_2_rotate':None,
|
'Carte_2_rotate': None,
|
||||||
'Legande_size': None,
|
'Legande_size': None,
|
||||||
'Legande_locals': None,
|
'Legande_locals': None,
|
||||||
'Legande_rotate':None,
|
'Legande_rotate': None,
|
||||||
'Arrow_size': None,
|
'Arrow_size': None,
|
||||||
'Arrow_locals': None,
|
'Arrow_locals': None,
|
||||||
'Arrow_rotate':None,
|
'Arrow_rotate': None,
|
||||||
'Echelle_size': None,
|
'Echelle_size': None,
|
||||||
'Echelle_locals': None,
|
'Echelle_locals': None,
|
||||||
'Echelle_rotate':None,
|
'Echelle_rotate': None,
|
||||||
'Logo_size': None,
|
'Logo_size': None,
|
||||||
'Logo_locals': None,
|
'Logo_locals': None,
|
||||||
'Logo_rotate':None,
|
'Logo_rotate': None,
|
||||||
'Titre_size':None,
|
'Titre_size': None,
|
||||||
'Titre_locals':None,
|
'Titre_locals': None,
|
||||||
'Titre_rotate':None,
|
'Titre_rotate': None,
|
||||||
'Sous_titre_size':None,
|
'Sous_titre_size': None,
|
||||||
'Sous_titre_locals':None,
|
'Sous_titre_locals': None,
|
||||||
'Sous_titre_rotate':None,
|
'Sous_titre_rotate': None,
|
||||||
'Credit_size': None,
|
'Credit_size': None,
|
||||||
'Credit_locals': None,
|
'Credit_locals': None,
|
||||||
'Credit_rotate':None,
|
'Credit_rotate': None,
|
||||||
'Source_size': None,
|
'Source_size': None,
|
||||||
'Source_locals': None,
|
'Source_locals': None,
|
||||||
'Source_rotate':None,
|
'Source_rotate': None,
|
||||||
'Logo_2_size': None,
|
'Logo_2_size': None,
|
||||||
'Logo_2_locals': None,
|
'Logo_2_locals': None,
|
||||||
'Logo_2_rotate': None,
|
'Logo_2_rotate': None,
|
||||||
@ -198,23 +196,25 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.hide_source()
|
self.hide_source()
|
||||||
self.hide_atlas()
|
self.hide_atlas()
|
||||||
|
|
||||||
def wheelEvent(self,event):
|
def wheelEvent(self, event):
|
||||||
if (event.angleDelta().y() >= 1):
|
if (event.angleDelta().y() >= 1):
|
||||||
vsb = self.verticalScrollBar.value()+20
|
vsb = self.verticalScrollBar.value() + 20
|
||||||
else:
|
else:
|
||||||
vsb = self.verticalScrollBar.value()-20
|
vsb = self.verticalScrollBar.value() - 20
|
||||||
self.verticalScrollBar.setValue(vsb)
|
self.verticalScrollBar.setValue(vsb)
|
||||||
|
|
||||||
def moveFrame(self):
|
def moveFrame(self):
|
||||||
self.frame.move(self.frame.x(),self.verticalScrollBar.value())
|
self.frame.move(self.frame.x(), self.verticalScrollBar.value())
|
||||||
|
|
||||||
def update_logo_library(self):
|
def update_logo_library(self):
|
||||||
self.mComboBox_4.clear()
|
self.mComboBox_4.clear()
|
||||||
logo_library = []
|
logo_library = []
|
||||||
custome_bibliotech = glob.glob(self.s.value("automap/logoteck", 1, type=str)+'*.*')
|
custome_bibliotech = glob.glob(self.s.value("automap/logoteck", 1, type=str) + '*.*')
|
||||||
for l,logo_x in enumerate(custome_bibliotech):
|
for l, logo_x in enumerate(custome_bibliotech):
|
||||||
logo_library.append(' '+os.path.basename(logo_x))
|
logo_library.append(' ' + os.path.basename(logo_x))
|
||||||
|
|
||||||
bibliotech = glob.glob(resources_path("logo_library","*.png"))
|
bibliotech = glob.glob(resources_path("logo_library", "*.png"))
|
||||||
for l,logo_x in enumerate(bibliotech):
|
for l, logo_x in enumerate(bibliotech):
|
||||||
logo_library.append(os.path.basename(logo_x))
|
logo_library.append(os.path.basename(logo_x))
|
||||||
self.mComboBox_4.addItems(sorted(logo_library))
|
self.mComboBox_4.addItems(sorted(logo_library))
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
options = QFileDialog.Options()
|
options = QFileDialog.Options()
|
||||||
options |= QFileDialog.ShowDirsOnly
|
options |= QFileDialog.ShowDirsOnly
|
||||||
folder = QFileDialog.getExistingDirectory(self, "Sélection du dossier parent", options=options)
|
folder = QFileDialog.getExistingDirectory(self, "Sélection du dossier parent", options=options)
|
||||||
return folder+'/'
|
return folder + '/'
|
||||||
|
|
||||||
def deflogoteck(self):
|
def deflogoteck(self):
|
||||||
folder = self.select_file()
|
folder = self.select_file()
|
||||||
@ -237,16 +237,20 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
try:
|
try:
|
||||||
layout_subtitle = project_subtitle.layoutManager().layoutByName(self.comboBox_7.currentText())
|
layout_subtitle = project_subtitle.layoutManager().layoutByName(self.comboBox_7.currentText())
|
||||||
self.lineEdit_3.setText(layout_subtitle.itemById("SubTitle").text())
|
self.lineEdit_3.setText(layout_subtitle.itemById("SubTitle").text())
|
||||||
except:
|
except NameError:
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
def load_ortho(self):
|
def load_ortho(self):
|
||||||
global myGroup,last_group
|
global myGroup, last_group
|
||||||
runing = False
|
runing = False
|
||||||
try: myGroup
|
try:
|
||||||
except NameError: runing = True
|
myGroup
|
||||||
try: last_group
|
except NameError:
|
||||||
except NameError: last_group = ''
|
runing = True
|
||||||
|
try:
|
||||||
|
last_group
|
||||||
|
except NameError:
|
||||||
|
last_group = ''
|
||||||
if runing or (last_group != '' and last_group != 'ortho'):
|
if runing or (last_group != '' and last_group != 'ortho'):
|
||||||
layername = False
|
layername = False
|
||||||
layerAll = QgsProject.instance().layerTreeRoot().children()
|
layerAll = QgsProject.instance().layerTreeRoot().children()
|
||||||
@ -255,7 +259,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
if layeritem.name() == 'SuperFont':
|
if layeritem.name() == 'SuperFont':
|
||||||
myGroup = layerAll[xl]
|
myGroup = layerAll[xl]
|
||||||
layername = True
|
layername = True
|
||||||
xl = xl+1
|
xl = xl + 1
|
||||||
if layername:
|
if layername:
|
||||||
(QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup)
|
(QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup)
|
||||||
runing = True
|
runing = True
|
||||||
@ -265,32 +269,36 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
myGroup = (QgsProject.instance().layerTreeRoot()).addGroup("SuperFont")
|
myGroup = (QgsProject.instance().layerTreeRoot()).addGroup("SuperFont")
|
||||||
last_group = 'ortho'
|
last_group = 'ortho'
|
||||||
|
|
||||||
#OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms')
|
# OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms')
|
||||||
ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms')
|
ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms')
|
||||||
MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms')
|
MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms')
|
||||||
PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms')
|
PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms')
|
||||||
|
|
||||||
#OSM_RASTER.loadNamedStyle(resources_path("font","osm_background.qml"))
|
# OSM_RASTER.loadNamedStyle(resources_path("font", "osm_background.qml"))
|
||||||
ORTHO_RASTER.loadNamedStyle(resources_path("font","ortho_aura.qml"))
|
ORTHO_RASTER.loadNamedStyle(resources_path("font", "ortho_aura.qml"))
|
||||||
MNT_RASTER.loadNamedStyle(resources_path("font","mnt_alti.qml"))
|
MNT_RASTER.loadNamedStyle(resources_path("font", "mnt_alti.qml"))
|
||||||
|
|
||||||
#QgsProject.instance().addMapLayer(OSM_RASTER,False)
|
# QgsProject.instance().addMapLayer(OSM_RASTER,False)
|
||||||
QgsProject.instance().addMapLayer(ORTHO_RASTER,False)
|
QgsProject.instance().addMapLayer(ORTHO_RASTER, False)
|
||||||
QgsProject.instance().addMapLayer(MNT_RASTER,False)
|
QgsProject.instance().addMapLayer(MNT_RASTER, False)
|
||||||
QgsProject.instance().addMapLayer(PENTE_RASTER,False)
|
QgsProject.instance().addMapLayer(PENTE_RASTER, False)
|
||||||
|
|
||||||
#myGroup.addLayer(OSM_RASTER)
|
# myGroup.addLayer(OSM_RASTER)
|
||||||
myGroup.addLayer(ORTHO_RASTER)
|
myGroup.addLayer(ORTHO_RASTER)
|
||||||
myGroup.addLayer(MNT_RASTER)
|
myGroup.addLayer(MNT_RASTER)
|
||||||
myGroup.addLayer(PENTE_RASTER)
|
myGroup.addLayer(PENTE_RASTER)
|
||||||
|
|
||||||
def load_osm(self):
|
def load_osm(self):
|
||||||
global myGroup,last_group
|
global myGroup, last_group
|
||||||
runing = False
|
runing = False
|
||||||
try: myGroup
|
try:
|
||||||
except NameError: runing = True
|
myGroup
|
||||||
try: last_group
|
except NameError:
|
||||||
except NameError: last_group = ''
|
runing = True
|
||||||
|
try:
|
||||||
|
last_group
|
||||||
|
except NameError:
|
||||||
|
last_group = ''
|
||||||
if runing or (last_group != '' and last_group != 'osm'):
|
if runing or (last_group != '' and last_group != 'osm'):
|
||||||
layername = False
|
layername = False
|
||||||
layerAll = QgsProject.instance().layerTreeRoot().children()
|
layerAll = QgsProject.instance().layerTreeRoot().children()
|
||||||
@ -299,7 +307,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
if layeritem.name() == 'SuperFont':
|
if layeritem.name() == 'SuperFont':
|
||||||
myGroup = layerAll[xl]
|
myGroup = layerAll[xl]
|
||||||
layername = True
|
layername = True
|
||||||
xl = xl+1
|
xl = xl + 1
|
||||||
if layername:
|
if layername:
|
||||||
(QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup)
|
(QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup)
|
||||||
runing = True
|
runing = True
|
||||||
@ -309,21 +317,21 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
last_group = 'osm'
|
last_group = 'osm'
|
||||||
|
|
||||||
OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms')
|
OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms')
|
||||||
#ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms')
|
# ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms')
|
||||||
MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms')
|
MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms')
|
||||||
PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms')
|
PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms')
|
||||||
|
|
||||||
OSM_RASTER.loadNamedStyle(resources_path("font","osm_background.qml"))
|
OSM_RASTER.loadNamedStyle(resources_path("font", "osm_background.qml"))
|
||||||
#ORTHO_RASTER.loadNamedStyle(resources_path("font","ortho_aura.qml"))
|
# ORTHO_RASTER.loadNamedStyle(resources_path("font","ortho_aura.qml"))
|
||||||
MNT_RASTER.loadNamedStyle(resources_path("font","mnt_alti.qml"))
|
MNT_RASTER.loadNamedStyle(resources_path("font", "mnt_alti.qml"))
|
||||||
|
|
||||||
QgsProject.instance().addMapLayer(OSM_RASTER,False)
|
QgsProject.instance().addMapLayer(OSM_RASTER, False)
|
||||||
#QgsProject.instance().addMapLayer(ORTHO_RASTER,False)
|
# QgsProject.instance().addMapLayer(ORTHO_RASTER,False)
|
||||||
QgsProject.instance().addMapLayer(MNT_RASTER,False)
|
QgsProject.instance().addMapLayer(MNT_RASTER, False)
|
||||||
QgsProject.instance().addMapLayer(PENTE_RASTER,False)
|
QgsProject.instance().addMapLayer(PENTE_RASTER, False)
|
||||||
|
|
||||||
myGroup.addLayer(OSM_RASTER)
|
myGroup.addLayer(OSM_RASTER)
|
||||||
#myGroup.addLayer(ORTHO_RASTER)
|
# myGroup.addLayer(ORTHO_RASTER)
|
||||||
myGroup.addLayer(MNT_RASTER)
|
myGroup.addLayer(MNT_RASTER)
|
||||||
myGroup.addLayer(PENTE_RASTER)
|
myGroup.addLayer(PENTE_RASTER)
|
||||||
|
|
||||||
@ -365,6 +373,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.show_map()
|
self.show_map()
|
||||||
else:
|
else:
|
||||||
self.hide_map()
|
self.hide_map()
|
||||||
|
|
||||||
def show_map(self):
|
def show_map(self):
|
||||||
self.groupBox_3.setEnabled(True)
|
self.groupBox_3.setEnabled(True)
|
||||||
self.groupBox_3.show()
|
self.groupBox_3.show()
|
||||||
@ -378,6 +387,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.show_titre()
|
self.show_titre()
|
||||||
else:
|
else:
|
||||||
self.hide_titre()
|
self.hide_titre()
|
||||||
|
|
||||||
def show_titre(self):
|
def show_titre(self):
|
||||||
self.lineEdit_2.setEnabled(False)
|
self.lineEdit_2.setEnabled(False)
|
||||||
self.lineEdit_2.hide()
|
self.lineEdit_2.hide()
|
||||||
@ -395,6 +405,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.show_source()
|
self.show_source()
|
||||||
else:
|
else:
|
||||||
self.hide_source()
|
self.hide_source()
|
||||||
|
|
||||||
def show_source(self):
|
def show_source(self):
|
||||||
self.lineEdit_4.setEnabled(False)
|
self.lineEdit_4.setEnabled(False)
|
||||||
self.lineEdit_4.hide()
|
self.lineEdit_4.hide()
|
||||||
@ -427,7 +438,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.comboBox_4.clear()
|
self.comboBox_4.clear()
|
||||||
if self.comboBox_2.currentText() != '':
|
if self.comboBox_2.currentText() != '':
|
||||||
layer = QgsProject.instance().mapLayersByName(self.comboBox_2.currentText())[0]
|
layer = QgsProject.instance().mapLayersByName(self.comboBox_2.currentText())[0]
|
||||||
#BUG sur layer.fields() pas défini sur ce qui est pas vecteur
|
# BUG sur layer.fields() pas défini sur ce qui est pas vecteur
|
||||||
for vfields in layer.fields():
|
for vfields in layer.fields():
|
||||||
fields.append(vfields.name())
|
fields.append(vfields.name())
|
||||||
self.comboBox_3.addItems(sorted(fields))
|
self.comboBox_3.addItems(sorted(fields))
|
||||||
@ -443,11 +454,11 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
layout_name = self.lineEdit_2.text()
|
layout_name = self.lineEdit_2.text()
|
||||||
layouts_list = self.manager.printLayouts()
|
layouts_list = self.manager.printLayouts()
|
||||||
|
|
||||||
for filename in glob.glob(resources_path("mises_en_pages","*.qpt")):
|
for filename in glob.glob(resources_path("mises_en_pages", "*.qpt")):
|
||||||
with open(os.path.join(os.getcwd(), filename), 'r') as f:
|
with open(os.path.join(os.getcwd(), filename), 'r') as f:
|
||||||
self.layout = QgsPrintLayout(project)
|
self.layout = QgsPrintLayout(project)
|
||||||
self.layout.initializeDefaults()
|
self.layout.initializeDefaults()
|
||||||
myAtlas=self.layout.atlas()
|
myAtlas = self.layout.atlas()
|
||||||
template_content = f.read()
|
template_content = f.read()
|
||||||
doc = QDomDocument()
|
doc = QDomDocument()
|
||||||
doc.setContent(template_content)
|
doc.setContent(template_content)
|
||||||
@ -455,12 +466,12 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cutLayout = layout_name.index("¶")
|
cutLayout = layout_name.index("¶")
|
||||||
except:
|
except NameError:
|
||||||
cutLayout = 0
|
cutLayout = 0
|
||||||
|
|
||||||
if cutLayout >= 1:
|
if cutLayout >= 1:
|
||||||
self.layout.setName(layout_name)
|
self.layout.setName(layout_name)
|
||||||
titre_layout_name=layout_name[:cutLayout]
|
titre_layout_name = layout_name[:cutLayout]
|
||||||
else:
|
else:
|
||||||
self.layout.setName(layout_name)
|
self.layout.setName(layout_name)
|
||||||
titre_layout_name = layout_name
|
titre_layout_name = layout_name
|
||||||
@ -473,11 +484,12 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
logo_div = A3_size['Portrait']['RIGHT']
|
logo_div = A3_size['Portrait']['RIGHT']
|
||||||
if self.radioButton_5.isChecked() and self.radioButton_8.isChecked():
|
if self.radioButton_5.isChecked() and self.radioButton_8.isChecked():
|
||||||
logo_div = A3_size['Portrait']['BOTTOM']
|
logo_div = A3_size['Portrait']['BOTTOM']
|
||||||
if True:#os.path.basename(filename) == "1. Modèle carto standard (consolidé).qpt":
|
# os.path.basename(filename) == "1. Modèle carto standard (consolidé).qpt":
|
||||||
|
if True:
|
||||||
|
|
||||||
self.actualisation_mise_en_page()
|
self.actualisation_mise_en_page()
|
||||||
|
|
||||||
## Add map to layout
|
# Add map to layout
|
||||||
self.map_modele_test = QgsLayoutItemMap(self.layout)
|
self.map_modele_test = QgsLayoutItemMap(self.layout)
|
||||||
# Charger une carte vide
|
# Charger une carte vide
|
||||||
self.map_modele_test.setRect(20, 20, 20, 20)
|
self.map_modele_test.setRect(20, 20, 20, 20)
|
||||||
@ -499,18 +511,18 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
if self.radioButton_12.isChecked() == 1:
|
if self.radioButton_12.isChecked() == 1:
|
||||||
self.position_map = QgsLayoutItemMap(self.layout)
|
self.position_map = QgsLayoutItemMap(self.layout)
|
||||||
self.position_map.setRect(20, 20, 20, 20)
|
self.position_map.setRect(20, 20, 20, 20)
|
||||||
self.position_map.setExtent(QgsRectangle(641552,6647386, 995856,6331104))
|
self.position_map.setExtent(QgsRectangle(641552, 6647386, 995856, 6331104))
|
||||||
self.position_map.setFollowVisibilityPreset(True)
|
self.position_map.setFollowVisibilityPreset(True)
|
||||||
self.position_map.setFollowVisibilityPresetName(self.comboBox_6.currentText())
|
self.position_map.setFollowVisibilityPresetName(self.comboBox_6.currentText())
|
||||||
self.position_map.setItemRotation(self.template_parameters['Carte_2_rotate'])
|
self.position_map.setItemRotation(self.template_parameters['Carte_2_rotate'])
|
||||||
self.position_map.attemptResize(self.template_parameters['Carte_2_size'])
|
self.position_map.attemptResize(self.template_parameters['Carte_2_size'])
|
||||||
self.position_map.attemptMove(self.template_parameters['Carte_2_locals'])
|
self.position_map.attemptMove(self.template_parameters['Carte_2_locals'])
|
||||||
self.position_map.overview().setLinkedMap(self.map_modele_test)
|
self.position_map.overview().setLinkedMap(self.map_modele_test)
|
||||||
#overviewitem = QgsLayoutItemMapOverviewStack(self.position_map)
|
# overviewitem = QgsLayoutItemMapOverviewStack(self.position_map)
|
||||||
#map_overview = self.position_map.overview()
|
# map_overview = self.position_map.overview()
|
||||||
#map_overview.setLinkedMap(self.map_modele_test)
|
# map_overview.setLinkedMap(self.map_modele_test)
|
||||||
#map_overview.setCentered(True)
|
# map_overview.setCentered(True)
|
||||||
#overviewitem.addOverview(map_overview)
|
# overviewitem.addOverview(map_overview)
|
||||||
|
|
||||||
self.position_map.refresh()
|
self.position_map.refresh()
|
||||||
self.map_modele_test.setFrameEnabled(True)
|
self.map_modele_test.setFrameEnabled(True)
|
||||||
@ -525,7 +537,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.layout.addLayoutItem(self.map_modele_test)
|
self.layout.addLayoutItem(self.map_modele_test)
|
||||||
self.map_modele_test.setId("carte_principale")
|
self.map_modele_test.setId("carte_principale")
|
||||||
|
|
||||||
## Ajout d'un titre à la mise en page
|
# Ajout d'un titre à la mise en page
|
||||||
title = QgsLayoutItemLabel(self.layout)
|
title = QgsLayoutItemLabel(self.layout)
|
||||||
self.layout.addLayoutItem(title)
|
self.layout.addLayoutItem(title)
|
||||||
titre = titre_layout_name
|
titre = titre_layout_name
|
||||||
@ -542,8 +554,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
title.setHAlign(Qt.AlignmentFlag(0x0004))
|
title.setHAlign(Qt.AlignmentFlag(0x0004))
|
||||||
title.setVAlign(Qt.AlignmentFlag(0x0080))
|
title.setVAlign(Qt.AlignmentFlag(0x0080))
|
||||||
|
|
||||||
|
# Ajout d'un sous titre à la mise en page
|
||||||
## Ajout d'un sous titre à la mise en page
|
|
||||||
subtitle = QgsLayoutItemLabel(self.layout)
|
subtitle = QgsLayoutItemLabel(self.layout)
|
||||||
self.layout.addLayoutItem(subtitle)
|
self.layout.addLayoutItem(subtitle)
|
||||||
titre = self.lineEdit_3.text()
|
titre = self.lineEdit_3.text()
|
||||||
@ -561,20 +572,18 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
subtitle.setHAlign(Qt.AlignmentFlag(0x0004))
|
subtitle.setHAlign(Qt.AlignmentFlag(0x0004))
|
||||||
subtitle.setVAlign(Qt.AlignmentFlag(0x0080))
|
subtitle.setVAlign(Qt.AlignmentFlag(0x0080))
|
||||||
|
|
||||||
|
# Ajout du logo CEN NA en haut à gauche de la page
|
||||||
## Ajout du logo CEN NA en haut à gauche de la page
|
|
||||||
logo = QgsLayoutItemPicture(self.layout)
|
logo = QgsLayoutItemPicture(self.layout)
|
||||||
logo.setResizeMode(QgsLayoutItemPicture.Zoom)
|
logo.setResizeMode(QgsLayoutItemPicture.Zoom)
|
||||||
logo.setMode(QgsLayoutItemPicture.FormatRaster)
|
logo.setMode(QgsLayoutItemPicture.FormatRaster)
|
||||||
logo.setItemRotation(self.template_parameters['Logo_rotate'])
|
logo.setItemRotation(self.template_parameters['Logo_rotate'])
|
||||||
logo.setFixedSize(self.template_parameters['Logo_size'])
|
logo.setFixedSize(self.template_parameters['Logo_size'])
|
||||||
logo.attemptMove(self.template_parameters['Logo_locals'])
|
logo.attemptMove(self.template_parameters['Logo_locals'])
|
||||||
logo.setPicturePath(resources_path("icons","CEN_RA.png"))
|
logo.setPicturePath(resources_path("icons", "CEN_RA.png"))
|
||||||
logo.setId('logo')
|
logo.setId('logo')
|
||||||
self.layout.addLayoutItem(logo)
|
self.layout.addLayoutItem(logo)
|
||||||
|
|
||||||
|
# Ajout de la legende :
|
||||||
## Ajout de la legende :
|
|
||||||
legend = QgsLayoutItemLegend(self.layout)
|
legend = QgsLayoutItemLegend(self.layout)
|
||||||
|
|
||||||
legend.setId('legende_model1')
|
legend.setId('legende_model1')
|
||||||
@ -619,7 +628,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
layertreelayer = root.findLayer(layer.id())
|
layertreelayer = root.findLayer(layer.id())
|
||||||
|
|
||||||
# get the parent of the layer tree layer (layer tree root, or group)
|
# get the parent of the layer tree layer (layer tree root, or group)
|
||||||
if layertreelayer != None:
|
if layertreelayer is not None:
|
||||||
parent = layertreelayer.parent()
|
parent = layertreelayer.parent()
|
||||||
|
|
||||||
# if the parent is a group and has a name, find it and remove the layer
|
# if the parent is a group and has a name, find it and remove the layer
|
||||||
@ -630,7 +639,6 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
else:
|
else:
|
||||||
root_group.removeLayer(layer)
|
root_group.removeLayer(layer)
|
||||||
|
|
||||||
|
|
||||||
legend.setEqualColumnWidth(True)
|
legend.setEqualColumnWidth(True)
|
||||||
legend.setSplitLayer(True)
|
legend.setSplitLayer(True)
|
||||||
legend.setColumnSpace(5)
|
legend.setColumnSpace(5)
|
||||||
@ -647,7 +655,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
legend.updateLegend()
|
legend.updateLegend()
|
||||||
legend.attemptMove(self.template_parameters['Legande_locals'])
|
legend.attemptMove(self.template_parameters['Legande_locals'])
|
||||||
|
|
||||||
## Ajout de l'échelle numeric à la mise en page
|
# Ajout de l'échelle numeric à la mise en page
|
||||||
self.scalebarnumeric_qpt = QgsLayoutItemScaleBar(self.layout)
|
self.scalebarnumeric_qpt = QgsLayoutItemScaleBar(self.layout)
|
||||||
self.scalebarnumeric_qpt.setStyle('Numeric')
|
self.scalebarnumeric_qpt.setStyle('Numeric')
|
||||||
self.scalebarnumeric_qpt.setLinkedMap(self.map_modele_test)
|
self.scalebarnumeric_qpt.setLinkedMap(self.map_modele_test)
|
||||||
@ -667,7 +675,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
self.layout.addLayoutItem(self.scalebarnumeric_qpt)
|
self.layout.addLayoutItem(self.scalebarnumeric_qpt)
|
||||||
|
|
||||||
## Ajout de l'échelle à la mise en page
|
# Ajout de l'échelle à la mise en page
|
||||||
self.scalebar_qpt = QgsLayoutItemScaleBar(self.layout)
|
self.scalebar_qpt = QgsLayoutItemScaleBar(self.layout)
|
||||||
self.scalebar_qpt.setStyle('Single Box')
|
self.scalebar_qpt.setStyle('Single Box')
|
||||||
self.scalebar_qpt.setLinkedMap(self.map_modele_test)
|
self.scalebar_qpt.setLinkedMap(self.map_modele_test)
|
||||||
@ -690,7 +698,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
# ajout de la fleche du Nord
|
# ajout de la fleche du Nord
|
||||||
north = QgsLayoutItemPicture(self.layout)
|
north = QgsLayoutItemPicture(self.layout)
|
||||||
north.setPicturePath(resources_path("mises_en_pages","NorthArrow_02.svg"))
|
north.setPicturePath(resources_path("mises_en_pages", "NorthArrow_02.svg"))
|
||||||
self.layout.addLayoutItem(north)
|
self.layout.addLayoutItem(north)
|
||||||
north.attemptMove(self.template_parameters['Arrow_locals'])
|
north.attemptMove(self.template_parameters['Arrow_locals'])
|
||||||
north.attemptResize(self.template_parameters['Arrow_size'])
|
north.attemptResize(self.template_parameters['Arrow_size'])
|
||||||
@ -701,16 +709,16 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
if self.radioButton_10.isChecked() == 1:
|
if self.radioButton_10.isChecked() == 1:
|
||||||
text_source = ' '
|
text_source = ' '
|
||||||
for Item_mComboBox_3 in self.mComboBox_3.checkedItems():
|
for Item_mComboBox_3 in self.mComboBox_3.checkedItems():
|
||||||
text_source = text_source+Item_mComboBox_3+','
|
text_source = text_source + Item_mComboBox_3 + ','
|
||||||
text_source = text_source[:-1]
|
text_source = text_source[:-1]
|
||||||
info_text = ["Source :" + text_source][0]
|
info_text = ["Source :" + text_source][0]
|
||||||
else:
|
else:
|
||||||
info_text = ["Source : " + self.lineEdit_4.text()][0]
|
info_text = ["Source : " + self.lineEdit_4.text()][0]
|
||||||
# ajout note info:
|
# ajout note info:
|
||||||
if self.radioButton_14.isChecked() == 1:
|
if self.radioButton_14.isChecked() == 1:
|
||||||
self.s.setValue("automap/prenom_nom",self.lineEdit_5.text())
|
self.s.setValue("automap/prenom_nom", self.lineEdit_5.text())
|
||||||
prenom_nom = self.s.value("automap/prenom_nom", 1, type=str)
|
prenom_nom = self.s.value("automap/prenom_nom", 1, type=str)
|
||||||
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ") par "+prenom_nom]
|
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ") par " + prenom_nom]
|
||||||
else:
|
else:
|
||||||
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ")"]
|
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ")"]
|
||||||
credit_text = QgsLayoutItemLabel(self.layout)
|
credit_text = QgsLayoutItemLabel(self.layout)
|
||||||
@ -736,7 +744,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.layout.addLayoutItem(credit_text)
|
self.layout.addLayoutItem(credit_text)
|
||||||
self.layout.addLayoutItem(credit_text2)
|
self.layout.addLayoutItem(credit_text2)
|
||||||
|
|
||||||
## Ajout du logo credit en bas à droit de la page
|
# Ajout du logo credit en bas à droit de la page
|
||||||
len_item = (len(self.mComboBox_4.checkedItems()))
|
len_item = (len(self.mComboBox_4.checkedItems()))
|
||||||
for logo_run in self.mComboBox_4.checkedItems():
|
for logo_run in self.mComboBox_4.checkedItems():
|
||||||
logo_credit = QgsLayoutItemPicture(self.layout)
|
logo_credit = QgsLayoutItemPicture(self.layout)
|
||||||
@ -745,14 +753,14 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
cur_x = self.template_parameters['Logo_2_locals'].x()
|
cur_x = self.template_parameters['Logo_2_locals'].x()
|
||||||
logo_credit.attemptMove(self.template_parameters['Logo_2_locals'])
|
logo_credit.attemptMove(self.template_parameters['Logo_2_locals'])
|
||||||
print(logo_credit.pictureAnchor())
|
print(logo_credit.pictureAnchor())
|
||||||
#logo_credit.setPictureAnchor(4)
|
# logo_credit.setPictureAnchor(4)
|
||||||
self.template_parameters['Logo_2_locals'].setX(cur_x+(logo_div/len_item))
|
self.template_parameters['Logo_2_locals'].setX(cur_x + (logo_div / len_item))
|
||||||
logo_credit.setFixedSize(self.template_parameters['Logo_2_size'])
|
logo_credit.setFixedSize(self.template_parameters['Logo_2_size'])
|
||||||
if logo_run[0] == ' ':
|
if logo_run[0] == ' ':
|
||||||
logo_credit.setPicturePath(self.s.value("automap/logoteck", 1, type=str)+logo_run[1:])
|
logo_credit.setPicturePath(self.s.value("automap/logoteck", 1, type=str) + logo_run[1:])
|
||||||
else:
|
else:
|
||||||
logo_credit.setPicturePath(resources_path("logo_library",logo_run))
|
logo_credit.setPicturePath(resources_path("logo_library", logo_run))
|
||||||
logo_credit.setId('logo_'+logo_run)
|
logo_credit.setId('logo_' + logo_run)
|
||||||
logo_credit.setBackgroundEnabled(True)
|
logo_credit.setBackgroundEnabled(True)
|
||||||
logo_credit.setBackgroundColor(QColor(255, 255, 255, 130))
|
logo_credit.setBackgroundColor(QColor(255, 255, 255, 130))
|
||||||
self.layout.addLayoutItem(logo_credit)
|
self.layout.addLayoutItem(logo_credit)
|
||||||
@ -767,33 +775,31 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.QMBquestion.setWindowTitle(u"Attention !")
|
self.QMBquestion.setWindowTitle(u"Attention !")
|
||||||
self.QMBquestion.setIcon(QMessageBox.Icon.Warning)
|
self.QMBquestion.setIcon(QMessageBox.Icon.Warning)
|
||||||
self.QMBquestion.setText("Mise en page existante, la mise en page va être écrasée !")
|
self.QMBquestion.setText("Mise en page existante, la mise en page va être écrasée !")
|
||||||
self.QMBquestion.setStandardButtons(QMessageBox.StandardButton(0x00004000)|QMessageBox.StandardButton(0x00010000))
|
self.QMBquestion.setStandardButtons(QMessageBox.StandardButton(0x00004000) | QMessageBox.StandardButton(0x00010000))
|
||||||
self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.ButtonRole(0))
|
self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.ButtonRole(0))
|
||||||
self.QMBquestion = self.QMBquestion.exec()
|
self.QMBquestion = self.QMBquestion.exec()
|
||||||
|
|
||||||
#if self.radioButton_12.isChecked() != 1:
|
# if self.radioButton_12.isChecked() != 1:
|
||||||
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
|
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
|
||||||
project.layoutManager().removeLayout(existing_layout)
|
project.layoutManager().removeLayout(existing_layout)
|
||||||
result = project.layoutManager().addLayout(self.layout)
|
result = project.layoutManager().addLayout(self.layout)
|
||||||
elif self.QMBquestion != QMessageBox.StandardButton(0x00010000):
|
elif self.QMBquestion != QMessageBox.StandardButton(0x00010000):
|
||||||
LayoutCOUNT=0
|
LayoutCOUNT = 0
|
||||||
arrayManager = []
|
arrayManager = []
|
||||||
for AddArrayManager in project.layoutManager().layouts():
|
for AddArrayManager in project.layoutManager().layouts():
|
||||||
arrayManager.append(AddArrayManager.name())
|
arrayManager.append(AddArrayManager.name())
|
||||||
arrayManager.sort()
|
arrayManager.sort()
|
||||||
for LayoutNAME in arrayManager:
|
for LayoutNAME in arrayManager:
|
||||||
if LayoutNAME == layout_name:
|
if LayoutNAME == layout_name:
|
||||||
LayoutCOUNT = LayoutCOUNT+1
|
LayoutCOUNT = LayoutCOUNT + 1
|
||||||
if LayoutNAME == layout_name+"¶"+str(LayoutCOUNT):
|
if LayoutNAME == layout_name + "¶" + str(LayoutCOUNT):
|
||||||
LayoutCOUNT=LayoutCOUNT+1
|
LayoutCOUNT = LayoutCOUNT + 1
|
||||||
layout_name = (layout_name+"¶"+str(LayoutCOUNT))
|
layout_name = (layout_name + "¶" + str(LayoutCOUNT))
|
||||||
self.layout.setName(layout_name)
|
self.layout.setName(layout_name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
existing_layout = True
|
existing_layout = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.manager.addLayout(self.layout)
|
self.manager.addLayout(self.layout)
|
||||||
if self.radioButton_9.isChecked() == 1:
|
if self.radioButton_9.isChecked() == 1:
|
||||||
self.layout.atlas().setEnabled(True)
|
self.layout.atlas().setEnabled(True)
|
||||||
@ -811,10 +817,10 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
else:
|
else:
|
||||||
TryMessage = False
|
TryMessage = False
|
||||||
del self.QMBquestion
|
del self.QMBquestion
|
||||||
except:
|
except NameError:
|
||||||
TryMessage = True
|
TryMessage = True
|
||||||
|
|
||||||
if TryMessage == True:
|
if TryMessage is True:
|
||||||
iface.openLayoutDesigner(layout_modifie)
|
iface.openLayoutDesigner(layout_modifie)
|
||||||
self.close()
|
self.close()
|
||||||
else:
|
else:
|
||||||
@ -844,15 +850,14 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
eval("exec('self.template_parameters = '+ values_page_import + '.fletch_canvas(self)')")
|
eval("exec('self.template_parameters = '+ values_page_import + '.fletch_canvas(self)')")
|
||||||
|
|
||||||
def bar_echelle_auto(self, echelle, bar_echelle):
|
def bar_echelle_auto(self, echelle, bar_echelle):
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
if echelle.scale() >= 40000:
|
if echelle.scale() >= 40000:
|
||||||
bar_echelle.setUnits(QgsUnitTypes.DistanceKilometers)
|
bar_echelle.setUnits(QgsUnitTypes.DistanceKilometers)
|
||||||
bar_echelle.setUnitLabel("km")
|
bar_echelle.setUnitLabel("km")
|
||||||
bar_echelle.setUnitsPerSegment(round((echelle.scale()*0.04)/1000))
|
bar_echelle.setUnitsPerSegment(round((echelle.scale() * 0.04) / 1000))
|
||||||
else:
|
else:
|
||||||
bar_echelle.setUnits(QgsUnitTypes.DistanceMeters)
|
bar_echelle.setUnits(QgsUnitTypes.DistanceMeters)
|
||||||
bar_echelle.setUnitLabel("m")
|
bar_echelle.setUnitLabel("m")
|
||||||
bar_echelle.setUnitsPerSegment(round(echelle.scale()*0.04))
|
bar_echelle.setUnitsPerSegment(round(echelle.scale() * 0.04))
|
||||||
|
|
||||||
bar_echelle.update()
|
bar_echelle.update()
|
||||||
|
|||||||
@ -1,10 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
plugin_dir = os.path.dirname(__file__)
|
|
||||||
end_find = plugin_dir.rfind('\\')+1
|
|
||||||
|
|
||||||
NAME = plugin_dir[end_find:]
|
|
||||||
#print(NAME)
|
|
||||||
|
|
||||||
from qgis.gui import *
|
from qgis.gui import *
|
||||||
|
|
||||||
from qgis.core import (
|
from qgis.core import (
|
||||||
@ -27,7 +21,7 @@ from qgis.PyQt.QtWidgets import (
|
|||||||
QInputDialog,
|
QInputDialog,
|
||||||
QMenu,
|
QMenu,
|
||||||
QToolButton,
|
QToolButton,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
)
|
)
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
@ -35,21 +29,27 @@ from qgis.utils import iface
|
|||||||
|
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
resources_path,
|
# resources_path,
|
||||||
send_issues,
|
send_issues,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
plugin_dir = os.path.dirname(__file__)
|
||||||
|
end_find = plugin_dir.rfind('\\') + 1
|
||||||
|
|
||||||
|
NAME = plugin_dir[end_find:]
|
||||||
|
# print(NAME)
|
||||||
|
|
||||||
EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui')
|
EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui')
|
||||||
|
|
||||||
class CenRa_Issues(QDialog, EDITOR_CLASS):
|
|
||||||
|
|
||||||
|
class CenRa_Issues(QDialog, EDITOR_CLASS):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
_ = parent
|
_ = parent
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.settings = QgsSettings()
|
self.settings = QgsSettings()
|
||||||
|
|
||||||
#place connect here
|
# place connect here
|
||||||
self.annuler_button.clicked.connect(self.close)
|
self.annuler_button.clicked.connect(self.close)
|
||||||
self.ok_button.clicked.connect(self.run_sendissues)
|
self.ok_button.clicked.connect(self.run_sendissues)
|
||||||
|
|
||||||
@ -63,17 +63,22 @@ class CenRa_Issues(QDialog, EDITOR_CLASS):
|
|||||||
statu_autre = self.check_autre.isChecked()
|
statu_autre = self.check_autre.isChecked()
|
||||||
|
|
||||||
statu = []
|
statu = []
|
||||||
if statu_bug == True : statu = statu + [1]
|
if statu_bug is True:
|
||||||
if statu_aide == True : statu = statu + [3]
|
statu = statu + [1]
|
||||||
if statu_question == True : statu = statu + [5]
|
if statu_aide is True:
|
||||||
if statu_amelioration == True : statu = statu + [2]
|
statu = statu + [3]
|
||||||
if statu_autre == True : statu = statu + [6]
|
if statu_question is True:
|
||||||
|
statu = statu + [5]
|
||||||
|
if statu_amelioration is True:
|
||||||
|
statu = statu + [2]
|
||||||
|
if statu_autre is True:
|
||||||
|
statu = statu + [6]
|
||||||
|
|
||||||
if len(statu) >= 1:
|
if len(statu) >= 1:
|
||||||
import qgis
|
import qgis
|
||||||
url = qgis.utils.pluginMetadata(NAME,'tracker')
|
url = qgis.utils.pluginMetadata(NAME, 'tracker')
|
||||||
print(text_message)
|
print(text_message)
|
||||||
send_info = send_issues(url,text_titre,text_message,statu)
|
send_info = send_issues(url, text_titre, text_message, statu)
|
||||||
code = send_info.status_code
|
code = send_info.status_code
|
||||||
print(code)
|
print(code)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user