~inkscape.dev/inkscape/trunk

« back to all changes in this revision

Viewing changes to src/sp-hatch-path.h

  • Committer: Jon A. Cruz
  • Date: 2014-10-18 00:03:52 UTC
  • Revision ID: jon@joncruz.org-20141018000352-jwnpt6bzb2amozhi
Refactoring hatch to remove memory leaks (bad GTKish casting macros) and uninitialized value.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/** @file
 
1
/**
 
2
 * @file
2
3
 * SVG <hatchPath> implementation
3
 
 *//*
 
4
 */
 
5
/*
4
6
 * Author:
5
7
 *   Tomasz Boczkowski <penginsbacon@gmail.com>
 
8
 *   Jon A. Cruz <jon@joncruz.org>
6
9
 *
7
10
 * Copyright (C) 2014 Tomasz Boczkowski
8
11
 *
26
29
 
27
30
}
28
31
 
29
 
#define SP_HATCH_PATH(obj) (dynamic_cast<SPHatchPath*>((SPObject*)obj))
30
 
#define SP_IS_HATCH_PATH(obj) (dynamic_cast<const SPHatchPath*>((SPObject*)obj) != NULL)
31
 
 
32
32
class SPHatchPath : public SPObject {
33
33
public:
34
34
    SPHatchPath();
35
 
        virtual ~SPHatchPath();
36
 
 
37
 
        SVGLength offset;
38
 
 
39
 
        void setCurve(SPCurve *curve, bool owner);
 
35
    virtual ~SPHatchPath();
 
36
 
 
37
    SVGLength offset;
 
38
 
 
39
    void setCurve(SPCurve *curve, bool owner);
40
40
 
41
41
    bool isValid() const;
42
42
 
43
43
    Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned int key, Geom::OptInterval extents);
44
44
    void hide(unsigned int key);
45
45
 
46
 
        void setStripExtents(unsigned int key, Geom::OptInterval const &extents);
47
 
        Geom::Interval bounds() const;
 
46
    void setStripExtents(unsigned int key, Geom::OptInterval const &extents);
 
47
    Geom::Interval bounds() const;
48
48
 
49
 
        SPCurve *calculateRenderCurve(unsigned key) const;
 
49
    SPCurve *calculateRenderCurve(unsigned key) const;
50
50
 
51
51
protected:
52
 
        virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
53
 
        virtual void release();
54
 
        virtual void set(unsigned int key, const gchar* value);
55
 
        virtual void update(SPCtx* ctx, unsigned int flags);
 
52
    virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
 
53
    virtual void release();
 
54
    virtual void set(unsigned int key, const gchar* value);
 
55
    virtual void update(SPCtx* ctx, unsigned int flags);
56
56
 
57
57
private:
58
 
    struct View {
 
58
    class View {
 
59
    public:
59
60
        View(Inkscape::DrawingShape *arenaitem, int key);
60
61
        //Do not delete arenaitem in destructor.
61
62
 
 
63
        ~View();
 
64
 
62
65
        Inkscape::DrawingShape *arenaitem;
63
66
        Geom::OptInterval extents;
64
67
        unsigned int key;
65
68
    };
 
69
 
66
70
    typedef std::list<SPHatchPath::View>::iterator ViewIterator;
67
71
    typedef std::list<SPHatchPath::View>::const_iterator ConstViewIterator;
68
72
    std::list<View> _display;