Exemple #1
0
 public PieSlice(Geometry.Point p0, double r, double start, double end)
 {
     this.Center = p0;
     this.Radius = r;
     this.Start  = start;
     this.End    = end;
 }
Exemple #2
0
        /// <summary>
        /// Creates an arc from the start point, with the specified radius,
        /// and with the specified span.
        /// </summary>
        /// <param name="centre">Centre point for arc</param>
        /// <param name="start">Start point for arc</param>
        /// <param name="radius">Radius for arc</param>
        /// <param name="span">Span for arc</param>
        /// <returns>Arc created by the operation</returns>
        public PSArc CreateArcSpanExplicit(Geometry.Point centre, Geometry.Point start, double radius, Geometry.Degree span)
        {
            PSArc arc = new PSArc(_powerSHAPE, centre, start, radius, span);

            Add(arc);
            return(arc);
        }
Exemple #3
0
        /// <summary>
        /// Creates a new Workplane relative to an entity and adds it to the collection.
        /// </summary>
        /// <param name="entity">The entity on which to create the new Workplane.</param>
        /// <param name="origin">The intended origin for the workplane.</param>
        /// <returns>The created workplane.</returns>
        public PSWorkplane CreateWorkplaneAlignedToEntity(PSEntity entity, Geometry.Point origin)
        {
            PSWorkplane newWorkplane = new PSWorkplane(_powerSHAPE, entity, origin);

            Add(newWorkplane);
            return(newWorkplane);
        }
        /// <summary>
        /// Moves a group of entities by the relative distance between two absolute positions..
        /// </summary>
        /// <param name="entitiesToMove">The group of entities that are to be moved.</param>
        /// <param name="moveOriginCoordinates">The first of the two absolute positions.</param>
        /// <param name="pointToMoveTo">The second of the two absolute positions.</param>
        /// <param name="copiesToCreate">The number of copies that should be created by the operation.</param>
        /// <returns>A list containing any created copies of the original entities.  If copiesToCreate is 0, the operation returns an empty list.</returns>
        public static List <PSEntity> MoveEntitiesBetweenPoints(
            List <IPSMoveable> entitiesToMove,
            Geometry.Point moveOriginCoordinates,
            Geometry.Point pointToMoveTo,
            int copiesToCreate)
        {
            SetupMove(entitiesToMove, copiesToCreate);

            // Move the origin
            _powerSHAPE.DoCommand("MOVEORIGIN");
            _powerSHAPE.DoCommand("ABS " + moveOriginCoordinates);

            // Carry out the process
            _powerSHAPE.DoCommand("ABS " + pointToMoveTo.X.ToString() + " " + pointToMoveTo.Y.ToString() + " " +
                                  pointToMoveTo.Z.ToString());

            if (_powerSHAPE.Version >= new Version("11.2"))
            {
                _powerSHAPE.DoCommand("APPLY", "DISMISS");
            }
            else
            {
                _powerSHAPE.DoCommand("CANCEL");
            }
            _powerSHAPE.DoCommand("CANCEL");

            return(FinishMove());
        }
        /// <summary>
        /// Creates a single point in PowerShape.
        /// </summary>
        /// <param name="point">The point to create.</param>
        /// <returns>The created point.</returns>
        public PSPoint CreatePoint(Geometry.Point point)
        {
            PSPoint newPoint = new PSPoint(_powerSHAPE, point);

            Add(newPoint);
            return(newPoint);
        }
        public void RemoveVertex(Geometry.Point vertex)
        {
            int indexToRemove;

            for (indexToRemove = 0; indexToRemove < _vertices.Count; ++indexToRemove)
            {
                if (_vertices[indexToRemove].Equals(vertex))
                {
                    break;
                }
            }
            if (indexToRemove == _vertices.Count)
            {
                return;
            }

            if (_vertices.Count == 1)
            {
                _vertices.RemoveAt(indexToRemove);
                return;
            }

            if (_vertices.Count <= 2)
            {
                HandleVertexRemovalTwoPoint(indexToRemove);
                return;
            }


            //TODO: Find new vertices that will emerge from removing the vertex
            //TODO: preserve the cyclical ordering of the vertices to aid in area calculation.
        }
