Ignore:
Timestamp:
2008-08-18T01:27:58+02:00 (16 years ago)
Author:
stoecker
Message:

Added virtual nodes in select mode. Closes #595.

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r804 r805  
    182182        }
    183183
     184        private Boolean virtualnodes = false;
     185        public void enableVirtualNodes(Boolean state)
     186        {
     187                if(virtualnodes != state)
     188                {
     189                        virtualnodes = state;
     190                        repaint();
     191                }
     192        }
     193        public Boolean useVirtualNodes()
     194        {
     195                return virtualnodes;
     196        }
     197
    184198        /**
    185199         * Moves the layer to the given new position. No event is fired.
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r794 r805  
    3232public class NavigatableComponent extends JComponent implements Helpful {
    3333
    34 
    3534        public static final EastNorth world = Main.proj.latlon2eastNorth(new LatLon(Projection.MAX_LAT, Projection.MAX_LON));
    36 
     35        public static final int snapDistance = sqr(Main.pref.getInteger("node.snap-distance", 10));
     36
     37        private static int sqr(int a) { return a*a;}
    3738        /**
    3839         * The scale factor in x or y-units per pixel. This means, if scale = 10,
     
    141142                        Point sp = getPoint(n.eastNorth);
    142143                        double dist = p.distanceSq(sp);
    143                         if (minDistanceSq > dist && dist < 100) {
     144                        if (minDistanceSq > dist && dist < snapDistance) {
    144145                                minDistanceSq = p.distanceSq(sp);
    145146                                minPrimitive = n;
     
    180181                                double b = p.distanceSq(A);
    181182                                double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared
    182                                 if (perDist < 100 && a < c+100 && b < c+100) {
     183                                if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) {
    183184                                        List<WaySegment> l;
    184185                                        if (nearest.containsKey(perDist)) {
     
    228229                WaySegment nearestWaySeg = getNearestWaySegment(p);
    229230                return nearestWaySeg == null ? null : nearestWaySeg.way;
    230     }
     231        }
    231232
    232233        /**
     
    240241         * If nothing is found, return <code>null</code>.
    241242         *
    242          * @param p                              The point on screen.
    243          * @return      The primitive that is nearest to the point p.
     243         * @param p The point on screen.
     244         * @return  The primitive that is nearest to the point p.
    244245         */
    245246        public OsmPrimitive getNearest(Point p) {
    246247                OsmPrimitive osm = getNearestNode(p);
    247248                if (osm == null)
     249                {
    248250                        osm = getNearestWay(p);
     251                }
    249252                return osm;
    250253        }
     
    258261                        return Collections.emptySet();
    259262                return Collections.singleton(osm);
    260         }
    261 
    262         @Deprecated
    263         public OsmPrimitive getNearest(Point p, boolean segmentInsteadWay) {
    264                 return getNearest(p);
    265263        }
    266264
     
    290288                                double b = p.distanceSq(A);
    291289                                double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared
    292                                 if (perDist < 100 && a < c+100 && b < c+100) {
     290                                if (perDist < snapDistance && a < c+snapDistance && b < c+snapDistance) {
    293291                                        nearest.add(w);
    294292                                                break;
     
    299297                for (Node n : Main.ds.nodes) {
    300298                        if (!n.deleted && !n.incomplete
    301                                         && getPoint(n.eastNorth).distanceSq(p) < 100) {
     299                                        && getPoint(n.eastNorth).distanceSq(p) < snapDistance) {
    302300                                nearest.add(n);
    303301                        }
     
    318316                for (Node n : Main.ds.nodes) {
    319317                        if (!n.deleted && !n.incomplete
    320                                         && getPoint(n.eastNorth).distanceSq(p) < 100) {
     318                                        && getPoint(n.eastNorth).distanceSq(p) < snapDistance) {
    321319                                nearest.add(n);
    322320                        }
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r804 r805  
    148148        @Override public void paint(final Graphics g, final MapView mv) {
    149149                boolean inactive = Main.map.mapView.getActiveLayer() != this && Main.pref.getBoolean("draw.data.inactive_color", true);
     150                boolean virtual = !inactive && Main.map.mapView.useVirtualNodes();
    150151                if (Main.pref.getBoolean("draw.data.downloaded_area", true)) {
    151152                        // FIXME this is inefficient; instead a proper polygon has to be built, and instead
     
    169170                        wireframeMapPainter.setNavigatableComponent(mv);
    170171                        wireframeMapPainter.inactive = inactive;
    171                         wireframeMapPainter.visitAll(data);
     172                        wireframeMapPainter.visitAll(data, virtual);
    172173                }
    173174                else
     
    176177                        standardMapPainter.setNavigatableComponent(mv);
    177178                        standardMapPainter.inactive = inactive;
    178                         standardMapPainter.visitAll(data);
     179                        standardMapPainter.visitAll(data, virtual);
    179180                }
    180181                Main.map.conflictDialog.paintConflicts(g, mv);
  • trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java

    r781 r805  
    2727        private JCheckBox segmentOrderNumber = new JCheckBox(tr("Draw segment order numbers"));
    2828        private JCheckBox sourceBounds = new JCheckBox(tr("Draw boundaries of downloaded data"));
     29        private JCheckBox virtualNodes = new JCheckBox(tr("Draw virtual nodes in select mode"));
    2930        private JCheckBox inactive = new JCheckBox(tr("Draw inactive layers in other color"));
    3031        private JCheckBox useAntialiasing = new JCheckBox(tr("Smooth map graphics (antialiasing)"));
     
    121122                sourceBounds.setSelected(Main.pref.getBoolean("draw.data.downloaded_area", true));
    122123                gui.display.add(sourceBounds, GBC.eop().insets(20,0,0,0));
    123                
     124
     125                // virtual nodes
     126                virtualNodes.setToolTipText(tr("Draw virtual nodes in select mode for easy way modification."));
     127                virtualNodes.setSelected(Main.pref.getInteger("mappaint.node.virtual-size", 4) != 0);
     128                gui.display.add(virtualNodes, GBC.eop().insets(20,0,0,0));
     129
    124130                // background layers in inactive color
    125131                inactive.setToolTipText(tr("Draw the inactive data layers in a different color."));
     
    142148                Main.pref.put("draw.data.inactive_color", inactive.isSelected());
    143149                Main.pref.put("mappaint.use-antialiasing", useAntialiasing.isSelected());
     150                Main.pref.put("mappaint.node.virtual-size", virtualNodes.isSelected() ? "4" : "0");
    144151    }
    145152}
Note: See TracChangeset for help on using the changeset viewer.