diff --git a/CMakeLists.txt b/CMakeLists.txt index 4348486..9da12aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ if(NOT DEFINED ADD_DEMO) endif() if(NOT DEFINED USE_GUI) - set(USE_GUI OFF) + set(USE_GUI 0) endif() set(matplotlibcpp17_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/README.md b/README.md index aceaa7b..71bae66 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,9 @@ From [gallery/artist_animation/random_walk.cpp](https://github.com/soblin/matplo mkdir build; cd build; cmake .. ; make -j ``` -If you want to see the demo with `plt.show()`, add `-DUSE_GUI=ON` (by default it is `OFF`). Otherwise the executables will `plt.savefig()` to each source directory. Then `make ` runs all executables under that directory. +If you want to see the demo with `plt.show()`, add `-DUSE_GUI=1` (by default it is `0`). Otherwise the executables will `plt.savefig()` to `gallery/images` directory. + +`make ` runs all executables under that directory. ```bash make lines_bars_and_markers diff --git a/include/matplotlibcpp17/animation.h b/include/matplotlibcpp17/animation.h index 6f4aaa4..fbd4623 100644 --- a/include/matplotlibcpp17/animation.h +++ b/include/matplotlibcpp17/animation.h @@ -1,4 +1,11 @@ -namespace animation { +#ifndef MATPLOTLIBCPP17_ANIMATION_H +#define MATPLOTLIBCPP17_ANIMATION_H + +#include + +#include + +namespace matplotlibcpp17::animation { struct DECL_STRUCT_ATTR ArtistAnimation { ArtistAnimation(const pybind11::tuple &args, const pybind11::dict &kwargs) { @@ -14,4 +21,6 @@ struct DECL_STRUCT_ATTR ArtistAnimation { pybind11::object save; }; -} // namespace animation +} // namespace matplotlibcpp17::animation + +#endif /* MATPLOTLIBCPP17_ANIMATION_H */ diff --git a/include/matplotlibcpp17/axes.h b/include/matplotlibcpp17/axes.h index 394e8ef..823fb2c 100644 --- a/include/matplotlibcpp17/axes.h +++ b/include/matplotlibcpp17/axes.h @@ -1,4 +1,19 @@ -namespace axes { +#ifndef MATPLOTLIBCPP17_AXES_H +#define MATPLOTLIBCPP17_AXES_H + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace matplotlibcpp17::axes { struct DECL_STRUCT_ATTR Axes { Axes(pybind11::object axes) { @@ -248,4 +263,6 @@ Axes::scatter(const pybind11::tuple &args = pybind11::tuple(), return collections::PathCollection(obj); } -} // namespace axes +} // namespace matplotlibcpp17::axes + +#endif /* MATPLOTLIBCPP17_AXES_H */ diff --git a/include/matplotlibcpp17/collections.h b/include/matplotlibcpp17/collections.h index 295af33..6f73ba9 100644 --- a/include/matplotlibcpp17/collections.h +++ b/include/matplotlibcpp17/collections.h @@ -1,4 +1,13 @@ -namespace collections { +#ifndef MATPLOTLIBCPP17_COLLECTIONS_H +#define MATPLOTLIBCPP17_COLLECTIONS_H + +#include + +#include + +#include + +namespace matplotlibcpp17::collections { struct DECL_STRUCT_ATTR PathCollection { PathCollection(pybind11::object pathcollection) { @@ -47,4 +56,6 @@ struct DECL_STRUCT_ATTR PatchCollection { pybind11::object set_array; }; -} // namespace collections +} // namespace matplotlibcpp17::collections + +#endif /* MATPLOTLIBCPP17_COLLECTIONS_H */ diff --git a/include/matplotlibcpp17/common.h b/include/matplotlibcpp17/common.h index 3c3d785..5d1bb90 100644 --- a/include/matplotlibcpp17/common.h +++ b/include/matplotlibcpp17/common.h @@ -1,3 +1,6 @@ +#ifndef MATPLOTLIBCPP17_COMMON_H +#define MATPLOTLIBCPP17_COMMON_H + #define LOAD_VOID_ATTR(obj, mod) \ do { \ obj = mod.attr(#obj); \ @@ -9,3 +12,5 @@ } while (0) #define DECL_STRUCT_ATTR __attribute__((visibility("hidden"))) + +#endif /* MATPLOTLIBCPP17_COMMON_H */ diff --git a/include/matplotlibcpp17/container.h b/include/matplotlibcpp17/container.h index ef43940..7e109f4 100644 --- a/include/matplotlibcpp17/container.h +++ b/include/matplotlibcpp17/container.h @@ -1,4 +1,11 @@ -namespace container { +#ifndef MATPLOTLIBCPP17_CONTAINER_H +#define MATPLOTLIBCPP17_CONTAINER_H + +#include + +#include + +namespace matplotlibcpp17::container { struct DECL_STRUCT_ATTR BarContainer { BarContainer(pybind11::object bar_container) { self = bar_container; } @@ -9,4 +16,6 @@ struct DECL_STRUCT_ATTR BarContainer { pybind11::object unwrap() { return self; } }; -} // namespace container +} // namespace matplotlibcpp17::container + +#endif /* MATPLOTLIBCPP17_CONTAINER_H */ diff --git a/include/matplotlibcpp17/figure.h b/include/matplotlibcpp17/figure.h index 505ae3c..7e3cf7c 100644 --- a/include/matplotlibcpp17/figure.h +++ b/include/matplotlibcpp17/figure.h @@ -1,4 +1,13 @@ -namespace figure { +#ifndef MATPLOTLIBCPP17_FIGURE_H +#define MATPLOTLIBCPP17_FIGURE_H + +#include +#include +#include + +#include + +namespace matplotlibcpp17::figure { struct DECL_STRUCT_ATTR Figure { Figure(pybind11::object figure) { @@ -72,4 +81,6 @@ Figure::add_subplot(const pybind11::tuple &args = pybind11::tuple(), pybind11::object obj = add_subplot_attr(*args, **kwargs); return axes::Axes(obj); } -} // namespace figure +} // namespace matplotlibcpp17::figure + +#endif /* MATPLOTLIBCPP17_FIGURE_H */ diff --git a/include/matplotlibcpp17/gridspec.h b/include/matplotlibcpp17/gridspec.h index 76f1d2d..f37f953 100644 --- a/include/matplotlibcpp17/gridspec.h +++ b/include/matplotlibcpp17/gridspec.h @@ -1,4 +1,11 @@ -namespace gridspec { +#ifndef MATPLOTLIBCPP17_GRIDSPEC_H +#define MATPLOTLIBCPP17_GRIDSPEC_H + +#include + +#include + +namespace matplotlibcpp17::gridspec { struct DECL_STRUCT_ATTR SubplotSpec { SubplotSpec(pybind11::object subplotspec) { self = subplotspec; } @@ -29,4 +36,6 @@ struct DECL_STRUCT_ATTR GridSpec { pybind11::object gridspec_attr; }; -} // namespace gridspec +} // namespace matplotlibcpp17::gridspec + +#endif /* MATPLOTLIBCPP17_GRIDSPEC_H */ diff --git a/include/matplotlibcpp17/legend.h b/include/matplotlibcpp17/legend.h index 8eb3f22..e113a10 100644 --- a/include/matplotlibcpp17/legend.h +++ b/include/matplotlibcpp17/legend.h @@ -1,4 +1,11 @@ -namespace legend { +#ifndef MATPLOTLIBCPP17_LEGEND_H +#define MATPLOTLIBCPP17_LEGEND_H + +#include + +#include + +namespace matplotlibcpp17::legend { struct DECL_STRUCT_ATTR Legend { Legend(pybind11::object obj) { @@ -12,4 +19,6 @@ struct DECL_STRUCT_ATTR Legend { // for passing as python object pybind11::object unwrap() { return self; } }; -} // namespace legend +} // namespace matplotlibcpp17::legend + +#endif /* MATPLOTLIBCPP17_LEGEND_H */ diff --git a/include/matplotlibcpp17/matplotlibcpp17.h b/include/matplotlibcpp17/matplotlibcpp17.h index 8939ab8..fda7678 100644 --- a/include/matplotlibcpp17/matplotlibcpp17.h +++ b/include/matplotlibcpp17/matplotlibcpp17.h @@ -1,24 +1,18 @@ #ifndef MATPLOTLIBCPP_17_H #define MATPLOTLIBCPP_17_H -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace matplotlibcpp17 { -#include "common.h" - -#include "animation.h" -#include "text.h" -#include "container.h" -#include "collections.h" -#include "legend.h" -#include "quiver.h" -#include "axes.h" -#include "gridspec.h" -#include "figure.h" -#include "patches.h" -#include "pyplot.h" - template pybind11::tuple args_(Args &&... args) { return pybind11::make_tuple(std::forward(args)...); } diff --git a/include/matplotlibcpp17/patches.h b/include/matplotlibcpp17/patches.h index 5802d71..2a69c03 100644 --- a/include/matplotlibcpp17/patches.h +++ b/include/matplotlibcpp17/patches.h @@ -1,4 +1,11 @@ -namespace patches { +#ifndef MATPLOTLIBCPP17_PATCHES_H +#define MATPLOTLIBCPP17_PATCHES_H + +#include + +#include + +namespace matplotlibcpp17::patches { struct DECL_STRUCT_ATTR Circle { Circle(const pybind11::tuple &args = pybind11::tuple(), @@ -58,4 +65,6 @@ struct DECL_STRUCT_ATTR Wedge { pybind11::object wedge_attr; }; -} // namespace patches +} // namespace matplotlibcpp17::patches + +#endif /* MATPLOTLIBCPP17_PATCHES_H */ diff --git a/include/matplotlibcpp17/pyplot.h b/include/matplotlibcpp17/pyplot.h index 2080f09..ce98b8c 100644 --- a/include/matplotlibcpp17/pyplot.h +++ b/include/matplotlibcpp17/pyplot.h @@ -1,4 +1,15 @@ -namespace pyplot { +#ifndef MATPLOTLIBCPP17_PYPLOT_H +#define MATPLOTLIBCPP17_PYPLOT_H + +#include + +#include +#include +#include + +#include + +namespace matplotlibcpp17::pyplot { struct DECL_STRUCT_ATTR PyPlot { PyPlot() {} @@ -175,4 +186,6 @@ PyPlot import() { return g_pyplot; } -} // namespace pyplot +} // namespace matplotlibcpp17::pyplot + +#endif /* MATPLOTLIBCPP17_PYPLOT_H */ diff --git a/include/matplotlibcpp17/quiver.h b/include/matplotlibcpp17/quiver.h index 1233fef..4be6534 100644 --- a/include/matplotlibcpp17/quiver.h +++ b/include/matplotlibcpp17/quiver.h @@ -1,4 +1,11 @@ -namespace quiver { +#ifndef MATPLOTLIBCPP17_QUIVER_H +#define MATPLOTLIBCPP17_QUIVER_H + +#include + +#include + +namespace matplotlibcpp17::quiver { struct DECL_STRUCT_ATTR Quiver { Quiver(pybind11::object q) { self = q; } @@ -15,4 +22,6 @@ struct DECL_STRUCT_ATTR QuiverKey { pybind11::object unwrap() { return self; } }; -} // namespace quiver +} // namespace matplotlibcpp17::quiver + +#endif /* MATPLOTLIBCPP17_QUIVER_H */ diff --git a/include/matplotlibcpp17/text.h b/include/matplotlibcpp17/text.h index d401734..48a880a 100644 --- a/include/matplotlibcpp17/text.h +++ b/include/matplotlibcpp17/text.h @@ -1,4 +1,11 @@ -namespace text { +#ifndef MATPLOTLIBCPP17_TEXT_H +#define MATPLOTLIBCPP17_TEXT_H + +#include + +#include + +namespace matplotlibcpp17::text { struct DECL_STRUCT_ATTR Text { Text(pybind11::object text) { @@ -10,4 +17,6 @@ struct DECL_STRUCT_ATTR Text { pybind11::object set_rotation; }; -} // namespace text +} // namespace matplotlibcpp17::text + +#endif /* MATPLOTLIBCPP17_TEXT_H */