index f102be1f73c34e93e2684439529dcf7032badc59..5ae9c4137255c7ab9cc1db66f7cb700045190448 100644 (file)
*/
/* Authors:
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
+ * Abhishek Sharma
*
* Copyright (C) 2009 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
}
}
+/** Insert new nodes exactly at the positions of selected nodes while preserving shape.
+ * This is equivalent to breaking, except that it doesn't split into subpaths. */
+void PathManipulator::duplicateNodes()
+{
+ if (_num_selected == 0) return;
+
+ for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) {
+ for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) {
+ if (j->selected()) {
+ NodeList::iterator k = j.next();
+ Node *n = new Node(_multi_path_manipulator._path_data.node_data, *j);
+
+ // Move the new node to the bottom of the Z-order. This way you can drag all
+ // nodes that were selected before this operation without deselecting
+ // everything because there is a new node above.
+ n->sink();
+
+ n->front()->setPosition(*j->front());
+ j->front()->retract();
+ j->setType(NODE_CUSP, false);
+ (*i)->insert(k, n);
+
+ // We need to manually call the selection change callback to refresh
+ // the handle display correctly.
+ // This call changes num_selected, but we call this once for a selected node
+ // and once for an unselected node, so in the end the number stays correct.
+ _selectionChanged(j.ptr(), true);
+ _selectionChanged(n, false);
+ }
+ }
+ }
+}
+
/** Replace contiguous selections of nodes in each subpath with one node. */
void PathManipulator::weldNodes(NodeList::iterator preserve_pos)
{
/** Called by the XML observer when something else than us modifies the path. */
void PathManipulator::_externalChange(unsigned type)
{
+ hideDragPoint();
+
switch (type) {
case PATH_CHANGE_D: {
_getGeometry();
// TODO maybe migrate to inkscape:node-types?
// TODO move this into SPPath - do not manipulate directly
- //XML Tree being used here directly while it shouldn't be.
+ //XML Tree being used here directly while it shouldn't be.
gchar const *nts_raw = _path ? _path->getRepr()->attribute(_nodetypesKey().data()) : 0;
std::string nodetype_string = nts_raw ? nts_raw : "";
/* Calculate the needed length of the nodetype string.
LIVEPATHEFFECT(_path)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
} else {
- //XML Tree being used here directly while it shouldn't be.
+ //XML Tree being used here directly while it shouldn't be.
if (_path->getRepr()->attribute("inkscape:original-d"))
sp_path_set_original_curve(_path, _spcurve, false, false);
else
* This method is wrong but necessary at the moment. */
Inkscape::XML::Node *PathManipulator::_getXMLNode()
{
- //XML Tree being used here directly while it shouldn't be.
+ //XML Tree being used here directly while it shouldn't be.
if (_lpe_key.empty()) return _path->getRepr();
- //XML Tree being used here directly while it shouldn't be.
+ //XML Tree being used here directly while it shouldn't be.
return LIVEPATHEFFECT(_path)->getRepr();
}
return true;
} else if (held_control(*event)) {
// Ctrl+click: cycle between node types
- if (n->isEndNode()) {
- if (n->type() == NODE_CUSP) {
- n->setType(NODE_SMOOTH);
- } else {
- n->setType(NODE_CUSP);
- }
- } else {
+ if (!n->isEndNode()) {
n->setType(static_cast<NodeType>((n->type() + 1) % NODE_LAST_REAL_TYPE));
+ update();
+ _commit(_("Cycle node type"));
}
- update();
- _commit(_("Cycle node type"));
return true;
}
return false;
void PathManipulator::_commit(Glib::ustring const &annotation)
{
writeXML();
- SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data());
+ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data());
}
void PathManipulator::_commit(Glib::ustring const &annotation, gchar const *key)
{
writeXML();
- SPDocumentUndo::maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE,
- annotation.data());
+ DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE,
+ annotation.data());
}
/** Update the position of the curve drag point such that it is over the nearest
NodeList::iterator first = (*spi)->before(pvp->t, &fracpart);
double stroke_tolerance = _getStrokeTolerance();
- if (Geom::distance(evp, nearest_point) < stroke_tolerance) {
+ if (first && first.next() &&
+ fracpart != 0.0 &&
+ Geom::distance(evp, nearest_point) < stroke_tolerance)
+ {
_dragpoint->setVisible(true);
_dragpoint->setPosition(_desktop->w2d(nearest_point));
_dragpoint->setSize(2 * stroke_tolerance);
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :