Changeset 31375 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-07-15T16:34:24+02:00 (9 years ago)
Author:
nokutu
Message:

Fixed double click and shift click for sequences of imported images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    r31358 r31375  
    4848    if (e.getButton() != MouseEvent.BUTTON1)
    4949      return;
    50     MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
    51     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closestTemp != null
    52         && Main.map.mapMode == Main.map.mapModeSelect) {
     50    MapillaryAbstractImage closest = getClosest(e.getPoint());
     51    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     52        && closest != null && Main.map.mapMode == Main.map.mapModeSelect) {
    5353      this.lastClicked = this.closest;
    54       MapillaryData.getInstance().setSelectedImage(closestTemp);
    55       return;
    56     } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance())
    57       return;
    58     if (closestTemp instanceof MapillaryImage || closestTemp == null) {
    59       MapillaryImage closest = (MapillaryImage) closestTemp;
    60       // Doube click
    61       if (e.getClickCount() == 2 && data.getSelectedImage() != null && closest != null) {
    62         for (MapillaryAbstractImage img : closest.getSequence().getImages()) {
    63           data.addMultiSelectedImage(img);
    64         }
    65       }
    66       this.start = e.getPoint();
    67       this.lastClicked = this.closest;
    68       this.closest = closest;
    69       if (data.getMultiSelectedImages().contains(closest))
    70         return;
    71       // ctrl+click
    72       if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK) && closest != null)
    73         data.addMultiSelectedImage(closest);
    74       // shift + click
    75       else if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)
    76           && this.closest instanceof MapillaryImage && this.lastClicked instanceof MapillaryImage) {
    77         if (this.closest != null && this.lastClicked != null
    78             && ((MapillaryImage) this.closest).getSequence() == ((MapillaryImage) this.lastClicked).getSequence()) {
    79           int i = ((MapillaryImage) this.closest).getSequence().getImages().indexOf(this.closest);
    80           int j = ((MapillaryImage) this.lastClicked).getSequence().getImages().indexOf(this.lastClicked);
    81           if (i < j)
    82             data.addMultiSelectedImage(new ArrayList<>(((MapillaryImage) this.closest).getSequence()
    83                 .getImages().subList(i, j + 1)));
    84           else
    85             data.addMultiSelectedImage(new ArrayList<>(((MapillaryImage) this.closest).getSequence()
    86                 .getImages().subList(j, i + 1)));
    87         }
    88         // click
    89       } else
    90         data.setSelectedImage(closest);
    91       // If you select an imported image
    92     } else if (closestTemp instanceof MapillaryImportedImage) {
    93       MapillaryImportedImage closest = (MapillaryImportedImage) closestTemp;
    94       this.start = e.getPoint();
    95       this.lastClicked = this.closest;
    96       this.closest = closest;
    97       if (data.getMultiSelectedImages().contains(closest))
    98         return;
    99       if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK) && closest != null)
    100         data.addMultiSelectedImage(closest);
    101       else
    102         data.setSelectedImage(closest);
    103     }
     54      MapillaryData.getInstance().setSelectedImage(closest);
     55      return;
     56    } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer
     57        .getInstance())
     58      return;
     59    // Double click
     60    if (e.getClickCount() == 2 && data.getSelectedImage() != null
     61        && closest != null) {
     62      for (MapillaryAbstractImage img : closest.getSequence().getImages()) {
     63        data.addMultiSelectedImage(img);
     64      }
     65    }
     66    this.start = e.getPoint();
     67    this.lastClicked = this.closest;
     68    this.closest = closest;
     69    if (data.getMultiSelectedImages().contains(closest))
     70      return;
     71    // ctrl+click
     72    if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)
     73        && closest != null)
     74      data.addMultiSelectedImage(closest);
     75    // shift + click
     76    else if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)
     77        && this.lastClicked instanceof MapillaryImage) {
     78      if (this.closest != null && this.lastClicked != null
     79          && this.closest.getSequence() == (this.lastClicked).getSequence()) {
     80        int i = this.closest.getSequence().getImages().indexOf(this.closest);
     81        int j = this.lastClicked.getSequence().getImages()
     82            .indexOf(this.lastClicked);
     83        if (i < j)
     84          data.addMultiSelectedImage(new ArrayList<>(this.closest.getSequence()
     85              .getImages().subList(i, j + 1)));
     86        else
     87          data.addMultiSelectedImage(new ArrayList<>(this.closest.getSequence()
     88              .getImages().subList(j, i + 1)));
     89      }
     90      // click
     91    } else
     92      data.setSelectedImage(closest);
    10493  }
    10594
     
    11099
    111100    if (!Main.pref.getBoolean("mapillary.developer"))
    112       for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) {
     101      for (MapillaryAbstractImage img : MapillaryData.getInstance()
     102          .getMultiSelectedImages()) {
    113103        if (img instanceof MapillaryImage)
    114104          return;
     
    118108        LatLon to = Main.map.mapView.getLatLon(e.getX(), e.getY());
    119109        LatLon from = Main.map.mapView.getLatLon(start.getX(), start.getY());
    120         for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) {
     110        for (MapillaryAbstractImage img : MapillaryData.getInstance()
     111            .getMultiSelectedImages()) {
    121112
    122113          img.move(to.getX() - from.getX(), to.getY() - from.getY());
     
    124115        Main.map.repaint();
    125116      } else if (lastButton == MouseEvent.BUTTON1 && e.isShiftDown()) {
    126         this.closest
    127             .turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa());
    128         for (MapillaryAbstractImage img : MapillaryData.getInstance().getMultiSelectedImages()) {
    129           img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))) - closest.getTempCa());
     117        this.closest.turn(Math.toDegrees(Math.atan2((e.getX() - start.x),
     118            -(e.getY() - start.y)))
     119            - closest.getTempCa());
     120        for (MapillaryAbstractImage img : MapillaryData.getInstance()
     121            .getMultiSelectedImages()) {
     122          img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x),
     123              -(e.getY() - start.y))) - closest.getTempCa());
    130124        }
    131125        Main.map.repaint();
     
    141135      double from = data.getSelectedImage().getTempCa();
    142136      double to = data.getSelectedImage().getCa();
    143       record.addCommand(new CommandTurnImage(data.getMultiSelectedImages(), to - from));
    144     } else if (data.getSelectedImage().getTempLatLon() != data.getSelectedImage().getLatLon()) {
     137      record.addCommand(new CommandTurnImage(data.getMultiSelectedImages(), to
     138          - from));
     139    } else if (data.getSelectedImage().getTempLatLon() != data
     140        .getSelectedImage().getLatLon()) {
    145141      LatLon from = data.getSelectedImage().getTempLatLon();
    146142      LatLon to = data.getSelectedImage().getLatLon();
    147       record.addCommand(new CommandMoveImage(data.getMultiSelectedImages(), to.getX() - from.getX(), to.getY()
    148           - from.getY()));
     143      record.addCommand(new CommandMoveImage(data.getMultiSelectedImages(), to
     144          .getX() - from.getX(), to.getY() - from.getY()));
    149145    }
    150146    for (MapillaryAbstractImage img : data.getMultiSelectedImages()) {
     
    160156  public void mouseMoved(MouseEvent e) {
    161157    MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
    162     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && Main.map.mapMode != Main.map.mapModeSelect)
    163       return;
    164     if (closestTemp != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && !imageHighlighted) {
     158    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     159        && Main.map.mapMode != Main.map.mapModeSelect)
     160      return;
     161    if (closestTemp != null
     162        && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     163        && !imageHighlighted) {
    165164      Main.map.mapMode.putValue("active", Boolean.FALSE);
    166165      imageHighlighted = true;
    167166
    168     } else if (closestTemp == null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && imageHighlighted
    169         && nothingHighlighted) {
     167    } else if (closestTemp == null
     168        && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     169        && imageHighlighted && nothingHighlighted) {
    170170      nothingHighlighted = false;
    171171      Main.map.mapMode.putValue("active", Boolean.TRUE);
    172172
    173     } else if (imageHighlighted && !nothingHighlighted && Main.map.mapView != null
    174         && Main.map.mapView.getEditLayer().data != null && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
    175 
    176       for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data.allPrimitives()) {
     173    } else if (imageHighlighted && !nothingHighlighted
     174        && Main.map.mapView != null
     175        && Main.map.mapView.getEditLayer().data != null
     176        && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
     177
     178      for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data
     179          .allPrimitives()) {
    177180        primivitive.setHighlighted(false);
    178181      }
     
    181184    }
    182185
    183     if (MapillaryData.getInstance().getHighlighted() != closestTemp && closestTemp != null) {
     186    if (MapillaryData.getInstance().getHighlighted() != closestTemp
     187        && closestTemp != null) {
    184188      MapillaryData.getInstance().setHighlightedImage(closestTemp);
    185189      MapillaryMainDialog.getInstance().setImage(closestTemp);
    186190      MapillaryMainDialog.getInstance().updateImage();
    187     } else if (MapillaryData.getInstance().getHighlighted() != closestTemp && closestTemp == null) {
     191    } else if (MapillaryData.getInstance().getHighlighted() != closestTemp
     192        && closestTemp == null) {
    188193      MapillaryData.getInstance().setHighlightedImage(null);
    189       MapillaryMainDialog.getInstance().setImage(MapillaryData.getInstance().getSelectedImage());
     194      MapillaryMainDialog.getInstance().setImage(
     195          MapillaryData.getInstance().getSelectedImage());
    190196      MapillaryMainDialog.getInstance().updateImage();
    191197    }
     
    196202  public void paint(Graphics2D g, MapView mv, Bounds box) {
    197203  }
    198  
     204
    199205  @Override
    200206  public String toString() {
Note: See TracChangeset for help on using the changeset viewer.