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,697 @@
|
|
|
1
|
+
# DEPRECATED!!!!!!!!!!!!!!!!!!!! use row and cols instead
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# deprecated cause not very useful cause can be changed easily
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# test of all then try to publish again
|
|
9
|
+
# see how to handle scale bars...
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# https://docs.python.org/2/library/operator.html
|
|
16
|
+
# can I have fractions also in panels to really create complex stuff --> maybe think about it though --> no it's probably not a good idea
|
|
17
|
+
# pb is if I add a panel to another it will be unpacked --> is that what I want ??? probably not I just want it to be added as one single image I guess
|
|
18
|
+
|
|
19
|
+
# finalement est ce qu'un vertical row ou horizontal row suffirait pas c'est un peu comme un qvboxlayou et un qhboxlayout
|
|
20
|
+
# puis je tout faire avec ça ??? peut etre en fait
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# vbox
|
|
24
|
+
# hbox
|
|
25
|
+
# fig serait un container de vbox et de hbox en fait --> puise-je tt faire avec ça peut etre
|
|
26
|
+
# ai-je besoin d'un panel en fait puisqu'un panel est juste un arrangement de vbox et de hbox
|
|
27
|
+
# le seul avantage c'est d'organiser les images en fait en 3*2 ou alike --> peut etre remettre row mais vraiment l'améliorer et garder le panel
|
|
28
|
+
# en fait le panel serait 2D sinon mieux vaut utiliser une vbox ou une hbox
|
|
29
|
+
# puis-je aussi faire un systeme de grid ??? pas si facile avec des images
|
|
30
|
+
|
|
31
|
+
import os
|
|
32
|
+
from batoolset.settings.global_settings import set_UI # set the UI to qtpy
|
|
33
|
+
set_UI()
|
|
34
|
+
from batoolset.draw.shapes.rect2d import Rect2D
|
|
35
|
+
from qtpy.QtCore import QPointF, QRectF
|
|
36
|
+
|
|
37
|
+
# from batoolset.figure.fig_tools import preview
|
|
38
|
+
from batoolset.figure.row import Row
|
|
39
|
+
# import math
|
|
40
|
+
# logger
|
|
41
|
+
from batoolset.tools.logger import TA_logger
|
|
42
|
+
|
|
43
|
+
# en fait
|
|
44
|
+
|
|
45
|
+
# TODO controler les set2width and settoheight de ce truc afin d'etre sur qu'ils fonctionnent car je ne pense pas que ce soit le cas en fait
|
|
46
|
+
|
|
47
|
+
logger = TA_logger(logging_level=TA_logger.DEBUG)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# can have a 1D and 2D with horizontal or vertical stuff
|
|
51
|
+
# TODO really try
|
|
52
|
+
# ça marche un panel peut contenir autant de panels que necessaire --> tt sera panel dans ce truc
|
|
53
|
+
# pourrait implement un sticky mode qui se comporte comme une figure ds EZF et un floating mode ou tout flotte
|
|
54
|
+
# should I sketch content for fusion --> draw how it would look like if done
|
|
55
|
+
|
|
56
|
+
# ce truc serait dedie au 2D en fait et le reste se ferait par des trucs differents
|
|
57
|
+
# could be called row and col and allow them to contain panels
|
|
58
|
+
|
|
59
|
+
# figure serait le master container --> en fait je garde la structure
|
|
60
|
+
# d'avant'
|
|
61
|
+
|
|
62
|
+
# pkoi ne pas tt restaurer alors
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Panel(Rect2D):
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# orientation='horizontal' orientation='vertical'
|
|
70
|
+
def __init__(self, *args, nCols=None, nRows=None, space=3,
|
|
71
|
+
orientation='horizontal'): # replace orientation by horizontal or vertical instead of with or height just set fixed dimension size
|
|
72
|
+
# self.width = 512 # KEEP # already exists in Qrect so not need to set it elsewhere !!!!!!
|
|
73
|
+
# self.height = 0
|
|
74
|
+
# super(Panel, self).__init__(0, 0, 0, 0)
|
|
75
|
+
self.space = space
|
|
76
|
+
self.orientation = orientation
|
|
77
|
+
|
|
78
|
+
if nCols is None and nRows is None:
|
|
79
|
+
# by default panels behave as 1D panel either being a row or a column --> quite cool
|
|
80
|
+
# should do the job ???
|
|
81
|
+
# try it
|
|
82
|
+
if len(args) > 0:
|
|
83
|
+
# self.nCols = self.nRows = round(math.sqrt(len(args)))
|
|
84
|
+
# TODO need suppress this behaviour if I want to get rid of the row stuff to replace everything by panels --> would be simpler in a way
|
|
85
|
+
# this way I can select single objects
|
|
86
|
+
# print(self.nCols, round(self.nCols))
|
|
87
|
+
if self.orientation == 'horizontal':
|
|
88
|
+
self.nCols = len(args)
|
|
89
|
+
self.nRows = 1
|
|
90
|
+
else:
|
|
91
|
+
self.nRows = len(args)
|
|
92
|
+
self.nCols = 1
|
|
93
|
+
else:
|
|
94
|
+
self.nCols = self.nRows = 0
|
|
95
|
+
else:
|
|
96
|
+
self.nCols = nCols
|
|
97
|
+
self.nRows = nRows
|
|
98
|
+
if self.nRows is None or self.nRows == 0:
|
|
99
|
+
self.nRows = 1
|
|
100
|
+
if self.nCols is None or self.nCols == 0:
|
|
101
|
+
self.nCols = 1
|
|
102
|
+
nb_images = self.nCols * self.nRows
|
|
103
|
+
if len(args) > nb_images:
|
|
104
|
+
logger.error('too few images incrementing nb of rows to compensate')
|
|
105
|
+
while (self.nCols * self.nRows < len(args)):
|
|
106
|
+
# add more rows so that it can fit
|
|
107
|
+
self.nRows += 1
|
|
108
|
+
|
|
109
|
+
# store all images in there and create the appropriate figure with rows and cols specified
|
|
110
|
+
self.images = []
|
|
111
|
+
if args:
|
|
112
|
+
for arg in args:
|
|
113
|
+
if isinstance(arg, str):
|
|
114
|
+
# TODO need check image is not null --> file was found really
|
|
115
|
+
self.images.append(Image2D(arg))
|
|
116
|
+
elif isinstance(arg, Image2D):
|
|
117
|
+
self.images.append(arg)
|
|
118
|
+
else:
|
|
119
|
+
logger.error('unsupported input for panel ' + str(arg))
|
|
120
|
+
super(Rect2D, self).__init__()
|
|
121
|
+
# self.isSet = True # required to allow dragging
|
|
122
|
+
self.createTable()
|
|
123
|
+
|
|
124
|
+
def __iter__(self):
|
|
125
|
+
''' Returns the Iterator object '''
|
|
126
|
+
self._index = -1
|
|
127
|
+
return self
|
|
128
|
+
|
|
129
|
+
def __next__(self):
|
|
130
|
+
''' Returns the next image or panel in the row '''
|
|
131
|
+
self._index += 1
|
|
132
|
+
if self._index < len(self.images):
|
|
133
|
+
return self.images[self._index]
|
|
134
|
+
# End of Iteration
|
|
135
|
+
raise StopIteration
|
|
136
|
+
|
|
137
|
+
def __len__(self):
|
|
138
|
+
if self.images is None:
|
|
139
|
+
return 0
|
|
140
|
+
return len(self.images)
|
|
141
|
+
|
|
142
|
+
def __add__(self, other):
|
|
143
|
+
# if isinstance(other, Image2D):
|
|
144
|
+
self.images.append(other)
|
|
145
|
+
self.createTable()
|
|
146
|
+
# behaviour change to replace everything by panels if possible
|
|
147
|
+
# elif isinstance(other, Panel):
|
|
148
|
+
# print(self.images)
|
|
149
|
+
# print(len(self.images))
|
|
150
|
+
# print(other.images)
|
|
151
|
+
# print(len(other.images))
|
|
152
|
+
# self.images = self.images + other.images
|
|
153
|
+
# self.createTable()
|
|
154
|
+
# NEW BEHAVIOUR
|
|
155
|
+
# elif isinstance(other, Panel):
|
|
156
|
+
# print('adding panel to panel')
|
|
157
|
+
# self.images.append(other)
|
|
158
|
+
# self.createTable()
|
|
159
|
+
# print(self.images)
|
|
160
|
+
# print(len(self.images))
|
|
161
|
+
# print(other.images)
|
|
162
|
+
# print(len(other.images))
|
|
163
|
+
# self.images = self.images + other.images
|
|
164
|
+
# self.createTable()
|
|
165
|
+
return self
|
|
166
|
+
|
|
167
|
+
def __sub__(self, other):
|
|
168
|
+
if other in self.images:
|
|
169
|
+
self.images.remove(other)
|
|
170
|
+
self.createTable()
|
|
171
|
+
return self
|
|
172
|
+
|
|
173
|
+
def __lshift__(self, other):
|
|
174
|
+
# move image left with respect to self
|
|
175
|
+
|
|
176
|
+
if isinstance(other, Image2D):
|
|
177
|
+
# swap the position of the two images and repack
|
|
178
|
+
if other in self.images:
|
|
179
|
+
pos = self.images.index(other)
|
|
180
|
+
if pos - 1 >= 0:
|
|
181
|
+
self.images[pos - 1], self.images[pos] = self.images[pos], self.images[pos - 1]
|
|
182
|
+
else:
|
|
183
|
+
return self
|
|
184
|
+
self.createTable()
|
|
185
|
+
return self
|
|
186
|
+
else:
|
|
187
|
+
logger.error('not implemented yet swapping two objects ' + str(type(other)))
|
|
188
|
+
|
|
189
|
+
__ilshift__ = __lshift__
|
|
190
|
+
|
|
191
|
+
def __rshift__(self, other):
|
|
192
|
+
# move image left with respect to self
|
|
193
|
+
if isinstance(other, Image2D):
|
|
194
|
+
if other in self.images:
|
|
195
|
+
pos = self.images.index(other)
|
|
196
|
+
if pos + 1 < len(self.images):
|
|
197
|
+
self.images[pos + 1], self.images[pos] = self.images[pos], self.images[pos + 1]
|
|
198
|
+
else:
|
|
199
|
+
return self
|
|
200
|
+
self.createTable()
|
|
201
|
+
return self
|
|
202
|
+
else:
|
|
203
|
+
logger.error('not implemented yet swapping two objects ' + str(type(other)))
|
|
204
|
+
|
|
205
|
+
__irshift__ = __rshift__
|
|
206
|
+
|
|
207
|
+
def __or__(self, other):
|
|
208
|
+
if isinstance(other, Panel):
|
|
209
|
+
pos = self.get_P1().toPoint()
|
|
210
|
+
other_pos = other.get_P1().toPoint()
|
|
211
|
+
self.set_P1(other_pos)
|
|
212
|
+
other.set_P1(pos)
|
|
213
|
+
else:
|
|
214
|
+
logger.error('swapping not implemented yet for ' + str(type(other)))
|
|
215
|
+
|
|
216
|
+
def is_empty(self):
|
|
217
|
+
if self.images is None or not self.images:
|
|
218
|
+
return True
|
|
219
|
+
return False
|
|
220
|
+
|
|
221
|
+
def setToHeight(self, height):
|
|
222
|
+
# self.height = height
|
|
223
|
+
self.setHeight(height)
|
|
224
|
+
self.setWidth(0)
|
|
225
|
+
self.createTable()
|
|
226
|
+
|
|
227
|
+
# TODO handle differently width and height ???
|
|
228
|
+
# pb it does also change height which it shouldn't --> I have a bug somewhere in the computations --> the nb of cols is incorrect I need to get incompressible space for all content stuff and not only outside
|
|
229
|
+
def setToWidth(self, width):
|
|
230
|
+
# self.width = width
|
|
231
|
+
self.setWidth(width)
|
|
232
|
+
self.setHeight(0)
|
|
233
|
+
self.createTable()
|
|
234
|
+
|
|
235
|
+
def set_ori(self, *args):
|
|
236
|
+
self.set_P1(*args)
|
|
237
|
+
|
|
238
|
+
def set_P1(self, *args):
|
|
239
|
+
curP1 = self.get_P1()
|
|
240
|
+
Rect2D.set_P1(self, *args)
|
|
241
|
+
newP1 = self.get_P1()
|
|
242
|
+
# need do a translation of all its content images
|
|
243
|
+
for img in self:
|
|
244
|
+
img.translate(newP1.x() - curP1.x(), newP1.y() - curP1.y())
|
|
245
|
+
|
|
246
|
+
self.updateBoudingRect()
|
|
247
|
+
|
|
248
|
+
def translate(self, *args):
|
|
249
|
+
if len(args) == 1:
|
|
250
|
+
point = args[0]
|
|
251
|
+
QRectF.translate(self, point.x(), point.y())
|
|
252
|
+
for img in self:
|
|
253
|
+
img.translate(point.x(), point.y())
|
|
254
|
+
else:
|
|
255
|
+
QRectF.translate(self, args[0], args[1])
|
|
256
|
+
for img in self:
|
|
257
|
+
img.translate(QPointF(args[0], args[1]))
|
|
258
|
+
|
|
259
|
+
def draw(self, painter, draw=True):
|
|
260
|
+
if draw:
|
|
261
|
+
painter.save()
|
|
262
|
+
if draw:
|
|
263
|
+
for img in self:
|
|
264
|
+
img.draw(painter, draw=draw)
|
|
265
|
+
painter.restore()
|
|
266
|
+
|
|
267
|
+
def fill(self, painter, draw=True):
|
|
268
|
+
if self.fill_color is None:
|
|
269
|
+
return
|
|
270
|
+
if draw:
|
|
271
|
+
painter.save()
|
|
272
|
+
if draw:
|
|
273
|
+
for img in self:
|
|
274
|
+
img.fill(painter, draw=draw)
|
|
275
|
+
painter.restore()
|
|
276
|
+
|
|
277
|
+
# TODO pb will draw the shape twice.... ---> because painter drawpolygon is called twice
|
|
278
|
+
|
|
279
|
+
def drawAndFill(self, painter):
|
|
280
|
+
painter.save()
|
|
281
|
+
self.draw(painter, draw=True)
|
|
282
|
+
painter.restore()
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
# need handle incompressibility here in fact otherwise bug
|
|
286
|
+
def createTable_neo(self):
|
|
287
|
+
if len(self) == 0:
|
|
288
|
+
return
|
|
289
|
+
if self.nRows == 0:
|
|
290
|
+
self.nRows = 1
|
|
291
|
+
if self.nCols == 0:
|
|
292
|
+
self.nCols = 1
|
|
293
|
+
|
|
294
|
+
# print('nb images ' + str(len(self)) + ' nRows:' + str(self.nRows) + ' nCols:' + str(self.nCols))
|
|
295
|
+
if self.nCols * self.nRows < len(self):
|
|
296
|
+
while self.nCols * self.nRows < len(self):
|
|
297
|
+
self.nRows += 1
|
|
298
|
+
|
|
299
|
+
# hack to make it linear then compute more complex stuff otherwise if it is really 2D
|
|
300
|
+
self.nRows = 1
|
|
301
|
+
self.nCols = len(self)
|
|
302
|
+
# for img in self:
|
|
303
|
+
counter = 0
|
|
304
|
+
|
|
305
|
+
# maybe bug is just because of not properly handling set to with and set to height
|
|
306
|
+
|
|
307
|
+
# why the hell do I have a figure in panel really need to recode that
|
|
308
|
+
# from batoolset.figure.row import Column
|
|
309
|
+
# fig = col(space=self.space)
|
|
310
|
+
|
|
311
|
+
fig = []
|
|
312
|
+
|
|
313
|
+
# TODO recode that and do not go through rows for that
|
|
314
|
+
# if it is None
|
|
315
|
+
|
|
316
|
+
# en fait aligner en y les images suffirait puis les packer en x puis faire le retaillage
|
|
317
|
+
|
|
318
|
+
# for img in self.images:
|
|
319
|
+
# print('type', type(img))
|
|
320
|
+
|
|
321
|
+
for i in range(self.nRows):
|
|
322
|
+
row = []
|
|
323
|
+
# last_size = None
|
|
324
|
+
for j in range(self.nCols):
|
|
325
|
+
if i * self.nCols + j < len(self):
|
|
326
|
+
img = self.images[i * self.nCols + j]
|
|
327
|
+
# last_size = img.boundingRect()
|
|
328
|
+
# print('last_size',last_size)
|
|
329
|
+
# if row is None:
|
|
330
|
+
# row = Column(img)
|
|
331
|
+
# else:
|
|
332
|
+
# row += img
|
|
333
|
+
row.append(img)
|
|
334
|
+
# else:
|
|
335
|
+
# not enough images so adding empty images with same size as last one
|
|
336
|
+
# if last_size is not None:
|
|
337
|
+
# logger.debug('not enough images so adding empty images with same size as last entry')
|
|
338
|
+
# row += Image2D(width=last_size.width(), height=last_size.height())
|
|
339
|
+
if row is not None and not len(row) == 0:
|
|
340
|
+
from batoolset.draw.widgets.image_organizer import packX
|
|
341
|
+
# packing seems correct then need align top
|
|
342
|
+
packX(row, self.space) # ça ça marche
|
|
343
|
+
from batoolset.draw.widgets.image_organizer import alignTop
|
|
344
|
+
alignTop(row) # ça ça marche
|
|
345
|
+
# seems ok too
|
|
346
|
+
|
|
347
|
+
print('#' * 20)
|
|
348
|
+
for c in row:
|
|
349
|
+
print(c.boundingRect())
|
|
350
|
+
print('#' * 20)
|
|
351
|
+
# fig += row
|
|
352
|
+
fig.append(row)
|
|
353
|
+
# if len(fig) == 0:
|
|
354
|
+
|
|
355
|
+
print('fig len', len(fig)) # --> ok
|
|
356
|
+
# logger.error('empty panel created there has to be an error somewhere')
|
|
357
|
+
|
|
358
|
+
from batoolset.draw.widgets.image_organizer import packY
|
|
359
|
+
# not necessarily that by the way
|
|
360
|
+
# packY(fig, space=self.space)
|
|
361
|
+
from batoolset.draw.widgets.image_organizer import sameHeight
|
|
362
|
+
|
|
363
|
+
# required
|
|
364
|
+
|
|
365
|
+
print('brfore same height', self.boundingRect())
|
|
366
|
+
|
|
367
|
+
sameHeight(self.images, space=self.space) # bug here
|
|
368
|
+
print('arfter same height', self.boundingRect())
|
|
369
|
+
|
|
370
|
+
from batoolset.draw.widgets.image_group import group
|
|
371
|
+
if self.width() != 0:
|
|
372
|
+
group(*self.images).setToWidth(self.width())
|
|
373
|
+
if self.height() !=0:
|
|
374
|
+
group(*self.images).setToHeight(self.height())
|
|
375
|
+
# sameHeight(, space=self.space) # see that # ça n'a pas l'air de marcher
|
|
376
|
+
for r in self.images:
|
|
377
|
+
print('bounding rect after same height', r.boundingRect(), len(self.images))
|
|
378
|
+
|
|
379
|
+
# should also update bounding rect of all the content in a way
|
|
380
|
+
|
|
381
|
+
# for r in fig:
|
|
382
|
+
# print('type', type(r))
|
|
383
|
+
|
|
384
|
+
# group(*r).setToWidth(512)
|
|
385
|
+
|
|
386
|
+
packY(fig, space=self.space)
|
|
387
|
+
|
|
388
|
+
# print('width here',self.width())
|
|
389
|
+
# on dirait que ça marche mais faudrait distinguer la width de la desired width...
|
|
390
|
+
# if self.width()!=0:
|
|
391
|
+
# fig.setToWidth(self.width()) # or settoheight by the way
|
|
392
|
+
self.updateBoudingRect()
|
|
393
|
+
|
|
394
|
+
# TODO recode that then I'll be done
|
|
395
|
+
# really weird code --> can I make it better
|
|
396
|
+
def createTable(self):
|
|
397
|
+
|
|
398
|
+
# print('create table called', len(self))
|
|
399
|
+
if len(self) == 0:
|
|
400
|
+
return
|
|
401
|
+
if self.nRows == 0:
|
|
402
|
+
self.nRows = 1
|
|
403
|
+
if self.nCols == 0:
|
|
404
|
+
self.nCols = 1
|
|
405
|
+
print('nb images ' + str(len(self)) + ' nRows:' + str(self.nRows) + ' nCols:' + str(self.nCols))
|
|
406
|
+
if self.nCols * self.nRows < len(self):
|
|
407
|
+
while self.nCols * self.nRows < len(self):
|
|
408
|
+
self.nRows += 1
|
|
409
|
+
# for img in self:
|
|
410
|
+
counter = 0
|
|
411
|
+
|
|
412
|
+
# maybe bug is just because of not properly handling set to with and set to height
|
|
413
|
+
|
|
414
|
+
# why the hell do I have a figure in panel really need to recode that
|
|
415
|
+
from batoolset.draw.widgets.col import col
|
|
416
|
+
fig = col(space=self.space)
|
|
417
|
+
self.rows=[]
|
|
418
|
+
|
|
419
|
+
# TODO recode that and do not go through rows for that
|
|
420
|
+
# if it is None
|
|
421
|
+
for i in range(self.nRows):
|
|
422
|
+
row = None
|
|
423
|
+
last_size = None
|
|
424
|
+
for j in range(self.nCols):
|
|
425
|
+
if i * self.nCols + j < len(self):
|
|
426
|
+
img = self.images[i * self.nCols + j]
|
|
427
|
+
last_size = img.boundingRect()
|
|
428
|
+
print('last_size', last_size)
|
|
429
|
+
if row is None:
|
|
430
|
+
row = Row(img)
|
|
431
|
+
else:
|
|
432
|
+
row += img
|
|
433
|
+
else:
|
|
434
|
+
# not enough images so adding empty images with same size as last one
|
|
435
|
+
if last_size is not None:
|
|
436
|
+
logger.debug('not enough images so adding empty images with same size as last entry')
|
|
437
|
+
row += Image2D(width=last_size.width(), height=last_size.height())
|
|
438
|
+
if row is not None and not row.isEmpty():
|
|
439
|
+
row.packX(self.space)
|
|
440
|
+
self.rows.append(row)
|
|
441
|
+
fig += row
|
|
442
|
+
|
|
443
|
+
if len(fig) == 0:
|
|
444
|
+
logger.error('empty panel created there has to be an error somewhere')
|
|
445
|
+
|
|
446
|
+
# not necessarily that by the way
|
|
447
|
+
fig.packY(space=self.space)
|
|
448
|
+
|
|
449
|
+
print('width here', self.width())
|
|
450
|
+
# on dirait que ça marche mais faudrait distinguer la width de la desired width...
|
|
451
|
+
if self.width() != 0:
|
|
452
|
+
fig.setToWidth(self.width()) # or settoheight by the way
|
|
453
|
+
self.updateBoudingRect()
|
|
454
|
+
# unique = len(self) == 1
|
|
455
|
+
|
|
456
|
+
def updateBoudingRect(self):
|
|
457
|
+
'''updates the image bounding rect depending on content'''
|
|
458
|
+
x = None
|
|
459
|
+
y = None
|
|
460
|
+
x2 = None
|
|
461
|
+
y2 = None
|
|
462
|
+
for img in self:
|
|
463
|
+
topLeft = img.get_P1()
|
|
464
|
+
if x is None:
|
|
465
|
+
x = topLeft.x()
|
|
466
|
+
if y is None:
|
|
467
|
+
y = topLeft.y()
|
|
468
|
+
x = min(topLeft.x(), x)
|
|
469
|
+
y = min(topLeft.y(), y)
|
|
470
|
+
if x2 is None:
|
|
471
|
+
x2 = topLeft.x() + img.boundingRect().width()
|
|
472
|
+
if y2 is None:
|
|
473
|
+
y2 = topLeft.y() + img.boundingRect().height()
|
|
474
|
+
x2 = max(topLeft.x() + img.boundingRect().width(), x2)
|
|
475
|
+
y2 = max(topLeft.y() + img.boundingRect().height(), y2)
|
|
476
|
+
|
|
477
|
+
self.setX(x)
|
|
478
|
+
self.setY(y)
|
|
479
|
+
self.setWidth(x2 - x)
|
|
480
|
+
self.setHeight(y2 - y)
|
|
481
|
+
|
|
482
|
+
# @return the block incompressible width
|
|
483
|
+
# def getIncompressibleWidth(self):
|
|
484
|
+
# # in fact need get nb of cols a
|
|
485
|
+
# extra_space = (self.nCols - 1.) * self.space
|
|
486
|
+
# extra_space += self.getExtraIncompressibleWidth()
|
|
487
|
+
# return extra_space
|
|
488
|
+
|
|
489
|
+
# def getExtraIncompressibleWidth(self):
|
|
490
|
+
# extra_space = 0
|
|
491
|
+
# return extra_space
|
|
492
|
+
#
|
|
493
|
+
# # @return the block incompressible height
|
|
494
|
+
# def getIncompressibleHeight(self):
|
|
495
|
+
# # in fact need get nb of cols a
|
|
496
|
+
# extra_space = (self.nRows - 1.) * self.space
|
|
497
|
+
# extra_space += self.getExtraIncompressibleHeight()
|
|
498
|
+
# return extra_space
|
|
499
|
+
#
|
|
500
|
+
# def getExtraIncompressibleHeight(self):
|
|
501
|
+
# extra_space = 0
|
|
502
|
+
# return extra_space
|
|
503
|
+
|
|
504
|
+
if __name__ == '__main__':
|
|
505
|
+
from batoolset.draw.shapes.image2d import Image2D # KEEP Really required to avoid circular imports
|
|
506
|
+
|
|
507
|
+
img0 = Image2D('/E/Sample_images/counter/00.png')
|
|
508
|
+
# img0.setLetter(TAText2D(
|
|
509
|
+
# text='<p style="text-align:left;color: yellow">This text is left aligned <span style="float:right;font-style: italic;font-size: 8pt;"> This text is right aligned </span><span style="float:right;font-size: 4pt;color:red"> This text is another text </span></p>'))
|
|
510
|
+
|
|
511
|
+
img1 = Image2D('/E/Sample_images/counter/01.png')
|
|
512
|
+
# img1 = Image2D('D:/dataset1/unseen/focused_Series012.png')
|
|
513
|
+
# img1.setLetter(TAText2D(text="<font face='Comic Sans Ms' size=16 color='blue' >this is a <br>test</font>"))
|
|
514
|
+
# ça ça marche vraiment en fait --> use css to write my text instead of that
|
|
515
|
+
|
|
516
|
+
# ça ça a l'air de marcher --> pas trop mal en fait du coup
|
|
517
|
+
# ça a l'air de marcher maintenant --> could use that and do a converter for ezfig ???
|
|
518
|
+
# img1.setLetter(TAText2D(text="<span style='font-size: 12pt; font-style: italic; font-weight: bold; color: yellow; paddind: 20px; text-align: center;'> <u>Don't miss it</u></span><span style='font-size: 4pt; font-style: italic; font-weight: bold; color: #00FF00; paddind: 3px; text-align: right;'> <u>test2</u></span>"))
|
|
519
|
+
|
|
520
|
+
# TODO need remove <meta name="qrichtext" content="1" /> from the stuff otherwise alignment is not ok... TODO --> should I offer a change to that ??? maybe not
|
|
521
|
+
# test_text = '''
|
|
522
|
+
# </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
|
523
|
+
# <p style="color:#00ff00;"><span style=" color:#ff0000;">toto</span><br />tu<span style=" vertical-align:super;">tu</span></p>
|
|
524
|
+
# '''
|
|
525
|
+
# img1.setLetter(TAText2D(text=test_text))
|
|
526
|
+
# background-color: orange;
|
|
527
|
+
# span div et p donnent la meme chose par contre c'est sur deux lignes
|
|
528
|
+
# display:inline; float:left # to display as the same line .... --> does that work html to svg
|
|
529
|
+
# https://stackoverflow.com/questions/10451445/two-div-blocks-on-same-line --> same line for two divs
|
|
530
|
+
|
|
531
|
+
img2 = Image2D('/E/Sample_images/counter/02.png')
|
|
532
|
+
img3 = Image2D('/E/Sample_images/counter/03.png')
|
|
533
|
+
img4 = Image2D('/E/Sample_images/counter/04.png')
|
|
534
|
+
img5 = Image2D('/E/Sample_images/counter/05.png')
|
|
535
|
+
img6 = Image2D('/E/Sample_images/counter/06.png')
|
|
536
|
+
img7 = Image2D('/E/Sample_images/counter/07.png')
|
|
537
|
+
img8 = Image2D('/E/Sample_images/counter/08.png')
|
|
538
|
+
img9 = Image2D('/E/Sample_images/counter/09.png')
|
|
539
|
+
img10 = Image2D('/E/Sample_images/counter/10.png')
|
|
540
|
+
|
|
541
|
+
# img10 = Image2D('/E/Sample_images/counter/10.png')
|
|
542
|
+
# img2 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
543
|
+
# img3 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
544
|
+
# img4 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
545
|
+
# img5 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
546
|
+
# img6 = Image2D('D:/dataset1/unseen/focused_Series012.png')
|
|
547
|
+
# img7 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
548
|
+
# img8 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
549
|
+
# img9 = Image2D('D:/dataset1/unseen/100708_png06.png')
|
|
550
|
+
# img10 = Image2D('D:/dataset1/unseen/focused_Series012.png')
|
|
551
|
+
|
|
552
|
+
# is row really different from a panel ??? probably not that different
|
|
553
|
+
# row = img1 + img2
|
|
554
|
+
|
|
555
|
+
# self.shapes_to_draw.append(row)
|
|
556
|
+
# self.shapes_to_draw.append(row)
|
|
557
|
+
|
|
558
|
+
# pkoi ça creerait pas plutot un panel
|
|
559
|
+
# au lieu de creer une row faut creer des trucs
|
|
560
|
+
# row2 = img4 + img5
|
|
561
|
+
# fig = row / row2
|
|
562
|
+
# fig = col(row, row2, width=512)# ça c'est ok
|
|
563
|
+
# self.shapes_to_draw.append(fig)
|
|
564
|
+
|
|
565
|
+
# TODO add image swapping and other changes and also implement sticky pos --> just need store initial pos
|
|
566
|
+
|
|
567
|
+
# print(len(row))
|
|
568
|
+
# for img in row:
|
|
569
|
+
# print(img.boundingRect())
|
|
570
|
+
|
|
571
|
+
# fig.setToWidth(512) # bug is really here I do miss something but what and why
|
|
572
|
+
|
|
573
|
+
# print('rows', len(fig))
|
|
574
|
+
# for r in fig:
|
|
575
|
+
# print('bounding rect', r.boundingRect())
|
|
576
|
+
# print('cols in row', len(r))
|
|
577
|
+
|
|
578
|
+
# self.shapes_to_draw.append(fig)
|
|
579
|
+
|
|
580
|
+
# peut etre si rien n'est mis juste faire une row avec un panel
|
|
581
|
+
panel = Panel(img0) #, img1, img2, img3) # , img6, #, nCols=3, nRows=2
|
|
582
|
+
|
|
583
|
+
# marche pas en fait car un truc ne prend pas en charge les figs
|
|
584
|
+
|
|
585
|
+
# ça marche donc en fait tt peut etre un panel en fait
|
|
586
|
+
|
|
587
|
+
panel2 = Panel(img4)#, img5, img6, img7) # , img6, img6, nCols=3, nRows=2,
|
|
588
|
+
|
|
589
|
+
# panel3 = Panel(img8, img9)
|
|
590
|
+
|
|
591
|
+
print(type(panel2))
|
|
592
|
+
panel2 += panel
|
|
593
|
+
print(type(panel2))
|
|
594
|
+
# panel2+=panel3 # bug here cause does not resize the panel properly
|
|
595
|
+
# print(panel2.nCols, panel2.nRows, panel2.orientation, len(panel2.images), type(panel2), panel2.boundingRect())
|
|
596
|
+
|
|
597
|
+
panel2.setToWidth(128)
|
|
598
|
+
|
|
599
|
+
# img1 = Image2D('/E/Sample_images/counter/00.png')
|
|
600
|
+
# img2 = Image2D('/E/Sample_images/counter/01.png')
|
|
601
|
+
# img3 = Image2D('/E/Sample_images/counter/02.png')
|
|
602
|
+
# img4 = Image2D('/E/Sample_images/counter/03.png')
|
|
603
|
+
|
|
604
|
+
# panel = Panel(img1, img2)
|
|
605
|
+
print('last', panel2.boundingRect(), panel2.boundingRect().height())
|
|
606
|
+
|
|
607
|
+
# if True:
|
|
608
|
+
# import sys
|
|
609
|
+
#
|
|
610
|
+
# sys.exit(0)
|
|
611
|
+
|
|
612
|
+
# result = img1 + img2
|
|
613
|
+
#
|
|
614
|
+
# print(result)
|
|
615
|
+
# print(len(result.images))
|
|
616
|
+
|
|
617
|
+
# result += img3
|
|
618
|
+
# result += img4
|
|
619
|
+
|
|
620
|
+
# print(result)
|
|
621
|
+
# print(len(result.images)) # ça ça marche
|
|
622
|
+
|
|
623
|
+
# if True:
|
|
624
|
+
# sys.exit(0)
|
|
625
|
+
|
|
626
|
+
# img3.pop()
|
|
627
|
+
|
|
628
|
+
# row2 = img3 + img4
|
|
629
|
+
# row2 = row(img3, img4)
|
|
630
|
+
|
|
631
|
+
# print(row2)
|
|
632
|
+
# print(row2.images) # why 4 images here ....
|
|
633
|
+
# print('row2', len(row2.images)) # pas bon trop d'images --> pkoi ????
|
|
634
|
+
|
|
635
|
+
# print(Image2D)
|
|
636
|
+
#
|
|
637
|
+
# fig = result + row2
|
|
638
|
+
# print(fig)
|
|
639
|
+
# print(len(fig.images))
|
|
640
|
+
#
|
|
641
|
+
# count = 0
|
|
642
|
+
# for img in fig.images:
|
|
643
|
+
# print(count, img.filename)
|
|
644
|
+
# count += 1
|
|
645
|
+
#
|
|
646
|
+
# final_result = fig - img4
|
|
647
|
+
# print(final_result)
|
|
648
|
+
# print(final_result.images)
|
|
649
|
+
# print(len(final_result.images))
|
|
650
|
+
#
|
|
651
|
+
# ça marche
|
|
652
|
+
|
|
653
|
+
# final_result = img4 + fig # ça ne marche pas
|
|
654
|
+
# print(final_result)
|
|
655
|
+
# print(final_result.images)
|
|
656
|
+
# print(len(final_result.images))
|
|
657
|
+
|
|
658
|
+
# si je divide une row alors ça ajoute une colonne à la figure --> return 2 rows in a figure
|
|
659
|
+
|
|
660
|
+
img5 = Image2D('/E/Sample_images/counter/04.png')
|
|
661
|
+
img6 = Image2D('/E/Sample_images/counter/05.png')
|
|
662
|
+
|
|
663
|
+
fig = img5 / img6 # --> could create a panel vertical containing two stuff
|
|
664
|
+
|
|
665
|
+
print(fig)
|
|
666
|
+
# print(fig.cols)
|
|
667
|
+
# print(len(fig.cols))
|
|
668
|
+
|
|
669
|
+
final_fig = fig - img5
|
|
670
|
+
|
|
671
|
+
# print(final_fig)
|
|
672
|
+
# print(final_fig.rows)
|
|
673
|
+
# print(len(final_fig.rows))
|
|
674
|
+
|
|
675
|
+
# final_fig += row2
|
|
676
|
+
|
|
677
|
+
# print(final_fig)
|
|
678
|
+
# print(final_fig.rows)
|
|
679
|
+
# print(len(final_fig.rows))
|
|
680
|
+
|
|
681
|
+
img8 = Image2D('/E/Sample_images/counter/06.png')
|
|
682
|
+
img9 = Image2D('/E/Sample_images/counter/07.png')
|
|
683
|
+
img10 = Image2D('/E/Sample_images/counter/08.png')
|
|
684
|
+
img11 = Image2D('/E/Sample_images/counter/09.png')
|
|
685
|
+
|
|
686
|
+
# fig = (img8 + img9) / (img10 + img11)
|
|
687
|
+
# print(fig)
|
|
688
|
+
# print(fig.rows)
|
|
689
|
+
# print(len(fig.rows))
|
|
690
|
+
# print('r1', len(fig.rows[0].images))
|
|
691
|
+
# print('r2', len(fig.rows[1].images))
|
|
692
|
+
|
|
693
|
+
# nb there are big size bugs here in terms of size --> not the same size but maybe this is what I want ????
|
|
694
|
+
columns = Panel(img8, img9, img10, img11, nCols=2)
|
|
695
|
+
columns.setToWidth(300)
|
|
696
|
+
|
|
697
|
+
# preview(columns)
|