canvas-axonomgrid.cpp revision bc2c9f897bc52112f52a3977137983e8fa3a7cc2
159N/A#define CANVAS_AXONOMGRID_C
159N/A * For example: the line drawing code should not be here. There _must_ be a function somewhere else that can provide this functionality...
159N/A#include "sp-canvas-util.h"
2745N/A#include "canvas-axonomgrid.h"
159N/A#include "display-forward.h"
618N/A#include "canvas-grid.h"
159N/A#include "desktop-handles.h"
844N/A#include "svg/svg-color.h"
1544N/A#include "xml/node-event-vector.h"
1544N/A#include "sp-object.h"
159N/A#include "sp-namedview.h"
2899N/A#include "inkscape.h"
159N/A#include "document.h"
159N/A#include "preferences.h"
1440N/A#define SAFE_SETPIXEL //undefine this when it is certain that setpixel is never called with invalid params
#ifdef SAFE_SETPIXEL
guint r, g, b, a;
p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
#ifdef SAFE_SETPIXEL
if (fraction >= 0) {
if (fraction >= 0) {
guint r, g, b, a;
guchar *p;
p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
namespace Inkscape {
* A DIRECT COPY-PASTE FROM DOCUMENT-PROPERTIES.CPP TO QUICKLY GET RESULTS
} else if (arr[i]) {
CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
if (!gridunit)
origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/origin_x", 0.0), *gridunit );
origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/origin_y", 0.0), *gridunit );
lengthy = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/spacing_y", 1.0), *gridunit );
angle_deg[Y] = 0;
if (!str) {
return FALSE;
gchar *u;
return FALSE;
while (isspace(*u)) {
*val = v;
return TRUE;
*val = v;
return TRUE;
return FALSE;
*val = v;
return TRUE;
return FALSE;
if (!str) {
return FALSE;
gchar *u;
return FALSE;
return TRUE;
* Called when XML node attribute changed; updates dialog widgets if change was not done by widgets themselves.
CanvasAxonomGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const */*key*/, gchar const */*oldval*/, gchar const */*newval*/, bool /*is_interactive*/)
readRepr();
Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = Gtk::manage( new Inkscape::UI::Widget::RegisteredUnitMenu(
Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
Inkscape::UI::Widget::RegisteredScalar *_rsu_ax = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
Inkscape::UI::Widget::RegisteredScalar *_rsu_az = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger(
0, _rumg,
0, _rsu_ox,
0, _rsu_oy,
0, _rsu_sy,
0, _rsu_ax,
0, _rsu_az,
0, _rsi,
return table;
_wr.setUpdating (true);
_rcb_visible.setActive(visible);
_rcb_enabled.setActive(snapper->getEnabled());
_rumg.setUnit (gridunit);
_rsu_ox.setValue (val);
_rsu_oy.setValue (val);
_rsu_sy.setValue (gridy);
_rsu_ax.setValue(angle_deg[X]);
_rsu_az.setValue(angle_deg[Z]);
_rcp_gcol.setRgba32 (color);
_rcp_gmcol.setRgba32 (empcolor);
_rsi.setValue (empspacing);
_wr.setUpdating (false);
int watchdog = 0;
watchdog++;
if (empspacing == 0) {
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
gdouble x;
gdouble y;
gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw );
gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X];
gint const zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw );
CanvasAxonomGridSnapper::CanvasAxonomGridSnapper(CanvasAxonomGrid *grid, SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d)
LineList s;
double scaled_spacing_h = grid->spacing_ylines; // this is spacing of visible lines if screen pixels
if (SP_ACTIVE_DESKTOP) {
Geom::Coord x_max = Inkscape::Util::round_to_upper_multiple_plus(p[Geom::X], scaled_spacing_h, grid->origin[Geom::X]);
Geom::Coord x_min = Inkscape::Util::round_to_lower_multiple_plus(p[Geom::X], scaled_spacing_h, grid->origin[Geom::X]);
double y_proj_along_z_max = Inkscape::Util::round_to_upper_multiple_plus(y_proj_along_z, scaled_spacing_v, grid->origin[Geom::Y]);
double y_proj_along_z_min = Inkscape::Util::round_to_lower_multiple_plus(y_proj_along_z, scaled_spacing_v, grid->origin[Geom::Y]);
double y_proj_along_x_max = Inkscape::Util::round_to_upper_multiple_plus(y_proj_along_x, scaled_spacing_v, grid->origin[Geom::Y]);
double y_proj_along_x_min = Inkscape::Util::round_to_lower_multiple_plus(y_proj_along_x, scaled_spacing_v, grid->origin[Geom::Y]);
result);
bool use_left_half = true;
bool use_right_half = true;
//std::cout << "intersection at " << result << " leads to use_left_half = " << use_left_half << " and use_right_half = " << use_right_half << std::endl;
if (use_left_half) {
if (use_right_half) {
void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, Geom::Point const normal_to_line, Geom::Point const point_on_line) const
SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
return _snap_enabled && _snapmanager->snapprefs.getSnapToGrids() && _snapmanager->snapprefs.getSnapModeBBoxOrNodes();