Esempio n. 1
0
        public EditGeometryMenu(MainForm mainForm, IShape container, ShpPoint vertex)
            : base()
        {
            this.mainForm = mainForm;
            this.container = container;
            this.vertex = vertex;

            moveMenuItem = new MenuItem();
            moveMenuItem.Text = "verschieben";
            moveMenuItem.Checked = false;
            moveMenuItem.Click += new System.EventHandler(menuItemClick);

            //choosePositionMenuItem = new MenuItem();
            //choosePositionMenuItem.Text = "Position eingeben";
            //choosePositionMenuItem.Checked = false;
            //choosePositionMenuItem.Click += new System.EventHandler(menuItemClick);

            removeShapeMenuItem = new MenuItem();
            removeShapeMenuItem.Text = "löschen";
            removeShapeMenuItem.Checked = false;
            removeShapeMenuItem.Click += new System.EventHandler(menuItemClick);

            // you can not delete a point if there are less then three points in the polygon
            if ((container.PointCount <= 4 &&
                (container as ShpPolygon) != null)
                ||
                (container.PointCount <= 2 &&
                (container as ShpPolyline) != null))
                removeShapeMenuItem.Enabled = false;

            this.MenuItems.Add(moveMenuItem);
            //this.MenuItems.Add(choosePositionMenuItem);
            this.MenuItems.Add(removeShapeMenuItem);
        }
Esempio n. 2
0
 public RemoveGeometryAction(ShpPoint shapeToRemove, IShape container,
     LayerManager layerManager)
 {
     this.layerManager = layerManager;
     this.d.x = this.layerManager.GetMainControler().MapPanel.DX;
     this.d.y = this.layerManager.GetMainControler().MapPanel.DY;
     this.scale = layerManager.Scale;
     this.shapeToDelete = shapeToRemove;
     this.container = container;
     this.pointSize = 2;
     deletedPoint.x = shapeToDelete.RootX;
     deletedPoint.y = shapeToDelete.RootY;
 }
Esempio n. 3
0
        /// <summary>
        /// Moves a certain Transport to a certain position
        /// </summary>
        /// <param name="selectedTransportShape"></param>
        /// <param name="unscaledDifference"></param>
        /// <param name="pointSize"></param>
        /// <param name="scale"></param>
        /// <param name="d"></param>
        /// <param name="mapPanel"></param>
        //public MoveTransportShapeAction(Point newM, Point oldM,Point dragStartPoint,int pointSize,double scale,MapPanel mapPanel)
        //{
        //    this.mapPanelDiff[0] = (newM.X - dragStartPoint.X);
        //    this.mapPanelDiff[1] = (newM.Y - dragStartPoint.Y);
        //    this.mapPanel = mapPanel;
        //    this.d.x = mapPanel.DX;
        //    this.d.y = mapPanel.DY;
        //    this.pointSize = pointSize;
        //    this.scale = scale;
        //    this.newM = newM;
        //    this.oldM = oldM;
        //    this.this.selshpInfo.iShapeInf = mapPanel.SelectedTransportShape;
        //}
        public MoveIShapeAction(IShape shapeToMove, Point m, Point dragStartPoint, int pointSize, double scale, LayerManager layerManager)
        {
            this.mapPanelDiff[0] = (m.X - dragStartPoint.X);
            this.mapPanelDiff[1] = (m.Y - dragStartPoint.Y);
            this.layerManager = layerManager;
            this.d.x = this.layerManager.GetMainControler().MapPanel.DX;
            this.d.y = this.layerManager.GetMainControler().MapPanel.DY;
            this.pointSize = pointSize;
            this.scale = scale;
            this.m = m;
            this.selShpInfo.iShapeInf = shapeToMove;
            this.selShpInfo.quadTreePosItemInf = selShpInfo.iShapeInf.Reference;

            this.dragStartPoint = dragStartPoint;
        }
Esempio n. 4
0
        private void OnSelectShape(IShape shapeToSelect)
        {
            if (selectedTransportShape != null)
                selectedTransportShape.IsHighlighted = false;

            selectedTransportShape = shapeToSelect;
            selectedTransportShape.IsHighlighted = true;
        }
