~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/object-snapper.cpp

  • Committer: Ted Gould
  • Date: 2008-11-21 05:24:08 UTC
  • Revision ID: ted@canonical.com-20081121052408-tilucis2pjrrpzxx
MergeĀ fromĀ fe-moved

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
                if (SP_IS_GROUP(o)) {
139
139
                    _findCandidates(o, it, false, bbox_to_snap, snap_dim, false, Geom::identity());
140
140
                } else {
141
 
                    boost::optional<Geom::Rect> bbox_of_item = Geom::Rect();
 
141
                    Geom::OptRect bbox_of_item = Geom::Rect();
142
142
                    if (clip_or_mask) {
143
143
                        // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to
144
144
                        // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
215
215
                    // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox
216
216
                    // of the item AND the bbox of the clipping path at the same time
217
217
                    if (!(*i).clip_or_mask) {  
218
 
                        boost::optional<Geom::Rect> b = sp_item_bbox_desktop(root_item, bbox_type);
 
218
                        Geom::OptRect b = sp_item_bbox_desktop(root_item, bbox_type);
219
219
                        if (b) {
220
220
                            for ( unsigned k = 0 ; k < 4 ; k++ ) {
221
221
                                _points_to_snap_to->push_back(b->corner(k));
378
378
                    // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox
379
379
                    // of the item AND the bbox of the clipping path at the same time
380
380
                    if (!(*i).clip_or_mask) { 
381
 
                        NRRect rect;
382
 
                        sp_item_invoke_bbox(root_item, &rect, i2doc, TRUE, bbox_type);
383
 
                        Geom::Rect const rect2 = to_2geom(*rect.upgrade());
384
 
                        Geom::PathVector *path = _getPathvFromRect(rect2);
385
 
                        _paths_to_snap_to->push_back(path);                        
 
381
                        Geom::OptRect rect;
 
382
                        sp_item_invoke_bbox(root_item, rect, i2doc, TRUE, bbox_type);
 
383
                        if (rect) {
 
384
                                Geom::PathVector *path = _getPathvFromRect(*rect);
 
385
                                _paths_to_snap_to->push_back(path);
 
386
                        }
386
387
                    }
387
388
                }
388
389
            }
406
407
    bool const node_tool_active = _snap_to_itempath && selected_path != NULL;
407
408
    
408
409
    if (first_point) {
409
 
        /* While editing a path in the node tool, findCandidates must ignore that path because 
410
 
         * of the node snapping requirements (i.e. only unselected nodes must be snapable).
 
410
        /* findCandidates() is used for snapping to both paths and nodes. It ignores the path that is
 
411
         * currently being edited, because that path requires special care: when snapping to nodes 
 
412
         * only the unselected nodes of that path should be considered, and these will be passed on separately.
411
413
         * This path must not be ignored however when snapping to the paths, so we add it here
412
414
         * manually when applicable. 
413
415
         * 
452
454
                    g_assert(unselected_nodes != NULL);
453
455
                    Geom::Point start_pt = _snapmanager->getDesktop()->doc2dt(curve->pointAt(0)); 
454
456
                    Geom::Point end_pt = _snapmanager->getDesktop()->doc2dt(curve->pointAt(1));                                    
455
 
                    c1 = isUnselectedNode(start_pt, unselected_nodes);
456
 
                    c2 = isUnselectedNode(end_pt, unselected_nodes);
 
457
                    c1 = isUnselectedNode(start_pt, unselected_nodes); 
 
458
                    c2 = isUnselectedNode(end_pt, unselected_nodes);  
 
459
                    /* Unfortunately, this might yield false positives for coincident nodes. Inkscape might therefore mistakenly
 
460
                     * snap to path segments that are not stationary. There are at least two possible ways to overcome this:
 
461
                     * - Linking the individual nodes of the SPPath we have here, to the nodes of the NodePath::SubPath class as being
 
462
                     *   used in sp_nodepath_selected_nodes_move. This class has a member variable called "selected". For this the nodes
 
463
                     *   should be in the exact same order for both classes, so we can index them
 
464
                     * - Replacing the SPPath being used here by the the NodePath::SubPath class; but how?
 
465
                     */ 
457
466
                }
458
467
                
459
468
                Geom::Point const sp_dt = _snapmanager->getDesktop()->doc2dt(sp_doc);                
550
559
                                            Inkscape::SnapPreferences::PointType const &t,
551
560
                                            Geom::Point const &p,
552
561
                                            bool const &first_point,
553
 
                                            boost::optional<Geom::Rect> const &bbox_to_snap,
 
562
                                            Geom::OptRect const &bbox_to_snap,
554
563
                                            std::vector<SPItem const *> const *it,
555
564
                                            std::vector<Geom::Point> *unselected_nodes) const
556
565
{
593
602
                                                  Inkscape::SnapPreferences::PointType const &t,
594
603
                                                  Geom::Point const &p,
595
604
                                                  bool const &first_point,
596
 
                                                  boost::optional<Geom::Rect> const &bbox_to_snap,
 
605
                                                  Geom::OptRect const &bbox_to_snap,
597
606
                                                  ConstraintLine const &c,
598
607
                                                  std::vector<SPItem const *> const *it) const
599
608
{