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.
Files changed (162) hide show
  1. batoolset/GUI/__init__.py +0 -0
  2. batoolset/GUI/list_gui.py +513 -0
  3. batoolset/GUI/multi_image_display.py +989 -0
  4. batoolset/GUI/open.py +325 -0
  5. batoolset/GUI/overlay_hints.py +45 -0
  6. batoolset/GUI/paint2.py +1345 -0
  7. batoolset/GUI/scrollablepaint.py +1152 -0
  8. batoolset/IJ_ROIs/__init__.py +0 -0
  9. batoolset/IJ_ROIs/tools.py +40 -0
  10. batoolset/PATH/__init__.py +0 -0
  11. batoolset/PATH/tools.py +79 -0
  12. batoolset/SQLite_tools/__init__.py +0 -0
  13. batoolset/SQLite_tools/tools.py +840 -0
  14. batoolset/__init__.py +0 -0
  15. batoolset/binary/__init__.py +0 -0
  16. batoolset/binary/tools.py +123 -0
  17. batoolset/binarytools/__init__.py +0 -0
  18. batoolset/binarytools/cell_center_detector.py +290 -0
  19. batoolset/clipboard_tools/__init__.py +0 -0
  20. batoolset/clipboard_tools/tools.py +7 -0
  21. batoolset/colors/__init__.py +0 -0
  22. batoolset/colors/colorgen.py +193 -0
  23. batoolset/colors/tools.py +22 -0
  24. batoolset/command_line/__init__.py +0 -0
  25. batoolset/command_line/tools.py +18 -0
  26. batoolset/dialogs/__init__.py +0 -0
  27. batoolset/dialogs/opensave.py +228 -0
  28. batoolset/dicts/__init__.py +0 -0
  29. batoolset/dicts/tools.py +299 -0
  30. batoolset/dims/__init__.py +0 -0
  31. batoolset/dims/tools.py +83 -0
  32. batoolset/draw/__init__.py +0 -0
  33. batoolset/draw/shapes/Position.py +183 -0
  34. batoolset/draw/shapes/__init__.py +0 -0
  35. batoolset/draw/shapes/automated_alignment_drawing_refactored.py +346 -0
  36. batoolset/draw/shapes/circle2d.py +99 -0
  37. batoolset/draw/shapes/compute_optimal_size_all_merged.py +317 -0
  38. batoolset/draw/shapes/ellipse2d.py +336 -0
  39. batoolset/draw/shapes/freehand2d.py +235 -0
  40. batoolset/draw/shapes/group.py +1830 -0
  41. batoolset/draw/shapes/image2d.py +2469 -0
  42. batoolset/draw/shapes/line2d.py +575 -0
  43. batoolset/draw/shapes/point2d.py +257 -0
  44. batoolset/draw/shapes/polygon2d.py +357 -0
  45. batoolset/draw/shapes/polyline2d.py +235 -0
  46. batoolset/draw/shapes/rect2d.py +388 -0
  47. batoolset/draw/shapes/rectangle2d.py +601 -0
  48. batoolset/draw/shapes/scalebar.py +304 -0
  49. batoolset/draw/shapes/serializablefont.py +126 -0
  50. batoolset/draw/shapes/serializableguiparams.py +10 -0
  51. batoolset/draw/shapes/square2d.py +103 -0
  52. batoolset/draw/shapes/textorientation.py +45 -0
  53. batoolset/draw/shapes/tools.py +467 -0
  54. batoolset/draw/shapes/transform2D.py +350 -0
  55. batoolset/draw/shapes/txt2d.py +550 -0
  56. batoolset/draw/widgets/__init__.py +0 -0
  57. batoolset/draw/widgets/col.py +343 -0
  58. batoolset/draw/widgets/image_group.py +248 -0
  59. batoolset/draw/widgets/image_organizer.py +96 -0
  60. batoolset/draw/widgets/paint.py +184 -0
  61. batoolset/draw/widgets/vectorial.py +257 -0
  62. batoolset/figure/__init__.py +0 -0
  63. batoolset/figure/alignment.py +814 -0
  64. batoolset/figure/column.py +1117 -0
  65. batoolset/figure/fig_tools.py +285 -0
  66. batoolset/figure/minimal_debugger_scale_etc.py +139 -0
  67. batoolset/figure/panel.py +697 -0
  68. batoolset/figure/row.py +852 -0
  69. batoolset/figure/user_selection.py +287 -0
  70. batoolset/files/__init__.py +0 -0
  71. batoolset/files/tools.py +1321 -0
  72. batoolset/images/__init__.py +0 -0
  73. batoolset/images/tools.py +81 -0
  74. batoolset/img.py +5216 -0
  75. batoolset/linux/__init__.py +0 -0
  76. batoolset/linux/tools.py +72 -0
  77. batoolset/lists/__init__.py +0 -0
  78. batoolset/lists/tools.py +436 -0
  79. batoolset/luts/__init__.py +0 -0
  80. batoolset/luts/lut_minimal_test.py +1207 -0
  81. batoolset/matplolib/__init__.py +0 -0
  82. batoolset/matplolib/tools.py +44 -0
  83. batoolset/np_tools/__init__.py +0 -0
  84. batoolset/np_tools/tools.py +252 -0
  85. batoolset/np_tools/trash.py +15 -0
  86. batoolset/pandas_tools/__init__.py +0 -0
  87. batoolset/pandas_tools/tools.py +880 -0
  88. batoolset/partials/__init__.py +0 -0
  89. batoolset/partials/tools.py +83 -0
  90. batoolset/plot_tools/__init__.py +0 -0
  91. batoolset/plot_tools/tools.py +70 -0
  92. batoolset/pyqt/__init__.py +0 -0
  93. batoolset/pyqt/tools.py +691 -0
  94. batoolset/re_tools/__init__.py +0 -0
  95. batoolset/re_tools/tools.py +35 -0
  96. batoolset/serialization/__init__.py +0 -0
  97. batoolset/serialization/tools.py +1192 -0
  98. batoolset/sets/__init__.py +0 -0
  99. batoolset/sets/tools.py +109 -0
  100. batoolset/settings/__init__.py +0 -0
  101. batoolset/settings/global_settings.py +134 -0
  102. batoolset/strings/__init__.py +0 -0
  103. batoolset/strings/tools.py +225 -0
  104. batoolset/ta/__init__.py +0 -0
  105. batoolset/ta/database/__init__.py +0 -0
  106. batoolset/ta/database/advanced_sql_plotter.py +1170 -0
  107. batoolset/ta/database/my_qt_table.py +79 -0
  108. batoolset/ta/database/preview_and_edit_sqlite_db.py +405 -0
  109. batoolset/ta/database/sql.py +2141 -0
  110. batoolset/ta/database/sql_column_name_dialog.py +122 -0
  111. batoolset/ta/measurements/TAmeasures.py +2226 -0
  112. batoolset/ta/measurements/__init__.py +0 -0
  113. batoolset/ta/measurements/measurements3D/__init__.py +0 -0
  114. batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +175 -0
  115. batoolset/ta/measurements/measurements3D/height_map_to_projection.py +82 -0
  116. batoolset/ta/measurements/measurements3D/measures3D.py +208 -0
  117. batoolset/ta/measurements/measurements3D/triangulate.py +331 -0
  118. batoolset/ta/measurements/nematic.py +562 -0
  119. batoolset/ta/measurements/nematic_measurements.py +107 -0
  120. batoolset/ta/segmentation/__init__.py +0 -0
  121. batoolset/ta/segmentation/neo_wshed.py +314 -0
  122. batoolset/ta/selections/__init__.py +0 -0
  123. batoolset/ta/selections/selection.py +329 -0
  124. batoolset/ta/tracking/__init__.py +0 -0
  125. batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +653 -0
  126. batoolset/ta/tracking/local_to_track_correspondance.py +138 -0
  127. batoolset/ta/tracking/rapid_detection_of_vertices.py +517 -0
  128. batoolset/ta/tracking/registration.py +108 -0
  129. batoolset/ta/tracking/swap_detector_and_fixer.py +296 -0
  130. batoolset/ta/tracking/track_correction.py +238 -0
  131. batoolset/ta/tracking/tracking_error_detector_and_fixer.py +3099 -0
  132. batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +725 -0
  133. batoolset/ta/utils/TA_tools.py +43 -0
  134. batoolset/ta/utils/__init__.py +0 -0
  135. batoolset/ta/utils/rps_tools.py +1783 -0
  136. batoolset/tests/__init__.py +0 -0
  137. batoolset/tests/rps_tools.py +51 -0
  138. batoolset/tests/tools.py +10 -0
  139. batoolset/tools/__init__.py +0 -0
  140. batoolset/tools/early_stopper_class.py +9 -0
  141. batoolset/tools/guided_data_recoverer.py +110 -0
  142. batoolset/tools/logger.py +100 -0
  143. batoolset/tools/mytimer.py +31 -0
  144. batoolset/tools/prompt_color.py +160 -0
  145. batoolset/tools/qthandler.py +118 -0
  146. batoolset/uitools/__init__.py +0 -0
  147. batoolset/uitools/blinker.py +56 -0
  148. batoolset/unsafe/__init__.py +0 -0
  149. batoolset/unsafe/tools.py +115 -0
  150. batoolset/utils/__init__.py +0 -0
  151. batoolset/utils/commontools.py +158 -0
  152. batoolset/utils/loadlist.py +728 -0
  153. batoolset/version.py +10 -0
  154. batoolset/xml/__init__.py +0 -0
  155. batoolset/xml/tools.py +65 -0
  156. batoolset/zip_tools/__init__.py +0 -0
  157. batoolset/zip_tools/tools.py +76 -0
  158. batoolset-0.1.0.dist-info/LICENSE +24 -0
  159. batoolset-0.1.0.dist-info/METADATA +45 -0
  160. batoolset-0.1.0.dist-info/RECORD +162 -0
  161. batoolset-0.1.0.dist-info/WHEEL +5 -0
  162. batoolset-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,235 @@
