pymodaq 4.2.3__py3-none-any.whl → 5.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.

Potentially problematic release.


This version of pymodaq might be problematic. Click here for more details.

Files changed (399) hide show
  1. pymodaq/__init__.py +30 -23
  2. pymodaq/control_modules/daq_move.py +27 -14
  3. pymodaq/control_modules/daq_move_ui.py +33 -16
  4. pymodaq/control_modules/daq_viewer.py +38 -28
  5. pymodaq/control_modules/daq_viewer_ui.py +6 -6
  6. pymodaq/control_modules/mocks.py +1 -1
  7. pymodaq/control_modules/move_utility_classes.py +19 -10
  8. pymodaq/control_modules/utils.py +18 -12
  9. pymodaq/control_modules/viewer_utility_classes.py +13 -4
  10. pymodaq/dashboard.py +166 -118
  11. pymodaq/examples/custom_app.py +13 -16
  12. pymodaq/examples/custom_viewer.py +7 -7
  13. pymodaq/examples/function_plotter.py +13 -12
  14. pymodaq/examples/parameter_ex.py +50 -25
  15. pymodaq/examples/tcp_client.py +1 -1
  16. pymodaq/extensions/__init__.py +1 -1
  17. pymodaq/extensions/bayesian/bayesian_optimisation.py +15 -12
  18. pymodaq/extensions/bayesian/utils.py +10 -10
  19. pymodaq/extensions/console.py +10 -13
  20. pymodaq/extensions/{daq_logger.py → daq_logger/daq_logger.py} +36 -56
  21. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger.py +16 -15
  22. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger_models.py +2 -0
  23. pymodaq/{utils/h5modules → extensions/daq_logger}/h5logging.py +7 -8
  24. pymodaq/extensions/daq_scan.py +153 -247
  25. pymodaq/extensions/daq_scan_ui.py +11 -9
  26. pymodaq/extensions/h5browser.py +8 -8
  27. pymodaq/extensions/pid/__init__.py +6 -3
  28. pymodaq/extensions/pid/daq_move_PID.py +4 -2
  29. pymodaq/extensions/pid/pid_controller.py +15 -12
  30. pymodaq/extensions/pid/utils.py +10 -5
  31. pymodaq/extensions/utils.py +5 -3
  32. pymodaq/post_treatment/load_and_plot.py +10 -7
  33. pymodaq/resources/preset_default.xml +1 -1
  34. pymodaq/utils/array_manipulation.py +4 -384
  35. pymodaq/utils/calibration_camera.py +12 -9
  36. pymodaq/utils/chrono_timer.py +7 -5
  37. pymodaq/utils/config.py +3 -450
  38. pymodaq/utils/daq_utils.py +6 -664
  39. pymodaq/utils/data.py +9 -2774
  40. pymodaq/utils/exceptions.py +0 -4
  41. pymodaq/utils/gui_utils/__init__.py +8 -8
  42. pymodaq/utils/gui_utils/loader_utils.py +38 -0
  43. pymodaq/utils/gui_utils/utils.py +6 -138
  44. pymodaq/utils/h5modules/__init__.py +0 -4
  45. pymodaq/utils/h5modules/module_saving.py +15 -8
  46. pymodaq/utils/leco/__init__.py +2 -2
  47. pymodaq/utils/leco/daq_move_LECODirector.py +2 -2
  48. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +2 -2
  49. pymodaq/utils/leco/director_utils.py +2 -2
  50. pymodaq/utils/leco/leco_director.py +3 -3
  51. pymodaq/utils/leco/pymodaq_listener.py +2 -2
  52. pymodaq/utils/leco/utils.py +1 -1
  53. pymodaq/utils/logger.py +4 -76
  54. pymodaq/utils/managers/batchscan_manager.py +16 -19
  55. pymodaq/utils/managers/modules_manager.py +10 -7
  56. pymodaq/utils/managers/overshoot_manager.py +3 -5
  57. pymodaq/utils/managers/preset_manager.py +37 -15
  58. pymodaq/utils/managers/preset_manager_utils.py +11 -9
  59. pymodaq/utils/managers/remote_manager.py +12 -10
  60. pymodaq/utils/math_utils.py +4 -572
  61. pymodaq/utils/parameter/__init__.py +4 -11
  62. pymodaq/utils/parameter/utils.py +4 -299
  63. pymodaq/utils/scanner/scan_config.py +1 -1
  64. pymodaq/utils/scanner/scan_factory.py +16 -12
  65. pymodaq/utils/{plotting → scanner}/scan_selector.py +19 -20
  66. pymodaq/utils/scanner/scanner.py +10 -8
  67. pymodaq/utils/scanner/scanners/_1d_scanners.py +8 -5
  68. pymodaq/utils/scanner/scanners/_2d_scanners.py +5 -5
  69. pymodaq/utils/scanner/scanners/sequential.py +8 -8
  70. pymodaq/utils/scanner/scanners/tabular.py +9 -9
  71. pymodaq/utils/scanner/utils.py +6 -4
  72. pymodaq/utils/svg/svg_viewer2D.py +3 -4
  73. pymodaq/utils/tcp_ip/serializer.py +64 -16
  74. pymodaq/utils/tcp_ip/tcp_server_client.py +10 -8
  75. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/METADATA +5 -3
  76. pymodaq-5.0.0.dist-info/RECORD +123 -0
  77. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/WHEEL +1 -1
  78. pymodaq/post_treatment/process_to_scalar.py +0 -263
  79. pymodaq/resources/QtDesigner_Ressources/Icon_Library/1d.png +0 -0
  80. pymodaq/resources/QtDesigner_Ressources/Icon_Library/2d.png +0 -0
  81. pymodaq/resources/QtDesigner_Ressources/Icon_Library/3d.png +0 -0
  82. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add2.png +0 -0
  83. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add_Step.png +0 -0
  84. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve.png +0 -0
  85. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve_All.png +0 -0
  86. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Browse_Dir_Path.png +0 -0
  87. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Calculator.png +0 -0
  88. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnGroup.png +0 -0
  89. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnNum.png +0 -0
  90. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnText.png +0 -0
  91. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnTime.png +0 -0
  92. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnWave.png +0 -0
  93. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Close3.png +0 -0
  94. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll.png +0 -0
  95. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll_32.png +0 -0
  96. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ColorPicker.png +0 -0
  97. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Contract.png +0 -0
  98. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Create.png +0 -0
  99. pymodaq/resources/QtDesigner_Ressources/Icon_Library/DeleteLayer.png +0 -0
  100. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditOpen.png +0 -0
  101. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditRedo.png +0 -0
  102. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditUndo.png +0 -0
  103. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Ellipse.png +0 -0
  104. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EllipseFilled.png +0 -0
  105. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error.png +0 -0
  106. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ErrorMessage.png +0 -0
  107. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error_16.png +0 -0
  108. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Exit.png +0 -0
  109. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Expand.png +0 -0
  110. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll.png +0 -0
  111. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll_32.png +0 -0
  112. pymodaq/resources/QtDesigner_Ressources/Icon_Library/FFT.png +0 -0
  113. pymodaq/resources/QtDesigner_Ressources/Icon_Library/HLM.ico +0 -0
  114. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help.png +0 -0
  115. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help_32.png +0 -0
  116. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Histogram.png +0 -0
  117. pymodaq/resources/QtDesigner_Ressources/Icon_Library/LUT_LookUpTable.png +0 -0
  118. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass.png +0 -0
  119. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass_24.png +0 -0
  120. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Marker.png +0 -0
  121. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Math.png +0 -0
  122. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MeasurementStudio_32.png +0 -0
  123. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Move.png +0 -0
  124. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveDown.png +0 -0
  125. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveUp.png +0 -0
  126. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Multiply.png +0 -0
  127. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewFile.png +0 -0
  128. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewLayer.png +0 -0
  129. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_File.png +0 -0
  130. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_Folder.png +0 -0
  131. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open.png +0 -0
  132. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_1D.png +0 -0
  133. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_2D.png +0 -0
  134. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File.png +0 -0
  135. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File_32.png +0 -0
  136. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_sim.png +0 -0
  137. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Options.png +0 -0
  138. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope.png +0 -0
  139. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope_16.png +0 -0
  140. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Pass.png +0 -0
  141. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RGB.png +0 -0
  142. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rectangle.png +0 -0
  143. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RectangleFilled.png +0 -0
  144. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Redo.png +0 -0
  145. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh.png +0 -0
  146. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh2.png +0 -0
  147. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh_32.png +0 -0
  148. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Region.png +0 -0
  149. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rendezvous.png +0 -0
  150. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SELECT.png +0 -0
  151. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save.png +0 -0
  152. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll.png +0 -0
  153. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll_32.png +0 -0
  154. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs.png +0 -0
  155. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs_32.png +0 -0
  156. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_24.png +0 -0
  157. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_32.png +0 -0
  158. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Search.png +0 -0
  159. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SelectPolygon.png +0 -0
  160. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Select_24.png +0 -0
  161. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Settings.png +0 -0
  162. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snap&Save.png +0 -0
  163. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot.png +0 -0
  164. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2.png +0 -0
  165. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_16.png +0 -0
  166. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_32.png +0 -0
  167. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Spreadsheet.png +0 -0
  168. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics.png +0 -0
  169. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics2.png +0 -0
  170. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Status.png +0 -0
  171. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Subtract.png +0 -0
  172. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Vision.png +0 -0
  173. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Volts.png +0 -0
  174. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Wait2.png +0 -0
  175. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_1_1.png +0 -0
  176. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_in.png +0 -0
  177. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_out.png +0 -0
  178. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_to_Selection.png +0 -0
  179. pymodaq/resources/QtDesigner_Ressources/Icon_Library/abort.png +0 -0
  180. pymodaq/resources/QtDesigner_Ressources/Icon_Library/advanced2.png +0 -0
  181. pymodaq/resources/QtDesigner_Ressources/Icon_Library/autoscale.png +0 -0
  182. pymodaq/resources/QtDesigner_Ressources/Icon_Library/b_icon.png +0 -0
  183. pymodaq/resources/QtDesigner_Ressources/Icon_Library/back.png +0 -0
  184. pymodaq/resources/QtDesigner_Ressources/Icon_Library/bg_icon.png +0 -0
  185. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera.png +0 -0
  186. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera_snap.png +0 -0
  187. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cartesian.png +0 -0
  188. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear2.png +0 -0
  189. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear_ROI.png +0 -0
  190. pymodaq/resources/QtDesigner_Ressources/Icon_Library/close2.png +0 -0
  191. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cluster2.png +0 -0
  192. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color.png +0 -0
  193. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color2.png +0 -0
  194. pymodaq/resources/QtDesigner_Ressources/Icon_Library/continuous.png +0 -0
  195. pymodaq/resources/QtDesigner_Ressources/Icon_Library/data.png +0 -0
  196. pymodaq/resources/QtDesigner_Ressources/Icon_Library/delay.png +0 -0
  197. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download.png +0 -0
  198. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download2.png +0 -0
  199. pymodaq/resources/QtDesigner_Ressources/Icon_Library/error2.png +0 -0
  200. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ethernet.png +0 -0
  201. pymodaq/resources/QtDesigner_Ressources/Icon_Library/exit2.png +0 -0
  202. pymodaq/resources/QtDesigner_Ressources/Icon_Library/fan.png +0 -0
  203. pymodaq/resources/QtDesigner_Ressources/Icon_Library/filter2.png +0 -0
  204. pymodaq/resources/QtDesigner_Ressources/Icon_Library/g_icon.png +0 -0
  205. pymodaq/resources/QtDesigner_Ressources/Icon_Library/gear2.png +0 -0
  206. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to.png +0 -0
  207. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_1.png +0 -0
  208. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_2.png +0 -0
  209. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grab.png +0 -0
  210. pymodaq/resources/QtDesigner_Ressources/Icon_Library/graph.png +0 -0
  211. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2.png +0 -0
  212. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2_32.png +0 -0
  213. pymodaq/resources/QtDesigner_Ressources/Icon_Library/green_light.png +0 -0
  214. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grey_icon.png +0 -0
  215. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greyscale.png +0 -0
  216. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1.png +0 -0
  217. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1_32.png +0 -0
  218. pymodaq/resources/QtDesigner_Ressources/Icon_Library/home2.png +0 -0
  219. pymodaq/resources/QtDesigner_Ressources/Icon_Library/information2.png +0 -0
  220. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ini.png +0 -0
  221. pymodaq/resources/QtDesigner_Ressources/Icon_Library/integrator.png +0 -0
  222. pymodaq/resources/QtDesigner_Ressources/Icon_Library/joystick.png +0 -0
  223. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green.png +0 -0
  224. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green_16.png +0 -0
  225. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red.png +0 -0
  226. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red_16.png +0 -0
  227. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow.png +0 -0
  228. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow_16.png +0 -0
  229. pymodaq/resources/QtDesigner_Ressources/Icon_Library/limiter.png +0 -0
  230. pymodaq/resources/QtDesigner_Ressources/Icon_Library/load_ROI.png +0 -0
  231. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meshPlot.png +0 -0
  232. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter.png +0 -0
  233. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter2.png +0 -0
  234. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter_32.png +0 -0
  235. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_contour.png +0 -0
  236. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_straight_line.png +0 -0
  237. pymodaq/resources/QtDesigner_Ressources/Icon_Library/movie.png +0 -0
  238. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multi_point.png +0 -0
  239. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multiplexer.png +0 -0
  240. pymodaq/resources/QtDesigner_Ressources/Icon_Library/new.png +0 -0
  241. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openArrow.png +0 -0
  242. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openTree.png +0 -0
  243. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope2.png +0 -0
  244. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope3.png +0 -0
  245. pymodaq/resources/QtDesigner_Ressources/Icon_Library/overlay.png +0 -0
  246. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2.png +0 -0
  247. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2_16.png +0 -0
  248. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass_32.png +0 -0
  249. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pause.png +0 -0
  250. pymodaq/resources/QtDesigner_Ressources/Icon_Library/permute.png +0 -0
  251. pymodaq/resources/QtDesigner_Ressources/Icon_Library/phase.png +0 -0
  252. pymodaq/resources/QtDesigner_Ressources/Icon_Library/play.png +0 -0
  253. pymodaq/resources/QtDesigner_Ressources/Icon_Library/polar.png +0 -0
  254. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pole_zero.png +0 -0
  255. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerMeter.png +0 -0
  256. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch.png +0 -0
  257. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch_16.png +0 -0
  258. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2.png +0 -0
  259. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2_32.png +0 -0
  260. pymodaq/resources/QtDesigner_Ressources/Icon_Library/properties.png +0 -0
  261. pymodaq/resources/QtDesigner_Ressources/Icon_Library/r_icon.png +0 -0
  262. pymodaq/resources/QtDesigner_Ressources/Icon_Library/radiocontrolbutton.png +0 -0
  263. pymodaq/resources/QtDesigner_Ressources/Icon_Library/read2.png +0 -0
  264. pymodaq/resources/QtDesigner_Ressources/Icon_Library/red_light.png +0 -0
  265. pymodaq/resources/QtDesigner_Ressources/Icon_Library/remove.png +0 -0
  266. pymodaq/resources/QtDesigner_Ressources/Icon_Library/reset.png +0 -0
  267. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rgb_icon.png +0 -0
  268. pymodaq/resources/QtDesigner_Ressources/Icon_Library/robot.png +0 -0
  269. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rotation2.png +0 -0
  270. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run2.png +0 -0
  271. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  272. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saturation.png +0 -0
  273. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saveTree.png +0 -0
  274. pymodaq/resources/QtDesigner_Ressources/Icon_Library/save_ROI.png +0 -0
  275. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_horizontally.png +0 -0
  276. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_vertically.png +0 -0
  277. pymodaq/resources/QtDesigner_Ressources/Icon_Library/search2.png +0 -0
  278. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select2.png +0 -0
  279. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all.png +0 -0
  280. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all2.png +0 -0
  281. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_none.png +0 -0
  282. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence.png +0 -0
  283. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence2.png +0 -0
  284. pymodaq/resources/QtDesigner_Ressources/Icon_Library/snap.png +0 -0
  285. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sort_ascend.png +0 -0
  286. pymodaq/resources/QtDesigner_Ressources/Icon_Library/spectrumAnalyzer.png +0 -0
  287. pymodaq/resources/QtDesigner_Ressources/Icon_Library/start.png +0 -0
  288. pymodaq/resources/QtDesigner_Ressources/Icon_Library/status_cancelled.png +0 -0
  289. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop.png +0 -0
  290. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop2.png +0 -0
  291. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop3.png +0 -0
  292. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  293. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sum.png +0 -0
  294. pymodaq/resources/QtDesigner_Ressources/Icon_Library/surfacePlot.png +0 -0
  295. pymodaq/resources/QtDesigner_Ressources/Icon_Library/tree.png +0 -0
  296. pymodaq/resources/QtDesigner_Ressources/Icon_Library/updateTree.png +0 -0
  297. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility2.png +0 -0
  298. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility_small.png +0 -0
  299. pymodaq/resources/QtDesigner_Ressources/Icon_Library/vector.png +0 -0
  300. pymodaq/resources/QtDesigner_Ressources/Icon_Library/verify.png +0 -0
  301. pymodaq/resources/QtDesigner_Ressources/Icon_Library/video.png +0 -0
  302. pymodaq/resources/QtDesigner_Ressources/Icon_Library/wait.png +0 -0
  303. pymodaq/resources/QtDesigner_Ressources/Icon_Library/waterfallPlot.png +0 -0
  304. pymodaq/resources/QtDesigner_Ressources/Icon_Library/watershed.png +0 -0
  305. pymodaq/resources/QtDesigner_Ressources/Icon_Library/yellow_light.png +0 -0
  306. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zip_file.png +0 -0
  307. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomAuto.png +0 -0
  308. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomReset.png +0 -0
  309. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +0 -2
  310. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +0 -234
  311. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +0 -127150
  312. pymodaq/resources/QtDesigner_Ressources/icons.svg +0 -142
  313. pymodaq/resources/VERSION +0 -1
  314. pymodaq/resources/config_template.toml +0 -90
  315. pymodaq/resources/triangulation_data.npy +0 -0
  316. pymodaq/utils/abstract/__init__.py +0 -48
  317. pymodaq/utils/db/__init__.py +0 -0
  318. pymodaq/utils/db/db_logger/__init__.py +0 -0
  319. pymodaq/utils/enums.py +0 -76
  320. pymodaq/utils/factory.py +0 -82
  321. pymodaq/utils/gui_utils/custom_app.py +0 -133
  322. pymodaq/utils/gui_utils/dock.py +0 -107
  323. pymodaq/utils/gui_utils/file_io.py +0 -93
  324. pymodaq/utils/gui_utils/layout.py +0 -34
  325. pymodaq/utils/gui_utils/list_picker.py +0 -38
  326. pymodaq/utils/gui_utils/widgets/__init__.py +0 -5
  327. pymodaq/utils/gui_utils/widgets/label.py +0 -24
  328. pymodaq/utils/gui_utils/widgets/lcd.py +0 -111
  329. pymodaq/utils/gui_utils/widgets/push.py +0 -149
  330. pymodaq/utils/gui_utils/widgets/qled.py +0 -62
  331. pymodaq/utils/gui_utils/widgets/spinbox.py +0 -24
  332. pymodaq/utils/gui_utils/widgets/table.py +0 -263
  333. pymodaq/utils/gui_utils/widgets/tree_layout.py +0 -188
  334. pymodaq/utils/gui_utils/widgets/tree_toml.py +0 -102
  335. pymodaq/utils/h5modules/backends.py +0 -1022
  336. pymodaq/utils/h5modules/browsing.py +0 -625
  337. pymodaq/utils/h5modules/data_saving.py +0 -1101
  338. pymodaq/utils/h5modules/exporter.py +0 -119
  339. pymodaq/utils/h5modules/exporters/__init__.py +0 -0
  340. pymodaq/utils/h5modules/exporters/base.py +0 -111
  341. pymodaq/utils/h5modules/exporters/flimj.py +0 -63
  342. pymodaq/utils/h5modules/exporters/hyperspy.py +0 -143
  343. pymodaq/utils/h5modules/saving.py +0 -866
  344. pymodaq/utils/h5modules/utils.py +0 -115
  345. pymodaq/utils/managers/action_manager.py +0 -489
  346. pymodaq/utils/managers/parameter_manager.py +0 -282
  347. pymodaq/utils/managers/roi_manager.py +0 -726
  348. pymodaq/utils/messenger.py +0 -66
  349. pymodaq/utils/parameter/ioxml.py +0 -542
  350. pymodaq/utils/parameter/pymodaq_ptypes/__init__.py +0 -38
  351. pymodaq/utils/parameter/pymodaq_ptypes/bool.py +0 -31
  352. pymodaq/utils/parameter/pymodaq_ptypes/date.py +0 -126
  353. pymodaq/utils/parameter/pymodaq_ptypes/filedir.py +0 -143
  354. pymodaq/utils/parameter/pymodaq_ptypes/itemselect.py +0 -265
  355. pymodaq/utils/parameter/pymodaq_ptypes/led.py +0 -44
  356. pymodaq/utils/parameter/pymodaq_ptypes/list.py +0 -150
  357. pymodaq/utils/parameter/pymodaq_ptypes/numeric.py +0 -18
  358. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +0 -175
  359. pymodaq/utils/parameter/pymodaq_ptypes/slide.py +0 -145
  360. pymodaq/utils/parameter/pymodaq_ptypes/table.py +0 -135
  361. pymodaq/utils/parameter/pymodaq_ptypes/tableview.py +0 -149
  362. pymodaq/utils/parameter/pymodaq_ptypes/text.py +0 -142
  363. pymodaq/utils/plotting/__init__.py +0 -0
  364. pymodaq/utils/plotting/data_viewers/__init__.py +0 -10
  365. pymodaq/utils/plotting/data_viewers/base.py +0 -286
  366. pymodaq/utils/plotting/data_viewers/viewer.py +0 -274
  367. pymodaq/utils/plotting/data_viewers/viewer0D.py +0 -298
  368. pymodaq/utils/plotting/data_viewers/viewer1D.py +0 -820
  369. pymodaq/utils/plotting/data_viewers/viewer1Dbasic.py +0 -231
  370. pymodaq/utils/plotting/data_viewers/viewer2D.py +0 -1118
  371. pymodaq/utils/plotting/data_viewers/viewer2D_basic.py +0 -146
  372. pymodaq/utils/plotting/data_viewers/viewerND.py +0 -800
  373. pymodaq/utils/plotting/gant_chart.py +0 -123
  374. pymodaq/utils/plotting/image_viewer.py +0 -97
  375. pymodaq/utils/plotting/items/__init__.py +0 -0
  376. pymodaq/utils/plotting/items/axis_scaled.py +0 -93
  377. pymodaq/utils/plotting/items/crosshair.py +0 -94
  378. pymodaq/utils/plotting/items/image.py +0 -388
  379. pymodaq/utils/plotting/navigator.py +0 -353
  380. pymodaq/utils/plotting/plotter/plotter.py +0 -94
  381. pymodaq/utils/plotting/plotter/plotters/__init__.py +0 -0
  382. pymodaq/utils/plotting/plotter/plotters/matplotlib_plotters.py +0 -134
  383. pymodaq/utils/plotting/plotter/plotters/qt_plotters.py +0 -78
  384. pymodaq/utils/plotting/utils/__init__.py +0 -0
  385. pymodaq/utils/plotting/utils/axes_viewer.py +0 -88
  386. pymodaq/utils/plotting/utils/filter.py +0 -585
  387. pymodaq/utils/plotting/utils/lineout.py +0 -226
  388. pymodaq/utils/plotting/utils/plot_utils.py +0 -579
  389. pymodaq/utils/plotting/utils/signalND.py +0 -1347
  390. pymodaq/utils/plotting/widgets.py +0 -76
  391. pymodaq/utils/qvariant.py +0 -12
  392. pymodaq/utils/slicing.py +0 -63
  393. pymodaq/utils/units.py +0 -216
  394. pymodaq-4.2.3.dist-info/RECORD +0 -438
  395. /pymodaq/{post_treatment/daq_analysis → extensions/daq_logger}/__init__.py +0 -0
  396. /pymodaq/{utils/abstract/logger.py → extensions/daq_logger/abstract.py} +0 -0
  397. /pymodaq/{resources/QtDesigner_Ressources → extensions/daq_logger/db}/__init__.py +0 -0
  398. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/entry_points.txt +0 -0
  399. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,726 +0,0 @@
