/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import nl.idgis.giclient.geoma.Point; import nl.idgis.giclient.gis.Layer; import nl.idgis.giclient.gui.mapviewer.MapFeature; import nl.idgis.giclient.gui.mapviewer.MapGeometry; import nl.idgis.giclient.gui.mapviewer.MapLayer; import nl.idgis.giclient.gui.mapviewer.MapViewer; import nl.idgis.giclient.modes.MapViewerAction; import nl.idgis.giclient.util.Pixel; import nl.idgis.giclient.gis.SelectableLayer; import nl.idgis.giclient.framework.FrameWork; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.modes.MapViewerEditMove implements MapViewerAction { private var numMouseDowns:Number = 0; private var intervalID:Number = null; private var draggingPoint:Point = null; function enter(mapViewer:MapViewer):Void { } function exit(mapViewer:MapViewer):Void { } function resetNumMouseDowns():Void { if (numMouseDowns >= 1) { numMouseDowns = 0; clearInterval(intervalID); } } function performPress(mapViewer:MapViewer,pressX:Number,pressY:Number, worldPoint:Point):Void { if (numMouseDowns == 0) { intervalID = setInterval(this, "resetNumMouseDowns", 400); } numMouseDowns++; var double:Boolean = false; if (numMouseDowns == 2) { double = true; resetNumMouseDowns(); } var editLayer:Layer = mapViewer.ruler.getEditLayer(); var mapLayer:MapLayer; var allLayers:Array = mapViewer.ruler.getGIS().getEditableLayers(); for(var i:Number = 0; i < allLayers.length; i++) { if(allLayers[i] != editLayer) { mapLayer = mapViewer.getMapLayer(allLayers[i]); var features:Array = mapLayer.getMapFeatures(pressX, pressY, false, false, true, true); if(features.length != 0) { FrameWork(_root.frameWork).message( Strings.getFile("Gui").getString("FeatureNotInCurrentLayer", {feature: features[0]})); } } } mapLayer = mapViewer.getMapLayer(editLayer); //trace("mapLayer = " + mapLayer); var mapFeature:MapFeature = mapLayer.getCurrentEditingMapFeature(); if (mapFeature != null) { //if mouse point does not hit current mapFeature then try to select a different one if (!(mapFeature.getMapGeometry().hitTest(pressX, pressY, true))) { mapViewer.setSelection(MapViewer.EDIT_LAYER, SelectableLayer.SELECT_AND_CURRENT); } } else { mapViewer.setSelection(MapViewer.EDIT_LAYER, SelectableLayer.SELECT_AND_CURRENT); } mapFeature = mapLayer.getCurrentEditingMapFeature(); //trace("mapFeature = " + mapFeature); if (mapFeature != null) { //trace("mapFeature.getFeature().isEditable() = " + mapFeature.getFeature().isEditable()); if(mapFeature.getFeature().isEditable()) { var mapGeometry:MapGeometry = mapFeature.getMapGeometry(); if (mapGeometry != null) { var eventObject:Object = new Object(); eventObject["mode"] = "GeneralEdit"; eventObject["type"] = "MouseDown"; eventObject["double"] = double; eventObject["pixel"] = new Pixel(pressX, pressY); eventObject["delKey"] = Key.isDown(Key.DELETEKEY); mapViewer.getGeometryLayer().setSelectedMapGeometry(mapGeometry.performEvent(eventObject)); if (mapViewer.getGeometryLayer().getSelectedMapGeometry() != null) { draggingPoint = mapViewer.pixel2Point(pressX, pressY); } } } } } function performRelease(mapViewer:MapViewer):Void { } function performMouseUp(mapViewer:MapViewer):Void { var selectedMapGeometry:MapGeometry = mapViewer.getGeometryLayer().getSelectedMapGeometry(); if (selectedMapGeometry) { if (selectedMapGeometry != _root["boozoo"]) { // WORKAROUND BOOZOO _root["apiInterpreter"].onChangeGeometry(selectedMapGeometry.getGeometry().getMostSuperGeometry(), true); } mapViewer.getGeometryLayer().setSelectedMapGeometry(null); draggingPoint = null; } } function performMouseMove(mapViewer:MapViewer):Void { if (mapViewer.getGeometryLayer().getSelectedMapGeometry() != null) { var point:Point = mapViewer.pixel2Point(mapViewer._xmouse, mapViewer._ymouse); var dx:Number = point.getX() - draggingPoint.getX(); var dy:Number = point.getY() - draggingPoint.getY(); draggingPoint = point; var eventObject:Object = new Object(); eventObject["mode"] = "GeneralEdit"; eventObject["type"] = "MouseMove"; eventObject["dx"] = dx; eventObject["dy"] = dy; mapViewer.getGeometryLayer().getSelectedMapGeometry().performEvent(eventObject); } } function performDrag(mapViewer:MapViewer):Void { } function onKeyPress(mapViewer:MapViewer):Void { } }