Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to infobox #85

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if(ACTSVG_BUILD_TESTING OR ACTSVG_BUILD_EXAMPLES)
endif()
endif()

option(ACTSVG_BUILD_PYTHON_BINDINGS "Build the python bindings of ACTSVG" OFF)
option(ACTSVG_BUILD_PYTHON_BINDINGS "Build the python bindings of ACTSVG" ON)
asalzburger marked this conversation as resolved.
Show resolved Hide resolved
if(ACTSVG_BUILD_PYTHON_BINDINGS)
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development)
option(
Expand Down
22 changes: 22 additions & 0 deletions core/include/actsvg/core/draw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,28 @@ svg::object connected_text(
const style::transform &transform_, const svg::object &object_,
const std::vector<std::string> &highlight_ = {"mouseover", "mouseout"});

/** Draw a image object - connected
*
* @param id_ is the image object id
* @param href_ is the image object href field
* @param height_ is the image object height field
* @param width_ is the image object width field
* @param x_ is the image object x field
* @param y_ is the image object y field
* @param object_ is the connected object
* @param highlight_ are the hightlighting options
* @param onerror_ is the image object onerror field
*
* @return an svg object with highlight connection
*
**/
svg::object image_box(const std::string &id_, const std::string &href_,
const std::string &height_, const std::string &width_,
const std::string &x_, const std::string &y_,
const svg::object &object_,
const std::vector<std::string> &highlight_,
const std::string &onerror_);

/** Draw a text object - connected
*
* @param id_ is the text object id
Expand Down
53 changes: 53 additions & 0 deletions core/src/core/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,58 @@ svg::object connected_text(const std::string &id_, const point2 &p_,
return t;
}

svg::object image_box(const std::string &id_, const std::string &href_,
const std::string &height_, const std::string &width_,
const std::string &x_, const std::string &y_,
const svg::object &object_,
const std::vector<std::string> &highlight_,
const std::string &onerror_) {
svg::object i;

i._tag = "g";
i._id = id_;

// Image box object
svg::object imgb;
imgb._tag = "image";
imgb._attribute_map["href"] = href_;
imgb._attribute_map["height"] = height_;
imgb._attribute_map["width"] = width_;
imgb._attribute_map["x"] = x_;
imgb._attribute_map["y"] = y_;
imgb._attribute_map["onerror"] = onerror_;

i.add_object(imgb);
// Connect it
if (object_.is_defined()) {
i._attribute_map["display"] = "none";

svg::object on;
on._tag = "animate";
on._attribute_map["fill"] = "freeze";
on._attribute_map["attributeName"] = "display";
on._attribute_map["from"] = "none";
on._attribute_map["to"] = "block";
on._attribute_map["begin"] = object_._id + __d + highlight_[1];
on._attribute_map["fill-opacity"] = 1;

svg::object off;

off._tag = "animate";
off._attribute_map["fill"] = "freeze";
off._attribute_map["attributeName"] = "display";
off._attribute_map["to"] = "none";
off._attribute_map["from"] = "block";
off._attribute_map["begin"] = object_._id + __d + highlight_[0];

// Store the animation
i._sub_objects.push_back(on);
i._sub_objects.push_back(off);
}

return i;
}

svg::object connected_info_box(
const std::string &id_, const point2 &p_, const std::string &title_,
const style::fill &title_fill_, const style::font &title_font_,
Expand Down Expand Up @@ -507,6 +559,7 @@ svg::object connected_info_box(
on._attribute_map["from"] = "none";
on._attribute_map["to"] = "block";
on._attribute_map["begin"] = object_._id + __d + highlight_[1];
on._attribute_map["fill-opacity"] = 1;

svg::object off;

Expand Down
2 changes: 2 additions & 0 deletions python/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ void add_core_module(context& ctx) {
/// Draw a connected info box
d.def("connected_info_box", &draw::connected_info_box);

d.def("image_box", &draw::image_box);

/// Draw a cartesian grid
d.def("cartesian_grid", &draw::cartesian_grid);

Expand Down
Loading