Ticket #7991: 7991-DualAlignFixes.patch

File 7991-DualAlignFixes.patch, 2.3 KB (added by AlfonZ, 11 years ago)

Setting DualAlignSegmentCollapsed to false at the beginning and the end of action, so status line displays correctly.
Alt+DualAlign+Collapse now doesn't even create the fourth node.

  • src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

     
    179179    /** Dual alignment reference segments */
    180180    private ReferenceSegment dualAlignSegment1, dualAlignSegment2;
    181181    /** {@code true}, if new segment was collapsed */
    182     private boolean dualAlignSegmentCollapsed;
     182    private boolean dualAlignSegmentCollapsed = false;
    183183    // Dual alignment UI stuff
    184184    private final DualAlignChangeAction dualAlignChangeAction;
    185185    private final JCheckBoxMenuItem dualAlignCheckboxMenuItem;
     
    547547            selectedSegment = null;
    548548            moveCommand = null;
    549549            mode = Mode.select;
     550            dualAlignSegmentCollapsed = false;
    550551            updateStatusLine();
    551552            Main.map.mapView.repaint();
    552553        }
     
    589590        wnew.addNode(selectedSegment.getFirstNode());
    590591        wnew.addNode(selectedSegment.getSecondNode());
    591592        wnew.addNode(third);
    592         if (newN1en.distance(newN2en)>1e-6) {
    593             wnew.addNode(fourth); // rectangle can degrade to triangle for dual alignment
     593        if (!dualAlignSegmentCollapsed) {
     594            // rectangle can degrade to triangle for dual alignment after collapsing
     595            wnew.addNode(fourth);
    594596        }
    595597        // ... and close the way
    596598        wnew.addNode(selectedSegment.getFirstNode());
    597599        // undo support
    598600        cmds.add(new AddCommand(third));
    599         cmds.add(new AddCommand(fourth));
     601        if (!dualAlignSegmentCollapsed) {
     602            cmds.add(new AddCommand(fourth));
     603        }
    600604        cmds.add(new AddCommand(wnew));
    601605        Command c = new SequenceCommand(tr("Extrude Way"), cmds);
    602606        Main.main.undoRedo.add(c);
     
    692696    }
    693697
    694698    private void joinNodesIfCollapsed(List<Node> changedNodes) {
    695         if (!dualAlignActive || newN1en == null || newN2en == null) return;
     699        if (!dualAlignSegmentCollapsed) return;
    696700        if (newN1en.distance(newN2en) > 1e-6) return;
    697701        // If the dual alignment moved two nodes to the same point, merge them
    698702        Node targetNode = MergeNodesAction.selectTargetNode(changedNodes);