1
- from abc import abstractmethod
2
- import os
3
- import sys
4
- from typing import List, TYPE_CHECKING, Tuple
5
- import pymodaq.utils
6
- from qtpy import QtCore, QtGui, QtWidgets
7
- from qtpy.QtCore import QObject, Slot, Signal, QPointF
8
- from qtpy.QtGui import QIcon, QPixmap
9
- from collections import OrderedDict
10
-
11
- from pymodaq.utils.parameter import ioxml
12
- from pymodaq.utils.parameter import utils as putils
13
- from pymodaq.utils.parameter import ParameterTree, Parameter
14
- from pyqtgraph.parametertree.parameterTypes.basetypes import GroupParameter
15
- from pymodaq.utils.parameter import pymodaq_ptypes
16
- from pymodaq.utils.managers.action_manager import QAction
17
- from pyqtgraph import ROI as pgROI
18
- from pyqtgraph import RectROI as pgRectROI
19
- from pyqtgraph import functions as fn
20
- from pyqtgraph import LinearRegionItem as pgLinearROI
21
- from pymodaq.utils.daq_utils import plot_colors
22
- from pymodaq.utils.logger import get_module_name, set_logger
23
- from pymodaq.utils.config import get_set_roi_path
24
- from pymodaq.utils.gui_utils import select_file
25
- from pymodaq.utils.math_utils import rotate2D
26
-
27
- import numpy as np
28
- from pathlib import Path
29
- from pymodaq.post_treatment.process_to_scalar import DataProcessorFactory
30
-
31
- if TYPE_CHECKING:
32
- from pymodaq.control_modules.daq_viewer import DAQ_Viewer
33
-
34
- data_processors = DataProcessorFactory()
35
-
36
- roi_path = get_set_roi_path()
37
- logger = set_logger(get_module_name(__file__))
38
-
39
-
40
- class ROIPositionMapper(QtWidgets.QWidget):
41
- """ Widget presenting a Tree structure representing a ROI positions.
42
- """
43
-
44
- def __init__(self, roi_pos, roi_size):
45
- super().__init__()
46
- self.roi_pos = roi_pos
47
- self.roi_size = roi_size
48
-
49
- def show_dialog(self):
50
- self.params = [
51
- {'name': 'position', 'type': 'group', 'children': [
52
- {'name': 'x0', 'type': 'float', 'value': self.roi_pos[0] + self.roi_size[0] / 2, 'step': 1},
53
- {'name': 'y0', 'type': 'float', 'value': self.roi_pos[1] + self.roi_size[1] / 2, 'step': 1}
54
- ]},
55
- {'name': 'size', 'type': 'group', 'children': [
56
- {'name': 'width', 'type': 'float', 'value': self.roi_size[0], 'step': 1},
57
- {'name': 'height', 'type': 'float', 'value': self.roi_size[1], 'step': 1}]
58
- }]
59
-
60
- dialog = QtWidgets.QDialog(self)
61
- vlayout = QtWidgets.QVBoxLayout()
62
- self.settings_tree = ParameterTree()
63
- vlayout.addWidget(self.settings_tree, 10)
64
- self.settings_tree.setMinimumWidth(300)
65
- self.settings = Parameter.create(name='settings', type='group', children=self.params)
66
- self.settings_tree.setParameters(self.settings, showTop=False)
67
- dialog.setLayout(vlayout)
68
-
69
- buttonBox = QtWidgets.QDialogButtonBox(parent=self)
70
- buttonBox.addButton('Apply', buttonBox.AcceptRole)
71
- buttonBox.accepted.connect(dialog.accept)
72
- buttonBox.addButton('Cancel', buttonBox.RejectRole)
73
- buttonBox.rejected.connect(dialog.reject)
74
-
75
- vlayout.addWidget(buttonBox)
76
- self.setWindowTitle('Set Precise positions for the ROI')
77
- res = dialog.exec()
78
-
79
- if res == dialog.Accepted:
80
-
81
- return self.settings
82
- else:
83
- return None
84
-
85
-
86
- class ROI(pgROI):
87
- index_signal = Signal(int)
88
-
89
- def __init__(self, *args, index=0, name='roi', **kwargs):
90
- super().__init__(*args, **kwargs)
91
- self.name = name
92
- self.index = index
93
- self._menu = QtWidgets.QMenu()
94
- self._menu.addAction('Set ROI positions', self.set_positions)
95
- self.sigRegionChangeFinished.connect(self.emit_index_signal)
96
-
97
- def emit_index_signal(self):
98
- self.index_signal.emit(self.index)
99
-
100
- @property
101
- def color(self):
102
- return self.pen.color()
103
-
104
- def center(self):
105
- return QPointF(self.pos().x() + self.size().x() / 2, self.pos().y() + self.size().y() / 2)
106
-
107
- def set_positions(self):
108
- mapper = ROIPositionMapper(self.pos(), self.size())
109
- settings = mapper.show_dialog()
110
- if settings is not None:
111
- self.setSize((settings['size', 'width'], settings['size', 'height']))
112
- self.setPos((settings['position', 'x0'] - settings['size', 'width'] / 2,
113
- settings['position', 'y0'] - settings['size', 'height'] / 2))
114
-
115
- def contextMenuEvent(self, event):
116
- if self._menu is not None:
117
- self._menu.exec(event.screenPos())
118
-
119
- def width(self) -> float:
120
- return self.size().x()
121
-
122
- def height(self) -> float:
123
- return self.size().y()
124
-
125
-
126
- class ROIBrushable(ROI):
127
- def __init__(self, brush=None, *args, **kwargs):
128
- super().__init__(*args, **kwargs)
129
-
130
- if brush is None:
131
- brush = QtGui.QBrush(QtGui.QColor(0, 0, 255, 50))
132
- self.setBrush(brush)
133
-
134
- def setBrush(self, *br, **kargs):
135
- """Set the brush that fills the region. Can have any arguments that are valid
136
- for :func:`mkBrush <pyqtgraph.mkBrush>`.
137
- """
138
- self.brush = fn.mkBrush(*br, **kargs)
139
- self.currentBrush = self.brush
140
-
141
- def paint(self, p, opt, widget):
142
- # p.save()
143
- # Note: don't use self.boundingRect here, because subclasses may need to redefine it.
144
- r = QtCore.QRectF(0, 0, self.state['size'][0], self.state['size'][1]).normalized()
145
-
146
- p.setRenderHint(QtGui.QPainter.Antialiasing)
147
- p.setPen(self.currentPen)
148
- p.setBrush(self.currentBrush)
149
- p.translate(r.left(), r.top())
150
- p.scale(r.width(), r.height())
151
- p.drawRect(0, 0, 1, 1)
152
- # p.restore()
153
-
154
-
155
- class LinearROI(pgLinearROI):
156
- index_signal = Signal(int)
157
-
158
- def __init__(self, index=0, pos=[0, 10], name = 'roi', **kwargs):
159
- super().__init__(values=pos, **kwargs)
160
- self.name = name
161
- self.index = index
162
- self.sigRegionChangeFinished.connect(self.emit_index_signal)
163
-
164
- def pos(self) -> Tuple[float, float]:
165
- return self.getRegion()
166
-
167
- def center(self) -> float:
168
- pos = self.pos()
169
- return (pos[0] + pos[1]) / 2
170
-
171
- def setPos(self, pos: Tuple[int, int]):
172
- self.setRegion(pos)
173
-
174
- def setPen(self, color):
175
- self.setBrush(color)
176
-
177
- @property
178
- def color(self):
179
- return self.brush.color()
180
-
181
- def emit_index_signal(self):
182
- self.index_signal.emit(self.index)
183
-
184
-
185
- class EllipseROI(ROI):
186
- """
187
- Elliptical ROI subclass with one scale handle and one rotation handle.
188
-
189
-
190
- ============== =============================================================
191
- **Arguments**
192
- pos (length-2 sequence) The position of the ROI's origin.
193
- size (length-2 sequence) The size of the ROI's bounding rectangle.
194
- **args All extra keyword arguments are passed to ROI()
195
- ============== =============================================================
196
-
197
- """
198
-
199
-
200
- def __init__(self, index=0, pos=[0, 0], size=[10, 10], **kwargs):
201
- # QtGui.QGraphicsRectItem.__init__(self, 0, 0, size[0], size[1])
202
- super().__init__(pos=pos, size=size, index=index, **kwargs)
203
- self.addRotateHandle([1.0, 0.5], [0.5, 0.5])
204
- self.addScaleHandle([0.5 * 2. ** -0.5 + 0.5, 0.5 * 2. ** -0.5 + 0.5], [0.5, 0.5])
205
-
206
- def getArrayRegion(self, arr, img=None, axes=(0, 1), **kwds):
207
- """
208
- Return the result of ROI.getArrayRegion() masked by the elliptical shape
209
- of the ROI. Regions outside the ellipse are set to 0.
210
- """
211
- # Note: we could use the same method as used by PolyLineROI, but this
212
- # implementation produces a nicer mask.
213
- if kwds["returnMappedCoords"]:
214
- arr, coords = pgROI.getArrayRegion(self, arr, img, axes, **kwds)
215
- else:
216
- arr = pgROI.getArrayRegion(self, arr, img, axes, **kwds)
217
- if arr is None or arr.shape[axes[0]] == 0 or arr.shape[axes[1]] == 0:
218
- return arr
219
- w = arr.shape[axes[0]]
220
- h = arr.shape[axes[1]]
221
- # generate an ellipsoidal mask
222
- mask = np.fromfunction(
223
- lambda x, y: (((x + 0.5) / (w / 2.) - 1) ** 2 + ((y + 0.5) / (h / 2.) - 1) ** 2) ** 0.5 < 1, (w, h))
224
-
225
- # reshape to match array axes
226
- if axes[0] > axes[1]:
227
- mask = mask.T
228
- shape = [(n if i in axes else 1) for i, n in enumerate(arr.shape)]
229
- mask = mask.reshape(shape)
230
- if kwds["returnMappedCoords"]:
231
- return arr * mask, coords
232
- else:
233
- return arr * mask
234
-
235
- def paint(self, p, opt, widget):
236
- r = self.boundingRect()
237
- p.setRenderHint(QtGui.QPainter.Antialiasing)
238
- p.setPen(self.currentPen)
239
-
240
- p.scale(r.width(), r.height()) # workaround for GL bug
241
- r = QtCore.QRectF(r.x() / r.width(), r.y() / r.height(), 1, 1)
242
-
243
- p.drawEllipse(r)
244
-
245
- def shape(self):
246
- self.path = QtGui.QPainterPath()
247
- self.path.addEllipse(self.boundingRect())
248
- return self.path
249
-
250
-
251
- class SimpleRectROI(ROI):
252
- r"""
253
- Rectangular ROI subclass with a single scale handle at the top-right corner.
254
- """
255
-
256
- def __init__(self, pos=[0, 0], size=[10, 10], centered=False, sideScalers=False, **args):
257
- super().__init__(pos, size, **args)
258
- if centered:
259
- center = [0.5, 0.5]
260
- else:
261
- center = [0, 0]
262
-
263
- self.addScaleHandle([1, 1], center)
264
- if sideScalers:
265
- self.addScaleHandle([1, 0.5], [center[0], 0.5])
266
- self.addScaleHandle([0.5, 1], [0.5, center[1]])
267
-
268
-
269
- class RectROI(ROI):
270
- def __init__(self, index=0, pos=[0, 0], size=[10, 10], **kwargs):
271
- super().__init__(pos=pos, size=size, index=index, **kwargs) # , scaleSnap=True, translateSnap=True)
272
- self.addScaleHandle([1, 1], [0, 0])
273
- self.addRotateHandle([0, 0], [0.5, 0.5])
274
-
275
-
276
- ROI_NAME_PREFIX = 'ROI_'
277
- ROI2D_TYPES = ['RectROI', 'EllipseROI']
278
-
279
-
280
- class ROIScalableGroup(GroupParameter):
281
- def __init__(self, roi_type='1D', **opts):
282
- opts['type'] = 'group'
283
- opts['addText'] = "Add"
284
- self.roi_type = roi_type
285
- if roi_type != '1D':
286
- opts['addList'] = ROI2D_TYPES
287
- self.color_list = ROIManager.color_list
288
- super().__init__(**opts)
289
-
290
- def addNew(self, typ=''):
291
- name_prefix = ROI_NAME_PREFIX
292
- child_indexes = [int(par.name()[len(name_prefix) + 1:]) for par in self.children()]
293
- if not child_indexes:
294
- newindex = 0
295
- else:
296
- newindex = max(child_indexes) + 1
297
-
298
- child = {'name': ROIManager.roi_format(newindex), 'type': 'group', 'removable': True, 'renamable': False}
299
-
300
- children = [{'name': 'type', 'type': 'str', 'value': self.roi_type, 'readonly': True, 'visible': False}, ]
301
- if self.roi_type == '2D':
302
- children.extend([{'title': 'ROI Type', 'name': 'roi_type', 'type': 'str', 'value': typ, 'readonly': True},
303
- {'title': 'Use channel', 'name': 'use_channel', 'type': 'list',
304
- 'limits': ['red', 'green', 'blue']}, ])
305
- children.append({'title': 'Math type:', 'name': 'math_function', 'type': 'list',
306
- 'limits': data_processors.functions_filtered('Data2D')})
307
- else:
308
- children.append({'title': 'Use channel', 'name': 'use_channel', 'type': 'list'})
309
- children.append({'title': 'Math type:', 'name': 'math_function', 'type': 'list',
310
- 'limits': data_processors.functions_filtered('Data1D')})
311
-
312
- children.extend([
313
- {'name': 'Color', 'type': 'color', 'value': list(np.roll(self.color_list, newindex)[0])}, ])
314
- if self.roi_type == '2D':
315
- children.extend([{'name': 'position', 'type': 'group', 'children': [
316
- {'name': 'x', 'type': 'float', 'value': 0, 'step': 1},
317
- {'name': 'y', 'type': 'float', 'value': 0, 'step': 1}
318
- ]}, ])
319
- else:
320
- children.extend([{'name': 'position', 'type': 'group', 'children': [
321
- {'name': 'left', 'type': 'float', 'value': 0, 'step': 1},
322
- {'name': 'right', 'type': 'float', 'value': 10, 'step': 1}
323
- ]}, ])
324
- if self.roi_type == '2D':
325
- children.extend([
326
- {'name': 'size', 'type': 'group', 'children': [
327
- {'name': 'width', 'type': 'float', 'value': 10, 'step': 1},
328
- {'name': 'height', 'type': 'float', 'value': 10, 'step': 1}
329
- ]},
330
- {'name': 'angle', 'type': 'float', 'value': 0, 'step': 1}])
331
-
332
- child['children'] = children
333
-
334
- self.addChild(child)
335
-
336
-
337
- class ROIManager(QObject):
338
-
339
- new_ROI_signal = Signal(int, str, str)
340
- remove_ROI_signal = Signal(str)
341
- roi_value_changed = Signal(str, tuple)
342
- color_signal = Signal(list)
343
- roi_update_children = Signal(list)
344
- roi_changed = Signal()
345
- color_list = np.array(plot_colors)
346
-
347
- def __init__(self, viewer_widget=None, ROI_type='1D'):
348
- super().__init__()
349
- self.ROI_type = ROI_type
350
- self.roiwidget = QtWidgets.QWidget()
351
- self.viewer_widget = viewer_widget # either a PlotWidget or a ImageWidget
352
- self._ROIs: OrderedDict[str, ROI] = OrderedDict([])
353
- self.setupUI()
354
-
355
- @staticmethod
356
- def roi_format(index):
357
- return f'{ROI_NAME_PREFIX}{index:02d}'
358
-
359
- @property
360
- def ROIs(self):
361
- return self._ROIs
362
-
363
- def __len__(self):
364
- return len(self._ROIs)
365
-
366
- def get_roi_from_index(self, index: int) -> ROI:
367
- return self.ROIs[self.roi_format(index)]
368
-
369
- def _set_roi_from_index(self, index: int, roi):
370
- self.ROIs[self.roi_format(index)] = roi
371
-
372
- def get_roi(self, roi_key):
373
- if roi_key in self.ROIs:
374
- return self.ROIs[roi_key]
375
- else:
376
- raise KeyError(f'{roi_key} is not a valid ROI identifier for {self.ROIs}')
377
-
378
- def emit_colors(self):
379
- self.color_signal.emit([self._ROIs[roi_key].color for roi_key in self._ROIs])
380
-
381
- def add_roi_programmatically(self, roitype=ROI2D_TYPES[0]):
382
- self.settings.child('ROIs').addNew(roitype)
383
-
384
- def remove_roi_programmatically(self, index: int):
385
- self.settings.child('ROIs').removeChild(self.settings.child('ROIs', self.roi_format(index)))
386
-
387
- def setupUI(self):
388
-
389
- vlayout = QtWidgets.QVBoxLayout()
390
- self.roiwidget.setLayout(vlayout)
391
-
392
- self.toolbar = QtWidgets.QToolBar()
393
- vlayout.addWidget(self.toolbar)
394
-
395
- self.save_ROI_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/save_ROI.png")), 'Save ROIs')
396
- self.load_ROI_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/load_ROI.png")), 'Load ROIs')
397
- self.clear_ROI_pb = QAction(QIcon(QPixmap(":/icons/Icon_Library/clear_ROI.png")), 'Clear ROIs')
398
- self.toolbar.addActions([self.save_ROI_pb, self.load_ROI_pb, self.clear_ROI_pb])
399
-
400
-
401
- self.roitree = ParameterTree()
402
- vlayout.addWidget(self.roitree)
403
- self.roiwidget.setMinimumWidth(250)
404
- self.roiwidget.setMaximumWidth(300)
405
-
406
- params = [
407
- {'title': 'Measurements:', 'name': 'measurements', 'type': 'table', 'value': OrderedDict([]), 'Ncol': 2,
408
- 'header': ["LO", "Value"]},
409
- ROIScalableGroup(roi_type=self.ROI_type, name="ROIs")]
410
- self.settings = Parameter.create(title='ROIs Settings', name='rois_settings', type='group', children=params)
411
- self.roitree.setParameters(self.settings, showTop=False)
412
- self.settings.sigTreeStateChanged.connect(self.roi_tree_changed)
413
-
414
- self.save_ROI_pb.triggered.connect(self.save_ROI)
415
- self.load_ROI_pb.triggered.connect(lambda: self.load_ROI(None))
416
- self.clear_ROI_pb.triggered.connect(self.clear_ROI)
417
-
418
- def roi_tree_changed(self, param, changes):
419
-
420
- for param, change, data in changes:
421
- path = self.settings.childPath(param)
422
- if path is not None:
423
- childName = '.'.join(path)
424
- else:
425
- childName = param.name()
426
- if change == 'childAdded': # new roi to create
427
- par: Parameter = data[0]
428
- newindex = int(par.name()[-2:])
429
- roi_type = ''
430
- if par.child('type').value() == '1D':
431
- roi_type = ''
432
-
433
- pos = self.viewer_widget.plotItem.vb.viewRange()[0]
434
- pos = pos[0] + np.diff(pos)*np.array([2,4])/6
435
- newroi = LinearROI(index=newindex, pos=pos)
436
-
437
- newroi.setZValue(-10)
438
- newroi.setBrush(par.child('Color').value())
439
- newroi.setOpacity(0.2)
440
-
441
- elif par.child('type').value() == '2D':
442
- roi_type = par.child('roi_type').value()
443
- xrange = self.viewer_widget.plotItem.vb.viewRange()[0]
444
- yrange = self.viewer_widget.plotItem.vb.viewRange()[1]
445
- width = np.max(((xrange[1] - xrange[0]) / 10, 2))
446
- height = np.max(((yrange[1] - yrange[0]) / 10, 2))
447
- pos = [int(np.mean(xrange) - width / 2), int(np.mean(yrange) - width / 2)]
448
-
449
- if roi_type == 'RectROI':
450
- newroi = RectROI(index=newindex, pos=pos,
451
- size=[width, height], name=par.name())
452
- else:
453
- newroi = EllipseROI(index=newindex, pos=pos,
454
- size=[width, height], name=par.name())
455
- newroi.setPen(par['Color'])
456
-
457
- newroi.sigRegionChangeFinished.connect(lambda: self.roi_changed.emit())
458
- newroi.index_signal[int].connect(self.update_roi_tree)
459
- try:
460
- self.settings.sigTreeStateChanged.disconnect()
461
- except Exception:
462
- pass
463
- self.settings.sigTreeStateChanged.connect(self.roi_tree_changed)
464
- self.viewer_widget.plotItem.addItem(newroi)
465
-
466
- self._set_roi_from_index(newindex, newroi)
467
-
468
- self.new_ROI_signal.emit(newindex, roi_type, par.name())
469
- self.update_roi_tree(newindex)
470
- self.emit_colors()
471
- self.roi_changed.emit()
472
-
473
- elif change == 'value':
474
- if param.name() in putils.iter_children(self.settings.child('ROIs'), []):
475
- parent_name = putils.get_param_path(param)[putils.get_param_path(param).index('ROIs')+1]
476
- self.update_roi(parent_name, param)
477
- self.roi_value_changed.emit(parent_name, (param, param.value()))
478
- if param.name() == 'Color':
479
- self.emit_colors()
480
-
481
- elif change == 'parent':
482
- if 'ROI' in param.name():
483
- roi = self._ROIs.pop(param.name())
484
- self.viewer_widget.plotItem.removeItem(roi)
485
- self.remove_ROI_signal.emit(param.name())
486
- self.emit_colors()
487
-
488
- def update_use_channel(self, channels: List[str]):
489
- channels.append('All')
490
- for ind in range(len(self)):
491
- val = self.settings['ROIs', self.roi_format(ind), 'use_channel']
492
- self.settings.child('ROIs', self.roi_format(ind), 'use_channel').setLimits(channels)
493
- if val not in channels:
494
- self.settings.child('ROIs', self.roi_format(ind), 'use_channel').setValue(channels[0])
495
-
496
- def update_roi(self, roi_key, param):
497
- self._ROIs[roi_key].index_signal[int].disconnect()
498
- if param.name() == 'Color':
499
- self._ROIs[roi_key].setPen(param.value())
500
- self.emit_colors()
501
- elif param.name() == 'left' or param.name() == 'x':
502
- pos = self._ROIs[roi_key].pos()
503
- poss = [param.value(), pos[1]]
504
- if self.settings.child('ROIs', roi_key, 'type').value() == '1D':
505
- poss.sort()
506
- self._ROIs[roi_key].setPos(poss)
507
-
508
- elif param.name() == 'right' or param.name() == 'y':
509
- pos = self._ROIs[roi_key].pos()
510
- poss = [pos[0], param.value()]
511
- if self.settings.child('ROIs', roi_key, 'type').value() == '1D':
512
- poss.sort()
513
- self._ROIs[roi_key].setPos(poss)
514
-
515
- elif param.name() == 'angle':
516
- self._ROIs[roi_key].setAngle(param.value(),center=[0.5,0.5])
517
- elif param.name() == 'width':
518
- size = self._ROIs[roi_key].size()
519
- self._ROIs[roi_key].setSize((param.value(), size[1]))
520
- elif param.name() == 'height':
521
- size = self._ROIs[roi_key].size()
522
- self._ROIs[roi_key].setSize((size[0], param.value()))
523
- self._ROIs[roi_key].index_signal[int].connect(self.update_roi_tree)
524
-
525
- @Slot(int)
526
- def update_roi_tree(self, index):
527
- roi = self.get_roi_from_index(index)
528
- par = self.settings.child(*('ROIs', self.roi_format(index)))
529
- if isinstance(roi, LinearROI):
530
- pos = roi.getRegion()
531
- else:
532
- pos = roi.pos()
533
- size = roi.size()
534
- angle = roi.angle()
535
-
536
- try:
537
- self.settings.sigTreeStateChanged.disconnect()
538
- except Exception:
539
- pass
540
- if isinstance(roi, LinearROI):
541
- par.child(*('position', 'left')).setValue(pos[0])
542
- par.child(*('position', 'right')).setValue(pos[1])
543
- if not isinstance(roi, LinearROI):
544
- par.child(*('position', 'x')).setValue(pos[0])
545
- par.child(*('position', 'y')).setValue(pos[1])
546
- par.child(*('size', 'width')).setValue(size[0])
547
- par.child(*('size', 'height')).setValue(size[1])
548
- par.child('angle').setValue(angle)
549
-
550
- self.settings.sigTreeStateChanged.connect(self.roi_tree_changed)
551
-
552
- def save_ROI(self):
553
-
554
- try:
555
- data = ioxml.parameter_to_xml_string(self.settings.child(('ROIs')))
556
- path = select_file(start_path=Path.home(), ext='xml', save=True, force_save_extension=True)
557
-
558
- if path != '':
559
- with open(path, 'wb') as f:
560
- f.write(data)
561
- except Exception as e:
562
- print(e)
563
-
564
- def clear_ROI(self):
565
- indexes = [roi.index for roi in self._ROIs.values()]
566
- for index in indexes:
567
- self.settings.child(*('ROIs', self.roi_format(index))).remove()
568
- # self.settings.sigTreeStateChanged.connect(self.roi_tree_changed)
569
-
570
- def load_ROI(self, path=None, params=None):
571
- try:
572
- if params is None:
573
- if path is None:
574
- path = select_file(start_path=Path.home(), save=False, ext='xml', filter='XML files (*.xml)')
575
- if path != '':
576
- params = Parameter.create(title='Settings', name='settings', type='group',
577
- children=ioxml.XML_file_to_parameter(path))
578
-
579
- if params is not None:
580
- self.clear_ROI()
581
- QtWidgets.QApplication.processEvents()
582
-
583
- for param in params:
584
- if 'roi_type' in putils.iter_children(param, []):
585
- self.settings.child('ROIs').addNew(param.child('roi_type').value())
586
- else:
587
- self.settings.child('ROIs').addNew()
588
- QtWidgets.QApplication.processEvents()
589
- self.set_roi(self.settings.child('ROIs').children(), params)
590
- except Exception as e:
591
- logger.exception(str(e))
592
-
593
- def set_roi(self, roi_params, roi_params_new):
594
- for child, new_child in zip(roi_params, roi_params_new):
595
- if 'group' not in child.opts['type']:
596
- child.setValue(new_child.value())
597
- else:
598
- self.set_roi(child.children(), new_child.children())
599
-
600
-
601
-
602
- if __name__ == '__main__':
603
- app = QtWidgets.QApplication(sys.argv)
604
- from pymodaq.utils.plotting.widgets import ImageWidget
605
- from pyqtgraph import PlotWidget
606
-
607
- im = ImageWidget()
608
- im = PlotWidget()
609
- prog = ROIManager(im, '2D')
610
- widget = QtWidgets.QWidget()
611
- layout = QtWidgets.QHBoxLayout()
612
- widget.setLayout(layout)
613
- layout.addWidget(im)
614
- layout.addWidget(prog.roiwidget)
615
- widget.show()
616
- prog.add_roi_programmatically(ROI2D_TYPES[0])
617
- prog.add_roi_programmatically(ROI2D_TYPES[1])
618
- sys.exit(app.exec_())
619
-
620
-
621
- class ROISaver:
622
- def __init__(self, msgbox=False, det_modules=[]):
623
-
624
- self.roi_presets = None
625
- self.detector_modules = det_modules
626
-
627
- if msgbox:
628
- msgBox = QtWidgets.QMessageBox()
629
- msgBox.setText("ROI Manager?")
630
- msgBox.setInformativeText("What do you want to do?")
631
- cancel_button = msgBox.addButton(QtWidgets.QMessageBox.Cancel)
632
- modify_button = msgBox.addButton('Modify', QtWidgets.QMessageBox.AcceptRole)
633
- msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
634
- ret = msgBox.exec()
635
-
636
- if msgBox.clickedButton() == modify_button:
637
- path = select_file(start_path=roi_path, save=False, ext='xml')
638
- if path != '':
639
- self.set_file_roi(str(path))
640
- else: # cancel
641
- pass
642
-
643
- def set_file_roi(self, filename, show=True):
644
- """
645
-
646
- """
647
-
648
- children = ioxml.XML_file_to_parameter(filename)
649
- self.roi_presets = Parameter.create(title='roi', name='rois', type='group', children=children)
650
-
651
- det_children = [child for child in self.roi_presets.children() if 'det' in child.opts['name']]
652
- det_names = [child.child('detname').value() for child in self.roi_presets.children() if
653
- 'det' in child.opts['name']]
654
- det_module_names = [det.title for det in self.detector_modules]
655
- for ind_det, det_roi in enumerate(det_children):
656
- det_module: DAQ_Viewer = self.detector_modules[det_module_names.index(det_names[ind_det])]
657
- viewer_children = [child for child in det_roi.children() if 'viewer' in child.opts['name']]
658
- for ind_viewer, viewer in enumerate(det_module.viewers):
659
- rois_params = [child for child in viewer_children[ind_viewer].children() if 'ROI' in child.opts['name']]
660
- if len(rois_params) > 0:
661
- if hasattr(viewer, 'roi_manager'):
662
- if hasattr(viewer, 'activate_roi'): # because for viewer 0D it is irrelevant
663
- viewer.activate_roi()
664
- viewer.roi_manager.load_ROI(params=rois_params)
665
- QtWidgets.QApplication.processEvents()
666
-
667
- if show:
668
- self.show_rois()
669
-
670
- def set_new_roi(self, file=None):
671
- if file is None:
672
- file = 'roi_default'
673
-
674
- self.roi_presets = Parameter.create(name='roi_settings', type='group', children=[
675
- {'title': 'Filename:', 'name': 'filename', 'type': 'str', 'value': file}, ])
676
-
677
- for ind_det, det in enumerate(self.detector_modules):
678
- det_param = Parameter.create(name=f'det_{ind_det:03d}', type='group', children=[
679
- {'title': 'Det Name:', 'name': 'detname', 'type': 'str', 'value': det.title}, ])
680
-
681
- for ind_viewer, viewer in enumerate(det.ui.viewers):
682
- viewer_param = Parameter.create(name=f'viewer_{ind_viewer:03d}', type='group', children=[
683
- {'title': 'Viewer:', 'name': 'viewername', 'type': 'str',
684
- 'value': det.ui.viewer_docks[ind_viewer].name()}, ])
685
-
686
- if hasattr(viewer, 'roi_manager'):
687
- viewer_param.addChild({'title': 'ROI type:', 'name': 'roi_type', 'type': 'str',
688
- 'value': viewer.roi_manager.settings.child('ROIs').roi_type})
689
- viewer_param.addChildren(viewer.roi_manager.settings.child('ROIs').children())
690
- det_param.addChild(viewer_param)
691
- self.roi_presets.addChild(det_param)
692
-
693
- ioxml.parameter_to_xml_file(self.roi_presets, os.path.join(roi_path, file))
694
- self.show_rois()
695
-
696
- def show_rois(self):
697
- """
698
-
699
- """
700
- dialog = QtWidgets.QDialog()
701
- vlayout = QtWidgets.QVBoxLayout()
702
- tree = ParameterTree()
703
- tree.setMinimumWidth(400)
704
- tree.setMinimumHeight(500)
705
- tree.setParameters(self.roi_presets, showTop=False)
706
-
707
- vlayout.addWidget(tree)
708
- dialog.setLayout(vlayout)
709
- buttonBox = QtWidgets.QDialogButtonBox(parent=dialog)
710
-
711
- buttonBox.addButton('Save', buttonBox.AcceptRole)
712
- buttonBox.accepted.connect(dialog.accept)
713
- buttonBox.addButton('Cancel', buttonBox.RejectRole)
714
- buttonBox.rejected.connect(dialog.reject)
715
-
716
- vlayout.addWidget(buttonBox)
717
- dialog.setWindowTitle('Fill in information about this manager')
718
- res = dialog.exec()
719
-
720
- if res == dialog.Accepted:
721
- # save managers parameters in a xml file
722
- # start = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
723
- # start = os.path.join("..",'daq_scan')
724
- ioxml.parameter_to_xml_file(
725
- self.roi_presets, os.path.join(roi_path, self.roi_presets.child('filename').value()))
726
-