Exemplo n.º 1
0
        private void QueryBoundsFromGeom(int hDC, ref IDisplayTransformation transform, ref IPolygon boundary,
                                         ref IGeometry point)
        {
            IPointCollection pointCollection = null;

            pointCollection = (IPointCollection)boundary;
            try
            {
                IPolygon    polygonClass    = new Polygon() as IPolygon;
                ITextSymbol textSymbolClass = new TextSymbol()
                {
                    Text = this.m_NumeratorText
                };
                (textSymbolClass as ISymbol).QueryBoundary(hDC, transform, point, polygonClass);
                IEnvelope envelope = polygonClass.Envelope;
                IPolygon  polygon  = new Polygon() as IPolygon;
                textSymbolClass = new TextSymbol()
                {
                    Text = this.m_DenominatorText
                };
                (textSymbolClass as ISymbol).QueryBoundary(hDC, transform, point, polygon);
                envelope.Union(polygon.Envelope);
                envelope.Expand(4, 0, false);
                object value = Missing.Value;
                object obj   = Missing.Value;
                pointCollection.AddPoint(envelope.LowerLeft, ref value, ref value);
                pointCollection.AddPoint(envelope.LowerRight, ref value, ref value);
                pointCollection.AddPoint(envelope.UpperRight, ref value, ref value);
                pointCollection.AddPoint(envelope.UpperLeft, ref value, ref value);
                pointCollection.AddPoint(envelope.LowerLeft, ref value, ref value);
                ITransform2D transform2D = null;
                if (this.m_Angle + this.m_dMapRotation != 0)
                {
                    transform2D = boundary as ITransform2D;
                    if (point is IPoint)
                    {
                        transform2D.Rotate(point as IPoint, Utility.Radians(this.m_Angle + this.m_dMapRotation));
                    }
                    else if (point is IEnvelope)
                    {
                        transform2D.Rotate((point as IEnvelope).LowerLeft,
                                           Utility.Radians(this.m_Angle + this.m_dMapRotation));
                    }
                }
            }
            catch (Exception exception)
            {
                exception.ToString();
            }
        }
Exemplo n.º 2
0
        private IPolygon CreatePolygon(IPoint pt1, IPoint pt2)
        {
            try
            {
                //Dim rotation As Double = CountRotationAsRatians(pt1, pt2)

                ILine line = new Line();
                line.FromPoint = pt1;
                line.ToPoint   = pt2;

                IPoint centerPt = new ESRI.ArcGIS.Geometry.Point();
                centerPt.PutCoords((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2);


                ITransform2D trans = line as ITransform2D;
                trans.Rotate(centerPt, -Rotation);


                IPolygon     poly         = BuildRectange(centerPt);
                ITransform2D transForPoly = poly as ITransform2D;
                transForPoly.Rotate(centerPt, Rotation * (Math.PI / 180));

                poly.SpatialReference = pt1.SpatialReference;

                return(poly);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        private void RotateElement(IElement elem, double new_angle, IAGAnimationContainer pContainer)
        {
            ITransform2D transform2D = elem as ITransform2D;
            IPoint       rotateOrigin;

            if (elem.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                rotateOrigin = elem.Geometry as IPoint;
            }
            else
            {
                IEnvelope elementEnvelope = elem.Geometry.Envelope;
                IArea     elementArea     = elementEnvelope as IArea;
                rotateOrigin = elementArea.Centroid;
            }

            AddPropertySet(elem);

            IElementProperties prop = (IElementProperties)elem; //record the old properties
            IPropertySet       propSet;

            propSet = (IPropertySet)prop.CustomProperty;
            double old_angle;

            old_angle = (double)propSet.GetProperty("Angle");

            propSet.SetProperty("Angle", new_angle); //update old angle

            transform2D.Rotate(rotateOrigin, new_angle - old_angle);
        }
Exemplo n.º 4
0
        private void method_0(double double_1)
        {
            int num;
            int num1;
            int num2;
            int num3;

            if (double_1 != 0)
            {
                for (int i = 0; i < this.igeometryCollection_0.GeometryCount; i++)
                {
                    IGeometry    geometry    = this.igeometryCollection_0.Geometry[i];
                    ITransform2D transform2D = (geometry as IClone).Clone() as ITransform2D;
                    transform2D.Rotate(this.ipoint_1, double_1);
                    if (
                        !(geometry.GeometryType == esriGeometryType.esriGeometryMultipoint
                            ? false
                            : geometry.GeometryType != esriGeometryType.esriGeometryPoint))
                    {
                        if (this.isymbol_0 != null)
                        {
                            if (this.ipoint_3 == null)
                            {
                                this.isymbol_0.Draw(transform2D as IGeometry);
                                this.ipoint_3 = transform2D as IPoint;
                            }
                            else
                            {
                                this.iscreenDisplay_0.DisplayTransformation.FromMapPoint(this.ipoint_3, out num,
                                                                                         out num1);
                                this.iscreenDisplay_0.DisplayTransformation.FromMapPoint(transform2D as IPoint, out num2,
                                                                                         out num3);
                                if ((num - num2) * (num - num2) + (num1 - num3) * (num1 - num3) > 4)
                                {
                                    this.isymbol_0.Draw(transform2D as IGeometry);
                                    this.ipoint_3 = transform2D as IPoint;
                                }
                            }
                        }
                    }
                    else if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        if (this.isymbol_1 != null)
                        {
                            this.isymbol_1.Draw(transform2D as IGeometry);
                        }
                    }
                    else if (geometry.GeometryType == esriGeometryType.esriGeometryPolygon && this.isymbol_2 != null)
                    {
                        this.isymbol_2.Draw(transform2D as IGeometry);
                    }
                }
            }
        }
Exemplo n.º 5
0
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return(null);
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy  = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Rotate(m_pCenterPoint, m_dAngle);
         m_bDone = true;
         return(m_pGeomCopy);
     }
 }
