PyImageLabeling 1.0.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 (99) hide show
  1. PyImageLabeling/__init__.py +22 -0
  2. PyImageLabeling/config.json +289 -0
  3. PyImageLabeling/controller/Controller.py +25 -0
  4. PyImageLabeling/controller/Events.py +147 -0
  5. PyImageLabeling/controller/FileEvents.py +69 -0
  6. PyImageLabeling/controller/ImageEvents.py +32 -0
  7. PyImageLabeling/controller/LabelEvents.py +219 -0
  8. PyImageLabeling/controller/LabelingEvents.py +123 -0
  9. PyImageLabeling/controller/settings/ContourFillinSetting.py +93 -0
  10. PyImageLabeling/controller/settings/CoutourFillingApplyCancel.py +37 -0
  11. PyImageLabeling/controller/settings/EraserSetting.py +73 -0
  12. PyImageLabeling/controller/settings/LabelSetting.py +91 -0
  13. PyImageLabeling/controller/settings/MagicPenSetting.py +125 -0
  14. PyImageLabeling/controller/settings/OpacitySetting.py +66 -0
  15. PyImageLabeling/controller/settings/PaintBrushSetting.py +66 -0
  16. PyImageLabeling/icons/apply.png +0 -0
  17. PyImageLabeling/icons/asterisk-green.png +0 -0
  18. PyImageLabeling/icons/asterisk-red.png +0 -0
  19. PyImageLabeling/icons/back.png +0 -0
  20. PyImageLabeling/icons/border.png +0 -0
  21. PyImageLabeling/icons/cancel.png +0 -0
  22. PyImageLabeling/icons/cleaner.png +0 -0
  23. PyImageLabeling/icons/close.png +0 -0
  24. PyImageLabeling/icons/down.png +0 -0
  25. PyImageLabeling/icons/ellipse.png +0 -0
  26. PyImageLabeling/icons/eraser.png +0 -0
  27. PyImageLabeling/icons/filling.png +0 -0
  28. PyImageLabeling/icons/logoMAIA.png +0 -0
  29. PyImageLabeling/icons/magic.png +0 -0
  30. PyImageLabeling/icons/maia.png +0 -0
  31. PyImageLabeling/icons/maia1.png +0 -0
  32. PyImageLabeling/icons/maia3.ico +0 -0
  33. PyImageLabeling/icons/maia_icon.png +0 -0
  34. PyImageLabeling/icons/move.png +0 -0
  35. PyImageLabeling/icons/opacity.png +0 -0
  36. PyImageLabeling/icons/open_image.png +0 -0
  37. PyImageLabeling/icons/open_layer.png +0 -0
  38. PyImageLabeling/icons/paint.png +0 -0
  39. PyImageLabeling/icons/plus.png +0 -0
  40. PyImageLabeling/icons/polygon.png +0 -0
  41. PyImageLabeling/icons/rectangle.png +0 -0
  42. PyImageLabeling/icons/reset.png +0 -0
  43. PyImageLabeling/icons/save.png +0 -0
  44. PyImageLabeling/icons/setting.png +0 -0
  45. PyImageLabeling/icons/transparency.png:Zone.Identifier +4 -0
  46. PyImageLabeling/icons/up.png +0 -0
  47. PyImageLabeling/icons/visibility.png +0 -0
  48. PyImageLabeling/icons/zoom_minus.png +0 -0
  49. PyImageLabeling/icons/zoom_plus.png +0 -0
  50. PyImageLabeling/model/Core.py +795 -0
  51. PyImageLabeling/model/File/Files.py +166 -0
  52. PyImageLabeling/model/File/NextImage.py +36 -0
  53. PyImageLabeling/model/File/PreviousImage.py +19 -0
  54. PyImageLabeling/model/Image/MoveImage.py +32 -0
  55. PyImageLabeling/model/Image/ResetMoveZoomImage.py +16 -0
  56. PyImageLabeling/model/Image/ZoomMinus.py +25 -0
  57. PyImageLabeling/model/Image/ZoomPlus.py +16 -0
  58. PyImageLabeling/model/Labeling/ClearAll.py +22 -0
  59. PyImageLabeling/model/Labeling/ContourFilling.py +135 -0
  60. PyImageLabeling/model/Labeling/Ellipse.py +350 -0
  61. PyImageLabeling/model/Labeling/Eraser.py +131 -0
  62. PyImageLabeling/model/Labeling/MagicPen.py +131 -0
  63. PyImageLabeling/model/Labeling/PaintBrush.py +207 -0
  64. PyImageLabeling/model/Labeling/Polygon.py +279 -0
  65. PyImageLabeling/model/Labeling/Rectangle.py +248 -0
  66. PyImageLabeling/model/Labeling/Undo.py +12 -0
  67. PyImageLabeling/model/Model.py +40 -0
  68. PyImageLabeling/model/Utils.py +40 -0
  69. PyImageLabeling/old_version/label_rectangle_properties.json +6 -0
  70. PyImageLabeling/old_version/main.py +2073 -0
  71. PyImageLabeling/old_version/models/EraseSettingsDialog.py +51 -0
  72. PyImageLabeling/old_version/models/LabeledRectangle.py +80 -0
  73. PyImageLabeling/old_version/models/MagicSettingsDialog.py +119 -0
  74. PyImageLabeling/old_version/models/OverlayOpacityDialog.py +63 -0
  75. PyImageLabeling/old_version/models/PaintSettingsDialog.py +289 -0
  76. PyImageLabeling/old_version/models/PointItem.py +66 -0
  77. PyImageLabeling/old_version/models/ProcessWorker.py +52 -0
  78. PyImageLabeling/old_version/models/ZoomableGraphicsView.py +1214 -0
  79. PyImageLabeling/old_version/models/tools/ContourTool.py +279 -0
  80. PyImageLabeling/old_version/models/tools/EraserTool.py +290 -0
  81. PyImageLabeling/old_version/models/tools/MagicPenTool.py +199 -0
  82. PyImageLabeling/old_version/models/tools/OverlayTool.py +179 -0
  83. PyImageLabeling/old_version/models/tools/PaintTool.py +68 -0
  84. PyImageLabeling/old_version/models/tools/PolygonTool.py +786 -0
  85. PyImageLabeling/old_version/models/tools/RectangleTool.py +1036 -0
  86. PyImageLabeling/parameters.json +1 -0
  87. PyImageLabeling/style.css +611 -0
  88. PyImageLabeling/view/Builder.py +333 -0
  89. PyImageLabeling/view/QBackgroundItem.py +30 -0
  90. PyImageLabeling/view/QWidgets.py +10 -0
  91. PyImageLabeling/view/View.py +226 -0
  92. PyImageLabeling/view/ZoomableGraphicsView.py +91 -0
  93. PyImageLabeling/view/__init__.py +0 -0
  94. pyimagelabeling-1.0.0.dist-info/METADATA +55 -0
  95. pyimagelabeling-1.0.0.dist-info/RECORD +99 -0
  96. pyimagelabeling-1.0.0.dist-info/WHEEL +5 -0
  97. pyimagelabeling-1.0.0.dist-info/licenses/LICENCE +22 -0
  98. pyimagelabeling-1.0.0.dist-info/top_level.txt +2 -0
  99. pypi/publish_pypi.py +18 -0
