10#include <glibmm/i18n.h>
30namespace LivePathEffect {
37 , knot_color(0xff88ff00)
53 bool transform_stroke = prefs ? prefs->
getBool(
"/options/transform/stroke",
true) :
true;
54 if (transform_stroke) {
55 std::vector<Geom::Point>
result;
74 std::vector<Geom::Point> points;
91 g_warning(
"Broken powerstroke point at %f, I won't try to add that", offset_point[
X]);
101 for (
auto path : pathv) {
115 std::optional<Geom::PathVectorTime> pos = pathv.
nearestTime(p);
123std::vector<Geom::Point>
126 std::vector<Geom::Point> controlpoints;
132 controlpoints.emplace_back(new_pos,i[
Geom::Y]);
139 controlpoints.clear();
144 return controlpoints;
204 using namespace Geom;
212 static gint prev_index = 0;
224 for (
auto path : pathv) {
226 if (pathin == path) {
246 gint
index = std::floor(pos);
247 if (pos == begin || pos ==
end) {
252 bool bigjump =
false;
266 if (ps && ps->
not_jump && bigjump) {
307 if (state & GDK_CONTROL_MASK) {
308 if (state & GDK_ALT_MASK) {
311 if (vec.size() > 1) {
312 vec.erase(vec.begin() +
_index);
317 if ( pspa_ent && pspa_ent->
_pparam == this->_pparam ) {
318 if (pspa_ent->
_index > this->_index) {
336 if ( pspa_ent && pspa_ent->
_pparam == this->_pparam ) {
337 if (pspa_ent->
_index > this->_index) {
345 _(
"<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a "
346 "control point, <b>Ctrl+Alt+click</b> deletes it, <b>Shift+click</b> launches width dialog."),
350 }
else if ((state & GDK_ALT_MASK) || (state & GDK_SHIFT_MASK)) {
358 for (
unsigned int i = 0; i <
_vector.size(); ++i) {
361 _(
"<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a "
362 "control point, <b>Ctrl+Alt+click</b> deletes it, <b>Shift+click</b> launches width dialog."),
Conversion between Bezier control points and SBasis curves.
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
Adaptor that creates 2D functions from 1D ones.
size_type size() const
Get the number of paths in the vector.
std::optional< PathVectorTime > nearestTime(Point const &p, Coord *dist=NULL) const
Path & pathAt(Coord t, Coord *rest=NULL)
Sequence of contiguous curves, aka spline.
Function defined as discrete pieces.
output_type valueAt(double t) const
Two-dimensional point that doubles as a vector.
void param_set_and_write_new_value(std::vector< Geom::Point > const &new_vector)
std::vector< Geom::Point > _vector
void makeUndoDone(Glib::ustring message)
void knot_click(guint state) override
virtual void knot_set_offset(Geom::Point offset)
Geom::Point knot_get() const override
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, guint state) override
bool valid_index(unsigned int index) const
Checks whether the index falls within the size of the parameter's vector.
PowerStrokePointArrayParam * _pparam
void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) override
PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index)
Geom::Piecewise< Geom::D2< Geom::SBasis > > const & get_pwd2() const
Geom::Point knot_get(size_t index)
Geom::Piecewise< Geom::D2< Geom::SBasis > > last_pwd2_normal
Inkscape::CanvasItemCtrlShape knot_shape
void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item) override
Geom::Piecewise< Geom::D2< Geom::SBasis > > last_pwd2
PowerStrokePointArrayParam(const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect)
void recalculate_controlpoints(Geom::PathVector pv)
call this method to recalculate the controlpoints such that they stay at the same location relative t...
void set_oncanvas_looks(CanvasItemCtrlShape shape, uint32_t color)
Geom::Point knot_reposition(size_t index, Geom::PathVector pathv)
void set_pwd2(Geom::Piecewise< Geom::D2< Geom::SBasis > > const &pwd2_in, Geom::Piecewise< Geom::D2< Geom::SBasis > > const &pwd2_normal_in)
std::vector< Geom::Point > reverse_controlpoints(bool write)
call this method to recalculate the controlpoints when path is reversed.
~PowerStrokePointArrayParam() override
friend class PowerStrokePointArrayParamKnotHolderEntity
void param_transform_multiply(Geom::Affine const &postmul, bool) override
Geom::Piecewise< Geom::D2< Geom::SBasis > > const & get_pwd2_normal() const
Gtk::Widget * param_newWidget() override
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
void setDouble(Glib::ustring const &pref_path, double value)
Set a floating point value.
static void showDialog(SPDesktop *desktop, Geom::Point const &knotpoint, LivePathEffect::PowerStrokePointArrayParamKnotHolderEntity *knot)
Geom::Point snap_knot_position(Geom::Point const &p, unsigned state)
void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, Inkscape::CanvasItemCtrlType type=Inkscape::CANVAS_ITEM_CTRL_TYPE_DEFAULT, Glib::ustring const &name="unknown", char const *tip="", uint32_t color=0xffffff00)
KnotHolder * parent_holder
void knot_ungrabbed_handler(SPKnot *knot, unsigned int state)
std::list< KnotHolderEntity * > entity
void add(KnotHolderEntity *e)
Base class for visual SVG elements.
void hide()
Hide knot on its canvas.
constexpr Coord infinity()
Get a value representing infinity.
double Coord
Floating point type used to store coordinates.
size_t count_pathvector_curves(Geom::PathVector const &pathv)
Specific geometry functions for Inkscape, not provided my lib2geom.
Dialog for editing power strokes.
PowerStroke LPE effect, see lpe-powerstroke.cpp.
Various utility functions.
Bezier reverse(const Bezier &a)
Coord nearest_time(Point const &p, Curve const &c)
PathVector path_from_piecewise(Piecewise< D2< SBasis > > const &B, double tol, bool only_cubicbeziers=false)
Make a path from a d2 sbasis.
T dot(D2< T > const &a, D2< T > const &b)
size_t sp_calculate_origin(size_t i, Geom::PathVector pathv)
Helper class to stream background task notifications as a series of messages.
@ CANVAS_ITEM_CTRL_SHAPE_DIAMOND
@ CANVAS_ITEM_CTRL_TYPE_LPE
static cairo_user_data_key_t key
Piecewise function class.
Singleton class to access the preferences file in a convenient way.
Obsolete 2D SBasis function class.
two-dimensional geometric operators.
void sp_lpe_item_update_patheffect(SPLPEItem *lpeitem, bool wholetree, bool write, bool with_satellites)
Calls any registered handlers for the update_patheffect action.
Base class for live path effect items.