~ubuntu-branches/ubuntu/precise/inkscape/precise-updates

« back to all changes in this revision

Viewing changes to src/display/canvas-grid.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
635
635
    }
636
636
 
637
637
    if ( (value = repr->attribute("snapvisiblegridlinesonly")) ) {
638
 
                g_assert(snapper != NULL);
639
 
                snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
640
 
        }
 
638
        g_assert(snapper != NULL);
 
639
        snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
 
640
    }
641
641
 
642
642
    for (GSList *l = canvasitems; l != NULL; l = l->next) {
643
643
        sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
972
972
 */
973
973
Geom::Coord CanvasXYGridSnapper::getSnapperTolerance() const
974
974
{
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;
978
978
}
979
979
 
980
980
bool CanvasXYGridSnapper::getSnapperAlwaysSnap() const
993
993
 
994
994
    for (unsigned int i = 0; i < 2; ++i) {
995
995
 
996
 
        double spacing;
 
996
        double spacing;
997
997
 
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();
1004
 
                if (dt) {
1005
 
                        spacing /= dt->current_zoom();
1006
 
                }
 
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();
 
1004
            if (dt) {
 
1005
                spacing /= dt->current_zoom();
 
1006
            }
1007
1007
        } else {
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];
1010
1010
        }
1011
1011
 
1012
1012
        Geom::Coord rounded;
1024
1024
    return s;
1025
1025
}
1026
1026
 
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
1028
1028
{
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);
1031
1031
}
1032
1032
 
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
1034
1034
{
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);
1037
1037
}
1038
1038
 
1039
1039
/**