@@ -0,0 +1,22 @@
1
+ from PyImageLabeling.model.Utils import Utils
2
+ from PyImageLabeling.view.View import View
3
+ from PyImageLabeling.controller.Controller import Controller
4
+ from PyImageLabeling.model.Model import Model
5
+
6
+ from PyQt6.QtWidgets import QApplication
7
+ import sys
8
+
9
+ __version__ = "1.0.0"
10
+
11
+ def __main__():
12
+ config = Utils.get_config()
13
+ app = QApplication(sys.argv)
14
+
15
+ controller = Controller(config)
16
+ view = View(controller, config)
17
+ model = Model(view, controller, config)
18
+ controller.set_model(model)
19
+
20
+ sys.exit(app.exec())
21
+
22
+ __main__()
@@ -0,0 +1,289 @@
1
+ {
2
+ "window_size":{
3
+ "margin": 10,
4
+ "icon": [20, 20],
5
+ "icon_save_marker": [12, 12],
6
+
7
+ "graphics_view":{
8
+ "width":400
9
+ },
10
+ "labeling_bar":{
11
+ "width": 250
12
+ },
13
+ "image_bar":{
14
+ "height": 220,
15
+ "width": 65
16
+ },
17
+ "label_bar":{
18
+ "height": 75
19
+ },
20
+ "file_bar":{
21
+ "width": 250
22
+ }
23
+ },
24
+ "apply_cancel_bar":[
25
+ {
26
+ "name": "apply",
27
+ "name_view": "Apply",
28
+ "icon": "apply",
29
+ "checkable": false,
30
+ "tooltip": "Apply an operation."
31
+ },
32
+ {
33
+ "name": "cancel",
34
+ "name_view": "Cancel",
35
+ "icon": "cancel",
36
+ "checkable": false,
37
+ "tooltip": "Cancel an operation."
38
+ }
39
+ ],
40
+ "file_bar":[
41
+ {
42
+ "name": "load",
43
+ "name_view": "Load images and labels",
44
+ "icon": "open_image",
45
+ "checkable": false,
46
+ "tooltip": "Load images and labels."
47
+ },
48
+ {
49
+ "name": "save",
50
+ "name_view": "Save labels",
51
+ "icon": "save",
52
+ "checkable": false,
53
+ "tooltip": "Save all labels."
54
+ },
55
+ {
56
+ "name": "next_image",
57
+ "name_view": "Next Image",
58
+ "icon": "down",
59
+ "checkable": false,
60
+ "tooltip": "Next image."
61
+ },
62
+ {
63
+ "name": "previous_image",
64
+ "name_view": "Previous Image",
65
+ "icon": "up",
66
+ "checkable": false,
67
+ "tooltip": "Previous image."
68
+ }
69
+ ],
70
+
71
+ "image_bar":
72
+ [
73
+ {
74
+ "name": "zoom_plus",
75
+ "name_view": "Zoom Plus",
76
+ "icon": "zoom_plus",
77
+ "checkable": true,
78
+ "tooltip": "Zoom Plus."
79
+ },
80
+ {
81
+ "name": "zoom_minus",
82
+ "name_view": "Zoom Minus",
83
+ "icon": "zoom_minus",
84
+ "checkable": true,
85
+ "tooltip": "zoom_minus."
86
+ },
87
+ {
88
+ "name": "move_image",
89
+ "icon": "move",
90
+ "checkable": true,
91
+ "name_view": "Move",
92
+ "tooltip": "Click to activate Move mode. This allows you to move the image around in the viewer by dragging it."
93
+ },
94
+ {
95
+ "name": "reset_move_zoom_image",
96
+ "icon": "reset",
97
+ "checkable": false,
98
+ "name_view": "Move/Zoom Reset",
99
+ "tooltip": "Click to reset the image's position and zoom level to the default view."
100
+ }
101
+ ],
102
+ "label_bar":
103
+ {"permanent":[
104
+ {
105
+ "name": "new_label",
106
+ "name_view": "New Label",
107
+ "icon": "plus",
108
+ "checkable": false,
109
+ "tooltip": "Add a new label."
110
+ },
111
+ {
112
+ "name": "opacity",
113
+ "name_view": "Opacity",
114
+ "checkable": false,
115
+ "icon": "opacity",
116
+ "tooltip": "Click to toggle opacity mode, allowing you to adjust the transparency of layers."
117
+ }
118
+ ],
119
+ "layer":[
120
+ {
121
+ "name": "color",
122
+ "name_view": "Color",
123
+ "icon": "",
124
+ "checkable": false,
125
+ "tooltip": "Color of the layer/label."
126
+ },
127
+ {
128
+ "name": "visibility",
129
+ "name_view": "Visibility",
130
+ "icon": "visibility",
131
+ "checkable": true,
132
+ "tooltip": "Visibility of the label."
133
+ },
134
+ {
135
+ "name": "label_setting",
136
+ "name_view": "Label Setting",
137
+ "icon": "setting",
138
+ "checkable": false,
139
+ "tooltip": "Parameters of the layer/label."
140
+ },
141
+ {
142
+ "name": "remove_label",
143
+ "name_view": "Remove Label",
144
+ "icon": "close",
145
+ "checkable": false,
146
+ "tooltip": "Remove the label"
147
+ }
148
+
149
+ ]},
150
+ "labeling_bar":
151
+ {"pixel": {
152
+ "name_view": "Pixel-by-pixel",
153
+ "buttons": [
154
+ {
155
+ "name": "contour_filling",
156
+ "icon": "filling",
157
+ "checkable": true,
158
+ "name_view": "Contour Filling",
159
+ "tooltip": "Click to activate Move mode. This allows you to move the image around in the viewer by dragging it."
160
+ },
161
+ {
162
+ "name": "paintbrush",
163
+ "name_view": "Paintbrush",
164
+ "checkable": true,
165
+ "icon": "paint",
166
+ "tooltip": "Click to reset the image's position and zoom level to the default view."
167
+ },
168
+ {
169
+ "name": "magic_pen",
170
+ "name_view": "Magic Pen",
171
+ "checkable": true,
172
+ "icon": "magic",
173
+ "tooltip": "Click to activate Move mode. This allows you to move the image around in the viewer by dragging it."
174
+ }
175
+ ]
176
+ }
177
+ ,
178
+ "geometric":{
179
+ "name_view": "Geometric shapes",
180
+ "buttons": [
181
+ {
182
+ "name": "ellipse",
183
+ "name_view": "Ellipse",
184
+ "checkable": true,
185
+ "icon": "ellipse",
186
+ "tooltip": "."
187
+ },
188
+ {
189
+ "name": "rectangle",
190
+ "name_view": "Rectangle",
191
+ "checkable": true,
192
+ "icon": "rectangle",
193
+ "tooltip": "Click to reset the image's position and zoom level to the default view."
194
+ },
195
+ {
196
+ "name": "polygon",
197
+ "name_view": "Polygon",
198
+ "checkable": true,
199
+ "icon": "polygon",
200
+ "tooltip": "Click to activate Move mode. This allows you to move the image around in the viewer by dragging it."
201
+ }
202
+ ]}
203
+ ,
204
+ "edit":{
205
+ "name_view": "Edition",
206
+ "buttons": [
207
+ {
208
+ "name": "undo",
209
+ "name_view": "Undo",
210
+ "checkable": false,
211
+ "icon": "back",
212
+ "tooltip": "Click to undo the last drawing action or modification."
213
+ },
214
+ {
215
+ "name": "eraser",
216
+ "name_view": "Eraser",
217
+ "checkable": true,
218
+ "icon": "eraser",
219
+ "tooltip": "Click to activate the eraser tool, allowing you to erase parts of the image or layer."
220
+ },
221
+ {
222
+ "name": "clear_all",
223
+ "name_view": "Clear All",
224
+ "checkable": false,
225
+ "icon": "cleaner",
226
+ "tooltip": "Click to clear all layers and reset the image to its original state."
227
+ }
228
+ ]}
229
+ }
230
+ ,
231
+ "labeling_bar_setting":
232
+ [
233
+ {"Edit Setting":[
234
+ {
235
+ "name": "eraser_setting",
236
+ "name_view": "Eraser Setting",
237
+ "icon": "setting",
238
+ "checkable": false,
239
+ "tooltip": "Parameters of eraser."
240
+ }
241
+ ]},
242
+ {"Pixel Labeling Setting":[
243
+ {
244
+ "name": "contour_filling_setting",
245
+ "name_view": "Contour Filling Setting",
246
+ "icon": "setting",
247
+ "checkable": false,
248
+ "tooltip": "Parameters of contour filling."
249
+ },
250
+ {
251
+ "name": "paintbrush_setting",
252
+ "name_view": "PaintBrush Setting",
253
+ "icon": "setting",
254
+ "checkable": false,
255
+ "tooltip": "Parameters of paintbrush."
256
+ },
257
+ {
258
+ "name": "magic_pen_setting",
259
+ "name_view": "Magic Pen Setting",
260
+ "icon": "setting",
261
+ "checkable": false,
262
+ "tooltip": "Parameters of magic pen."
263
+ }
264
+ ]},
265
+ {"Geometric Labeling Setting":[
266
+ {
267
+ "name": "ellipse_setting",
268
+ "name_view": "Ellipse Setting",
269
+ "icon": "setting",
270
+ "checkable": false,
271
+ "tooltip": "Parameters of ellipse."
272
+ },
273
+ {
274
+ "name": "rectangle_setting",
275
+ "name_view": "Rectangle Setting",
276
+ "icon": "setting",
277
+ "checkable": false,
278
+ "tooltip": "Parameters of rectangle."
279
+ },
280
+ {
281
+ "name": "polygon_setting",
282
+ "name_view": "Polygon Setting",
283
+ "icon": "setting",
284
+ "checkable": false,
285
+ "tooltip": "Parameters of polygon."
286
+ }
287
+ ]}
288
+ ]
289
+ }
@@ -0,0 +1,25 @@
1
+
2
+ from PyImageLabeling.controller.FileEvents import FileEvents
3
+ from PyImageLabeling.controller.LabelingEvents import LabelingEvents
4
+ from PyImageLabeling.controller.ImageEvents import ImageEvents
5
+ from PyImageLabeling.controller.LabelEvents import LabelEvents
6
+
7
+ from PyQt6.QtWidgets import QMessageBox
8
+
9
+ class Controller(FileEvents, LabelingEvents, ImageEvents, LabelEvents):
10
+ def __init__(self, config):
11
+ super().__init__()
12
+
13
+ self.config = config
14
+ self.view = None
15
+ self.model = None
16
+
17
+ def set_view(self, view):
18
+ super().set_view(view)
19
+ self.view = view
20
+
21
+ def set_model(self, model):
22
+ super().set_model(model)
23
+ self.model = model
24
+
25
+
@@ -0,0 +1,147 @@
1
+ from PyQt6.QtWidgets import QMessageBox, QGraphicsView, QApplication, QGraphicsItem
2
+ from PyQt6.QtCore import QObject, QEvent, Qt, QRectF, QRect
3
+ from PyQt6.QtGui import QPixmap, QMouseEvent, QKeyEvent, QBrush, QColor
4
+ from PyQt6.QtWidgets import QLabel
5
+ import os
6
+
7
+ from PyImageLabeling.model.Utils import Utils
8
+
9
+
10
+
11
+
12
+ class eventEater(QObject):
13
+ def __init__(self, controler, view, model):
14
+ super().__init__()
15
+ self.controler = controler
16
+ self.view = view
17
+ self.model = model
18
+
19
+ def set_model(self, model):
20
+ self.model = model
21
+
22
+ def eventFilter(self, event):
23
+ #self.view.zoomable_graphics_view.setDragMode(QGraphicsView.DragMode.NoDrag)
24
+ #print("event.type() QObject", event.type())
25
+ #print("event.type() QObject", obj)
26
+
27
+ if event.type() == QEvent.Type.GraphicsSceneMousePress and event.button() == Qt.MouseButton.LeftButton:
28
+ if self.model.checked_button == "zoom_plus":
29
+ self.model.start_zoom_plus()
30
+ elif self.model.checked_button == "zoom_minus":
31
+ self.model.start_zoom_minus()
32
+ elif self.model.checked_button == "move_image":
33
+ self.model.start_move_tool(event)
34
+ elif self.model.checked_button == "paint_brush":
35
+ self.model.start_paint_brush(event.scenePos())
36
+ elif self.model.checked_button == "magic_pen":
37
+ self.model.start_magic_pen(event.scenePos())
38
+ elif self.model.checked_button == "contour_filling":
39
+ # Fill the contour clicked
40
+ self.model.fill_contour(event.scenePos())
41
+ elif self.model.checked_button == "eraser":
42
+ self.model.start_eraser(event.scenePos())
43
+ elif self.model.checked_button == "rectangle":
44
+ self.model.start_rectangle_tool(event.scenePos())
45
+ elif self.model.checked_button == "polygon":
46
+ self.model.start_polygon_tool(event.scenePos())
47
+ elif self.model.checked_button == "ellipse":
48
+ self.model.start_ellipse_tool(event.scenePos())
49
+
50
+ elif event.type() == QEvent.Type.GraphicsSceneMouseMove and event.buttons() == Qt.MouseButton.LeftButton:
51
+ if self.model.checked_button == "paint_brush":
52
+ self.model.move_paint_brush(event.scenePos())
53
+ elif self.model.checked_button == "move_image":
54
+ self.model.move_move_tool(event)
55
+ elif self.model.checked_button == "eraser":
56
+ self.model.move_eraser(event.scenePos())
57
+ elif self.model.checked_button == "rectangle":
58
+ self.model.move_rectangle_tool(event.scenePos())
59
+ elif self.model.checked_button == "polygon":
60
+ self.model.move_polygon_tool(event.scenePos())
61
+ elif self.model.checked_button == "ellipse":
62
+ self.model.move_ellipse_tool(event.scenePos())
63
+
64
+
65
+ elif event.type() == QEvent.Type.GraphicsSceneMouseRelease and event.button() == Qt.MouseButton.LeftButton:
66
+ if self.model.checked_button == "paint_brush":
67
+ self.model.end_paint_brush()
68
+ elif self.model.checked_button == "move_image":
69
+ self.model.end_move_tool()
70
+ elif self.model.checked_button == "contour_filling":
71
+ self.model.end_contour_filling()
72
+ elif self.model.checked_button == "magic_pen":
73
+
74
+ self.view.zoomable_graphics_view.change_cursor("magic")
75
+ elif self.model.checked_button == "eraser":
76
+ self.model.end_eraser()
77
+ elif self.model.checked_button == "rectangle":
78
+ self.model.end_rectangle_tool()
79
+ elif self.model.checked_button == "ellipse":
80
+ self.model.end_ellipse_tool()
81
+
82
+ elif event.type() == QEvent.Type.GraphicsSceneMousePress and event.button() == Qt.MouseButton.RightButton:
83
+ #elif event.type() == QEvent.Type.KeyPress:
84
+ #if event.key() == Qt.Key.Key_Delete:
85
+ if self.model.checked_button == "rectangle":
86
+ self.model.clear_rectangle()
87
+ if self.model.checked_button == "polygon":
88
+ self.model.clear_polygon()
89
+ if self.model.checked_button == "ellipse":
90
+ self.model.clear_ellipse()
91
+
92
+ #elif event.type() == QEvent.Type.GraphicsSceneMousePress and event.button() == Qt.MouseButton.RightButton:
93
+ # if self.model.checked_button == "contour_filling":
94
+ # if self.view.layer_activation == True :
95
+ # self.model.fill_contour(event.scenePos())
96
+
97
+ #MouseButton.MiddleButton: move tool
98
+ elif event.type() == QEvent.Type.GraphicsSceneMousePress and event.button() == Qt.MouseButton.MiddleButton:
99
+ self.model.start_move_tool(event)
100
+ elif event.type() == QEvent.Type.GraphicsSceneMouseMove:
101
+ self.model.move_move_tool(event)
102
+ elif event.type() == QEvent.Type.GraphicsSceneMouseRelease and event.button() == Qt.MouseButton.MiddleButton:
103
+ self.model.end_move_tool()
104
+
105
+ #MouseButton.MiddleButton: zoom tool
106
+ elif event.type() == QEvent.Type.Wheel and self.model.move_tool_activation == False:
107
+ #if QApplication.mouseButtons() & Qt.MiddleButton:
108
+ # return False
109
+ if hasattr(self.view, 'zoomable_graphics_view'):
110
+ self.view.zoomable_graphics_view.wheelEvent(event)
111
+ return True
112
+
113
+
114
+ class Events:
115
+ def __init__(self):
116
+ self.view = None
117
+ self.model = None
118
+ self.event_eater = None
119
+
120
+ def set_view(self, view):
121
+ self.view = view
122
+ self.event_eater = eventEater(self, self.view, self.model)
123
+ #self.view.zoomable_graphics_view.scene.installEventFilter(self.event_eater)
124
+
125
+ def set_model(self, model):
126
+ self.model = model
127
+ self.event_eater.set_model(model)
128
+
129
+ def all_events(self, event_name):
130
+ print("all_events")
131
+
132
+ def desactivate_buttons_labeling_image_bar(self, event_name):
133
+ self.view.desactivate_buttons(event_name, [self.view.buttons_labeling_bar, self.view.buttons_image_bar])
134
+
135
+ def desactivate_buttons_label_bar(self, event_name):
136
+ buttons_bar = {key: self.view.buttons_label_bar_temporary[key] for key in self.view.buttons_label_bar_temporary.keys() if key.startswith("activation_")}
137
+ self.view.desactivate_buttons(event_name, [buttons_bar])
138
+
139
+ def error_message(self, title, text):
140
+ msg_box = QMessageBox(self.view)
141
+ for button in msg_box.buttons():
142
+ button.setObjectName("dialog")
143
+ msg_box.setObjectName("dialog")
144
+ msg_box.setWindowTitle("Error: "+str(title))
145
+ msg_box.setText(text)
146
+ msg_box.exec()
147
+
@@ -0,0 +1,69 @@
1
+
2
+ from PyImageLabeling.controller.Events import Events
3
+
4
+ from PyQt6.QtWidgets import QFileDialog, QLabel
5
+ from PyQt6.QtGui import QPixmap, QImage
6
+
7
+ import os
8
+
9
+ class FileEvents(Events):
10
+ def __init__(self):
11
+ super().__init__()
12
+
13
+ def set_view(self, view):
14
+ super().set_view(view)
15
+
16
+ def set_model(self, model):
17
+ super().set_model(model)
18
+
19
+ def load(self):
20
+ self.all_events(self.load.__name__)
21
+ self.model.load()
22
+ for button_names in self.view.buttons_image_bar:
23
+ self.view.buttons_image_bar[button_names].setEnabled(True)
24
+ for button_names in self.view.buttons_label_bar_permanent:
25
+ self.view.buttons_label_bar_permanent[button_names].setEnabled(True)
26
+
27
+ self.move_image() # we active the move button :)
28
+ print("load")
29
+
30
+
31
+ def save(self):
32
+ self.model.save()
33
+
34
+
35
+ def select_image(self, item):
36
+ print("item:", item)
37
+
38
+ #filename = item.filename
39
+ self.model.select_image(item.file_path)
40
+
41
+ if self.model.get_current_label_item() is not None:
42
+ self.model.update_labeling_overlays(self.model.get_current_label_item().get_label_id())
43
+
44
+ self.view.file_bar_list.setCurrentItem(item)
45
+
46
+ # item_widget = self.view.file_bar_list.itemWidget(item)
47
+ # if item_widget:
48
+ # file_label = item_widget.findChild(QLabel)
49
+ # if file_label:
50
+ # filename = file_label.text()
51
+ # matching_path = None
52
+ # for path in self.model.loaded_image_paths:
53
+ # if os.path.basename(path) == filename:
54
+ # matching_path = path
55
+ # break
56
+ # if matching_path:
57
+ # self.model.load_image(matching_path)
58
+ # self.view.file_bar_list.setCurrentItem(item)
59
+ # print(f"Loaded image: {filename}")
60
+ # else:
61
+ # print(f"Error: Could not find path for {filename}")
62
+
63
+ def next_image(self):
64
+ self.all_events(self.next_image.__name__)
65
+ self.model.next_image()
66
+
67
+ def previous_image(self):
68
+ self.all_events(self.previous_image.__name__)
69
+ self.model.previous_image()
@@ -0,0 +1,32 @@
1
+ from controller.Events import Events
2
+
3
+
4
+ class ImageEvents(Events):
5
+ def __init__(self):
6
+ super().__init__()
7
+
8
+ def zoom_plus(self):
9
+ self.desactivate_buttons_labeling_image_bar(self.zoom_plus.__name__)
10
+ self.all_events(self.zoom_plus.__name__)
11
+ self.view.zoomable_graphics_view.change_cursor("zoom_plus")
12
+ self.model.zoom_plus()
13
+
14
+ def zoom_minus(self):
15
+ self.desactivate_buttons_labeling_image_bar(self.zoom_minus.__name__)
16
+ self.all_events(self.zoom_minus.__name__)
17
+ self.view.zoomable_graphics_view.change_cursor("zoom_minus")
18
+ self.model.zoom_minus()
19
+
20
+ def move_image(self):
21
+ self.desactivate_buttons_labeling_image_bar(self.move_image.__name__)
22
+ self.all_events(self.move_image.__name__)
23
+ self.view.zoomable_graphics_view.change_cursor("move")
24
+ self.model.move_image()
25
+
26
+ def reset_move_zoom_image(self):
27
+ self.all_events(self.reset_move_zoom_image.__name__)
28
+ self.model.reset_move_zoom_image()
29
+
30
+
31
+
32
+