Ignore:
Timestamp:
2011-09-12T19:25:00+02:00 (13 years ago)
Author:
akks
Message:

'Utilsplugin2: select all inside (testing)'

Location:
applications/editors/josm/plugins/utilsplugin2
Files:
2 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/build.xml

    r26639 r26644  
    3030<project name="utilsplugin2" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="Utilsplugin2: configuring custom URLs"/>
     32    <property name="commit.message" value="Utilsplugin2: select all inside (testing)"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="4395"/>
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java

    r26639 r26644  
    3030    JMenuItem intWays;
    3131    JMenuItem intWaysR;
     32    JMenuItem allInside;
    3233    JMenuItem undoSelection;
    3334    JMenuItem extractPoint;
     
    7374        intWays = MainMenu.add(selectionMenu, new IntersectedWaysAction());
    7475        intWaysR = MainMenu.add(selectionMenu, new IntersectedWaysRecursiveAction());
     76        allInside = MainMenu.add(selectionMenu, new SelectAllInsideAction());
    7577        selModifiedNodes = MainMenu.add(selectionMenu, new SelectModNodesAction());
    7678        selModifiedWays = MainMenu.add(selectionMenu, new SelectModWaysAction());
     
    110112        undoSelection.setEnabled(enabled);
    111113        selectURL.setEnabled(enabled);
     114        allInside.setEnabled(enabled);
    112115    }
    113116    @Override
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysAction.java

    r25876 r26644  
    3030
    3131    public void actionPerformed(ActionEvent e) {
    32         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
    33         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    34         Set<Way> activeWays = new HashSet<Way>();
    35 
    3632        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
    3733
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/IntersectedWaysRecursiveAction.java

    r26639 r26644  
    3232    public void actionPerformed(ActionEvent e) {
    3333        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
    34         Set<Node> selectedNodes = OsmPrimitive.getFilteredSet(selection, Node.class);
    35         Set<Way> activeWays = new HashSet<Way>();
    36 
     34       
    3735        Set<Way> selectedWays = OsmPrimitive.getFilteredSet(getCurrentDataSet().getSelected(), Way.class);
    3836
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/NodeWayUtils.java

    r26051 r26644  
    99import javax.swing.JOptionPane;
    1010import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.osm.BBox;
     12import org.openstreetmap.josm.data.osm.DataSet;
    1113import org.openstreetmap.josm.data.osm.Node;
    1214import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    263265    }
    264266
    265 
     267   
     268
     269    static void addAllInsideWay(DataSet data, Way way, Set<Way> newWays, Set<Node> newNodes) {
     270        if (!way.isClosed()) return;
     271        BBox box = way.getBBox();
     272        List<Node> polyNodes = way.getNodes();
     273        List<Node> searchNodes = data.searchNodes(box);
     274        Set<Node> newestNodes = new HashSet<Node>();
     275        Set<Way> newestWays = new HashSet<Way>();
     276        for (Node n : searchNodes) {
     277            if (Geometry.nodeInsidePolygon(n, polyNodes)) {
     278                newestNodes.add(n);
     279            }
     280        }
     281       
     282        List<Way> searchWays = data.searchWays(box);
     283        for (Way w : searchWays) {
     284            if (newestNodes.containsAll(w.getNodes())) {
     285                newestWays.add(w);
     286            }
     287        }
     288        for (Way w : newestWays) {
     289            newestNodes.removeAll(w.getNodes());
     290            // do not select nodes of already selected ways
     291        }
     292       
     293        newNodes.addAll(newestNodes);
     294        newWays.addAll(newestWays);
     295    }
    266296}
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/selection/SelectAllInsideAction.java

    r26641 r26644  
    2020 *    Extends current selection by selecting nodes on all touched ways
    2121 */
    22 public class IntersectedWaysAction extends JosmAction {
     22public class SelectAllInsideAction extends JosmAction {
    2323
    24     public IntersectedWaysAction() {
    25         super(tr("Intersecting ways"), "intway", tr("Select intersecting ways"),
    26                 Shortcut.registerShortcut("tools:intway", tr("Tool: {0}","Intersecting ways"),
    27                 KeyEvent.VK_I, Shortcut.GROUP_EDIT), true);
    28         putValue("help", ht("/Action/SelectIntersectingWays"));
     24    public SelectAllInsideAction() {
     25        super(tr("All inside [testing]"), "selinside", tr("Select all inside selected polygons"),
     26                Shortcut.registerShortcut("tools:selinside", tr("Tool: {0}","All inside"),
     27                KeyEvent.VK_I, Shortcut.GROUP_EDIT ,KeyEvent.ALT_DOWN_MASK|KeyEvent.SHIFT_DOWN_MASK), true);
     28        putValue("help", ht("/Action/SelectAllInside"));
    2929    }
    3030
     
    3939        if (!selectedWays.isEmpty()) {
    4040            Set<Way> newWays = new HashSet<Way>();
    41             NodeWayUtils.addWaysIntersectingWays(
    42                     getCurrentDataSet().getWays(),
    43                     selectedWays, newWays);
     41            Set<Node> newNodes = new HashSet<Node>();
     42            for (Way w: selectedWays) {
     43                NodeWayUtils.addAllInsideWay(getCurrentDataSet(),w,newWays,newNodes);
     44            }
    4445            getCurrentDataSet().addSelected(newWays);
     46            getCurrentDataSet().addSelected(newNodes);
    4547            return;
    4648        } else {
Note: See TracChangeset for help on using the changeset viewer.