Beispiel #1
0
        /// <summary>
        /// This method requests a point and returns a joint. If a joint is found, the method gets it. If not, then creates one and if the created joint lies on a line,
        /// then the command splits the line and adds the new line to the newLines list.
        /// </summary>
        /// <param name="newLines"> List of new lines created by this method while creating new joints </param>
        /// <returns> The created or found joint </returns>
        public Model.Joint GetJoint(IList <Model.LineElement> newLines)
        {
            Model.Joint joint;
            Canguro.Controller.Snap.Magnet magnet = GetPoint();
            if (magnet == null)
            {
                return(null);
            }
            if (magnet is Canguro.Controller.Snap.PointMagnet && ((Canguro.Controller.Snap.PointMagnet)magnet).Joint != null)
            {
                joint = ((Canguro.Controller.Snap.PointMagnet)magnet).Joint;
            }
            else
            {
                Microsoft.DirectX.Vector3 v = magnet.SnapPosition;
                joint = new Canguro.Model.Joint(v.X, v.Y, v.Z);
                Model.JointList.Add(joint);

                if (magnet is Canguro.Controller.Snap.PointMagnet)
                {
                    Canguro.Controller.Snap.PointMagnet pmag = (Canguro.Controller.Snap.PointMagnet)magnet;
                    if (pmag.RelatedMagnets != null && pmag.RelatedMagnets.Count > 0)
                    {
                        for (int i = 0; i < pmag.RelatedMagnets.Count; i++)
                        {
                            if (pmag.RelatedMagnets[i] is Canguro.Controller.Snap.LineMagnet && ((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line != null)
                            {
                                Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line, joint, Model);
                            }
                        }
                    }
                }
                else if (magnet is Canguro.Controller.Snap.LineMagnet)
                {
                    Canguro.Controller.Snap.LineMagnet lmag = (Canguro.Controller.Snap.LineMagnet)magnet;
                    if (lmag.Line != null)
                    {
                        Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)magnet).Line, joint, Model);
                    }
                }
            }
            SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(joint);
            return(joint);
        }
        /// <summary>
        /// This method returns a vector (displacement) obtained by user input,
        /// either from clicking or typing. The input works by asking for a 
        /// basepoint and then for a second point, which can be typed with absolute
        /// or relative coordinates. The difference between the 2 points is returned.
        /// </summary>
        /// <param name="v">The vector (diplacement) to be returned or Vector3.Empty if
        /// no vector could be obtained.</param>
        /// <returns>True if a valid vector (displacement) could be obtained, false otherwise.</returns>
        public bool GetVector(out Microsoft.DirectX.Vector3 v)
        {
            Snap.Magnet m1, m2;

            // Ask for 1st point
            if ((m1 = GetPoint(Culture.Get("getVector1"))) == null)
            {
                v = Microsoft.DirectX.Vector3.Empty;
                return false;
            }

            // Activate vector Tracking
            Tracking.TrackingService ts = TrackingService;
            TrackingService = Tracking.VectorTrackingService.Instance;
            Microsoft.DirectX.Vector3 origin = m1.SnapPositionInt;
            TrackingService.SetPoint(origin);
            SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(origin, Canguro.Controller.Snap.PointMagnetType.SimplePoint);

            // Ask for 2nd point
            if ((m2 = GetPoint(Culture.Get("getVector2"))) == null)
            {
                v = Microsoft.DirectX.Vector3.Empty;
                TrackingService = ts;
                return false;
            }
            SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(m2.SnapPositionInt, Canguro.Controller.Snap.PointMagnetType.SimplePoint);

            // Calculate and return difference
            v = m2.SnapPositionInt - origin;
            Model.UnitSystem.UnitSystem us = Canguro.Model.UnitSystem.UnitSystemsManager.Instance.CurrentSystem;
            v.X = us.FromInternational(v.X, Canguro.Model.UnitSystem.Units.Distance);
            v.Y = us.FromInternational(v.Y, Canguro.Model.UnitSystem.Units.Distance);
            v.Z = us.FromInternational(v.Z, Canguro.Model.UnitSystem.Units.Distance);

            TrackingService = ts;
            return true;
        }
        /// <summary>
        /// This method requests a point and returns a joint. If a joint is found, the method gets it. If not, then creates one and if the created joint lies on a line,
        /// then the command splits the line and adds the new line to the newLines list. 
        /// </summary>
        /// <param name="newLines"> List of new lines created by this method while creating new joints </param>
        /// <returns> The created or found joint </returns>
        public Model.Joint GetJoint(IList<Model.LineElement> newLines)
        {
            Model.Joint joint;
            Canguro.Controller.Snap.Magnet magnet = GetPoint();
            if (magnet == null)
                return null;
            if (magnet is Canguro.Controller.Snap.PointMagnet && ((Canguro.Controller.Snap.PointMagnet)magnet).Joint != null)
                joint = ((Canguro.Controller.Snap.PointMagnet)magnet).Joint;
            else
            {
                Microsoft.DirectX.Vector3 v = magnet.SnapPosition;
                joint = new Canguro.Model.Joint(v.X, v.Y, v.Z);
                Model.JointList.Add(joint);

                if (magnet is Canguro.Controller.Snap.PointMagnet)
                {
                    Canguro.Controller.Snap.PointMagnet pmag = (Canguro.Controller.Snap.PointMagnet)magnet;
                    if (pmag.RelatedMagnets != null && pmag.RelatedMagnets.Count > 0)
                        for (int i = 0; i < pmag.RelatedMagnets.Count; i++)
                            if (pmag.RelatedMagnets[i] is Canguro.Controller.Snap.LineMagnet && ((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line != null)
                                Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)pmag.RelatedMagnets[i]).Line, joint, Model);
                }
                else if (magnet is Canguro.Controller.Snap.LineMagnet)
                {
                    Canguro.Controller.Snap.LineMagnet lmag = (Canguro.Controller.Snap.LineMagnet)magnet;
                    if (lmag.Line != null)
                        Canguro.Commands.Model.SplitCmd.Split(((Canguro.Controller.Snap.LineMagnet)magnet).Line, joint, Model);
                }
            }
            SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(joint);
            return joint;
        }