shape-editor.cpp revision a88ae89fce92b829569bae803c07ccac583d61f5
#define __SHAPE_EDITOR_CPP__
/*
* Inkscape::ShapeEditor
*
* Authors:
* bulia byak <buliabyak@users.sf.net>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "sp-object.h"
#include "sp-item.h"
#include "live_effects/lpeobject.h"
#include "selection.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "knotholder.h"
#include "live_effects/parameter/pointparam-knotholder.h"
#include "nodepath.h"
#include "xml/node-event-vector.h"
#include "prefs-utils.h"
#include "object-edit.h"
#include "style.h"
#include "sp-shape.h"
#include "shape-editor.h"
}
}
void ShapeEditorsCollective::update_statusbar() {
//!!! move from nodepath: sp_nodepath_update_statusbar but summing for all nodepaths
}
this->grab_node = -1;
this->knotholder = NULL;
this->hit = false;
}
ShapeEditor::~ShapeEditor() {
}
g_print ("ShapeEditor::unset_item()\n");
switch (type) {
case SH_NODEPATH:
if (this->nodepath) {
this->grab_node = -1;
sp_nodepath_destroy(this->nodepath);
}
break;
case SH_KNOTHOLDER:
if (this->knotholder) {
if (!keep_knotholder) {
delete this->knotholder;
this->knotholder = NULL;
}
}
break;
}
}
bool ShapeEditor::has_nodepath () {
}
bool ShapeEditor::has_knotholder () {
return (this->knotholder != NULL);
}
void ShapeEditor::update_knotholder () {
if (this->knotholder)
this->knotholder->update_knots();
}
switch (type) {
case SH_NODEPATH:
case SH_KNOTHOLDER:
default:
}
}
switch (type) {
case SH_NODEPATH:
this->nodepath->local_change--;
}
break;
case SH_KNOTHOLDER:
if (this->knotholder) {
}
break;
default:
}
}
switch (type) {
case SH_NODEPATH:
if (this->has_nodepath()) {
}
break;
case SH_KNOTHOLDER:
if (this->has_knotholder()) {
}
break;
}
return item;
}
if (this->nodepath)
return ::save_nodepath_selection (this->nodepath);
return NULL;
}
}
}
return false;
}
{
g_print ("shapeeditor_event_attr_changed()\n");
{
}
if (changed_np) {
if (sh->has_nodepath()) {
}
g_list_free (saved);
}
}
if (sh->has_knotholder())
{
if (changed_kh) {
// this can happen if an LPEItem's knotholder handle was dragged, in which case we want
// to keep the knotholder; in all other cases (e.g., if the LPE itself changes) we delete it
}
}
}
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* content_changed */
NULL /* order_changed */
};
g_print ("ShapeEditor::set_item()\n");
// this happens (and should only happen) when for an LPEItem having both knotholder and nodepath the knotholder
// is adapted; in this case we don't want to delete the knotholder since this freezes the handles
this->grab_node = -1;
if (item) {
switch(type) {
case SH_NODEPATH:
if (SP_IS_LPE_ITEM(item)) {
this->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
}
if (this->nodepath) {
this->nodepath->shape_editor = this;
// setting new listener
}
break;
case SH_KNOTHOLDER:
if (!this->knotholder) {
// only recreate knotholder if none is present
}
if (this->knotholder) {
this->knotholder->update_knots();
// setting new listener
}
break;
}
}
}
/** Please note that this function only works for path parameters.
* All other parameters probably will crash Inkscape!
*/
{
g_print ("ShapeEditor::set_item_lpe_path_parameter()\n");
this->grab_node = -1;
if (lpeobject) {
if (this->nodepath) {
this->nodepath->shape_editor = this;
// setting new listener
if (repr) {
}
}
}
}
/**
* pass a new knotholder to ShapeEditor to manage (and delete)
*/
void
{
this->grab_node = -1;
if (knot_holder) {
this->knotholder = knot_holder;
}
}
/** FIXME: think about this. Is this thing only called when the item needs to be updated?
Why not make a reload function in NodePath and in KnotHolder? */
{
g_print ("ShapeEditor::reset_item()\n");
switch (type) {
case SH_NODEPATH:
set_item_lpe_path_parameter(item, obj, key); // the above checks for nodepath, so it is indeed a path that we are editing
} else {
}
break;
case SH_KNOTHOLDER:
if (this->knotholder) {
}
break;
}
}
void ShapeEditor::nodepath_destroyed () {
}
void ShapeEditor::update_statusbar () {
if (this->nodepath)
sp_nodepath_update_statusbar(this->nodepath);
}
g_print ("ShapeEditor::is_over_stroke ()");
if (!this->nodepath)
return false; // no stroke in knotholder
//Translate click point into proper coord system
if (SP_IS_SHAPE(item)) {
g_print ("; getting curve from shape\n");
} else {
g_print ("; getting curve from nodepath's curve\n");
}
double stroke_tolerance =
desktop->current_zoom() *
: 0.0)
+ prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item));
// calculate index for nodepath's representation.
double int_part;
segment_index += 1;
}
this->hit = true;
this->grab_t = t;
this->grab_node = segment_index;
}
return close;
}
void ShapeEditor::add_node_near_point() {
if (this->nodepath) {
} else if (this->knotholder) {
// we do not add nodes in knotholder... yet
}
}
if (this->nodepath) {
}
if (this->knotholder) {
// we do not select segments in knotholder... yet?
}
}
void ShapeEditor::cancel_hit() {
this->hit = false;
}
bool ShapeEditor::hits_curve() {
return (this->hit);
}
return;
// We round off the extra precision in the motion coordinates provided
// by some input devices (like tablets). As we'll store the coordinates
// as integers in curvepoint_event we need to do this rounding before
// comparing them with the last coordinates from curvepoint_event.
// See bug #1593499 for details.
// The coordinates hasn't changed since the last motion event, abort
if (this->curvepoint_event[NR::X] == x &&
this->curvepoint_event[NR::Y] == y)
return;
this->curvepoint_event[NR::X] = x;
this->curvepoint_event[NR::Y] = y;
}
if (this->knotholder) {
// we do not drag curve in knotholder
}
}
void ShapeEditor::finish_drag() {
}
}
if (this->nodepath) {
}
}
bool ShapeEditor::has_selection() {
if (this->nodepath)
return false; // so far, knotholder cannot have selection
}
void ShapeEditor::deselect() {
if (this->nodepath)
sp_nodepath_deselect(this->nodepath);
}
void ShapeEditor::add_node () {
sp_node_selected_add_node(this->nodepath);
}
void ShapeEditor::delete_nodes () {
sp_node_selected_delete(this->nodepath);
}
void ShapeEditor::delete_nodes_preserving_shape () {
}
}
void ShapeEditor::delete_segment () {
}
}
void ShapeEditor::break_at_nodes() {
sp_node_selected_break(this->nodepath);
}
void ShapeEditor::join_nodes() {
sp_node_selected_join(this->nodepath);
}
void ShapeEditor::join_segments() {
}
void ShapeEditor::duplicate_nodes() {
sp_node_selected_duplicate(this->nodepath);
}
}
}
}
if (this->nodepath)
}
}
}
if (this->nodepath)
}
if (this->nodepath)
}
void ShapeEditor::select_next () {
if (this->nodepath) {
sp_nodepath_select_next (this->nodepath);
}
}
}
void ShapeEditor::select_prev () {
if (this->nodepath) {
sp_nodepath_select_prev (this->nodepath);
}
}
}
}
if (this->nodepath)
}
if (this->nodepath)
}
if (this->nodepath)
}
if (this->nodepath)
}
/*
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 :