Skip to content
Merged
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fig.savefig('trig.pdf', folder=True)

## GUI Editor

gleplot also ships a desktop editor (PySide6) for building figures without writing code: load data, pick columns, style series, arrange subplots, and export -- all with a live preview.
gleplot also ships a desktop editor (PySide6) for building figures without writing code: load data, pick columns, style series, arrange subplots, annotate, and export -- all with a live preview.

### Install
```bash
Expand All @@ -61,9 +61,11 @@ gleplot-gui
```

### Features
✨ **Live Preview** - Debounced, async GLE compile-to-PNG as you edit
✨ **Live Preview** - Debounced, async GLE compile as you edit, as a vector SVG by default (with an automatic, sticky PNG fallback if SVG isn't usable)
✨ **On-Canvas Annotations** - Add, drag, double-click-edit, and delete free-form text labels directly on the preview, kept in sync with a dedicated Texts tab
✨ **Data Manager** - Load CSV/`.dat` files, pick columns, import data or reference the file in place
✨ **Property Panels** - Layout, Figure, Axes, and Series tabs for point-and-click styling
✨ **Named Data Columns** - Generated `.dat` sidecars carry real column names (from your series labels) instead of anonymous placeholders
✨ **Property Panels** - Layout, Figure, Axes, Series, and Texts tabs for point-and-click styling
✨ **Native `.gle` Files** - Save and open your work directly as `.gle` (the same format GLE renders) via File ▸ Save / Open -- unrecognized content is preserved as raw GLE
✨ **Export Dialog** - PDF, PNG, EPS, SVG, JPG, or raw GLE script, with an optional folder bundle
✨ **Undo/Redo** - Full editing history
Expand Down
91 changes: 87 additions & 4 deletions docs/guides/GUI_EDITOR.md

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions docs/source/gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,34 @@ the main editor window and runs the Qt event loop.
What it provides
-----------------

- A central **live preview** that recompiles the figure to PNG via GLE as you
edit, debounced so rapid edits don't trigger a compile per keystroke.
- A central **live preview** that recompiles the figure via GLE as you edit,
debounced so rapid edits don't trigger a compile per keystroke. It renders
as a vector **SVG** by default, with an automatic, sticky fallback to PNG
for the rest of the session if SVG output isn't usable (a **View ▸ Vector
preview (SVG)** toggle switches between the two manually).
- **On-canvas text annotations**: add, drag, double-click-edit, and delete
free-form text labels directly on the preview, in sync both ways with a
dedicated **Texts** tab in the Properties dock.
- A **Data** dock for loading delimited data files (CSV/``.dat``/``.txt``)
and creating series by mapping columns, either importing the data or
referencing the file in place.
- A **Properties** dock with **Layout**, **Figure**, **Axes**, and **Series**
tabs for point-and-click styling and subplot arrangement.
referencing the file in place. Generated ``.dat`` sidecars carry a named
header row (derived from each series' label) instead of anonymous column
numbers.
- A **Properties** dock with **Layout**, **Figure**, **Axes**, **Series**,
and **Texts** tabs for point-and-click styling, subplot arrangement, and
annotation editing.
- An **Output** dock listing structured compile errors with line/column
information when GLE reports it, plus any recovery warnings raised when a
``.gle`` file is opened.
- **Native ``.gle`` files** via File |menu| Save / Open: Save writes a plain
GLE script (``Figure.savefig_gle``, with imported data as ``.dat``
GLE script (``Figure.savefig_gle``, with imported data as named ``.dat``
sidecars) and Open parses it back into the editor
(``gleplot.parser.recognizer.parse_gle_figure``), tolerantly preserving any
unrecognized content as raw GLE (a read-only **Raw GLE** tab).
- An **export dialog** producing PDF, PNG, EPS, SVG, JPG, or a raw ``.gle``
script, optionally bundled into a folder with its data files.
script, optionally bundled into a folder with its data files. Exports
always compile the figure exactly as saved, independent of anything the
live preview substitutes for on-screen rendering.
- **Undo/redo** and a read-only preview mode for ``.gle`` files that use GLE
programming constructs.

Expand Down
37 changes: 27 additions & 10 deletions examples/gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,33 @@ A small, ready-to-open figure for the gleplot GUI editor (`gleplot-gui`).
and series creation from scratch.
- **`damped_oscillation.gle`** -- the finished figure as a native `.gle`
file: an error-bar series for the measured data plus a dashed line for the
model, with axis labels, a title, and a legend. `.gle` is the editor's
native save format, so File > Open parses this straight back into the
editor -- open it to see a fully styled result, then keep editing.
model, with axis labels, a title, a legend, and three text annotations
("Initial peak", "Decay envelope", "Settling") marking points of interest
on the curve. `.gle` is the editor's native save format, so File > Open
parses this straight back into the editor -- open it to see a fully styled
result, then keep editing.
- **`data_0.dat`**, **`data_1.dat`** -- the two `.dat` sidecars the `.gle`
references (the measured series and the model curve). They live alongside
the `.gle` and are read on open and rewritten on save.
the `.gle` and are read on open and rewritten on save. Each one starts with
a named header row (`x measured err`, `x model_fit`) instead of anonymous
column numbers -- open either in a text editor to see it.

## Try it

1. Launch the editor: `gleplot-gui`
2. **Open the finished figure**: File > Open > `damped_oscillation.gle`.
It parses into the editor and renders immediately in the live preview --
fully editable, not a static preview.
3. **Or build it yourself** from the raw data:
3. **Try the annotations**: hover over any of the three text labels on the
preview and drag it to a new spot (a semi-transparent "ghost" follows the
cursor until the next render lands with the text at its new position);
double-click one to edit its wording inline; select one and press Delete
to remove it. Or press **T** (Edit > Add text annotation) and click
anywhere on the plot to place a new label. The Properties dock's **Texts**
tab lists all three and lets you edit position, color, size, and
horizontal alignment from a form instead -- selecting a row there
highlights the matching label on the canvas, and vice versa.
4. **Or build it yourself** from the raw data:
- Data dock > "Load data file..." > `damped_oscillation.csv`.
- Pick `x` for X, `y_measured` for Y, `yerr` for Y error, plot type
"Error bars", mode "Import data" > Add series.
Expand All @@ -33,16 +46,20 @@ A small, ready-to-open figure for the gleplot GUI editor (`gleplot-gui`).
X label to "Time (s)", Y label to "Amplitude".
- Properties dock > Series tab: style the model line (color, dash) and
the measured series (marker, color) to taste; enable the legend.
- Add a label or two of your own with Edit > Add text annotation (or the
Texts tab's Add button).
- File > Save As... to write your own `.gle`.
4. **Export**: File > Export (Ctrl+E) to produce a PDF/PNG/SVG/EPS/JPG, or a
5. **Export**: File > Export (Ctrl+E) to produce a PDF/PNG/SVG/EPS/JPG, or a
`.gle` script, or a folder bundle containing the script plus its data
files.

## Regenerating

`damped_oscillation.gle` (and its `data_*.dat` sidecars) was generated
programmatically (not hand-edited) using the gleplot API plus
`Figure.savefig_gle`, mirroring what the Data dock's "Import data" mode
produces. It round-trips through `gleplot.parser.recognizer.parse_gle_figure`
with zero warnings. See `docs/guides/GUI_EDITOR.md` for the equivalent manual
programmatically (not hand-edited) using the gleplot API -- including the
three text annotations, added via `Axes.text()` -- plus `Figure.savefig_gle`,
mirroring what the Data dock's "Import data" mode plus manual annotation
placement produces. It round-trips through
`gleplot.parser.recognizer.parse_gle_figure` with zero warnings, and compiles
cleanly with GLE. See `docs/guides/GUI_EDITOR.md` for the equivalent manual
workflow.
200 changes: 100 additions & 100 deletions examples/gui/damped_oscillation.csv
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
x,y_measured,yerr,y_model
0.000000,1.012189,0.050000,1.000000
0.101010,0.908822,0.050000,0.950422
0.202020,0.895427,0.050000,0.865409
0.303030,0.788099,0.050000,0.750476
0.404040,0.533978,0.050000,0.612020
0.505051,0.404923,0.050000,0.457010
0.606061,0.297789,0.050000,0.292676
0.707071,0.113546,0.050000,0.126195
0.808081,-0.036259,0.050000,-0.035587
0.909091,-0.220541,0.050000,-0.186420
1.010101,-0.285684,0.050000,-0.320860
1.111111,-0.403336,0.050000,-0.434448
1.212121,-0.521185,0.050000,-0.523826
1.313131,-0.541722,0.050000,-0.586811
1.414141,-0.603714,0.050000,-0.622415
1.515152,-0.665181,0.050000,-0.630810
1.616162,-0.598508,0.050000,-0.613258
1.717172,-0.610348,0.050000,-0.571992
1.818182,-0.474936,0.050000,-0.510074
1.919192,-0.433212,0.050000,-0.431215
2.020202,-0.346988,0.050000,-0.339593
2.121212,-0.266894,0.050000,-0.239657
2.222222,-0.087025,0.050000,-0.135927
2.323232,-0.038994,0.050000,-0.032813
2.424242,0.048429,0.050000,0.065562
2.525253,0.141421,0.050000,0.155506
2.626263,0.255179,0.050000,0.233887
2.727273,0.312838,0.050000,0.298220
2.828283,0.363247,0.050000,0.346737
2.929293,0.395643,0.050000,0.378410
3.030303,0.478617,0.050000,0.392952
3.131313,0.374525,0.050000,0.390782
3.232323,0.352482,0.050000,0.372972
3.333333,0.308609,0.050000,0.341160
3.434343,0.322091,0.050000,0.297452
3.535354,0.289471,0.050000,0.244312
3.636364,0.179882,0.050000,0.184440
3.737374,0.087039,0.050000,0.120645
3.838384,0.022755,0.050000,0.055735
3.939394,0.018416,0.050000,-0.007608
4.040404,-0.037188,0.050000,-0.066918
4.141414,-0.098315,0.050000,-0.120041
4.242424,-0.191816,0.050000,-0.165196
4.343434,-0.191743,0.050000,-0.201030
4.444444,-0.221977,0.050000,-0.226645
4.545455,-0.232861,0.050000,-0.241608
4.646465,-0.211086,0.050000,-0.245943
4.747475,-0.231155,0.050000,-0.240098
4.848485,-0.197753,0.050000,-0.224910
4.949495,-0.198836,0.050000,-0.201539
5.050505,-0.159846,0.050000,-0.171410
5.151515,-0.110886,0.050000,-0.136137
5.252525,-0.155731,0.050000,-0.097445
5.353535,-0.069883,0.050000,-0.057096
5.454545,-0.035631,0.050000,-0.016816
5.555556,-0.003782,0.050000,0.021774
5.656566,0.046210,0.050000,0.057215
5.757576,0.148062,0.050000,0.088264
5.858586,0.079293,0.050000,0.113926
5.959596,0.172213,0.050000,0.133482
6.060606,0.079186,0.050000,0.146501
6.161616,0.139448,0.050000,0.152844
6.262626,0.159156,0.050000,0.152646
6.363636,0.169749,0.050000,0.146301
6.464646,0.162874,0.050000,0.134425
6.565657,0.149558,0.050000,0.117824
6.666667,0.083495,0.050000,0.097444
6.767677,0.055837,0.050000,0.074332
6.868687,0.083898,0.050000,0.049579
6.969697,0.016629,0.050000,0.024281
7.070707,-0.051537,0.050000,-0.000509
7.171717,-0.069152,0.050000,-0.023821
7.272727,-0.081578,0.050000,-0.044800
7.373737,-0.042852,0.050000,-0.062738
7.474747,-0.071393,0.050000,-0.077090
7.575758,-0.059868,0.050000,-0.087487
7.676768,-0.110833,0.050000,-0.093743
7.777778,-0.089506,0.050000,-0.095848
7.878788,-0.068938,0.050000,-0.093962
7.979798,-0.100769,0.050000,-0.088395
8.080808,-0.061318,0.050000,-0.079589
8.181818,-0.094566,0.050000,-0.068089
8.282828,-0.069041,0.050000,-0.054518
8.383838,-0.054815,0.050000,-0.039546
8.484848,-0.071692,0.050000,-0.023858
8.585859,0.011349,0.050000,-0.008130
8.686869,-0.011775,0.050000,0.007001
8.787879,0.021460,0.050000,0.020960
8.888889,0.052482,0.050000,0.033252
8.989899,0.061341,0.050000,0.043480
9.090909,0.077967,0.050000,0.051352
9.191919,0.052749,0.050000,0.056688
9.292929,0.042492,0.050000,0.059424
9.393939,0.056412,0.050000,0.059601
9.494949,-0.010131,0.050000,0.057362
9.595960,-0.004943,0.050000,0.052941
9.696970,-0.006265,0.050000,0.046643
9.797980,-0.001056,0.050000,0.038834
9.898990,0.045908,0.050000,0.029917
10.000000,-0.015902,0.050000,0.020317
0.000000,1.006287,0.050000,1.000000
0.101010,0.952432,0.050000,0.959037
0.202020,0.930331,0.050000,0.898310
0.303030,0.825630,0.050000,0.820385
0.404040,0.701292,0.050000,0.728075
0.505051,0.642441,0.050000,0.624361
0.606061,0.577511,0.050000,0.512311
0.707071,0.442359,0.050000,0.395005
0.808081,0.240278,0.050000,0.275464
0.909091,0.093314,0.050000,0.156585
1.010101,0.009913,0.050000,0.041077
1.111111,-0.066523,0.050000,-0.068589
1.212121,-0.286471,0.050000,-0.170220
1.313131,-0.272878,0.050000,-0.261939
1.414141,-0.404504,0.050000,-0.342208
1.515152,-0.446458,0.050000,-0.409845
1.616162,-0.491242,0.050000,-0.464029
1.717172,-0.520113,0.050000,-0.504298
1.818182,-0.509959,0.050000,-0.530540
1.919192,-0.490847,0.050000,-0.542973
2.020202,-0.548548,0.050000,-0.542121
2.121212,-0.460462,0.050000,-0.528785
2.222222,-0.537268,0.050000,-0.504008
2.323232,-0.451460,0.050000,-0.469036
2.424242,-0.380102,0.050000,-0.425276
2.525253,-0.369556,0.050000,-0.374256
2.626263,-0.354760,0.050000,-0.317585
2.727273,-0.302989,0.050000,-0.256903
2.828283,-0.216737,0.050000,-0.193850
2.929293,-0.119014,0.050000,-0.130024
3.030303,-0.117425,0.050000,-0.066944
3.131313,-0.016485,0.050000,-0.006027
3.232323,0.043487,0.050000,0.051448
3.333333,0.131396,0.050000,0.104353
3.434343,0.162468,0.050000,0.151735
3.535354,0.210591,0.050000,0.192822
3.636364,0.194344,0.050000,0.227035
3.737374,0.247506,0.050000,0.253987
3.838384,0.312681,0.050000,0.273482
3.939394,0.360179,0.050000,0.285507
4.040404,0.227272,0.050000,0.290225
4.141414,0.363651,0.050000,0.287955
4.242424,0.346455,0.050000,0.279161
4.343434,0.303495,0.050000,0.264430
4.444444,0.257674,0.050000,0.244451
4.545455,0.204300,0.050000,0.219996
4.646465,0.264794,0.050000,0.191893
4.747475,0.259018,0.050000,0.161005
4.848485,0.218294,0.050000,0.128212
4.949495,0.160138,0.050000,0.094383
5.050505,0.078230,0.050000,0.060361
5.151515,-0.033472,0.050000,0.026944
5.252525,-0.005353,0.050000,-0.005131
5.353535,-0.002377,0.050000,-0.035201
5.454545,-0.127106,0.050000,-0.062688
5.555556,-0.067354,0.050000,-0.087110
5.656566,-0.086589,0.050000,-0.108082
5.757576,-0.090520,0.050000,-0.125322
5.858586,-0.197856,0.050000,-0.138650
5.959596,-0.181074,0.050000,-0.147989
6.060606,-0.175179,0.050000,-0.153358
6.161616,-0.213355,0.050000,-0.154865
6.262626,-0.065734,0.050000,-0.152703
6.363636,-0.171933,0.050000,-0.147137
6.464646,-0.122049,0.050000,-0.138497
6.565657,-0.140092,0.050000,-0.127163
6.666667,-0.034382,0.050000,-0.113556
6.767677,-0.032105,0.050000,-0.098123
6.868687,-0.049662,0.050000,-0.081330
6.969697,-0.173819,0.050000,-0.063643
7.070707,-0.042924,0.050000,-0.045525
7.171717,0.006764,0.050000,-0.027420
7.272727,0.040452,0.050000,-0.009746
7.373737,-0.023781,0.050000,0.007114
7.474747,0.113919,0.050000,0.022818
7.575758,-0.028950,0.050000,0.037071
7.676768,0.016553,0.050000,0.049629
7.777778,0.107054,0.050000,0.060301
7.878788,0.071404,0.050000,0.068951
7.979798,0.175619,0.050000,0.075499
8.080808,0.089342,0.050000,0.079916
8.181818,0.050566,0.050000,0.082225
8.282828,0.063620,0.050000,0.082498
8.383838,0.026290,0.050000,0.080847
8.484848,0.013540,0.050000,0.077424
8.585859,0.103933,0.050000,0.072413
8.686869,0.095080,0.050000,0.066021
8.787879,0.123208,0.050000,0.058480
8.888889,0.012299,0.050000,0.050030
8.989899,0.125375,0.050000,0.040920
9.090909,0.017030,0.050000,0.031399
9.191919,0.100433,0.050000,0.021713
9.292929,-0.009545,0.050000,0.012094
9.393939,-0.034013,0.050000,0.002761
9.494949,0.006403,0.050000,-0.006087
9.595960,0.037299,0.050000,-0.014273
9.696970,-0.013598,0.050000,-0.021649
9.797980,-0.057366,0.050000,-0.028090
9.898990,-0.100564,0.050000,-0.033503
10.000000,-0.107899,0.050000,-0.037823
21 changes: 18 additions & 3 deletions examples/gui/damped_oscillation.gle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ begin graph
xtitle "Time (s)"
ytitle "Amplitude"
xaxis min 0 max 10
yaxis min -0.715181 max 1.06219
yaxis min -0.598548 max 1.05629
data data_1.dat d1=c1,c2
d1 line smooth color RED lwidth 0.05292 lstyle 2 key "Model fit"
data data_0.dat d2=c1,c2 d3=c1,c3
d2 marker FCIRCLE msize 0.15 color BLUE line lwidth 0.05292 err d3 errwidth 0.1059 key "Measured"
d2 marker FCIRCLE msize 0.15 color BLUE line lwidth 0.05292 err d3 key "Measured"
key pos tr
end graph
end graph
set hei 0.352734
set color BLACK
set just left
amove xg(1) yg(0.92)
write "Initial peak"
set hei 0.352734
set color DARKGREEN
set just left
amove xg(4.5) yg(-0.32)
write "Decay envelope"
set hei 0.352734
set color PURPLE
set just right
amove xg(8.5) yg(0.25)
write "Settling"
Loading
Loading