- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 undomanager 撤消/重做编辑顶点。
图形对象经过测试。但我不知道该怎么做编辑顶点撤消/重做。
顶点是否可以撤消/重做?
我找了很多例子都没有找到答案。
我是韩国初学者程序员。帮帮我吧~ T.T
function initEditing(evt) {
console.log("initEditing", evt);
var currentLayer = null;
var layers = arrayUtils.map(evt.layers, function(result) {
return result.layer;
console.log("result ==== "+result);
});
console.log("layers", layers);
editToolbar = new Edit(map);
editToolbar.on("deactivate", function(evt) {
console.log("deactivate !!!! ");
currentLayer.applyEdits(null, [evt.graphic], null);
});
arrayUtils.forEach(layers, function(layer) {
var editingEnabled = false;
layer.on("dbl-click", function(evt) {
event.stop(evt);
if (editingEnabled === false) {
editingEnabled = true;
editToolbar.activate(Edit.EDIT_VERTICES , evt.graphic);
pre_evt = evt.graphic;
editToolbar.on("vertex-move-stop", function(evt){
console.log("vertex-move-stop~");
g_evt = evt;
console.log("evt.transform ===== " +evt.transform);
var operation = new esri.dijit.editing.Update({
featureLayer : landusePointLayer,
preUpdatedGraphics:pre_evt,
postUpdatedGraphics: evt.graphic
})
var operation = new CustomOperation.Add({
graphicsLayer: pre_evt._graphicsLayer,
addedGraphic: evt.graphic
});
undoManager.add(operation);
console.log("operation ======== ",operation);
});
console.log("dbl-click & eidt true");
} else {
currentLayer = this;
editToolbar.deactivate();
editingEnabled = false;
console.log("dbl-click & eidt false ");
}
});
最佳答案
您所引用的示例只是让您了解如何使用 UndoManager。如果需要对顶点进行撤消/重做,则需要创建自己的操作。下面我为 AddVertex 提供了一个。您需要为其他操作创建自己的。
define(["dojo/_base/declare",
"esri/OperationBase"],
function(declare,
OperationBase) {
var customOp = {};
customOp.AddVertex = declare(OperationBase, {
label: "Add Vertex",
_editedGraphic: null,
_vertexInfo: null,
_vertex: null,
_editTool: null,
constructor: function (params) {
params = params || {};
if (!params.editTool) {
console.error("no edit toolbar provided");
return;
}
this._editTool = params.editTool;
if (!params.editedGraphic) {
console.error("no graphics provided");
return;
}
this._editedGraphic = params.editedGraphic;
if (!params.vertexinfo) {
console.error("no vertexinfo provided");
return;
}
this._vertexInfo = params.vertexinfo;
var geometry = this._editedGraphic.geometry;
if(geometry.type === "multipoint") {
this._vertex = geometry.getPoint(this._vertexInfo.pointIndex);
} else if(geometry.type === "polyline" || geometry.type === "polygon") {
this._vertex = geometry.getPoint(this._vertexInfo.segmentIndex, this._vertexInfo.pointIndex);
} else {
console.error("Not valid geometry type.");
}
},
performUndo: function () {
var geometry = this._editedGraphic.geometry;
if(geometry.type === "multipoint"){
geometry.removePoint(this._vertexInfo.pointIndex);
} else if(geometry.type === "polyline" || geometry.type === "polygon") {
geometry.removePoint(this._vertexInfo.segmentIndex, this._vertexInfo.pointIndex);
}
this._editedGraphic.draw();
this._editTool.refresh();
},
performRedo: function () {
var geometry = this._editedGraphic.geometry;
if(geometry.type === "multipoint"){
geometry.removePoint(this._vertexInfo.pointIndex, this._vertex);
} else if(geometry.type === "polyline" || geometry.type === "polygon") {
geometry.insertPoint(this._vertexInfo.segmentIndex, this._vertexInfo.pointIndex, this._vertex);
}
this._editedGraphic.draw();
this._editTool.refresh();
}
});
return customOp;
});
确保在停用编辑工具栏时清除 UndoManager。否则,操作将保留。不要将添加图形操作与顶点操作结合起来。它不会工作,因为他们使用不同的工具栏,并且一旦您停用它,编辑工具栏状态就会丢失。
还要注意的一点是,当您使用 UndoManager 时,图形 isModified 状态将始终为 true,因为我们在撤消/重做期间添加和删除顶点,即使撤消所有更改也是如此。因此,请确保您需要通过检查是否有任何待处理的撤消(几何图形确实已修改)来应用编辑。
希望这对您有所帮助。
关于javascript - 如何使用 arcgis javascript 顶点 undoManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37559439/
HTML5 规范提到了一个 UndoManager,它可用于查询用户编辑过的文档的先前状态 (http://www.whatwg.org/specs/web-apps/current-work/#un
我使用 UndoManager在我的 Swing 应用程序中。如果在 UndoManager 上调用了 undo()、redo()、addEdit() 或其他方法,Undo 和 Redo 按钮最终必须
我有 3 个 MOC。 MainThread MOC 显示内容(使用 undomanager) 后台保存 MOC 以将数据保存到光盘(连接到存储) Backgorund-update MOC 从服务器
我正在使用 UndoManager 来捕获我的 JTextArea 中的更改。 setText() 方法会删除所有内容,然后粘贴文本。当我撤消时,我首先看到一个空白区域,然后它会显示它之前的文本。 如
我对 ACE 很陌生编辑器和 javascript 一般情况下,除了以下内容之外,我已经设法实现了大部分我想要的: 我想启用或禁用“保存”按钮,具体取决于是否对文档进行了未完成的修改,并且我已尝试通过
我希望能够从我的文档模型中访问 UndoManager,这样我就可以在模型中注册撤消操作: // Assume I've extended MyDocument to conform to Refer
我有一个名为 appointment 的 NSManagedObject,我编辑了它的属性。如果我的用户按下取消,我想撤消所有这些编辑。 如果我这样做(示例代码) [[appointment mana
使用 ACE Editor , 它看起来好像使用 editor.getSession().getUndoManager() 和一个已经用 editor.setSession() 设置的 session
我有一个 JTextArea 和一个 JComboBox 允许我循环浏览各种打开的文件 - JTextArea 的内容随着我的选择而改变一个不同的文件。我试图为每个文件维护一个不同的撤消缓冲区,并为每
我正在尝试在我的模型中实现撤消/重做。所以我让我的模型类成为 NSResponder 的子类,然后实现了以下内容: 注意:此代码是根据评论后的更多研究编辑的 func setAnnotations(_
我正在努力向使用 undoManager 的 Swift 库添加一些测试。在库的演示中,将以下打印添加到 viewDidAppear: 会导致打印 NSUndoManagerObject。 overr
我对如何在 Firefox 中使用 undoManager 有点困惑。根据Mozilla , Firefox 20 现在支持它,但我不知道在哪里。我已经在 document、Objects 等下进行了
我想在我的应用程序中应用撤消和重做操作。我阅读了苹果文档并用谷歌搜索了它,但没有得到正确的解决方案。在我的应用程序中,我在 UIImage 上应用了很多图像操作,我想存储每个状态并相应地应用 Undo
我将以下代码用于核心数据单例。下面是我的代码。 (基于 NachoMan 的 blog 。但是代码来自他的要点。 // DataManager.h #import #import extern N
如何在 Swift 中使用 UndoManager(以前的 NSUndoManager)? 这是我尝试复制的 Objective-C 示例: [[undoManager prepareWithInvo
我正在尝试在类似绘画的程序中设置UndoManager,但不幸失败了。我一直在查看的示例程序是文本编辑器 ( Example ),它们调用 JTextComponent 类的 addUndoableE
我尝试使用 undomanager 撤消/重做编辑顶点。 图形对象经过测试。但我不知道该怎么做编辑顶点撤消/重做。 顶点是否可以撤消/重做? 我找了很多例子都没有找到答案。 我是韩国初学者程序员。帮帮
使用 Swift 3.02 (Xcode 8.2) 我引用了答案中描述的撤消解决方案:https://stackoverflow.com/a/31450475/7448394 . 在下面的代码中,我使
我只是试图让用户在我的应用程序中执行的操作撤消。默认情况下,用户所做的任何文本编辑都具有撤消的好处,但以其他方式(通过我的代码)完成的任何操作都没有。 我可以看到文档解释说我需要获取 NSUndoMa
为什么@Environment UndoManager不更新其 canUndo当它的堆栈中有 Action 时的属性?我有一个 View ,它有一个可以使用取消/重做功能的 child ,但由于某种原
我是一名优秀的程序员,十分优秀!