361
361
if ( (value = repr->attribute("snapvisiblegridlinesonly")) ) {
362
g_assert(snapper != NULL);
363
snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
362
g_assert(snapper != NULL);
363
snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
366
366
for (GSList *l = canvasitems; l != NULL; l = l->next) {
367
367
sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
525
528
if (scaling_factor <= 1)
526
529
scaling_factor = 5;
529
531
int watchdog = 0;
530
532
while ( (sw[dim] < 8.0) & (watchdog < 100) ) {
532
534
sw[dim] *= scaling_factor;
533
535
// First pass, go up to the major line spacing, then
534
536
// keep increasing by two.
541
spacing_ylines = sw[Geom::X] * lengthy /(tan_angle[X] + tan_angle[Z]);
542
lyw = sw[Geom::Y] * lengthy;
543
lxw_x = (lengthy / tan_angle[X]) * sw[Geom::X];
544
lxw_z = (lengthy / tan_angle[Z]) * sw[Geom::X];
543
spacing_ylines = sw[Geom::X] /(tan_angle[X] + tan_angle[Z]);
545
lxw_x = sw[Geom::X] / tan_angle[X];
546
lxw_z = sw[Geom::X] / tan_angle[Z];
546
548
if (empspacing == 0) {
672
674
Geom::Coord CanvasAxonomGridSnapper::getSnapperTolerance() const
674
SPDesktop const *dt = _snapmanager->getDesktop();
675
double const zoom = dt ? dt->current_zoom() : 1;
676
return _snapmanager->snapprefs.getGridTolerance() / zoom;
676
SPDesktop const *dt = _snapmanager->getDesktop();
677
double const zoom = dt ? dt->current_zoom() : 1;
678
return _snapmanager->snapprefs.getGridTolerance() / zoom;
679
681
bool CanvasAxonomGridSnapper::getSnapperAlwaysSnap() const
694
696
double spacing_v;
696
698
if (getSnapVisibleOnly()) {
697
// Only snapping to visible grid lines
698
spacing_h = grid->spacing_ylines; // this is the spacing of the visible grid lines measured in screen pixels
699
spacing_v = grid->lyw; // vertical
700
// convert screen pixels to px
701
// FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
702
SPDesktop const *dt = _snapmanager->getDesktop();
704
spacing_h /= dt->current_zoom();
705
spacing_v /= dt->current_zoom();
708
// Snapping to any grid line, whether it's visible or not
709
spacing_h = grid->lengthy /(grid->tan_angle[X] + grid->tan_angle[Z]);
710
spacing_v = grid->lengthy;
699
// Only snapping to visible grid lines
700
spacing_h = grid->spacing_ylines; // this is the spacing of the visible grid lines measured in screen pixels
701
spacing_v = grid->lyw; // vertical
702
// convert screen pixels to px
703
// FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
704
SPDesktop const *dt = _snapmanager->getDesktop();
706
spacing_h /= dt->current_zoom();
707
spacing_v /= dt->current_zoom();
710
// Snapping to any grid line, whether it's visible or not
711
spacing_h = grid->lengthy /(grid->tan_angle[X] + grid->tan_angle[Z]);
712
spacing_v = grid->lengthy;
714
716
// In an axonometric grid, any point will be surrounded by 6 grid lines:
715
717
// - 2 vertical grid lines, one left and one right from the point
746
748
Geom::Point p_x(0, y_proj_along_x_max);
747
749
Geom::Line line_x(p_x, p_x + vers_x);
748
750
Geom::Point p_z(0, y_proj_along_z_max);
749
Geom::Line line_z(p_z, p_z + vers_z);
751
Geom::Line line_z(p_z, p_z + vers_z);
751
753
Geom::OptCrossing inters = Geom::OptCrossing(); // empty by default
754
inters = Geom::intersection(line_x, line_z);
756
catch (Geom::InfiniteSolutions e)
758
// We're probably dealing with parallel lines; this is useless!
756
inters = Geom::intersection(line_x, line_z);
758
catch (Geom::InfiniteSolutions e)
760
// We're probably dealing with parallel lines; this is useless!
762
764
// Determine which half of the parallelogram to use
763
765
bool use_left_half = true;
767
769
Geom::Point inters_pt = line_x.pointAt((*inters).ta);
768
use_left_half = (p[Geom::X] - grid->origin[Geom::X]) < inters_pt[Geom::X];
770
use_left_half = (p[Geom::X] - grid->origin[Geom::X]) < inters_pt[Geom::X];
769
771
use_right_half = !use_left_half;
789
void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, Geom::Point const normal_to_line, Geom::Point const point_on_line) const
791
void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const
791
SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
793
SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
792
794
sc.grid_lines.push_back(dummy);
795
void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source) const
797
void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
797
SnappedPoint dummy = SnappedPoint(snapped_point, source, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), true);
798
sc.points.push_back(dummy);
799
SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
800
sc.points.push_back(dummy);
801
803
bool CanvasAxonomGridSnapper::ThisSnapperMightSnap() const