/*
* Node editing extension to objects
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Mitsuru Oka
* Maximilian Albert <maximilian.albert@gmail.com>
* Abhishek Sharma
* Jon A. Cruz <jon@joncruz.org>
*
* Licensed under GNU GPL
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "sp-item.h"
#include "sp-rect.h"
#include "box3d.h"
#include "sp-ellipse.h"
#include "sp-star.h"
#include "sp-spiral.h"
#include "sp-offset.h"
#include "sp-flowtext.h"
#include "preferences.h"
#include "style.h"
#include "desktop.h"
#include "sp-namedview.h"
#include "live_effects/effect.h"
#include "sp-pattern.h"
#include "sp-path.h"
#include "ui/object-edit.h"
#include "knot-holder-entity.h"
#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m)))
namespace {
{
return knot_holder;
}
} // namespace
namespace Inkscape {
namespace UI {
{
if (lpe &&
lpe->getCurrentLPE() &&
} else if (dynamic_cast<SPGenericEllipse *>(item)) {
} else {
} else if ((item->style->fill.isPaintserver() && dynamic_cast<SPPattern *>(item->style->getFillPaintServer())) ||
(item->style->stroke.isPaintserver() && dynamic_cast<SPPattern *>(item->style->getStrokePaintServer()))) {
}
}
return knotholder;
}
}
} // namespace Inkscape
/* SPRect */
/* handle for horizontal rounding radius */
public:
virtual void knot_click(unsigned int state);
};
/* handle for vertical rounding radius */
public:
virtual void knot_click(unsigned int state);
};
public:
protected:
};
/* handle for x/y adjustment */
public:
};
{
}
void
RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
//In general we cannot just snap this radius to an arbitrary point, as we have only a single
//degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
//the radius then we should have a constrained snap. snap_knot_position() is unconstrained
Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)), state);
if (state & GDK_CONTROL_MASK) {
} else {
rect->rx = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0);
}
update_knot();
}
void
{
if (state & GDK_SHIFT_MASK) {
/* remove rounding from rectangle */
} else if (state & GDK_CONTROL_MASK) {
/* Ctrl-click sets the vertical rounding to be the same as the horizontal */
}
}
{
}
void
RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
//In general we cannot just snap this radius to an arbitrary point, as we have only a single
//degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
//the radius then we should have a constrained snap. snap_knot_position() is unconstrained
Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)), state);
// resulting in a perfect circle (and not an ellipse)
} else {
0.0,
} else {
0.0,
}
}
update_knot();
}
void
{
if (state & GDK_SHIFT_MASK) {
/* remove rounding */
} else if (state & GDK_CONTROL_MASK) {
/* Ctrl-click sets the vertical rounding to be the same as the horizontal */
}
}
{
}
}
}
{
return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
}
void
RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
if (state & GDK_CONTROL_MASK) {
//original ratio
// mouse displacement since drag started
Geom::Point p_handle(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
// snap to horizontal or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
} else {
// closer to the horizontal, change only width, height is h_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
}
} else {
// snap to vertical or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
} else {
// closer to the vertical, change only height, width is w_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
}
}
} else {
// move freely
s = snap_knot_position(p, state);
}
}
void
RectKnotHolderEntityWH::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
update_knot();
}
{
}
void
RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
// opposite corner (unmoved)
// mouse displacement since drag started
if (state & GDK_CONTROL_MASK) {
//original ratio
// snap to horizontal or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
} else {
// closer to the horizontal, change only width, height is h_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state);
// Dead assignment: Value stored to 'miny' is never read
//miny = s[Geom::Y] - origin[Geom::Y];
}
} else {
// snap to vertical or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state);
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
} else {
// closer to the vertical, change only height, width is w_orig
s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state);
// Dead assignment: Value stored to 'minx' is never read
//minx = s[Geom::X] - origin[Geom::X];
}
}
} else {
// move freely
s = snap_knot_position(p, state);
}
update_knot();
}
RectKnotHolder::RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
_("Adjust the <b>horizontal rounding</b> radius; with <b>Ctrl</b> "
"to make the vertical radius the same"),
_("Adjust the <b>vertical rounding</b> radius; with <b>Ctrl</b> "
"to make the horizontal radius the same"),
_("Adjust the <b>width and height</b> of the rectangle; with <b>Ctrl</b> "
"to lock ratio or stretch in one dimension only"),
_("Adjust the <b>width and height</b> of the rectangle; with <b>Ctrl</b> "
"to lock ratio or stretch in one dimension only"),
}
/* Box3D (= the new 3D box structure) */
public:
void knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &p, unsigned int state);
};
{
if (box) {
} else {
}
}
void
Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, unsigned int state)
{
} else {
}
}
public:
};
public:
};
public:
};
public:
};
public:
};
public:
};
public:
};
public:
};
public:
};
{
return knot_get_generic(item, 0);
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
if (box) {
return box3d_get_center_screen(box);
} else {
}
}
void
Box3DKnotHolderEntity0::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity1::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity2::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity3::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity4::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity5::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity6::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state)
{
}
void
Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, unsigned int state)
{
}
Box3DKnotHolder::Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
_("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; "
"with <b>Ctrl</b> to constrain to the directions of edges or diagonals"));
_("Move the box in perspective"),
}
/* SPArc */
public:
virtual void knot_click(unsigned int state);
};
public:
virtual void knot_click(unsigned int state);
};
public:
virtual void knot_click(unsigned int state);
};
public:
virtual void knot_click(unsigned int state);
};
/*
* return values:
* 1 : inside
* 0 : on the curves
* -1 : outside
*/
static gint
{
if (s < 1.0) return 1;
if (s > 1.0) return -1;
return 0;
}
void
ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
}
}
{
}
void
{
if (state & GDK_SHIFT_MASK) {
ge->updateRepr();
}
}
void
ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
}
}
{
}
void
{
if (state & GDK_SHIFT_MASK) {
ge->updateRepr();
}
}
void
ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
if ( state & GDK_CONTROL_MASK ) {
}
}
{
}
void
{
if (state & GDK_CONTROL_MASK) {
ge->updateRepr();
}
}
void
ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
if ( state & GDK_CONTROL_MASK ) {
}
}
{
}
void
{
if (state & GDK_CONTROL_MASK) {
ge->updateRepr();
}
}
ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
_("Adjust ellipse <b>width</b>, with <b>Ctrl</b> to make circle"),
_("Adjust ellipse <b>height</b>, with <b>Ctrl</b> to make circle"),
_("Position the <b>start point</b> of the arc or segment; with <b>Ctrl</b> "
"to snap angle; drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"),
_("Position the <b>end point</b> of the arc or segment; with <b>Ctrl</b> to snap angle; "
"drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"),
}
/* SPStar */
public:
virtual void knot_click(unsigned int state);
};
public:
virtual void knot_click(unsigned int state);
};
void
StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
if (state & GDK_MOD1_MASK) {
} else if (state & GDK_SHIFT_MASK) {
} else if (state & GDK_CONTROL_MASK) {
} else {
}
}
void
StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
if (state & GDK_MOD1_MASK) {
} else if (state & GDK_SHIFT_MASK) {
} else if (state & GDK_CONTROL_MASK) {
}
else {
}
}
}
{
}
{
}
static void
{
if (state & GDK_MOD1_MASK) {
star->randomized = 0;
star->updateRepr();
} else if (state & GDK_SHIFT_MASK) {
star->updateRepr();
} else if (state & GDK_CONTROL_MASK) {
star->updateRepr();
}
}
void
{
}
void
{
}
StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
_("Adjust the <b>tip radius</b> of the star or polygon; "
"with <b>Shift</b> to round; with <b>Alt</b> to randomize"));
_("Adjust the <b>base radius</b> of the star; with <b>Ctrl</b> to keep star rays "
"radial (no skew); with <b>Shift</b> to round; with <b>Alt</b> to randomize"));
}
}
/* SPSpiral */
public:
virtual void knot_click(unsigned int state);
};
public:
};
/*
* set attributes via inner (t=t0) knot point:
* [control] constrain inner arg to round per PI/4
*/
void
SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
if (state & GDK_MOD1_MASK) {
// adjust divergence by vertical drag, relative to rad
}
} else {
if ( ( state & GDK_CONTROL_MASK )
&& ( snaps != 0 ) ) {
}
}
}
/*
* set attributes via outer (t=1) knot point:
* [control] constrain inner arg to round per PI/4
*/
void
SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
if (!(state & GDK_MOD1_MASK)) {
// if alt not pressed, change also rad; otherwise it is locked
}
if ( ( state & GDK_CONTROL_MASK )
&& snaps ) {
}
// arg of the spiral outer end
double arg_1;
// its fractional part after the whole turns are subtracted
// arg of the mouse point relative to spiral center
if (mouse_angle < 0)
// snap if ctrl
}
// by how much we want to rotate the outer point
// calculate the new rad;
// the value of t corresponding to the angle arg_1 + diff:
// the rad at that t:
double rad_new = 0;
// change the revo (converting diff from radians to the number of turns)
// if alt not pressed and the values are sane, change the rad
// adjust t0 too so that the inner point stays unmoved
double r0;
}
}
}
{
}
{
}
void
{
if (state & GDK_MOD1_MASK) {
spiral->updateRepr();
} else if (state & GDK_SHIFT_MASK) {
spiral->updateRepr();
}
}
SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
}
/* SPOffset */
public:
};
void
OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state)
{
}
{
return np;
}
OffsetKnotHolder::OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
_("Adjust the <b>offset distance</b>"));
}
// TODO: this is derived from RectKnotHolderEntityWH because it used the same static function
// set_internal as the latter before KnotHolderEntity was C++ified. Check whether this also makes
// sense logically.
public:
};
{
return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
}
void
FlowtextKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
{
}
FlowtextKnotHolder::FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
_("Drag to resize the <b>flowed text frame</b>"));
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :