Skip to content

Commit b0effc0

Browse files
Merge pull request #55 from SylvainCorlay/update-xwidgets
Update xwidgets
2 parents a48630f + 1d6372e commit b0effc0

20 files changed

Lines changed: 466 additions & 588 deletions

β€Ž.appveyor.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install:
2929
- conda update -q conda
3030
- conda info -a
3131
# Install host dependencies
32-
- conda install xeus=0.21.1 cppzmq=4.3.0 xproperty=0.8.1 xwidgets=0.19.0 -c conda-forge
32+
- conda install xeus=0.23.3 cppzmq=4.3.0 xproperty=0.10.1 xwidgets=0.20.0 -c conda-forge
3333
# Install build dependencies
3434
- conda install gtest cmake -c conda-forge
3535
- cmake -G "NMake Makefiles" -D CMAKE_INSTALL_PREFIX=%MINICONDA%\\LIBRARY -DBUILD_TESTS=ON .

β€Ž.travis.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ install:
1818
- conda config --set always_yes yes --set changeps1 no
1919
- conda update -q conda
2020
# Install host dependencies
21-
- conda install xeus=0.21.1 cppzmq=4.3.0 xproperty=0.8.1 xwidgets=0.19.0 -c conda-forge
21+
- conda install xeus=0.23.3 cppzmq=4.3.0 xproperty=0.10.1 xwidgets=0.20.0 -c conda-forge
2222
# Install build dependencies
2323
- conda install cmake
2424
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then

β€ŽCMakeLists.txtβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ message(STATUS "xplot binary version: v${XPLOT_BINARY_VERSION}")
7474

7575
find_package(cppzmq 4.3.0 REQUIRED)
7676
find_package(xtl 0.6.5 REQUIRED)
77-
find_package(xeus 0.21.1 REQUIRED)
78-
find_package(xwidgets 0.19.0 REQUIRED)
77+
find_package(xeus 0.23.3 REQUIRED)
78+
find_package(xwidgets 0.20.0 REQUIRED)
79+
find_package(xproperty 0.10.1 REQUIRED)
7980

8081
# Source files
8182
# ============

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ All the dependencies of xplot are available for the conda package manager.
7979

8080
| `xplot` | `xwidgets` | `xeus` |
8181
|---------|-------------|-----------------|
82-
| master | ~0.19.0 | >=0.21.1,<0.22 |
82+
| master | ~0.20.0 | >=0.23.3,<0.24 |
8383
| 0.14.0 | ~0.19.0 | >=0.21.1,<0.22 |
8484
| 0.13.0 | ~0.18.0 | >=0.20.0,<0.21 |
8585
| 0.12.0 | ~0.17.0 | >=0.19.1,<0.20 |

β€Ženvironment.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ channels:
44
- conda-forge
55
dependencies:
66
- xplot=0.14.0
7-
- xeus-cling=0.7.1
7+
- xeus-cling=0.8.1
88
- bqplot=0.11.5
99
- widgetsnbextension >=3.0.0

β€Žinclude/xplot/xaxes.hppβ€Ž

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <utility>
1414
#include <vector>
1515

16+
#include "nlohmann/json.hpp"
17+
1618
#include "xtl/xoptional.hpp"
1719

1820
#include "xwidgets/xeither.hpp"
@@ -21,6 +23,8 @@
2123
#include "xscales.hpp"
2224
#include "xinteracts.hpp"
2325

