batoolset 0.1.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.
- batoolset/GUI/__init__.py +0 -0
- batoolset/GUI/list_gui.py +513 -0
- batoolset/GUI/multi_image_display.py +989 -0
- batoolset/GUI/open.py +325 -0
- batoolset/GUI/overlay_hints.py +45 -0
- batoolset/GUI/paint2.py +1345 -0
- batoolset/GUI/scrollablepaint.py +1152 -0
- batoolset/IJ_ROIs/__init__.py +0 -0
- batoolset/IJ_ROIs/tools.py +40 -0
- batoolset/PATH/__init__.py +0 -0
- batoolset/PATH/tools.py +79 -0
- batoolset/SQLite_tools/__init__.py +0 -0
- batoolset/SQLite_tools/tools.py +840 -0
- batoolset/__init__.py +0 -0
- batoolset/binary/__init__.py +0 -0
- batoolset/binary/tools.py +123 -0
- batoolset/binarytools/__init__.py +0 -0
- batoolset/binarytools/cell_center_detector.py +290 -0
- batoolset/clipboard_tools/__init__.py +0 -0
- batoolset/clipboard_tools/tools.py +7 -0
- batoolset/colors/__init__.py +0 -0
- batoolset/colors/colorgen.py +193 -0
- batoolset/colors/tools.py +22 -0
- batoolset/command_line/__init__.py +0 -0
- batoolset/command_line/tools.py +18 -0
- batoolset/dialogs/__init__.py +0 -0
- batoolset/dialogs/opensave.py +228 -0
- batoolset/dicts/__init__.py +0 -0
- batoolset/dicts/tools.py +299 -0
- batoolset/dims/__init__.py +0 -0
- batoolset/dims/tools.py +83 -0
- batoolset/draw/__init__.py +0 -0
- batoolset/draw/shapes/Position.py +183 -0
- batoolset/draw/shapes/__init__.py +0 -0
- batoolset/draw/shapes/automated_alignment_drawing_refactored.py +346 -0
- batoolset/draw/shapes/circle2d.py +99 -0
- batoolset/draw/shapes/compute_optimal_size_all_merged.py +317 -0
- batoolset/draw/shapes/ellipse2d.py +336 -0
- batoolset/draw/shapes/freehand2d.py +235 -0
- batoolset/draw/shapes/group.py +1830 -0
- batoolset/draw/shapes/image2d.py +2469 -0
- batoolset/draw/shapes/line2d.py +575 -0
- batoolset/draw/shapes/point2d.py +257 -0
- batoolset/draw/shapes/polygon2d.py +357 -0
- batoolset/draw/shapes/polyline2d.py +235 -0
- batoolset/draw/shapes/rect2d.py +388 -0
- batoolset/draw/shapes/rectangle2d.py +601 -0
- batoolset/draw/shapes/scalebar.py +304 -0
- batoolset/draw/shapes/serializablefont.py +126 -0
- batoolset/draw/shapes/serializableguiparams.py +10 -0
- batoolset/draw/shapes/square2d.py +103 -0
- batoolset/draw/shapes/textorientation.py +45 -0
- batoolset/draw/shapes/tools.py +467 -0
- batoolset/draw/shapes/transform2D.py +350 -0
- batoolset/draw/shapes/txt2d.py +550 -0
- batoolset/draw/widgets/__init__.py +0 -0
- batoolset/draw/widgets/col.py +343 -0
- batoolset/draw/widgets/image_group.py +248 -0
- batoolset/draw/widgets/image_organizer.py +96 -0
- batoolset/draw/widgets/paint.py +184 -0
- batoolset/draw/widgets/vectorial.py +257 -0
- batoolset/figure/__init__.py +0 -0
- batoolset/figure/alignment.py +814 -0
- batoolset/figure/column.py +1117 -0
- batoolset/figure/fig_tools.py +285 -0
- batoolset/figure/minimal_debugger_scale_etc.py +139 -0
- batoolset/figure/panel.py +697 -0
- batoolset/figure/row.py +852 -0
- batoolset/figure/user_selection.py +287 -0
- batoolset/files/__init__.py +0 -0
- batoolset/files/tools.py +1321 -0
- batoolset/images/__init__.py +0 -0
- batoolset/images/tools.py +81 -0
- batoolset/img.py +5216 -0
- batoolset/linux/__init__.py +0 -0
- batoolset/linux/tools.py +72 -0
- batoolset/lists/__init__.py +0 -0
- batoolset/lists/tools.py +436 -0
- batoolset/luts/__init__.py +0 -0
- batoolset/luts/lut_minimal_test.py +1207 -0
- batoolset/matplolib/__init__.py +0 -0
- batoolset/matplolib/tools.py +44 -0
- batoolset/np_tools/__init__.py +0 -0
- batoolset/np_tools/tools.py +252 -0
- batoolset/np_tools/trash.py +15 -0
- batoolset/pandas_tools/__init__.py +0 -0
- batoolset/pandas_tools/tools.py +880 -0
- batoolset/partials/__init__.py +0 -0
- batoolset/partials/tools.py +83 -0
- batoolset/plot_tools/__init__.py +0 -0
- batoolset/plot_tools/tools.py +70 -0
- batoolset/pyqt/__init__.py +0 -0
- batoolset/pyqt/tools.py +691 -0
- batoolset/re_tools/__init__.py +0 -0
- batoolset/re_tools/tools.py +35 -0
- batoolset/serialization/__init__.py +0 -0
- batoolset/serialization/tools.py +1192 -0
- batoolset/sets/__init__.py +0 -0
- batoolset/sets/tools.py +109 -0
- batoolset/settings/__init__.py +0 -0
- batoolset/settings/global_settings.py +134 -0
- batoolset/strings/__init__.py +0 -0
- batoolset/strings/tools.py +225 -0
- batoolset/ta/__init__.py +0 -0
- batoolset/ta/database/__init__.py +0 -0
- batoolset/ta/database/advanced_sql_plotter.py +1170 -0
- batoolset/ta/database/my_qt_table.py +79 -0
- batoolset/ta/database/preview_and_edit_sqlite_db.py +405 -0
- batoolset/ta/database/sql.py +2141 -0
- batoolset/ta/database/sql_column_name_dialog.py +122 -0
- batoolset/ta/measurements/TAmeasures.py +2226 -0
- batoolset/ta/measurements/__init__.py +0 -0
- batoolset/ta/measurements/measurements3D/__init__.py +0 -0
- batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +175 -0
- batoolset/ta/measurements/measurements3D/height_map_to_projection.py +82 -0
- batoolset/ta/measurements/measurements3D/measures3D.py +208 -0
- batoolset/ta/measurements/measurements3D/triangulate.py +331 -0
- batoolset/ta/measurements/nematic.py +562 -0
- batoolset/ta/measurements/nematic_measurements.py +107 -0
- batoolset/ta/segmentation/__init__.py +0 -0
- batoolset/ta/segmentation/neo_wshed.py +314 -0
- batoolset/ta/selections/__init__.py +0 -0
- batoolset/ta/selections/selection.py +329 -0
- batoolset/ta/tracking/__init__.py +0 -0
- batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +653 -0
- batoolset/ta/tracking/local_to_track_correspondance.py +138 -0
- batoolset/ta/tracking/rapid_detection_of_vertices.py +517 -0
- batoolset/ta/tracking/registration.py +108 -0
- batoolset/ta/tracking/swap_detector_and_fixer.py +296 -0
- batoolset/ta/tracking/track_correction.py +238 -0
- batoolset/ta/tracking/tracking_error_detector_and_fixer.py +3099 -0
- batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +725 -0
- batoolset/ta/utils/TA_tools.py +43 -0
- batoolset/ta/utils/__init__.py +0 -0
- batoolset/ta/utils/rps_tools.py +1783 -0
- batoolset/tests/__init__.py +0 -0
- batoolset/tests/rps_tools.py +51 -0
- batoolset/tests/tools.py +10 -0
- batoolset/tools/__init__.py +0 -0
- batoolset/tools/early_stopper_class.py +9 -0
- batoolset/tools/guided_data_recoverer.py +110 -0
- batoolset/tools/logger.py +100 -0
- batoolset/tools/mytimer.py +31 -0
- batoolset/tools/prompt_color.py +160 -0
- batoolset/tools/qthandler.py +118 -0
- batoolset/uitools/__init__.py +0 -0
- batoolset/uitools/blinker.py +56 -0
- batoolset/unsafe/__init__.py +0 -0
- batoolset/unsafe/tools.py +115 -0
- batoolset/utils/__init__.py +0 -0
- batoolset/utils/commontools.py +158 -0
- batoolset/utils/loadlist.py +728 -0
- batoolset/version.py +10 -0
- batoolset/xml/__init__.py +0 -0
- batoolset/xml/tools.py +65 -0
- batoolset/zip_tools/__init__.py +0 -0
- batoolset/zip_tools/tools.py +76 -0
- batoolset-0.1.0.dist-info/LICENSE +24 -0
- batoolset-0.1.0.dist-info/METADATA +45 -0
- batoolset-0.1.0.dist-info/RECORD +162 -0
- batoolset-0.1.0.dist-info/WHEEL +5 -0
- batoolset-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
from batoolset.settings.global_settings import set_UI # set the UI to qtpy
|
|
2
|
+
set_UI()
|
|
3
|
+
from batoolset.draw.shapes.freehand2d import Freehand2D
|
|
4
|
+
from batoolset.draw.shapes.polyline2d import PolyLine2D
|
|
5
|
+
from batoolset.serialization.tools import clone_object
|
|
6
|
+
from qtpy.QtCore import QRectF, QPointF,QPoint
|
|
7
|
+
from qtpy.QtGui import QTransform, QPolygonF,QPolygon
|
|
8
|
+
import numpy as np
|
|
9
|
+
from batoolset.draw.shapes import polyline2d, freehand2d
|
|
10
|
+
from batoolset.draw.shapes.ellipse2d import Ellipse2D
|
|
11
|
+
from batoolset.draw.shapes.line2d import Line2D
|
|
12
|
+
from batoolset.draw.shapes.point2d import Point2D
|
|
13
|
+
from batoolset.draw.shapes.polygon2d import Polygon2D
|
|
14
|
+
from batoolset.draw.shapes.rectangle2d import Rectangle2D
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def translated(shape, point):
|
|
18
|
+
# get the rotated
|
|
19
|
+
|
|
20
|
+
# if not centroid:
|
|
21
|
+
centroid = get_centroid(get_points(shape))
|
|
22
|
+
|
|
23
|
+
if isinstance(centroid, (QPointF, QPoint)):
|
|
24
|
+
centroid = (centroid.x(), centroid.y())
|
|
25
|
+
|
|
26
|
+
# new_centoid=
|
|
27
|
+
transform = Transform2D()
|
|
28
|
+
transform.translate(point[0], point[1])
|
|
29
|
+
|
|
30
|
+
print(centroid)
|
|
31
|
+
|
|
32
|
+
centroid = transform.apply(centroid)
|
|
33
|
+
|
|
34
|
+
print('after', centroid)
|
|
35
|
+
|
|
36
|
+
# then see how to return the modified shape
|
|
37
|
+
# whatever the shape I need to center it to some position
|
|
38
|
+
# and to clone it
|
|
39
|
+
|
|
40
|
+
clone = clone_object(shape)
|
|
41
|
+
# clone.theta = clone.theta+angle
|
|
42
|
+
# then I need to center the stuff
|
|
43
|
+
clone.set_to_center(centroid)
|
|
44
|
+
|
|
45
|
+
# in some cases I may need to do more crazy stuff
|
|
46
|
+
|
|
47
|
+
return clone
|
|
48
|
+
|
|
49
|
+
def rotated(shape, angle, centroid=None):
|
|
50
|
+
# get the rotated
|
|
51
|
+
|
|
52
|
+
if not centroid:
|
|
53
|
+
centroid = get_centroid(get_points(shape))
|
|
54
|
+
|
|
55
|
+
if isinstance(centroid, (QPointF, QPoint)):
|
|
56
|
+
centroid = (centroid.x(), centroid.y())
|
|
57
|
+
|
|
58
|
+
# new_centoid=
|
|
59
|
+
transform = Transform2D()
|
|
60
|
+
transform.translate(centroid[0], centroid[1])
|
|
61
|
+
transform.rotate(angle)
|
|
62
|
+
transform.translate(-centroid[0], -centroid[1])
|
|
63
|
+
|
|
64
|
+
centroid = transform.apply(centroid)
|
|
65
|
+
# then see how to return the modified shape
|
|
66
|
+
# whatever the shape I need to center it to some position
|
|
67
|
+
# and to clone it
|
|
68
|
+
|
|
69
|
+
clone = clone_object(shape)
|
|
70
|
+
clone.theta = clone.theta+angle
|
|
71
|
+
# then I need to center the stuff
|
|
72
|
+
clone.set_to_center(centroid)
|
|
73
|
+
|
|
74
|
+
# in some cases I may need to do more crazy stuff
|
|
75
|
+
|
|
76
|
+
return clone
|
|
77
|
+
|
|
78
|
+
def get_centroid(points):
|
|
79
|
+
"""Calculate the centroid of a list of 2D points.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
points (list of tuple): List of (x, y) points.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
tuple: The (x, y) coordinates of the centroid.
|
|
86
|
+
"""
|
|
87
|
+
if not points:
|
|
88
|
+
raise ValueError("The list of points is empty.")
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
x_coords = [p[0] for p in points]
|
|
92
|
+
y_coords = [p[1] for p in points]
|
|
93
|
+
except:
|
|
94
|
+
x_coords = [p.x() for p in points]
|
|
95
|
+
y_coords = [p.y() for p in points]
|
|
96
|
+
|
|
97
|
+
centroid_x = sum(x_coords) / len(points)
|
|
98
|
+
centroid_y = sum(y_coords) / len(points)
|
|
99
|
+
|
|
100
|
+
return centroid_x, centroid_y
|
|
101
|
+
|
|
102
|
+
def get_points(shape):
|
|
103
|
+
|
|
104
|
+
# TODO --> I could do that for all shapes
|
|
105
|
+
if isinstance(shape, QRectF):
|
|
106
|
+
"""Get the corners/vertices of a QRectF.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
rect (QRectF): The rectangle from which to get the corners.
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
list of tuple: A list containing the corners (x, y).
|
|
113
|
+
"""
|
|
114
|
+
top_left = (shape.topLeft().x(), shape.topLeft().y())
|
|
115
|
+
top_right = (shape.topRight().x(), shape.topRight().y())
|
|
116
|
+
bottom_left = (shape.bottomLeft().x(), shape.bottomLeft().y())
|
|
117
|
+
bottom_right = (shape.bottomRight().x(), shape.bottomRight().y())
|
|
118
|
+
|
|
119
|
+
return [top_left, top_right, bottom_left, bottom_right]
|
|
120
|
+
elif isinstance(shape, (QPolygon, QPolygonF, Polygon2D, PolyLine2D, Freehand2D)):
|
|
121
|
+
# print('entering')
|
|
122
|
+
vertices = []
|
|
123
|
+
for point in shape:
|
|
124
|
+
vertices.append((point.x(), point.y()))
|
|
125
|
+
if shape.first() == shape.last(): # if poly is closed --> remove the point
|
|
126
|
+
vertices=vertices[:-1]
|
|
127
|
+
return vertices
|
|
128
|
+
elif isinstance(shape,Point2D):
|
|
129
|
+
return [(shape.x(), shape.y())]
|
|
130
|
+
elif isinstance(shape,Line2D):
|
|
131
|
+
return [((shape.x1()+shape.x2())/2., (shape.y1()+shape.y2())/2.)]
|
|
132
|
+
elif isinstance(shape,Rectangle2D):
|
|
133
|
+
return [shape.top_left(), shape.top_right(), shape.bottom_left(), shape.bottom_right()]
|
|
134
|
+
elif isinstance(shape, Line2D):
|
|
135
|
+
return [(shape.x1(), shape.y1()), (shape.x2(), shape.y2())]
|
|
136
|
+
elif isinstance(shape, Line2D):
|
|
137
|
+
return [(shape.x1(), shape.y1()), (shape.x2(), shape.y2())]
|
|
138
|
+
# elif isinstance(shape, Ellipse2D): # probably need the rect
|
|
139
|
+
#
|
|
140
|
+
|
|
141
|
+
def get_bounding_rect(points, return_qrectf=False):
|
|
142
|
+
"""Get the bounding rectangle of a list of 2D points.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
points (list of tuple): List of (x, y) points.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
tuple: (min_x, min_y, max_x, max_y) representing the bounding rectangle.
|
|
149
|
+
"""
|
|
150
|
+
if not points:
|
|
151
|
+
raise ValueError("The list of points is empty.")
|
|
152
|
+
|
|
153
|
+
# Initialize the min and max values with the first point
|
|
154
|
+
min_x, min_y = points[0]
|
|
155
|
+
max_x, max_y = points[0]
|
|
156
|
+
|
|
157
|
+
# Iterate over all points to find the min and max x and y values
|
|
158
|
+
for (x, y) in points:
|
|
159
|
+
if x < min_x:
|
|
160
|
+
min_x = x
|
|
161
|
+
if x > max_x:
|
|
162
|
+
max_x = x
|
|
163
|
+
if y < min_y:
|
|
164
|
+
min_y = y
|
|
165
|
+
if y > max_y:
|
|
166
|
+
max_y = y
|
|
167
|
+
if return_qrectf:
|
|
168
|
+
return QRectF(min_x, min_y, max_x-min_x, max_y-min_y)
|
|
169
|
+
return min_x, min_y, max_x, max_y
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class Transform2D:
|
|
173
|
+
def __init__(self):
|
|
174
|
+
# Initialize with the identity matrix
|
|
175
|
+
self.matrix = np.identity(3)
|
|
176
|
+
|
|
177
|
+
def translate(self, tx, ty):
|
|
178
|
+
"""Apply a translation by (tx, ty)."""
|
|
179
|
+
translation_matrix = np.array([
|
|
180
|
+
[1, 0, tx],
|
|
181
|
+
[0, 1, ty],
|
|
182
|
+
[0, 0, 1]
|
|
183
|
+
])
|
|
184
|
+
self.matrix = np.dot(self.matrix, translation_matrix)
|
|
185
|
+
return self
|
|
186
|
+
|
|
187
|
+
def rotate(self, theta):
|
|
188
|
+
"""Apply a rotation by theta degrees."""
|
|
189
|
+
radians = np.radians(theta)
|
|
190
|
+
cos_theta = np.cos(radians)
|
|
191
|
+
sin_theta = np.sin(radians)
|
|
192
|
+
rotation_matrix = np.array([
|
|
193
|
+
[cos_theta, -sin_theta, 0],
|
|
194
|
+
[sin_theta, cos_theta, 0],
|
|
195
|
+
[0, 0, 1]
|
|
196
|
+
])
|
|
197
|
+
self.matrix = np.dot(self.matrix, rotation_matrix)
|
|
198
|
+
return self
|
|
199
|
+
|
|
200
|
+
def scale(self, sx, sy):
|
|
201
|
+
"""Apply scaling by (sx, sy)."""
|
|
202
|
+
scale_matrix = np.array([
|
|
203
|
+
[sx, 0, 0],
|
|
204
|
+
[0, sy, 0],
|
|
205
|
+
[0, 0, 1]
|
|
206
|
+
])
|
|
207
|
+
self.matrix = np.dot(self.matrix, scale_matrix)
|
|
208
|
+
return self
|
|
209
|
+
|
|
210
|
+
def apply(self, points, auto_unpack_if_single=True):
|
|
211
|
+
"""Apply the transformation to a list of 2D points."""
|
|
212
|
+
if isinstance(points, tuple):
|
|
213
|
+
points=[points]
|
|
214
|
+
transformed_points = []
|
|
215
|
+
for point in points:
|
|
216
|
+
x, y = point
|
|
217
|
+
# Homogeneous coordinate vector
|
|
218
|
+
point_matrix = np.array([x, y, 1])
|
|
219
|
+
transformed_point = np.dot(self.matrix, point_matrix)
|
|
220
|
+
transformed_points.append((transformed_point[0], transformed_point[1]))
|
|
221
|
+
if auto_unpack_if_single and len(transformed_points)==1:
|
|
222
|
+
return transformed_points[0]
|
|
223
|
+
return transformed_points
|
|
224
|
+
|
|
225
|
+
def reset(self):
|
|
226
|
+
"""Reset the transformation matrix to the identity matrix."""
|
|
227
|
+
self.matrix = np.identity(3)
|
|
228
|
+
return self
|
|
229
|
+
|
|
230
|
+
def get_matrix(self):
|
|
231
|
+
"""Get the current transformation matrix."""
|
|
232
|
+
return self.matrix
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
if __name__ == '__main__':
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# Example usage
|
|
242
|
+
transform = Transform2D()
|
|
243
|
+
transform.translate(2, 3).rotate(45).scale(2, 2)
|
|
244
|
+
points = [(1, 1), (2, 2), (3, 3)]
|
|
245
|
+
transformed_points = transform.apply(points)
|
|
246
|
+
print("Transformed Points:", transformed_points)
|
|
247
|
+
print("Transformation Matrix:\n", transform.get_matrix())
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
transform = Transform2D()
|
|
251
|
+
transform.translate(-10,10).translate(10,-10)
|
|
252
|
+
print(transform.apply(points)) # does not work
|
|
253
|
+
print("Transformation Matrix:\n", transform.get_matrix())
|
|
254
|
+
|
|
255
|
+
# now implement that for squares and other shapes --> TODO
|
|
256
|
+
# very good that works
|
|
257
|
+
transform = Transform2D()
|
|
258
|
+
transform.translate(0, 0).translate(1,-1)
|
|
259
|
+
print(transform.apply(points)) # does not work
|
|
260
|
+
print("Transformation Matrix:\n", transform.get_matrix())
|
|
261
|
+
|
|
262
|
+
# points = [(10,20), (200+10,300+20), (210,20), (10, 320)]
|
|
263
|
+
rect = QRectF(10,20,200, 300)
|
|
264
|
+
points = get_points(rect)
|
|
265
|
+
print('points',points)
|
|
266
|
+
print('get_centroid',get_centroid(points))
|
|
267
|
+
center = rect.center()
|
|
268
|
+
points.append((center.x(),center.y()))
|
|
269
|
+
|
|
270
|
+
print(center)
|
|
271
|
+
transform = Transform2D()
|
|
272
|
+
transform.translate(center.x(),center.y())
|
|
273
|
+
transform.rotate(45)
|
|
274
|
+
transform.translate(-center.x(),-center.y())
|
|
275
|
+
|
|
276
|
+
print(transform.apply(points))
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
qtrafo = QTransform()
|
|
280
|
+
qtrafo.translate(center.x(), center.y())
|
|
281
|
+
qtrafo.rotate(45)
|
|
282
|
+
qtrafo.translate(-center.x(), -center.y())
|
|
283
|
+
|
|
284
|
+
print(qtrafo.map(10,20))
|
|
285
|
+
print(qtrafo.map(210,320))
|
|
286
|
+
print(qtrafo.map(center.x(),center.y()))
|
|
287
|
+
|
|
288
|
+
# Example usage
|
|
289
|
+
# points = [(1, 1), (2, 2), (3, 3), (-1, -1), (4, 0)]
|
|
290
|
+
bounding_rect = get_bounding_rect(points)
|
|
291
|
+
print("Bounding Rectangle:", bounding_rect)
|
|
292
|
+
|
|
293
|
+
# is that really correct --> looks like there is a bug!!!
|
|
294
|
+
|
|
295
|
+
print(get_bounding_rect(transform.apply(points)))
|
|
296
|
+
print(qtrafo.mapRect(rect)) # la sortie est pas du tout la meme
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
print(get_bounding_rect(transform.apply(points), return_qrectf=True)) # no it's ok but I really need the four corner to get the real bounding rect
|
|
300
|
+
# and then that works perfectly
|
|
301
|
+
|
|
302
|
+
polygon = QPolygonF([QPointF(0, 0), QPointF(1, 1), QPointF(2, 0), QPointF(1, -1)])
|
|
303
|
+
print(polygon.isClosed())
|
|
304
|
+
vertices = get_points(polygon)
|
|
305
|
+
print(vertices)
|
|
306
|
+
if polygon.first() != polygon.last():
|
|
307
|
+
polygon.append(polygon.first())
|
|
308
|
+
vertices = get_points(polygon)
|
|
309
|
+
print(vertices)
|
|
310
|
+
|
|
311
|
+
# what is map rect doing in fact
|
|
312
|
+
# the map rect seems to work though
|
|
313
|
+
|
|
314
|
+
vertices2 = []
|
|
315
|
+
for vx in vertices:
|
|
316
|
+
vertices2.append(vx[0])
|
|
317
|
+
vertices2.append(vx[1])
|
|
318
|
+
print(len(vertices2))
|
|
319
|
+
# poly = Polygon2D(*vertices2)
|
|
320
|
+
p2d = Polygon2D(*vertices)
|
|
321
|
+
|
|
322
|
+
print(get_points(p2d))
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
print('p2d rot',rotated(p2d, 45).listVertices()) # pb is that it creates super minor rounding errors but maybe still ok!!!
|
|
326
|
+
print('p2d rot',rotated(p2d, 45,(256,256)).listVertices()) # pb is that it creates super minor rounding errors but maybe still ok!!!
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
# maybe that works
|
|
330
|
+
# just try it maybe
|
|
331
|
+
|
|
332
|
+
r2d = Rectangle2D(0,0,256,516)
|
|
333
|
+
print('rect rot',rotated(r2d, 90).boundingRect())
|
|
334
|
+
print('rect rot',rotated(r2d, 90,(256,256)).boundingRect())
|
|
335
|
+
|
|
336
|
+
print('dab', r2d.x(), r2d.y(), r2d.width(), r2d.height())
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
print(r2d.boundingRect().center(), 'vs',get_centroid(get_points(r2d)), get_points(r2d))
|
|
340
|
+
trans = translated(r2d,(10,25))
|
|
341
|
+
print('dab',trans.x(),trans.y(), trans.width(), trans.height(), trans.boundingRect())
|
|
342
|
+
# --> à tester --> mais peut etre ok --> dessiner ttes les shapes tournées dans le truc # see if I can chain things or not ???
|
|
343
|
+
|
|
344
|
+
# bug
|
|
345
|
+
|
|
346
|
+
el2d = Ellipse2D(0,0,256,512)
|
|
347
|
+
trans =translated(r2d, (10, 25))
|
|
348
|
+
print(trans.x(),trans.y(), trans.width(), trans.height()) # --> ok it seems
|
|
349
|
+
|
|
350
|
+
# TODO --> maybe try all for real now
|