Adding the ability to change the aspect ratio of features while resizing with the modify feature control. Thanks for the patch rdewit! r=me (closes #1975)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9150 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -526,8 +526,11 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.ModifyFeature.RESIZE))) {
|
||||
this.collectRadiusHandle();
|
||||
}
|
||||
if((this.mode & OpenLayers.Control.ModifyFeature.RESHAPE)) {
|
||||
this.collectVertices();
|
||||
if(this.mode & OpenLayers.Control.ModifyFeature.RESHAPE){
|
||||
// Don't collect vertices when we're resizing
|
||||
if (!(this.mode & OpenLayers.Control.ModifyFeature.RESIZE)){
|
||||
this.collectVertices();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -661,7 +664,9 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
);
|
||||
var radius = new OpenLayers.Feature.Vector(radiusGeometry);
|
||||
var resize = (this.mode & OpenLayers.Control.ModifyFeature.RESIZE);
|
||||
var reshape = (this.mode & OpenLayers.Control.ModifyFeature.RESHAPE);
|
||||
var rotate = (this.mode & OpenLayers.Control.ModifyFeature.ROTATE);
|
||||
|
||||
radiusGeometry.move = function(x, y) {
|
||||
OpenLayers.Geometry.Point.prototype.move.call(this, x, y);
|
||||
var dx1 = this.x - originGeometry.x;
|
||||
@@ -676,9 +681,18 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
geometry.rotate(angle, originGeometry);
|
||||
}
|
||||
if(resize) {
|
||||
var l0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));
|
||||
var l1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));
|
||||
geometry.resize(l1 / l0, originGeometry);
|
||||
var scale, ratio;
|
||||
// 'resize' together with 'reshape' implies that the aspect
|
||||
// ratio of the geometry will not be preserved whilst resizing
|
||||
if (reshape) {
|
||||
scale = dy1 / dy0;
|
||||
ratio = (dx1 / dx0) / scale;
|
||||
} else {
|
||||
var l0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));
|
||||
var l1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));
|
||||
scale = l1 / l0;
|
||||
}
|
||||
geometry.resize(scale, originGeometry, ratio);
|
||||
}
|
||||
};
|
||||
radius._sketch = true;
|
||||
|
||||
Reference in New Issue
Block a user