Skip to content

Commit

Permalink
Merge branch 'godardma-codac2_dev' into codac2_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Dec 6, 2024
2 parents 7ecc7cf + 519b781 commit 639b848
Show file tree
Hide file tree
Showing 38 changed files with 1,609 additions and 805 deletions.
49 changes: 49 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,53 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mathjax_stmaryrd.js

endif()

endif()

# User manual (Sphinx)

find_package(Sphinx)

if(NOT SPHINX_FOUND)

message(STATUS "Sphinx not found, will not be able to generate the manual.")

else()

# Includes CMake commands in config file:
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/manual/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/manual/conf.py)

set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/manual)
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/manual)

# Copying _static files of Sphinx to build directories
foreach(static_file ${CMAKE_CURRENT_SOURCE_DIR}/manual/_static/)
file(COPY ${static_file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/manual/_static/)
endforeach()

# Copying tmp files
foreach(static_file ${CMAKE_CURRENT_SOURCE_DIR}/manual/tmp/)
file(COPY ${static_file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/manual/tmp/)
endforeach()

# todo: the SPHINX_EXECUTABLE is already set by FindSphinx.cmake:
# check that it works without the following overload for Win and Linux:
if(WIN32)
set(SPHINX_EXECUTABLE "sphinx-build")
else()
set(SPHINX_EXECUTABLE "python3" "-msphinx")
endif()

add_custom_target(manual
COMMAND
${SPHINX_EXECUTABLE} -b html
# Specifying path to conf.py generated by CMake:
-c ${CMAKE_CURRENT_BINARY_DIR}/manual/
${SPHINX_SOURCE} ${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating the manual website using Sphinx")

install(DIRECTORY ${SPHINX_BUILD}/
DESTINATION share/manual/${CMAKE_PROJECT_NAME}
OPTIONAL)

endif()
10 changes: 10 additions & 0 deletions doc/manual/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
div.rst-content a:visited
{
color: #2980b9;
text-decoration: none;
}

div.rst-content li.toctree-l1 > a
{
font-weight: bold;
}
Empty file added doc/manual/_static/empty.txt
Empty file.
Empty file added doc/manual/_templates/empty.txt
Empty file.
40 changes: 40 additions & 0 deletions doc/manual/conf.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Codac'
copyright = 'Codac Team'
author = 'Codac Team'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx_rtd_theme',
]

templates_path = ['_templates']
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_static_path = ['_static']
html_theme = "sphinx_rtd_theme"
html_logo = "_static/logos/logo_codac.svg"

# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
'css/custom.css',
]

html_theme_options = {
'logo_only': True,
'display_version': True,
}
51 changes: 51 additions & 0 deletions doc/manual/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Codac manual
============


.. toctree::
:caption: Overview of Codac
:maxdepth: 3

Constraint programming and IA <http://codac.io>
The Codac framework <http://codac.io>
Target audience <http://codac.io>


.. toctree::
:caption: User manual
:maxdepth: 3

installation/index.rst
intervals/index.rst
linear/index.rst
functions/index.rst
tubes/index.rst
contractors/index.rst
separators/index.rst
pavers/index.rst
cn/index.rst
geometry/index.rst
ellipsoids/index.rst
topology/index.rst
visualization/index.rst
extensions/index.rst
seealso/index.rst
references/index.rst


.. toctree::
:caption: How-to guides
:maxdepth: 3

howto/robotics/index.rst
howto/geometry/index.rst
howto/dynamical/index.rst


.. toctree::
:caption: Development
:maxdepth: 3

Changelog <http://codac.io>
C++ API <http://codac.io>
Information for developers <http://codac.io>
Empty file added doc/manual/tmp/empty.txt
Empty file.
30 changes: 28 additions & 2 deletions examples/00_graphics/graphic_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
fig1.set_window_properties([50,50],[500,500]) # position, window size
fig1.set_axes(axis(0,[-10,10]), axis(1,[-10,10])) # (axis_id,[range_of_values_on_this_axis])
fig1.draw_box([[-1,1],[-1,1]],[Color.green(),Color.red(0.2)]) # drawing a green box with red opacity values inside
fig1.draw_circle([1,1],0.5,Color(255,155,5)) # drawing a circle at (1,1) of radius 0.5 with a custom RGB color
fig1.draw_circle([1,1],0.5,Color([255,155,5])) # drawing a circle at (1,1) of radius 0.5 with a custom RGB color
fig1.draw_ring([1,1],[4,6],Color.red()) # drawing a ring at (1,1) of radius [4,6] with a predefined red color

fig2 = Figure2D("My figure 2", GraphicOutput.VIBES | GraphicOutput.IPE)
Expand All @@ -44,5 +44,31 @@
fig2.draw_polygone([[2,4.5],[4,4.5],[4.2,3.5],[3.5,3]], [Color.none(),Color.green(0.5)])
fig2.draw_polyline([[-0.8,0],[0,1.5]], 0.2, [Color.red(),Color.black(0.3)])
fig2.draw_ellipse([1,1],[0.5,2], 0.2, [Color.blue(),Color.blue(0.3)])

# Colors
# predefined colors without and with opacity
fig2.draw_point([2,2], [Color.red(),Color.yellow(0.5)])
fig2.draw_box([[2.4,2.9],[2.4,2.9]],[Color("#da3907"),Color("#da390755")])
# HTML color without and with opacity
fig2.draw_box([[2.4,2.9],[2.4,2.9]],[Color("#da3907"),Color("#da390755")])
# HSV color without and with opacity
fig2.draw_box([[2.6,3.1],[2.6,3.1]],[Color([108,90,78],Model.HSV),Color([108,90,78,20],Model.HSV)])
# RGB color auto cast from list without and with opacity
fig2.draw_box([[2.,2.3],[2.6,2.9]],[[255,0,255],[255,0,255,100]])

fig3 = Figure2D("ColorMap figure", GraphicOutput.VIBES | GraphicOutput.IPE)
fig3.set_axes(axis(0,[-1,21]), axis(1,[-5.5,0.5]))
fig3.set_window_properties([800,250],[500,500])

cmap_haxby=ColorMap.haxby()
cmap_default=ColorMap.basic()
cmap_blue_tube=ColorMap.blue_tube()
cmap_red_tube=ColorMap.red_tube()
cmap_rainbow=ColorMap.rainbow()

for i in range (20):
ratio=i/20
fig3.draw_box([[i,i+1],[-1,0]],[Color.black(),cmap_haxby.color(ratio)])
fig3.draw_box([[i,i+1],[-2,-1]],[Color.black(),cmap_default.color(ratio)])
fig3.draw_box([[i,i+1],[-3,-2]],[Color.black(),cmap_blue_tube.color(ratio)])
fig3.draw_box([[i,i+1],[-4,-3]],[Color.black(),cmap_red_tube.color(ratio)])
fig3.draw_box([[i,i+1],[-5,-4]],[Color.black(),cmap_rainbow.color(ratio)])
File renamed without changes.
1 change: 1 addition & 0 deletions python/src/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
paver/codac2_py_drawwhilepaving.cpp

styles/codac2_py_Color.cpp
styles/codac2_py_ColorMap.cpp
styles/codac2_py_StyleProperties.cpp
)

Expand Down
2 changes: 2 additions & 0 deletions python/src/graphics/codac2_py_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void export_drawwhilepaving(py::module& m);

// styles
void export_Color(py::module& m);
void export_ColorMap(py::module& m);
void export_StyleProperties(py::module& m);


Expand All @@ -31,6 +32,7 @@ PYBIND11_MODULE(_graphics, m)

// styles
export_Color(m);
export_ColorMap(m);
export_StyleProperties(m);

// figures
Expand Down
10 changes: 10 additions & 0 deletions python/src/graphics/figures/codac2_py_Figure2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ void export_Figure2D(py::module& m)
VOID_FIGURE2D_DRAW_AUV_CONST_VECTOR_REF_FLOAT_CONST_STYLEPROPERTIES_REF,
"x"_a, "size"_a, "s"_a=StyleProperties())