26+
namespace nl = nlohmann;
27+
2428
namespace xpl
2529
{
2630
/********************
@@ -38,8 +42,8 @@ namespace xpl
3842
using scale_type = xw::xholder<xscale>;
3943
using tick_values_type = std::vector<double>;
4044

41-
void serialize_state(xeus::xjson&, xeus::buffer_sequence&) const;
42-
void apply_patch(const xeus::xjson&, const xeus::buffer_sequence&);
45+
void serialize_state(nl::json&, xeus::buffer_sequence&) const;
46+
void apply_patch(const nl::json&, const xeus::buffer_sequence&);
4347

4448
XPROPERTY(std::string, derived_type, orientation, "horizontal", XEITHER("horizontal", "vertical"));
4549
XPROPERTY(xtl::xoptional<std::string>, derived_type, side, xtl::missing<std::string>(), XEITHER_OPTIONAL("bottom", "top", "left", "right"));
@@ -48,8 +52,8 @@ namespace xpl
4852
XPROPERTY(xtl::xoptional<std::string>, derived_type, tick_format);
4953
XPROPERTY(scale_type, derived_type, scale);
5054
XPROPERTY(xtl::xoptional<int>, derived_type, num_ticks);
51-
XPROPERTY(::xeus::xjson, derived_type, tick_values, xeus::xjson::array());
52-
XPROPERTY(::xeus::xjson, derived_type, offset, ::xeus::xjson::object());
55+
XPROPERTY(::nl::json, derived_type, tick_values, nl::json::array());
56+
XPROPERTY(::nl::json, derived_type, offset, ::nl::json::object());
5357
XPROPERTY(std::string, derived_type, label_location, "middle", XEITHER("middle", "start", "end"));
5458
XPROPERTY(xtl::xoptional<color_type>, derived_type, label_color);
5559
XPROPERTY(xtl::xoptional<color_type>, derived_type, grid_color);
@@ -77,8 +81,6 @@ namespace xpl
7781

7882
using axis = xw::xmaterialize<xaxis>;
7983

80-
using axis_generator = xw::xgenerator<xaxis>;
81-
8284
template <class T, class R = void>
8385
struct enable_xaxis
8486
{
@@ -100,8 +102,8 @@ namespace xpl
100102
using base_type = xaxis<D>;
101103
using derived_type = D;
102104

103-
void serialize_state(xeus::xjson&, xeus::buffer_sequence&) const;
104-
void apply_patch(const xeus::xjson&, const xeus::buffer_sequence&);
105+
void serialize_state(nl::json&, xeus::buffer_sequence&) const;
106+
void apply_patch(const nl::json&, const xeus::buffer_sequence&);
105107

106108
protected:
107109

@@ -123,14 +125,12 @@ namespace xpl
123125

124126
using color_axis = xw::xmaterialize<xcolor_axis>;
125127

126-
using color_axis_generator = xw::xgenerator<xcolor_axis>;
127-
128128
/***********************
129129
* axis implementation *
130130
***********************/
131131

132132
template <class D>
133-
inline void xaxis<D>::apply_patch(const xeus::xjson& patch, const xeus::buffer_sequence& buffers)
133+
inline void xaxis<D>::apply_patch(const nl::json& patch, const xeus::buffer_sequence& buffers)
134134
{
135135
using xw::set_property_from_patch;
136136
base_type::apply_patch(patch, buffers);
@@ -153,26 +153,26 @@ namespace xpl
153153
}
154154

155155
template <class D>
156-
inline void xaxis<D>::serialize_state(xeus::xjson& state, xeus::buffer_sequence& buffers) const
156+
inline void xaxis<D>::serialize_state(nl::json& state, xeus::buffer_sequence& buffers) const
157157
{
158-
using xw::set_patch_from_property;
158+
using xw::xwidgets_serialize;
159159
base_type::serialize_state(state, buffers);
160160

161-
set_patch_from_property(orientation, state, buffers);
162-
set_patch_from_property(side, state, buffers);
163-
set_patch_from_property(label, state, buffers);
164-
set_patch_from_property(tick_format, state, buffers);
165-
set_patch_from_property(scale, state, buffers);
166-
set_patch_from_property(num_ticks, state, buffers);
167-
set_patch_from_property(tick_values, state, buffers);
168-
set_patch_from_property(offset, state, buffers);
169-
set_patch_from_property(label_location, state, buffers);
170-
set_patch_from_property(label_color, state, buffers);
171-
set_patch_from_property(grid_lines, state, buffers);
172-
set_patch_from_property(grid_color, state, buffers);
173-
set_patch_from_property(color, state, buffers);
174-
set_patch_from_property(label_offset, state, buffers);
175-
set_patch_from_property(visible, state, buffers);
161+
xwidgets_serialize(orientation, state["orientation"], buffers);
162+
xwidgets_serialize(side, state["side"], buffers);
163+
xwidgets_serialize(label, state["label"], buffers);
164+
xwidgets_serialize(tick_format, state["tick_format"], buffers);
165+
// xwidgets_serialize(scale, state["scale"], buffers);
166+
xwidgets_serialize(num_ticks, state["num_ticks"], buffers);
167+
xwidgets_serialize(tick_values, state["tick_values"], buffers);
168+
xwidgets_serialize(offset, state["offset"], buffers);
169+
xwidgets_serialize(label_location, state["label_location"], buffers);
170+
xwidgets_serialize(label_color, state["label_color"], buffers);
171+
xwidgets_serialize(grid_lines, state["grid_lines"], buffers);
172+
xwidgets_serialize(grid_color, state["grid_color"], buffers);
173+
xwidgets_serialize(color, state["color"], buffers);
174+
xwidgets_serialize(label_offset, state["label_offset"], buffers);
175+
xwidgets_serialize(visible, state["visible"], buffers);
176176
}
177177

178178
template <class D>
@@ -217,16 +217,16 @@ namespace xpl
217217
******************************/
218218

219219
template <class D>
220-
inline void xcolor_axis<D>::apply_patch(const xeus::xjson& patch, const xeus::buffer_sequence& buffers)
220+
inline void xcolor_axis<D>::apply_patch(const nl::json& patch, const xeus::buffer_sequence& buffers)
221221
{
222222
using xw::set_property_from_patch;
223223
base_type::apply_patch(patch, buffers);
224224
}
225225

226226
template <class D>
227-
inline void xcolor_axis<D>::serialize_state(xeus::xjson& state, xeus::buffer_sequence& buffers) const
227+
inline void xcolor_axis<D>::serialize_state(nl::json& state, xeus::buffer_sequence& buffers) const
228228
{
229-
using xw::set_patch_from_property;
229+
using xw::xwidgets_serialize;
230230
base_type::serialize_state(state, buffers);
231231
}
232232

@@ -269,13 +269,9 @@ namespace xpl
269269
#ifndef _WIN32
270270
extern template class xw::xmaterialize<xpl::xaxis>;
271271
extern template class xw::xtransport<xw::xmaterialize<xpl::xaxis>>;
272-
extern template class xw::xgenerator<xpl::xaxis>;
273-
extern template class xw::xtransport<xw::xgenerator<xpl::xaxis>>;
274272

275273
extern template class xw::xmaterialize<xpl::xcolor_axis>;
276274
extern template class xw::xtransport<xw::xmaterialize<xpl::xcolor_axis>>;
277-
extern template class xw::xgenerator<xpl::xcolor_axis>;
278-
extern template class xw::xtransport<xw::xgenerator<xpl::xcolor_axis>>;
279275
#endif
280276

281277
#endif

β€Žinclude/xplot/xboxed_container.hppβ€Ž

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
#ifndef XBOXED_CONTAINER_HPP
1010
#define XBOXED_CONTAINER_HPP
1111

12+
#include <algorithm>
1213
#include <string>
14+
#include <utility>
15+
#include <vector>
16+
17+
#include "nlohmann/json.hpp"
1318

1419
#include "xeus/xjson.hpp"
1520

21+
namespace nl = nlohmann;
22+
1623
namespace xpl
1724
{
1825
/********************************
@@ -56,9 +63,9 @@ namespace xpl
5663
};
5764

5865
template <class C>
59-
void to_json(xeus::xjson& j, const xboxed_container<C>& o);
66+
void to_json(nl::json& j, const xboxed_container<C>& o);
6067
template <class C>
61-
void from_json(const xeus::xjson& j, xboxed_container<C>& o);
68+
void from_json(const nl::json& j, xboxed_container<C>& o);
6269

6370
template <class T>
6471
std::string type_to_string() noexcept;
@@ -122,15 +129,15 @@ namespace xpl
122129
}
123130

124131
template <class C>
125-
inline void to_json(xeus::xjson& j, const xboxed_container<C>& o)
132+
inline void to_json(nl::json& j, const xboxed_container<C>& o)
126133
{
127134
using container_type = typename xboxed_container<C>::container_type;
128135
j["values"] = container_type(o);
129136
j["type"] = type_to_string<typename container_type::value_type>();
130137
}
131138

132139
template <class C>
133-
inline void from_json(const xeus::xjson& j, xboxed_container<C>& o)
140+
inline void from_json(const nl::json& j, xboxed_container<C>& o)
134141
{
135142
using container_type = typename xboxed_container<C>::container_type;
136143
container_type& values = o;

β€Žinclude/xplot/xfigure.hppβ€Ž

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <vector>
1414
#include <utility>
1515

16+
#include "nlohmann/json.hpp"
17+
18+
#include "xproperty/xjson.hpp"
19+
1620
#include "xwidgets/xeither.hpp"
1721
#include "xwidgets/xwidget.hpp"
1822

@@ -21,6 +25,8 @@
2125
#include "xplot_config.hpp"
2226
#include "xscales.hpp"
2327

28+
namespace nl = nlohmann;
29+
2430
namespace xpl
2531
{
2632
/***********************
@@ -40,20 +46,20 @@ namespace xpl
4046
using scales_type = xw::xholder<xscale>;
4147
using interaction_type = xw::xholder<xinteraction>;
4248

43-
void serialize_state(xeus::xjson&, xeus::buffer_sequence&) const;
44-
void apply_patch(const xeus::xjson&, const xeus::buffer_sequence&);
49+
void serialize_state(nl::json&, xeus::buffer_sequence&) const;
50+
void apply_patch(const nl::json&, const xeus::buffer_sequence&);
4551

4652
XPROPERTY(std::string, derived_type, title);
4753
XPROPERTY(axes_type, derived_type, axes);
4854
XPROPERTY(marks_type, derived_type, marks);
4955
XPROPERTY(xtl::xoptional<interaction_type>, derived_type, interaction);
5056
XPROPERTY(scales_type, derived_type, scale_x);
5157
XPROPERTY(scales_type, derived_type, scale_y);
52-
XPROPERTY(::xeus::xjson, derived_type, title_style);
53-
XPROPERTY(::xeus::xjson, derived_type, background_style);
58+
XPROPERTY(::nl::json, derived_type, title_style);
59+
XPROPERTY(::nl::json, derived_type, background_style);
5460
XPROPERTY(double, derived_type, min_aspect_ratio, 1.);
5561
XPROPERTY(double, derived_type, max_aspect_ratio, 6.);
56-
XPROPERTY(::xeus::xjson, derived_type, fig_margin, xeus::xjson({
62+
XPROPERTY(::nl::json, derived_type, fig_margin, nl::json({
5763
{"top", 60}, {"bottom", 60}, {"left", 60}, {"right", 60}
5864
}));
5965
XPROPERTY(double, derived_type, padding_x, 0.);
@@ -104,8 +110,6 @@ namespace xpl
104110

105111
using figure = xw::xmaterialize<xfigure>;
106112

107-
using figure_generator = xw::xgenerator<xfigure>;
108-
109113
template <class T, class R = void>
110114
struct enable_xfigure
111115
{
@@ -120,7 +124,7 @@ namespace xpl
120124
**************************/
121125

122126
template <class D>
123-
inline void xfigure<D>::apply_patch(const xeus::xjson& patch, const xeus::buffer_sequence& buffers)
127+
inline void xfigure<D>::apply_patch(const nl::json& patch, const xeus::buffer_sequence& buffers)
124128
{
125129
using xw::set_property_from_patch;
126130
base_type::apply_patch(patch, buffers);
@@ -143,26 +147,26 @@ namespace xpl
143147
}
144148

145149
template <class D>
146-
inline void xfigure<D>::serialize_state(xeus::xjson& state, xeus::buffer_sequence& buffers) const
150+
inline void xfigure<D>::serialize_state(nl::json& state, xeus::buffer_sequence& buffers) const
147151
{
148-
using xw::set_patch_from_property;
152+
using xw::xwidgets_serialize;
149153
base_type::serialize_state(state, buffers);
150154

151-
set_patch_from_property(title, state, buffers);
152-
set_patch_from_property(axes, state, buffers);
153-
set_patch_from_property(marks, state, buffers);
154-
set_patch_from_property(interaction, state, buffers);
155-
set_patch_from_property(scale_x, state, buffers);
156-
set_patch_from_property(scale_y, state, buffers);
157-
set_patch_from_property(title_style, state, buffers);
158-
set_patch_from_property(background_style, state, buffers);
159-
set_patch_from_property(min_aspect_ratio, state, buffers);
160-
set_patch_from_property(max_aspect_ratio, state, buffers);
161-
set_patch_from_property(fig_margin, state, buffers);
162-
set_patch_from_property(padding_x, state, buffers);
163-
set_patch_from_property(padding_y, state, buffers);
164-
set_patch_from_property(legend_location, state, buffers);
165-
set_patch_from_property(animation_duration, state, buffers);
155+
xwidgets_serialize(title, state["title"], buffers);
156+
xwidgets_serialize(axes, state["axes"], buffers);
157+
xwidgets_serialize(marks, state["marks"], buffers);
158+
xwidgets_serialize(interaction, state["interaction"], buffers);
159+
xwidgets_serialize(scale_x, state["scale_x"], buffers);
160+
xwidgets_serialize(scale_y, state["scale_y"], buffers);
161+
xwidgets_serialize(title_style, state["title_style"], buffers);
162+
xwidgets_serialize(background_style, state["background_style"], buffers);
163+
xwidgets_serialize(min_aspect_ratio, state["min_aspect_ratio"], buffers);
164+
xwidgets_serialize(max_aspect_ratio, state["max_aspect_ratio"], buffers);
165+
xwidgets_serialize(fig_margin, state["fig_margin"], buffers);
166+
xwidgets_serialize(padding_x, state["padding_x"], buffers);
167+
xwidgets_serialize(padding_y, state["padding_y"], buffers);
168+
xwidgets_serialize(legend_location, state["legend_location"], buffers);
169+
xwidgets_serialize(animation_duration, state["animation_duration"], buffers);
166170
}
167171

168172
template <class D>
@@ -293,20 +297,20 @@ namespace xpl
293297
template <class D>
294298
inline void xfigure<D>::send_marks_patch() const
295299
{
296-
using xw::set_patch_from_property;
297-
xeus::xjson state;
300+
using xw::xwidgets_serialize;
301+
nl::json state;
298302
xeus::buffer_sequence buffers;
299-
set_patch_from_property(marks, state, buffers);
303+
xwidgets_serialize(marks, state["marks"], buffers);
300304
this->send_patch(std::move(state), std::move(buffers));
301305
}
302306

303307
template <class D>
304308
inline void xfigure<D>::send_axes_patch() const
305309
{
306-
using xw::set_patch_from_property;
307-
xeus::xjson state;
310+
using xw::xwidgets_serialize;
311+
nl::json state;
308312
xeus::buffer_sequence buffers;
309-
set_patch_from_property(axes, state, buffers);
313+
xwidgets_serialize(axes, state["axes"], buffers);
310314
this->send_patch(std::move(state), std::move(buffers));
311315
}
312316
}
@@ -319,9 +323,6 @@ namespace xpl
319323
extern template class xw::xmaterialize<xpl::xfigure>;
320324
extern template class xw::xtransport<xw::xmaterialize<xpl::xfigure>>;
321325
extern template xw::xmaterialize<xpl::xfigure>::xmaterialize();
322-
extern template class xw::xgenerator<xpl::xfigure>;
323-
extern template xw::xgenerator<xpl::xfigure>::xgenerator();
324-
extern template class xw::xtransport<xw::xgenerator<xpl::xfigure>>;
325326
#endif
326327

327328
#endif

0 commit comments

Comments
 (0)