scitex 2.7.3__py3-none-any.whl → 2.10.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.
- scitex/__init__.py +15 -7
- scitex/__version__.py +1 -2
- scitex/_install_guide.py +250 -0
- scitex/_optional_deps.py +206 -39
- scitex/ai/_gen_ai/_Groq.py +2 -4
- scitex/ai/_gen_ai/_OpenAI.py +5 -2
- scitex/ai/_gen_ai/_Perplexity.py +20 -6
- scitex/audio/__init__.py +24 -15
- scitex/audio/_cross_process_lock.py +139 -0
- scitex/audio/_mcp_handlers.py +256 -0
- scitex/audio/_mcp_tool_schemas.py +203 -0
- scitex/audio/engines/elevenlabs_engine.py +5 -2
- scitex/audio/mcp_server.py +98 -457
- scitex/bridge/__init__.py +30 -19
- scitex/bridge/_figrecipe.py +245 -0
- scitex/bridge/_helpers.py +2 -1
- scitex/bridge/_plt_vis.py +23 -10
- scitex/bridge/_stats_plt.py +18 -5
- scitex/bridge/_stats_vis.py +16 -2
- scitex/browser/__init__.py +84 -44
- scitex/browser/automation/__init__.py +5 -1
- scitex/browser/core/BrowserMixin.py +17 -4
- scitex/browser/core/__init__.py +11 -2
- scitex/browser/remote/CaptchaHandler.py +1 -1
- scitex/browser/remote/ZenRowsAPIClient.py +1 -1
- scitex/capture/grid.py +487 -0
- scitex/capture/mcp_handlers.py +401 -0
- scitex/capture/mcp_tool_defs.py +192 -0
- scitex/capture/mcp_tools.py +241 -0
- scitex/capture/mcp_utils.py +30 -0
- scitex/cli/convert.py +421 -0
- scitex/cli/main.py +6 -4
- scitex/datetime/__init__.py +46 -0
- scitex/datetime/_linspace.py +100 -0
- scitex/datetime/_normalize_timestamp.py +306 -0
- scitex/db/_delete_duplicates.py +4 -4
- scitex/db/_sqlite3/_delete_duplicates.py +11 -2
- scitex/dev/plt/__init__.py +61 -62
- scitex/dev/plt/demo_plotters/__init__.py +0 -0
- scitex/dev/plt/demo_plotters/plot_mpl_axhline.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_axhspan.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_axvline.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_axvspan.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_bar.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_barh.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_boxplot.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_contour.py +31 -0
- scitex/dev/plt/demo_plotters/plot_mpl_contourf.py +31 -0
- scitex/dev/plt/demo_plotters/plot_mpl_errorbar.py +30 -0
- scitex/dev/plt/demo_plotters/plot_mpl_eventplot.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_fill.py +30 -0
- scitex/dev/plt/demo_plotters/plot_mpl_fill_between.py +31 -0
- scitex/dev/plt/demo_plotters/plot_mpl_hexbin.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_hist.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_hist2d.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_imshow.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_pcolormesh.py +31 -0
- scitex/dev/plt/demo_plotters/plot_mpl_pie.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_plot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_quiver.py +31 -0
- scitex/dev/plt/demo_plotters/plot_mpl_scatter.py +28 -0
- scitex/dev/plt/demo_plotters/plot_mpl_stackplot.py +31 -0
- scitex/dev/plt/demo_plotters/plot_mpl_stem.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_step.py +29 -0
- scitex/dev/plt/demo_plotters/plot_mpl_violinplot.py +28 -0
- scitex/dev/plt/demo_plotters/plot_sns_barplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_boxplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_heatmap.py +28 -0
- scitex/dev/plt/demo_plotters/plot_sns_histplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_kdeplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_lineplot.py +31 -0
- scitex/dev/plt/demo_plotters/plot_sns_scatterplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_stripplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_swarmplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_sns_violinplot.py +29 -0
- scitex/dev/plt/demo_plotters/plot_stx_bar.py +29 -0
- scitex/dev/plt/demo_plotters/plot_stx_barh.py +29 -0
- scitex/dev/plt/demo_plotters/plot_stx_box.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_boxplot.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_conf_mat.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_contour.py +31 -0
- scitex/dev/plt/demo_plotters/plot_stx_ecdf.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_errorbar.py +30 -0
- scitex/dev/plt/demo_plotters/plot_stx_fill_between.py +31 -0
- scitex/dev/plt/demo_plotters/plot_stx_fillv.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_heatmap.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_image.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_imshow.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_joyplot.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_kde.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_line.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_mean_ci.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_mean_std.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_median_iqr.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_raster.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_rectangle.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_scatter.py +29 -0
- scitex/dev/plt/demo_plotters/plot_stx_shaded_line.py +29 -0
- scitex/dev/plt/demo_plotters/plot_stx_violin.py +28 -0
- scitex/dev/plt/demo_plotters/plot_stx_violinplot.py +28 -0
- scitex/dev/plt/mpl/get_dir_ax.py +46 -0
- scitex/dev/plt/mpl/get_signatures.py +176 -0
- scitex/dev/plt/mpl/get_signatures_details.py +522 -0
- scitex/dev/plt/plot_mpl_axhline.py +0 -0
- scitex/dev/plt/plot_mpl_axhspan.py +0 -0
- scitex/dev/plt/plot_mpl_axvline.py +0 -0
- scitex/dev/plt/plot_mpl_axvspan.py +0 -0
- scitex/dev/plt/plot_mpl_bar.py +0 -0
- scitex/dev/plt/plot_mpl_barh.py +0 -0
- scitex/dev/plt/plot_mpl_boxplot.py +0 -0
- scitex/dev/plt/plot_mpl_contour.py +0 -0
- scitex/dev/plt/plot_mpl_contourf.py +0 -0
- scitex/dev/plt/plot_mpl_errorbar.py +0 -0
- scitex/dev/plt/plot_mpl_eventplot.py +0 -0
- scitex/dev/plt/plot_mpl_fill.py +0 -0
- scitex/dev/plt/plot_mpl_fill_between.py +0 -0
- scitex/dev/plt/plot_mpl_hexbin.py +0 -0
- scitex/dev/plt/plot_mpl_hist.py +0 -0
- scitex/dev/plt/plot_mpl_hist2d.py +0 -0
- scitex/dev/plt/plot_mpl_imshow.py +0 -0
- scitex/dev/plt/plot_mpl_pcolormesh.py +0 -0
- scitex/dev/plt/plot_mpl_pie.py +0 -0
- scitex/dev/plt/plot_mpl_plot.py +0 -0
- scitex/dev/plt/plot_mpl_quiver.py +0 -0
- scitex/dev/plt/plot_mpl_scatter.py +0 -0
- scitex/dev/plt/plot_mpl_stackplot.py +0 -0
- scitex/dev/plt/plot_mpl_stem.py +0 -0
- scitex/dev/plt/plot_mpl_step.py +0 -0
- scitex/dev/plt/plot_mpl_violinplot.py +0 -0
- scitex/dev/plt/plot_sns_barplot.py +0 -0
- scitex/dev/plt/plot_sns_boxplot.py +0 -0
- scitex/dev/plt/plot_sns_heatmap.py +0 -0
- scitex/dev/plt/plot_sns_histplot.py +0 -0
- scitex/dev/plt/plot_sns_kdeplot.py +0 -0
- scitex/dev/plt/plot_sns_lineplot.py +0 -0
- scitex/dev/plt/plot_sns_scatterplot.py +0 -0
- scitex/dev/plt/plot_sns_stripplot.py +0 -0
- scitex/dev/plt/plot_sns_swarmplot.py +0 -0
- scitex/dev/plt/plot_sns_violinplot.py +0 -0
- scitex/dev/plt/plot_stx_bar.py +0 -0
- scitex/dev/plt/plot_stx_barh.py +0 -0
- scitex/dev/plt/plot_stx_box.py +0 -0
- scitex/dev/plt/plot_stx_boxplot.py +0 -0
- scitex/dev/plt/plot_stx_conf_mat.py +0 -0
- scitex/dev/plt/plot_stx_contour.py +0 -0
- scitex/dev/plt/plot_stx_ecdf.py +0 -0
- scitex/dev/plt/plot_stx_errorbar.py +0 -0
- scitex/dev/plt/plot_stx_fill_between.py +0 -0
- scitex/dev/plt/plot_stx_fillv.py +0 -0
- scitex/dev/plt/plot_stx_heatmap.py +0 -0
- scitex/dev/plt/plot_stx_image.py +0 -0
- scitex/dev/plt/plot_stx_imshow.py +0 -0
- scitex/dev/plt/plot_stx_joyplot.py +0 -0
- scitex/dev/plt/plot_stx_kde.py +0 -0
- scitex/dev/plt/plot_stx_line.py +0 -0
- scitex/dev/plt/plot_stx_mean_ci.py +0 -0
- scitex/dev/plt/plot_stx_mean_std.py +0 -0
- scitex/dev/plt/plot_stx_median_iqr.py +0 -0
- scitex/dev/plt/plot_stx_raster.py +0 -0
- scitex/dev/plt/plot_stx_rectangle.py +0 -0
- scitex/dev/plt/plot_stx_scatter.py +0 -0
- scitex/dev/plt/plot_stx_shaded_line.py +0 -0
- scitex/dev/plt/plot_stx_violin.py +0 -0
- scitex/dev/plt/plot_stx_violinplot.py +0 -0
- scitex/diagram/README.md +197 -0
- scitex/diagram/__init__.py +48 -0
- scitex/diagram/_compile.py +312 -0
- scitex/diagram/_diagram.py +355 -0
- scitex/diagram/_presets.py +173 -0
- scitex/diagram/_schema.py +182 -0
- scitex/diagram/_split.py +278 -0
- scitex/dict/_pop_keys.py +1 -7
- scitex/dsp/__init__.py +15 -10
- scitex/dsp/add_noise.py +5 -2
- scitex/dsp/example.py +35 -22
- scitex/dsp/filt.py +8 -3
- scitex/dsp/reference.py +3 -2
- scitex/dsp/utils/__init__.py +2 -1
- scitex/dsp/utils/_differential_bandpass_filters.py +14 -4
- scitex/dt/__init__.py +39 -2
- scitex/errors.py +82 -521
- scitex/fig/__init__.py +4 -4
- scitex/fig/editor/__init__.py +5 -2
- scitex/fig/editor/_dearpygui_editor.py +1 -1
- scitex/fig/editor/_mpl_editor.py +1 -1
- scitex/fig/editor/_qt_editor.py +1 -1
- scitex/fig/editor/_tkinter_editor.py +1 -1
- scitex/fig/editor/edit/__init__.py +50 -0
- scitex/fig/editor/edit/backend_detector.py +109 -0
- scitex/fig/editor/edit/bundle_resolver.py +240 -0
- scitex/fig/editor/edit/editor_launcher.py +239 -0
- scitex/fig/editor/edit/manual_handler.py +53 -0
- scitex/fig/editor/edit/panel_loader.py +232 -0
- scitex/fig/editor/edit/path_resolver.py +67 -0
- scitex/fig/editor/flask_editor/_bbox.py +23 -0
- scitex/fig/editor/flask_editor/_core.py +908 -103
- scitex/fig/editor/flask_editor/_renderer.py +74 -0
- scitex/fig/editor/flask_editor/static/css/base/reset.css +41 -0
- scitex/fig/editor/flask_editor/static/css/base/typography.css +16 -0
- scitex/fig/editor/flask_editor/static/css/base/variables.css +85 -0
- scitex/fig/editor/flask_editor/static/css/components/buttons.css +217 -0
- scitex/fig/editor/flask_editor/static/css/components/context-menu.css +93 -0
- scitex/fig/editor/flask_editor/static/css/components/dropdown.css +57 -0
- scitex/fig/editor/flask_editor/static/css/components/forms.css +112 -0
- scitex/fig/editor/flask_editor/static/css/components/modal.css +59 -0
- scitex/fig/editor/flask_editor/static/css/components/sections.css +212 -0
- scitex/fig/editor/flask_editor/static/css/features/canvas.css +176 -0
- scitex/fig/editor/flask_editor/static/css/features/element-inspector.css +190 -0
- scitex/fig/editor/flask_editor/static/css/features/loading.css +59 -0
- scitex/fig/editor/flask_editor/static/css/features/overlay.css +45 -0
- scitex/fig/editor/flask_editor/static/css/features/panel-grid.css +95 -0
- scitex/fig/editor/flask_editor/static/css/features/selection.css +101 -0
- scitex/fig/editor/flask_editor/static/css/features/statistics.css +138 -0
- scitex/fig/editor/flask_editor/static/css/index.css +31 -0
- scitex/fig/editor/flask_editor/static/css/layout/container.css +7 -0
- scitex/fig/editor/flask_editor/static/css/layout/controls.css +56 -0
- scitex/fig/editor/flask_editor/static/css/layout/preview.css +78 -0
- scitex/fig/editor/flask_editor/static/js/alignment/axis.js +314 -0
- scitex/fig/editor/flask_editor/static/js/alignment/basic.js +107 -0
- scitex/fig/editor/flask_editor/static/js/alignment/distribute.js +54 -0
- scitex/fig/editor/flask_editor/static/js/canvas/canvas.js +172 -0
- scitex/fig/editor/flask_editor/static/js/canvas/dragging.js +258 -0
- scitex/fig/editor/flask_editor/static/js/canvas/resize.js +48 -0
- scitex/fig/editor/flask_editor/static/js/canvas/selection.js +71 -0
- scitex/fig/editor/flask_editor/static/js/core/api.js +288 -0
- scitex/fig/editor/flask_editor/static/js/core/state.js +143 -0
- scitex/fig/editor/flask_editor/static/js/core/utils.js +245 -0
- scitex/fig/editor/flask_editor/static/js/dev/element-inspector.js +992 -0
- scitex/fig/editor/flask_editor/static/js/editor/bbox.js +339 -0
- scitex/fig/editor/flask_editor/static/js/editor/element-drag.js +286 -0
- scitex/fig/editor/flask_editor/static/js/editor/overlay.js +371 -0
- scitex/fig/editor/flask_editor/static/js/editor/preview.js +293 -0
- scitex/fig/editor/flask_editor/static/js/main.js +426 -0
- scitex/fig/editor/flask_editor/static/js/shortcuts/context-menu.js +152 -0
- scitex/fig/editor/flask_editor/static/js/shortcuts/keyboard.js +265 -0
- scitex/fig/editor/flask_editor/static/js/ui/controls.js +184 -0
- scitex/fig/editor/flask_editor/static/js/ui/download.js +57 -0
- scitex/fig/editor/flask_editor/static/js/ui/help.js +100 -0
- scitex/fig/editor/flask_editor/static/js/ui/theme.js +34 -0
- scitex/fig/editor/flask_editor/templates/__init__.py +95 -5
- scitex/fig/editor/flask_editor/templates/_html.py +27 -9
- scitex/fig/editor/flask_editor/templates/_scripts.py +1928 -131
- scitex/fig/editor/flask_editor/templates/_styles.py +363 -51
- scitex/fig/io/_bundle.py +104 -19
- scitex/fts/README.md +262 -0
- scitex/fts/TODO.md +66 -0
- scitex/fts/__init__.py +90 -0
- scitex/fts/_bundle/README_IN_BUNDLE.md +102 -0
- scitex/fts/_bundle/_FTS.py +657 -0
- scitex/fts/_bundle/__init__.py +38 -0
- scitex/fts/_bundle/_children.py +216 -0
- scitex/fts/_bundle/_conversion/__init__.py +15 -0
- scitex/fts/_bundle/_conversion/_bundle2dict.py +44 -0
- scitex/fts/_bundle/_conversion/_dict2bundle.py +50 -0
- scitex/fts/_bundle/_dataclasses/_Axes.py +57 -0
- scitex/fts/_bundle/_dataclasses/_BBox.py +54 -0
- scitex/fts/_bundle/_dataclasses/_ColumnDef.py +72 -0
- scitex/fts/_bundle/_dataclasses/_DataFormat.py +40 -0
- scitex/fts/_bundle/_dataclasses/_DataInfo.py +135 -0
- scitex/fts/_bundle/_dataclasses/_DataSource.py +44 -0
- scitex/fts/_bundle/_dataclasses/_Node.py +319 -0
- scitex/fts/_bundle/_dataclasses/_NodeRefs.py +45 -0
- scitex/fts/_bundle/_dataclasses/_SizeMM.py +38 -0
- scitex/fts/_bundle/_dataclasses/__init__.py +35 -0
- scitex/fts/_bundle/_extractors/__init__.py +32 -0
- scitex/fts/_bundle/_extractors/_extract_bar.py +131 -0
- scitex/fts/_bundle/_extractors/_extract_line.py +71 -0
- scitex/fts/_bundle/_extractors/_extract_scatter.py +79 -0
- scitex/fts/_bundle/_loader.py +134 -0
- scitex/fts/_bundle/_mpl_helpers.py +389 -0
- scitex/fts/_bundle/_saver.py +269 -0
- scitex/fts/_bundle/_storage.py +200 -0
- scitex/fts/_bundle/_utils/__init__.py +55 -0
- scitex/fts/_bundle/_utils/_const.py +26 -0
- scitex/fts/_bundle/_utils/_errors.py +73 -0
- scitex/fts/_bundle/_utils/_generate.py +21 -0
- scitex/fts/_bundle/_utils/_types.py +76 -0
- scitex/fts/_bundle/_validation.py +434 -0
- scitex/fts/_bundle/_zipbundle.py +165 -0
- scitex/fts/_fig/__init__.py +22 -0
- scitex/fts/_fig/_backend/__init__.py +53 -0
- scitex/fts/_fig/_backend/_export.py +165 -0
- scitex/fts/_fig/_backend/_parser.py +188 -0
- scitex/fts/_fig/_backend/_render.py +538 -0
- scitex/fts/_fig/_composite.py +345 -0
- scitex/fts/_fig/_dataclasses/_ChannelEncoding.py +46 -0
- scitex/fts/_fig/_dataclasses/_Encoding.py +82 -0
- scitex/fts/_fig/_dataclasses/_Theme.py +441 -0
- scitex/fts/_fig/_dataclasses/_TraceEncoding.py +52 -0
- scitex/fts/_fig/_dataclasses/__init__.py +47 -0
- scitex/fts/_fig/_editor/__init__.py +14 -0
- scitex/fts/_fig/_editor/_cui/__init__.py +33 -0
- scitex/fts/_fig/_editor/_cui/_backend_detector.py +39 -0
- scitex/fts/_fig/_editor/_cui/_bundle_resolver.py +366 -0
- scitex/fts/_fig/_editor/_cui/_editor_launcher.py +175 -0
- scitex/fts/_fig/_editor/_cui/_manual_handler.py +52 -0
- scitex/fts/_fig/_editor/_cui/_panel_loader.py +246 -0
- scitex/fts/_fig/_editor/_cui/_path_resolver.py +66 -0
- scitex/fts/_fig/_editor/_defaults.py +300 -0
- scitex/fts/_fig/_editor/_gui/__init__.py +11 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/__init__.py +20 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/_bbox.py +1339 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/_core.py +1688 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/_plotter.py +664 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/_renderer.py +853 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/_utils.py +79 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/base/reset.css +41 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/base/typography.css +16 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/base/variables.css +85 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/components/buttons.css +217 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/components/context-menu.css +93 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/components/dropdown.css +57 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/components/forms.css +112 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/components/modal.css +59 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/components/sections.css +212 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/canvas.css +176 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/element-inspector.css +190 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/loading.css +59 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/overlay.css +45 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/panel-grid.css +95 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/selection.css +101 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/features/statistics.css +138 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/index.css +31 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/layout/container.css +7 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/layout/controls.css +56 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/css/layout/preview.css +78 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/alignment/axis.js +314 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/alignment/basic.js +107 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/alignment/distribute.js +54 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/canvas/canvas.js +172 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/canvas/dragging.js +258 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/canvas/resize.js +48 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/canvas/selection.js +71 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/core/api.js +288 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/core/state.js +143 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/core/utils.js +245 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/dev/element-inspector.js +992 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/editor/bbox.js +339 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/editor/element-drag.js +286 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/editor/overlay.js +371 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/editor/preview.js +293 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/main.js +426 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/shortcuts/context-menu.js +152 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/shortcuts/keyboard.js +265 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/ui/controls.js +184 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/ui/download.js +57 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/ui/help.js +100 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/static/js/ui/theme.js +34 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/templates/__init__.py +124 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/templates/_html.py +851 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/templates/_scripts.py +4932 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor/templates/_styles.py +1657 -0
- scitex/fts/_fig/_editor/_gui/_flask_editor.py +36 -0
- scitex/fts/_fig/_models/_Annotations.py +115 -0
- scitex/fts/_fig/_models/_Axes.py +152 -0
- scitex/fts/_fig/_models/_Figure.py +138 -0
- scitex/fts/_fig/_models/_Guides.py +104 -0
- scitex/fts/_fig/_models/_Plot.py +123 -0
- scitex/fts/_fig/_models/_Styles.py +245 -0
- scitex/fts/_fig/_models/__init__.py +80 -0
- scitex/fts/_fig/_models/_plot_types/__init__.py +156 -0
- scitex/fts/_fig/_models/_plot_types/_bar.py +43 -0
- scitex/fts/_fig/_models/_plot_types/_box.py +38 -0
- scitex/fts/_fig/_models/_plot_types/_distribution.py +36 -0
- scitex/fts/_fig/_models/_plot_types/_errorbar.py +60 -0
- scitex/fts/_fig/_models/_plot_types/_histogram.py +30 -0
- scitex/fts/_fig/_models/_plot_types/_image.py +61 -0
- scitex/fts/_fig/_models/_plot_types/_line.py +57 -0
- scitex/fts/_fig/_models/_plot_types/_scatter.py +30 -0
- scitex/fts/_fig/_models/_plot_types/_seaborn.py +121 -0
- scitex/fts/_fig/_models/_plot_types/_violin.py +36 -0
- scitex/fts/_fig/_utils/__init__.py +129 -0
- scitex/fts/_fig/_utils/_auto_layout.py +127 -0
- scitex/fts/_fig/_utils/_calc_bounds.py +111 -0
- scitex/fts/_fig/_utils/_const_sizes.py +48 -0
- scitex/fts/_fig/_utils/_convert_coords.py +77 -0
- scitex/fts/_fig/_utils/_get_template.py +178 -0
- scitex/fts/_fig/_utils/_normalize.py +73 -0
- scitex/fts/_fig/_utils/_plot_layout.py +397 -0
- scitex/fts/_fig/_utils/_validate.py +197 -0
- scitex/fts/_kinds/__init__.py +45 -0
- scitex/fts/_kinds/_figure/__init__.py +19 -0
- scitex/fts/_kinds/_figure/_composite.py +345 -0
- scitex/fts/_kinds/_plot/__init__.py +25 -0
- scitex/fts/_kinds/_plot/_backend/__init__.py +53 -0
- scitex/fts/_kinds/_plot/_backend/_export.py +165 -0
- scitex/fts/_kinds/_plot/_backend/_parser.py +188 -0
- scitex/fts/_kinds/_plot/_backend/_render.py +538 -0
- scitex/fts/_kinds/_plot/_dataclasses/_ChannelEncoding.py +46 -0
- scitex/fts/_kinds/_plot/_dataclasses/_Encoding.py +82 -0
- scitex/fts/_kinds/_plot/_dataclasses/_Theme.py +441 -0
- scitex/fts/_kinds/_plot/_dataclasses/_TraceEncoding.py +52 -0
- scitex/fts/_kinds/_plot/_dataclasses/__init__.py +47 -0
- scitex/fts/_kinds/_plot/_models/_Annotations.py +115 -0
- scitex/fts/_kinds/_plot/_models/_Axes.py +152 -0
- scitex/fts/_kinds/_plot/_models/_Figure.py +138 -0
- scitex/fts/_kinds/_plot/_models/_Guides.py +104 -0
- scitex/fts/_kinds/_plot/_models/_Plot.py +123 -0
- scitex/fts/_kinds/_plot/_models/_Styles.py +245 -0
- scitex/fts/_kinds/_plot/_models/__init__.py +80 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/__init__.py +156 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_bar.py +43 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_box.py +38 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_distribution.py +36 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_errorbar.py +60 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_histogram.py +30 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_image.py +61 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_line.py +57 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_scatter.py +30 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_seaborn.py +121 -0
- scitex/fts/_kinds/_plot/_models/_plot_types/_violin.py +36 -0
- scitex/fts/_kinds/_plot/_utils/__init__.py +129 -0
- scitex/fts/_kinds/_plot/_utils/_auto_layout.py +127 -0
- scitex/fts/_kinds/_plot/_utils/_calc_bounds.py +111 -0
- scitex/fts/_kinds/_plot/_utils/_const_sizes.py +48 -0
- scitex/fts/_kinds/_plot/_utils/_convert_coords.py +77 -0
- scitex/fts/_kinds/_plot/_utils/_get_template.py +178 -0
- scitex/fts/_kinds/_plot/_utils/_normalize.py +73 -0
- scitex/fts/_kinds/_plot/_utils/_plot_layout.py +397 -0
- scitex/fts/_kinds/_plot/_utils/_validate.py +197 -0
- scitex/fts/_kinds/_shape/__init__.py +141 -0
- scitex/fts/_kinds/_stats/__init__.py +56 -0
- scitex/fts/_kinds/_stats/_dataclasses/_Stats.py +423 -0
- scitex/fts/_kinds/_stats/_dataclasses/__init__.py +48 -0
- scitex/fts/_kinds/_table/__init__.py +72 -0
- scitex/fts/_kinds/_table/_latex/__init__.py +93 -0
- scitex/fts/_kinds/_table/_latex/_editor/__init__.py +11 -0
- scitex/fts/_kinds/_table/_latex/_editor/_app.py +725 -0
- scitex/fts/_kinds/_table/_latex/_export.py +279 -0
- scitex/fts/_kinds/_table/_latex/_figure_exporter.py +153 -0
- scitex/fts/_kinds/_table/_latex/_stats_formatter.py +274 -0
- scitex/fts/_kinds/_table/_latex/_table_exporter.py +362 -0
- scitex/fts/_kinds/_table/_latex/_utils.py +369 -0
- scitex/fts/_kinds/_table/_latex/_validator.py +445 -0
- scitex/fts/_kinds/_text/__init__.py +77 -0
- scitex/fts/_schemas/data_info.schema.json +75 -0
- scitex/fts/_schemas/encoding.schema.json +90 -0
- scitex/fts/_schemas/node.schema.json +145 -0
- scitex/fts/_schemas/render_manifest.schema.json +62 -0
- scitex/fts/_schemas/stats.schema.json +132 -0
- scitex/fts/_schemas/theme.schema.json +141 -0
- scitex/fts/_stats/__init__.py +48 -0
- scitex/fts/_stats/_dataclasses/_Stats.py +423 -0
- scitex/fts/_stats/_dataclasses/__init__.py +48 -0
- scitex/fts/_tables/__init__.py +65 -0
- scitex/fts/_tables/_latex/__init__.py +93 -0
- scitex/fts/_tables/_latex/_editor/__init__.py +11 -0
- scitex/fts/_tables/_latex/_editor/_app.py +725 -0
- scitex/fts/_tables/_latex/_export.py +279 -0
- scitex/fts/_tables/_latex/_figure_exporter.py +153 -0
- scitex/fts/_tables/_latex/_stats_formatter.py +274 -0
- scitex/fts/_tables/_latex/_table_exporter.py +362 -0
- scitex/fts/_tables/_latex/_utils.py +369 -0
- scitex/fts/_tables/_latex/_validator.py +445 -0
- scitex/gen/__init__.py +66 -25
- scitex/gen/misc.py +28 -0
- scitex/io/__init__.py +47 -20
- scitex/io/_load.py +87 -36
- scitex/io/_load_modules/__init__.py +10 -7
- scitex/io/_load_modules/_pandas.py +6 -1
- scitex/io/_save.py +299 -1556
- scitex/io/_save_modules/__init__.py +76 -19
- scitex/io/_save_modules/_figure_utils.py +90 -0
- scitex/io/_save_modules/_image_csv.py +497 -0
- scitex/io/_save_modules/_legends.py +91 -0
- scitex/io/_save_modules/_pltz_bundle.py +356 -0
- scitex/io/_save_modules/_pltz_stx.py +536 -0
- scitex/io/_save_modules/_stx_bundle.py +104 -0
- scitex/io/_save_modules/_symlink.py +96 -0
- scitex/io/_save_modules/_yaml.py +1 -1
- scitex/io/_save_modules/_zarr.py +64 -18
- scitex/io/bundle/README.md +212 -0
- scitex/io/bundle/__init__.py +110 -0
- scitex/io/{_bundle.py → bundle/_core.py} +219 -89
- scitex/io/bundle/_nested.py +713 -0
- scitex/io/bundle/_types.py +74 -0
- scitex/io/bundle/_zip.py +487 -0
- scitex/io/utils/h5_to_zarr.py +1 -1
- scitex/logging/__init__.py +108 -13
- scitex/logging/_errors.py +508 -0
- scitex/logging/_formatters.py +30 -6
- scitex/logging/_warnings.py +261 -0
- scitex/plt/__init__.py +4 -1
- scitex/plt/_figrecipe.py +236 -0
- scitex/plt/_subplots/_AxisWrapper.py +6 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/__init__.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/_labels.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/_metadata.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_AdjustmentMixin/_visual.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/__init__.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_base.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_scientific.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_statistical.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_MatplotlibPlotMixin/_stx_aliases.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_RawMatplotlibMixin.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/__init__.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/_base.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/_wrappers.py +0 -0
- scitex/plt/_subplots/_AxisWrapperMixins/_UnitAwareMixin.py +112 -1
- scitex/plt/_subplots/_FigWrapper.py +15 -0
- scitex/plt/_subplots/_SubplotsWrapper.py +125 -489
- scitex/plt/_subplots/_export_as_csv.py +11 -0
- scitex/plt/_subplots/_export_as_csv_formatters/__init__.py +2 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_pcolormesh.py +66 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stackplot.py +62 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_bar.py +0 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_barh.py +0 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_errorbar.py +0 -0
- scitex/plt/_subplots/_export_as_csv_formatters/_format_stx_scatter.py +0 -0
- scitex/plt/_subplots/_export_as_csv_formatters/test_formatters.py +208 -0
- scitex/plt/_subplots/_fonts.py +71 -0
- scitex/plt/_subplots/_mm_layout.py +282 -0
- scitex/plt/gallery/__init__.py +99 -2
- scitex/plt/io/_layered_bundle.py +0 -0
- scitex/plt/styles/_plot_postprocess.py +3 -1
- scitex/plt/utils/_configure_mpl.py +16 -19
- scitex/repro/_RandomStateManager.py +13 -8
- scitex/resource/__init__.py +19 -1
- scitex/resource/_utils/_get_env_info.py +13 -25
- scitex/schema/__init__.py +149 -160
- scitex/schema/_encoding.py +273 -0
- scitex/schema/_figure_elements.py +406 -0
- scitex/schema/_plot.py +0 -0
- scitex/schema/_theme.py +360 -0
- scitex/schema/_validation.py +0 -98
- scitex/scholar/__init__.py +56 -14
- scitex/scholar/auth/ScholarAuthManager.py +1 -1
- scitex/scholar/auth/__init__.py +11 -2
- scitex/scholar/auth/providers/BaseAuthenticator.py +1 -1
- scitex/scholar/auth/providers/EZProxyAuthenticator.py +1 -1
- scitex/scholar/auth/providers/OpenAthensAuthenticator.py +1 -1
- scitex/scholar/auth/providers/ShibbolethAuthenticator.py +1 -1
- scitex/scholar/config/ScholarConfig.py +1 -1
- scitex/scholar/core/Scholar.py +1 -1
- scitex/session/_decorator.py +18 -16
- scitex/session/_lifecycle.py +9 -11
- scitex/session/template.py +9 -8
- scitex/sh/test_sh.py +72 -0
- scitex/sh/test_sh_simple.py +61 -0
- scitex/stats/__init__.py +221 -97
- scitex/stats/_schema.py +21 -22
- scitex/stats/descriptive/_circular.py +212 -351
- scitex/stats/descriptive/_describe.py +81 -132
- scitex/stats/descriptive/_nan.py +205 -433
- scitex/stats/descriptive/_real.py +127 -141
- scitex/str/_format_plot_text.py +5 -5
- scitex/str/_latex.py +26 -84
- scitex/str/_latex_fallback.py +53 -47
- scitex/web/_search_pubmed.py +5 -4
- scitex/writer/tests/test_diff_between.py +451 -0
- scitex/writer/tests/test_document_section.py +311 -0
- scitex/writer/tests/test_document_workflow.py +393 -0
- scitex/writer/tests/test_writer.py +361 -0
- scitex/writer/tests/test_writer_integration.py +303 -0
- {scitex-2.7.3.dist-info → scitex-2.10.0.dist-info}/METADATA +364 -181
- {scitex-2.7.3.dist-info → scitex-2.10.0.dist-info}/RECORD +479 -108
- scitex/fig/editor/_edit.py +0 -751
- scitex/scholar/docs/to_claude/guidelines/examples/mgmt/ARCHITECTURE_EXAMPLE.md +0 -905
- scitex/scholar/docs/to_claude/guidelines/examples/mgmt/BULLETIN_BOARD_EXAMPLE.md +0 -99
- scitex/scholar/docs/to_claude/guidelines/examples/mgmt/PROJECT_DESCRIPTION_EXAMPLE.md +0 -96
- {scitex-2.7.3.dist-info → scitex-2.10.0.dist-info}/WHEEL +0 -0
- {scitex-2.7.3.dist-info → scitex-2.10.0.dist-info}/entry_points.txt +0 -0
- {scitex-2.7.3.dist-info → scitex-2.10.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounding Box Detection
|
|
3
|
+
* Element hit detection and proximity calculations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Hit Detection - Main Entry Point
|
|
8
|
+
// ============================================================================
|
|
9
|
+
function findElementAt(x, y) {
|
|
10
|
+
// Multi-panel aware hit detection with specificity hierarchy:
|
|
11
|
+
// 1. Data elements with legacy points - proximity detection (correct saved-image coords)
|
|
12
|
+
// 2. Small elements (labels, ticks, legends, bars, fills)
|
|
13
|
+
// 3. Panel bboxes - lowest priority (fallback)
|
|
14
|
+
|
|
15
|
+
const PROXIMITY_THRESHOLD = 15;
|
|
16
|
+
const SCATTER_THRESHOLD = 20; // Larger threshold for scatter points
|
|
17
|
+
|
|
18
|
+
// First: Check for data elements using legacy points (in saved-image coordinates)
|
|
19
|
+
let closestDataElement = null;
|
|
20
|
+
let minDistance = Infinity;
|
|
21
|
+
|
|
22
|
+
for (const [name, bbox] of Object.entries(elementBboxes)) {
|
|
23
|
+
if (name === '_meta') continue; // Skip metadata entry
|
|
24
|
+
|
|
25
|
+
// Prioritize legacy points array (already in correct saved-image coordinates)
|
|
26
|
+
if (bbox.points && bbox.points.length > 0) {
|
|
27
|
+
// Check if cursor is within general bbox area first
|
|
28
|
+
if (x >= bbox.x0 - SCATTER_THRESHOLD && x <= bbox.x1 + SCATTER_THRESHOLD &&
|
|
29
|
+
y >= bbox.y0 - SCATTER_THRESHOLD && y <= bbox.y1 + SCATTER_THRESHOLD) {
|
|
30
|
+
|
|
31
|
+
const elementType = bbox.element_type || 'line';
|
|
32
|
+
let dist;
|
|
33
|
+
|
|
34
|
+
if (elementType === 'scatter') {
|
|
35
|
+
// For scatter, find distance to nearest point
|
|
36
|
+
dist = distanceToNearestPoint(x, y, bbox.points);
|
|
37
|
+
} else {
|
|
38
|
+
// For lines, find distance to line segments
|
|
39
|
+
dist = distanceToLine(x, y, bbox.points);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (dist < minDistance) {
|
|
43
|
+
minDistance = dist;
|
|
44
|
+
closestDataElement = name;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Use appropriate threshold based on element type
|
|
51
|
+
if (closestDataElement) {
|
|
52
|
+
const bbox = elementBboxes[closestDataElement];
|
|
53
|
+
const threshold = (bbox.element_type === 'scatter') ? SCATTER_THRESHOLD : PROXIMITY_THRESHOLD;
|
|
54
|
+
if (minDistance <= threshold) {
|
|
55
|
+
return closestDataElement;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Second: Collect all bbox matches, excluding panels and data elements with points
|
|
60
|
+
const elementMatches = [];
|
|
61
|
+
const panelMatches = [];
|
|
62
|
+
|
|
63
|
+
for (const [name, bbox] of Object.entries(elementBboxes)) {
|
|
64
|
+
if (x >= bbox.x0 && x <= bbox.x1 && y >= bbox.y0 && y <= bbox.y1) {
|
|
65
|
+
const area = (bbox.x1 - bbox.x0) * (bbox.y1 - bbox.y0);
|
|
66
|
+
const isPanel = bbox.is_panel || name.endsWith('_panel');
|
|
67
|
+
const hasPoints = bbox.points && bbox.points.length > 0;
|
|
68
|
+
|
|
69
|
+
if (hasPoints) {
|
|
70
|
+
// Already handled above with proximity
|
|
71
|
+
continue;
|
|
72
|
+
} else if (isPanel) {
|
|
73
|
+
panelMatches.push({name, area, bbox});
|
|
74
|
+
} else {
|
|
75
|
+
elementMatches.push({name, area, bbox});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Return smallest non-panel element if any
|
|
81
|
+
if (elementMatches.length > 0) {
|
|
82
|
+
elementMatches.sort((a, b) => a.area - b.area);
|
|
83
|
+
return elementMatches[0].name;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Fallback to panel selection (useful for multi-panel figures)
|
|
87
|
+
if (panelMatches.length > 0) {
|
|
88
|
+
panelMatches.sort((a, b) => a.area - b.area);
|
|
89
|
+
return panelMatches[0].name;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// Find All Overlapping Elements (for cycle selection)
|
|
97
|
+
// ============================================================================
|
|
98
|
+
function findAllElementsAt(x, y) {
|
|
99
|
+
// Find all elements at cursor position (for cycle selection)
|
|
100
|
+
// Returns array sorted by specificity (most specific first)
|
|
101
|
+
const PROXIMITY_THRESHOLD = 15;
|
|
102
|
+
const SCATTER_THRESHOLD = 20;
|
|
103
|
+
|
|
104
|
+
const results = [];
|
|
105
|
+
|
|
106
|
+
for (const [name, bbox] of Object.entries(elementBboxes)) {
|
|
107
|
+
let match = false;
|
|
108
|
+
let distance = Infinity;
|
|
109
|
+
let priority = 0; // Lower = more specific
|
|
110
|
+
|
|
111
|
+
const hasPoints = bbox.points && bbox.points.length > 0;
|
|
112
|
+
const elementType = bbox.element_type || '';
|
|
113
|
+
const isPanel = bbox.is_panel || name.endsWith('_panel');
|
|
114
|
+
|
|
115
|
+
// Check data elements with points (lines, scatter)
|
|
116
|
+
if (hasPoints) {
|
|
117
|
+
if (x >= bbox.x0 - SCATTER_THRESHOLD && x <= bbox.x1 + SCATTER_THRESHOLD &&
|
|
118
|
+
y >= bbox.y0 - SCATTER_THRESHOLD && y <= bbox.y1 + SCATTER_THRESHOLD) {
|
|
119
|
+
|
|
120
|
+
if (elementType === 'scatter') {
|
|
121
|
+
distance = distanceToNearestPoint(x, y, bbox.points);
|
|
122
|
+
if (distance <= SCATTER_THRESHOLD) {
|
|
123
|
+
match = true;
|
|
124
|
+
priority = 1; // Scatter points = high priority
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
distance = distanceToLine(x, y, bbox.points);
|
|
128
|
+
if (distance <= PROXIMITY_THRESHOLD) {
|
|
129
|
+
match = true;
|
|
130
|
+
priority = 2; // Lines = high priority
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Check bbox containment
|
|
137
|
+
if (x >= bbox.x0 && x <= bbox.x1 && y >= bbox.y0 && y <= bbox.y1) {
|
|
138
|
+
const area = (bbox.x1 - bbox.x0) * (bbox.y1 - bbox.y0);
|
|
139
|
+
|
|
140
|
+
if (!match) {
|
|
141
|
+
match = true;
|
|
142
|
+
distance = 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (isPanel) {
|
|
146
|
+
priority = 100; // Panels = lowest priority
|
|
147
|
+
} else if (!hasPoints) {
|
|
148
|
+
// Small elements like labels, ticks - use area for priority
|
|
149
|
+
priority = 10 + Math.min(area / 10000, 50);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (match) {
|
|
154
|
+
results.push({ name, distance, priority, bbox });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Sort by priority (lower first), then by distance
|
|
159
|
+
results.sort((a, b) => {
|
|
160
|
+
if (a.priority !== b.priority) return a.priority - b.priority;
|
|
161
|
+
return a.distance - b.distance;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return results.map(r => r.name);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// Panel Element Detection (for multi-panel canvas)
|
|
169
|
+
// ============================================================================
|
|
170
|
+
function findElementInPanelAt(x, y, bboxes) {
|
|
171
|
+
const PROXIMITY_THRESHOLD = 15;
|
|
172
|
+
const SCATTER_THRESHOLD = 20;
|
|
173
|
+
|
|
174
|
+
let closestDataElement = null;
|
|
175
|
+
let minDistance = Infinity;
|
|
176
|
+
|
|
177
|
+
// Check data elements with points
|
|
178
|
+
for (const [name, bbox] of Object.entries(bboxes)) {
|
|
179
|
+
if (name === '_meta') continue;
|
|
180
|
+
|
|
181
|
+
if (bbox.points && bbox.points.length > 0) {
|
|
182
|
+
if (x >= bbox.x0 - SCATTER_THRESHOLD && x <= bbox.x1 + SCATTER_THRESHOLD &&
|
|
183
|
+
y >= bbox.y0 - SCATTER_THRESHOLD && y <= bbox.y1 + SCATTER_THRESHOLD) {
|
|
184
|
+
|
|
185
|
+
const elementType = bbox.element_type || 'line';
|
|
186
|
+
let dist;
|
|
187
|
+
|
|
188
|
+
if (elementType === 'scatter') {
|
|
189
|
+
dist = distanceToNearestPoint(x, y, bbox.points);
|
|
190
|
+
} else {
|
|
191
|
+
dist = distanceToLine(x, y, bbox.points);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (dist < minDistance) {
|
|
195
|
+
minDistance = dist;
|
|
196
|
+
closestDataElement = name;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (closestDataElement) {
|
|
203
|
+
const bbox = bboxes[closestDataElement];
|
|
204
|
+
const threshold = (bbox.element_type === 'scatter') ? SCATTER_THRESHOLD : PROXIMITY_THRESHOLD;
|
|
205
|
+
if (minDistance <= threshold) {
|
|
206
|
+
return closestDataElement;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Check bbox containment for other elements
|
|
211
|
+
const elementMatches = [];
|
|
212
|
+
for (const [name, bbox] of Object.entries(bboxes)) {
|
|
213
|
+
if (name === '_meta') continue;
|
|
214
|
+
|
|
215
|
+
if (x >= bbox.x0 && x <= bbox.x1 && y >= bbox.y0 && y <= bbox.y1) {
|
|
216
|
+
const area = (bbox.x1 - bbox.x0) * (bbox.y1 - bbox.y0);
|
|
217
|
+
const isPanel = bbox.is_panel || name.endsWith('_panel');
|
|
218
|
+
|
|
219
|
+
if (!isPanel) {
|
|
220
|
+
elementMatches.push({name, area, bbox});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (elementMatches.length > 0) {
|
|
226
|
+
elementMatches.sort((a, b) => a.area - b.area);
|
|
227
|
+
return elementMatches[0].name;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ============================================================================
|
|
234
|
+
// Distance Calculations
|
|
235
|
+
// ============================================================================
|
|
236
|
+
function distanceToNearestPoint(px, py, points) {
|
|
237
|
+
// Find distance to nearest point in scatter
|
|
238
|
+
if (!Array.isArray(points) || points.length === 0) return Infinity;
|
|
239
|
+
let minDist = Infinity;
|
|
240
|
+
for (const pt of points) {
|
|
241
|
+
if (!Array.isArray(pt) || pt.length < 2) continue;
|
|
242
|
+
const [x, y] = pt;
|
|
243
|
+
const dist = Math.sqrt((px - x) ** 2 + (py - y) ** 2);
|
|
244
|
+
if (dist < minDist) minDist = dist;
|
|
245
|
+
}
|
|
246
|
+
return minDist;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function distanceToLine(px, py, points) {
|
|
250
|
+
if (!Array.isArray(points) || points.length < 2) return Infinity;
|
|
251
|
+
let minDist = Infinity;
|
|
252
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
253
|
+
const pt1 = points[i];
|
|
254
|
+
const pt2 = points[i + 1];
|
|
255
|
+
if (!Array.isArray(pt1) || pt1.length < 2) continue;
|
|
256
|
+
if (!Array.isArray(pt2) || pt2.length < 2) continue;
|
|
257
|
+
const [x1, y1] = pt1;
|
|
258
|
+
const [x2, y2] = pt2;
|
|
259
|
+
const dist = distanceToSegment(px, py, x1, y1, x2, y2);
|
|
260
|
+
if (dist < minDist) minDist = dist;
|
|
261
|
+
}
|
|
262
|
+
return minDist;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function distanceToSegment(px, py, x1, y1, x2, y2) {
|
|
266
|
+
const dx = x2 - x1;
|
|
267
|
+
const dy = y2 - y1;
|
|
268
|
+
const lenSq = dx * dx + dy * dy;
|
|
269
|
+
|
|
270
|
+
if (lenSq === 0) {
|
|
271
|
+
return Math.sqrt((px - x1) ** 2 + (py - y1) ** 2);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let t = ((px - x1) * dx + (py - y1) * dy) / lenSq;
|
|
275
|
+
t = Math.max(0, Math.min(1, t));
|
|
276
|
+
|
|
277
|
+
const projX = x1 + t * dx;
|
|
278
|
+
const projY = y1 + t * dy;
|
|
279
|
+
|
|
280
|
+
return Math.sqrt((px - projX) ** 2 + (py - projY) ** 2);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// ============================================================================
|
|
284
|
+
// Polygon Test
|
|
285
|
+
// ============================================================================
|
|
286
|
+
function pointInPolygon(px, py, polygon) {
|
|
287
|
+
if (!Array.isArray(polygon) || polygon.length < 3) return false;
|
|
288
|
+
|
|
289
|
+
let inside = false;
|
|
290
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
291
|
+
const ptI = polygon[i];
|
|
292
|
+
const ptJ = polygon[j];
|
|
293
|
+
if (!Array.isArray(ptI) || ptI.length < 2) continue;
|
|
294
|
+
if (!Array.isArray(ptJ) || ptJ.length < 2) continue;
|
|
295
|
+
const [xi, yi] = ptI;
|
|
296
|
+
const [xj, yj] = ptJ;
|
|
297
|
+
|
|
298
|
+
if (((yi > py) !== (yj > py)) &&
|
|
299
|
+
(px < (xj - xi) * (py - yi) / (yj - yi) + xi)) {
|
|
300
|
+
inside = !inside;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return inside;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// ============================================================================
|
|
307
|
+
// Geometry Extraction
|
|
308
|
+
// ============================================================================
|
|
309
|
+
function getGeometryPoints(bbox) {
|
|
310
|
+
// Extract points for overlay drawing
|
|
311
|
+
// Returns array of [x, y] points or null
|
|
312
|
+
|
|
313
|
+
// For scatter: use points array directly
|
|
314
|
+
if (bbox.element_type === 'scatter' && bbox.points) {
|
|
315
|
+
return bbox.points;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// For lines: use path_simplified
|
|
319
|
+
if (bbox.element_type === 'line' && bbox.path_simplified) {
|
|
320
|
+
return bbox.path_simplified;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// For fills/polygons: use polygon
|
|
324
|
+
if (bbox.polygon) {
|
|
325
|
+
return bbox.polygon;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ============================================================================
|
|
332
|
+
// Axes Coordinate Transformation (for future use with geometry_px)
|
|
333
|
+
// ============================================================================
|
|
334
|
+
function axesLocalToImage(axLocalX, axLocalY, axesBbox) {
|
|
335
|
+
// axesBbox has: x, y, width, height in figure pixel coordinates
|
|
336
|
+
// The local editor uses tight layout which shifts coordinates
|
|
337
|
+
// For now we use the existing image coordinates from bboxes
|
|
338
|
+
return {x: axLocalX, y: axLocalY};
|
|
339
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element Dragging
|
|
3
|
+
* Handles dragging of legends and panel letters (maintains scientific rigor)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Draggable Element Check
|
|
8
|
+
// ============================================================================
|
|
9
|
+
function isDraggableElement(elementName, bboxes) {
|
|
10
|
+
if (!elementName || !bboxes) return false;
|
|
11
|
+
|
|
12
|
+
// Whitelist: ONLY these element types are draggable
|
|
13
|
+
const DRAGGABLE_TYPES = ['legend', 'panel_letter'];
|
|
14
|
+
|
|
15
|
+
// Check by element_type in bbox info
|
|
16
|
+
const info = bboxes[elementName];
|
|
17
|
+
if (info && DRAGGABLE_TYPES.includes(info.element_type)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Check by naming convention (strict match)
|
|
22
|
+
if (elementName.match(/_legend$/)) return true;
|
|
23
|
+
if (elementName.match(/_panel_letter_[A-Z]$/)) return true;
|
|
24
|
+
|
|
25
|
+
// Everything else is NOT draggable (data integrity)
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Element Drag Start
|
|
31
|
+
// ============================================================================
|
|
32
|
+
function startElementDrag(e, elementName, panelName, img, bboxes) {
|
|
33
|
+
const info = bboxes[elementName] || {};
|
|
34
|
+
const elementType = info.element_type || (elementName.includes('legend') ? 'legend' : 'panel_letter');
|
|
35
|
+
|
|
36
|
+
// Extract ax_id from element name (e.g., "ax_00_legend" -> "ax_00")
|
|
37
|
+
const axId = elementName.split('_').slice(0, 2).join('_');
|
|
38
|
+
|
|
39
|
+
// Get axes bbox for constraining drag
|
|
40
|
+
const axesBbox = bboxes[`${axId}_panel`] || null;
|
|
41
|
+
|
|
42
|
+
elementDragState = {
|
|
43
|
+
element: elementName,
|
|
44
|
+
panelName: panelName,
|
|
45
|
+
elementType: elementType,
|
|
46
|
+
axId: axId,
|
|
47
|
+
axesBbox: axesBbox,
|
|
48
|
+
bboxes: bboxes,
|
|
49
|
+
img: img,
|
|
50
|
+
startMouseX: e.clientX,
|
|
51
|
+
startMouseY: e.clientY,
|
|
52
|
+
startBbox: {...info},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Show snap guide overlay
|
|
56
|
+
showSnapGuides(img, axesBbox, bboxes);
|
|
57
|
+
|
|
58
|
+
document.addEventListener('mousemove', onElementDrag);
|
|
59
|
+
document.addEventListener('mouseup', stopElementDrag);
|
|
60
|
+
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Element Drag Move
|
|
67
|
+
// ============================================================================
|
|
68
|
+
function onElementDrag(e) {
|
|
69
|
+
if (!elementDragState) return;
|
|
70
|
+
|
|
71
|
+
const {img, bboxes, element, axId, axesBbox, startBbox, startMouseX, startMouseY} = elementDragState;
|
|
72
|
+
if (!img) return;
|
|
73
|
+
|
|
74
|
+
const rect = img.getBoundingClientRect();
|
|
75
|
+
const dims = getObjectFitContainDimensions(img);
|
|
76
|
+
|
|
77
|
+
// Calculate delta in image coordinates
|
|
78
|
+
const deltaX = e.clientX - startMouseX;
|
|
79
|
+
const deltaY = e.clientY - startMouseY;
|
|
80
|
+
|
|
81
|
+
// Convert to image pixel coordinates
|
|
82
|
+
const scaleX = dims.displayWidth / rect.width;
|
|
83
|
+
const scaleY = dims.displayHeight / rect.height;
|
|
84
|
+
const imgSize = bboxes._meta?.imgSize || {width: dims.displayWidth, height: dims.displayHeight};
|
|
85
|
+
const imgDeltaX = deltaX * scaleX * imgSize.width / dims.displayWidth;
|
|
86
|
+
const imgDeltaY = deltaY * scaleY * imgSize.height / dims.displayHeight;
|
|
87
|
+
|
|
88
|
+
// Update bbox position (for visual feedback)
|
|
89
|
+
if (bboxes[element]) {
|
|
90
|
+
const newX0 = startBbox.x0 + imgDeltaX;
|
|
91
|
+
const newY0 = startBbox.y0 + imgDeltaY;
|
|
92
|
+
bboxes[element].x0 = newX0;
|
|
93
|
+
bboxes[element].y0 = newY0;
|
|
94
|
+
bboxes[element].x1 = newX0 + (startBbox.x1 - startBbox.x0);
|
|
95
|
+
bboxes[element].y1 = newY0 + (startBbox.y1 - startBbox.y0);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Calculate normalized axes position (0-1)
|
|
99
|
+
if (axesBbox) {
|
|
100
|
+
const axesWidth = axesBbox.x1 - axesBbox.x0;
|
|
101
|
+
const axesHeight = axesBbox.y1 - axesBbox.y0;
|
|
102
|
+
const elemCenterX = (bboxes[element].x0 + bboxes[element].x1) / 2;
|
|
103
|
+
const elemCenterY = (bboxes[element].y0 + bboxes[element].y1) / 2;
|
|
104
|
+
const normX = (elemCenterX - axesBbox.x0) / axesWidth;
|
|
105
|
+
const normY = 1 - (elemCenterY - axesBbox.y0) / axesHeight; // Flip Y
|
|
106
|
+
|
|
107
|
+
// Update snap guide highlighting
|
|
108
|
+
updateSnapHighlight(normX, normY);
|
|
109
|
+
|
|
110
|
+
// Show position indicator
|
|
111
|
+
showElementPositionIndicator(element, normX, normY);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Redraw overlay
|
|
115
|
+
const overlay = img.parentElement?.querySelector('svg.panel-card-overlay');
|
|
116
|
+
if (overlay) {
|
|
117
|
+
const panelCache = panelBboxesCache[elementDragState.panelName];
|
|
118
|
+
if (panelCache) {
|
|
119
|
+
updatePanelOverlay(overlay, bboxes, panelCache.imgSize, rect.width, rect.height, element, element, img);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ============================================================================
|
|
125
|
+
// Element Drag Stop
|
|
126
|
+
// ============================================================================
|
|
127
|
+
function stopElementDrag() {
|
|
128
|
+
if (!elementDragState) return;
|
|
129
|
+
|
|
130
|
+
const {element, panelName, elementType, axId, bboxes, axesBbox} = elementDragState;
|
|
131
|
+
|
|
132
|
+
// Calculate final normalized position
|
|
133
|
+
let finalPosition = null;
|
|
134
|
+
let snapName = null;
|
|
135
|
+
|
|
136
|
+
if (axesBbox && bboxes[element]) {
|
|
137
|
+
const axesWidth = axesBbox.x1 - axesBbox.x0;
|
|
138
|
+
const axesHeight = axesBbox.y1 - axesBbox.y0;
|
|
139
|
+
const elemCenterX = (bboxes[element].x0 + bboxes[element].x1) / 2;
|
|
140
|
+
const elemCenterY = (bboxes[element].y0 + bboxes[element].y1) / 2;
|
|
141
|
+
const normX = (elemCenterX - axesBbox.x0) / axesWidth;
|
|
142
|
+
const normY = 1 - (elemCenterY - axesBbox.y0) / axesHeight;
|
|
143
|
+
|
|
144
|
+
// Check for snap to named position
|
|
145
|
+
snapName = findNearestSnapPosition(normX, normY);
|
|
146
|
+
finalPosition = snapName ? SNAP_POSITIONS[snapName] : {x: normX, y: normY};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Hide snap guides
|
|
150
|
+
hideSnapGuides();
|
|
151
|
+
hideElementPositionIndicator();
|
|
152
|
+
|
|
153
|
+
// Save position to server
|
|
154
|
+
if (finalPosition) {
|
|
155
|
+
updateElementPosition(panelName, element, finalPosition);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
document.removeEventListener('mousemove', onElementDrag);
|
|
159
|
+
document.removeEventListener('mouseup', stopElementDrag);
|
|
160
|
+
elementDragState = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ============================================================================
|
|
164
|
+
// Snap Position Finding
|
|
165
|
+
// ============================================================================
|
|
166
|
+
function findNearestSnapPosition(normX, normY, threshold = 0.08) {
|
|
167
|
+
let nearest = null;
|
|
168
|
+
let minDist = Infinity;
|
|
169
|
+
|
|
170
|
+
for (const [name, pos] of Object.entries(SNAP_POSITIONS)) {
|
|
171
|
+
const dist = Math.sqrt(Math.pow(normX - pos.x, 2) + Math.pow(normY - pos.y, 2));
|
|
172
|
+
if (dist < threshold && dist < minDist) {
|
|
173
|
+
minDist = dist;
|
|
174
|
+
nearest = name;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return nearest;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ============================================================================
|
|
181
|
+
// Snap Guides UI
|
|
182
|
+
// ============================================================================
|
|
183
|
+
function showSnapGuides(img, axesBbox, bboxes) {
|
|
184
|
+
if (!img || !axesBbox) return;
|
|
185
|
+
|
|
186
|
+
const container = img.parentElement;
|
|
187
|
+
if (!container) return;
|
|
188
|
+
|
|
189
|
+
// Remove existing guides
|
|
190
|
+
container.querySelectorAll('.snap-guide').forEach(el => el.remove());
|
|
191
|
+
|
|
192
|
+
const rect = img.getBoundingClientRect();
|
|
193
|
+
const dims = getObjectFitContainDimensions(img);
|
|
194
|
+
const imgSize = bboxes._meta?.imgSize || {width: dims.displayWidth, height: dims.displayHeight};
|
|
195
|
+
|
|
196
|
+
// Scale factors
|
|
197
|
+
const scaleX = dims.displayWidth / imgSize.width;
|
|
198
|
+
const scaleY = dims.displayHeight / imgSize.height;
|
|
199
|
+
|
|
200
|
+
// Create snap points
|
|
201
|
+
for (const [name, pos] of Object.entries(SNAP_POSITIONS)) {
|
|
202
|
+
const axesWidth = axesBbox.x1 - axesBbox.x0;
|
|
203
|
+
const axesHeight = axesBbox.y1 - axesBbox.y0;
|
|
204
|
+
|
|
205
|
+
// Calculate pixel position
|
|
206
|
+
const imgX = axesBbox.x0 + pos.x * axesWidth;
|
|
207
|
+
const imgY = axesBbox.y0 + (1 - pos.y) * axesHeight;
|
|
208
|
+
|
|
209
|
+
const displayX = dims.offsetX + imgX * scaleX;
|
|
210
|
+
const displayY = dims.offsetY + imgY * scaleY;
|
|
211
|
+
|
|
212
|
+
const guide = document.createElement('div');
|
|
213
|
+
guide.className = 'snap-guide';
|
|
214
|
+
guide.dataset.snapName = name;
|
|
215
|
+
guide.style.cssText = `
|
|
216
|
+
position: absolute;
|
|
217
|
+
left: ${displayX - 6}px;
|
|
218
|
+
top: ${displayY - 6}px;
|
|
219
|
+
width: 12px;
|
|
220
|
+
height: 12px;
|
|
221
|
+
border: 2px dashed rgba(100, 149, 237, 0.6);
|
|
222
|
+
border-radius: 50%;
|
|
223
|
+
pointer-events: none;
|
|
224
|
+
z-index: 50;
|
|
225
|
+
transition: all 0.15s ease;
|
|
226
|
+
`;
|
|
227
|
+
container.appendChild(guide);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function updateSnapHighlight(normX, normY) {
|
|
232
|
+
const threshold = 0.08;
|
|
233
|
+
document.querySelectorAll('.snap-guide').forEach(guide => {
|
|
234
|
+
const name = guide.dataset.snapName;
|
|
235
|
+
const pos = SNAP_POSITIONS[name];
|
|
236
|
+
const dist = Math.sqrt(Math.pow(normX - pos.x, 2) + Math.pow(normY - pos.y, 2));
|
|
237
|
+
if (dist < threshold) {
|
|
238
|
+
guide.style.borderColor = 'rgba(76, 175, 80, 0.9)';
|
|
239
|
+
guide.style.backgroundColor = 'rgba(76, 175, 80, 0.3)';
|
|
240
|
+
guide.style.transform = 'scale(1.5)';
|
|
241
|
+
} else {
|
|
242
|
+
guide.style.borderColor = 'rgba(100, 149, 237, 0.6)';
|
|
243
|
+
guide.style.backgroundColor = 'transparent';
|
|
244
|
+
guide.style.transform = 'scale(1)';
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function hideSnapGuides() {
|
|
250
|
+
document.querySelectorAll('.snap-guide').forEach(el => el.remove());
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ============================================================================
|
|
254
|
+
// Position Indicator
|
|
255
|
+
// ============================================================================
|
|
256
|
+
function showElementPositionIndicator(element, normX, normY) {
|
|
257
|
+
let indicator = document.getElementById('element-position-indicator');
|
|
258
|
+
if (!indicator) {
|
|
259
|
+
indicator = document.createElement('div');
|
|
260
|
+
indicator.id = 'element-position-indicator';
|
|
261
|
+
indicator.style.cssText = `
|
|
262
|
+
position: fixed;
|
|
263
|
+
bottom: 60px;
|
|
264
|
+
right: 20px;
|
|
265
|
+
background: rgba(0, 0, 0, 0.85);
|
|
266
|
+
color: white;
|
|
267
|
+
padding: 6px 10px;
|
|
268
|
+
border-radius: 4px;
|
|
269
|
+
font-family: monospace;
|
|
270
|
+
font-size: 11px;
|
|
271
|
+
z-index: 10001;
|
|
272
|
+
pointer-events: none;
|
|
273
|
+
`;
|
|
274
|
+
document.body.appendChild(indicator);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
indicator.textContent = `${element}: (${normX.toFixed(2)}, ${normY.toFixed(2)})`;
|
|
278
|
+
indicator.style.display = 'block';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function hideElementPositionIndicator() {
|
|
282
|
+
const indicator = document.getElementById('element-position-indicator');
|
|
283
|
+
if (indicator) {
|
|
284
|
+
indicator.style.display = 'none';
|
|
285
|
+
}
|
|
286
|
+
}
|