object-edit.cpp revision 5b20351508dc029f37f23fb7add6d0b43bf47f20
#define __SP_OBJECT_EDIT_C__
/*
* Node editing extension to objects
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Mitsuru Oka
* Maximilian Albert <maximilian.albert@gmail.com>
*
* 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 "prefs-utils.h"
#include "desktop-affine.h"
#include "style.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "sp-namedview.h"
#include "live_effects/effect.h"
#include "sp-pattern.h"
#include "sp-path.h"
#include "object-edit.h"
#include <libnr/nr-scale-ops.h>
#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m)))
{
return knot_holder;
}
{
if (SP_IS_LPE_ITEM(item) &&
} else if (SP_IS_RECT(item)) {
} else if (SP_IS_BOX3D(item)) {
} else if (SP_IS_STAR(item)) {
} else if (SP_IS_SPIRAL(item)) {
} else if (SP_IS_OFFSET(item)) {
}
return knotholder;
}
/* SPRect */
/* handle for horizontal rounding radius */
class RectKnotHolderEntityRX : public KnotHolderEntity {
public:
};
/* handle for vertical rounding radius */
class RectKnotHolderEntityRY : public KnotHolderEntity {
public:
};
class RectKnotHolderEntityWH : public KnotHolderEntity {
public:
protected:
};
/* handle for x/y adjustment */
class RectKnotHolderEntityXY : public KnotHolderEntity {
public:
};
{
}
void
{
//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
if (state & GDK_CONTROL_MASK) {
rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - p[NR::X], 0.0, temp);
} else {
rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - p[NR::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 */
}
update_knot();
}
{
}
void
{
//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
if (state & GDK_CONTROL_MASK) {
} 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
{
if (state & GDK_CONTROL_MASK) {
//original ratio
// mouse displacement since drag started
// snap to horizontal or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
} else {
// closer to the horizontal, change only width, height is h_orig
}
} else {
// snap to vertical or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
} else {
// closer to the vertical, change only height, width is w_orig
}
}
} else {
// move freely
}
}
void
{
update_knot();
}
{
}
void
{
// 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
} else {
// closer to the horizontal, change only width, height is h_orig
}
} else {
// snap to vertical or diagonal
// closer to the diagonal and in same-sign quarters, change both using ratio
} else {
// closer to the vertical, change only height, width is w_orig
}
}
} else {
// move freely
}
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) */
class Box3DKnotHolderEntity : public KnotHolderEntity {
public:
};
{
}
void
Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, guint state)
{
} else {
}
}
class Box3DKnotHolderEntity0 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity1 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity2 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity3 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity4 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity5 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity6 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntity7 : public Box3DKnotHolderEntity {
public:
};
class Box3DKnotHolderEntityCenter : public KnotHolderEntity {
public:
};
{
return knot_get_generic(item, 0);
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
void
Box3DKnotHolderEntity0::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity1::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity2::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity3::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity4::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity5::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity6::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, guint state)
{
}
void
Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, guint state)
{
box3d_set_center (SP_BOX3D(item), s * i2d, origin * i2d, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z,
}
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 */
class ArcKnotHolderEntityStart : public KnotHolderEntity {
public:
};
class ArcKnotHolderEntityEnd : public KnotHolderEntity {
public:
};
class ArcKnotHolderEntityRX : public KnotHolderEntity {
public:
};
class ArcKnotHolderEntityRY : public KnotHolderEntity {
public:
};
/*
* 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*/, guint state)
{
if ( ( state & GDK_CONTROL_MASK )
&& snaps )
{
}
}
{
}
void
{
if ( ( state & GDK_CONTROL_MASK )
&& snaps )
{
}
}
{
}
void
{
if (state & GDK_SHIFT_MASK) {
}
}
void
{
if ( state & GDK_CONTROL_MASK ) {
}
}
{
}
void
{
if (state & GDK_CONTROL_MASK) {
}
}
void
{
if ( state & GDK_CONTROL_MASK ) {
}
}
{
}
void
{
if (state & GDK_CONTROL_MASK) {
}
}
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 */
class StarKnotHolderEntity1 : public KnotHolderEntity {
public:
};
class StarKnotHolderEntity2 : public KnotHolderEntity {
public:
};
void
{
if (state & GDK_MOD1_MASK) {
} else if (state & GDK_SHIFT_MASK) {
} else if (state & GDK_CONTROL_MASK) {
} else {
}
}
void
{
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;
} else if (state & GDK_SHIFT_MASK) {
} else if (state & GDK_CONTROL_MASK) {
}
}
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 */
class SpiralKnotHolderEntityInner : public KnotHolderEntity {
public:
};
class SpiralKnotHolderEntityOuter : public KnotHolderEntity {
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*/, guint 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*/, guint 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) {
} else if (state & GDK_SHIFT_MASK) {
}
}
SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :
{
}
/* SPOffset */
class OffsetKnotHolderEntity : public KnotHolderEntity {
public:
};
void
OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*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.
class FlowtextKnotHolderEntity : public RectKnotHolderEntityWH {
public:
};
{
return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
}
void
{
}
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:encoding=utf-8:textwidth=99 :