示例#1
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[2];

                    double shapeAngle = 0;

                    if (origVertex.Parent is LfShapeViewModel)
                    {
                        LfShapeViewModel shape = origVertex.Parent as LfShapeViewModel;

                        shapeAngle = shape.Angle;
                    }

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    return((angle - shapeAngle) / Math.PI * 180);
                }
            }

            return(null);
        }
示例#2
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 2)
            {
                if ((values[0] is double) && (values[1] is LfPointViewModel))
                {
                    double              pos     = (double)values[0];
                    LfPointViewModel    vertex  = (LfPointViewModel)values[1];
                    IBoxPointsInterface boxVm   = vertex.PointsParent;
                    LfShapeViewModel    shapeVm = (LfShapeViewModel)vertex.PointsParent;

                    Point p;

                    if (parameter as string == "x")
                    {
                        p = new Point(pos, vertex.PosY);
                        Point rp = shapeVm.RotatedPointFromLocal(p);
                        return(rp.X);
                    }
                    else
                    {
                        p = new Point(vertex.PosX, pos);
                        Point rp = shapeVm.RotatedPointFromLocal(p);
                        return(rp.Y);
                    }
                }
            }

            return(null);
        }
 public void ConnectToShapes(CompositeCollection coll)
 {
     _bodyVm = ParentVm.FindShape(LocalModelObject.BodyName, coll);
     if (_bodyVm == null)
     {
         MessageBox.Show("The shape pointed to by " + LocalModelObject.BodyName + " does not exists in CO " + ParentVm.Name, "Error parsing file", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        // This method returns with the point of the shape's coordinate system
        // in this CompoundObject's coordinate system.
        // The position of the shape is added to the shape point. The shape point
        // can be either rotated or not.
        public Point ShapePointInCo(Point shapePoint, LfShapeViewModel shape)
        {
            if (shape == null)
            {
                return(new Point(0, 0));
            }

            Point coPoint = shapePoint;

            coPoint.Offset(shape.PosX, shape.PosY);

            return(coPoint);
        }
        // This method returns with the point of the CO's coordinate system
        // in this Shape's coordinate system.
        // The position of the shape is subtracted from the CO point.
        public Point CoPointInShape(Point coPoint, LfShapeViewModel shape)
        {
            if (shape == null)
            {
                return(new Point(0, 0));
            }

            Point shapePoint = coPoint;

            shapePoint.Offset(-shape.PosX, -shape.PosY);

            return(shapePoint);
        }
        public void ConnectToShapes(StateShapeCollectionViewModel shapes)
        {
            _aVm = ParentVm.FindShape(ModelObject.AName, shapes);
            if (_aVm == null)
            {
                MessageBox.Show("The shape A pointed to by " + ModelObject.Name + " does not exists in CO " + ParentVm.Name, "Error parsing file", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            _bVm = ParentVm.FindShape(ModelObject.BName, shapes);
            if (_bVm == null)
            {
                MessageBox.Show("The shape B pointed to by " + ModelObject.Name + " does not exists in CO " + ParentVm.Name, "Error parsing file", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void DeselectAllChildren()
        {
            if ((Behaviour != null) && (Behaviour.BehaviourProperties != null))
            {
                Behaviour.BehaviourProperties.IsSelected = false;
            }

            if ((StateShapes != null) && (StateShapes.Shapes != null))
            {
                foreach (object o in StateShapes.Shapes)
                {
                    if (o is LfPolygonViewModel)
                    {
                        LfPolygonViewModel pvm = o as LfPolygonViewModel;

                        pvm.DeselectAllPoints();
                        pvm.IsSelected = false;
                    }
                    else if (o is LfShapeViewModel)
                    {
                        LfShapeViewModel shape = o as LfShapeViewModel;

                        shape.IsSelected = false;
                    }
                }
            }

            if (StateJoints != null)
            {
                foreach (object o in StateJoints.Joints)
                {
                    if (o is WeldJointViewModel)
                    {
                        WeldJointViewModel joint = (WeldJointViewModel)o;

                        joint.IsSelected = false;
                    }
                }
            }

            if (ChildObjectsWithStates != null)
            {
                foreach (ChildObjectViewModel child in ChildObjectsWithStates.Children)
                {
                    child.DeselectAllChildren();
                    child.IsSelected = false;
                }
            }
        }
示例#8
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is LfDragablePointViewModel)
            {
                LfDragablePointViewModel vertex = (LfDragablePointViewModel)value;
                LfShapeViewModel         shape  = vertex.Parent;

                Point p  = new Point(vertex.PosX, vertex.PosY);
                Point rp = shape.RotatedPointFromLocal(p);

                return(rp.Y);
            }

            return(null);
        }
示例#9
0
        public void AddChildShapesToGlobalCollection(ref CompositeCollection coll, bool showJoints, bool showSystems, bool showBackgrounds)
        {
            if (CompObj != null)
            {
                foreach (Object o in CompObj.ShapeCollection.Shapes)
                {
                    if (o is LfShapeViewModel)
                    {
                        LfShapeViewModel svm = o as LfShapeViewModel;
                        coll.Add(svm);
                    }
                }

                if (showJoints)
                {
                    foreach (Object o in CompObj.JointCollection.Joints)
                    {
                        if (o is WeldJointViewModel)
                        {
                            WeldJointViewModel wjvm = o as WeldJointViewModel;
                            coll.Add(wjvm);
                        }
                    }
                }

                if (showSystems)
                {
                    foreach (Object o in CompObj.SystemCollection.Systems)
                    {
                        if (o is CoSystemViewModel)
                        {
                            CoSystemViewModel svm = o as CoSystemViewModel;
                            coll.Add(svm);
                        }
                    }
                }


                if (CompObj != MainVm.EditedCpVm)
                {
                    foreach (ChildObjectViewModel covm in CompObj.ChildObjectCollection.Children)
                    {
                        covm.AddChildShapesToGlobalCollection(ref coll, showJoints, showSystems, showBackgrounds);
                    }
                }
            }
        }
        public LfShapeViewModel FindShape(string name, StateShapeCollectionViewModel shapes)
        {
            foreach (object o in shapes.Shapes)
            {
                if (o is LfShapeViewModel)
                {
                    LfShapeViewModel shape = (LfShapeViewModel)o;

                    if (shape.Name == name)
                    {
                        return(shape);
                    }
                }
            }

            return(null);
        }
示例#11
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 7)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] != null) && (values[2] is LfShapeViewModel))
                {
                    // In this case Shape B exists and is used. The conversion is done as in MultiRotatedJointValueConverter
                    Point            pos   = new Point((double)values[0], (double)values[1]);
                    LfShapeViewModel shape = (LfShapeViewModel)values[2];
                    Point            rp    = shape.RotatedPointFromLocal(pos);
                    rp.Offset(shape.PosX, shape.PosY);

                    if (parameter as string == "x")
                    {
                        return(rp.X);
                    }
                    else
                    {
                        return(rp.Y);
                    }
                }
                else if ((values[3] is double) && (values[4] is double) && (values[5] is LfShapeViewModel) && (values[6] is double))
                {
                    // In this case Shape B does not exists, the end point will be as For shape A but a distance Length below

                    Point            pos    = new Point((double)values[3], (double)values[4]);
                    LfShapeViewModel shape  = (LfShapeViewModel)values[5];
                    double           length = (double)values[6];
                    Point            rp     = shape.RotatedPointFromLocal(pos);
                    rp.Offset(shape.PosX, shape.PosY);

                    rp.Y += length;

                    if (parameter as string == "x")
                    {
                        return(rp.X);
                    }
                    else
                    {
                        return(rp.Y);
                    }
                }
            }

            return(null);
        }
示例#12
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 2)
            {
                if ((values[0] is double) && (values[1] is LfPointViewModel))
                {
                    LfPointViewModel    origVertex = (LfPointViewModel)values[1];
                    IBoxPointsInterface boxVm      = origVertex.PointsParent;
                    LfShapeViewModel    shapeVm    = (LfShapeViewModel)origVertex.PointsParent;

                    int i = boxVm.PointVms.IndexOf(origVertex);

                    if (i == -1)
                    {
                        return(null);
                    }

                    LfPointViewModel vertex;

                    if (i > 0)
                    {
                        vertex = boxVm.PointVms[i - 1];
                    }
                    else
                    {
                        vertex = boxVm.PointVms[boxVm.PointVms.Count() - 1];
                    }

                    Point p  = new Point(vertex.PosX, vertex.PosY);
                    Point rp = shapeVm.RotatedPointFromLocal(p);

                    if (parameter as string == "x")
                    {
                        return(rp.X);
                    }
                    else
                    {
                        return(rp.Y);
                    }
                }
            }

            return(null);
        }
        virtual public void DeselectAllChildren()
        {
            if ((ShapeCollection != null) && (ShapeCollection.Shapes != null))
            {
                foreach (object o in ShapeCollection.Shapes)
                {
                    if (o is LfPolygonViewModel)
                    {
                        LfPolygonViewModel pvm = o as LfPolygonViewModel;

                        pvm.DeselectAllPoints();
                        pvm.IsSelected = false;
                    }
                    else if (o is LfShapeViewModel)
                    {
                        LfShapeViewModel shape = o as LfShapeViewModel;

                        shape.IsSelected = false;
                    }
                }
            }
        }
示例#14
0
        public ObjectFactoryPropertiesViewModel(
            TreeViewViewModel treeParent,
            CompoundObjectViewModel parentVm,
            MainViewModel mainVm,
            ObjectFactoryProperties modelObject,
            CoSystemViewModel systemViewModel) :
            base(treeParent, parentVm, mainVm, systemViewModel)
        {
            _modelObject = modelObject;

            if (_modelObject != null)
            {
                _bodyObject = ParentVm.FindBodyObject(_modelObject.Body);
            }

            foreach (SpawnObject so in LocalModelObject.SpawnObjects)
            {
                SpawnObjectViewModel sovm = new SpawnObjectViewModel(this, parentVm, mainVm, this, so);
                SpawnObjects.Add(sovm);
            }

            UpdateCornerPoints();
        }
        public void RemoveShape(LfShapeViewModel svm)
        {
            // Check if there are any joints connected to this svm, if so, removed them
            // We may remove joints so we need a for loop here:
            for (int i = StateJoints.Joints.Count - 1; i >= 0; i--)
            {
                // Below will take care of all joints since they
                // all inherit from WeldJoint
                if (StateJoints.Joints[i] is WeldJointViewModel)
                {
                    WeldJointViewModel joint = (WeldJointViewModel)StateJoints.Joints[i];

                    if ((joint.AName == svm.Name) || (joint.BName == svm.Name))
                    {
                        // Remove the joint
                        ModelObject.RemoveJoint(joint.ModelObject);
                        StateJoints.Joints.RemoveAt(i);
                    }
                }
            }

            // Remove the shape model
            ModelObject.RemoveShape(svm.ModelObject);

            // Remove the shape viewmodel from this
            StateShapes.Shapes.Remove(svm);

            // If there are no more shapes in the CO, remove the CO
            if (StateShapes.Shapes.Count == 0)
            {
                //ParentVm.StateChildObjects.Remove(this);
                //ParentVm.ModelObject.ChildObjectRefs(this.ChildObjectOfParent)
            }

            OnPropertyChanged("");
        }
示例#16
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfShapeViewModel))
                {
                    Point            pos   = new Point((double)values[0], (double)values[1]);
                    LfShapeViewModel shape = (LfShapeViewModel)values[2];
                    Point            rp    = shape.RotatedPointFromLocal(pos);
                    rp.Offset(shape.PosX, shape.PosY);

                    if (parameter as string == "x")
                    {
                        return(rp.X);
                    }
                    else
                    {
                        return(rp.Y);
                    }
                }
            }

            return(null);
        }
示例#17
0
 public ShapePoint(Point p, LfShapeViewModel shape)
 {
     _p     = p;
     _shape = shape;
 }
 // Override me
 virtual public void RemoveShape(LfShapeViewModel svm)
 {
 }