Exemplo n.º 1
0
    public void AddGeometryState(GeometryState state)
    {
        int color = ConfigManager.GeometryGroup().Color;

        geometryMap.Add(state.geometry, state);
        AddState(state, geometryStates, color);
    }
Exemplo n.º 2
0
    private void AddState(Geometry geometry)
    {
        Type type = Type.GetType(tool.Name + "GeometryState");

        if (type != null)
        {
            GeometryState geometryState = (GeometryState)Activator.CreateInstance(type, tool, geometry);
            geometryState.OnClickDelete = () => geoController.ClearGeometryOperation(geometry);

            stateController.AddGeometryState(geometryState);
        }
    }
Exemplo n.º 3
0
        //=============================================================================
        protected override void _SetState(GeometryState state)
        {
            base._SetState(state);

            SheetGeometry_State sheetGeomState = state as SheetGeometry_State;

            if (sheetGeomState == null)
            {
                return;
            }

            this.m_BoundSheetGUID = sheetGeomState.BoundSheetGUID;
        }
Exemplo n.º 4
0
        //=============================================================================
        protected override void _SetState(GeometryState state)
        {
            base._SetState(state);

            Shutter_State shutterState = state as Shutter_State;

            if (shutterState == null)
            {
                return;
            }

            this.m_SwingDoor = shutterState.SwingDoor;
        }
Exemplo n.º 5
0
        //=============================================================================
        protected override void _SetState(GeometryState state)
        {
            base._SetState(state);

            Wall_State wallState = state as Wall_State;

            if (wallState == null)
            {
                return;
            }

            this.m_WallPosition = wallState.WallPosition;
        }
Exemplo n.º 6
0
        //=============================================================================
        protected override void _SetState(GeometryState state)
        {
            base._SetState(state);

            TieBeam_State tieBeamState = state as TieBeam_State;

            if (tieBeamState == null)
            {
                return;
            }

            this.m_AttachedRacksHeightError = tieBeamState.AttachedRacksHeightError;
        }
Exemplo n.º 7
0
        //=============================================================================
        public override bool SetGripPoint(int gripIndex, Point pnt, double DrawingLength, double DrawingWidth)
        {
            //
            if (GRIP_TOP_LEFT == gripIndex || GRIP_CENTER == gripIndex || GRIP_BOTTOM_RIGHT == gripIndex)
            {
                string strError;
                bool   bRes = false;

                GeometryState oldState = this._GetClonedState();

                if (GRIP_TOP_LEFT == gripIndex)
                {
                    bRes = SetPropertyValue(PROP_TOP_LEFT_POINT, pnt, false, false, false, out strError);
                }
                else if (GRIP_CENTER == gripIndex)
                {
                    bRes = SetPropertyValue(PROP_CENTER_POINT, pnt, false, false, false, out strError);
                }
                else if (GRIP_BOTTOM_RIGHT == gripIndex)
                {
                    bRes = SetPropertyValue(PROP_BOT_RIGHT_POINT, pnt, false, false, false, out strError);
                }

                if (!bRes)
                {
                    this._SetState(oldState);
                }

                if (bRes)
                {
                    _MarkStateChanged();
                }

                this.UpdateProperties();

                return(bRes);
            }

            bool bResult = base.SetGripPoint(gripIndex, pnt, DrawingLength, DrawingWidth);

            OnSizeChanged();

            if (bResult)
            {
                _MarkStateChanged();
            }

            this.UpdateProperties();

            return(bResult);
        }
Exemplo n.º 8
0
        //=============================================================================
        protected override void _SetState(GeometryState state)
        {
            base._SetState(state);

            Column_State columnState = state as Column_State;

            if (columnState == null)
            {
                return;
            }

            this.m_iSizeIndex       = columnState.SizeIndex;
            this.CanContinuePattern = columnState.CanContinuePattern;
            this.ColumnPattern_ID   = columnState.ColumnPattern_ID;
        }
