~danieljabailey/inkscape/arc_node_editor

« back to all changes in this revision

Viewing changes to src/ui/tool/node.h

  • Committer: Daniel Bailey
  • Date: 2016-05-15 20:44:44 UTC
  • Revision ID: d@nielbailey.com-20160515204444-tak344mvzf55nhwk
Added support for editting arc segments in the node editor

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include <boost/enable_shared_from_this.hpp>
31
31
#include <boost/shared_ptr.hpp>
 
32
#include <2geom/elliptical-arc.h>
32
33
#include "ui/tool/selectable-control-point.h"
33
34
#include "snapped-point.h"
34
35
#include "ui/tool/node-types.h"
100
101
    virtual ~Handle();
101
102
    inline Geom::Point relativePos() const;
102
103
    inline double length() const;
 
104
    inline Geom::Angle angle() const;
103
105
    bool isDegenerate() const { return _degenerate; } // True if the handle is retracted, i.e. has zero length.
104
106
 
105
107
    virtual void setVisible(bool);
107
109
 
108
110
    virtual void setPosition(Geom::Point const &p);
109
111
    inline void setRelativePos(Geom::Point const &p);
 
112
    virtual void setOffset(Geom::Point const &offset);
110
113
    void setLength(double len);
 
114
    void setAngle(Geom::Angle a);
 
115
    void setAngleAndLength(Geom::Angle a, double len);
111
116
    void retract();
112
117
    void setDirection(Geom::Point const &from, Geom::Point const &to);
113
118
    void setDirection(Geom::Point const &dir);
140
145
    SPCtrlLine *_handle_line;
141
146
    bool _degenerate; // True if the handle is retracted, i.e. has zero length. This is used often internally so it makes sense to cache this
142
147
 
 
148
    Geom::Point _offset;
 
149
 
143
150
    /**
144
151
     * Control point of a cubic Bezier curve in a path.
145
152
     *
183
190
    void showHandles(bool v);
184
191
 
185
192
    void updateHandles();
 
193
    void updateArcHandleConstriants(Handle *constraint);
 
194
    void moveArcHandles(Geom::Point lineBetweenNodes, double lenX, double lenY, Geom::Angle rotX, Geom::Angle rotY);
 
195
 
 
196
    void retractArcHandles();
186
197
 
187
198
 
188
199
    /**
195
206
    bool isEndNode() const;
196
207
    Handle *front() { return &_front; }
197
208
    Handle *back()  { return &_back;  }
 
209
    Handle *arc_rx() { return &_arc_rx; }
 
210
    Handle *arc_ry() { return &_arc_ry; }
 
211
    bool *arc_large() { return &_arc_large; }
 
212
    bool *arc_sweep() { return &_arc_sweep; }
198
213
 
199
214
    /**
200
215
     * Gets the handle that faces the given adjacent node.
278
293
    // as a line segment
279
294
    Handle _front; ///< Node handle in the backward direction of the path
280
295
    Handle _back; ///< Node handle in the forward direction of the path
 
296
    // The arc control points and flags relate to an arc starting at this node and ending at the next node
 
297
    Handle _arc_rx; ///< Handle for controling the x radius and rotation of the elipse (in eliptical arc mode)
 
298
    Handle _arc_ry; ///< Handle for controling the y radius and rotation of the elipse (in eliptical arc mode)
 
299
    bool _arc_large; ///< Flag that determines if arc mode is shallow or bulge
 
300
    bool _arc_sweep; ///< Flag that determines the direction of an arc's sweep
281
301
    NodeType _type; ///< Type of node - cusp, smooth...
282
302
    bool _handles_shown;
283
303
    static ColorSet node_colors;
489
509
 
490
510
// define inline Handle funcs after definition of Node
491
511
inline Geom::Point Handle::relativePos() const {
492
 
    return position() - _parent->position();
 
512
    return position() - (_parent->position() + _offset);
493
513
}
494
514
inline void Handle::setRelativePos(Geom::Point const &p) {
495
 
    setPosition(_parent->position() + p);
 
515
    setPosition(_parent->position() + _offset + p);
496
516
}
497
517
inline double Handle::length() const {
498
518
    return relativePos().length();
499
519
}
 
520
inline Geom::Angle Handle::angle() const {
 
521
    return Geom::Angle(position() - _parent->position() - _offset);
 
522
}
500
523
inline PathManipulator &Handle::_pm() {
501
524
    return _parent->_pm();
502
525
}