measure-context.cpp revision d30d92cb3986f498497418917e65f061073f81f8
/*
* 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 "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.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 "draw-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;
}
{
else
}
void calculate_intersections(SPDesktop *desktop, SPItem* item, Geom::PathVector *lineseg, SPCurve *curve, std::vector<Geom::Point> *intersections){
// Find all intersections of the control-line with this shape
// Reconstruct and store the points of intersection
#if 0
//TODO: consider only visible intersections
double eps = 0.0001;
}
#else
#endif
}
}
{
case GDK_BUTTON_PRESS:
{
// save drag origin
within_tolerance = true;
}
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;
//clear previous temporary canvas items, we'll draw new ones
unsigned int idx;
}
//rotation constraint
//draw control line
//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;
if (!ignore_1st_and_last){
}
if (SP_IS_SHAPE(item)) {
} else {
do {
break;
// get path from iter to iter_next:
if (!curve) continue; // error converting this glyph
continue;
}
break;
} while (true);
}
}
}
if (!ignore_1st_and_last){
}
//sort intersections
}
// 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, end_point + desktop->w2d(Geom::Point(5*fontsize,0)), angle_str);
}
break;
}
case GDK_BUTTON_RELEASE:
{
//clear all temporary canvas items related to the measurement tool.
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 :