lpe-tool-context.cpp revision 469edb969f8070f518f2100039d56ad53dd38594
/*
* LPEToolContext: a context for a generic tool composed of subtools that are given by LPEs
*
* Authors:
* Maximilian Albert <maximilian.albert@gmail.com>
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 1998 The Free Software Foundation
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
* Copyright (C) 2008 Maximilian Albert
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gdk/gdkkeysyms.h>
//#include <gtk/gtkobject.h>
#include "macros.h"
#include "forward.h"
#include "pixmaps/cursor-node.xpm"
#include "pixmaps/cursor-crosshairs.xpm"
#include "desktop.h"
#include "message-context.h"
#include "prefs-utils.h"
#include "shape-editor.h"
#include "selection.h"
#include "desktop-handles.h"
#include "document.h"
#include "display/canvas-bpath.h"
#include "message-stack.h"
#include "sp-path.h"
#include "lpe-tool-context.h"
const int num_subtools = 8;
Inkscape::LivePathEffect::INVALID_LPE, // this must be here to account for the "all inactive" action
};
static SPPenContextClass *lpetool_parent_class = 0;
{
if (!type) {
sizeof(SPLPEToolContextClass),
0, // base_init
0, // base_finalize
0, // class_finalize
0, // class_data
sizeof(SPLPEToolContext),
0, // n_preallocs
0 // value_table
};
type = g_type_register_static(SP_TYPE_PEN_CONTEXT, "SPLPEToolContext", &info, static_cast<GTypeFlags>(0));
}
return type;
}
static void
{
}
static void
{
}
static void
{
delete lc->shape_editor;
if (lc->canvas_bbox) {
}
delete lc->measuring_items;
}
static void
{
selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_lpetool_context_selection_changed), (gpointer)lc));
// TODO temp force:
ec->enableSelectionCue();
if (item) {
}
ec->enableSelectionCue();
}
}
/**
\brief Callback that processes the "changed" signal on the selection;
destroys old and creates new nodepath and reassigns listeners to the new selected item's repr
*/
void
{
// TODO: update ShapeEditorsCollective instead
}
static void
{
// FIXME: how to set this correcly? the value from preferences-skeleton.h doesn't seem to get
// read (it wants to set drag = 1)
/**
//pass on up to parent class to handle common attributes.
if ( lpetool_parent_class->set ) {
lpetool_parent_class->set(ec, key, val);
}
**/
}
{
bool ret = false;
if (sp_pen_context_has_waiting_LPE(lc)) {
// quit when we are waiting for a LPE to be applied
return ret;
}
case GDK_BUTTON_PRESS:
// don't do anything for now if we are inactive
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Choose a construction tool from the toolbar."));
ret = true;
break;
}
// save drag origin
event_context->within_tolerance = true;
using namespace Inkscape::LivePathEffect;
//bool over_stroke = lc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), true);
sp_pen_context_wait_for_LPE_mouse_clicks(lc, type, Inkscape::LivePathEffect::Effect::acceptsNumClicks(type));
// we pass the mouse click on to pen tool as the first click which it should collect
}
break;
case GDK_MOTION_NOTIFY:
{
break;
}
bool over_stroke = false;
if (over_stroke) {
} else {
}
}
break;
case GDK_BUTTON_RELEASE:
{
/**
break;
**/
}
case GDK_KEY_PRESS:
/**
switch (get_group0_keyval (&event->key)) {
}
break;
**/
case GDK_KEY_RELEASE:
/**
switch (get_group0_keyval(&event->key)) {
case GDK_Control_L:
case GDK_Control_R:
dc->_message_context->clear();
break;
default:
break;
}
**/
default:
break;
}
if (!ret) {
}
}
return ret;
}
/*
* Finds the index in the list of geometric subtools corresponding to the given LPE type.
* Returns -1 if no subtool is found.
*/
int
for (int i = 0; i < num_subtools; ++i) {
if (lpesubtools[i] == type) {
return i;
}
}
return -1;
}
/*
* Checks whether an item has a construction applied as LPE and if so returns the index in
* lpesubtools of this construction
*/
{
if (!SP_IS_LPE_ITEM(item)) {
return -1;
}
if (!lpe) {
return -1;
}
}
/*
* Attempts to perform the construction of the given type (i.e., to apply the corresponding LPE) to
* a single selected item. Returns whether we succeeded.
*/
bool
{
// TODO: should we check whether type represents a valid geometric construction?
if (item && SP_IS_LPE_ITEM(item) && Inkscape::LivePathEffect::Effect::acceptsNumClicks(type) == 0) {
return true;
}
return false;
}
void
{
if (index != -1) {
} else {
return;
}
}
void
}
/*
* Reads the limiting bounding box from preferences and draws it on the screen
*/
// TODO: Note that currently the bbox is not user-settable; we simply use the page borders
void
{
if (lc->canvas_bbox) {
}
return;
A *= doc2dt;
B *= doc2dt;
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(lc->canvas_bbox), 0x0000ffff, 0.8, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 5);
}
static void
const double t, const double length, bool use_curvature = false)
{
using namespace Geom;
}
void
{
bool show = prefs_get_int_attribute ("tools.lpetool", "show_measuring_info", 1) == 1 ? true : false;
if (!selection) {
}
double lengthval;
if (SP_IS_PATH(i->data)) {
if (!show)
SPUnitId unitid = static_cast<SPUnitId>(prefs_get_int_attribute("tools.lpetool", "unitid", SP_UNIT_PX));
arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px");
// TODO: must we free arc_length?
}
}
}
void
{
}
}
void
{
double lengthval;
SPUnitId unitid = static_cast<SPUnitId>(prefs_get_int_attribute("tools.lpetool", "unitid", SP_UNIT_PX));
arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px");
// TODO: must we free arc_length?
}
}
void
{
if (show) {
} else {
}
}
}
/*
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:encoding=utf-8:textwidth=99 :