// Pavings

.def("draw_paving", (void(Figure2D::*)(const PavingOut&,const StyleProperties&,const StyleProperties&))&Figure2D::draw_paving,
VOID_FIGURE2D_DRAW_PAVING_CONST_PAVINGOUT_REF_CONST_STYLEPROPERTIES_REF_CONST_STYLEPROPERTIES_REF,
"p"_a, "boundary_style"_a=StyleProperties::boundary(), "outside_style"_a=StyleProperties::outside())

.def("draw_paving", (void(Figure2D::*)(const PavingInOut&,const StyleProperties&,const StyleProperties&,const StyleProperties&))&Figure2D::draw_paving,
VOID_FIGURE2D_DRAW_PAVING_CONST_PAVINGINOUT_REF_CONST_STYLEPROPERTIES_REF_CONST_STYLEPROPERTIES_REF_CONST_STYLEPROPERTIES_REF,
"p"_a, "boundary_style"_a=StyleProperties::boundary(), "outside_style"_a=StyleProperties::outside(), "inside_style"_a=StyleProperties::inside())

;

py::class_<DefaultView> exported_default_view(m, "DefaultView", DEFAULTVIEW_MAIN);
Expand Down
57 changes: 45 additions & 12 deletions python/src/graphics/styles/codac2_py_Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,60 @@ using namespace codac2;
namespace py = pybind11;
using namespace pybind11::literals;


