measure-context.cpp revision 76c55e068d7f183a8c519a1954230eab80af325a
/*
* Our nice measuring tool
*
* Authors:
* Felipe Correa da Silva Sanches <juca@members.fsf.org>
*
* Copyright (C) 2011 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <gdk/gdkkeysyms.h>
#include "macros.h"
#include "sp-shape.h"
#include "display/sp-ctrlline.h"
#include "display/sodipodi-ctrl.h"
#include "display/sp-canvas-item.h"
#include "display/sp-canvas-util.h"
#include "desktop.h"
#include "document.h"
#include "pixmaps/cursor-measure.xpm"
#include "preferences.h"
#include "inkscape.h"
#include "desktop-handles.h"
#include "measure-context.h"
#include "display/canvas-text.h"
#include "path-chemistry.h"
static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
static SPEventContextClass *parent_class;
static bool within_tolerance = false;
{
if (!type) {
sizeof(SPMeasureContextClass),
sizeof(SPMeasureContext),
4,
NULL, /* value_table */
};
}
return type;
}
{
}
{
}
static void
{
ec->enableGrDrag(false);
}
}
{
}
}
static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
{
}
return ret;
}
{
}
{
case GDK_BUTTON_PRESS:
{
// save drag origin
within_tolerance = true;
}
if (!line){
}
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
break;
}
case GDK_MOTION_NOTIFY:
{
if ( within_tolerance
break; // do not drag if we're within tolerance from origin
}
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
within_tolerance = false;
sp_ctrlline_set_coords (SP_CTRLLINE(line), start_point[Geom::X], start_point[Geom::Y], motion_dt[Geom::X], motion_dt[Geom::Y]);
//TODO: calculate NPOINTS
//800 seems to be a good value for 800x600 resolution
#define NPOINTS 800
double i;
for (i=0; i<NPOINTS; i++){
}
//select elements crossed by line segment:
GSList *l;
int counter=0;
if (!ignore_1st_and_last){
}
#if 0
//TODO: deal with all kinds of objects:
if (!repr) continue;
if (!item) continue;
#else
if (SP_IS_SHAPE(item)) {
}
#endif
if (!curve) continue;
counter++;
// Find all intersections of the control-line with this shape
// Store the results as intersection points
unsigned int index = 0;
break;
}
// Reconstruct and store the points of intersection
}
index++;
}
//g_free(repr);
}
if (!ignore_1st_and_last){
}
//sort intersections
}
unsigned int idx;
}
// Display the intersection indicator (i.e. the cross)
"anchor", GTK_ANCHOR_CENTER,
"size", 8.0,
"stroked", TRUE,
"stroke_color", 0xff0000ff,
"mode", SP_KNOT_MODE_XOR,
"shape", SP_KNOT_SHAPE_CROSS,
NULL );
}
if (intersections.size()>0)
previous_point = intersections[0];
//TODO: shift label a few pixels in the y coordinate
SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->dt2doc(measure_text_pos), measure_str);
}
SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, motion_dt + desktop->w2d(Geom::Point(50,0)), angle_str);
}
break;
}
case GDK_BUTTON_RELEASE:
{
if (line){
}
unsigned int idx;
}
}
break;
}
default:
break;
}
if (!ret) {
}
}
return ret;
}
/*
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 :