diff --git a/.gitignore b/.gitignore index da4e3f2c..443e01e4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ !CenRa_METABASE/ !CenRa_POSTGIS/ !CenRa_SICEN/ +!CenRa_PAGERENDER/ #ReIgnore **/__pycache__ diff --git a/CenRa_PAGERENDER/CenRa_PageRender.py b/CenRa_PAGERENDER/CenRa_PageRender.py new file mode 100644 index 00000000..6b49c3f7 --- /dev/null +++ b/CenRa_PAGERENDER/CenRa_PageRender.py @@ -0,0 +1,142 @@ +__copyright__ = "Copyright 2021, 3Liz" +__license__ = "GPL version 3" +__email__ = "info@3liz.org" + + +from qgis.core import QgsApplication +from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl +from qgis.PyQt.QtGui import QDesktopServices, QIcon +from qgis.PyQt.QtWidgets import QAction, QMessageBox +from qgis.utils import iface +import qgis + + +#include +''' +from pg_metadata.connection_manager import ( + store_connections, + validate_connections_names, +) + + +from pg_metadata.locator import LocatorFilter +from pg_metadata.processing.provider import PgMetadataProvider +from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger +''' +import os +from .tools.resources import ( + plugin_path, + resources_path, + maj_verif, +) +from .canvas_editor import PageRender_Editor +from .about_form import PageRenderAboutDialog + +from PyQt5.QtCore import * + +class PgPageRender: + def __init__(self): + """ Constructor. """ + self.canvas_editor = None +# self.issues = None + self.provider = None + self.locator_filter = None + self.dock_action = None + self.help_action = None + plugin_dir = os.path.dirname(__file__) + end_find = plugin_dir.rfind('\\')+1 + global NAME + NAME = plugin_dir[end_find:] + maj_verif(NAME) + + # Display About window on first use + version = qgis.utils.pluginMetadata('CenRa_PAGERENDER','version') + s = QSettings() + versionUse = s.value("pagerender/version", 1, type=str) + if str(versionUse) != str(version) : + s.setValue("pagerender/version", str(version)) + print(versionUse,version) + self.open_about_dialog() + + def initGui(self): + """ Build the plugin GUI. """ + + self.toolBar = iface.addToolBar("CenRa_PAGERENDER") + self.toolBar.setObjectName("CenRa_PAGERENDER") + + icon = QIcon(resources_path('icons', 'icon.png')) + + # Open the online help + self.help_action = QAction(icon, 'CenRa_PAGERENDER', iface.mainWindow()) + iface.pluginHelpMenu().addAction(self.help_action) + self.help_action.triggered.connect(self.open_help) + if not self.canvas_editor: + self.canvas_editor = PageRender_Editor() + + + self.pagerender_action = QAction(icon, 'CenRa_PAGERENDER',None) + self.toolBar.addAction(self.pagerender_action) + self.pagerender_action.triggered.connect(self.open_editor) + ''' + if not self.locator_filter: + self.locator_filter = LocatorFilter(iface) + iface.registerLocatorFilter(self.locator_filter) + + @staticmethod + def check_invalid_connection_names(): + """ Check for invalid connection names in the QgsSettings. """ + valid, invalid = validate_connections_names() + n_invalid = len(invalid) + + if n_invalid == 0: + return + + invalid_text = ', '.join(invalid) + msg = QMessageBox() + msg.setIcon(QMessageBox.Warning) + msg.setWindowTitle(tr('PgMetadata: Database connection(s) not available')) + msg.setText(tr( + f'{n_invalid} connection(s) listed in PgMetadata’s settings are invalid or ' + f'no longer available: {invalid_text}')) + msg.setInformativeText(tr( + 'Do you want to remove these connection(s) from the PgMetadata settings? ' + '(You can also do this later with the “Set Connections” tool.)')) + msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + clicked = msg.exec() + + if clicked == QMessageBox.Yes: + iface.messageBar().pushSuccess('PgMetadata', tr(f'{n_invalid} invalid connection(s) removed.')) + store_connections(valid) + if clicked == QMessageBox.No: + iface.messageBar().pushInfo('PgMetadata', tr(f'Keeping {n_invalid} invalid connections.')) + ''' + def open_about_dialog(self): + """ + About dialog + """ + dialog = PageRenderAboutDialog(iface) + dialog.exec_() + def open_help(): + """ Open the online help. """ + QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) + + def open_editor(self): + self.canvas_editor.show() + self.canvas_editor.raise_() + + def unload(self): + """ Unload the plugin. """ + if self.canvas_editor: + iface.removePluginMenu('CenRa_PAGERENDER',self.pagerender_action) + + if self.provider: + QgsApplication.processingRegistry().removeProvider(self.provider) + del self.provider + + if self.locator_filter: + iface.deregisterLocatorFilter(self.locator_filter) + del self.locator_filter + + if self.help_action: + iface.pluginHelpMenu().removeAction(self.help_action) + del self.help_action diff --git a/CenRa_PAGERENDER/README.md b/CenRa_PAGERENDER/README.md new file mode 100644 index 00000000..80ccffeb --- /dev/null +++ b/CenRa_PAGERENDER/README.md @@ -0,0 +1 @@ +# CenRa_AutoMap \ No newline at end of file diff --git a/CenRa_PAGERENDER/__init__.py b/CenRa_PAGERENDER/__init__.py new file mode 100644 index 00000000..365e0900 --- /dev/null +++ b/CenRa_PAGERENDER/__init__.py @@ -0,0 +1,10 @@ +__copyright__ = "Copyright 2021, 3Liz" +__license__ = "GPL version 3" +__email__ = "info@3liz.org" + + +# noinspection PyPep8Naming +def classFactory(iface): # pylint: disable=invalid-name + _ = iface + from CenRa_PAGERENDER.CenRa_PageRender import PgPageRender + return PgPageRender() diff --git a/CenRa_PAGERENDER/about_form.py b/CenRa_PAGERENDER/about_form.py new file mode 100644 index 00000000..57827e54 --- /dev/null +++ b/CenRa_PAGERENDER/about_form.py @@ -0,0 +1,46 @@ +import os.path + +from pathlib import Path + +from qgis.PyQt import uic +from qgis.PyQt.QtGui import QPixmap +from qgis.PyQt.QtWidgets import QDialog + +from .tools.resources import devlog + +ABOUT_FORM_CLASS, _ = uic.loadUiType( + os.path.join( + str(Path(__file__).resolve().parent), + 'tools/ui', + 'CenRa_PageRender_about_form.ui' + ) +) + + +class PageRenderAboutDialog(QDialog, ABOUT_FORM_CLASS): + + """ About - Let the user display the about dialog. """ + + def __init__(self, iface, parent=None): + super().__init__(parent) + self.iface = iface + self.setupUi(self) + + self.viewer.setHtml(devlog('CenRa_PAGERENDER')) + + self.rejected.connect(self.onReject) + self.buttonBox.rejected.connect(self.onReject) + self.buttonBox.accepted.connect(self.onAccept) + + def onAccept(self): + """ + Save options when pressing OK button + """ + self.accept() + + def onReject(self): + """ + Run some actions when + the user closes the dialog + """ + self.close() \ No newline at end of file diff --git a/CenRa_PAGERENDER/canvas_editor.py b/CenRa_PAGERENDER/canvas_editor.py new file mode 100644 index 00000000..929131ec --- /dev/null +++ b/CenRa_PAGERENDER/canvas_editor.py @@ -0,0 +1,473 @@ +import logging +import os +from PyQt5.QtCore import QSettings +from collections import namedtuple +from enum import Enum +from functools import partial +from pathlib import Path +from xml.dom.minidom import parseString +from qgis.gui import * +import qgis +from qgis.core import ( + NULL, + QgsApplication, + QgsScaleBarSettings, + QgsDataSourceUri, + QgsProject, + QgsProviderConnectionException, + QgsProviderRegistry, + QgsRasterLayer, + QgsSettings, + QgsVectorLayer, + QgsGeometry, + QgsPrintLayout, + QgsReadWriteContext, + QgsLayoutItemMap, + QgsLayoutItemPage, + QgsLayoutSize, + QgsUnitTypes, + QgsLayoutPoint, + QgsLayoutItemLabel, + QgsLayoutItemPicture, + QgsLayoutItemLegend, + QgsLegendStyle, + QgsLayoutItemScaleBar, + QgsLayerTreeGroup, + QgsCoordinateReferenceSystem, + QgsCoordinateTransform, + QgsLayerTree, + QgsLayoutTableColumn, + QgsRectangle, + QgsLayoutItemMapOverviewStack, +) +from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt +from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie +from qgis.PyQt.QtPrintSupport import QPrinter +from qgis.PyQt.QtWebKitWidgets import QWebPage +from qgis.PyQt.QtWidgets import ( + QDialog, + QAction, + QDockWidget, + QFileDialog, + QInputDialog, + QMenu, + QToolButton, + QTableWidget, + QTableWidgetItem, + QVBoxLayout, +) +from PyQt5 import QtGui +from qgis.PyQt.QtXml import QDomDocument +from qgis.utils import iface +import glob +from .tools.resources import ( + load_ui, + resources_path, + login_base, + send_issues, +) +from .issues import CenRa_Issues +from datetime import date +last_select = None + +EDITOR_CLASS = load_ui('CenRa_PageRender_base.ui') +LOGGER = logging.getLogger('CenRa_PageRender') +url_osm = 'https://osm.datagrandest.fr/mapcache/?crs=EPSG:2154&featureCount=10&format=image/png&layers=pure&maxHeight=256&maxWidth=256&styles=&url=https://osm.datagrandest.fr/mapcache' +url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&format=image/jpeg&layers=ortho&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/ortho/service' +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' +data_source = [ +'CENRA', +'IGN', +'CRAIG', +'OpenStreetMap', +'Sandre', +'BRGM', +'MUSÉUM NATIONAL D’HISTOIRE NATURELLE', +"Muséum national d'Histoire naturelle", +'ONF', +'20xx LPO', +'ofb.gouv.fr', +'Stamen Design', +'MTES', +'MTES', +'FEDER', +'DREAL Auvergne-Rhône-Alpes', +'INSEE', +'DGFiP', +'Fédération des Conservatoires d’espaces naturels', +'Plan cadastral informatisé - Etalab - juillet 202X', +'Parcellaire Express - IGN - 202X', +] +class PageRender_Editor(QDialog, EDITOR_CLASS): + + def __init__(self, parent=None): + _ = parent + super().__init__() + self.setupUi(self) + self.settings = QgsSettings() + self.s = QSettings() + + self.varLandscape = {} + self.varPortrait = {} + self.rotate_object = { + 'Titre':0, + 'Sous_titre':0, + 'Carte':0, + 'Carte_2':0, + 'Legande':0, + 'Arrow':0, + 'Echelle':0, + 'Logo':0, + 'Credit':0, + 'Source':0, + 'Echelle_2':0, + 'Logo_2':0,} + + path = '' + ix = 0 + plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep) + for i in plugin_dir: + ix = ix+1 + path = path+'\\'+i + self.path = path[1:]+'\\demoV2.py' + + #self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);') + + self.horizontalSlider.valueChanged.connect(self.horizontal) + self.verticalSlider.valueChanged.connect(self.vertical) + self.tableWidget.itemSelectionChanged.connect(self.setSlider) + self.radioButton.toggled.connect(self.setSlider) + self.pushButton.clicked.connect(self.export) + self.spinBox.editingFinished.connect(self.valueSlider) + self.spinBox_2.editingFinished.connect(self.valueSlider) + self.toolButton.clicked.connect(self.rotate) + self.toolButton_2.clicked.connect(self.type_page) + self.pushButton_2.clicked.connect(self.load) + + def raise_(self): + self.activateWindow() + self.setNavigator() + + def select_file(self): + options = QFileDialog.Options() + options |= QFileDialog.ShowDirsOnly + folder = QFileDialog.getOpenFileName(self, "Sélection du fichier ",'','Python(*.py)') + if folder[0] != '': + return folder[0] + else: + return '' + def load(self): + folder = self.select_file() + logopath = folder + if logopath != '': + #logopath = (os.path.dirname(logopath).split('/')) + sourcefile = open(logopath, 'r') + splitsource = sourcefile.read().splitlines() + all_children = self.frame.children() + all_element = ['_locals','_size','_rotate'] + for children in all_children: + flen = 0 + for element in all_element: + flen = 0 + recherche_element = children.objectName()+element + for find_it in splitsource: + if find_it.find(recherche_element) != -1: + flen = flen+1 + if flen == 1: + if element != '_rotate': + value_find = (find_it[find_it[:].find('(')+1:-33]).split(',') + if element == '_size': + Psize_h = float(value_find[0])*3.5 + Psize_w = float(value_find[1])*3.5 + if element == '_locals': + Plocals_h = float(value_find[0])*3.5 + Plocals_w = float(value_find[1])*3.5 + else: + Protate = float((find_it[find_it[:].find('=')+2:]).split(',')[0]) + if flen == 3: + if element != '_rotate': + value_find = (find_it[find_it[:].find('(')+1:-33]).split(',') + if element == '_size': + Lsize_h = float(value_find[0])*3.5 + Lsize_w = float(value_find[1])*3.5 + if element == '_locals': + Llocals_h = float(value_find[0])*3.5 + Llocals_w = float(value_find[1])*3.5 + else: + Lrotate = float((find_it[find_it[:].find('=')+2:]).split(',')[0]) + #print('sh',Psize_h,',sw',Psize_w,',lh',Plocals_h,',lw',Plocals_w,',r',Protate) + match Lrotate: + case 90|270: + old = Lsize_w + Lsize_w = Lsize_h + Lsize_h = old + match Protate: + case 90|270: + old = Psize_w + Psize_w = Psize_h + Psize_h = old + if self.toolButton_2.text() == 'Landscape': + children.resize(round(Lsize_h),round(Lsize_w)) + children.move(round(Llocals_h),round(Llocals_w)) + self.rotate_object[children.objectName()] = Lrotate + if self.toolButton_2.text() == 'Portrait': + children.resize(round(Psize_h),round(Psize_w)) + children.move(round(Plocals_h),round(Plocals_w)) + self.rotate_object[children.objectName()] = Protate + + def valueSlider(self): + self.horizontalSlider.setValue(self.spinBox.value()) + self.verticalSlider.setValue(self.spinBox_2.value()) + + def setNavigator(self): + all_children = self.frame.children() + xR=0 + baseRow = self.tableWidget.rowCount() + while baseRow >= xR: + self.tableWidget.removeRow(0) + xR = xR+1 + self.tableWidget.clear() + id=0 + for children in all_children: + position = self.tableWidget.rowCount() + self.tableWidget.insertRow(position) + self.tableWidget.setItem(position,0,QTableWidgetItem(children.objectName())) + #print(children.objectName()) + def export(self): + self.type_page() + self.type_page() + all_children = self.frame.children() + #selection_name = (self.tableWidget.currentItem()).text() + export_str = """ +from qgis.core import ( + QgsLayoutSize, + QgsUnitTypes, + QgsLayoutPoint, +) +def fletch_canvas(self): + if self.radioButton_6.isChecked(): + values_page = 'A4' + else: + values_page = 'A3' + if self.radioButton_7.isChecked(): + page_rotate = 'Portrait' + else: + page_rotate = 'Landscape' +""" + + type = ["Portrait","Landscape"] + page = ["A4","A3"] + for page_type in type: + export_str = export_str+""" + if page_rotate == '"""+page_type+"""':""" + for page_size in page: + export_str = export_str+""" + if values_page == '"""+page_size+"""':""" + for children in all_children: + selection = children + if page_type == 'Portrait': + item_rotate_object=self.varPortrait[selection.objectName()+'_rotate'][0] + match item_rotate_object: + case 0|180: + sw = 0 + sh = 1 + case 90|270: + sw = 1 + sh = 0 + if page_size == 'A3': + size_w = (round((self.varPortrait[selection.objectName()+'_size'][sw]/3.5)*1.41)) + size_h = (round((self.varPortrait[selection.objectName()+'_size'][sh]/3.5)*1.41)) + locals_w = (round((self.varPortrait[selection.objectName()+'_locals'][1]/3.5)*1.41)) + locals_h = (round((self.varPortrait[selection.objectName()+'_locals'][0]/3.5)*1.41)) + else: + size_w = (round(self.varPortrait[selection.objectName()+'_size'][sw])/3.5) + size_h = (round(self.varPortrait[selection.objectName()+'_size'][sh]/3.5)) + locals_w = (round(self.varPortrait[selection.objectName()+'_locals'][1]/3.5)) + locals_h = (round(self.varPortrait[selection.objectName()+'_locals'][0]/3.5)) + if page_type == 'Landscape': + item_rotate_object=self.varLandscape[selection.objectName()+'_rotate'][0] + match item_rotate_object: + case 0|180: + sw = 0 + sh = 1 + case 90|270: + sw = 1 + sh = 0 + if page_size == 'A3': + size_w = (round((self.varLandscape[selection.objectName()+'_size'][sw]/3.5)*1.41)) + size_h = (round((self.varLandscape[selection.objectName()+'_size'][sh]/3.5)*1.41)) + locals_w = (round((self.varLandscape[selection.objectName()+'_locals'][1]/3.5)*1.41)) + locals_h = (round((self.varLandscape[selection.objectName()+'_locals'][0]/3.5)*1.41)) + else: + size_w = (round(self.varLandscape[selection.objectName()+'_size'][sw])/3.5) + size_h = (round(self.varLandscape[selection.objectName()+'_size'][sh]/3.5)) + locals_w = (round(self.varLandscape[selection.objectName()+'_locals'][1]/3.5)) + locals_h = (round(self.varLandscape[selection.objectName()+'_locals'][0]/3.5)) + + if item_rotate_object == 270: + locals_h= locals_h + size_w + if item_rotate_object == 180: + locals_h= locals_h + size_h + locals_w= locals_w + size_w + + size_w = str(size_w) + size_h = str(size_h) + locals_w = str(locals_w) + locals_h = str(locals_h) + + export_str = export_str+""" + self.template_parameters['"""+selection.objectName()+"""_size'] = QgsLayoutSize("""+size_w+""","""+ size_h+""", QgsUnitTypes.LayoutMillimeters) + self.template_parameters['"""+selection.objectName()+"""_locals'] = QgsLayoutPoint("""+locals_w+""", """+locals_h+""", QgsUnitTypes.LayoutMillimeters) + self.template_parameters['"""+selection.objectName()+"""_rotate'] = """+str(item_rotate_object) + export_str= export_str+""" + return self.template_parameters""" + sourceFile = open(self.path,'w') + print(export_str, file = sourceFile) + sourceFile.close() + def type_page(self): + all_children = self.frame.children() + if self.toolButton_2.text() == 'Landscape': + last_children=0 + for children in all_children: + selection = children + size_w = selection.size().width() + size_h = selection.size().height() + locals_h = selection.x() + locals_w = selection.y() + item_rotate_object = self.rotate_object[selection.objectName()] + self.varLandscape[selection.objectName()+'_size'] = [size_w,size_h] + self.varLandscape[selection.objectName()+'_locals'] = [locals_w,locals_h] + self.varLandscape[selection.objectName()+'_rotate'] = [item_rotate_object] + if self.varPortrait != {}: + selection.move(self.varPortrait[selection.objectName()+'_locals'][1],self.varPortrait[selection.objectName()+'_locals'][0]) + selection.resize(self.varPortrait[selection.objectName()+'_size'][0],self.varPortrait[selection.objectName()+'_size'][1]) + self.rotate_object[selection.objectName()] = self.varPortrait[selection.objectName()+'_rotate'][0] + self.rotate_color(selection,last_children) + last_children = selection + self.toolButton_2.setText('Portrait') + elif self.toolButton_2.text() == 'Portrait': + last_children=0 + for children in all_children: + selection = children + size_w = selection.size().width() + size_h = selection.size().height() + locals_h = selection.x() + locals_w = selection.y() + item_rotate_object = self.rotate_object[selection.objectName()] + self.varPortrait[selection.objectName()+'_size'] = [size_w,size_h] + self.varPortrait[selection.objectName()+'_locals'] = [locals_w,locals_h] + self.varPortrait[selection.objectName()+'_rotate'] = [item_rotate_object] + if self.varLandscape != {}: + selection.move(self.varLandscape[selection.objectName()+'_locals'][1],self.varLandscape[selection.objectName()+'_locals'][0]) + selection.resize(self.varLandscape[selection.objectName()+'_size'][0],self.varLandscape[selection.objectName()+'_size'][1]) + self.rotate_object[selection.objectName()] = self.varLandscape[selection.objectName()+'_rotate'][0] + self.rotate_color(selection,last_children) + last_children = selection + self.toolButton_2.setText('Landscape') + frame_w = self.frame.width() + frame_h = self.frame.height() + self.frame.resize(frame_h,frame_w) + frame_x = round(frame_w / 3) + frame_y = self.frame.y() + self.frame.move(frame_x,frame_y) + def setSlider(self): + if self.tableWidget.currentItem() != None: + selection_name = (self.tableWidget.currentItem()).text() + all_children = self.frame.children() + selection = 0 + last_children = 0 + for children in all_children: + if last_select == children.objectName(): + last_children = children + if selection_name == children.objectName(): + selection = children + if selection != 0: + self.rotate_color(selection,last_children) + if self.radioButton.isChecked() == False: + xx = round(selection.x()/3.5) + yy = round(selection.y()/3.5) + else: + xx = round(selection.size().width()/3.5) + yy = round(selection.size().height()/3.5) + #print(xx,yy) + self.horizontalSlider.setValue(xx) + self.verticalSlider.setValue(yy) + self.spinBox.setValue(xx) + self.spinBox_2.setValue(yy) + + def rotate_color(self,selection,last_children): + global last_select + if self.rotate_object[selection.objectName()] == 0: + selection.setStyleSheet("border: 2px solid;border-color:red;border-bottom-color: blue;background-color: rgb(10, 10, 80, 50)") + elif self.rotate_object[selection.objectName()] == 90: + selection.setStyleSheet("border: 2px solid;border-color:red;border-left-color: blue;background-color: rgb(10, 10, 80, 50)") + elif self.rotate_object[selection.objectName()] == 180: + selection.setStyleSheet("border: 2px solid;border-color:red;border-top-color: blue;background-color: rgb(10, 10, 80, 50)") + elif self.rotate_object[selection.objectName()] == 270: + selection.setStyleSheet("border: 2px solid;border-color:red;border-right-color: blue;background-color: rgb(10, 10, 80, 50)") + if last_children != 0: + if last_select != selection.objectName(): + last_children.setStyleSheet("background-color: rgb(10, 10, 10, 50)") + + last_select = selection.objectName() + + def rotate(self): + if self.tableWidget.currentItem() != None: + selection_name = (self.tableWidget.currentItem()).text() + all_children = self.frame.children() + selection = 0 + last_children = 0 + for children in all_children: + if last_select == children.objectName(): + last_children = children + if selection_name == children.objectName(): + selection = children + if selection != 0: + xx = round(selection.size().width()) + yy = round(selection.size().height()) + selection.resize(round(yy),round(xx)) + if self.radioButton.isChecked() == True: + self.spinBox.setValue(yy) + self.spinBox_2.setValue(xx) + self.horizontalSlider.setValue(round(yy/3.5)) + self.verticalSlider.setValue(round(xx/3.5)) + + if self.rotate_object[selection.objectName()] == 270: + self.rotate_object[selection.objectName()] = 0 + else: + self.rotate_object[selection.objectName()] = self.rotate_object[selection.objectName()] + 90 + self.rotate_color(selection,last_children) + + def vertical(self): + if self.tableWidget.currentItem() != None: + selection_name = (self.tableWidget.currentItem()).text() + all_children = self.frame.children() + selection = 0 + for children in all_children: + if selection_name == children.objectName(): + selection = children + if selection != 0: + if self.radioButton.isChecked() == False: + selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) + else: + selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) + self.spinBox.setValue(round(self.horizontalSlider.value())) + self.spinBox_2.setValue(round(self.verticalSlider.value())) + + def horizontal(self): + if self.tableWidget.currentItem() != None: + selection_name = (self.tableWidget.currentItem()).text() + all_children = self.frame.children() + selection = 0 + for children in all_children: + if selection_name == children.objectName(): + selection = children + if selection != 0: + if self.radioButton.isChecked() == False: + selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) + else: + selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) + self.spinBox.setValue(round(self.horizontalSlider.value())) + self.spinBox_2.setValue(round(self.verticalSlider.value())) + diff --git a/CenRa_PAGERENDER/demoV2.py b/CenRa_PAGERENDER/demoV2.py new file mode 100644 index 00000000..6cafdd29 --- /dev/null +++ b/CenRa_PAGERENDER/demoV2.py @@ -0,0 +1,167 @@ + +from qgis.core import ( + QgsLayoutSize, + QgsUnitTypes, + QgsLayoutPoint, +) +def fletch_canvas(self): + if self.radioButton_6.isChecked(): + values_page = 'A4' + else: + values_page = 'A3' + if self.radioButton_7.isChecked(): + page_rotate = 'Portrait' + else: + page_rotate = 'Landscape' + + if page_rotate == 'Portrait': + if values_page == 'A4': + self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_rotate'] = 0 + self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_rotate'] = 0 + self.template_parameters['Legande_size'] = QgsLayoutSize(85.71428571428571,131, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_locals'] = QgsLayoutPoint(209, 74, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_rotate'] = 0 + self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_rotate'] = 0 + self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_rotate'] = 0 + self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_rotate'] = 0 + self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_rotate'] = 0 + self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_rotate'] = 0 + self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_rotate'] = 0 + self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_rotate'] = 0 + self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_rotate'] = 0 + self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_rotate'] = 0 + if values_page == 'A3': + self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_rotate'] = 0 + self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_rotate'] = 0 + self.template_parameters['Legande_size'] = QgsLayoutSize(121,185, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_locals'] = QgsLayoutPoint(294, 105, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_rotate'] = 0 + self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_rotate'] = 0 + self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_rotate'] = 0 + self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_rotate'] = 0 + self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_rotate'] = 0 + self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_rotate'] = 0 + self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_rotate'] = 0 + self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_rotate'] = 0 + self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_rotate'] = 0 + self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_rotate'] = 0 + if page_rotate == 'Landscape': + if values_page == 'A4': + self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_rotate'] = 0 + self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_rotate'] = 0 + self.template_parameters['Legande_size'] = QgsLayoutSize(85.71428571428571,131, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_locals'] = QgsLayoutPoint(209, 74, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_rotate'] = 0 + self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_rotate'] = 0 + self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_rotate'] = 0 + self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_rotate'] = 0 + self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_rotate'] = 0 + self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_rotate'] = 0 + self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_rotate'] = 0 + self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_rotate'] = 0 + self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_rotate'] = 0 + self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_rotate'] = 0 + if values_page == 'A3': + self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_rotate'] = 0 + self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Carte_2_rotate'] = 0 + self.template_parameters['Legande_size'] = QgsLayoutSize(121,185, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_locals'] = QgsLayoutPoint(294, 105, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Legande_rotate'] = 0 + self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Arrow_rotate'] = 0 + self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_rotate'] = 0 + self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_rotate'] = 0 + self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Titre_rotate'] = 0 + self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Credit_rotate'] = 0 + self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Source_rotate'] = 0 + self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Sous_titre_rotate'] = 0 + self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Echelle_2_rotate'] = 0 + self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters) + self.template_parameters['Logo_2_rotate'] = 0 + return self.template_parameters diff --git a/CenRa_PAGERENDER/icon.png b/CenRa_PAGERENDER/icon.png new file mode 100644 index 00000000..d53a910f Binary files /dev/null and b/CenRa_PAGERENDER/icon.png differ diff --git a/CenRa_PAGERENDER/issues.py b/CenRa_PAGERENDER/issues.py new file mode 100644 index 00000000..0d6416a6 --- /dev/null +++ b/CenRa_PAGERENDER/issues.py @@ -0,0 +1,89 @@ +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.core import ( + NULL, + QgsApplication, + QgsDataSourceUri, + QgsProject, + QgsProviderConnectionException, + QgsProviderRegistry, + QgsRasterLayer, + QgsSettings, + QgsVectorLayer, + QgsGeometry, +) +from qgis.PyQt.QtWidgets import ( + QDialog, + QAction, + QDockWidget, + QFileDialog, + QInputDialog, + QMenu, + QToolButton, + QTableWidget, + QTableWidgetItem, +) +from qgis.utils import iface + + +from .tools.resources import ( + load_ui, + resources_path, + send_issues, +) + +EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui') + +class CenRa_Issues(QDialog, EDITOR_CLASS): + + def __init__(self, parent=None): + _ = parent + super().__init__() + self.setupUi(self) + self.settings = QgsSettings() + + #place connect here + self.annuler_button.clicked.connect(self.close) + self.ok_button.clicked.connect(self.run_sendissues) + + def run_sendissues(self): + text_titre = self.titre_line.text() + text_message = self.messages_plain.toPlainText() + statu_bug = self.check_bug.isChecked() + statu_aide = self.check_aide.isChecked() + statu_question = self.check_question.isChecked() + statu_amelioration = self.check_amelioration.isChecked() + statu_autre = self.check_autre.isChecked() + + statu = [] + if statu_bug == True : statu = statu + [1] + if statu_aide == True : statu = statu + [3] + if statu_question == True : statu = statu + [5] + if statu_amelioration == True : statu = statu + [2] + if statu_autre == True : statu = statu + [6] + + if len(statu) >= 1: + import qgis + url = qgis.utils.pluginMetadata(NAME,'tracker') + print(text_message) + send_info = send_issues(url,text_titre,text_message,statu) + code = send_info.status_code + print(code) + else: + code = 423 + if code == 201: + iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=Qgis.Success, duration=20) + self.close() + elif code == 422: + iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=Qgis.Critical, duration=20) + elif code == 423: + iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=Qgis.Critical, duration=20) + elif code == 404: + iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=Qgis.Warning, duration=20) diff --git a/CenRa_PAGERENDER/metadata.txt b/CenRa_PAGERENDER/metadata.txt new file mode 100644 index 00000000..6ecec244 --- /dev/null +++ b/CenRa_PAGERENDER/metadata.txt @@ -0,0 +1,48 @@ +# This file contains metadata for your plugin. + +# This file should be included when you package your plugin.# Mandatory items: + +[general] +name=CenRa_PageRender +qgisMinimumVersion=3.0 +description=CenRa_PageRender +version=1.1 +author=Conservatoire d'Espaces Naturels de Rhône-Alpes +email=si_besoin@cen-rhonealpes.fr + +about=Outils de création de mise en page prédéfinis pour simplifier et organiser cette étape. + +repository=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS +homepage=https://plateformesig.cenra-outils.org/ +tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues +# End of mandatory metadata + +# Recommended items: + +hasProcessingProvider=no +# Uncomment the following line and add your changelog: +changelog=

CenRa_PageRender:


21/10/2024 - Version 1.1:

- Enfin fonctionnel.


09/10/2024 - Version 1.0:

- Création.

+ +# Tags are comma separated with spaces allowed +tags=python + + +category=Plugins +icon=icon.png +# experimental flag +experimental=False + +# deprecated flag (applies to the whole plugin, not just a single version) +deprecated=False + +# Since QGIS 3.8, a comma separated list of plugins to be installed +# (or upgraded) can be specified. +# Check the documentation for more information. +# plugin_dependencies= + +Category of the plugin: Raster, Vector, Database or Web +# category=cenra,mise en page,atlas + +# If the plugin can run on QGIS Server. +server=False + diff --git a/CenRa_PAGERENDER/tools/PythonSQL.py b/CenRa_PAGERENDER/tools/PythonSQL.py new file mode 100644 index 00000000..f6c28865 --- /dev/null +++ b/CenRa_PAGERENDER/tools/PythonSQL.py @@ -0,0 +1,34 @@ +import sys +import socket +import os +IPAddr=socket.gethostbyname(socket.gethostname()) +#print(IPAddr) +if IPAddr[0:11] == "100.100.100": #4269 + host = "100.100.100.81" + port = "5432" + dbname = "sig4269" + sigdb="sig4269" + refdb="ref_geo4269" + password = "McVities" +if IPAddr[0:9] == "192.168.0": #01 + host = "192.168.0.201" + port = "5432" + dbname = "sig01" + sigdb="sig01" + refdb="ref_geo01" + password = "McVities" +if IPAddr[0:9] == "192.168.1": #0726 + host = "192.168.1.201" + port = "5432" + dbname = "sig0726" + sigdb="sig0726" + refdb="ref_geo0726" + password = "McVities" +if sys.platform == 'linux': + os_user = os.environ['USER'] +else: + os_user = os.environ['USERNAME'] +if os_user == 'STAGE': + os_user='stage' +if os_user == 'Administrateur': + os_user='stage' \ No newline at end of file diff --git a/CenRa_PAGERENDER/tools/icons/CEN_RA.png b/CenRa_PAGERENDER/tools/icons/CEN_RA.png new file mode 100644 index 00000000..95ead1cf Binary files /dev/null and b/CenRa_PAGERENDER/tools/icons/CEN_RA.png differ diff --git a/CenRa_PAGERENDER/tools/icons/icon.png b/CenRa_PAGERENDER/tools/icons/icon.png new file mode 100644 index 00000000..a0b6c4a9 Binary files /dev/null and b/CenRa_PAGERENDER/tools/icons/icon.png differ diff --git a/CenRa_PAGERENDER/tools/lecture_sql.py b/CenRa_PAGERENDER/tools/lecture_sql.py new file mode 100644 index 00000000..06d74050 Binary files /dev/null and b/CenRa_PAGERENDER/tools/lecture_sql.py differ diff --git a/CenRa_PAGERENDER/tools/resources.py b/CenRa_PAGERENDER/tools/resources.py new file mode 100644 index 00000000..75ddd77e --- /dev/null +++ b/CenRa_PAGERENDER/tools/resources.py @@ -0,0 +1,187 @@ +"""Tools to work with resource files.""" + +import configparser +import shutil +import tempfile +import base64 +import psycopg2 +import psycopg2.extras +from os.path import abspath, join, pardir, dirname +from qgis.PyQt.QtWidgets import QApplication +from qgis.PyQt import uic + +__copyright__ = "Copyright 2019, 3Liz" +__license__ = "GPL version 3" +__email__ = "info@3liz.org" +__revision__ = "$Format:%H$" + + +def plugin_path(*args): + """Get the path to plugin root folder. + + :param args List of path elements e.g. ['img', 'logos', 'image.png'] + :type args: str + + :return: Absolute path to the plugin path. + :rtype: str + """ + path = dirname(dirname(__file__)) + path = abspath(abspath(join(path, pardir))) + for item in args: + path = abspath(join(path, item)) + + return path + + +def plugin_name(): + """Return the plugin name according to metadata.txt. + + :return: The plugin name. + :rtype: basestring + """ + metadata = metadata_config() + name = metadata["general"]["name"] + return name + + +def metadata_config() -> configparser: + """Get the INI config parser for the metadata file. + + :return: The config parser object. + :rtype: ConfigParser + """ + path = plugin_path("metadata.txt") + config = configparser.ConfigParser() + config.read(path, encoding='utf8') + return config + + +def plugin_test_data_path(*args, copy=False): + """Get the path to the plugin test data path. + + :param args List of path elements e.g. ['img', 'logos', 'image.png'] + :type args: str + + :param copy: If the file must be copied into a temporary directory first. + :type copy: bool + + :return: Absolute path to the resources folder. + :rtype: str + """ + path = abspath(abspath(join(plugin_path(), "test", "data"))) + for item in args: + path = abspath(join(path, item)) + + if copy: + temp = tempfile.mkdtemp() + shutil.copy(path, temp) + return join(temp, args[-1]) + else: + return path + + +def resources_path(*args): + """Get the path to our resources folder. + + :param args List of path elements e.g. ['img', 'logos', 'image.png'] + :type args: str + + :return: Absolute path to the resources folder. + :rtype: str + """ + path = abspath(abspath(join(plugin_path(), "CenRa_PAGERENDER\\tools"))) + for item in args: + path = abspath(join(path, item)) + return path + + +def load_ui(*args): + """Get compile UI file. + + :param args List of path elements e.g. ['img', 'logos', 'image.png'] + :type args: str + + :return: Compiled UI file. + """ + ui_class, _ = uic.loadUiType(resources_path("ui", *args)) + + return ui_class + +def login_base(take=None): + from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user + first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) + first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) + first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") + res_ident = first_cur.fetchone() + + mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') + user = res_ident[1] + + con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) + + cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) + first_conn.close() + + if take: + return cur,con + else: + return cur +def send_issues(url,titre,body,labels): + import requests + import json + import os + import qgis + + usr = os.environ['USERNAME'] + token = '9d0a4e0bea561710e0728f161f7edf4e5201e112' + url=url+'?token='+token + + headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'} + + + payload = {'title': titre, 'body': body, 'labels': labels} + try: + urllib.request.urlopen('https://google.com') + binar = True + except: + binar = False + r = '' + if binar: + r = requests.post(url, data=json.dumps(payload), headers=headers) + return r + +def maj_verif(NAME): + import qgis + import urllib.request + iface = qgis.utils.iface + from qgis.core import Qgis + + url = qgis.utils.pluginMetadata(NAME,'repository') + #URL = url+'/raw/branch/main/plugins.xml' + URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' +# print(URL) + version = qgis.utils.pluginMetadata(NAME,'version') + len_version = len(version) + try: + urllib.request.urlopen('https://google.com') + binar = True + except: + binar = False + if binar: + version_web = str(urllib.request.urlopen(URL).read()) + plugin_num = version_web.find(NAME) + valeur_version_web = version_web.find('',plugin_num)+9 + version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] + if version_plugin != version: + iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) + else: + iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) + +def tr(text, context="@default"): + return QApplication.translate(context, text) + +def devlog(NAME): + import qgis + devmaj = '' + devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog') + return devmaj \ No newline at end of file diff --git a/CenRa_PAGERENDER/tools/ui/CenRa_IssuesSend.ui b/CenRa_PAGERENDER/tools/ui/CenRa_IssuesSend.ui new file mode 100644 index 00000000..14d923e4 --- /dev/null +++ b/CenRa_PAGERENDER/tools/ui/CenRa_IssuesSend.ui @@ -0,0 +1,332 @@ + + + CenRa_IssuesSend + + + + 0 + 0 + 810 + 587 + + + + CEN-RA Metabase + + + + icon.svgicon.svg + + + + + 0 + 550 + 811 + 31 + + + + + + + Annuler + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Envoyer + + + + + + + + + 10 + 10 + 791 + 531 + + + + Issues + + + + + 240 + 40 + 321 + 41 + + + + Qt::AlignCenter + + + + + + 10 + 101 + 571 + 421 + + + + + + + 589 + 100 + 191 + 431 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 9 + 9 + 341 + 411 + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Bug + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Aide + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Question + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Amélioration + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Autre + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 250 + 20 + 51 + 21 + + + + + Arial + 14 + + + + Titre: + + + + + + 20 + 70 + 91 + 31 + + + + + Arial + 12 + + + + Messages: + + + + + + 600 + 70 + 91 + 31 + + + + + Arial + 12 + + + + Sujet: + + + + + + ok_button + annuler_button + + + + diff --git a/CenRa_PAGERENDER/tools/ui/CenRa_PageRender_about_form.ui b/CenRa_PAGERENDER/tools/ui/CenRa_PageRender_about_form.ui new file mode 100644 index 00000000..3e3608ff --- /dev/null +++ b/CenRa_PAGERENDER/tools/ui/CenRa_PageRender_about_form.ui @@ -0,0 +1,96 @@ + + + CenRa_Metabase_editorwidget_base + + + + 0 + 0 + 471 + 594 + + + + Metabase + + + + ../../CenRa_Metabase/tools/ui/icon.svg../../CenRa_Metabase/tools/ui/icon.svg + + + + + + true + + + Qt::NoFocus + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 453 + 547 + + + + + + 0 + 0 + 451 + 541 + + + + DevLog + + + + + 10 + 20 + 431 + 511 + + + + + about:blank + + + + + + + + + + + QDialogButtonBox::Ok + + + + + + + + QWebView + QWidget +
QtWebKitWidgets/QWebView
+
+
+ + +
diff --git a/CenRa_PAGERENDER/tools/ui/CenRa_PageRender_base.ui b/CenRa_PAGERENDER/tools/ui/CenRa_PageRender_base.ui new file mode 100644 index 00000000..7c7e3930 --- /dev/null +++ b/CenRa_PAGERENDER/tools/ui/CenRa_PageRender_base.ui @@ -0,0 +1,652 @@ + + + MapCENDialogBase + + + + 0 + 0 + 1295 + 805 + + + + + 1295 + 805 + + + + + 1295 + 805 + + + + PageRender + + + + + + + + 0 + 0 + 1301 + 811 + + + + + 1301 + 743 + + + + + 1326 + 1323 + + + + + 1150 + 781 + + + + + + + 0 + + + + Liste de templates existants + + + + + 410 + 10 + 861 + 22 + + + + 296 + + + Qt::Horizontal + + + + + + 210 + 40 + 22 + 731 + + + + 210 + + + 10 + + + 0 + + + Qt::Vertical + + + true + + + + + + 240 + 40 + 1039 + 735 + + + + QFrame#frame{background-color: rgb(255, 255, 255, 170);} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 20 + 700 + 700 + + + + background-color: rgb(10, 10, 10, 50) + + + QFrame::NoFrame + + + QFrame::Plain + + + 5 + + + 2 + + + + + + Qt::AlignCenter + + + 5 + + + + + + 730 + 10 + 300 + 240 + + + + background-color: rgb(10, 10, 10, 50) + + + QFrame::Plain + + + + + + + + + 730 + 260 + 300 + 460 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 660 + 70 + 50 + 50 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 30 + 690 + 180 + 25 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 10 + 10 + 160 + 40 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 180 + 10 + 540 + 40 + + + + false + + + false + + + background-color: rgb(10, 10, 10, 50) + + + QFrame::NoFrame + + + QFrame::Raised + + + -1 + + + 0 + + + + + + false + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + false + + + 0 + + + + + + + + + 530 + 690 + 180 + 20 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 800 + 690 + 180 + 20 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 210 + 70 + 440 + 50 + + + + false + + + false + + + background-color: rgb(10, 10, 10, 50) + + + QFrame::NoFrame + + + QFrame::Raised + + + -1 + + + 0 + + + + + + false + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + false + + + 0 + + + + + + + + + 30 + 645 + 180 + 45 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + 30 + 530 + 100 + 100 + + + + background-color: rgb(10, 10, 10, 50) + + + + + + + + + + 20 + 20 + 181 + 751 + + + + QFrame#frame_2{background-color: rgb(255, 255, 255, 170);} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 161 + 641 + + + + 1 + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + QAbstractItemView::NoDragDrop + + + Qt::IgnoreAction + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + + 5 + 5 + + + + Qt::ElideMiddle + + + true + + + true + + + 0 + + + 1 + + + false + + + 50 + + + 160 + + + true + + + false + + + + + + + 60 + 720 + 61 + 23 + + + + Exporte + + + + + + 60 + 690 + 61 + 20 + + + + Landscape + + + + + + 10 + 650 + 161 + 21 + + + + Load + + + + + + + 210 + 10 + 20 + 21 + + + + + 0 + 0 + + + + + 12 + + + + Qt::NoFocus + + + Qt::LeftToRight + + + false + + + Qt::ImhNone + + + + + + + 32 + 32 + + + + E + + + + + + 240 + 10 + 61 + 22 + + + + QAbstractSpinBox::NoButtons + + + + + + X: + + + 999 + + + + + + 310 + 10 + 61 + 22 + + + + QAbstractSpinBox::NoButtons + + + + + + Y: + + + 999 + + + + + + 380 + 11 + 25 + 20 + + + + ... + + + + + + + + diff --git a/plugins.xml b/plugins.xml index da8cbb4f..50464e28 100644 --- a/plugins.xml +++ b/plugins.xml @@ -85,7 +85,7 @@ cenra,metabase - + 1.6 3.16 @@ -96,10 +96,26 @@ https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_AUTOMAP.zip CEN-Rhone-Alpes 2024-09-25 - 2024-10-07 + 2024-10-21 + False + False + cenra,mise en page,atlas + + + + + 1.1 + 3.16 + https://plateformesig.cenra-outils.org/ + CenRa_AUTOMAP.zip + CEN-Rhone-Alpes.png + CEN-Rhone-Alpes + https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_AUTOMAP.zip + CEN-Rhone-Alpes + 2024-10-09 + 2024-10-21 False False cenra,mise en page,atlas - \ No newline at end of file