Skip to content

Commit

Permalink
Added gr_drawaxes() function
Browse files Browse the repository at this point in the history
  • Loading branch information
jheinen committed Jun 13, 2024
1 parent 32f62cf commit 2101948
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/GR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export
mainloop,
axis,
drawaxis,
drawaxes,
GRAxis,
GRTick,
GRTickLabel
Expand Down Expand Up @@ -4475,7 +4476,7 @@ function axis(which::Char; min::Real = NaN, max::Real = NaN, tick::Real = NaN, o
return GRAxis(min=c_axis.min, max=c_axis.max, tick=c_axis.tick, org=c_axis.org, position=c_axis.position, major_count=c_axis.major_count, ticks=ticks, tick_labels=tick_labels, tick_size=c_axis.tick_size, draw_axis_line=c_axis.draw_axis_line)
end

function drawaxis(which::Char, axis::GRAxis, options::Int=AXES_WITH_GRID|AXES_WITH_FRAME)
function to_c_axis(axis::GRAxis)::c_axis_t
c_axis = c_axis_t(min=axis.min, max=axis.max, tick=axis.tick, org=axis.org, position=axis.position, major_count=axis.major_count, tick_size=axis.tick_size, draw_axis_line=axis.draw_axis_line)
if axis.ticks != nothing
ticks = c_tick_t[]
Expand All @@ -4499,10 +4500,24 @@ function drawaxis(which::Char, axis::GRAxis, options::Int=AXES_WITH_GRID|AXES_WI
c_axis.tick_labels = C_NULL
c_axis.num_tick_labels = 0
end
c_axis
end

function drawaxis(which::Char, axis::GRAxis)
c_axis = to_c_axis(axis)
ccall( libGR_ptr(:gr_drawaxis),
Nothing,
(Cchar, Ptr{c_axis_t}, Cint),
which, Ref(c_axis), options)
(Cchar, Ptr{c_axis_t}),
which, Ref(c_axis))
end

function drawaxes(x_axis::GRAxis, y_axis::GRAxis, options::Int=AXES_WITH_GRID|AXES_WITH_FRAME)
c_x_axis = to_c_axis(x_axis)
c_y_axis = to_c_axis(y_axis)
ccall( libGR_ptr(:gr_drawaxes),
Nothing,
(Ptr{c_axis_t}, Ptr{c_axis_t}, Cint),
Ref(c_x_axis), Ref(c_y_axis), options)
end

# JS functions
Expand Down
1 change: 1 addition & 0 deletions src/libgr_syms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@
:gr_inqclipregion
:gr_axis
:gr_drawaxis
:gr_drawaxes
]

0 comments on commit 2101948

Please sign in to comment.