1
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
2
+ set_UI()
3
+ import os
4
+ from qtpy import QtCore
5
+ from qtpy.QtCore import QPointF, Qt
6
+ from qtpy.QtGui import QPainter, QBrush, QPen, QImage, QColor
7
+ # from batoolset.draw.shapes.polygon2d import Polygon2D
8
+ # from qtpy.Qt
9
+ # from qtpy.Qt import (QPaintEngine, QPaintDevice, QTransform, QBrush)
10
+ from batoolset.draw.shapes.polygon2d import Polygon2D
11
+
12
+ from batoolset.tools.logger import TA_logger
13
+ logger = TA_logger()
14
+
15
+ class Freehand2D(Polygon2D):
16
+
17
+ def __init__(self, *args, coords_as_list=None, color=0xFFFFFF, opacity=1., stroke=0.65, line_style=None, theta=0, invert_coords=False, fill_color=None,__version__=1.0, **kwargs):
18
+ super(Freehand2D, self).__init__()
19
+ self.isSet = False
20
+ if len(args) > 0:
21
+ if isinstance(args[0],tuple):
22
+ for i in range(0, len(args)):
23
+ if invert_coords:
24
+ self.append(QPointF(args[i][1], args[i][0]))
25
+ else:
26
+ self.append(QPointF(args[i][0], args[i][1]))
27
+ # elif isinstance(args[0],QPolygonF):
28
+ #
29
+ else:
30
+ for i in range(0, len(args), 2):
31
+ if invert_coords:
32
+ self.append(QPointF(args[i+1], args[i]))
33
+ else:
34
+ self.append(QPointF(args[i], args[i+1]))
35
+
36
+ if coords_as_list:
37
+ for i in range(0, len(coords_as_list), 2):
38
+ self.append(QPointF(coords_as_list[i], coords_as_list[i + 1]))
39
+
40
+ self.color = color
41
+ self.fill_color = fill_color
42
+ self.stroke = stroke
43
+ self.opacity = opacity
44
+ self.line_style = line_style
45
+ # rotation
46
+ self.theta = theta
47
+ self.__version__ = __version__
48
+
49
+ # def draw(self, painter, draw=True):
50
+ # if self.color is None and self.fill_color is None:
51
+ # return
52
+ #
53
+ # if draw:
54
+ # painter.save()
55
+ # painter.setOpacity(self.opacity)
56
+ # if self.color is not None:
57
+ # pen = QPen(QColor(self.color))
58
+ # if self.stroke is not None:
59
+ # pen.setWidthF(self.stroke)
60
+ # if self.line_style is not None:
61
+ # if self.line_style in [Qt.SolidLine, Qt.DashLine, Qt.DashDotLine, Qt.DotLine, Qt.DashDotDotLine]:
62
+ # pen.setStyle(self.line_style)
63
+ # elif isinstance(self.line_style, list):
64
+ # pen.setStyle(Qt.CustomDashLine)
65
+ # pen.setDashPattern(self.line_style)
66
+ # painter.setPen(pen)
67
+ # else:
68
+ # painter.setPen(Qt.NoPen) # required to draw something filled without a border
69
+ # if self.fill_color is not None:
70
+ # painter.setBrush(QBrush(QColor(self.fill_color)))
71
+ # polygon_to_draw = self.translated(0, 0)
72
+ # if self.scale is not None and self.scale != 1:
73
+ # polygon_to_draw = self.__scaled()
74
+ #
75
+ # # print('mid rect_to_plot', rect_to_plot)
76
+ # if self.translation is not None:
77
+ # # rect_to_plot.setX(rect_to_plot.x()+self.translation.x())
78
+ # # rect_to_plot.setY(rect_to_plot.y()+self.translation.y())
79
+ # polygon_to_draw.translate(self.translation.x(), self.translation.y())
80
+ #
81
+ # if self.theta is not None and self.theta != 0:
82
+ # painter.translate(polygon_to_draw.center())
83
+ # painter.rotate(self.theta)
84
+ # painter.translate(-polygon_to_draw.center())
85
+ #
86
+ # if self.fill_color is not None:
87
+ # print('coloring')
88
+ # brush = QBrush(self.fill_color)
89
+ # painter.setBrush(brush)
90
+ #
91
+ # painter.drawPolygon(polygon_to_draw)
92
+ # painter.restore()
93
+ # it's simply a polygon so draw it as such
94
+
95
+ # def draw(self, painter, draw=True):
96
+ # if self.color is None and self.fill_color is None:
97
+ # return
98
+ #
99
+ # if draw:
100
+ # painter.save()
101
+ # pen = QPen(QColor(self.color))
102
+ # # pen.setStyle(Qt.SolidPattern)
103
+ # if self.stroke is not None:
104
+ # pen.setWidthF(self.stroke)
105
+ # if self.line_style is not None:
106
+ # if self.line_style in [Qt.SolidLine, Qt.DashLine, Qt.DashDotLine, Qt.DotLine, Qt.DashDotDotLine]:
107
+ # pen.setStyle(self.line_style)
108
+ # elif isinstance(self.line_style, list):
109
+ # pen.setStyle(Qt.CustomDashLine)
110
+ # pen.setDashPattern(self.line_style)
111
+ # painter.setPen(pen)
112
+ # painter.setOpacity(self.opacity)
113
+ # polyline_to_draw = self.translated(0, 0)
114
+ # if self.scale is not None and self.scale != 1:
115
+ # polyline_to_draw = self.__scaled()
116
+ # # print('mid rect_to_plot', rect_to_plot)
117
+ # if self.translation is not None:
118
+ # # rect_to_plot.setX(rect_to_plot.x()+self.translation.x())
119
+ # # rect_to_plot.setY(rect_to_plot.y()+self.translation.y())
120
+ # polyline_to_draw.translate(self.translation.x(), self.translation.y())
121
+ # # painter.drawPolygon(polygon_to_draw)
122
+ # if self.theta is not None and self.theta != 0:
123
+ # painter.translate(polyline_to_draw.boundingRect().center())
124
+ # painter.rotate(self.theta)
125
+ # painter.translate(-polyline_to_draw.boundingRect().center())
126
+ #
127
+ #
128
+ # if self.fill_color is not None:
129
+ #
130
+ # print('coloring')
131
+ # brush = QBrush(self.fill_color)
132
+ # painter.setBrush(brush)
133
+ #
134
+ # # painter.drawPolyline(polyline_to_draw)
135
+ # painter.drawPolygon(polyline_to_draw)
136
+ # # painter.toFillPolygon(polyline_to_draw)
137
+ # # painter.fill(polyline_to_draw)
138
+ # painter.restore()
139
+
140
+
141
+ # def draw(self, painter, draw=True):
142
+ # if draw:
143
+ # painter.save()
144
+ # pen = QPen(QColor(self.color))
145
+ # if self.stroke is not None:
146
+ # pen.setWidthF(self.stroke)
147
+ # painter.setPen(pen)
148
+ # painter.setOpacity(self.opacity)
149
+ # if draw:
150
+ # painter.drawPolyline(self)
151
+ # painter.restore()
152
+
153
+
154
+
155
+ # def fill(self, painter, draw=True):
156
+ # if self.fill_color is None:
157
+ # return
158
+ # if draw:
159
+ # painter.save()
160
+ # painter.setBrush(QBrush(QColor(self.fill_color)))
161
+ # painter.setOpacity(self.opacity)
162
+ # if draw:
163
+ # painter.drawPolyline(self)
164
+ # painter.restore()
165
+ #
166
+ # # TODO pb will draw the shape twice.... ---> because painter drawpolygon is called twice
167
+ # def drawAndFill(self, painter):
168
+ # painter.save()
169
+ # self.draw(painter, draw=False)
170
+ # self.fill(painter, draw=False)
171
+ # painter.drawPolyline(self)
172
+ # painter.restore()
173
+
174
+ # def setP1(self, point):
175
+ # self.append(point)
176
+
177
+ def add(self, *args):
178
+ self.append(args[1])
179
+ self.isSet=True
180
+
181
+
182
+
183
+ if __name__ == '__main__':
184
+ test = Freehand2D(0, 0, 10, 0, 10, 20, 0, 20, 0, 0)
185
+ print(test.count()) # marche pas --> pas ajouté
186
+ print(test)
187
+
188
+ hexagon = Freehand2D()
189
+ print(hexagon)
190
+ hexagon.append(QPointF(10, 20))
191
+ hexagon.append(QPointF(10, 30))
192
+ hexagon.append(QPointF(20, 30))
193
+
194
+ print(hexagon)
195
+ print(hexagon.isEmpty())
196
+ print(hexagon.count())
197
+ print(hexagon.stroke)
198
+ print(hexagon.get_stroke_size())
199
+ # ça marche maintenant
200
+ # print(hexagon.)
201
+ # trop cool l'acces aux points
202
+ for point in hexagon:
203
+ print(point)
204
+
205
+ print(hexagon.get_points())
206
+ print(hexagon.contains(QPointF(10, 20)))
207
+ print(hexagon.contains(QPointF(10, 21)))
208
+
209
+ print(hexagon.isClosed()) #
210
+ hexagon.append(QPointF(10, 20)) # closing the hexagon --> the last and first point should be the same
211
+ print(hexagon.isClosed()) #
212
+
213
+ image = QImage('/E/Sample_images/sample_images_PA/mini/focused_Series012/handCorrection.png')
214
+ painter = QPainter()
215
+ painter.begin(image)
216
+ # painter.setOpacity(0.3);
217
+ painter.drawImage(0, 0, image)
218
+ painter.setPen(QtCore.Qt.blue)
219
+ painter.drawPolygon(hexagon)
220
+ hexagon.opacity = 0.7
221
+ painter.translate(10, 20)
222
+ hexagon.draw(painter) # ça marche pourrait overloader ça avec du svg
223
+ painter.end()
224
+
225
+ # painter.save()
226
+ # painter.setCompositionMode(QtGui.QPainter.CompositionMode_Clear)
227
+ # painter.eraseRect(r)
228
+ # painter.restore()
229
+
230
+ image.save('/E/trash/test_pyQT_draw.png', "PNG");
231
+
232
+ #pas mal TODO faire une classe drawsmthg qui dessine n'importe quelle forme que l'on lui passe avec des parametres de couleur, transparence, ...
233
+
234
+ # tt marche aps mal ça va très vite
235
+