~h-e-6/inkscape/connector-wip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * SVG Connector draft <point> implementation
 *
 * Authors:
 *   Sebastian Götte <inkscape@jaseg.net>
 *
 * Copyright (C) 2013 Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 *
 * TODO:
 *  * implement directionality
 */

#ifndef SEEN_SP_POINT_H
#define SEEN_SP_POINT_H

#include "sp-guide-constraint.h"
#include "svg/svg-length.h"
#include "sp-shape.h"
#include "xml/document.h"
#include <2geom/forward.h>
#include <sigc++/sigc++.h>

#define SP_POINT(obj) (dynamic_cast<SPPoint*>((SPObject*)obj))
#define SP_IS_POINT(obj) (dynamic_cast<const SPPoint*>((SPObject*)obj) != NULL)

class SPPoint : public SPItem {
private:
    sigc::signal<void, SPPoint*, Geom::Point> _moved_signal;
    sigc::signal<void, SPPoint*> _updated_signal;

    SVGLength _x;
    SVGLength _y;

public:
    virtual void build(SPDocument *document, Inkscape::XML::Node *repr);
    /* Update the point's repr and the reprs of connected connectors */
    void updateWithConnectors();
    void setPosition(double x, double y, bool propagate=true);
    void setPosition(Geom::Point p, bool propagate=true);
    Geom::Point getPosition(void) const;
    virtual Geom::Affine setTransform(Geom::Affine const &xform);
    virtual void update(SPCtx *ctx, guint flags);

    virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type);
    virtual char* description(void);
    virtual Inkscape::XML::Node *write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags);
    virtual void setAttr(unsigned int key, const char *value);

    sigc::connection connectMoved(sigc::slot<void, SPPoint*, Geom::Point> slot);
    sigc::connection connectUpdated(sigc::slot<void, SPPoint*> slot);
};

#endif // SEEN_SP_POINT_H

/*
  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 :