diff --git a/CenRa_COPIE/tools/PythonSQL.py b/CenRa_COPIE/tools/PythonSQL.py index dbb7afc..fcf0b80 100644 --- a/CenRa_COPIE/tools/PythonSQL.py +++ b/CenRa_COPIE/tools/PythonSQL.py @@ -29,6 +29,8 @@ else: os_user = os.environ['USERNAME'] if os_user == 'STAGE': os_user='stage' +if os_user == 'Administrateur': + os_user = 'stage' geom = "geom" champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" diff --git a/CenRa_PAGERENDER/canvas_editor.py b/CenRa_PAGERENDER/canvas_editor.py index b4bbf69..c02928e 100644 --- a/CenRa_PAGERENDER/canvas_editor.py +++ b/CenRa_PAGERENDER/canvas_editor.py @@ -1,6 +1,6 @@ import logging import os -from PyQt5.QtCore import QSettings +from PyQt5.QtCore import QSettings,QPointF from collections import namedtuple from enum import Enum from functools import partial @@ -57,6 +57,7 @@ from qgis.PyQt.QtWidgets import ( QVBoxLayout, ) from PyQt5 import QtGui +from PyQt5.QtWidgets import QApplication from qgis.PyQt.QtXml import QDomDocument from qgis.utils import iface import glob @@ -148,14 +149,75 @@ class PageRender_Editor(QDialog, EDITOR_CLASS): self.toolButton_2.clicked.connect(self.type_page) self.pushButton_2.clicked.connect(self.load) self.verticalScrollBar.valueChanged.connect(self.moveFrame) + #self.setAcceptHoverEvents(True) def raise_(self): self.activateWindow() self.setNavigator() self.verticalScrollBar.setValue(self.frame.y()) + def mousePressEvent(self, event): + QApplication.setOverrideCursor(Qt.OpenHandCursor) + global lastPos + lastPos = {'x':event.pos().x(),'y':event.pos().y()} + def moveFrame(self): self.frame.move(self.frame.x(),self.verticalScrollBar.value()) + def wheelEvent(self,event): + if (event.angleDelta().y() >= 1): + vsb = self.verticalScrollBar.value()+50 + else: + vsb = self.verticalScrollBar.value()-50 + self.verticalScrollBar.setValue(vsb) + + def mouseMoveEvent(self, event): + updated_cursor_position = event.pos() + + 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 + + frame_x = self.frame.x() + frame_y = self.frame.y() + frame_w = self.frame.width()+frame_x + frame_h = self.frame.height()+frame_y + global lastPos + + orig_position_w = selection.width() + orig_position_h = selection.height() + if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() == True): + updated_cursor_position_x = orig_position_w+(round(updated_cursor_position.x()-lastPos['x'])) + lastPos['x'] = event.pos().x() + selection.resize(updated_cursor_position_x,orig_position_h) + orig_position_w = selection.width() + orig_position_h = selection.height() + if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() == True): + updated_cursor_position_y = orig_position_h+(round(updated_cursor_position.y()-lastPos['y'])) + lastPos['y'] = event.pos().y() + selection.resize(orig_position_w,updated_cursor_position_y) + + orig_position_x = selection.pos().x() + orig_position_y = selection.pos().y() + if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() == False): + updated_cursor_position_x = orig_position_x+(round(updated_cursor_position.x()-lastPos['x'])) + lastPos['x'] = event.pos().x() + #print(updated_cursor_position_x) + selection.move(updated_cursor_position_x,orig_position_y) + orig_position_x = selection.pos().x() + orig_position_y = selection.pos().y() + if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() == False): + updated_cursor_position_y = orig_position_y+(round(updated_cursor_position.y()-lastPos['y'])) + lastPos['y'] = event.pos().y() + #print(updated_cursor_position_y) + selection.move(orig_position_x,updated_cursor_position_y) + + def mouseReleaseEvent(self, event): + #print('x: {0}, y: {1}'.format(event.pos().x(), event.pos().y())) + QApplication.restoreOverrideCursor() + def select_file(self): options = QFileDialog.Options() options |= QFileDialog.ShowDirsOnly diff --git a/CenRa_PAGERENDER/metadata.txt b/CenRa_PAGERENDER/metadata.txt index fe649f0..1910576 100644 --- a/CenRa_PAGERENDER/metadata.txt +++ b/CenRa_PAGERENDER/metadata.txt @@ -6,7 +6,7 @@ name=CenRa_PageRender qgisMinimumVersion=3.0 description=CenRa_PageRender -version=1.3 +version=1.4 author=Conservatoire d'Espaces Naturels de Rhône-Alpes email=si_besoin@cen-rhonealpes.fr @@ -21,7 +21,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues hasProcessingProvider=no # Uncomment the following line and add your changelog: -changelog=