Changeset 21702 in osm


Ignore:
Timestamp:
2010-06-14T16:05:12+02:00 (14 years ago)
Author:
upliner
Message:

buildings_tools: make Shift key to ignore all constraints

Location:
applications/editors/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java

    r21236 r21702  
    3535       
    3636        private double len = 0;
    37         double lwidth;
     37        private double lwidth;
     38        private double heading;
    3839        private boolean angconstrainted;
    3940        private double angconstraint = 0;
     
    7677                updMetrics();
    7778        }
    78         public void setPlace(EastNorth p2,double width,double lenstep) {
    79                 double heading = p1.heading(p2);
     79        private void updatePos() {
     80                en1 = p1;
     81                en2 = new EastNorth(p1.east()+Math.sin(heading)*len*meter,p1.north()+Math.cos(heading)*len*meter);
     82                en3 = new EastNorth(p1.east()+Math.sin(heading)*len*meter+Math.cos(heading)*lwidth*meter,p1.north()+Math.cos(heading)*len*meter-Math.sin(heading)*lwidth*meter);
     83                en4 = new EastNorth(p1.east()+Math.cos(heading)*lwidth*meter,p1.north()-Math.sin(heading)*lwidth*meter);
     84        }
     85        public void setPlace(EastNorth p2,double width,double lenstep,boolean ignoreConstraint) {
     86                heading = p1.heading(p2);
    8087                double hdang = 0;
    81                 if (angconstrainted) {
     88                if (angconstrainted && !ignoreConstraint) {
    8289                        hdang = Math.round((heading-angconstraint)/Math.PI*4);
    8390                        if (hdang>=8)hdang-=8;
     
    8895                if (lenstep <= 0) len=distance; else len = Math.round(distance/lenstep)*lenstep;
    8996                if (len == 0) return;
    90 
    91                 en1 = p1;
    92                 en2 = new EastNorth(p1.east()+Math.sin(heading)*len*meter,p1.north()+Math.cos(heading)*len*meter);
    93                 en3 = new EastNorth(p1.east()+Math.sin(heading)*len*meter+Math.cos(heading)*width*meter,p1.north()+Math.cos(heading)*len*meter-Math.sin(heading)*width*meter);
    94                 en4 = new EastNorth(p1.east()+Math.cos(heading)*width*meter,p1.north()-Math.sin(heading)*width*meter);
    95 
    9697                lwidth = width;
     98                updatePos();
    9799                Main.map.statusLine.setHeading(Math.toDegrees(heading));
    98                 if (angconstrainted) {
     100                if (angconstrainted && !ignoreConstraint) {
    99101                        Main.map.statusLine.setAngle(hdang*45);
    100102                }
     103        }
     104        public void setWidth(double width) {
     105                lwidth = width;
     106                updatePos();
    101107        }
    102108        public void paint(Graphics2D g, MapView mv) {
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/DrawBuildingAction.java

    r21236 r21702  
    184184                                p2 = latlon2eastNorth(n.getCoor());
    185185                        }
    186                         building.setPlace(p2, width, e.isControlDown()?0:lenstep);
     186                        building.setPlace(p2, width, e.isShiftDown()?0:lenstep,e.isShiftDown());
    187187                        Main.map.statusLine.setDist(building.getLength());
    188188                        return;
     
    204204                                /p1.distanceSq(p2) * building.getLength();
    205205                       
    206                         building.setPlace(p2, mwidth, lenstep);
     206                        building.setWidth(mwidth);
    207207                        Main.map.statusLine.setDist(Math.abs(mwidth));                 
    208208                        return;
Note: See TracChangeset for help on using the changeset viewer.