Exemplo n.º 9
0
        //=============================================================================
        public override bool SetGripPoint(int gripIndex, Point pnt, double DrawingLength, double DrawingWidth)
        {
            if (Wrapper == null || Wrapper.Owner == null)
            {
                return(false);
            }

            if (GRIP_TOP_LEFT == gripIndex || GRIP_BOTTOM_RIGHT == gripIndex || GRIP_CENTER == gripIndex)
            {
                GeometryState oldState = this._GetClonedState();

                bool bRes = true;
                // change size of all columns in the column pattern
                if (GRIP_TOP_LEFT == gripIndex)
                {
                    bRes = _Column_SetPropertyValue(PROP_TOP_LEFT_POINT, pnt, DrawingLength, DrawingWidth, false, false);
                }
                else if (GRIP_BOTTOM_RIGHT == gripIndex)
                {
                    bRes = _Column_SetPropertyValue(PROP_BOT_RIGHT_POINT, pnt, DrawingLength, DrawingWidth, false, false);
                }
                else if (GRIP_CENTER == gripIndex)
                {
                    bRes = _Column_SetPropertyValue(PROP_CENTER_POINT, pnt, DrawingLength, DrawingWidth, false, true);
                }

                if (!bRes)
                {
                    this._SetState(oldState);
                }

                if (bRes)
                {
                    _MarkStateChanged();
                }

                this.UpdateProperties();

                return(bRes);
            }

            return(base.SetGripPoint(gripIndex, pnt, DrawingLength, DrawingWidth));
        }
Exemplo n.º 10
0
        //=============================================================================
        public override bool SetPropertyValue(string strPropSysName, object propValue, bool bWasChangedViaProperties, bool bChangeTheSameRectangles, bool bNotifySheet, out string strError, bool bCheckLayout = true)
        {
            strError = string.Empty;

            if (PROP_DIMENSION_Z == strPropSysName)
            {
                return(base.SetPropertyValue(strPropSysName, propValue, bWasChangedViaProperties, bChangeTheSameRectangles, bNotifySheet, out strError, bCheckLayout));
            }

            if (!m_bIsHorizontal)
            {
                if (PROP_DIMENSION_X == strPropSysName)
                {
                    strPropSysName = PROP_DIMENSION_Y;
                }
            }

            GeometryState oldState = this._GetClonedState();

            bool bRes = _SetPropertyValue(strPropSysName, propValue, bCheckLayout && this.IsInit, out strError);

            if (bRes)
            {
                _MarkStateChanged();
            }

            if (!bRes)
            {
                this._SetState(oldState);
            }

            if (m_Sheet != null && bNotifySheet)
            {
                m_Sheet.OnPropertyChanged(this, strPropSysName, bRes, strError);
            }

            this.UpdateProperties();

            return(bRes);
        }
Exemplo n.º 11
0
        void UpdateGeometryState()
        {
            m_GeometryState = GeometryState.Okay;
            var skinnedPoints = new NativeList <float3>(8192, Allocator.Temp);

            foreach (PhysicsShapeAuthoring shape in targets)
            {
                // if a custom mesh is assigned, only check it
                using (var so = new SerializedObject(shape))
                {
                    var customMesh = so.FindProperty(m_CustomMesh.propertyPath).objectReferenceValue as UnityMesh;
                    if (customMesh != null)
                    {
                        m_GeometryState |= GetGeometryState(customMesh, shape.gameObject);
                        continue;
                    }
                }

                // otherwise check all mesh filters in the hierarchy that might be included
                var geometryState = GeometryState.Okay;
                foreach (var meshFilter in PhysicsShapeAuthoring.GetAllMeshFiltersInHierarchyBelongingToShape(shape, false))
                {
                    geometryState |= GetGeometryState(meshFilter.sharedMesh, shape.gameObject);
                }

                if (shape.ShapeType == ShapeType.Mesh)
                {
                    PhysicsShapeAuthoring.GetAllSkinnedPointsInHierarchyBelongingToShape(shape, skinnedPoints, false);
                    if (skinnedPoints.Length > 0)
                    {
                        geometryState |= GeometryState.MeshWithSkinnedPoints;
                    }
                }

                m_GeometryState |= geometryState;
            }
            skinnedPoints.Dispose();
        }
Exemplo n.º 12
0
 //=============================================================================
 protected override void _SetState(GeometryState state)
 {
     base._SetState(state);
 }