Esempio n. 5
0
 void Model_ShapeRemoved()
 {
     selectedTransportShape = null;
     this.Refresh();
 }
Esempio n. 6
0
 private void ClearSelections()
 {
     bool invalidate = false;
     if (subSelection != null)
     {
         invalidate = true;
         subSelection.IsHighlighted = false;
         subSelection = null;
     }
     if (selectedTransportShape != null)
     {
         invalidate = true;
         selectedTransportShape.IsHighlighted = false;
         selectedTransportShape = null;
     }
     if (itemList.Count > 0)
     {
         invalidate = true;
         itemList.Clear();
     }
     if (invalidate) this.Invalidate();
 }
Esempio n. 7
0
 void TransportLayer_ElementAdded(IShape newElement)
 {
     if (selectedTool == Tool.DrawPoint
         || selectedTool == Tool.DrawPolygon
         || selectedTool == Tool.DrawPolyline)
     {
         OnSelectShape(newElement);
     }
 }
Esempio n. 8
0
        private void PanelMouseUp(object sender, MouseEventArgs m)
        {
            if (this.Visible)
            {
                double scale = mainControler.LayerManager.Scale;
                //unscaled x and y:
                double x = (m.X + d.x) / scale;
                double y = (m.Y - d.y) / scale;

                if (SelectedTool != Tool.Pointer)
                {
                    // right is positive
                    dragWidth = m.X - dragStartPoint.X;
                    // down is positive
                    dragHeight = m.Y - dragStartPoint.Y;
                    screenChanged = true;

                    if (selectedTool == Tool.Move)
                    {
                        if (dragWidth == 0 && dragHeight == 0)
                        {  // since we do not really drag
                            this.mDragging = false;
                            return;
                        }
                        PointD oldD = new PointD();

                        oldD = d;
                        d.x -= dragWidth;
                        d.y += dragHeight;

                        //keep actual panning values for zoom calculation
                        mainControler.PerformAction(new PanAction(oldD, d, scale,
                            this, GravurGIS.CoordinateSystems.CoordinateType.Display));

                    }
                    else if (selectedTool == Tool.ZoomIn || selectedTool == Tool.ZoomOut) //Zoom Tools:
                    {

                        double zoomFactor;
                        PointD newD = new PointD();
                        double maxAbsZoom = mainControler.LayerManager.getMaxAbsoluteZoom();

                        if (selectedTool == Tool.ZoomIn) // ZoomIn
                        {

                            // Wenn aufgezogenes Rechteck größer als 1x1 ist
                            if ( Math.Abs(dragWidth) > 1 && Math.Abs(dragHeight) > 1 )
                            {
                                zoomFactor = calculateZoomFactor(zoomRec.Width, zoomRec.Height);

                                newD.x = (d.x + zoomRec.X) * zoomFactor;
                                newD.y = (d.y - zoomRec.Y) * zoomFactor;
                            }
                            //no zoom rectangle created
                            else
                            {
                                zoomFactor = config.ZoomInFactor;
                                newD.x = (int)((d.x + m.X) * zoomFactor) - drawingArea.Width * 0.5;
                                newD.y = (int)(-1 * (m.Y - d.y) * zoomFactor) + drawingArea.Height * 0.5;
                            }
                        }
                        else // ZoomOut
                        {
                            zoomFactor = config.ZoomOutFactor;
                            newD.x = (int)((d.x + m.X) * zoomFactor) - drawingArea.Width * 0.5;
                            newD.y = (int)(-1 * (m.Y - d.y) * zoomFactor) + drawingArea.Height * 0.5;
                        }

                        double newAbsoluteZoom = absoluteZoom * zoomFactor;
                        mainControler.PerformAction(
                            new ZoomAction(absoluteZoom, d, newD, newAbsoluteZoom,
                                new PointD(x, y), maxAbsZoom, mainControler));
                    }
                    else if (selectedTool == Tool.TransportShapeMove)
                    {
                        #region Tool.TransportShapeMove

                        int pointSize;
                        if (selectedTransportShape.Type == MapTools.ShapeLib.ShapeType.MultiPoint)
                            pointSize = config.ExPntLayerPointWidth;
                        else if (selectedTransportShape.Type == MapTools.ShapeLib.ShapeType.PolyLine)
                            pointSize = config.ExPLineLayerPointWidth;
                        else
                            pointSize = config.ExPGonLayerPointWidth;

                        if (m.X - dragStartPoint.X == 0 && m.Y - dragStartPoint.Y == 0) // a click, instead of dragging
                        {
                            this.Invalidate(selectedTransportShape.getDisplayBoundingBox(d.x,
                             d.y, pointSize, scale, 1));

                            mainControler.PerformAction(
                                new MoveIShapeAction(selectedTransportShape,
                                new Point(
                                    Convert.ToInt32(m.X + d.x),
                                    Convert.ToInt32(m.Y - d.y)),
                                new Point(
                                    Convert.ToInt32(selectedTransportShape.MinX * scale),
                                    Convert.ToInt32(selectedTransportShape.MinY * scale)),
                                pointSize,
                                scale,
                                this.mainControler.LayerManager));
                        }
                        else
                        {
                            mainControler.PerformAction(
                                new MoveIShapeAction(selectedTransportShape,
                                    new Point(m.X, m.Y),
                                dragStartPoint, pointSize,
                                scale, this.mainControler.LayerManager));
                        }

                        itemList.Clear();

                        #endregion
                    }
                    else if (selectedTool == Tool.MoveGeometry && subSelection != null)
                    {
                        #region Tool.MoveGeometry

                        int pointSize = config.ExPntLayerPointWidth;

                        this.Invalidate(selectedTransportShape.getDisplayBoundingBox(d.x,
                             d.y, pointSize, scale, 2));

                            mainControler.PerformAction(
                                new MoveGeometryAction(subSelection, selectedTransportShape,
                                    new Point(m.X, m.Y),
                                dragStartPoint, pointSize,
                                scale, this.mainControler.LayerManager));

                        this.Invalidate(selectedTransportShape.getDisplayBoundingBox(d.x,
                             d.y, pointSize, scale, 2));

                        invalidateInfoPanel();

                        #endregion
                    }
                    else if (selectedTool == Tool.MoveComment)
                    {
                        #region Tool.MoveComment

                        //mainControler.PerformAction(
                        //        new MoveCommentAction(new Point(m.X, m.Y),
                        //        dragStartPoint, pointSize,
                        //        scale, this.mainControler.LayerManager));

                        #endregion
                    }
                    else if (selectedTool == Tool.DrawPolyline)
                    {
                        #region Tool.DrawPolyline

                        mainControler.PerformAction(new DrawAction(LayerType.PolylineCanvas, x, y, bEditingStarted, mainControler));
                        bEditingStarted = true;

                        #endregion
                    }
                    else if (selectedTool == Tool.DrawPolygon)
                    {
                        #region Tool.DrawPolygon

                        mainControler.PerformAction(new DrawAction(LayerType.PolygonCanvas, x, y, bEditingStarted, mainControler));
                        bEditingStarted = true;

                        #endregion
                    }
                    else if (selectedTool == Tool.DrawPoint)
                    {
                        #region Tool.DrawPoint

                        mainControler.PerformAction(new DrawAction(absoluteZoom, x, y, mainControler));

                        #endregion
                    }
                    else if (selectedTool == Tool.Identify)
                    {
                        #region Tool.Identify

                        mHighlight = mainControler.identify(x, -y);
                        this.Invalidate();

                        #endregion
                    }

                    SetPositionStatus(x, y);
                }
                else // selectedTool == Tool.Pointer
                {
                    bool invalidate = false;

                    if (itemList.Count > 0 && !contextMenuisActive)
                    {
                        toolTip.Visible = false;
                        toolTip.Invalidate();
                        mainControler.LayerManager.SelectedTransportQuadtreeItem = itemList[0];

                        // if we change the selected item, invalidate!
                        if (selectedTransportShape != itemList[0].Parent)
                        {
                            OnSelectShape(itemList[0].Parent);
                            this.Invalidate();
                        }

                        if (Environment.TickCount - mousePressedTime > 800)
                        {
                            contextMenuisActive = true;
                            if (subSelection == null)
                                shapeEditMenu.Show(this, new Point(m.X + 5, m.Y + 5));
                            else
                            {
                                ShpPoint pointToDelete = subSelection as ShpPoint;
                                if (pointToDelete != null)
                                {
                                    using (EditGeometryMenu geometryMenu = new EditGeometryMenu(mainForm, selectedTransportShape,
                                        pointToDelete))
                                    {
                                        geometryMenu.Show(this, new Point(m.X + 5, m.Y + 5));
                                    }
                                }
                            }
                        }

                        // if SelectedTool == Tool.TransportShapeMove, then itemList.Clear() is done
                        // in the appropriate MouseUp-Part as the QuadTreeItem is still needed!
                        if (selectedTool != Tool.TransportShapeMove
                            && selectedTool != Tool.Pointer) itemList.Clear();
                    }
                    else
                    {
                        if (selectedTransportShape != null)
                        {
                            selectedTransportShape.IsHighlighted = false;
                            invalidate = true;
                        }

                        selectedTransportShape = null;

                        if (invalidate) this.Invalidate();
                    }
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a new polyline object in the appr. layer, adds it to the quadtree
        /// (despite the fact that is has only one point at the moment) and set the
        /// currentlyEditedIShape to this shape.
        /// </summary>
        /// <param name="x">The x offset of the new shape</param>
        /// <param name="y">The y offset of the new shape</param>
        public ShapeInformation addTransportPolyline(double x, double y)
        {
            //int width = 2 * transportPolylineLayer.BbWidthMargin
            //    + config.ExPLineLayerPointWidth;
            //int height = 2 * transportPolylineLayer.BbHeightMargin
            //    + config.ExPLineLayerPointWidth;

            currentlyEditedIShape = transportPolylineLayer.addPolyline(x, y, scale);
            selectedTransportQuadtreeItem =
                transportLayerQuadtree.Insert(currentlyEditedIShape,
                new Vector2(x * firstScale, y * firstScale),
                new Vector2(1, 1)); //new Vector2(width, height));
            currentlyEditedIShape.Reference = selectedTransportQuadtreeItem;
            selectedTransportQuadtreeItem.reactOnZoom((4.0 * firstScale) / scale);
            ShapeInformation shpInfo;
            shpInfo.quadTreePosItemInf = selectedTransportQuadtreeItem;
            shpInfo.iShapeInf = currentlyEditedIShape;
            return shpInfo;
        }
Esempio n. 10
0
 public void removePolygon(IShape polyline)
 {
     polygons.Remove(polyline);
 }
Esempio n. 11
0
 public void removePolyline(IShape polyline)
 {
     polylines.Remove(polyline);
 }
Esempio n. 12
0
 public void removePoint(IShape point)
 {
     points.Remove(point);
 }
Esempio n. 13
0
 public void closeTransportPolyline()
 {
     currentlyEditedIShape = null;
     selectedTransportQuadtreeItem = null;
 }
Esempio n. 14
0
        private void PanelMouseDown(object sender, MouseEventArgs m)
        {
            contextMenuisActive = false;

            if (selectedTool == Tool.Move) mDragging = true;
            else if (selectedTool == Tool.ZoomIn) mZoom = true;
            else if (selectedTool == Tool.TransportShapeMove)
            {
                oldMovePoint.X = Convert.ToInt32(d.x + selectedTransportShape.CenterX * mainControler.LayerManager.Scale);
                oldMovePoint.Y = Convert.ToInt32(d.y + selectedTransportShape.CenterY * mainControler.LayerManager.Scale);
            }
            else if (selectedTool == Tool.MoveGeometry && subSelection != null)
            {
                oldMovePoint.X = Convert.ToInt32(d.x + subSelection.CenterX * mainControler.LayerManager.Scale);
                oldMovePoint.Y = Convert.ToInt32(d.y + subSelection.CenterY * mainControler.LayerManager.Scale);
            }
            else if (selectedTool == Tool.MoveComment)
            {
                oldMovePoint.X = selectedTransportShape.DrawCommentOffset.X;
                oldMovePoint.Y = selectedTransportShape.DrawCommentOffset.Y;
            }
            else if (selectedTool == Tool.Pointer)
            {
                double invScale = 1 / mainControler.LayerManager.Scale;
                PointD currentPosition = new PointD((m.X + d.x) / absoluteZoom, (m.Y - d.y) / absoluteZoom);

                if (subSelection != null && selectedTransportShape != null)
                {
                    IShape tempSelection = selectedTransportShape.NearestPointTo(
                        new PointD((m.X + d.x) * invScale, (m.Y - d.y) * invScale),
                        config.PxMaxSelectDistance * invScale);

                    itemList.Add(selectedTransportShape.Reference);

                    if (tempSelection != null && tempSelection.Equals(subSelection))
                    {
                        mousePressedTime = Environment.TickCount;
                        return;
                    }

                    subSelection.IsHighlighted = false;
                    subSelection = null;

                    // TODO: invalidate old point
                }

                bool selectNewItem = true;

                if (itemList.Count > 0 && !(itemList[0].Parent is ShpPoint) ) // e. g. we have something selected
                {
                    subSelection = itemList[0].Parent.NearestPointTo(
                        new PointD((m.X + d.x) * invScale, (m.Y - d.y) * invScale),
                        config.PxMaxSelectDistance * invScale);

                    if (subSelection != null)
                    {
                        selectNewItem = false;
                        // highlight and save the selected point
                        subSelection.IsHighlighted = true;
                        this.Invalidate();

                        //TODO: Invalidate only changing region
                        //this.Invalidate(subSelection.getDisplayBoundingBox(d.x, d.y, config.ExPntLayerPointWidth,
                        //    mainControler.LayerManager.Scale, 2));

                    }
                    else
                        selectNewItem = true;
                }

                if (selectNewItem)
                {

                    mainControler.LayerManager.getItemsAtPoint(currentPosition, ref itemList);

                    // remove invisible items
                    for (int i = 0; i < itemList.Count; i++)
                        if (!(itemList[i].Parent.Visible))
                            itemList.RemoveAt(i);
                }

                int count = itemList.Count;

                if (count > 0)
                {
                    mousePressedTime = Environment.TickCount;

                    if (count > 1) mainControler.sortItemList(ref itemList);
                    IShape shape = itemList[0].Parent;

                    // Show Tooltip with Comment
                    if (!String.IsNullOrEmpty(shape.Commment))
                    {
                        toolTip.Location = new Point(m.X, m.Y);
                        toolTip.Text = shape.Commment;
                        toolTip.Visible = true;
                    }
                }

            }
            dragStartPoint.X = m.X;
            dragStartPoint.Y = m.Y;
        }
Esempio n. 15
0
        void polygon_PositionChanged(IShape sender, bool combinedMove)
        {
            // Update the spatial index of the polygon
            GravurGIS.Topology.QuadTree.QuadTreePositionItem<IShape> qtItem = sender.Reference;

            if (qtItem != null)
            {
                double firstScale = layermanager.FirstScale;
                qtItem.changePosAndSize(
                    new GravurGIS.Topology.Vector2(sender.CenterX * firstScale, sender.CenterY * firstScale),
                    new GravurGIS.Topology.Vector2(sender.Width * firstScale, sender.Height * firstScale));
                qtItem.reactOnZoom((4.0 * firstScale) / layermanager.Scale);
            }
        }
Esempio n. 16
0
 public void removeVertex(IShape container, ShpPoint vertex)
 {
     if (container != null && vertex != null)
     {
        DialogResult result = MessageBox.Show("Möchten Sie diesen Punkt wirklich löschen?", "Punkt löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation,
             MessageBoxDefaultButton.Button2);
        if (result == DialogResult.Yes)
        {
            if (PerformAction(new RemoveGeometryAction(vertex, container, layerManager)))
            {
                mainForm.setStatus_Timed("Punkt erfolgreich gelöscht.", 1000);
                mapPanel.Invalidate();
            }
            else
                mainForm.setStatus_Timed("Punkt nicht gelöscht.", 1000);
        }
     }
 }
Esempio n. 17
0
        public void setDrawShapeInformation(DrawShapeInformation drawEnum,ShapeInformation shpInfo,LayerType lType)
        {
            this.currentlyEditedIShape = shpInfo.iShapeInf;
            this.selectedTransportQuadtreeItem = shpInfo.quadTreePosItemInf;

            this.DrawInfChanged(drawEnum,lType);
        }