mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
Relax the availability rules for rotation and reflection operations
(closes #4237) New rules: - Rotation available if at least 2 unique nodes in selectedIDs - Reflection available if at least 3 unique nodes in selectedIDs
This commit is contained in:
+11
-6
@@ -1,10 +1,9 @@
|
||||
import * as d3 from 'd3';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { t } from '../util/locale';
|
||||
|
||||
import { actionRotate } from '../actions/index';
|
||||
import { behaviorEdit } from '../behavior/index';
|
||||
|
||||
import { actionRotate } from '../actions';
|
||||
import { behaviorEdit } from '../behavior';
|
||||
import { geoInterp } from '../geo';
|
||||
import {
|
||||
modeBrowse,
|
||||
modeSelect
|
||||
@@ -17,7 +16,7 @@ import {
|
||||
operationOrthogonalize,
|
||||
operationReflectLong,
|
||||
operationReflectShort
|
||||
} from '../operations/index';
|
||||
} from '../operations';
|
||||
|
||||
import {
|
||||
polygonHull as d3polygonHull,
|
||||
@@ -71,7 +70,13 @@ export function modeRotate(context, entityIDs) {
|
||||
var nodes = utilGetAllNodes(entityIDs, context.graph()),
|
||||
points = nodes.map(function(n) { return projection(n.loc); });
|
||||
|
||||
pivot = d3polygonCentroid(d3polygonHull(points));
|
||||
if (points.length === 1) { // degenerate case
|
||||
pivot = points[0];
|
||||
} else if (points.length === 2) {
|
||||
pivot = geoInterp(points[0], points[1], 0.5);
|
||||
} else {
|
||||
pivot = d3polygonCentroid(d3polygonHull(points));
|
||||
}
|
||||
prevAngle = undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import { t } from '../util/locale';
|
||||
import { actionReflect } from '../actions/index';
|
||||
import { behaviorOperation } from '../behavior/index';
|
||||
import { geoExtent } from '../geo/index';
|
||||
import { actionReflect } from '../actions';
|
||||
import { behaviorOperation } from '../behavior';
|
||||
import { geoExtent } from '../geo';
|
||||
import { utilGetAllNodes } from '../util';
|
||||
|
||||
|
||||
export function operationReflectShort(selectedIDs, context) {
|
||||
@@ -31,13 +32,8 @@ export function operationReflect(selectedIDs, context, axis) {
|
||||
|
||||
|
||||
operation.available = function() {
|
||||
return _.some(selectedIDs, hasArea);
|
||||
|
||||
function hasArea(id) {
|
||||
var entity = context.entity(id);
|
||||
return (entity.type === 'way' && entity.isClosed()) ||
|
||||
(entity.type ==='relation' && entity.isMultipolygon());
|
||||
}
|
||||
var nodes = utilGetAllNodes(selectedIDs, context.graph());
|
||||
return _.uniqBy(nodes, function(n) { return n.loc; }).length >= 3;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
import { t } from '../util/locale';
|
||||
import { behaviorOperation } from '../behavior/index';
|
||||
import { geoExtent } from '../geo/index';
|
||||
import { modeRotate } from '../modes/index';
|
||||
import { behaviorOperation } from '../behavior';
|
||||
import { geoExtent } from '../geo';
|
||||
import { modeRotate } from '../modes';
|
||||
import { utilGetAllNodes } from '../util';
|
||||
|
||||
|
||||
export function operationRotate(selectedIDs, context) {
|
||||
@@ -18,13 +19,8 @@ export function operationRotate(selectedIDs, context) {
|
||||
|
||||
|
||||
operation.available = function() {
|
||||
return _.some(selectedIDs, hasArea);
|
||||
|
||||
function hasArea(id) {
|
||||
var entity = context.entity(id);
|
||||
return (entity.type === 'way' && entity.isClosed()) ||
|
||||
(entity.type ==='relation' && entity.isMultipolygon());
|
||||
}
|
||||
var nodes = utilGetAllNodes(selectedIDs, context.graph());
|
||||
return _.uniqBy(nodes, function(n) { return n.loc; }).length >= 2;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user