1 #define INKSCAPE_LIVEPATHEFFECT_POWERSTROKE_POINT_ARRAY_CPP
3 /*
4 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
5 *
6 * Released under GNU GPL, read the file 'COPYING' for more information
7 */
9 #include "live_effects/parameter/powerstrokepointarray.h"
11 #include "live_effects/effect.h"
12 #include "svg/svg.h"
13 #include "svg/stringstream.h"
14 #include <gtkmm.h>
15 #include "ui/widget/point.h"
16 #include "widgets/icon.h"
17 #include "ui/widget/registered-widget.h"
18 #include "inkscape.h"
19 #include "verbs.h"
20 #include "knotholder.h"
22 // needed for on-canvas editting:
23 #include "desktop.h"
25 namespace Inkscape {
27 namespace LivePathEffect {
29 PowerStrokePointArrayParam::PowerStrokePointArrayParam( const Glib::ustring& label, const Glib::ustring& tip,
30 const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
31 Effect* effect, const gchar *htip)
32 : ArrayParam<Geom::Point>(label, tip, key, wr, effect, 0)
33 {
34 knot_shape = SP_KNOT_SHAPE_DIAMOND;
35 knot_mode = SP_KNOT_MODE_XOR;
36 knot_color = 0xffffff00;
37 handle_tip = g_strdup(htip);
38 }
40 PowerStrokePointArrayParam::~PowerStrokePointArrayParam()
41 {
42 if (handle_tip)
43 g_free(handle_tip);
44 }
46 Gtk::Widget *
47 PowerStrokePointArrayParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
48 {
49 return NULL;
50 /*
51 Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage(
52 new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label,
53 param_tooltip,
54 param_key,
55 *param_wr,
56 param_effect->getRepr(),
57 param_effect->getSPDoc() ) );
58 // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
59 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
60 Geom::Matrix transf = desktop->doc2dt();
61 pointwdg->setTransform(transf);
62 pointwdg->setValue( *this );
63 pointwdg->clearProgrammatically();
64 pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
66 Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
67 static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
68 static_cast<Gtk::HBox*>(hbox)->show_all_children();
70 return dynamic_cast<Gtk::Widget *> (hbox);
71 */
72 }
75 void
76 PowerStrokePointArrayParam::param_transform_multiply(Geom::Matrix const& postmul, bool /*set*/)
77 {
78 // param_set_and_write_new_value( (*this) * postmul );
79 }
82 void
83 PowerStrokePointArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color)
84 {
85 knot_shape = shape;
86 knot_mode = mode;
87 knot_color = color;
88 }
90 class PowerStrokePointArrayParamKnotHolderEntity : public LPEKnotHolderEntity {
91 public:
92 PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index);
93 virtual ~PowerStrokePointArrayParamKnotHolderEntity() {}
95 virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
96 virtual Geom::Point knot_get();
97 virtual void knot_click(guint state);
99 private:
100 PowerStrokePointArrayParam *_pparam;
101 unsigned int _index;
102 };
104 PowerStrokePointArrayParamKnotHolderEntity::PowerStrokePointArrayParamKnotHolderEntity(PowerStrokePointArrayParam *p, unsigned int index)
105 : _pparam(p),
106 _index(index)
107 {
108 }
110 void
111 PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
112 {
113 // Geom::Point const s = snap_knot_position(p);
114 // pparam->param_setValue(s);
115 // sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
116 }
118 Geom::Point
119 PowerStrokePointArrayParamKnotHolderEntity::knot_get()
120 {
121 Geom::Point canvas_point;
122 return canvas_point;
123 }
125 void
126 PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint /*state*/)
127 {
128 g_print ("This is the %d handle associated to parameter '%s'\n", _index, _pparam->param_key.c_str());
129 }
131 void
132 PowerStrokePointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
133 {
134 //PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(this);
135 // TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself???
136 //e->create(desktop, item, knotholder, handleTip(), knot_shape, knot_mode, knot_color);
137 //knotholder->add(e);
139 }
141 } /* namespace LivePathEffect */
143 } /* namespace Inkscape */
145 /*
146 Local Variables:
147 mode:c++
148 c-file-style:"stroustrup"
149 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
150 indent-tabs-mode:nil
151 fill-column:99
152 End:
153 */
154 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :