From 654a8f579f38e0807de56ca8fb538458a416ae76 Mon Sep 17 00:00:00 2001
From: Tom LAVEILLE
Date: Thu, 14 Nov 2024 17:16:23 +0100
Subject: [PATCH] Ajout de fonctionnaliter mollet et mouse dragging
---
CenRa_COPIE/tools/PythonSQL.py | 2 +
CenRa_PAGERENDER/canvas_editor.py | 64 ++++++++++++++++++++++++++++++-
CenRa_PAGERENDER/metadata.txt | 4 +-
plugins.xml | 6 +--
4 files changed, 70 insertions(+), 6 deletions(-)
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=CenRa_PageRender:
08/11/2024 - Version 1.3:
- Correctif de bug. 21/10/2024 - Version 1.1:
- Les match en if. - Bouton de scroll et adaptation portrait.
09/10/2024 - Version 1.0:
- Création.
+changelog=CenRa_PageRender:
14/11/2024 - Version 1.4:
- Implementation de la mollet. - Implementation du dragging pour déplacer et modification de la taille 08/11/2024 - Version 1.3:
- Correctif de bug. 21/10/2024 - Version 1.1:
- Les match en if. - Bouton de scroll et adaptation portrait.09/10/2024 - Version 1.0:
- Création.
# Tags are comma separated with spaces allowed
tags=python
diff --git a/plugins.xml b/plugins.xml
index b9ad961..43b4f82 100644
--- a/plugins.xml
+++ b/plugins.xml
@@ -102,9 +102,9 @@
cenra,mise en page,atlas
-
+
- 1.3
+ 1.4
3.16
https://plateformesig.cenra-outils.org/
CenRa_PAGERENDER.zip
@@ -113,7 +113,7 @@
https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/CenRa_PAGERENDER.zip
CEN-Rhone-Alpes
2024-10-09
- 2024-11-08
+ 2024-11-14
True
False
cenra,mise en page,atlas