void export_Color(py::module& m)
{

py::enum_<Model>(m, "Model")
.value("RGB", Model::RGB)
.value("HSV", Model::HSV)
;

py::class_<Color> exported_color(m, "Color", COLOR_MAIN);
exported_color

.def(py::init<>(),COLOR_COLOR)

.def_readwrite("r", &Color::r)
.def_readwrite("g", &Color::g)
.def_readwrite("b", &Color::b)
.def_readwrite("alpha", &Color::alpha)
.def_readwrite("hex_str", &Color::hex_str)
.def(py::init<const std::array<float,3>&,Model>(),
COLOR_COLOR_CONST_ARRAY_FLOAT3_REF_MODEL,
"xyz"_a, "m_"_a=Model::RGB)

.def(py::init<int,int,int,int>(),
COLOR_COLOR_INT_INT_INT_INT,
"r"_a, "g"_a, "b"_a, "alpha"_a=255)

.def(py::init<float,float,float,float>(),
COLOR_COLOR_FLOAT_FLOAT_FLOAT_FLOAT,
"r"_a, "g"_a, "b"_a, "alpha"_a=1.)
.def(py::init<const std::array<float,4>&,Model>(),
COLOR_COLOR_CONST_ARRAY_FLOAT4_REF_MODEL,
"xyza"_a, "m_"_a=Model::RGB)

.def(py::init<const std::string&>(),
COLOR_COLOR_CONST_STRING_REF,
"hex_str"_a)

.def("model", &Color::model,
CONST_MODEL_REF_COLOR_MODEL_CONST)


// Other formats

.def("hex_str", &Color::hex_str,
STRING_COLOR_HEX_STR_CONST)

.def("vec", &Color::vec,
VECTOR_COLOR_VEC_CONST)

// Conversions

.def("rgb", &Color::rgb,
COLOR_COLOR_RGB_CONST)

.def("hsv", &Color::hsv,
COLOR_COLOR_HSV_CONST)

// Overload flux operator

.def("__str__", [](const Color& c) {
std::ostringstream oss;
oss << c;
return oss.str();
})

// Predefined colors

.def_static("none", &Color::none,
Expand Down Expand Up @@ -79,4 +110,6 @@ void export_Color(py::module& m)
STATIC_COLOR_COLOR_DARK_GRAY_FLOAT,
"alpha"_a=1.)
;

py::implicitly_convertible<py::list, Color>();
}
55 changes: 55 additions & 0 deletions python/src/graphics/styles/codac2_py_ColorMap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Codac binding (core)
* ----------------------------------------------------------------------------
* \date 2024
* \author Simon Rohou, Maël Godard
* \copyright Copyright 2024 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include <codac2_ColorMap.h>
#include "codac2_py_ColorMap_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):

using namespace std;
using namespace codac2;
namespace py = pybind11;
using namespace pybind11::literals;

void export_ColorMap(py::module& m)
{
py::class_<ColorMap> exported_colormap(m, "ColorMap", COLORMAP_MAIN);
exported_colormap

.def(py::init<Model>(),
COLORMAP_COLORMAP_MODEL,
"m"_a=Model::RGB)

.def("model", &ColorMap::model,
CONST_MODEL_REF_COLORMAP_MODEL_CONST)

.def("color", &ColorMap::color,
COLOR_COLORMAP_COLOR_FLOAT_CONST,
"r"_a)

// Predifined color maps

.def_static("haxby", &ColorMap::haxby,
STATIC_COLORMAP_COLORMAP_HAXBY)

.def_static("basic", &ColorMap::basic,
STATIC_COLORMAP_COLORMAP_BASIC)

.def_static("blue_tube", &ColorMap::blue_tube,
STATIC_COLORMAP_COLORMAP_BLUE_TUBE)

.def_static("red_tube", &ColorMap::red_tube,
STATIC_COLORMAP_COLORMAP_RED_TUBE)

.def_static("rainbow", &ColorMap::rainbow,
STATIC_COLORMAP_COLORMAP_RAINBOW)

;
}
Loading

0 comments on commit 639b848

Please sign in to comment.