Template
forked from CEN-RA/Plugin_QGIS
Ajout de fonctionnaliter mollet et mouse dragging
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user