Exemplo n.º 6
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                if (m_element is AnnotationElement)
                {
                    IPoint centerPoint = new PointClass
                    {
                        X = (m_element.Geometry.Envelope.LowerLeft.X + m_element.Geometry.Envelope.LowerRight.X) / 2,
                        Y = (m_element.Geometry.Envelope.LowerLeft.Y + m_element.Geometry.Envelope.UpperRight.Y) / 2
                    };
                    if (AnnotationLayer == null)
                    {
                        //ILayer pLayer = CommonFunctions.GetFeatureLayer("注记", m_hookHelper);
                        //AnnotationLayer = pLayer as IFeatureLayer;
                    }
                    //IFeatureClass pFeatureClass = AnnotationLayer.FeatureClass;
                    //IDataset pDataset = (IDataset)pFeatureClass;
                    //IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace;
                    //pWorkspaceEdit.StartEditing(true);
                    //pWorkspaceEdit.StartEditOperation();
                    //pWorkspaceEdit.EnableUndoRedo();

                    double       angle        = ((ITextElement)m_viewElement).Symbol.Angle;
                    double       oldAngle     = ((ITextElement)m_element).Symbol.Angle;
                    ITransform2D pTransform2D = m_element as ITransform2D;
                    pTransform2D.Rotate(centerPoint, (angle - oldAngle) * Math.PI / 180);

                    IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView as IGraphicsContainer;
                    pGraphicsContainer.UpdateElement(m_element);
                    //pWorkspaceEdit.DisableUndoRedo();
                    //pWorkspaceEdit.StopEditOperation();
                    //pWorkspaceEdit.StopEditing(true);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_hookHelper.ActiveView.Extent);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_element, m_hookHelper.ActiveView.Extent);

                    pGraphicsContainer.DeleteElement(m_viewElement);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_viewElement, m_hookHelper.ActiveView.Extent);
                }
                m_moving      = false;
                m_element     = null;
                m_point       = null;
                m_viewElement = null;
                m_oldPoint    = null;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 按指定的角度旋转
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="originPt"></param>
 /// <param name="rotate"></param>
 void TransformByRotate(ref object obj, IPoint originPt, double rotate)
 {
     if (obj == null && originPt == null)
     {
         return;
     }
     try
     {
         ITransform2D transform2D = obj as ITransform2D;
         if (transform2D == null)
         {
             return;
         }
         transform2D.Rotate(originPt, rotate);
     }
     catch
     { }
 }
Exemplo n.º 8
0
        private void QueryBoundsFromGeom(int hDC, ref IDisplayTransformation transform, ref IPolygon boundary,
                                         ref IPoint point)
        {
            double map  = 0;
            double num  = 0;
            double map1 = 0;

            num = this.PointsToMap(transform, this.m_dSize);
            if (this.m_dXOffset != 0)
            {
                map = this.PointsToMap(transform, this.m_dXOffset);
            }
            if (this.m_dYOffset != 0)
            {
                map1 = this.PointsToMap(transform, this.m_dYOffset);
            }
            point.PutCoords(point.X + map, point.Y + map1);
            this.SetupDeviceRatio(hDC, transform);
            IPointCollection   pointCollection   = null;
            ISegmentCollection segmentCollection = null;
            double             num1 = 0;
            double             num2 = 0;

            pointCollection   = (IPointCollection)boundary;
            segmentCollection = (ISegmentCollection)boundary;
            num2 = num / 2;
            num1 = Math.Sqrt(num2 * num2 / 2);
            object value = Missing.Value;

            pointCollection.AddPoint(Utility.CreatePoint(point.X + num1, point.Y - num1), ref value, ref value);
            pointCollection.AddPoint(Utility.CreatePoint(point.X - num1, point.Y - num1), ref value, ref value);
            pointCollection.AddPoint(Utility.CreatePoint(point.X - num1, point.Y + num1), ref value, ref value);
            IPoint point1 = pointCollection.Point[0];

            segmentCollection.AddSegment((ISegment)Utility.CreateCircArc(point, pointCollection.Point[2], ref point1),
                                         ref value, ref value);
            ITransform2D transform2D = null;

            if (this.m_dAngle + this.m_dMapRotation != 0)
            {
                transform2D = boundary as ITransform2D;
                transform2D.Rotate(point, Utility.Radians(this.m_dAngle + this.m_dMapRotation));
            }
        }
Exemplo n.º 9
0
 private void method_1(double double_1, int int_0)
 {
     for (int i = 0; i < this.igeometryCollection_0.GeometryCount; i++)
     {
         IGeometry    geometry    = this.igeometryCollection_0.Geometry[i];
         ITransform2D transform2D = (geometry as IClone).Clone() as ITransform2D;
         transform2D.Rotate(this.ipoint_1, double_1);
         if (
             !(geometry.GeometryType == esriGeometryType.esriGeometryMultipoint
                 ? false
                 : geometry.GeometryType != esriGeometryType.esriGeometryPoint))
         {
             if (this.isymbol_0 != null)
             {
                 this.isymbol_0.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
                 this.isymbol_0.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
                 this.isymbol_0.Draw(transform2D as IGeometry);
                 this.isymbol_0.ResetDC();
             }
         }
         else if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
         {
             if (this.isymbol_1 != null)
             {
                 this.isymbol_1.ROP2 = esriRasterOpCode.esriROPXOrPen;
                 this.isymbol_1.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
                 this.isymbol_1.Draw(transform2D as IGeometry);
                 this.isymbol_1.ResetDC();
             }
         }
         else if (geometry.GeometryType == esriGeometryType.esriGeometryPolygon && this.isymbol_1 != null)
         {
             this.isymbol_1.ROP2 = esriRasterOpCode.esriROPXOrPen;
             this.isymbol_1.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
             this.isymbol_1.Draw(transform2D as IGeometry);
             this.isymbol_1.ResetDC();
         }
     }
 }
Exemplo n.º 10
0
        private SortedList <double, int> Rotate(CPolyline frcpl, CPolyline tocpl, IPoint icentralpt)
        {
            IPointCollection4 pCol = new PolylineClass();

            pCol.AddPointCollection(tocpl as IPointCollection4);
            IPolyline5   newpolyline  = pCol as IPolyline5;
            ITransform2D pTransform2D = newpolyline as ITransform2D;

            SortedList <double, int> dblSimilaritySLt = new SortedList <double, int>(new CCmpDbl());
            double dblRotateAngle = 2 * Math.PI / 360;

            for (int i = 0; i < 360; i++)
            {
                pTransform2D.Rotate(icentralpt, dblRotateAngle);
                CPolyline        tocpl2        = new CPolyline(i, newpolyline);
                List <CCorrCpts> pCorrCptsLt   = BuildCorrespondences(frcpl, tocpl2);
                double           dblSimilarity = CalSimilarity(pCorrCptsLt);
                dblSimilaritySLt.Add(dblSimilarity, i);
            }

            return(dblSimilaritySLt);
        }
Exemplo n.º 11
0
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (this.irotateTrackerFeedback_0 != null)
     {
         if (int_0 == 1 && this.bool_2)
         {
             _context.ActiveView.Refresh();
         }
         else if (this.bool_1)
         {
             this.bool_1 = false;
             if (this.irotateTrackerFeedback_0 != null)
             {
                 this.irotateTrackerFeedback_0.ClearGeometry();
                 if (this.irotateTrackerFeedback_0.Angle != 0)
                 {
                     IEnvelope    envelope         = null;
                     IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;
                     featureSelection.Reset();
                     for (IFeature i = featureSelection.Next(); i != null; i = featureSelection.Next())
                     {
                         ITransform2D shapeCopy = i.ShapeCopy as ITransform2D;
                         if (envelope != null)
                         {
                             envelope.Union((shapeCopy as IGeometry).Envelope);
                         }
                         else
                         {
                             envelope = (shapeCopy as IGeometry).Envelope;
                         }
                         if (shapeCopy != null)
                         {
                             shapeCopy.Rotate(this.irotateTrackerFeedback_0.Origin,
                                              this.irotateTrackerFeedback_0.Angle);
                             Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(i.Class as IDataset);
                             try
                             {
                                 i.Shape = shapeCopy as IGeometry;
                                 i.Store();
                                 envelope.Union((shapeCopy as IGeometry).Envelope);
                             }
                             catch (Exception exception)
                             {
                                 CErrorLog.writeErrorLog(this, exception, "");
                             }
                             Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(i.Class as IDataset);
                         }
                     }
                     if (envelope != null)
                     {
                         double mapUnits = Common.ConvertPixelsToMapUnits(_context.ActiveView, 10);
                         envelope.Expand(mapUnits, mapUnits, false);
                         _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                            envelope);
                     }
                     _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                        null);
                     this.irotateTrackerFeedback_0.Origin = null;
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                if (!m_moving)
                {
                    return;
                }

                IPoint centerPoint = new PointClass
                {
                    X = (m_element.Geometry.Envelope.LowerLeft.X + m_element.Geometry.Envelope.LowerRight.X) / 2,
                    Y = (m_element.Geometry.Envelope.LowerLeft.Y + m_element.Geometry.Envelope.UpperRight.Y) / 2
                };
                if (m_element is AnnotationElement)
                {
                    // 如果旧点为空,则赋OnMouseDown事件所获取的点值
                    if (m_oldPoint == null)
                    {
                        m_oldPoint = m_point;
                    }
                    // 新点为当前的鼠标点坐标
                    IPoint newPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    // 获取旧点角度
                    IPointCollection pPointCollection = new PolylineClass();
                    object           missing          = Type.Missing;
                    pPointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pPointCollection.AddPoint(m_oldPoint, ref missing, ref missing);
                    double oldAngle = GetAngle(pPointCollection as IPolyline);
                    // 获取新点角度
                    IPointCollection pointCollection = new PolylineClass();
                    pointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pointCollection.AddPoint(newPoint, ref missing, ref missing);
                    double newAngle = GetAngle(pointCollection as IPolyline);
                    // 旋转Element,角度为新旧点之差
                    ITransform2D pTransform2D = m_viewElement as ITransform2D;
                    pTransform2D.Rotate(centerPoint, (newAngle - oldAngle));
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_viewElement, m_hookHelper.ActiveView.Extent);

                    // 更新旧点变量
                    m_oldPoint = newPoint;
                }
                else
                {
                    object           missing          = Type.Missing;
                    IPoint           newPoint         = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    IPointCollection pPointCollection = new PolylineClass();
                    pPointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pPointCollection.AddPoint(m_point, ref missing, ref missing);
                    double oldAngle = GetAngle(pPointCollection as IPolyline);

                    IPointCollection pointCollection = new PolylineClass();
                    pointCollection.AddPoint(centerPoint, ref missing, ref missing);
                    pointCollection.AddPoint(newPoint, ref missing, ref missing);
                    double newAngle = GetAngle(pointCollection as IPolyline);

                    ITransform2D pTransform2D = m_element as ITransform2D;
                    pTransform2D.Rotate(centerPoint, (newAngle - oldAngle));
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_element, m_hookHelper.ActiveView.Extent);
                    m_point = newPoint;
                }
            }
        }
 IGeometry IGeometricEffect.NextGeometry()
 {
     if (m_bDone)
     {
         return null;
     }
     else
     {
         m_pCloneGeom = (IClone)m_pGeom;
         m_pGeomCopy = (IGeometry)m_pCloneGeom.Clone();
         m_pTransform = (ITransform2D)m_pGeomCopy;
         m_pTransform.Rotate(m_pCenterPoint, m_dAngle);
         m_bDone = true;
         return m_pGeomCopy;                
     }
 }