Initial work on move to implot 0.7 compatibility. See notes.

- This updates the bindings generator, the low-level bindings as
  well as the higher-level bindings and the examples to work
  with a newer master of cimplot that links to implot 0.7.
- Several things are not done properly yet:
  - Contexts can be created and as long as they are not dropped
    things work out (shown in the examples). However, this should
    be done more imgui-rs like, where operations that require a context
    make that explicit by requiring a context reference to be passed.
  - The README has not been updated yet to all the new features that
    were added.
This commit is contained in:
4bb4 2020-10-04 14:43:18 +02:00
parent e0ad0e892e
commit f85c50657b
8 changed files with 988 additions and 244 deletions

View file

@ -2,7 +2,7 @@
//! features of the libray, see the line_plots example.
use imgui::{im_str, CollapsingHeader, Condition, Ui, Window};
use implot::{Plot, PlotBars};
use implot::{Context, Plot, PlotBars};
mod support;
@ -44,6 +44,7 @@ fn show_basic_horizontal_plot(ui: &Ui) {
fn main() {
let system = support::init(file!());
let mut showing_demo = false;
let _plotcontext = Context::create(); // TODO(4bb4) use this as soon as things have been adapted
system.main_loop(move |_, ui| {
Window::new(im_str!("Bar plots example"))
.size([430.0, 450.0], Condition::FirstUseEver)

View file

@ -4,9 +4,9 @@
use imgui::{im_str, CollapsingHeader, Condition, Ui, Window};
use implot::{
get_plot_limits, get_plot_mouse_position, get_plot_query, is_plot_hovered, is_plot_queried,
push_style_color, push_style_var_f32, push_style_var_u32, set_colormap_from_preset,
set_colormap_from_vec, AxisFlags, Colormap, ImPlotLimits, ImPlotPoint, ImPlotRange, ImVec4,
Marker, Plot, PlotColorElement, PlotFlags, PlotLine, StyleVar,
push_style_color, push_style_var_f32, push_style_var_i32, set_colormap_from_preset,
set_colormap_from_vec, AxisFlags, Colormap, Context, ImPlotLimits, ImPlotPoint, ImPlotRange,
ImVec4, Marker, Plot, PlotColorElement, PlotFlags, PlotLine, StyleVar,
};
mod support;
@ -46,11 +46,11 @@ fn show_configurable_plot(ui: &Ui) {
let y_min = 1.0;
let y_max = 2.0;
// - Plot flags, see the PlotFlags docs for more info
let plot_flags = PlotFlags::DEFAULT;
let plot_flags = PlotFlags::NONE;
// - Axis flags, see the AxisFlags docs for more info. All flags are bitflags-created,
// so they support a bunch of convenient operations, see https://docs.rs/bitflags
let x_axis_flags = AxisFlags::DEFAULT;
let y_axis_flags = AxisFlags::DEFAULT;
let x_axis_flags = AxisFlags::NONE;
let y_axis_flags = AxisFlags::NONE;
// - Unlabelled X axis ticks
let x_ticks = vec![2.2, 2.5, 2.8];
@ -154,12 +154,12 @@ fn show_style_plot(ui: &Ui) {
},
Condition::Always,
)
.with_plot_flags(&(PlotFlags::DEFAULT))
.with_y_axis_flags(&(AxisFlags::DEFAULT))
.with_plot_flags(&(PlotFlags::NONE))
.with_y_axis_flags(&(AxisFlags::NONE))
.build(|| {
// Markers can be selected as shown here. The markers are internally represented
// as an u32, hence this calling style.
let markerchoice = push_style_var_u32(&StyleVar::Marker, Marker::CROSS.bits());
let markerchoice = push_style_var_i32(&StyleVar::Marker, Marker::Cross as i32);
PlotLine::new("Left eye").plot(&vec![2.0, 2.0], &vec![2.0, 1.0]);
// Calling pop() on the return value of the push above will undo the marker choice.
markerchoice.pop();
@ -232,6 +232,7 @@ fn show_colormaps_plot(ui: &Ui) {
fn main() {
let system = support::init(file!());
let mut showing_demo = false;
let _plotcontext = Context::create(); // TODO(4bb4) use this as soon as things have been adapted
system.main_loop(move |_, ui| {
Window::new(im_str!("Line plots example"))
.size([430.0, 450.0], Condition::FirstUseEver)

View file

@ -2,7 +2,9 @@
//! features of the libray, see the line_plots example.
use imgui::{im_str, CollapsingHeader, Condition, Ui, Window};
use implot::{push_style_var_f32, push_style_var_u32, Marker, Plot, PlotScatter, StyleVar};
use implot::{
push_style_var_f32, push_style_var_i32, Context, Marker, Plot, PlotScatter, StyleVar,
};
mod support;
@ -28,7 +30,7 @@ fn show_custom_markers_plot(ui: &Ui) {
"This header shows how markers can be used in scatter plots."
));
let content_width = ui.window_content_region_width();
Plot::new("Simple scatter plot")
Plot::new("Multi-marker scatter plot")
// The size call could also be omitted, though the defaults don't consider window
// width, which is why we're not doing so here.
.size(content_width, 300.0)
@ -36,14 +38,14 @@ fn show_custom_markers_plot(ui: &Ui) {
// Change to cross marker for one scatter plot call
let x_positions = vec![0.1, 0.2, 0.1, 0.5, 0.9];
let y_positions = vec![0.1, 0.1, 0.3, 0.3, 0.9];
let markerchoice = push_style_var_u32(&StyleVar::Marker, Marker::CROSS.bits());
let markerchoice = push_style_var_i32(&StyleVar::Marker, Marker::Cross as i32);
PlotScatter::new("legend label 1").plot(&x_positions, &y_positions);
markerchoice.pop();
// One can combine things like marker size and markor choice
let x_positions = vec![0.4, 0.1];
let y_positions = vec![0.5, 0.3];
let marker_choice = push_style_var_u32(&StyleVar::Marker, Marker::DIAMOND.bits());
let marker_choice = push_style_var_i32(&StyleVar::Marker, Marker::Diamond as i32);
let marker_size = push_style_var_f32(&StyleVar::MarkerSize, 12.0);
PlotScatter::new("legend label 2").plot(&x_positions, &y_positions);
@ -57,6 +59,7 @@ fn show_custom_markers_plot(ui: &Ui) {
fn main() {
let system = support::init(file!());
let mut showing_demo = false;
let _plotcontext = Context::create(); // TODO(4bb4) use this as soon as things have been adapted
system.main_loop(move |_, ui| {
Window::new(im_str!("Scatter plots example"))
.size([430.0, 450.0], Condition::FirstUseEver)

View file

@ -2,7 +2,7 @@
//! features of the libray, see the line_plots example.
use imgui::{im_str, CollapsingHeader, Condition, Ui, Window};
use implot::{Plot, PlotText};
use implot::{Context, Plot, PlotText};
mod support;
@ -33,6 +33,7 @@ fn show_basic_plot(ui: &Ui) {
fn main() {
let system = support::init(file!());
let mut showing_demo = false;
let _plotcontext = Context::create(); // TODO(4bb4) use this as soon as things have been adapted
system.main_loop(move |_, ui| {
Window::new(im_str!("Text plots example"))
.size([430.0, 450.0], Condition::FirstUseEver)