batoolset-gui 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. batoolset/GUI/__init__.py +0 -0
  2. batoolset/GUI/customdialog.py +136 -0
  3. batoolset/GUI/exception_handler.py +74 -0
  4. batoolset/GUI/list_gui.py +514 -0
  5. batoolset/GUI/multi_image_display.py +1038 -0
  6. batoolset/GUI/open.py +325 -0
  7. batoolset/GUI/overlay_hints.py +45 -0
  8. batoolset/GUI/paint2.py +1369 -0
  9. batoolset/GUI/scrollablepaint.py +1165 -0
  10. batoolset/dialogs/__init__.py +0 -0
  11. batoolset/dialogs/opensave.py +228 -0
  12. batoolset/drawings/__init__.py +0 -0
  13. batoolset/drawings/math_text.py +294 -0
  14. batoolset/drawings/pdf_svg_renderer.py +376 -0
  15. batoolset/drawings/shapes/Position.py +183 -0
  16. batoolset/drawings/shapes/__init__.py +0 -0
  17. batoolset/drawings/shapes/automated_alignment_drawing_refactored.py +346 -0
  18. batoolset/drawings/shapes/circle2d.py +99 -0
  19. batoolset/drawings/shapes/compute_optimal_size_all_merged.py +328 -0
  20. batoolset/drawings/shapes/ellipse2d.py +336 -0
  21. batoolset/drawings/shapes/freehand2d.py +235 -0
  22. batoolset/drawings/shapes/group.py +1985 -0
  23. batoolset/drawings/shapes/image2d.py +3157 -0
  24. batoolset/drawings/shapes/line2d.py +579 -0
  25. batoolset/drawings/shapes/point2d.py +257 -0
  26. batoolset/drawings/shapes/polygon2d.py +357 -0
  27. batoolset/drawings/shapes/polyline2d.py +235 -0
  28. batoolset/drawings/shapes/rect2d.py +388 -0
  29. batoolset/drawings/shapes/rectangle2d.py +601 -0
  30. batoolset/drawings/shapes/scalebar.py +310 -0
  31. batoolset/drawings/shapes/serializablefont.py +133 -0
  32. batoolset/drawings/shapes/serializableguiparams.py +14 -0
  33. batoolset/drawings/shapes/square2d.py +102 -0
  34. batoolset/drawings/shapes/test_publication_style.py +220 -0
  35. batoolset/drawings/shapes/textorientation.py +45 -0
  36. batoolset/drawings/shapes/tools.py +467 -0
  37. batoolset/drawings/shapes/transform2D.py +350 -0
  38. batoolset/drawings/shapes/txt2d.py +615 -0
  39. batoolset/drawings/svg_clip_renderer.py +247 -0
  40. batoolset/drawings/svg_embed.py +165 -0
  41. batoolset/drawings/svg_text_renderer.py +183 -0
  42. batoolset/drawings/widgets/__init__.py +0 -0
  43. batoolset/drawings/widgets/col.py +343 -0
  44. batoolset/drawings/widgets/image_group.py +248 -0
  45. batoolset/drawings/widgets/image_organizer.py +96 -0
  46. batoolset/drawings/widgets/paint.py +184 -0
  47. batoolset/drawings/widgets/vectorial.py +256 -0
  48. batoolset/figure/__init__.py +0 -0
  49. batoolset/figure/alignment.py +822 -0
  50. batoolset/figure/column.py +1117 -0
  51. batoolset/figure/fig_tools.py +285 -0
  52. batoolset/figure/minimal_debugger_scale_etc.py +139 -0
  53. batoolset/figure/panel.py +697 -0
  54. batoolset/figure/row.py +852 -0
  55. batoolset/figure/user_selection.py +287 -0
  56. batoolset/icons/__init__.py +0 -0
  57. batoolset/icons/tools.py +248 -0
  58. batoolset/luts/__init__.py +0 -0
  59. batoolset/luts/lut_minimal_test.py +1308 -0
  60. batoolset/luts/lutcreatorfromformula.py +209 -0
  61. batoolset/luts/luteditor.py +243 -0
  62. batoolset/pyqts/__init__.py +0 -0
  63. batoolset/pyqts/pleasewaitdialog.py +14 -0
  64. batoolset/pyqts/tools.py +760 -0
  65. batoolset/serializations/__init__.py +0 -0
  66. batoolset/serializations/tools.py +1338 -0
  67. batoolset/theme.py +647 -0
  68. batoolset/uis/__init__.py +0 -0
  69. batoolset/uis/blinker.py +56 -0
  70. batoolset_gui-0.2.0.dist-info/METADATA +54 -0
  71. batoolset_gui-0.2.0.dist-info/RECORD +74 -0
  72. batoolset_gui-0.2.0.dist-info/WHEEL +5 -0
  73. batoolset_gui-0.2.0.dist-info/licenses/LICENSE +24 -0
  74. batoolset_gui-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,184 @@