Exemplo n.º 13
0
        //=============================================================================
        public override bool SetPropertyValue(string strPropSysName, object propValue, bool bWasChangedViaProperties, bool bChangeTheSameRectangles, bool bNotifySheet, out string strError, bool bCheckLayout = true)
        {
            strError = string.Empty;

            if (m_Sheet == null)
            {
                return(false);
            }

            GeometryState oldState = this._GetClonedState();

            bool bResult = false;

            // MinLengthX and MinLengthY of Aisle Space depends on the position and size.
            // base.SetPropertyValue check MinLengthX and MinLengthY while changing the property, it is not correct.
            // Need to set property with 0 as MinLengthX and MinLengthY. After the size and position of Aisle Space is set then
            // need to check MinLengthX and MinLengthY.
            if (PROP_TOP_LEFT_POINT == strPropSysName ||
                PROP_CENTER_POINT == strPropSysName ||
                PROP_BOT_RIGHT_POINT == strPropSysName ||
                PROP_TOP_LEFT_POINT_X == strPropSysName ||
                PROP_TOP_LEFT_POINT_Y == strPropSysName)
            {
                if (PROP_TOP_LEFT_POINT_X == strPropSysName || PROP_TOP_LEFT_POINT_Y == strPropSysName)
                {
                    Point newTopLeft_GlobalPoint = TopLeft_GlobalPoint;
                    if (PROP_TOP_LEFT_POINT_X == strPropSysName)
                    {
                        newTopLeft_GlobalPoint.X = Convert.ToDouble(propValue);
                    }
                    else if (PROP_TOP_LEFT_POINT_Y == strPropSysName)
                    {
                        newTopLeft_GlobalPoint.Y = Convert.ToDouble(propValue);
                    }

                    // dont stretch it, just move by center point
                    Point newCenterPoint = newTopLeft_GlobalPoint;
                    newCenterPoint.X += this.Length_X / 2;
                    newCenterPoint.Y += this.Length_Y / 2;

                    //
                    bResult = this._SetPropertyValue(PROP_CENTER_POINT, newCenterPoint, m_Sheet.Length, m_Sheet.Width, bWasChangedViaProperties, out strError, bCheckLayout);
                }
                else
                {
                    bResult = this._SetPropertyValue(strPropSysName, propValue, m_Sheet.Length, m_Sheet.Width, bWasChangedViaProperties, out strError, bCheckLayout);
                }
            }
            else
            {
                // dont notify sheet, because name is not changed yet
                bResult = base.SetPropertyValue(strPropSysName, propValue, bWasChangedViaProperties, bChangeTheSameRectangles, false, out strError, false);
            }

            OnSizeChanged();

            if (bResult)
            {
                _MarkStateChanged();
            }

            if (m_Sheet != null && bNotifySheet)
            {
                m_Sheet.OnPropertyChanged(this, strPropSysName, bResult, strError);
            }

            if (!bResult)
            {
                this._SetState(oldState);
            }

            this.UpdateProperties();

            return(bResult);
        }
