canvas-axonomgrid.cpp revision 1ed822fb016bc35dbe5bd8601ed2bca74ff8cf60
#define CANVAS_AXONOMGRID_C
/*
* Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
*/
/*
* Current limits are: one axis (y-axis) is always vertical. The other two
* axes are bound to a certain range of angles. The z-axis always has an angle
* smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending
* to the right). The x-axis will always have an angle between 0 and 90 degrees.
* When I quickly think about it: all possibilities are probably covered this way. Eg.
* a z-axis with negative angle can be replaced with an x-axis, etc.
*/
/*
* TODO: LOTS LOTS LOTS. Clean up code. dirty as hell
* THIS FILE AND THE HEADER FILE NEED HUGE CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO.
* For example: the line drawing code should not be here. There _must_ be a function somewhere else that can provide this functionality...
*/
#include "sp-canvas-util.h"
#include "canvas-axonomgrid.h"
#include "display-forward.h"
#include <libnr/nr-pixops.h>
#include "canvas-grid.h"
#include "desktop-handles.h"
#include "svg/svg-color.h"
#include "xml/node-event-vector.h"
#include "sp-object.h"
#include "sp-namedview.h"
#include "inkscape.h"
#include "desktop.h"
#include "document.h"
#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params
enum Dim3 { X=0, Y, Z };
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
/**
\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) {
}
}
}
}
static void
{
guint r, g, b, a;
guchar *p;
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]);
p += buf->buf_rowstride;
}
}
}
namespace Inkscape {
/**
* A DIRECT COPY-PASTE FROM DOCUMENT-PROPERTIES.CPP TO QUICKLY GET RESULTS
*
* Helper function that attachs widgets in a 3xn table. The widgets come in an
* array that has two entries per table row. The two entries code for four
* possible cases: (0,0) means insert space in first column; (0, non-0) means
* widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
* (non-0, non-0) means two widgets in columns 2 and 3.
**/
#define SPACE_SIZE_X 15
#define SPACE_SIZE_Y 10
static inline void
{
} else {
if (arr[i+1]) {
} else if (arr[i]) {
} else {
}
}
++r;
}
}
CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
{
color = 0xff3f3f20;
empcolor = 0xFF3F3F40;
empspacing = 5;
angle_deg[Y] =0;
lengthy = 1;
// initialize widgets:
_("Color of the major (highlighted) grid lines"),
0, 0,
};
}
{
}
/* fixme: Collect all these length parsing methods and think common sane API */
{
if (!str) {
return FALSE;
}
gchar *u;
if (!u) {
return FALSE;
}
while (isspace(*u)) {
u += 1;
}
if (!*u) {
/* No unit specified - keep default */
*val = v;
return TRUE;
}
if (base & SP_UNIT_DEVICE) {
*val = v;
return TRUE;
}
}
if (base & SP_UNIT_ABSOLUTE) {
} else {
return FALSE;
}
*val = v;
return TRUE;
}
return FALSE;
}
{
if (!str) {
return FALSE;
}
gchar *u;
if (!u) {
return FALSE;
}
return TRUE;
}
void
{
}
}
}
}
}
}
}
}
}
}
}
}
}
return;
}
/**
* Called when XML node attribute changed; updates dialog widgets if change was not done by widgets themselves.
*/
void
CanvasAxonomGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const */*key*/, gchar const */*oldval*/, gchar const */*newval*/, bool /*is_interactive*/)
{
readRepr();
if ( ! (_wr.isUpdating()) )
}
{
return vbox;
}
/**
* Update dialog widgets from object's values.
*/
void
{
if (_wr.isUpdating()) return;
_wr.setUpdating (true);
_wr.setUpdating (false);
return;
}
void
{
if (scaling_factor <= 1)
scaling_factor = 5;
int watchdog = 0;
// First pass, go up to the major line spacing, then
// keep increasing by two.
scaling_factor = 2;
watchdog++;
}
}
if (empspacing == 0) {
}
}
void
{
// gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow'.
// sc = screencoordinates ( for example "buf->rect.x0" is in screencoordinates )
// bc = buffer patch coordinates
// tl = topleft ; br = bottomright
gdouble x;
gdouble y;
// render the three separate line groups representing the main-axes:
// x-axis always goes from topleft to bottomright. (0,0) - (1,1)
// lijnen vanaf linker zijkant.
} else {
}
}
// lijnen vanaf bovenkant.
} else {
}
}
// y-axis lines (vertical)
} else {
}
}
// z-axis always goes from bottomleft to topright. (0,1) - (1,0)
// lijnen vanaf linker zijkant.
} else {
}
}
// draw lines from bottom-up
} else {
}
}
}
/**
* \return x rounded to the nearest multiple of c1 plus c0.
*
* \note
* If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero
* mean "ignore the grid in this dimention". We're currently discussing "good" semantics
*/
/* FIXME: move this somewhere else, perhaps */
{
}
CanvasAxonomGridSnapper::CanvasAxonomGridSnapper(CanvasAxonomGrid *grid, SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d)
{
}
{
LineList s;
return s;
}
for (unsigned int i = 0; i < 2; ++i) {
/* This is to make sure we snap to only visible grid lines */
// convert screen pixels to px
// FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
if (SP_ACTIVE_DESKTOP) {
}
}
return s;
}
void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, NR::Point const point_on_line) const
{
}
}; // namespace Inkscape
/*
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 :