637
637
if ( (value = repr->attribute("snapvisiblegridlinesonly")) ) {
638
g_assert(snapper != NULL);
639
snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
638
g_assert(snapper != NULL);
639
snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
642
642
for (GSList *l = canvasitems; l != NULL; l = l->next) {
643
643
sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
973
973
Geom::Coord CanvasXYGridSnapper::getSnapperTolerance() const
975
SPDesktop const *dt = _snapmanager->getDesktop();
976
double const zoom = dt ? dt->current_zoom() : 1;
977
return _snapmanager->snapprefs.getGridTolerance() / zoom;
975
SPDesktop const *dt = _snapmanager->getDesktop();
976
double const zoom = dt ? dt->current_zoom() : 1;
977
return _snapmanager->snapprefs.getGridTolerance() / zoom;
980
980
bool CanvasXYGridSnapper::getSnapperAlwaysSnap() const
994
994
for (unsigned int i = 0; i < 2; ++i) {
998
if (getSnapVisibleOnly()) {
999
// Only snapping to visible grid lines
1000
spacing = grid->sw[i]; // this is the spacing of the visible grid lines measured in screen pixels
1001
// convert screen pixels to px
1002
// FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
1003
SPDesktop const *dt = _snapmanager->getDesktop();
1005
spacing /= dt->current_zoom();
998
if (getSnapVisibleOnly()) {
999
// Only snapping to visible grid lines
1000
spacing = grid->sw[i]; // this is the spacing of the visible grid lines measured in screen pixels
1001
// convert screen pixels to px
1002
// FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
1003
SPDesktop const *dt = _snapmanager->getDesktop();
1005
spacing /= dt->current_zoom();
1008
// Snapping to any grid line, whether it's visible or not
1009
spacing = grid->spacing[i];
1008
// Snapping to any grid line, whether it's visible or not
1009
spacing = grid->spacing[i];
1012
1012
Geom::Coord rounded;
1027
void CanvasXYGridSnapper::_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
1027
void CanvasXYGridSnapper::_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
1029
SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
1029
SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
1030
1030
sc.grid_lines.push_back(dummy);
1033
void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source) const
1033
void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
1035
SnappedPoint dummy = SnappedPoint(snapped_point, source, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), true);
1036
sc.points.push_back(dummy);
1035
SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
1036
sc.points.push_back(dummy);