Exemplo n.º 14
0
        //=============================================================================
        public override bool SetGripPoint(int gripIndex, Point globalPoint, double DrawingLength, double DrawingWidth)
        {
            if (m_Sheet == null)
            {
                return(false);
            }

            if (Wrapper == null || Wrapper.Owner == null)
            {
                return(false);
            }

            GeometryState oldState = this._GetClonedState();

            //
            if (BaseRectangleGeometry.GRIP_CENTER == gripIndex)
            {
                // make a decision - to which border should it be snapped?
                double deltaTop   = Math.Abs(globalPoint.Y);
                double deltaBot   = Math.Abs(globalPoint.Y - DrawingWidth);
                double deltaLeft  = Math.Abs(globalPoint.X);
                double deltaRight = Math.Abs(globalPoint.X - DrawingLength);

                // horiz or vertical
                double minVert  = Math.Min(deltaLeft, deltaRight);
                double minHoriz = Math.Min(deltaBot, deltaTop);

                bool oldIsHorizontal = IsHorizontal;
                if (minHoriz <= minVert)
                {
                    IsHorizontal = true;
                }
                else
                {
                    IsHorizontal = false;
                }
                //
                if (oldIsHorizontal != IsHorizontal)
                {
                    double rVal = Length_X;
                    Length_X = Length_Y;
                    Length_Y = rVal;
                }

                // try to change position
                // mouse point is the center of this rectangle
                Point newTopLeftPoint = globalPoint;
                //
                if (IsHorizontal)
                {
                    newTopLeftPoint.X -= Length_X / 2;
                    //
                    if (newTopLeftPoint.X < 0)
                    {
                        newTopLeftPoint.X = 0;
                    }
                    if (newTopLeftPoint.X + Length_X > DrawingLength)
                    {
                        newTopLeftPoint.X = DrawingLength - Length_X;
                    }

                    //
                    if (deltaTop < deltaBot)
                    {
                        newTopLeftPoint.Y  = 0;
                        newTopLeftPoint.Y -= SHUTTER_DEPTH;
                    }
                    else
                    {
                        newTopLeftPoint.Y = DrawingWidth;
                    }
                }
                else
                {
                    newTopLeftPoint.Y -= Length_Y / 2;
                    //
                    if (newTopLeftPoint.Y < 0)
                    {
                        newTopLeftPoint.Y = 0;
                    }
                    if (newTopLeftPoint.Y + Length_Y > DrawingWidth)
                    {
                        newTopLeftPoint.Y = DrawingWidth - Length_Y;
                    }

                    // snap it to the left or right border
                    if (deltaLeft < deltaRight)
                    {
                        newTopLeftPoint.X  = 0;
                        newTopLeftPoint.X -= SHUTTER_DEPTH;
                    }
                    else
                    {
                        newTopLeftPoint.X = DrawingLength;
                    }
                }

                m_TopLeft_GlobalPoint = newTopLeftPoint;
            }
            else if (BaseRectangleGeometry.GRIP_TOP_LEFT == gripIndex)
            {
                if (IsHorizontal)
                {
                    m_TopLeft_GlobalPoint = TopRight_GlobalPoint;
                    //
                    Length_X = m_TopLeft_GlobalPoint.X - globalPoint.X;
                    Length_X = Utils.GetWholeNumberByStep(Length_X, StepLength_X);
                    Length_X = Utils.CheckWholeNumber(Length_X, MinLength_X, MaxLength_X);
                    //
                    m_TopLeft_GlobalPoint.X -= Length_X;
                }
                else
                {
                    m_TopLeft_GlobalPoint = BottomLeft_GlobalPoint;
                    //
                    Length_Y = m_TopLeft_GlobalPoint.Y - globalPoint.Y;
                    Length_Y = Utils.GetWholeNumberByStep(Length_Y, StepLength_Y);
                    Length_Y = Utils.CheckWholeNumber(Length_Y, MinLength_Y, MaxLength_Y);

                    m_TopLeft_GlobalPoint.Y -= Length_Y;
                }
            }
            else if (BaseRectangleGeometry.GRIP_BOTTOM_RIGHT == gripIndex)
            {
                if (IsHorizontal)
                {
                    //
                    Length_X = globalPoint.X - m_TopLeft_GlobalPoint.X;
                    Length_X = Utils.GetWholeNumberByStep(Length_X, StepLength_X);
                    Length_X = Utils.CheckWholeNumber(Length_X, MinLength_X, MaxLength_X);
                }
                else
                {
                    //
                    Length_Y = globalPoint.Y - m_TopLeft_GlobalPoint.Y;
                    Length_Y = Utils.GetWholeNumberByStep(Length_Y, StepLength_Y);
                    Length_Y = Utils.CheckWholeNumber(Length_Y, MinLength_Y, MaxLength_Y);
                }
            }

            List <BaseRectangleGeometry> rectanglesToIgnore = new List <BaseRectangleGeometry>();

            rectanglesToIgnore.Add(this);
            // check
            List <BaseRectangleGeometry> overlappedRectangles;

            if (!m_Sheet.IsLayoutCorrect(this, rectanglesToIgnore, out overlappedRectangles))
            {
                // try to fix it
                Point  _newTopLeftPoint;
                double _newGlobalLength;
                double _newGlobalWidth;
                //
                // infinity loop protection
                int iMaxLoopCount = 100;
                int iLoopCount    = 0;
                //
                bool bIncorrectCalc = false;
                //
                while (this._CalculateNotOverlapPosition(overlappedRectangles, gripIndex, DrawingLength, DrawingWidth, true, out _newTopLeftPoint, out _newGlobalLength, out _newGlobalWidth))
                {
                    // check
                    if (IsHorizontal)
                    {
                        //
                        if (_newTopLeftPoint.Y > -Length_Y / 2 && _newTopLeftPoint.Y < DrawingWidth + Length_Y / 2)
                        {
                            bIncorrectCalc = true;
                            break;
                        }
                        //
                        if (_newTopLeftPoint.X < 0)
                        {
                            _newTopLeftPoint.X = 0;
                        }
                        if (_newTopLeftPoint.X + Length_X > DrawingLength)
                        {
                            _newTopLeftPoint.X = DrawingLength - Length_X;
                        }
                    }
                    else
                    {
                        if (_newTopLeftPoint.X > -Length_X / 2 && _newTopLeftPoint.X < DrawingLength + Length_X / 2)
                        {
                            bIncorrectCalc = true;
                            break;
                        }
                        //
                        if (_newTopLeftPoint.Y < 0)
                        {
                            _newTopLeftPoint.Y = 0;
                        }
                        if (_newTopLeftPoint.Y + Length_Y > DrawingWidth)
                        {
                            _newTopLeftPoint.Y = DrawingWidth - Length_Y;
                        }
                    }

                    m_TopLeft_GlobalPoint = _newTopLeftPoint;
                    m_Length_X            = _newGlobalLength;
                    m_Length_Y            = _newGlobalWidth;

                    //
                    if (IsCorrect(eAppliedChanges.eMoveCenterGripPoint, out overlappedRectangles))
                    {
                        break;
                    }

                    ++iLoopCount;
                    if (iLoopCount >= iMaxLoopCount)
                    {
                        break;
                    }
                }

                if (bIncorrectCalc || !IsCorrect(eAppliedChanges.eMoveCenterGripPoint, out overlappedRectangles))
                {
                    this._SetState(oldState);
                    _UpdateProperties();

                    this.UpdateProperties();

                    return(false);
                }
            }

            _MarkStateChanged();
            _UpdateProperties();

            this.UpdateProperties();

            return(true);
        }
Exemplo n.º 15
0
        //=============================================================================
        public override bool SetPropertyValue(string strPropSysName, object propValue, bool bWasChangedViaProperties, bool bChangeTheSameRectangles, bool bNotifySheet, out string strError, bool bCheckLayout = true)
        {
            strError = string.Empty;

            if (m_Sheet == null)
            {
                return(false);
            }

            GeometryState oldState = this._GetClonedState();

            bool bRes = false;
            bool bPropertyWasTriedToSet = false;

            try
            {
                if (Column.PROP_COLUMN_PATTERN_DISTANCE_X == strPropSysName || Column.PROP_COLUMN_PATTERN_DISTANCE_Y == strPropSysName)
                {
                    bPropertyWasTriedToSet = true;

                    if (Column.PROP_COLUMN_PATTERN_DISTANCE_X == strPropSysName)
                    {
                        //
                        double rDistanceX = Convert.ToDouble(propValue);
                        bRes = ColumnPattern.ChangeOffsetX(this, rDistanceX, m_Sheet.Length, m_Sheet.Width, true);
                    }
                    else if (Column.PROP_COLUMN_PATTERN_DISTANCE_Y == strPropSysName)
                    {
                        //
                        double rDistanceY = Convert.ToDouble(propValue);
                        bRes = ColumnPattern.ChangeOffsetY(this, rDistanceY, m_Sheet.Length, m_Sheet.Width, true);
                    }
                }
                else if (PROP_DIMENSION_X == strPropSysName)
                {
                    bPropertyWasTriedToSet = true;

                    double rNewLength = Convert.ToDouble(propValue);
                    bRes = _Column_SetPropertyValue(PROP_DIMENSION_X, rNewLength, m_Sheet.Length, m_Sheet.Width, bWasChangedViaProperties, false, bCheckLayout);
                }
                else if (PROP_DIMENSION_Y == strPropSysName)
                {
                    bPropertyWasTriedToSet = true;

                    double rNewWidth = Convert.ToDouble(propValue);
                    bRes = _Column_SetPropertyValue(PROP_DIMENSION_Y, rNewWidth, m_Sheet.Length, m_Sheet.Width, bWasChangedViaProperties, false, bCheckLayout);
                }
                else if (PROP_TOP_LEFT_POINT_X == strPropSysName || PROP_TOP_LEFT_POINT_Y == strPropSysName)
                {
                    bPropertyWasTriedToSet = true;

                    double rNewValue = Convert.ToDouble(propValue);

                    Point newTopLeftPoint = this.TopLeft_GlobalPoint;
                    if (PROP_TOP_LEFT_POINT_X == strPropSysName)
                    {
                        newTopLeftPoint.X = rNewValue;
                    }
                    else if (PROP_TOP_LEFT_POINT_Y == strPropSysName)
                    {
                        newTopLeftPoint.Y = rNewValue;
                    }

                    bRes = _Column_SetPropertyValue(PROP_TOP_LEFT_POINT, newTopLeftPoint, m_Sheet.Length, m_Sheet.Width, bWasChangedViaProperties, true, bCheckLayout);
                }
            }
            catch { }

            if (!bPropertyWasTriedToSet)
            {
                bRes = base.SetPropertyValue(strPropSysName, propValue, bWasChangedViaProperties, bChangeTheSameRectangles, false, out strError, bCheckLayout);
            }

            if (bRes)
            {
                _MarkStateChanged();
            }

            if (m_Sheet != null && bNotifySheet)
            {
                m_Sheet.OnPropertyChanged(this, strPropSysName, bRes, strError);
            }

            if (!bRes)
            {
                this._SetState(oldState);
            }

            this.UpdateProperties();

            return(bRes);
        }