1
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
2
+ set_UI()
3
+ import sys
4
+ from qtpy.QtCore import QRect, QTimer
5
+ from qtpy.QtGui import QPixmap
6
+ from qtpy.QtWidgets import QWidget
7
+
8
+ from batoolset.drawings.widgets.vectorial import VectorialDrawPane
9
+ from qtpy.QtWidgets import QMenu, QApplication
10
+ from qtpy import QtCore, QtGui
11
+
12
+ from batoolset.img import toQimage
13
+ from batoolset.tools.logger import TA_logger # logging
14
+
15
+ logger = TA_logger()
16
+
17
+ class Createpaintwidget(QWidget):
18
+
19
+ def __init__(self):
20
+ super().__init__()
21
+ self.vdp = VectorialDrawPane(active=False) #, demo=True
22
+ self.image = None
23
+ self.imageDraw = None
24
+ self.cursor = None
25
+ self.maskVisible = True
26
+ self.scale = 1.0
27
+ self.drawing = False
28
+ self.brushSize = 3
29
+ self._clear_size = 30
30
+ self.drawColor = QtGui.QColor(QtCore.Qt.red) # blue green cyan
31
+ self.eraseColor = QtGui.QColor(QtCore.Qt.black)
32
+ self.cursorColor = QtGui.QColor(QtCore.Qt.green)
33
+ self.lastPoint = QtCore.QPointF()
34
+ self.change = False
35
+ # KEEP IMPORTANT required to track mouse even when not clicked
36
+ self.setMouseTracking(True) # KEEP IMPORTANT
37
+ self.scrollArea = None
38
+ self.statusBar = None
39
+
40
+ def setImage(self, img):
41
+ if img is None:
42
+ self.image = None
43
+ self.imageDraw = None
44
+ self.update()
45
+ return
46
+ else:
47
+ self.image = toQimage(img) #.getQimage() # bug is here
48
+
49
+ # self.image = QPixmap(100,200).toImage()
50
+ width = self.image.size().width()
51
+ height = self.image.size().height()
52
+ top = self.geometry().x()
53
+ left = self.geometry().y()
54
+ self.setGeometry(top, left, int(width*self.scale), int(height*self.scale))
55
+ self.imageDraw = QtGui.QImage(self.image.size(), QtGui.QImage.Format_ARGB32)
56
+ self.imageDraw.fill(QtCore.Qt.transparent)
57
+ self.cursor = QtGui.QImage(self.image.size(), QtGui.QImage.Format_ARGB32)
58
+ self.cursor.fill(QtCore.Qt.transparent)
59
+ self.update()
60
+
61
+ def mousePressEvent(self, event):
62
+ if not self.hasMouseTracking():
63
+ return
64
+ self.clickCount = 1
65
+ if self.vdp.active:
66
+ self.vdp.mousePressEvent(event)
67
+ self.update()
68
+ return
69
+
70
+ if event.buttons() == QtCore.Qt.LeftButton or event.buttons() == QtCore.Qt.RightButton:
71
+ self.drawing = True
72
+ zoom_corrected_pos = event.position() / self.scale
73
+ self.lastPoint = zoom_corrected_pos
74
+ self.drawOnImage(event)
75
+
76
+ def mouseMoveEvent(self, event):
77
+ if not self.hasMouseTracking():
78
+ return
79
+ # print('in mouse move', self.hasMouseTracking(), self.drawing, self.vdp.active)
80
+ if self.statusBar:
81
+ zoom_corrected_pos = event.position() / self.scale
82
+ self.statusBar.showMessage('x=' + str(zoom_corrected_pos.x()) + ' y=' + str(
83
+ zoom_corrected_pos.y()))
84
+ if self.vdp.active:
85
+ self.vdp.mouseMoveEvent(event)
86
+ region = self.scrollArea.widget().visibleRegion()
87
+ self.update(region)
88
+ return
89
+ self.drawOnImage(event)
90
+
91
+ def drawOnImage(self, event):
92
+ zoom_corrected_pos = event.position() / self.scale
93
+ if self.drawing and (event.buttons() == QtCore.Qt.LeftButton or event.buttons() == QtCore.Qt.RightButton):
94
+ # now drawing or erasing over the image
95
+ painter = QtGui.QPainter(self.imageDraw)
96
+ if event.buttons() == QtCore.Qt.LeftButton:
97
+ painter.setPen(QtGui.QPen(self.drawColor, self.brushSize, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,
98
+ QtCore.Qt.RoundJoin))
99
+ else:
100
+ painter.setPen(QtGui.QPen(self.eraseColor, self.brushSize, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,
101
+ QtCore.Qt.RoundJoin))
102
+ if self.lastPoint != zoom_corrected_pos:
103
+ painter.drawLine(self.lastPoint, zoom_corrected_pos)
104
+ else:
105
+ # if zero length line then draw point instead
106
+ painter.drawPoint(zoom_corrected_pos)
107
+ painter.end()
108
+
109
+ # Drawing the cursor TODO add boolean to ask if drawing cursor should be shown
110
+ painter = QtGui.QPainter(self.cursor)
111
+ # We erase previous pointer
112
+ r = QtCore.QRect(QtCore.QPoint(), self._clear_size * QtCore.QSize() * self.brushSize)
113
+ painter.save()
114
+ r.moveCenter(self.lastPoint.toPoint())
115
+ painter.setCompositionMode(QtGui.QPainter.CompositionMode_Clear)
116
+ painter.eraseRect(r)
117
+ painter.restore()
118
+ # draw the new one
119
+ painter.setPen(QtGui.QPen(self.cursorColor, 2, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap,
120
+ QtCore.Qt.RoundJoin))
121
+ painter.drawEllipse(zoom_corrected_pos, int(self.brushSize / 2.),
122
+ int(self.brushSize / 2.))
123
+ painter.end()
124
+ region = self.scrollArea.widget().visibleRegion()
125
+ self.update(region)
126
+
127
+ # required to erase mouse pointer
128
+ self.lastPoint = zoom_corrected_pos
129
+
130
+ def mouseReleaseEvent(self, event):
131
+ if not self.hasMouseTracking():
132
+ return
133
+ if self.vdp.active:
134
+ self.vdp.mouseReleaseEvent(event)
135
+ self.update() # required to update drawing
136
+ return
137
+ if event.button == QtCore.Qt.LeftButton:
138
+ self.drawing = False
139
+ if self.clickCount == 1:
140
+ QTimer.singleShot(QApplication.instance().doubleClickInterval(),
141
+ self.updateButtonCount)
142
+
143
+ # adds context/right click menu but only in vectorial mode
144
+ def contextMenuEvent(self, event):
145
+ if not self.vdp.active:
146
+ return
147
+ cmenu = QMenu(self)
148
+ newAct = cmenu.addAction("New")
149
+ opnAct = cmenu.addAction("Open")
150
+ quitAct = cmenu.addAction("Quit")
151
+ action = cmenu.exec_(self.mapToGlobal(event.position()))
152
+ if action == quitAct:
153
+ sys.exit(0)
154
+
155
+ def updateButtonCount(self):
156
+ self.clickCount = 1
157
+
158
+ def mouseDoubleClickEvent(self, event):
159
+ self.clickCount = 2
160
+ self.vdp.mouseDoubleClickEvent(event)
161
+
162
+ def paintEvent(self, event):
163
+ canvasPainter = QtGui.QPainter(self)
164
+ # the scrollpane visible region
165
+ visibleRegion = self.scrollArea.widget().visibleRegion()
166
+ # the corresponding rect
167
+ visibleRect = visibleRegion.boundingRect()
168
+ # the visibleRect taking zoom into account
169
+ scaledVisibleRect = QRect(int(visibleRect.x() / self.scale), int(visibleRect.y() / self.scale),
170
+ int(visibleRect.width() / self.scale), int(visibleRect.height() / self.scale))
171
+ if self.image is None:
172
+ canvasPainter.eraseRect(visibleRect)
173
+ canvasPainter.end()
174
+ return
175
+
176
+ canvasPainter.drawImage(visibleRect, self.image, scaledVisibleRect)
177
+ if not self.vdp.active and self.maskVisible:
178
+ canvasPainter.drawImage(visibleRect, self.imageDraw, scaledVisibleRect)
179
+ # should draw the cursor
180
+ canvasPainter.drawImage(visibleRect, self.cursor, scaledVisibleRect)
181
+
182
+ if self.vdp.active:
183
+ self.vdp.paintEvent(canvasPainter, scaledVisibleRect)
184
+ canvasPainter.end()
@@ -0,0 +1,256 @@
1
+ # TODO -−> add the small displacement filtering there!!! --> jut copy it from the other code -−> should be easy and maybe it would be useful to have a list of shapes so that one can delete them -−> see if I add that as separate stuff!!!
2
+ # I could also save the polygonF maybe
3
+
4
+
5
+ import os
6
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
7
+ set_UI()
8
+ from batoolset.drawings.shapes.txt2d import TAText2D
9
+ from batoolset.pyqts.tools import getCtrlModifier
10
+ from qtpy import QtCore
11
+ from batoolset.drawings.shapes.polygon2d import Polygon2D
12
+ from batoolset.drawings.shapes.line2d import Line2D
13
+ from batoolset.drawings.shapes.rect2d import Rect2D
14
+ from batoolset.drawings.shapes.square2d import Square2D
15
+ from batoolset.drawings.shapes.ellipse2d import Ellipse2D
16
+ from batoolset.drawings.shapes.circle2d import Circle2D
17
+ from batoolset.drawings.shapes.freehand2d import Freehand2D
18
+ from batoolset.drawings.shapes.point2d import Point2D
19
+ from batoolset.drawings.shapes.polyline2d import PolyLine2D
20
+ from batoolset.drawings.shapes.image2d import Image2D
21
+ from qtpy.QtCore import QPointF, QRectF
22
+ from batoolset.tools.logger import TA_logger # logging
23
+ logger = TA_logger()
24
+
25
+ class VectorialDrawPane:
26
+
27
+ def __init__(self, active=False, demo=False, scale=1.0, drawing_mode=False, extra_size_for_sel=0, filter_out_unwanted_shapes_based_on_distance=True):
28
+ self.shapes = []
29
+ self.currently_drawn_shape = None
30
+ self.shape_to_draw = None
31
+ self.selected_shape = []
32
+ self.active = active
33
+ self.scale = scale
34
+ self.drawing_mode = drawing_mode
35
+ self.extra_size_for_sel = extra_size_for_sel # can be used to add an extra size around very small shapes --> TODO
36
+ self.filter_out_unwanted_shapes_based_on_distance = filter_out_unwanted_shapes_based_on_distance # if set to True the tool will attempt to filter accidental drawings by the user (based on distance between draw points)
37
+ if demo:
38
+ self.shapes.append(Polygon2D(0, 0, 10, 0, 10, 20, 0, 20, 0, 0, color=0x00FF00))
39
+ self.shapes.append(
40
+ Polygon2D(100, 100, 110, 100, 110, 120, 10, 120, 100, 100, color=0x0000FF, fill_color=0x00FFFF,
41
+ stroke=2))
42
+ self.shapes.append(Line2D(0, 0, 110, 100, color=0xFF0000, stroke=3))
43
+ self.shapes.append(Rect2D(200, 150, 250, 100, stroke=10))
44
+ self.shapes.append(Square2D(300, 260, 250, stroke=3))
45
+ self.shapes.append(Ellipse2D(0, 50, 600, 200, stroke=3))
46
+ self.shapes.append(Circle2D(150, 300, 30, color=0xFF0000))
47
+ self.shapes.append(PolyLine2D(10, 10, 20, 10, 20, 30, 40, 30, color=0xFF0000, stroke=2))
48
+ self.shapes.append(PolyLine2D(10, 10, 20, 10, 20, 30, 40, 30, color=0xFF0000, stroke=2))
49
+ self.shapes.append(Point2D(128, 128, color=0xFF0000, stroke=6))
50
+ self.shapes.append(Point2D(128, 128, color=0x00FF00, stroke=1))
51
+ self.shapes.append(Point2D(10, 10, color=0x000000, stroke=6))
52
+ img0 = Image2D('/E/Sample_images/counter/00.png')
53
+ img1 = Image2D('/E/Sample_images/counter/01.png')
54
+ img2 = Image2D('/E/Sample_images/counter/02.png')
55
+ img3 = Image2D('/E/Sample_images/counter/03.png')
56
+ img4 = Image2D('/E/Sample_images/counter/04.png')
57
+ img5 = Image2D('/E/Sample_images/counter/05.png')
58
+ img6 = Image2D('/E/Sample_images/counter/06.png')
59
+ img7 = Image2D('/E/Sample_images/counter/07.png')
60
+ img8 = Image2D('/E/Sample_images/counter/08.png')
61
+ img9 = Image2D('/E/Sample_images/counter/09.png')
62
+ img10 = Image2D('/E/Sample_images/counter/10.png')
63
+
64
+ row = img1 + img2 + img10
65
+
66
+ self.shapes.append(row)
67
+
68
+ row2 = img4 + img5
69
+ fig = row / row2
70
+ # fig = Column(row, row2)
71
+ #self.shapes.append(fig)
72
+ self.drawing_mode = True
73
+ # self.shape_to_draw = Line2D
74
+ # self.shape_to_draw = Rect2D
75
+ # self.shape_to_draw = Square2D
76
+ # self.shape_to_draw = Ellipse2D
77
+ # self.shape_to_draw = Circle2D
78
+ # self.shape_to_draw = Point2D # ok maybe small centering issue
79
+ # self.shape_to_draw = Freehand2D
80
+ # self.shape_to_draw = PolyLine2D
81
+ # self.shape_to_draw = Polygon2D
82
+ import random
83
+ drawing_methods = [Line2D, Rect2D, Square2D, Ellipse2D, Circle2D, Point2D, Freehand2D, PolyLine2D, Polygon2D]
84
+ self.shape_to_draw = random.choice(drawing_methods)
85
+
86
+ # TODO freehand drawing
87
+ # TODO broken line --> need double click for end
88
+
89
+ def paintEvent(self, *args):
90
+ painter = args[0]
91
+ visibleRect = None
92
+ if len(args) >= 2:
93
+ visibleRect = args[1]
94
+
95
+ painter.save()
96
+ if self.scale != 1.0:
97
+ painter.scale(self.scale, self.scale)
98
+
99
+ for shape in self.shapes:
100
+ # only draw shapes if they are visible --> requires a visiblerect to be passed
101
+ if visibleRect is not None:
102
+ # only draws if in visible rect
103
+ if shape.boundingRect().intersects(QRectF(visibleRect)):
104
+ shape.draw(painter)
105
+ else:
106
+ shape.draw(painter)
107
+
108
+ if self.currently_drawn_shape is not None:
109
+ if self.currently_drawn_shape.isSet:
110
+ self.currently_drawn_shape.draw(painter)
111
+
112
+ sel = self.create_master_rect()
113
+ if sel is not None:
114
+ painter.drawRect(sel)
115
+ painter.restore()
116
+ # painter.end() # probably a good idea ????
117
+
118
+ def group_contains(self, x, y):
119
+ # checks if master rect for group contains click
120
+ # get bounds and create union and compare
121
+ master_rect = self.create_master_rect()
122
+ if master_rect is None:
123
+ return False
124
+ return master_rect.contains(QPointF(x, y))
125
+
126
+ def create_master_rect(self):
127
+ master_rect = None
128
+ if self.selected_shape:
129
+ for shape in self.selected_shape:
130
+ if master_rect is None:
131
+ master_rect = shape.boundingRect()
132
+ else:
133
+ master_rect = master_rect.united(shape.boundingRect())
134
+ return master_rect
135
+
136
+ def removeCurShape(self):
137
+ if self.selected_shape:
138
+ self.shapes = [e for e in self.shapes if e not in self.selected_shape]
139
+ self.selected_shape = []
140
+
141
+ def mousePressEvent(self, event):
142
+ if event.button() == QtCore.Qt.LeftButton:
143
+ self.drawing = True
144
+ self.lastPoint = event.position() / self.scale
145
+ self.firstPoint = event.position() / self.scale
146
+
147
+ shapeFound = False
148
+ if self.currently_drawn_shape is None:
149
+ for shape in reversed(self.shapes):
150
+ if shape.contains(self.lastPoint, extra=self.extra_size_for_sel) and not shape in self.selected_shape:
151
+ logger.debug('you clicked shape:' + str(shape))
152
+ if event.modifiers() == getCtrlModifier():
153
+ if shape not in self.selected_shape: # avoid doublons
154
+ self.selected_shape.append(shape) # add shape to group
155
+ logger.debug('adding shape to group')
156
+ # shapeFound = True
157
+ else:
158
+ if not self.group_contains(self.lastPoint.x(), self.lastPoint.y()):
159
+ self.selected_shape = [shape]
160
+ logger.debug('only one element is selected')
161
+ # shapeFound = True
162
+ return
163
+
164
+ if not shapeFound and event.modifiers() == getCtrlModifier():
165
+ for shape in reversed(self.shapes):
166
+ if shape.contains(self.lastPoint, extra=self.extra_size_for_sel):
167
+ if shape in self.selected_shape: # avoid doublons
168
+ logger.debug('you clicked again shape:' + str(shape))
169
+ self.selected_shape.remove(shape) # add shape to group
170
+ logger.debug('removing a shape from group')
171
+ shapeFound = True
172
+ # no shape found --> reset sel
173
+ if not shapeFound and not self.group_contains(self.lastPoint.x(), self.lastPoint.y()):
174
+ logger.debug('resetting sel')
175
+ self.selected_shape = []
176
+
177
+ # check if a shape is selected and only move that
178
+ if self.drawing_mode and not self.selected_shape and self.currently_drawn_shape is None:
179
+ # do not reset shape if not done drawing...
180
+ if self.shape_to_draw is not None:
181
+ self.currently_drawn_shape = self.shape_to_draw()
182
+ else:
183
+ self.currently_drawn_shape = None
184
+ if self.drawing_mode and not self.selected_shape:
185
+ if self.currently_drawn_shape is not None:
186
+ self.currently_drawn_shape.setTopLeft(QPointF(self.lastPoint.x(), self.lastPoint.y()))
187
+
188
+ def mouseMoveEvent(self, event):
189
+ if event.buttons() and QtCore.Qt.LeftButton:
190
+ if self.selected_shape and self.currently_drawn_shape is None:
191
+ logger.debug('moving' + str(self.selected_shape))
192
+ for shape in self.selected_shape:
193
+ shape.translate(event.position() / self.scale - self.lastPoint)
194
+
195
+ if self.currently_drawn_shape is not None:
196
+ self.currently_drawn_shape.add(self.firstPoint, self.lastPoint)
197
+
198
+ self.lastPoint = event.position() / self.scale
199
+
200
+ def mouseReleaseEvent(self, event):
201
+ if event.button() == QtCore.Qt.LeftButton:
202
+ self.lastPoint = event.position() / self.scale
203
+ self.drawing = False
204
+ if self.drawing_mode and self.currently_drawn_shape is not None:
205
+ self.currently_drawn_shape.add(self.firstPoint, self.lastPoint)
206
+ if isinstance(self.currently_drawn_shape, Freehand2D):
207
+ # this closes the freehand shape
208
+ self.currently_drawn_shape.add(self.lastPoint, self.firstPoint)
209
+ # should not erase the shape if it's a polyline or a polygon by the way
210
+ if isinstance(self.currently_drawn_shape, Freehand2D) or (not isinstance(self.currently_drawn_shape, PolyLine2D) and not isinstance(self.currently_drawn_shape, Polygon2D)):
211
+ if self.check_shape_size_before_adding_it():
212
+ self.shapes.append(self.currently_drawn_shape)
213
+ self.selected_shape = [self.currently_drawn_shape]
214
+ self.currently_drawn_shape = None
215
+ else:
216
+ self.currently_drawn_shape = None
217
+ self.selected_shape = []
218
+
219
+ else:
220
+ self.currently_drawn_shape=None
221
+ self.selected_shape = []
222
+
223
+ def mouseDoubleClickEvent(self, event):
224
+ if isinstance(self.currently_drawn_shape, PolyLine2D) or isinstance(self.currently_drawn_shape, Polygon2D):
225
+ self.shapes.append(self.currently_drawn_shape)
226
+ self.currently_drawn_shape = None
227
+
228
+ def check_shape_size_before_adding_it(self):
229
+ if self.filter_out_unwanted_shapes_based_on_distance: # TODO maybe allow arrowheads to be drawn and stay small, allow lines only if they are in arrwohed only mode (if so do not allow the body of the li,ne to be drawn)
230
+ # if the movement is too small and the object is not a point then the shape drawing is probably undesised!!!
231
+ # print(self.firstPoint , self.lastPoint)
232
+ # print('distance', self.distance(self.firstPoint, self.lastPoint))
233
+ # print('scaled distance', self.distance(self.firstPoint, self.lastPoint)*self.scale)
234
+ # if self.distance(self.firstPoint, self.lastPoint) < 20:
235
+ # best is to look
236
+ # print(self.currently_drawn_shape.getRect())
237
+ rect = self.currently_drawn_shape.getRect()
238
+
239
+ print(rect, self.scale)
240
+
241
+
242
+ print('area to check',rect.width()* rect.height()*self.scale)
243
+ if not isinstance(self.currently_drawn_shape,(Point2D, TAText2D, Line2D)) and rect.width()* rect.height()*self.scale<200:
244
+
245
+
246
+ # if not isinstance(self.currently_drawn_shape,(Point2D)) and self.distance(self.firstPoint,self.lastPoint) * self.scale < 40: # , Polygon2D, PolyLine2D, Freehand2D)
247
+ logger.warning(str(self.currently_drawn_shape) + '-->' +
248
+ 'area of object is too small, drawing is ignored, the software assumes unintended drawing, zoom more (Ctrl/Cmd +) and redraw the shape if wanted')
249
+ self.currently_drawn_shape = None
250
+ # self.update()
251
+ # print(distance )
252
+ return False
253
+ return True
254
+
255
+ if __name__ == '__main__':
256
+ VectorialDrawPane()
File without changes