Exemple #7
0
        /// <summary>
        /// Creates an arc with the specified start point and radius.
        /// </summary>
        /// <param name="centre">Centre point for arc</param>
        /// <param name="start">Start point for arc</param>
        /// <param name="radius">Radius for arc</param>
        /// <returns>Arc created by the operation</returns>
        public PSArc CreateArcCircle(Geometry.Point centre, Geometry.Point start, double radius)
        {
            PSArc arc = new PSArc(_powerSHAPE, centre, start, radius);

            Add(arc);
            return(arc);
        }
Exemple #8
0
        public Arc DrawArc(Geometry.Point center, double inner_radius, double outer_radius, double start, double end)
        {
            var arc = new Arc(center, inner_radius, outer_radius, start, end);

            this.Add(arc);
            return(arc);
        }
Exemple #9
0
        public Shape Drop(IVisio.Master master, Geometry.Point pos)
        {
            var m = new Shape(master, pos);

            this.Add(m);
            return(m);
        }
Exemple #10
0
        public Rectangle DrawRectangle(Geometry.Point p0, Geometry.Point p1)
        {
            var rectangle = new Rectangle(p0, p1);

            this.Add(rectangle);
            return(rectangle);
        }
Exemple #11
0
        public PieSlice DrawPieSlice(Geometry.Point center, double radius, double start, double end)
        {
            var pieslice = new PieSlice(center, radius, start, end);

            this.Add(pieslice);
            return(pieslice);
        }
Exemple #12
0
        public Line DrawLine(Geometry.Point p0, Geometry.Point p1)
        {
            var line = new Line(p0, p1);

            this.Add(line);
            return(line);
        }
Exemple #13
0
        private void _draw_connectors(RenderContext context)
        {
            var connector_nodes = this._shapes.Where(s => s is Connector).Cast <Connector>().ToList();

            // if no dynamic connectors then do nothing
            if (connector_nodes.Count < 1)
            {
                return;
            }

            // Drop the number of connectors needed somewhere on the page
            var masters = connector_nodes.Select(i => i.Master.VisioMaster).ToArray();
            var origin  = new Geometry.Point(-2, -2);
            var points  = Enumerable.Range(0, connector_nodes.Count)
                          .Select(i => origin + new Geometry.Point(1.10, 0))
                          .ToList();
            var connector_shapeids = context.VisioPage.DropManyU(masters, points);
            var page_shapes        = context.VisioPage.Shapes;

            // Perform the connection
            for (int i = 0; i < connector_shapeids.Length; i++)
            {
                var connector_shapeid = connector_shapeids[i];
                var vis_connector     = page_shapes.ItemFromID[connector_shapeid];
                var dyncon_shape      = connector_nodes[i];

                var from_shape = context.GetShape(dyncon_shape.From.VisioShapeID);
                var to_shape   = context.GetShape(dyncon_shape.To.VisioShapeID);

                ConnectorHelper.ConnectShapes(from_shape, to_shape, vis_connector);
                dyncon_shape.VisioShape   = vis_connector;
                dyncon_shape.VisioShapeID = connector_shapeids[i];
            }
        }
Exemple #14
0
        public IVisio.Shape AddShape(TextBlock block)
        {
            // Remember this Block
            this.Blocks.Add(block);

            // Calculate the Correct Full Rectangle
            var ll   = new Geometry.Point(this.InsertionPoint.X, this.InsertionPoint.Y - block.Size.Height);
            var tr   = new Geometry.Point(this.InsertionPoint.X + block.Size.Width, this.InsertionPoint.Y);
            var rect = new Geometry.Rectangle(ll, tr);

            // Draw the Shape
            var newshape = this._page.DrawRectangle(rect);

            block.VisioShape   = newshape;
            block.VisioShapeID = newshape.ID;
            block.Rectangle    = rect;

            // Handle Text If Needed
            if (block.Text != null)
            {
                newshape.Text = block.Text;
            }

            this.AdjustInsertionPoint(block.Size);

            return(newshape);
        }
Exemple #15
0
        public Shape Drop(string master, string stencil, Geometry.Point pos)
        {
            var m = new Shape(master, stencil, pos);

            this.Add(m);
            return(m);
        }
