drag, rotate, resize, and reshape with the ModifyFeature control - thanks pvalsecc and elemoine for the inspiration, tests, and code - good partenering with you guys (closes #1150).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5301 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -190,7 +190,10 @@
|
||||
control.dragControl.deactivate = function() { t.ok(true, "Deactivate called on drag control"); }
|
||||
control.onModificationEnd = function (feature) { t.eq(feature.id, fakeFeature.id, "onModificationEnd got feature.") }
|
||||
layer.removeFeatures = function(verts) {
|
||||
t.ok(verts == 'a' || verts == 'b', "Verts removed correctly")
|
||||
t.ok(verts == 'a', "Normal verts removed correctly");
|
||||
}
|
||||
layer.destroyFeatures = function(verts) {
|
||||
t.ok(verts == 'b', "Virtual verts destroyed correctly");
|
||||
}
|
||||
control.unselectFeature(fakeFeature);
|
||||
t.eq(control.feature, null, "feature is set to null");
|
||||
@@ -214,9 +217,11 @@
|
||||
control.selectFeature(fakeFeature);
|
||||
|
||||
control.collectVertices = function() {
|
||||
t.ok(true, "collectVertices called");
|
||||
this.vertices = 'a';
|
||||
this.virtualVertices = 'd';
|
||||
t.ok(true, "collectVertices called");
|
||||
layer.addFeatures(this.vertices);
|
||||
layer.addFeatures(this.virtualVertices);
|
||||
}
|
||||
|
||||
layer.addFeatures = function(features) {
|
||||
@@ -242,7 +247,7 @@
|
||||
}
|
||||
|
||||
function test_ModifyFeature_resetVertices(t) {
|
||||
t.plan(9);
|
||||
t.plan(15);
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
var control = new OpenLayers.Control.ModifyFeature(layer);
|
||||
var point = new OpenLayers.Geometry.Point(5,6);
|
||||
@@ -253,7 +258,7 @@
|
||||
control.resetVertices();
|
||||
t.eq(control.vertices.length, 0, "Correct vertices length");
|
||||
t.eq(control.virtualVertices.length, 0, "Correct virtual vertices length.");
|
||||
|
||||
|
||||
var multiPoint = new OpenLayers.Geometry.MultiPoint([point, point2]);
|
||||
control.feature = new OpenLayers.Feature.Vector(multiPoint);
|
||||
control.resetVertices();
|
||||
@@ -273,6 +278,20 @@
|
||||
t.eq(control.vertices[0].geometry.id, control.vertices[3].geometry.id, "First and last vertices are the same");
|
||||
t.eq(control.virtualVertices.length, 3, "Correct virtual vertices length (polygon).");
|
||||
|
||||
control.drag = true;
|
||||
control.resetVertices();
|
||||
t.ok(control.dragHandle != null, "Drag handle is set");
|
||||
t.eq(control.vertices.length, 4, "Correct vertices length with polygon (drag)");
|
||||
|
||||
control.rotate = true;
|
||||
control.resetVertices();
|
||||
t.ok(control.radiusHandle != null, "Radius handle is set");
|
||||
t.eq(control.vertices.length, 0, "Correct vertices length with polygon (rotate)");
|
||||
|
||||
control.rotate = false;
|
||||
control.resize = true;
|
||||
t.ok(control.radiusHandle != null, "Radius handle is set");
|
||||
t.eq(control.vertices.length, 0, "Correct vertices length with polygon (resize)");
|
||||
}
|
||||
|
||||
function test_ModifyFeature_onDrag(t) {
|
||||
@@ -289,11 +308,6 @@
|
||||
'geometry': { 'id':'myGeom'},
|
||||
'id': 'fakeFeature'
|
||||
};
|
||||
control.collectVertices = function(geom) {
|
||||
t.eq(geom.id, 'myGeom', "collect geom called");
|
||||
this.vertices = 'normal';
|
||||
this.virtualVertices = 'virtual';
|
||||
}
|
||||
layer.addFeatures = function (verts) {
|
||||
t.ok(verts == 'virtual' || verts == 'normal', verts + " verts correct");
|
||||
}
|
||||
@@ -303,6 +317,13 @@
|
||||
control.onModification = function(feat) {
|
||||
t.eq(feat.id, fakeFeature.id, "onModification gets correct feat");
|
||||
}
|
||||
control.collectVertices = function() {
|
||||
t.ok(true, "collectVertices called");
|
||||
this.vertices = 'normal';
|
||||
this.virtualVertices = 'virtual';
|
||||
layer.addFeatures(this.vertices);
|
||||
layer.addFeatures(this.virtualVertices);
|
||||
}
|
||||
control.feature = fakeFeature;
|
||||
control.vertices = 'previous normal';
|
||||
control.virtualVertices = 'previous virtual';
|
||||
|
||||
Reference in New Issue
Block a user