Changeset 31218 in osm for applications/editors


Ignore:
Timestamp:
2015-06-04T16:39:36+02:00 (10 years ago)
Author:
nokutu
Message:

Finished pictures dragging and turning, also works if you multi select pictures

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
3 edited

Legend:

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

    r31185 r31218  
    157157                        if (image.next() != null) {
    158158                                new MapillaryCache(image.next().getKey(),
    159                                                 MapillaryCache.Type.THUMBNAIL).submit(
    160                                                 this, false);
     159                                                MapillaryCache.Type.THUMBNAIL).submit(this, false);
    161160                                if (image.next().next() != null)
    162161                                        new MapillaryCache(image.next().next().getKey(),
    163                                                         MapillaryCache.Type.THUMBNAIL)
    164                                                         .submit(this, false);
     162                                                        MapillaryCache.Type.THUMBNAIL).submit(this, false);
    165163                        }
    166164                        if (image.previous() != null) {
    167165                                new MapillaryCache(image.previous().getKey(),
    168                                                 MapillaryCache.Type.THUMBNAIL).submit(
    169                                                 this, false);
     166                                                MapillaryCache.Type.THUMBNAIL).submit(this, false);
    170167                                if (image.previous().previous() != null)
    171168                                        new MapillaryCache(image.previous().previous().getKey(),
    172                                                         MapillaryCache.Type.THUMBNAIL)
    173                                                         .submit(this, false);
     169                                                        MapillaryCache.Type.THUMBNAIL).submit(this, false);
    174170                        }
    175171                }
     
    187183         */
    188184        public void addMultiSelectedImage(MapillaryImage image) {
    189                 this.multiSelectedImages.add(image);
     185                if (this.getSelectedImage() != null)
     186                        this.multiSelectedImages.add(image);
     187                else
     188                        this.setSelectedImage(image);
    190189                Main.map.mapView.repaint();
    191190        }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java

    r31217 r31218  
    1111 */
    1212public class MapillaryImage {
     13        /** Unique identifier of the object */
    1314        private final String key;
     15        /** Postion of the picture */
    1416        private final LatLon latLon;
     17        /** Direction of the picture */
    1518        private final double ca;
     19        /** Sequence of pictures containing this */
    1620        private MapillarySequence sequence;
    17        
     21
    1822        private boolean isModified = false;
     23        /** Temporal position of the picture until it is uplaoded */
    1924        private LatLon tempLatLon;
     25        /**
     26         * When the object is being dragged in the map, the temporal position is
     27         * stored here
     28         */
     29        private LatLon movingLatLon;
     30        /** Temporal direction of the picture until it is uplaoded */
    2031        private double tempCa;
    2132
     
    3647                this.latLon = new LatLon(lat, lon);
    3748                this.tempLatLon = new LatLon(lat, lon);
     49                this.movingLatLon = new LatLon(lat, lon);
    3850                this.ca = ca;
    3951                this.tempCa = ca;
     
    5567         */
    5668        public LatLon getLatLon() {
    57                 return tempLatLon;
     69                return movingLatLon;
    5870        }
    59        
     71
    6072        /**
    6173         * Moves the image temporally to another position
     
    6375         * @param pos
    6476         */
    65         public void move(LatLon pos) {
    66                 this.tempLatLon = pos;
     77        public void move(double x, double y) {
     78                this.movingLatLon = new LatLon(this.tempLatLon.getY() + y,
     79                                this.tempLatLon.getX() + x);
    6780                this.isModified = true;
    6881        }
    69        
     82
    7083        /**
    7184         * Turns the image direction.
     85         *
    7286         * @param ca
    7387         */
     
    7589                this.tempCa = ca;
    7690                this.isModified = true;
     91        }
     92
     93        /**
     94         * Called when the mouse button is released, meaning that the picture has
     95         * stopped being dragged.
     96         */
     97        public void stopMoving() {
     98                this.tempLatLon = this.movingLatLon;
    7799        }
    78100
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31217 r31218  
    136136                                }
    137137                                start = e.getPoint();
     138                                if (mapillaryData.getMultiSelectedImages().contains(closest))
     139                                        return;
    138140                                if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK))
    139141                                        mapillaryData.addMultiSelectedImage(closest);
     
    146148                                if (MapillaryData.getInstance().getSelectedImage() != null) {
    147149                                        if (lastButton == MouseEvent.BUTTON1 && !e.isShiftDown()) {
    148                                                 MapillaryData
    149                                                                 .getInstance()
    150                                                                 .getSelectedImage()
    151                                                                 .move(Main.map.mapView.getLatLon(e.getX(),
    152                                                                                 e.getY()));
     150                                                LatLon to = Main.map.mapView.getLatLon(e.getX(),
     151                                                                e.getY());
     152                                                LatLon from = Main.map.mapView.getLatLon(start.getX(),
     153                                                                start.getY());
     154                                                for (MapillaryImage img : MapillaryData.getInstance()
     155                                                                .getMultiSelectedImages()) {
     156                                                        img.move(to.getX() - from.getX(),
     157                                                                        to.getY() - from.getY());
     158                                                }
    153159                                                Main.map.repaint();
    154                                         } else if (lastButton == MouseEvent.BUTTON1 && e.isShiftDown()) {
    155                                                 MapillaryData
    156                                                 .getInstance()
    157                                                 .getSelectedImage().turn(Math.toDegrees(Math.atan2((e.getX() - start.x), -(e.getY() - start.y))));
     160                                        } else if (lastButton == MouseEvent.BUTTON1
     161                                                        && e.isShiftDown()) {
     162                                                for (MapillaryImage img : MapillaryData.getInstance()
     163                                                                .getMultiSelectedImages()) {
     164                                                        img.turn(Math.toDegrees(Math.atan2(
     165                                                                        (e.getX() - start.x), -(e.getY() - start.y))));
     166                                                }
    158167                                                Main.map.repaint();
    159168                                        }
     169                                }
     170                        }
     171
     172                        @Override
     173                        public void mouseReleased(MouseEvent e) {
     174                                for (MapillaryImage img : MapillaryData.getInstance()
     175                                                .getMultiSelectedImages()) {
     176                                        if (img != null)
     177                                                img.stopMoving();
    160178                                }
    161179                        }
Note: See TracChangeset for help on using the changeset viewer.