diff --git a/README.adoc b/README.adoc index ef39de9..fdf3658 100644 --- a/README.adoc +++ b/README.adoc @@ -13,6 +13,21 @@ * Visualize with GLMakie (or CairoMakie) ** Inspecting with GUI +== Docs +Clone this repo, and +```sh +$ cd docs + +$ julia --project -e 'using Pkg; Pkg.instantiate()' + +$ julia --project make.jl + +$ cd build + +$ python -m http.server --bind localhost + +``` + == TODO - [x] Printing - [ ] visualize diff --git a/docs/src/apis.md b/docs/src/apis.md index ab2478d..6f203de 100644 --- a/docs/src/apis.md +++ b/docs/src/apis.md @@ -6,3 +6,9 @@ ```@autodocs Modules = [CoordVisualize] ``` + +# ColorMapFuncs + +```@autodocs +Modules = [CoordVisualize.ColorMapFuncs] +``` diff --git a/docs/src/index.md b/docs/src/index.md index eeeaa19..293bc14 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -12,7 +12,7 @@ Readers are expected to be familiar with basics of julia. ### Preparing This will take a few minutes. -```juliarepl +```julia-repl julia> # type ] (@v1.10) Pkg> activate . @@ -21,24 +21,52 @@ julia> # type ] ``` ### Parse log -```juliarepl +```julia-repl julia> using CoordVisualize -julia> interactive_edit_log("coord_log_1.txt", "coord_log_2.txt") +julia> iedit_log("coord_log_1.txt", "coord_log_2.txt") ... Follow the instruction ... ``` -### CoordVisualize -Get map image file and place it as "map.png". +### Visualize the log +Get map image file and place it as "map.png" beforehand. -```juliarepl +```julia-repl julia> using GLMakie, CoordVisualize -julia> tlog = include(""); +julia> tlog = Observable(include("")) +... + +julia> # or + +julia> tlog = Observable(interactive_edit_log("log files", "log file2")) +... julia> include("/interactive_viz.jl") +... +``` + +Available colorschemes at https://juliagraphics.github.io/ColorSchemes.jl/stable/catalogue/ . +Available colors at https://juliagraphics.github.io/Colors.jl/stable/constructionandconversion/#Color-Parsing and https://juliagraphics.github.io/Colors.jl/stable/namedcolors/ . + +### Edit the log +```julia-repl +julia> isplit_log!(tlog[], 3, 30) +... + +julia> iedit_note!(tlog[], 3) +... + +julia> ijoin_logs!(tlog[], 5, 7) +... + +``` + +### Export the log +```julia-repl +julia> export_log(tlog[], "") ``` ## Low level diff --git a/interactive_viz.jl b/interactive_viz.jl index 4fa85f4..18e7c9c 100644 --- a/interactive_viz.jl +++ b/interactive_viz.jl @@ -94,7 +94,7 @@ inspector_options = grid!( [1, 2] => toggle_inspector, width = options_width, ) -fig[1:2, 2] = grid!( +fig[1:2, 3] = grid!( [0, :] => Label(fig, "Line", font = :bold), [1, :] => line_options, [2, :] => Label(fig, "Marker", font = :bold), @@ -143,7 +143,7 @@ cbm = Colorbar( ticklabelsize = 10, label = menu_mcolormapfunc.selection, ) -fig[1:2, 3] = grid!( +fig[1:2, 2] = grid!( [0, 1] => Label(fig, "line", font = :bold), [1, 1] => cbl, [2, 1] => Label(fig, "marker", font = :bold), diff --git a/src/interactive_edit.jl b/src/interactive_edit.jl index 298a8f8..b92fb50 100644 --- a/src/interactive_edit.jl +++ b/src/interactive_edit.jl @@ -2,6 +2,9 @@ using Statistics using Dates using Printf +""" +Interactively parse log files and edit the log. +""" function iedit_log(filenames...; writetofile = true) printstyled(stdout, "[CoordLog Editor] \n", color = :blue, bold = true) logs = CoordLog[] @@ -118,6 +121,15 @@ function iedit_log(filenames...; writetofile = true) return edited_logs end +""" + isplit_log!( + logs::AbstractVector{CoordLog{T}}, + logid::Integer, + pointid::Integer, + ) where {T} + +Split the log. Supply notes interactively. +""" function isplit_log!( logs::AbstractVector{CoordLog{T}}, logid::Integer, @@ -143,6 +155,11 @@ function isplit_log!( insert!(logs, logid + 1, new_logs[2]) end +""" + iedit_note!(logs::AbstractVector{CoordLog{T}}, logid::Integer) where {T} + +Edit the note at `logid`. Supply new note interactively. +""" function iedit_note!(logs::AbstractVector{CoordLog{T}}, logid::Integer) where {T} 1 ≤ logid ≤ length(logs) || throw(ArgumentError("logid out of index: ¬ 1 ≤ $(logid) ≤ $(length(logid))")) @@ -151,6 +168,11 @@ function iedit_note!(logs::AbstractVector{CoordLog{T}}, logid::Integer) where {T logs[logid].note = note end +""" + ijoin_logs!(logs::AbstractVector{CoordLog{T}}, logid1::Integer, logid2::Integer) where {T} + +Join the logs at `logid1` and `logid2`. Supply new note interactively. +""" function ijoin_logs!(logs::AbstractVector{CoordLog{T}}, logid1::Integer, logid2::Integer) where {T} 1 ≤ logid1 ≤ length(logs) || throw(ArgumentError("logid1 out of index: ¬ 1 ≤ $(logid1) ≤ $(length(logid1))")) diff --git a/src/recipes.jl b/src/recipes.jl index 813c30c..76c87a1 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -4,16 +4,29 @@ using ColorSchemes """ Predefined color map functions. +Receives +- `cmap`: colormap +- `logs`: vector of `CoordLog` +- `n`: number of returning ticks + +and returns tuple of +1. vector of `Colorant` +2. ticks to pass to `Colorbar`, which is a Tuple of + 1. vector of tick location (0 to 1) + 2. vector of tick labels (strings) + +Any function (or struct) which behaves like this can be used for +`lcolormapfunc` and `mcolormapfunc` kwargs of `trace2ds`. # Types -[`ColorMapFunc`](@ref) +[`ColorMapFunc`](@ref) is a supertype of all of these. # Interface Define these methods for the ColorMapFunc. - (AbstractVector{CoordLog}) -> Vector{∈ [0, 1]}, ticks + (cmap, logs, n) -> Vector{Colorant}, ticks """ module ColorMapFuncs @@ -26,7 +39,8 @@ using Makie: wong_colors, Scene # Methods (f::ColorMapFunc)(cmap, logs) -Helper method. +Helper struct for those use vector of 0 to 1 floats. +Example functions are [`Date`](@ref) and [`Altitude`](@ref). """ abstract type ColorMapFunc end