21#include <glibmm/i18n.h>
38 Glib::ustring
const &
name,
39 char const *tip, uint32_t color)
90 if (state & GDK_SHIFT_MASK) {
98 std::cerr <<
"No desktop" << std::endl;
101 std::cerr <<
"No named view" << std::endl;
110 return s * i2dt.inverse();
115 if (state & GDK_SHIFT_MASK) {
131 return s * i2d.inverse();
160 return transform ? pt * pat->getTransform() : pt;
182 auto i2p = pat->getTransform().
inverse();
185 return (loc * d2i * i2p *
scale.inverse()).floor();
206 _quad->lower_to_bottom();
207 _quad->set_fill(0x00000000);
208 _quad->set_stroke(0x808080ff);
209 _quad->set_inverted(
true);
210 _quad->set_visible(
false);
219 _quad->set_visible(
true);
231 if (state & GDK_CONTROL_MASK) {
232 if (std::abs((p -
origin).x()) > std::abs((p -
origin).y())) {
233 p_snapped.y() =
origin.y();
235 p_snapped.x() =
origin.x();
240 auto const q = p_snapped -
knot_get();
257 int const snaps = prefs->getInt(
"/options/rotationsnapsperpi/value", 12);
261 double theta = atan2(p - transform_origin);
262 double theta_old = atan2(
knot_get() - transform_origin);
264 if (state & GDK_CONTROL_MASK) {
266 double snaps_radian = M_PI / snaps;
267 theta = std::round(theta / snaps_radian) * snaps_radian;
305 using namespace Geom;
316 Affine new_transform = (state & GDK_CONTROL_MASK) ?
Scale((scale_x + scale_y) * 0.5)
317 :
Scale(scale_x, scale_y);
321 auto const new_uncompensated_origin =
_get_pos(0, 0,
false) * new_transform;
359 auto pitch = hatch->pitch();
367 if (state & GDK_CONTROL_MASK) {
368 if (std::abs((p -
origin).x()) > std::abs((p -
origin).y())) {
369 p_snapped.y() =
origin.y();
371 p_snapped.x() =
origin.x();
376 auto const q = p_snapped -
knot_get();
386 int const snaps = prefs->
getInt(
"/options/rotationsnapsperpi/value", 12);
392 double theta = atan2(p - transform_origin);
393 double theta_old = atan2(
knot_get() - transform_origin);
395 if (state & GDK_CONTROL_MASK) {
397 double snaps_radian = M_PI / snaps;
398 theta = std::round(theta / snaps_radian) * snaps_radian;
421 double hatch_pitch = hatch->
pitch();
422 if (state & GDK_CONTROL_MASK) {
441 if (state & GDK_CONTROL_MASK) {
442 if (std::abs((p -
origin).x()) > std::abs((p -
origin).y())) {
458 if (!filter->width._set) {
461 if (!filter->height._set) {
464 if (!filter->x._set) {
467 if (!filter->y._set) {
472 float x_a = filter->width.computed;
473 float y_a = filter->height.computed;
474 filter->height.scale(new_bbox.height() / orig_bbox->height());
475 filter->width.scale(new_bbox.width() / orig_bbox->width());
476 float x_b = filter->width.computed;
477 float y_b = filter->height.computed;
478 filter->x.set(filter->x.unit, filter->x.computed + x_a - x_b);
479 filter->y.set(filter->y.unit, filter->y.computed + y_a - y_b);
481 filter->height.scale(new_bbox.height() / orig_bbox->height());
482 filter->width.scale(new_bbox.width() / orig_bbox->width());
484 filter->auto_region =
false;
485 filter->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
498 return _topleft ? r->min() : r->max();
509 _line->set_z_position(0);
510 _line->set_stroke(0x0033cccc);
511 _line->set_visible(
false);
521 if (
auto blur =
_blur()) {
524 _watch_blur = blur->connectModified([
this] (
auto item,
unsigned flags) {
530 _line->set_visible(
false);
539 for (
auto &primitive : filter->children) {
540 if (
auto blur = cast<SPGaussianBlur>(&primitive)) {
568 auto dev = blur->get_std_deviation();
571 double x = dev.getNumber();
572 double y = dev.getOptNumber(
true);
579 _line->set_visible(
true);
580 _line->set_coords(p0 * tr, p1 * tr);
595 if (state & GDK_CONTROL_MASK) {
596 if (state & GDK_SHIFT_MASK) {
608 blur->set_deviation(dev);
pair< double, double > Point
void on_created() override
CanvasItemPtr< Inkscape::CanvasItemCurve > _line
sigc::scoped_connection _watch_blur
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
SPGaussianBlur * _blur() const
sigc::scoped_connection _watch_filter
void update_knot() override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
bool _topleft
true for top left point, false for bottom right
3x3 matrix representing an affine transformation.
Coord descrim2() const
Calculate the square of the descriminant.
Affine inverse() const
Compute the inverse matrix.
Affine withoutTranslation() const
Two-dimensional point with integer coordinates.
Two-dimensional point that doubles as a vector.
bool isFinite() const
Check whether both coordinates are finite.
Coord length() const
Compute the distance from origin.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
Axis aligned, non-empty rectangle.
Rotation around the origin.
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
bool knot_missing() const override
bool _fill
true if the entity tracks fill, false for stroke
void makeUndoDone(Glib::ustring message)
Preference storage class.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
Geom::Point getDirection() const
Geom::Point getPoint() const
virtual void on_created()
sigc::scoped_connection _ungrabbed_connection
Geom::Point snap_knot_position(Geom::Point const &p, unsigned state)
sigc::scoped_connection _click_connection
sigc::scoped_connection _moved_connection
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
Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, unsigned state)
virtual ~KnotHolderEntity()
virtual void update_knot()
virtual Geom::Point knot_get() const =0
sigc::scoped_connection _mousedown_connection
void knot_mousedown_handler(SPKnot *knot, unsigned int state)
Geom::Affine getEditTransform() const
void knot_moved_handler(SPKnot *knot, Geom::Point const &p, unsigned int state)
void knot_ungrabbed_handler(SPKnot *knot, unsigned int state)
void knot_clicked_handler(SPKnot *knot, unsigned int state)
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Inkscape::LivePathEffect::Effect * _effect
float getOptNumber(bool or_num=false) const
void setOptNumber(float optnum)
void setNumber(float num)
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Affine _cached_inverse_linear
Geom::Point _cached_diagonal
Geom::Point knot_get() const override
void knot_grabbed(Geom::Point const &grab_pos, unsigned state) override
Store pattern geometry info when the scale knot is first grabbed.
static constexpr double MAX_REPETITIONS
Maximum number of pattern repetitons allowed in an item.
Geom::Point _cached_origin
Geom::Affine _cached_transform
void on_created() override
void update_knot() override
CanvasItemPtr< Inkscape::CanvasItemQuad > _quad
Extra visual element to show the pattern editing area.
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
bool _fill
true if the entity tracks fill, false for stroke
Geom::Point _get_pos(double x, double y, bool transform=true) const
Returns the position based on the pattern's origin, shifted by the percent x/y of its size.
void on_created() override
void update_knot() override
bool knot_missing() const override
Geom::IntPoint offset_to_cell(Geom::Point loc) const
bool set_item_clickpos(Geom::Point loc) override
SPPattern * _pattern() const
To do: update description of desktop.
Inkscape::CanvasItemGroup * getCanvasControls() const
SPNamedView * getNamedView() const
Geom::Affine const & hatchTransform() const
Base class for visual SVG elements.
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
Geom::OptRect documentVisualBounds() const
Get item's visual bbox in document coordinate system.
Geom::OptRect documentGeometricBounds() const
Get item's geometric bbox in document coordinate system.
virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const
void adjust_hatch(Geom::Affine const &postmul, bool set=false, PaintServerTransform=TRANSFORM_BOTH)
void adjust_pattern(Geom::Affine const &postmul, bool set=false, PaintServerTransform=TRANSFORM_BOTH)
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
Geom::OptRect visualBounds(Geom::Affine const &transform=Geom::identity(), bool wfilter=true, bool wclip=true, bool wmask=true) const
Get item's visual bounding box in this item's coordinate system.
Desktop-bound visual control object.
sigc::signal< void(SPKnot *, unsigned int)> ungrabbed_signal
sigc::signal< void(SPKnot *, Geom::Point const &, unsigned int)> moved_signal
sigc::signal< void(SPKnot *, unsigned int)> click_signal
void setPosition(Geom::Point const &p, unsigned int state)
Move knot to new position and emits "moved" signal.
sigc::signal< void(SPKnot *, unsigned int)> mousedown_signal
static void unref(SPKnot *knot)
void hide()
Hide knot on its canvas.
void show()
Show knot on its canvas.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
Geom::Affine const & getTransform() const
SPPaintServer * getFillPaintServer()
SPPaintServer * getStrokePaintServer()
sigc::signal< void(SPObject *, SPObject *)> signal_filter_changed
Emitted when the filter changes, meaning it starts pointing to a different object.
void setup(SPDesktop const *desktop, bool snapindicator=true, SPObject const *item_to_ignore=nullptr, std::vector< Inkscape::SnapCandidatePoint > *unselected_nodes=nullptr)
Convenience shortcut when there is only one item to ignore.
Editable view implementation.
static char const *const parent
SVG Gaussian blur filter effect.
constexpr Coord infinity()
Get a value representing infinity.
static Geom::Point sp_hatch_knot_get(SPHatch const *hatch, double x, double y)
Various utility functions.
Affine identity()
Create an identity matrix.
Singleton class to access the preferences file in a convenient way.
SVG <hatch> implementation.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SVG <pattern> implementation.
SPStyle - a style object for SPItem objects.