draw-context.cpp revision 62820017a6d7b284d9495cb1951bc1a3b83a92d5
#define __SP_DRAW_CONTEXT_C__
/*
* Generic drawing context
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#define DRAW_VERBOSE
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gdk/gdkkeysyms.h>
#include "display/canvas-bpath.h"
#include "libnr/n-art-bpath.h"
#include "desktop.h"
#include "desktop-affine.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "document.h"
#include "draw-anchor.h"
#include "macros.h"
#include "message-stack.h"
#include "pen-context.h"
#include "prefs-utils.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "snap.h"
#include "sp-path.h"
#include "sp-namedview.h"
static SPEventContextClass *draw_parent_class;
sp_draw_context_get_type(void)
{
if (!type) {
sizeof(SPDrawContextClass),
sizeof(SPDrawContext),
4,
NULL, /* value_table */
};
}
return type;
}
static void
{
}
static void
{
dc->red_curve_is_valid = false;
}
static void
{
}
}
}
static void
{
}
/* Connect signals to track selection changes */
);
);
/* Create red bpath */
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->red_bpath), dc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
/* Create red curve */
/* Create blue bpath */
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->blue_bpath), dc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
/* Create blue curve */
/* Create green curve */
/* No green anchor by default */
}
static void
{
}
}
}
static void
{
}
{
//SPDrawContext *dc = SP_DRAW_CONTEXT(ec);
case GDK_KEY_PRESS:
case GDK_Escape:
break;
case GDK_Tab: // Tab - cycle selection forward
}
break;
case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
}
break;
case GDK_Up:
case GDK_Down:
case GDK_KP_Up:
case GDK_KP_Down:
// prevent the zoom field from activation
if (!MOD__CTRL_ONLY) {
}
break;
default:
break;
}
break;
default:
break;
}
if (!ret) {
}
}
return ret;
}
/*
* Selection handlers
*/
static void
{
}
}
/* fixme: We have to ensure this is not delayed (Lauris) */
static void
{
}
}
static void
{
/* Create new white data */
/* Item */
/* Curve list */
/* We keep it in desktop coordinates to eliminate calculation errors */
/* Anchor list */
SPCurve *c;
NArtBpath *s, *e;
SPDrawAnchor *a;
s = sp_curve_first_bpath(c);
e = sp_curve_last_bpath(c);
}
}
/* fixme: recalculate active anchor? */
}
}
/**
* Snaps node or handle to PI/rotationsnapsperpi degree increments.
*
* \param dc draw context
* \param p cursor point (to be changed by snapping)
* \param o origin point
* \param state keyboard state to check if ctrl was pressed
*/
{
/* Control must be down for this snap to work */
if ((state & GDK_CONTROL_MASK) == 0) {
return;
}
/* 0 means no snapping. */
/* mirrored by fabs, so this corresponds to 15 degrees */
double bdot = 0;
for (unsigned i = 0; i < snaps; i++) {
/* I think it is better numerically to use the normal, rather than the dot product
* to assess solutions, but I haven't proven it. */
best = v;
}
v = t;
}
/* Snap it along best vector */
}
}
{
/* Shift disables this snap */
if (state & GDK_SHIFT_MASK) {
return;
}
/* FIXME: this should be doing bbox snap as well */
}
static SPCurve *
{
return ret;
}
/**
* Concats red, blue and green.
* If any anchors are defined, process these, optionally removing curves from white list
* Invoke _flush_white to write result back to object.
*/
void
{
/* Concat RBG */
/* Green */
while (dc->green_bpaths) {
}
/* Blue */
/* Red */
if (dc->red_curve_is_valid) {
}
if (sp_curve_empty(c)) {
sp_curve_unref(c);
return;
}
/* Step A - test, whether we ended on green anchor */
// We hit green anchor, closing Green-Blue-Red
SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
/* Closed path, just flush */
spdc_flush_white(dc, c);
sp_curve_unref(c);
return;
}
/* Step B - both start and end anchored to same curve */
{
// We hit bot start and end of single curve, closing paths
c = reverse_then_unref(c);
}
sp_curve_unref(c);
return;
}
/* Step C - test start */
s = reverse_then_unref(s);
}
sp_curve_append_continuous(s, c, 0.0625);
sp_curve_unref(c);
c = s;
e = reverse_then_unref(e);
}
sp_curve_append_continuous(c, e, 0.0625);
sp_curve_unref(e);
}
spdc_flush_white(dc, c);
sp_curve_unref(c);
}
static char const *
{
return ( SP_IS_PEN_CONTEXT(dc)
? "tools.freehand.pen"
: "tools.freehand.pencil" );
}
/*
* Flushes white curve(s) and additional curve into object
*
* No cleaning of colored curves - this has to be done by caller
* No rereading of white data, so if you cannot rely on ::modified, do it in caller
*
*/
static void
{
SPCurve *c;
if (dc->white_curves) {
if (gc) {
}
} else if (gc) {
c = gc;
sp_curve_ref(c);
} else {
return;
}
/* Now we have to go back to item coordinates at last */
if ( c && !sp_curve_empty(c) ) {
/* We actually have something to write */
if (dc->white_item) {
} else {
/* Set style */
}
if (!dc->white_item) {
/* Attach repr */
item->updateRepr();
}
}
sp_curve_unref(c);
/* Flush pending updates */
}
/**
* Returns FIRST active anchor (the activated one).
*/
{
/* Test green anchor */
if (dc->green_anchor) {
}
}
}
return active;
}
static void
{
if (dc->white_item) {
/* We do not hold refcount */
}
while (dc->white_curves) {
}
while (dc->white_anchors) {
}
}
static void
{
/* Red */
}
}
/* Blue */
if (dc->blue_bpath) {
}
if (dc->blue_curve) {
}
/* Green */
while (dc->green_bpaths) {
}
if (dc->green_curve) {
}
if (dc->green_anchor) {
}
/* White */
if (dc->white_item) {
/* We do not hold refcount */
}
while (dc->white_curves) {
}
while (dc->white_anchors) {
}
}
/*
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 :