Beispiel #1
0
    void AddPoint(DrawingPoint drawingPoint)
    {
        if (previousPoint != null && ancestorPoint != null)
        {
            if (Drawer.AreOnLine(ancestorPoint.transform, previousPoint.transform, drawingPoint.transform))
            {
                Points.points++;
            }
        }

        if (drawingPoint.currentPoint != null)
        {
            if (previousPoint != null)
            {
                Extend(drawingPoint.currentPoint);
            }
            previousPoint = drawingPoint.currentPoint;
        }
        else
        {
            Point newPoint = drawingPoint.CreatePoint();
            if (previousPoint != null)
            {
                Extend(newPoint);
            }
            previousPoint = newPoint;
        }
    }
Beispiel #2
0
    public void AddPoint(DrawingPoint newDrawPoint)
    {
        Vector2 newPoint = new Vector2(newDrawPoint.x, newDrawPoint.y);

        // add line if necessary
        if (!newDrawPoint.dragging)
        {
            GameObject lineGo = Instantiate(linePrefab);
            lineGo.transform.SetParent(linesContainer, false);
            LineRenderer line = lineGo.GetComponent <LineRenderer>();
            lines.Add(line);
            lineIndex = lines.Count - 1;

            lines[lineIndex].positionCount = 2;
            lines[lineIndex].SetPosition(0, newPoint);
            lines[lineIndex].SetPosition(1, newPoint);
        }
        else
        {
            int newPointIndex = lines[lineIndex].positionCount;
            lines[lineIndex].positionCount++;
            lines[lineIndex].SetPosition(newPointIndex, newPoint);
        }

        lastPoint = newPoint;
    }
        public SetFixityDialog(SlopeCanvas canvas, DrawingPoint p)
        {
            InitializeComponent();

            this.canvas = canvas;

            this.p             = p;
            isFixedX.IsChecked = p.IsFixedX;
            isFixedY.IsChecked = p.IsFixedY;

            List <LineConstraint> attachedLCs = new List <LineConstraint>();

            canvas.MaterialBlocks.ForEach(
                delegate(MaterialBlock mb)
            {
                attachedLCs.AddRange(mb.LineConstraints.FindAll(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p)); }));
            });
            attachedLCs.ForEach(
                delegate(LineConstraint lc)
            {
                if (lc.IsFixedX)
                {
                    isFixedX.IsEnabled = false;
                }
                if (lc.IsFixedY)
                {
                    isFixedY.IsEnabled = false;
                }
            });
            attachedLCs.Clear();
        }
Beispiel #4
0
    public Point CreatePoint(DrawingPoint drawingPoint)
    {
        GameObject newPoint = Instantiate(pointPref);

        newPoint.transform.position = drawingPoint.transform.position;
        Point newPointScript = newPoint.GetComponent <Point>();

        drawingPoint.currentPoint = newPointScript;
        return(newPointScript);
    }
Beispiel #5
0
 public void MouseOverPoint(DrawingPoint drawingPoint)
 {
     if (isErasing)
     {
         drawingPoint.ErasePoint();
     }
     if (isDrawing == true && (drawingPoint.currentPoint != previousPoint || previousPoint == null))
     {
         AddPoint(drawingPoint);
     }
 }
        private void BeginDrawingObject(MouseButtonEventArgs e)
        {
            Vector mousePos = (Vector)e.GetPosition(MainImageContainer);

            switch (currentlyPressedButton.Name)
            {
            case "DrawLineButon":
                ILine line = new ClippedLine((Vector)e.GetPosition(MainImageContainer), (Vector)e.GetPosition(MainImageContainer), 2, CurrentColor, ClipRectangles);
                currentlyDrawnObject = line;
                DrawingObjects.Add(currentlyDrawnObject);
                currentlyDrawnPoint = line.Point2;
                break;

            case "DrawCircleButton":
                MidpointCircle circle = new MidpointCircle((Vector)e.GetPosition(MainImageContainer), (Vector)e.GetPosition(MainImageContainer), CurrentColor);
                currentlyDrawnObject = circle;
                DrawingObjects.Add(currentlyDrawnObject);
                currentlyDrawnPoint = circle.radiusUtilityPoint;
                break;

            case "DrawPolygonButton":
                Polygon poly = new FilledPolygon(CurrentColor, 2, ClipRectangles, (Vector)e.GetPosition(MainImageContainer), (Vector)e.GetPosition(MainImageContainer));
                currentlyDrawnObject = poly;
                DrawingObjects.Add(currentlyDrawnObject);
                currentlyDrawnPoint = poly.Points[1];
                break;

            case "DrawCapsuleButton":
                Capsule cap = new Capsule(mousePos, mousePos, 0, CurrentColor);
                currentlyDrawnObject = cap;
                DrawingObjects.Add(currentlyDrawnObject);
                currentlyDrawnPoint = cap.Point2;
                break;

            case "DrawRectangleButton":
                DrawingRectangle rec = new DrawingRectangle(CurrentColor, 2, mousePos, mousePos);
                currentlyDrawnObject = rec;
                DrawingObjects.Add(currentlyDrawnObject);
                currentlyDrawnPoint = rec.Points[2];
                break;

            case "FloodFillButton":
                FloodFill fill = new FloodFill(mousePos, CurrentColor);
                DrawingObjects.Add(fill);
                currentState = UIState.PreparingToDraw;
                break;

            default:
                throw new NotImplementedException();
            }
        }
        private void draw(Graphics e, DrawingPoint a)
        {
            Pen p = new Pen(Color.Black, 2);

            using (Font useFont = new Font("Gotham Medium", 28, FontStyle.Bold))
            {
                RectangleF header2Rect = new RectangleF();
                int        moldX       = a.old.X - 5;
                int        moldY       = a.old.Y;
                header2Rect.Location = new Point(moldX, moldY);
                header2Rect.Size     = new Size(600, ((int)e.MeasureString(header2, useFont, 600, StringFormat.GenericTypographic).Height));
                e.DrawString(a.Rand, useFont, Brushes.Black, header2Rect);
            }
        }
Beispiel #8
0
        public override bool ProcessIntent(ControlIntent intent, object data)
        {
            Debug.Assert(HasParent, "A titlebar should always have a parent control!");
            bool handled = false;
            switch (intent) {
                case ControlIntent.Released:
                    goto default; // See if the close button is interested

                case ControlIntent.Held:
                    if (_closeButton.ScreenSpace.Contains((Vector2)data))
                        goto default;
                    else if (ScreenSpace.Contains((Vector2)data))
                        State = ControlState.Moving;
                    handled = true;
                    break;

                case ControlIntent.Move:
                    if (State == ControlState.Moving) {
                        Vector2 newPosition = Parent.Position + (Vector2)data;
                        DrawingPoint mouseCorrection = new DrawingPoint();
                        if (newPosition.X > GameApplication.ScreenSize.Width - Parent.Width) {
                            mouseCorrection.X = (int)((GameApplication.ScreenSize.Width - Parent.Width) - newPosition.X);
                            newPosition.X = GameApplication.ScreenSize.Width - Parent.Width;
                        } else if (newPosition.X < 0) {
                            mouseCorrection.X = (int)-newPosition.X;
                            newPosition.X = 0;
                        }
                        if (newPosition.Y > GameApplication.ScreenSize.Height - Parent.Height) {
                            mouseCorrection.Y = (int)((GameApplication.ScreenSize.Height - Parent.Height) - newPosition.Y);
                            newPosition.Y = GameApplication.ScreenSize.Height - Parent.Height;
                        } else if (newPosition.Y < 0) {
                            mouseCorrection.Y = (int)-newPosition.Y;
                            newPosition.Y = 0;
                        }
                        Cursor.Position = new System.Drawing.Point(
                            Cursor.Position.X + mouseCorrection.X,
                            Cursor.Position.Y + mouseCorrection.Y);
                        Parent.Position = Parent.Position + (Vector2)data;
                        handled = true;
                    }
                    break;

                default:
                    handled = base.ProcessIntent(intent, data);
                    break;
            }
            return handled;
        }
Beispiel #9
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Point curve = new GH_Point();

            DA.GetData <GH_Point>("Point", ref curve);
            GH_String layer = new GH_String(string.Empty);

            DA.GetData <GH_String>("Layer", ref layer);


            DrawingPoint arc = new DrawingPoint();

            arc.point       = curve.ToGrevitPoint();
            arc.TypeOrLayer = layer.Value;
            arc.GID         = this.InstanceGuid.ToString();
            DA.SetData("GrevitComponent", arc);
        }
Beispiel #10
0
 void AddPoint(DrawingPoint drawingPoint)
 {
     if (drawingPoint.currentPoint != null)
     {
         if (previousPoint != null)
         {
             Extend(drawingPoint.currentPoint);
         }
         previousPoint = drawingPoint.currentPoint;
     }
     else
     {
         Point newPoint = CreatePoint(drawingPoint);
         if (previousPoint != null)
         {
             Extend(newPoint);
         }
         previousPoint = newPoint;
     }
 }
        private void CancelDrawingObject()
        {
            if (currentlyDrawnObject != null)
            {
                if (currentlyDrawnObject is Polygon && (currentlyDrawnObject as Polygon).Points.Count > 2)
                {
                    currentlyDrawnPoint = null;
                    (currentlyDrawnObject as Polygon).RemoveLastPoint();
                    currentlyDrawnObject = null;
                }
                else
                {
                    DrawingObjects.Remove(currentlyDrawnObject);
                    currentlyDrawnObject = null;
                    currentlyDrawnPoint  = null;
                }

                UpdateMainImage();
            }
        }
        private void ok_Click(object sender, RoutedEventArgs e)
        {
            if (lc != null)
            {
                lc.IsActiveX = (bool)isFixedX.IsChecked;
                lc.IsActiveY = (bool)isFixedY.IsChecked;

                List <LineConstraint> existingLCs = new List <LineConstraint>();
                existingLCs.Add(lc);
                DrawingPoint endNode = lc.Nodes[0];
                foreach (MaterialBlock mb in canvas.Substructs)
                {
                    existingLCs.AddRange(mb.LineConstraints.FindAll(delegate(LineConstraint lc0) { return(!existingLCs.Contains(lc0) && lc0.Nodes.Contains(endNode)); }));
                }
                endNode.IsFixActiveX = endNode.IsFixActiveY = false;
                existingLCs.ForEach(delegate(LineConstraint lc0) { endNode.IsFixActiveX = endNode.IsFixActiveX || lc0.IsActiveX; endNode.IsFixActiveY = endNode.IsFixActiveY || lc0.IsActiveY; });
                existingLCs.Clear();

                existingLCs.Add(lc);
                endNode = lc.Nodes[1];
                foreach (MaterialBlock mb in canvas.Substructs)
                {
                    existingLCs.AddRange(mb.LineConstraints.FindAll(delegate(LineConstraint lc0) { return(!existingLCs.Contains(lc0) && lc0.Nodes.Contains(endNode)); }));
                }
                endNode.IsFixActiveX = endNode.IsFixActiveY = false;
                existingLCs.ForEach(delegate(LineConstraint lc0) { endNode.IsFixActiveX = endNode.IsFixActiveX || lc0.IsActiveX; endNode.IsFixActiveY = endNode.IsFixActiveY || lc0.IsActiveY; });
                existingLCs.Clear();
            }
            else if (p != null)
            {
                p.IsFixActiveX = (bool)isFixedX.IsChecked;
                p.IsFixActiveY = (bool)isFixedY.IsChecked;
            }

            this.DialogResult = true;
        }
        public ActivateFixityDialog(SlopeDefineCanvas canvas, DrawingPoint p)
        {
            InitializeComponent();

            this.canvas = canvas;

            this.p = p;

            MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.BoundaryPoints.Contains(p)); });

            isFixedX.IsEnabled = parent != null && p.IsFixedX;
            isFixedY.IsEnabled = parent != null && p.IsFixedY;
            isFixedX.IsChecked = parent != null && p.IsFixActiveX;
            isFixedY.IsChecked = parent != null && p.IsFixActiveY;

            List <LineConstraint> attachedLCs = new List <LineConstraint>();

            canvas.Substructs.ForEach(
                delegate(MaterialBlock mb)
            {
                attachedLCs.AddRange(mb.LineConstraints.FindAll(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p)); }));
            });
            attachedLCs.ForEach(
                delegate(LineConstraint lc)
            {
                if (lc.IsActiveX)
                {
                    isFixedX.IsEnabled = false;
                }
                if (lc.IsActiveY)
                {
                    isFixedY.IsEnabled = false;
                }
            });
            attachedLCs.Clear();
        }
Beispiel #14
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <param name="strokeStyle">The style of stroke to apply. </param>
 /// <param name="transform">The transform to apply to the stroked geometry.  </param>
 /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the stroke by less than the tolerance are still considered inside.  Smaller values produce more accurate results but cause slower execution. </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(DrawingPoint point, float strokeWidth, StrokeStyle strokeStyle, Matrix3x2 transform, float flatteningTolerance)
 {
     return StrokeContainsPoint(new DrawingPointF(point.X, point.Y), strokeWidth, strokeStyle, transform, flatteningTolerance);
 }
Beispiel #15
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <param name="strokeStyle">The style of stroke to apply. </param>
 /// <param name="transform">The transform to apply to the stroked geometry.  </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(DrawingPoint point, float strokeWidth, StrokeStyle strokeStyle, Matrix3x2 transform)
 {
     return StrokeContainsPoint(point, strokeWidth, strokeStyle, transform, FlatteningTolerance);
 }
Beispiel #16
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <param name="strokeStyle">The style of stroke to apply. </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(DrawingPoint point, float strokeWidth, StrokeStyle strokeStyle)
 {
     return StrokeContainsPoint(new DrawingPointF(point.X, point.Y), strokeWidth, strokeStyle);            
 }
Beispiel #17
0
 /// <summary>	
 /// Determines whether the geometry's stroke contains the specified point given the specified stroke thickness, style, and transform. 	
 /// </summary>	
 /// <param name="point">The point to test for containment. </param>
 /// <param name="strokeWidth">The thickness of the stroke to apply. </param>
 /// <returns>When this method returns, contains a boolean value set to true if the geometry's stroke contains the specified point; otherwise, false. You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::StrokeContainsPoint([None] D2D1_POINT_2F point,[None] float strokeWidth,[In, Optional] ID2D1StrokeStyle* strokeStyle,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool StrokeContainsPoint(DrawingPoint point, float strokeWidth)
 {
     return StrokeContainsPoint(point, strokeWidth, null);
 }
Beispiel #18
0
 /// <summary>	
 /// Indicates whether the area filled by the geometry would contain the specified point given the specified flattening tolerance. 	
 /// </summary>	
 /// <param name="point">The point to test. </param>
 /// <param name="worldTransform">The transform to apply to the geometry prior to testing for containment, or NULL. </param>
 /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the fill by less than the tolerance are still considered inside.  Smaller values produce more accurate results but cause slower execution.  </param>
 /// <returns>When this method returns, contains a bool value that is true if the area filled by the geometry contains point; otherwise, false.You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::FillContainsPoint([None] D2D1_POINT_2F point,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool FillContainsPoint(DrawingPoint point, Matrix3x2 worldTransform, float flatteningTolerance)
 {
     return FillContainsPoint(new DrawingPointF(point.X, point.Y), worldTransform, flatteningTolerance);
 }
Beispiel #19
0
 /// <summary>	
 /// Indicates whether the area filled by the geometry would contain the specified point given the specified flattening tolerance. 	
 /// </summary>	
 /// <param name="point">The point to test. </param>
 /// <param name="flatteningTolerance">The numeric accuracy with which the precise geometric path and path intersection is calculated. Points missing the fill by less than the tolerance are still considered inside.  Smaller values produce more accurate results but cause slower execution.  </param>
 /// <returns>When this method returns, contains a bool value that is true if the area filled by the geometry contains point; otherwise, false.You must allocate storage for this parameter. </returns>
 /// <unmanaged>HRESULT ID2D1Geometry::FillContainsPoint([None] D2D1_POINT_2F point,[In, Optional] const D2D1_MATRIX_3X2_F* worldTransform,[None] float flatteningTolerance,[Out] BOOL* contains)</unmanaged>
 public bool FillContainsPoint(DrawingPoint point, float flatteningTolerance)
 {
     return FillContainsPoint(new DrawingPointF (point.X, point.Y), null, flatteningTolerance);
 }
        private void ContinueDrawingObject(MouseButtonEventArgs e)
        {
            Vector mousePos = (Vector)e.GetPosition(MainImageContainer);

            switch (currentlyPressedButton.Name)
            {
            case "DrawCircleButton":     //line and circle are exactly the same
            case "DrawLineButon":
                currentlyDrawnObject      = null;
                currentlyDrawnPoint.Point = mousePos;
                currentlyDrawnPoint       = null;
                currentState = UIState.PreparingToDraw;
                UpdateMainImage();
                break;

            case "DrawPolygonButton":
                Polygon poly = currentlyDrawnObject as Polygon;
                if (poly.Points.Count > 2 && poly.Points[0].dist(mousePos) < MaximumSelectDistance)
                {
                    currentlyDrawnObject      = null;
                    currentlyDrawnPoint.Point = mousePos;
                    currentlyDrawnPoint       = null;
                    currentState = UIState.PreparingToDraw;
                }
                else
                {
                    currentlyDrawnPoint.Point = mousePos;
                    currentlyDrawnPoint       = poly.AddPoint(mousePos);
                }
                UpdateMainImage();
                break;

            case "DrawCapsuleButton":
                Capsule cap = currentlyDrawnObject as Capsule;

                if (currentlyDrawnPoint == cap.Point2)
                {
                    currentlyDrawnPoint.Point = mousePos;
                    currentlyDrawnPoint       = cap.radiusUtilityPoint;
                }
                else
                {
                    currentlyDrawnObject      = null;
                    currentlyDrawnPoint.Point = mousePos;
                    currentlyDrawnPoint       = null;
                    currentState = UIState.PreparingToDraw;
                    UpdateMainImage();
                }
                break;

            case "DrawRectangleButton":
                currentlyDrawnObject      = null;
                currentlyDrawnPoint.Point = mousePos;
                currentlyDrawnPoint       = null;
                currentState = UIState.PreparingToDraw;
                UpdateMainImage();
                break;

            default:
                throw new NotImplementedException();
            }
        }