node.h revision 364d9045bfd158352b8040721b3e2e2602e921ea
/** @file
* Editable node and associated data structures.
*/
/* Authors:
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
*
* Copyright (C) 2009 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifndef SEEN_UI_TOOL_NODE_H
#define SEEN_UI_TOOL_NODE_H
#include <glib.h>
#include <iterator>
#include <iosfwd>
#include <stdexcept>
#include <cstddef>
#include <tr1/functional>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
#include <boost/operators.hpp>
#include "snapped-point.h"
#include "ui/tool/selectable-control-point.h"
#include "ui/tool/node-types.h"
}
}
}
}
/*
template <typename T>
struct ListMember {
T *next;
T *prev;
};
struct SubpathMember : public ListMember<NodeListMember> {
Subpath *list;
};
struct SubpathListMember : public ListMember<SubpathListMember> {
SubpathList *list;
};
*/
struct ListNode {
};
struct NodeSharedData {
};
inline double length();
bool isDegenerate() { return _degenerate; }
virtual void setVisible(bool);
void retract();
virtual bool _hasDragTips() { return true; }
inline PathManipulator &_pm();
// so a naked pointer is OK and allows setting it during Node's construction
bool _degenerate; // this is used often internally so it makes sense to cache this
static double _saved_length;
static bool _drag_out;
};
void showHandles(bool v);
void pickBestType(); // automatically determine the type from handle positions
bool isEndNode();
void sink();
static NodeType parse_nodetype(char x);
// temporarily public
virtual bool _hasDragTips() { return true; }
void _updateAutoHandles();
void _linearGrow(int dir);
inline PathManipulator &_pm();
// Handles are always present, but are not visible if they coincide with the node
// (are degenerate). A segment that has both handles degenerate is always treated
// as a line segment
bool _handles_shown;
};
/// Iterator for editable nodes
/** Use this class for all operations that require some knowledge about the node's
* neighbors. It is a bidirectional iterator.
*
* Because paths can be cyclic, node iterators have two different ways to
* increment and decrement them. When using ++/--, the end iterator will eventually
* be returned. Whent using advance()/retreat(), the end iterator will only be returned
* when the path is open. If it's closed, calling advance() will cycle indefinitely.
* This is particularly useful for cases where the adjacency of nodes is more important
* than their sequence order.
*
* When @a i is a node iterator, then:
* - <code>++i</code> moves the iterator to the next node in sequence order;
* - <code>--i</code> moves the iterator to the previous node in sequence order;
* - <code>i.next()</code> returns the next node with wrap-around;
* - <code>i.prev()</code> returns the previous node with wrap-around;
* - <code>i.advance()</code> moves the iterator to the next node with wrap-around;
* - <code>i.retreat()</code> moves the iterator to the previous node with wrap-around.
*
* next() and prev() do not change their iterator. They can return the end iterator
* if the path is open.
*
* Unlike most other iterators, you can check whether you've reached the end of the list
* without having access to the iterator's container.
* Simply use <code>if (i) { ...</code>
* */
N *, N &>
{
typedef NodeIterator self;
: _node(0)
{}
// default copy, default assign
return *this;
}
return *this;
}
inline operator bool() const; // define after NodeList
/// Get a pointer to the underlying node. Equivalent to <code>&*i</code>.
/// @see get_pointer()
r.advance();
return r;
}
r.retreat();
return r;
}
NodeIterator(ListNode const *n)
{}
};
typedef Node const &const_reference;
typedef Node const *const_pointer;
typedef Node value_type;
// TODO Lame. Make this private and make SubpathList a factory
~NodeList();
// iterators
// size
bool empty();
// extra node-specific methods
bool closed();
bool degenerate();
}
// list operations
}
void reverse();
void shift(int n);
void clear();
return ret;
}
// member access - undefined results when the list is empty
// HACK remove this subpath from its path. This will be removed later.
void kill();
// no copy or assign
bool _closed;
};
/** List of node lists. Represents an editable path. */
};
// define inline Handle funcs after definition of Node
}
}
return relativePos().length();
}
}
}
// definitions for node iterator
NodeIterator<N>::operator bool() const {
}
++(*this);
return *this;
}
--(*this);
return *this;
}
} // namespace UI
} // namespace Inkscape
#endif
/*
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 :