Exemple #16
0
        /// <summary>
        /// Creates a workplane from three points
        /// </summary>
        internal PSWorkplane(
            PSAutomation powerSHAPE,
            Geometry.Point origin,
            Geometry.Point xAxisPoint,
            Geometry.Point yAxisPoint) : base(powerSHAPE)
        {
            _powerSHAPE.DoCommand("CREATE WORKPLANE THREEPOINTS",
                                  "X " + origin.X.ToString(),
                                  "Y " + origin.Y.ToString(),
                                  "Z " + origin.Z.ToString(),
                                  "X " + xAxisPoint.X.ToString(),
                                  "Y " + xAxisPoint.Y.ToString(),
                                  "Z " + xAxisPoint.Z.ToString(),
                                  "X " + yAxisPoint.X.ToString(),
                                  "Y " + yAxisPoint.Y.ToString(),
                                  "Z " + yAxisPoint.Z.ToString());
            _powerSHAPE.DoCommand("ACCEPT");

            // Get the new workplane
            PSWorkplane newWorkplane = (PSWorkplane)_powerSHAPE.ActiveModel.CreatedItems[0];

            // Get the id of the new workplane
            _name = newWorkplane.Name;
            _id   = newWorkplane.Id;
        }
Exemple #17
0
        /// <summary>
        /// Creates a new Workplane oriented to the current view at the specified origin and adds it to the collection.
        /// </summary>
        /// <param name="origin">The intended origin for the workplane.</param>
        public PSWorkplane CreateWorkplaneAlignedToView(Geometry.Point origin)
        {
            PSWorkplane newWorkplane = new PSWorkplane(_powerSHAPE, origin);

            Add(newWorkplane);
            return(newWorkplane);
        }
Exemple #18
0
        public static Int64 CreateBidService(Int64 AppUserId, Int64 TempAppUserId, Int64 ServiceId, string CustomerComment)
        {
            BidService NewBid  = new BidService();
            BidService HelpBid = GetActiveBidServiceByAppOrTempUserId(AppUserId, TempAppUserId);
            Int64      CityId  = 0;

            Geometry.Point Location = null;
            if (HelpBid != null)
            {
                return(0);
            }
            if (AppUserId != 0)
            {
                AppUser a = AppUser.FetchByID(AppUserId);
                NewBid.AppUserId = AppUserId;;
                CityId           = a.CityId;
                Location         = a.AddressLocation;
            }
            else if (TempAppUserId != 0)
            {
                TempAppUser t = TempAppUser.FetchByID(TempAppUserId);
                NewBid.TempAppUserId = TempAppUserId;
                CityId   = t.CityId;
                Location = t.Location;
            }
            NewBid.ServiceId      = ServiceId;
            NewBid.StartDate      = DateTime.UtcNow;
            NewBid.ServiceComment = CustomerComment;
            NewBid.EndDate        = DateTime.UtcNow.AddHours(Convert.ToDouble(Settings.GetSettingDecimal(Settings.Keys.END_BID_TIME_MIN, 15)));
            NewBid.Save();

            //send push to suppliers
            SendPushToSuppliers(NewBid.BidId, ServiceId, CityId, Location);
            return(NewBid.BidId);
        }
Exemple #19
0
        public static IVisio.Shape DrawLine(this IVisio.Page page, Geometry.Point p1, Geometry.Point p2)
        {
            var surface = new SurfaceTarget(page);
            var shape   = surface.DrawLine(p1, p2);

            return(shape);
        }
Exemple #20
0
        /// <summary>
        /// Creates a line between the specified points.
        /// </summary>
        /// <param name="startPoint">The start point.</param>
        /// <param name="endPoint">The end point.</param>
        /// <returns>The new line.</returns>
        /// <remarks></remarks>
        public PSLine CreateLine(Geometry.Point startPoint, Geometry.Point endPoint)
        {
            var objLine = new PSLine(_powerSHAPE, startPoint, endPoint);

            Add(objLine);
            return(objLine);
        }
        /// <summary>
        /// Creates a spring at a specified origin.
        /// </summary>
        /// <param name="origin">The origin at which to create the spring.</param>
        /// <returns>The created spring.</returns>
        /// <remarks></remarks>
        public PSSurfaceSpring CreateSpring(Geometry.Point origin)
        {
            PSSurfaceSpring newSpring = new PSSurfaceSpring(_powerSHAPE, origin);

            _powerSHAPE.ActiveModel.Surfaces.Add(newSpring);
            return(newSpring);
        }
Exemple #22
0
        public IFigure Add(Geometry.Point t)
        {
            int i;

            for (i = Length; i > 0 && !t.IsLighted(Back, Front); i--)
            {
                PushBack(PopFront);
            }
            if (i > 0)
            {
                Geometry.Point x;
                Grow(Back, Front, t);
                for (x = PopFront; t.IsLighted(x, Front); x = PopFront)
                {
                    Grow(x, Front, t);
                }
                PushFront(x);
                for (x = PopBack; t.IsLighted(Back, x); x = PopBack)
                {
                    Grow(Back, x, t);
                }
                PushBack(x);
                Perimeter += Basics.DistanceBetween(Back, t) + Basics.DistanceBetween(t, Front);
                PushFront(t);
            }
            return(this);
        }
        /// <summary>
        /// Creates a cone at a specified origin.
        /// </summary>
        /// <param name="origin">The origin at which to create the cone.</param>
        /// <returns>The created cone.</returns>
        /// <remarks></remarks>
        public PSSurfaceCone CreateCone(Geometry.Point origin)
        {
            PSSurfaceCone newCone = new PSSurfaceCone(_powerSHAPE, origin);

            _powerSHAPE.ActiveModel.Surfaces.Add(newCone);
            return(newCone);
        }
        /// <summary>
        /// Creates a Torus at a specified origin.
        /// </summary>
        /// <param name="origin">The origin at which to create the Torus.</param>
        /// <returns>The created Torus.</returns>
        /// <remarks></remarks>
        public PSSurfaceTorus CreateTorus(Geometry.Point origin)
        {
            PSSurfaceTorus newTorus = new PSSurfaceTorus(_powerSHAPE, origin);

            _powerSHAPE.ActiveModel.Surfaces.Add(newTorus);
            return(newTorus);
        }
        /// <summary>
        /// Draws a point geometry
        /// </summary>
        /// <param name="p">Point geometry</param>
        private void DrawPoint(Point p)
        {
            float x = (float)p.X - PointRadius;
            float y = canvasHeight - (float)p.Y - PointRadius;

            graphics.DrawEllipse(drawingPen, x, y, PointDiameter, PointDiameter);
        }
        /// <summary>
        /// Creates a plane at a specified origin.
        /// </summary>
        /// <param name="origin">The origin at which to create the plane.</param>
        /// <param name="principalPlane">Sets the principal plane. Defines which plane is the principal plane of the workspace.</param>
        /// <returns>The created plane.</returns>
        /// <remarks></remarks>
        public PSSurfacePlane CreatePlane(Geometry.Point origin, Planes principalPlane)
        {
            PSSurfacePlane newPlane = new PSSurfacePlane(_powerSHAPE, origin, principalPlane);

            _powerSHAPE.ActiveModel.Surfaces.Add(newPlane);
            return(newPlane);
        }
Exemple #27
0
        public override void DrawLine(Geometry.Point a, Geometry.Point b, Geometry.Color color)
        {
            CheckInFrame("DrawLine");

            mGraphics.DrawLine(new Pen(Interop.Convert(color)),
                               Interop.Convert(a), Interop.Convert(b));
        }
Exemple #28
0
        public ApplicationPlaceholderObject TopographyToNative(Topography speckleSurface)
        {
            var docObj = GetExistingElementByApplicationId(((Base)speckleSurface).applicationId);

            var pts = new List <XYZ>();

            for (int i = 0; i < speckleSurface.displayMesh.vertices.Count; i += 3)
            {
                var point = new Geometry.Point(speckleSurface.displayMesh.vertices[i], speckleSurface.displayMesh.vertices[i + 1], speckleSurface.displayMesh.vertices[i + 2], speckleSurface.displayMesh.units);
                pts.Add(PointToNative(point));
            }

            if (docObj != null)
            {
                Doc.Delete(docObj.Id);
            }

            var revitSurface = TopographySurface.Create(Doc, pts);

            if (speckleSurface is RevitTopography rt)
            {
                SetInstanceParameters(revitSurface, rt);
            }
            //Report.Log($"Created Topography {revitSurface.Id}");
            return(new ApplicationPlaceholderObject {
                applicationId = ((Base)speckleSurface).applicationId, ApplicationGeneratedId = revitSurface.UniqueId, NativeObject = revitSurface
            });
        }
