-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic screencasts and release 0.1.2
- Loading branch information
1 parent
51a4923
commit 89efce1
Showing
9 changed files
with
203 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,7 @@ dependencies: | |
- bqplot | ||
- scipy | ||
- ipympl | ||
- voila=0.1.1 | ||
- voila=0.1.2 | ||
- ipympl | ||
- xleaflet=0.7.0 | ||
- xeus-cling=0.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Using voila with the C++ kernel and interactive widgets" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#include <iostream>\n", | ||
"#include <string>\n", | ||
"\n", | ||
"#include \"xwidgets/xoutput.hpp\"\n", | ||
"\n", | ||
"#include \"xleaflet/xmap.hpp\"\n", | ||
"#include \"xleaflet/xdraw_control.hpp\"\n", | ||
"#include \"xleaflet/xbasemaps.hpp\"\n", | ||
"\n", | ||
"namespace nl = nlohmann;" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "5c813cab5e09472ba3a2caa018a6c88d", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"A Jupyter widget" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"// Create map widget\n", | ||
"auto water_color = xlf::basemap({\"OpenStreetMap\", \"France\"});\n", | ||
"\n", | ||
"auto map = xlf::map_generator()\n", | ||
" .layers({water_color})\n", | ||
" .center({47, 363})\n", | ||
" .zoom(5)\n", | ||
" .finalize();\n", | ||
"\n", | ||
"map" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"// Create output widget to log draw events\n", | ||
"xw::output out;\n", | ||
"out" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"// Options for the draw control\n", | ||
"nl::json polyline_options = {\n", | ||
" {\"shapeOptions\", {\n", | ||
" {\"color\", \"#6bc2e5\"},\n", | ||
" {\"weight\", 8},\n", | ||
" {\"opacity\", 1.0}\n", | ||
" }}\n", | ||
"};\n", | ||
"\n", | ||
"nl::json polygon_options = {\n", | ||
" {\"shapeOptions\", {\n", | ||
" {\"fillColor\", \"#6be5c3\"},\n", | ||
" {\"color\", \"#6be5c3\"},\n", | ||
" {\"fillOpacity\", 1.0}\n", | ||
" }},\n", | ||
" {\"drawError\", {\n", | ||
" {\"color\", \"#dd253b\"},\n", | ||
" {\"message\", \"Oups!\"}\n", | ||
" }},\n", | ||
" {\"allowIntersection\", false}\n", | ||
"};\n", | ||
"\n", | ||
"nl::json circle_options = {\n", | ||
" {\"shapeOptions\", {\n", | ||
" {\"fillColor\", \"#efed69\"},\n", | ||
" {\"fillOpacity\", 1.0},\n", | ||
" {\"color\", \"#efed69\"}\n", | ||
" }}\n", | ||
"};\n", | ||
"\n", | ||
"nl::json rectangle_options = {\n", | ||
" {\"shapeOptions\", {\n", | ||
" {\"fillColor\", \"#fca45d\"},\n", | ||
" {\"fillOpacity\", 1.0},\n", | ||
" {\"color\", \"#fca45d\"}\n", | ||
" }}\n", | ||
"};" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"// Log last action\n", | ||
"void print_draw_event(std::string action, xeus::xjson geo_json)\n", | ||
"{\n", | ||
" // Capturing the stdout with the output widget \n", | ||
" auto guard = out.guard();\n", | ||
" std::cout << action << \" a \" \n", | ||
" << geo_json[\"geometry\"][\"type\"]\n", | ||
" << std::endl;\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"// Add the draw control and event logger\n", | ||
"auto draw_control = xlf::draw_control_generator()\n", | ||
" .polyline(polyline_options)\n", | ||
" .polygon(polygon_options)\n", | ||
" .circle(circle_options)\n", | ||
" .rectangle(rectangle_options)\n", | ||
" .finalize();\n", | ||
"\n", | ||
"draw_control.on_draw(print_draw_event);\n", | ||
"map.add_control(draw_control);" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "C++14", | ||
"language": "C++14", | ||
"name": "xcpp14" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "text/x-c++src", | ||
"file_extension": ".cpp", | ||
"mimetype": "text/x-c++src", | ||
"name": "c++", | ||
"version": "-std=c++14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters