Exemplo n.º 1
0
        protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
        {
            double mindist = double.MaxValue;

            found = GeoPoint.Origin;
            if (base.CurrentInput == lengthInput && iCurve is Line)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeAll();
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        double[] tanpos = (l[i] as ICurve).TangentPosition(iCurve.StartDirection);
                        if (tanpos != null)
                        {
                            for (int j = 0; j < tanpos.Length; j++)
                            {
                                GeoPoint p = (l[i] as ICurve).PointAt(tanpos[j]);
                                double   d = base.WorldPoint(e.Location) | p;
                                if (d < mindist)
                                {
                                    mindist = d;
                                    found   = p;
                                }
                            }
                        }
                    }
                }
            }
            return(mindist != double.MaxValue);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseMove"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseMove.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseMove.vw"/></param>
 public override void OnMouseMove(MouseEventArgs e, IView vw)
 {
     using (Frame.Project.Undo.ContextFrame(this))
     {
         SnapPointFinder.DidSnapModes DidSnap;
         GeoPoint p = base.SnapPoint(e, fixPoint, vw, out DidSnap);
         // hier möglicherweise einige Fangmethoden ausschalten
         // der fixPoint und der aktuelle Punkt werden in die aktuelle Zeichenebene projiziert
         if (CalculateAngleEvent != null)
         {
             SetAngle(new Angle(CalculateAngleEvent(p)));
         }
         else
         {
             if (usesLocalPlane)
             {
                 GeoPoint2D pp = localPlane.Project(p);
                 SetAngle(new Angle(pp, GeoPoint2D.Origin));
             }
             else
             {
                 GeoPoint2D pp        = ActiveDrawingPlane.Project(p);
                 GeoPoint2D pfixpoint = ActiveDrawingPlane.Project(fixPoint);
                 SetAngle(new Angle(pp, pfixpoint));
             }
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseDown"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseDown.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseDown.vw"/></param>
 public override void OnMouseDown(MouseEventArgs e, IView vw)
 {
     if (Mode == 0 && Frame.GetBooleanSetting("ZoomAction.SingleClick", false))
     {
         OnMouseUp(e, vw); // schaltet in Modus 1 weiter
     }
 }
Exemplo n.º 4
0
        public override void OnMouseMove(MouseEventArgs e, IView vw)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (modelView == null)
            {
                return;
            }
            int HScrollOffset = lastPanPosition.X - e.X;

            if (HScrollOffset == 0)
            {
                return;
            }
            double Factor = 1.0;

            if (HScrollOffset > 0)
            {
                Factor = 1.0 + HScrollOffset / 100.0;
            }
            else if (HScrollOffset < 0)
            {
                Factor = 1.0 / (1.0 - HScrollOffset / 100.0);
            }
            (modelView as IView).ZoomDelta(Factor);
            lastPanPosition = new System.Drawing.Point(e.X, e.Y);
        }
Exemplo n.º 5
0
 public void OnMouseMove(MouseEventArgs e, IView View)
 {
     try
     {
         Action a = (Actions.Count > 0) ? (Action)Actions.Peek() : null;
         if (a != null && a.AcceptMouseInput(View))
         {
             a.SetCurrentMouseView(View);
             a.OnMouseMove(e, View);
         }
         else
         {
             View.SetCursor("No");
         }
         ++liceneseCounter; // overflow macht nix, ausprobiert!
         if (liceneseCounter % 5000 == 10)
         {
         }
     }
     catch (Exception ex)
     {   // der ActionStack ist der Verteiler der MouseMessages. Falls dort eine Exception auftritt
         // wird die hier gefangen und stört nicht weiter. Das ist eine Forderung von ERSA. Ggf.
         // hier eine Möglichkeit die Exceeption doch noch weiterzureichen vorsehen.
         if (ex is ThreadAbortException)
         {
             throw (ex);
         }
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseMove"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseMove.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseMove.vw"/></param>
 public override void OnMouseMove(MouseEventArgs e, IView vw)
 {
     using (Frame.Project.Undo.ContextFrame(this))
     {
         SnapPointFinder.DidSnapModes DidSnap;
         SetGeoVector(base.SnapPoint(e, vw, out DidSnap) - basePoint);
     }
 }
        protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
        {
            double mindist = double.MaxValue;

            found = GeoPoint.Origin;
            if (CurrentInput == width && startPointInput.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeAll();
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        double[] tanpos = (l[i] as ICurve).TangentPosition(line.ParallelogramSecondaryDirection);
                        if (tanpos != null)
                        {
                            for (int j = 0; j < tanpos.Length; j++)
                            {
                                GeoPoint p = (l[i] as ICurve).PointAt(tanpos[j]);
                                double   d = base.WorldPoint(e.Location) | p;
                                if (d < mindist)
                                {
                                    mindist = d;
                                    found   = p;
                                }
                            }
                        }
                    }
                }
            }
            if (CurrentInput == height && startPointInput.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeBlocks(true);
                l.DecomposeBlockRefs();
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        double[] tanpos = (l[i] as ICurve).TangentPosition(line.StartDirection);
                        if (tanpos != null)
                        {
                            for (int j = 0; j < tanpos.Length; j++)
                            {
                                GeoPoint p = (l[i] as ICurve).PointAt(tanpos[j]);
                                double   d = base.WorldPoint(e.Location) | p;
                                if (d < mindist)
                                {
                                    mindist = d;
                                    found   = p;
                                }
                            }
                        }
                    }
                }
            }
            return(mindist != double.MaxValue);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseUp"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseUp.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseUp.vw"/></param>
 public override void OnMouseUp(MouseEventArgs e, IView vw)
 {
     using (Frame.Project.Undo.ContextFrame(this))
     {
         SnapPointFinder.DidSnapModes DidSnap;
         SetGeoVector(base.SnapPoint(e, vw, out DidSnap) - basePoint);
     }
     Frame.Project.Undo.ClearContext(); // also die nächsten Änderungen sind ein neuer undo Schritt
     base.RemoveThisAction();
 }
Exemplo n.º 9
0
        private void OnClickOnSelectedObject(IGeoObject selected, IView vw, MouseEventArgs e, ref bool handled)
        {
            if (!handled && propertyPage != null)
            {
                GeoPoint dp = vw.Projection.DrawingPlanePoint(new Point(e.X, e.Y));
                int      index;
                Dimension.HitPosition hp = dimension.GetHitPosition(vw.Projection, vw.Projection.ProjectUnscaled(dp), out index);
                if ((hp & Dimension.HitPosition.Text) != 0)
                {
                    propertyPage.MakeVisible(dimText[index]);
                    propertyPage.SelectEntry(dimText[index]);
                }
                else if ((hp & Dimension.HitPosition.LowerText) != 0)
                {
                    propertyPage.MakeVisible(tolMinusText[index]);
                    propertyPage.SelectEntry(tolMinusText[index]);
                }
                else if ((hp & Dimension.HitPosition.PostFix) != 0)
                {
                    propertyPage.MakeVisible(postfix[index]);
                    propertyPage.SelectEntry(postfix[index]);
                }
                else if ((hp & Dimension.HitPosition.PostFixAlt) != 0)
                {
                    propertyPage.MakeVisible(postfixAlt[index]);
                    propertyPage.SelectEntry(postfixAlt[index]);
                }
                else if ((hp & Dimension.HitPosition.Prefix) != 0)
                {
                    propertyPage.MakeVisible(prefix[index]);
                    propertyPage.SelectEntry(prefix[index]);
                }
                else if ((hp & Dimension.HitPosition.UpperText) != 0)
                {
                    propertyPage.MakeVisible(tolPlusText[index]);
                    propertyPage.SelectEntry(tolPlusText[index]);
                }
                else if ((hp & Dimension.HitPosition.AltText) != 0)
                {
                    // den gibts noch nicht
                }

                // es wird nicht gehandled hier, damit der Text-Hotspot noch geht

                // der Texteditor macht noch zu große Probleme hier
                // er ist in der Dimension auch erst für DimText mit Index 0 implementiert ...
                //				Text text = dimension.EditText(vw.Projection,0,Dimension.EditingMode.editDimText);
                //				editor = new TextEditor(text,dimText[0],Frame);
                //				editor.OnFilterMouseMessages(SelectObjectsAction.MouseAction.MouseDown, e,vw,ref handled);
                //				if (handled)
                //				{
                //					text.DidChange += new ChangeDelegate(OnTextEdited);
                //				}
            }
        }
Exemplo n.º 10
0
        protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
        {
            double mindist = double.MaxValue;

            found = GeoPoint.Origin;
            // nur beim dritten Punkt:
            if (CurrentInput == pointInput && curve1Input.Fixed && curve2Input.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeAll();
                GeoPoint inpoint = base.WorldPoint(e.Location);
                Plane    pln     = arc.Plane;
                bool     plnOK   = false;
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        ICurve curve = l[i] as ICurve;
                        if (curve is Line)
                        {
                            // alles in einer Ebene? In welcher?
                            plnOK = !((pln.Distance((curve as Line).StartPoint) > Precision.eps) || (pln.Distance((curve as Line).EndPoint) > Precision.eps));
                        }
                        if (curve is Ellipse)
                        {
                            plnOK = (curve.IsInPlane(pln));
                            // alles in einer Ebene?
                        }
                        if (plnOK)
                        {
                            // Achtung! Die Sortierung mit Linie(n) am Anfang ist wichtig für die Auswertung des Abstandes!!
                            ICurve2D     l2D1          = (l[i] as ICurve).GetProjectedCurve(pln);
                            ICurve2D     l2D2          = tang1Curves[selected1].GetProjectedCurve(pln);
                            ICurve2D     l2D3          = tang2Curves[selected2].GetProjectedCurve(pln);
                            GeoPoint2D[] tangentPoints = Curves2D.TangentCircle(l2D1, l2D2, l2D3, pln.Project(inpoint), pln.Project(object1Point), pln.Project(object2Point));
                            if (tangentPoints.Length > 0)
                            {
                                for (int k = 0; k < tangentPoints.Length; k += 4)
                                {
                                    double dist = Geometry.Dist(tangentPoints[k + 1], pln.Project(inpoint));
                                    if (dist < mindist)
                                    {
                                        mindist = dist;
                                        found   = pln.ToGlobal(tangentPoints[k + 1]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(mindist != double.MaxValue);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Implements <see cref="Action.OnMouseMove"/>. If you override this method
        /// don't forget to call the bas implementation.
        /// </summary>
        /// <param name="e"><paramref name="Action.OnMouseMove.e"/></param>
        /// <param name="vw"><paramref name="Action.OnMouseMove.vw"/></param>
        public override void OnMouseMove(MouseEventArgs e, IView vw)
        {
            using (Frame.Project.Undo.ContextFrame(this))
            {
                SnapPointFinder.DidSnapModes DidSnap;
                switch (mode)
                {
                case Mode.fromPoint:
                    SetLength(Geometry.Dist(base.SnapPoint(e, fixPoint, vw, out DidSnap), fixPoint));
                    break;

                case Mode.fromLine:
                    SetLength(Geometry.DistPL(base.SnapPoint(e, fixPoint, vw, out DidSnap), linePoint, lineDirection));
                    break;
                }
            }
        }
Exemplo n.º 12
0
        public override void OnMouseMove(MouseEventArgs e, IView vw)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (modelView == null)
            {
                return;
            }
            vw.Canvas.Cursor = "SizeAll";
            int HScrollOffset = e.X - lastPanPosition.X;
            int VScrollOffset = e.Y - lastPanPosition.Y;

            modelView.Scroll(HScrollOffset, VScrollOffset);
            lastPanPosition = new System.Drawing.Point(e.X, e.Y);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseMove"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseMove.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseMove.vw"/></param>
 public override void OnMouseMove(MouseEventArgs e, IView vw)
 {
     using (Frame.Project.Undo.ContextFrame(this))
     {
         SnapPointFinder.DidSnapModes DidSnap;
         GeoPoint p = base.SnapPoint(e, basePoint, vw, out DidSnap);
         if (DidSnap == SnapPointFinder.DidSnapModes.DidNotSnap)
         {
             // der Punkt wurde also nicht gefangen, befindet sich somit in der Zeichenebene
             // da diese Aktion aber bei Hotspots drankommt, soll aber statt der Zeichenebene die zur Zeichenebene
             // parallele Ebene durch den basePoint (den Ausgangspunkt) genommen werden
             Plane parallel = GetMousePlane(vw); //  new Plane(basePoint, vw.Projection.DrawingPlane.DirectionX, vw.Projection.DrawingPlane.DirectionY);
             p = parallel.ToGlobal(parallel.Project(p));
             // die Berechnung ist umständlich, man bräuchte nur den Offsetvektor einmal berechnen
         }
         SetGeoPoint(p);
     }
 }
Exemplo n.º 14
0
 public void OnMouseWheel(MouseEventArgs e, IView View)
 {
     try
     {
         Action a = (Actions.Count > 0) ? (Action)Actions.Peek() : null;
         if (a != null && a.AcceptMouseInput(View))
         {
             a.OnMouseWheel(e, View);
         }
     }
     catch (Exception ex)
     {   // der ActionStack ist der Verteiler der MouseMessages. Falls dort eine Exception auftritt
         // wird die hier gefangen und stört nicht weiter. Das ist eine Forderung von ERSA. Ggf.
         // hier eine Möglichkeit die Exceeption doch noch weiterzureichen vorsehen.
         if (ex is ThreadAbortException)
         {
             throw (ex);
         }
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Overrides <see cref="CADability.Actions.Action.OnMouseUp (MouseEventArgs, IView)"/>
        /// </summary>
        /// <param name="e"></param>
        /// <param name="vw"></param>
        public override void OnMouseUp(MouseEventArgs e, IView vw)
        {
            OnMouseMove(e, vw); // damit wird Invalidate... aufgerufen
            switch (Mode)
            {
            case 0:
                Mode        = 1;
                SecondPoint = FirstPoint;
                break;

            case 1:
                Mode = -1;
                BoundingRect mm = BoundingRect.EmptyBoundingRect;
                mm.MinMax(vw.Projection.PointWorld2D(FirstPoint));
                mm.MinMax(vw.Projection.PointWorld2D(SecondPoint));
                base.RemoveThisAction();     // damit werden auch die PaintHandler abgemeldet
                                             // und es gibt noch ungültige Bereiche im Active. D.h. es wird gelöscht.
                vw.ZoomToRect(mm);
                break;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Implements <see cref="Action.OnMouseMove"/>. If you override this method
        /// don't forget to call the bas implementation.
        /// </summary>
        /// <param name="e"><paramref name="Action.OnMouseMove.e"/></param>
        /// <param name="vw"><paramref name="Action.OnMouseMove.vw"/></param>
        public override void OnMouseMove(MouseEventArgs e, IView vw)
        {
            switch (Mode)
            {
            case 0:
                activeView = vw;
                vw.Invalidate(PaintBuffer.DrawingAspect.Active, Rectangle.FromLTRB(vw.DisplayRectangle.Left, FirstPoint.Y, vw.DisplayRectangle.Right, FirstPoint.Y + 1));
                vw.Invalidate(PaintBuffer.DrawingAspect.Active, Rectangle.FromLTRB(FirstPoint.X, vw.DisplayRectangle.Top, FirstPoint.X + 1, vw.DisplayRectangle.Bottom));
                FirstPoint = new Point(e.X, e.Y);
                vw.Invalidate(PaintBuffer.DrawingAspect.Active, Rectangle.FromLTRB(vw.DisplayRectangle.Left, FirstPoint.Y, vw.DisplayRectangle.Right, FirstPoint.Y + 1));
                vw.Invalidate(PaintBuffer.DrawingAspect.Active, Rectangle.FromLTRB(FirstPoint.X, vw.DisplayRectangle.Top, FirstPoint.X + 1, vw.DisplayRectangle.Bottom));
                break;

            case 1:
                Rectangle Clip = PaintBuffer.RectangleFromPoints(FirstPoint, SecondPoint, new Point(e.X, e.Y));
                Clip.Width  += 1;
                Clip.Height += 1;
                vw.Invalidate(PaintBuffer.DrawingAspect.Active, Clip);
                SecondPoint = new Point(e.X, e.Y);
                break;
            }
        }
Exemplo n.º 17
0
        protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
        {
            double mindist = double.MaxValue;

            found = GeoPoint.Origin;
            if (CurrentInput == rad && circCenter.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeBlocks(true);
                l.DecomposeBlockRefs();
                GeoPoint inpoint = base.WorldPoint(e.Location);
                Plane    pln     = vw.Projection.DrawingPlane;
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        ICurve curve = l[i] as ICurve;
                        if (curve.IsInPlane(pln))
                        {
                            ICurve2D     c2d  = curve.GetProjectedCurve(pln);
                            GeoPoint2D   c12d = pln.Project(circle.Center);
                            GeoPoint2D[] pp   = c2d.PerpendicularFoot(c12d);
                            for (int j = 0; j < pp.Length; j++)
                            {
                                GeoPoint p = pln.ToGlobal(pp[j]);
                                double   d = base.WorldPoint(e.Location) | p;
                                if (d < mindist)
                                {
                                    mindist = d;
                                    found   = p;
                                }
                            }
                        }
                    }
                }
            }
            return(mindist != double.MaxValue);
        }
Exemplo n.º 18
0
 public void OnMouseUp(MouseEventArgs e, IView View)
 {
     try
     {
         Action a = (Actions.Count > 0) ? (Action)Actions.Peek() : null;
         if (a != null && a.AcceptMouseInput(View))
         {
             a.SetCurrentMouseView(View);
             a.OnMouseUp(e, View);
         }
         {   // folgende Zeile nur zum Aufwecken der open cascade dll
             // dmit die Prüfung der Lizenz stattfindet
         }
     }
     catch (Exception ex)
     {   // der ActionStack ist der Verteiler der MouseMessages. Falls dort eine Exception auftritt
         // wird die hier gefangen und stört nicht weiter. Das ist eine Forderung von ERSA. Ggf.
         // hier eine Möglichkeit die Exceeption doch noch weiterzureichen vorsehen.
         if (ex is ThreadAbortException)
         {
             throw (ex);
         }
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseDown"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseDown.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseDown.vw"/></param>
 public override void OnMouseDown(MouseEventArgs e, IView vw)
 {
     base.OnMouseDown(e, vw);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Implements <see cref="Action.OnMouseUp"/>. If you override this method
 /// don't forget to call the bas implementation.
 /// </summary>
 /// <param name="e"><paramref name="Action.OnMouseUp.e"/></param>
 /// <param name="vw"><paramref name="Action.OnMouseUp.vw"/></param>
 public override void OnMouseUp(MouseEventArgs e, IView vw)
 {
     OnMouseMove(e, vw);
     Frame.Project.Undo.ClearContext(); // also die nächsten Änderungen sind ein neuer undo Schritt
     base.RemoveThisAction();
 }
Exemplo n.º 21
0
        public override void OnMouseMove(MouseEventArgs e, IView vw)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (modelView == null)
            {
                return;
            }
            int HOffset = e.X - lastPanPosition.X;
            int VOffset = e.Y - lastPanPosition.Y;

            if (VOffset != 0 || HOffset != 0)
            {
                Projection Projection = vw.Projection;
                lastPanPosition = new Point(e.X, e.Y);
                GeoVector haxis = Projection.InverseProjection * GeoVector.XAxis;
                GeoVector vaxis = Projection.InverseProjection * GeoVector.YAxis;
                ModOp     mh    = ModOp.Rotate(vaxis, SweepAngle.Deg(HOffset / 5.0));
                ModOp     mv    = ModOp.Rotate(haxis, SweepAngle.Deg(VOffset / 5.0));

                ModOp project = Projection.UnscaledProjection * mv * mh;
                // jetzt noch die Z-Achse einrichten. Die kann senkrecht nach oben oder unten
                // zeigen. Wenn die Z-Achse genau auf den Betrachter zeigt oder genau von ihm weg,
                // dann wird keine Anpassung vorgenommen, weils sonst zu sehr wackelt
                GeoVector z = project * GeoVector.ZAxis;
                if (modelView.ZAxisUp)
                {
                    const double mindeg = 0.05; // nur etwas aufrichten, aber in jedem Durchlauf
                    if (z.y < -0.1)
                    {                           // Z-Achse soll nach unten zeigen
                        Angle a = new Angle(-GeoVector2D.YAxis, new GeoVector2D(z.x, z.y));
                        if (a.Radian > mindeg)
                        {
                            a.Radian = mindeg;
                        }
                        if (a.Radian < -mindeg)
                        {
                            a.Radian = -mindeg;
                        }
                        if (z.x < 0)
                        {
                            project = project * ModOp.Rotate(vaxis ^ haxis, -a.Radian);
                        }
                        else
                        {
                            project = project * ModOp.Rotate(vaxis ^ haxis, a.Radian);
                        }
                        z = project * GeoVector.ZAxis;
                    }
                    else if (z.y > 0.1)
                    {
                        Angle a = new Angle(GeoVector2D.YAxis, new GeoVector2D(z.x, z.y));
                        if (a.Radian > mindeg)
                        {
                            a.Radian = mindeg;
                        }
                        if (a.Radian < -mindeg)
                        {
                            a.Radian = -mindeg;
                        }
                        if (z.x < 0)
                        {
                            project = project * ModOp.Rotate(vaxis ^ haxis, a.Radian);
                        }
                        else
                        {
                            project = project * ModOp.Rotate(vaxis ^ haxis, -a.Radian);
                        }
                        z = project * GeoVector.ZAxis;
                    }
                }
                // Fixpunkt bestimmen
                Point clcenter = vw.Canvas.ClientRectangle.Location;
                clcenter.X += vw.Canvas.ClientRectangle.Width / 2;
                clcenter.Y += vw.Canvas.ClientRectangle.Height / 2;
                // ium Folgenden ist Temporary auf true zu setzen und ein Mechanismus zu finden
                // wie der QuadTree von ProjektedModel berechnet werden soll
                //GeoVector newDirection = mv * mh * Projection.Direction;
                //GeoVector oldDirection = Projection.Direction;
                //GeoVector perp = oldDirection ^ newDirection;

                GeoPoint fixpoint;
                //if (Settings.GlobalSettings.ContainsSetting("ViewFixPoint"))
                if (modelView != null && modelView.FixPointValid)
                {
                    //fixpoint = (GeoPoint)Settings.GlobalSettings.GetValue("ViewFixPoint");
                    fixpoint = modelView.FixPoint;
                }
                else
                {
                    fixpoint = Projection.UnProject(clcenter);
                }
                modelView.SetViewDirection(project, fixpoint, true);
                if (Math.Abs(HOffset) > Math.Abs(VOffset))
                {
                    if (HOffset > 0)
                    {
                        vw.Canvas.Cursor = "PanEast";
                    }
                    else
                    {
                        vw.Canvas.Cursor = "PanWest";
                    }
                }
                else
                {
                    if (HOffset > 0)
                    {
                        vw.Canvas.Cursor = "PanSouth";
                    }
                    else
                    {
                        vw.Canvas.Cursor = "PanNorth";
                    }
                }
                modelView.projectedModelNeedsRecalc = false;
            }
        }
Exemplo n.º 22
0
 public override void OnMouseUp(MouseEventArgs e, IView vw)
 {
     base.RemoveThisAction();
 }
Exemplo n.º 23
0
 public override void OnMouseUp(MouseEventArgs e, IView vw)
 {
     (layoutView as IView).Invalidate(PaintBuffer.DrawingAspect.Active, (layoutView as IView).Canvas.ClientRectangle);
     layoutPatch.RefreshShowProperties();
     layoutView.Repaint();
 }
Exemplo n.º 24
0
 public override void OnMouseDown(MouseEventArgs e, IView vw)
 {
     lastPanPosition = new System.Drawing.Point(e.X, e.Y);
     modelView       = vw as ModelView; // nur da soll gedreht werden
 }
Exemplo n.º 25
0
 public override void OnMouseDown(MouseEventArgs e, IView vw)
 {
     lastPos = downPos = layoutView.screenToLayout * new GeoPoint2D(e.X, e.Y);
 }
Exemplo n.º 26
0
        protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
        {
            double mindist = double.MaxValue;

            found = GeoPoint.Origin;
            if (CurrentInput == secondPointInput && startPointInput.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeAll();
                GeoPoint inpoint = base.WorldPoint(e.Location);
                Plane    pln     = vw.Projection.DrawingPlane;
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        ICurve curve = l[i] as ICurve;
                        if (curve.IsInPlane(pln))
                        {
                            ICurve2D     c2d  = curve.GetProjectedCurve(pln);
                            GeoPoint2D   c12d = pln.Project(line.RectangleLocation);
                            GeoPoint2D[] pp   = c2d.PerpendicularFoot(c12d);
                            for (int j = 0; j < pp.Length; j++)
                            {
                                GeoPoint p = pln.ToGlobal(pp[j]);
                                double   d = base.WorldPoint(e.Location) | p;
                                if (d < mindist)
                                {
                                    mindist = d;
                                    found   = p;
                                }
                            }
                        }
                    }
                }
            }
            if (CurrentInput == height && startPointInput.Fixed && secondPointInput.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeBlocks(true);
                l.DecomposeBlockRefs();
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        double[] tanpos = (l[i] as ICurve).TangentPosition(line.StartDirection);
                        if (tanpos != null)
                        {
                            for (int j = 0; j < tanpos.Length; j++)
                            {
                                GeoPoint p = (l[i] as ICurve).PointAt(tanpos[j]);
                                double   d = base.WorldPoint(e.Location) | p;
                                if (d < mindist)
                                {
                                    mindist = d;
                                    found   = p;
                                }
                            }
                        }
                    }
                }
            }
            return(mindist != double.MaxValue);
        }
Exemplo n.º 27
0
        public override void OnMouseMove(MouseEventArgs e, IView vw)
        {
            if (e.Button == MouseButtons.None)
            {
                GeoPoint2D p  = layoutView.screenToLayout * new GeoPoint2D(e.X, e.Y);
                double     fr = Math.Abs(layoutView.screenToLayout * 3); // 3 Pixel ModOp2D
                                                                         // p im LayoutSystem
                BoundingRect ext;
                if (layoutPatch.Area == null)
                {
                    ext = new BoundingRect(0.0, 0.0, layoutView.Layout.PaperWidth, layoutView.Layout.PaperHeight);
                }
                else
                {
                    ext = layoutPatch.Area.Extent;
                }
                BoundingRect.Position pos = ext.GetPosition(p, fr);
                if (pos == BoundingRect.Position.inside)
                {
                    currentPosition = Position.inside;
                }
                else if (pos == BoundingRect.Position.outside)
                {
                    currentPosition = Position.outside;
                }
                else
                {
                    if (Math.Abs(ext.Bottom - p.y) < fr)
                    {
                        currentPosition = Position.bottom;
                    }
                    if (Math.Abs(ext.Top - p.y) < fr)
                    {
                        currentPosition = Position.top;
                    }
                    if (Math.Abs(ext.Left - p.x) < fr)
                    {
                        currentPosition = Position.left;
                    }
                    if (Math.Abs(ext.Right - p.x) < fr)
                    {
                        currentPosition = Position.right;
                    }
                }
                setCursor(vw);
            }
            else if (e.Button == MouseButtons.Left)
            {
                setCursor(vw);
                GeoPoint2D   p = layoutView.screenToLayout * new GeoPoint2D(e.X, e.Y);
                BoundingRect ext;
                if (layoutPatch.Area == null)
                {
                    ext = new BoundingRect(0.0, 0.0, layoutView.Layout.PaperWidth, layoutView.Layout.PaperHeight);
                }
                else
                {
                    ext = layoutPatch.Area.Extent;
                }
                double xPos = 0.0;
                double yPos = 0.0;
                switch (currentPosition)
                {
                case Position.inside:
                    xPos    = p.x - lastPos.x;
                    yPos    = p.y - lastPos.y;
                    lastPos = p;
                    break;

                case Position.outside:
                    xPos = p.x - lastPos.x;
                    yPos = p.y - lastPos.y;
                    ext.Move(new GeoVector2D(xPos, yPos));
                    lastPos = p;
                    break;

                case Position.left:
                    ext.Left = p.x;
                    break;

                case Position.right:
                    ext.Right = p.x;
                    break;

                case Position.bottom:
                    ext.Bottom = p.y;
                    break;

                case Position.top:
                    ext.Top = p.y;
                    break;
                }
                layoutPatch.Area = ext.ToBorder();
                if (xPos != 0.0 || yPos != 0.0)
                {
                    layoutView.Layout.MovePatch(layoutPatch, xPos, yPos);
                }
                (layoutView as IView).Invalidate(PaintBuffer.DrawingAspect.Active, (layoutView as IView).Canvas.ClientRectangle);
            }
        }
Exemplo n.º 28
0
        protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
        {
            double mindist = double.MaxValue;

            found = GeoPoint.Origin;
            // nur beim dritten Punkt:
            if (CurrentInput == arcPoint3Input && arcPoint1Input.Fixed && arcPoint2Input.Fixed)
            {
                GeoObjectList l = base.GetObjectsUnderCursor(e.Location);
                l.DecomposeAll();
                GeoPoint inpoint = base.WorldPoint(e.Location);
                Plane    pln     = Plane.XYPlane;
                bool     plnOK   = false;
                for (int i = 0; i < l.Count; i++)
                {
                    if (l[i] is ICurve)
                    {
                        ICurve curve = l[i] as ICurve;
                        if (curve is Line)
                        {
                            double eps;
                            bool   linear;
                            // alles in einer Ebene? In welcher?
                            pln   = Plane.FromPoints(new GeoPoint[] { circlePoint1, circlePoint2, (curve as Line).StartPoint, (curve as Line).EndPoint }, out eps, out linear);
                            plnOK = !(linear || eps > Precision.eps);
                        }
                        if (curve is Ellipse)
                        {
                            pln = (curve as Ellipse).GetPlane();
                            // alles in einer Ebene?
                            plnOK = !((pln.Distance(circlePoint1) > Precision.eps) || (pln.Distance(circlePoint2) > Precision.eps));
                        }
                        if (plnOK)
                        {   // Hilfskreise machen um die ersten 2 Punkte:
                            Ellipse circLoc1;
                            circLoc1 = Ellipse.Construct();
                            circLoc1.SetCirclePlaneCenterRadius(pln, circlePoint1, 0.0);
                            Ellipse circLoc2;
                            circLoc2 = Ellipse.Construct();
                            circLoc2.SetCirclePlaneCenterRadius(pln, circlePoint2, 0.0);
                            // Achtung! Die Sortierung mit Linie(n) am Anfang ist wichtig für die Auswertung des Abstandes!!
                            ICurve2D     l2D1          = (l[i] as ICurve).GetProjectedCurve(pln);
                            ICurve2D     l2D2          = circLoc1.GetProjectedCurve(pln);
                            ICurve2D     l2D3          = circLoc2.GetProjectedCurve(pln);
                            GeoPoint2D[] tangentPoints = Curves2D.TangentCircle(l2D1, l2D2, l2D3, pln.Project(inpoint), pln.Project(circlePoint1), pln.Project(circlePoint2));
                            if (tangentPoints.Length > 0)
                            {
                                for (int k = 0; k < tangentPoints.Length; k += 4)
                                {
                                    double dist = Geometry.Dist(tangentPoints[k + 1], pln.Project(inpoint));
                                    if (dist < mindist)
                                    {
                                        mindist = dist;
                                        found   = pln.ToGlobal(tangentPoints[k + 1]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(mindist != double.MaxValue);
        }