guideline.cpp revision 30c340c2c1ad07599daa4e97135cc3786e6a70fc
#define __SP_GUIDELINE_C__
/*
* Horizontal/vertical but can also be angled line
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Johan Engelen
*
* Copyright (C) 2000-2002 Lauris Kaplinski
* Copyright (C) 2007 Johan Engelen
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <libnr/nr-pixops.h>
#include "display-forward.h"
#include "sp-canvas-util.h"
#include "guideline.h"
static void sp_guideline_class_init(SPGuideLineClass *c);
static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba);
static SPCanvasItemClass *parent_class;
{
static GType guideline_type = 0;
if (!guideline_type) {
static GTypeInfo const guideline_info = {
sizeof (SPGuideLineClass),
sizeof (SPGuideLine),
16,
NULL,
};
guideline_type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPGuideLine", &guideline_info, (GTypeFlags) 0);
}
return guideline_type;
}
static void sp_guideline_class_init(SPGuideLineClass *c)
{
}
{
}
{
}
{
if (gl->is_vertical()) {
return;
}
d[0] = NR_COMPOSEN11_1111(r, a, d[0]);
d += step;
}
} else if (gl->is_horizontal()) {
return;
}
int step = 3;
d[0] = NR_COMPOSEN11_1111(r, a, d[0]);
d += step;
}
} else {
// render angled line, once intersection has been detected, draw from there.
//try to intersect with left vertical of rect
double y_intersect_left = (buf->rect.x0 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y];
// intersects with left vertical!
double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y];
sp_guideline_drawline (buf, buf->rect.x0, round(y_intersect_left), buf->rect.x1, round(y_intersect_right), gl->rgba);
return;
}
//try to intersect with right vertical of rect
double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y];
// intersects with right vertical!
sp_guideline_drawline (buf, buf->rect.x1, round(y_intersect_right), buf->rect.x0, round(y_intersect_left), gl->rgba);
return;
}
//try to intersect with top horizontal of rect
double x_intersect_top = (buf->rect.y0 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X];
// intersects with top horizontal!
double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X];
sp_guideline_drawline (buf, round(x_intersect_top), buf->rect.y0, round(x_intersect_bottom), buf->rect.y1, gl->rgba);
return;
}
//try to intersect with bottom horizontal of rect
double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X];
// intersects with bottom horizontal!
sp_guideline_drawline (buf, round(x_intersect_bottom), buf->rect.y1, round(x_intersect_top), buf->rect.y0, gl->rgba);
return;
}
}
}
{
}
if (gl->is_horizontal()) {
sp_canvas_update_bbox (item, -1000000, gl->point_on_line[Geom::Y], 1000000, gl->point_on_line[Geom::Y] + 1);
} else if (gl->is_vertical()) {
sp_canvas_update_bbox (item, gl->point_on_line[Geom::X], -1000000, gl->point_on_line[Geom::X]+1, 1000000);
} else {
}
}
// Returns 0.0 if point is on the guideline
{
return NR_HUGE;
}
*actual_item = item;
}
SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, Geom::Point normal)
{
return item;
}
{
}
{
}
{
}
{
}
//##########################################################
// Line rendering
#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params
/**
\brief This function renders a pixel on a particular buffer.
The topleft of the buffer equals
( rect.x0 , rect.y0 ) in screen coordinates
( 0 , 0 ) in setpixel coordinates
The bottomright of the buffer equals
( rect.x1 , rect,y1 ) in screen coordinates
( rect.x1 - rect.x0 , rect.y1 - rect.y0 ) in setpixel coordinates
*/
static void
{
#ifdef SAFE_SETPIXEL
#endif
guint r, g, b, a;
r = NR_RGBA32_R (rgba);
g = NR_RGBA32_G (rgba);
b = NR_RGBA32_B (rgba);
a = NR_RGBA32_A (rgba);
p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
#ifdef SAFE_SETPIXEL
}
#endif
}
/**
\brief This function renders a line on a particular canvas buffer,
using Bresenham's line drawing function.
Coordinates are interpreted as SCREENcoordinates
*/
static void
{
if (fraction >= 0) {
}
}
} else {
if (fraction >= 0) {
}
}
}
}
/*
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 :