a simple plotter for morden C++.
more shots in screenshots
.
This is a very simple plotter module, providing a drawing interface and a low-level rendering interface. It can be easily ported to various UI platforms by implement the render API.
irender.h an An abstract API of render,please implement a render.
isploter.h the abstract interface of sploter
sploter_data.h the interface of curves data.
- implement the
irender
API
!! Note !!
- render origin should be left-top
- render x increase from left to right
- render y increase from top to bottom
- init
std::unique_ptr<isploter> plot_
with asploter_factory::create()
pointer instance. - call
plot_->draw(render_->init(&ctx));
in the UIdraw(ctx)
function. - call
handle_events
andmouse_click
. - run and show the UI!
bool eplot::cursor(context const &ctx, point p, cursor_tracking status)
{
return plot_->handle_events(render_->init(&ctx), p.x, p.y, static_cast<isploter::cursor_tracking>(status));
}
bool eplot::click(const context &ctx, mouse_button btn)
{
tracker<>::click(ctx, btn);
return plot_->mouse_click(
render_->init(&ctx), btn.pos.x, btn.pos.y, btn.down, static_cast<isploter::mouse_key>(btn.state));
}
add link to splot library in cmake
target_link_libraries(splot_example splot::splot)
more see the examples
tree view
cpp
|_ splot
|_...(this project folder)
|_ elements
|_ fltk-1.4.x
|_ nanogui
There are some examples:
- elements
based on elements-ui ,smooth and interactivaty
- fltk
based on fltk-1.4.x(cmake support), no alpha channel for colors, delays event with doubled buffer.
- nanogui
based on nanogui(mitsuba-renderer branch)
There's an example for elements UI.
Please check the SPLOT_BUILD_EXAMPLES
option to be ON (default is ON).
- first download elements somewhere.
git clone https://github.com/cycfi/elements
- set the
ELEMENTS_ROOT
value to the path elements. It's set toexamples/CMakeLists.txt
set(ELEMENTS_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../elements")
- build with cmake
- x,y axes grid may NOT divided by 10, it's intend to auto fix the data ranges. Also try to make Zero(original XY) on the grid.
- axes may adjust to the data ranges
- optimize axes grid division
- port to FLTK
- port to nanogui
- make grid/legand/markers interactions available on screen