Exemple #29
0
 /// <summary>
 /// Moves a single curve by the relative distance between two absolute positions
 /// </summary>
 /// <param name="moveOriginCoordinates">First of the two absolute positions</param>
 /// <param name="pointToMoveTo">Second of the two absolute positions</param>
 /// <param name="copiesToCreate">Number of copies that should be created by the operation</param>
 public List <PSEntity> MoveBetweenPoints(
     Geometry.Point moveOriginCoordinates,
     Geometry.Point pointToMoveTo,
     int copiesToCreate)
 {
     return(PSEntityMover.MoveEntityBetweenPoints(this, moveOriginCoordinates, pointToMoveTo, copiesToCreate));
 }
Exemple #30
0
        /// <summary>
        /// Creates an arc between the start and end points,
        /// inferring the radius from the start point.
        /// </summary>
        /// <param name="centre">Centre point for arc</param>
        /// <param name="startPoint">Start point for arc</param>
        /// <param name="endPoint">End point for arc</param>
        /// <returns>Arc created by the operation</returns>
        public PSArc CreateArcSpanImplicit(Geometry.Point centre, Geometry.Point startPoint, Geometry.Point endPoint)
        {
            PSArc arc = new PSArc(_powerSHAPE, centre, startPoint, endPoint);

            Add(arc);
            return(arc);
        }
 public ShrinkingBoard(int geoboardOrder)
 {
     _geoboardOrder = geoboardOrder;
     var lowerLeft = new Geometry.Point(0, 0);
     var lowerRight = new Geometry.Point(_geoboardOrder, 0);
     var upperRight = new Geometry.Point(_geoboardOrder, _geoboardOrder);
     var upperLeft = new Geometry.Point(0, _geoboardOrder);
     _vertices = new List<Geometry.Point>
                 {
                     lowerLeft,
                     lowerRight,
                     upperRight,
                     upperLeft
                 };
 }
Exemple #32
0
        private static Geometry.Point ReadPoint(BinaryReader reader, int? SRID, WkbCoordinateSystem cs)
        {
            double x = reader.ReadDouble();
            double y = reader.ReadDouble();

            Geometry.Point pt = new Geometry.Point(x, y);
            pt.SRID = SRID;

            switch (cs)
            {
                case WkbCoordinateSystem.XY:
                    break;
                case WkbCoordinateSystem.XYZ:
                    {
                        pt.Z = reader.ReadDouble();
                    }
                    break;
                case WkbCoordinateSystem.XYM:
                    {
                        pt.M = reader.ReadDouble();
                    }
                    break;
                case WkbCoordinateSystem.XYZM:
                    {
                        pt.Z = reader.ReadDouble();
                        pt.M = reader.ReadDouble();
                    }
                    break;
                default:
                    throw new ArgumentException(String.Format("Coordinate system not supported: {0}", cs));
            }

            return pt;
        }
        private void HandleVertexRemovalTwoPoint(int indexToRemove)
        {
            if(indexToRemove > 1 || _vertices.Count != 2)
                throw new ArgumentException("Should not call HandleVertexRemovalTwoPoint with invalid index or with more than 2 verticies.");

            var vertexToRemove = _vertices[indexToRemove];
            var otherVertex = _vertices[indexToRemove == 0 ? 1 : 0];
            var totalRise = vertexToRemove.Y - otherVertex.X;
            var totalRun = vertexToRemove.X - otherVertex.X;
            var gcd = NumericalMethods.Math.Gcd(totalRise, totalRun);
            var rise = totalRise/gcd;
            var run = totalRun/gcd;

            var trialAdditionalVertex = new Geometry.Point(vertexToRemove.X + run, vertexToRemove.Y + rise);
            _vertices.RemoveAt(indexToRemove);
            if(!trialAdditionalVertex.Equals(otherVertex))
                _vertices.Insert(indexToRemove, trialAdditionalVertex);
        }
Exemple #34
0
 public void setCurrentPos(Coordinates.Coordinate projCoordinate)
 {
     currentPosition = projCoordinate.coordinatePoint;
 }