Example #1
0
        /// <summary>
        /// Override for left-click selection
        /// </summary>
        /// <param name="sender">Reference to sending object.</param>
        /// <param name="e">Mouse event arguments.</param>
        private void MouseLeftButtonUp( object sender , MouseEventArgs e )
        {
            if ( canvas != null )
            {
                if ( canvas.DrawMode == DrawModes.Select
                    || canvas.DrawMode == DrawModes.LineLoad )
                {
                    // start dialog for user input
                    SetFixityDialog dlg = new SetFixityDialog( canvas , this );
                    dlg.ShowDialog();

                    // if there is no load in horizontal or vertical direction, delete the load ...
                    if ( !this.IsFixedX && !this.IsFixedY )
                    {
                        this.Delete();

                        foreach ( MaterialBlock mb in canvas.MaterialBlocks )
                        {
                            mb.LineConstraints.RemoveAll( delegate( LineConstraint lc ) { return lc == this; } );
                        }
                    }

                    // ... otherwise update its visibility and plotting location
                    else
                    {
                        this.Update();
                    }

                    if ( dlg.DialogResult == true )
                    {
                        canvas.IsSaved = false;
                        canvas.IsVerified = false;
                    }
                }
            }
            else if ( defineCanvas != null )
            {
                ActivateFixityDialog dlg = new ActivateFixityDialog( defineCanvas , this );
                dlg.ShowDialog();

                this.Update();
            }
        }
Example #2
0
        public bool ApplyFixity( DrawingPoint p1 , DrawingPoint p2 )
        {
            bool added = false;

            // find point indices in list
            int index1 = BoundaryPoints.FindIndex( delegate( DrawingPoint p ) { return p == p1; } );
            int index2 = BoundaryPoints.FindIndex( delegate( DrawingPoint p ) { return p == p2; } );

            // if points were not successfully found
            if ( index1 == -1 || index2 == -1 )
            {
                MessageBox.Show( "Points not found on block." , "Fix X error" );
                return added;
            }

            // ensure max and min as appropriate
            if ( ((index1 > index2) && !(index2 == 0 && index1 == BoundaryPoints.Count - 1))
                || (index1 == 0 && index2 == BoundaryPoints.Count - 1) )
            {
                int tmp = index1;
                index1 = index2;
                index2 = tmp;

                DrawingPoint tmpPt = p1;
                p1 = p2;
                p2 = tmpPt;
            }

            // if points are the same, fix/unfix the point ...
            if ( index1 == index2 )
            {
                bool prevFixedX = p1.IsFixedX , prevFixedY = p1.IsFixedY;

                SetFixityDialog dlg = new SetFixityDialog( canvas , p1 );
                dlg.ShowDialog();

                if ( dlg.DialogResult == true )
                {
                    bool newFixedX = p1.IsFixedX;
                    if ( newFixedX != prevFixedX )
                    {
                        for ( int i = 0 ; i < p1.PhaseFixActiveX.Count ; i++ )
                        {
                            p1.PhaseFixActiveX[i] = newFixedX;
                        }
                    }

                    bool newFixedY = p1.IsFixedY;
                    if ( newFixedY != prevFixedY )
                    {
                        for ( int i = 0 ; i < p1.PhaseFixActiveY.Count ; i++ )
                        {
                            p1.PhaseFixActiveY[i] = newFixedY;
                        }
                    }

                    canvas.IsSaved = false;
                    canvas.IsVerified = false;
                }
                added = true;
            }

            // ... or if the points are adjacent, create a line constraint ...
            else if ( ((index2 - index1) == 1) || (index2 == 0 && index1 == BoundaryPoints.Count - 1) )
            {
                LineConstraint existingLC = LineConstraints.Find( delegate( LineConstraint lc ) { return lc.Nodes.Contains( p1 ) && lc.Nodes.Contains( p2 ); } );

                if ( existingLC != null )
                {
                    bool prevFixX = existingLC.IsFixedX;
                    bool prevFixY = existingLC.IsFixedY;

                    SetFixityDialog dlg = new SetFixityDialog( canvas , existingLC );
                    dlg.ShowDialog();

                    if ( dlg.DialogResult == true )
                    {
                        bool newFixX = existingLC.IsFixedX;
                        if ( newFixX != prevFixX )
                        {
                            for ( int i = 0 ; i < existingLC.PhaseFixedX.Count ; i++ )
                                existingLC.PhaseFixedX[i] = newFixX;

                            for ( int i = 0 ; i < existingLC.Nodes.Count ; i++ )
                            {
                                for ( int j = 0 ; j < existingLC.Nodes[i].PhaseFixActiveX.Count ; j++ )
                                    existingLC.Nodes[i].PhaseFixActiveX[j] =
                                        existingLC.Nodes[i].PhaseFixActiveX[j] || existingLC.PhaseFixedX[j];
                            }
                        }
                        bool newFixY = existingLC.IsFixedY;
                        if ( newFixY != prevFixY )
                        {
                            for ( int i = 0 ; i < existingLC.PhaseFixedY.Count ; i++ )
                                existingLC.PhaseFixedY[i] = newFixY;

                            for ( int i = 0 ; i < existingLC.Nodes.Count ; i++ )
                            {
                                for ( int j = 0 ; j < existingLC.Nodes.Count ; j++ )
                                    existingLC.Nodes[i].PhaseFixActiveY[j] =
                                        existingLC.Nodes[i].PhaseFixActiveY[j] || existingLC.PhaseFixedY[j];
                            }
                        }

                        canvas.IsSaved = false;
                        canvas.IsVerified = false;
                    }
                    added = true;
                }
                else
                {
                    LineConstraint newLC = new LineConstraint( canvas , p1 , p2 , false , false );
                    SetFixityDialog dlg = new SetFixityDialog( canvas , newLC );
                    dlg.ShowDialog();

                    if ( dlg.DialogResult == true )
                    {
                        bool newFixX = newLC.IsFixedX , newFixY = newLC.IsFixedY;
                        for ( int i = 0 ; i < newLC.PhaseFixedX.Count ; i++ )
                        {
                            newLC.PhaseFixedX[i] = newFixX;
                            newLC.PhaseFixedY[i] = newFixY;
                        }
                        for ( int i = 0 ; i < newLC.Nodes.Count ; i++ )
                        {
                            for ( int j = 0 ; j < newLC.Nodes[i].PhaseFixActiveX.Count ; j++ )
                            {
                                newLC.Nodes[i].PhaseFixActiveX[j] =
                                    newLC.Nodes[i].PhaseFixActiveX[j] || newLC.PhaseFixedX[j];

                                newLC.Nodes[i].PhaseFixActiveY[j] =
                                    newLC.Nodes[i].PhaseFixActiveY[j] || newLC.PhaseFixedY[j];
                            }
                        }

                        //canvas.MaterialBlocks.ForEach(
                        //    delegate( MaterialBlock mb )
                        //    {
                        //        if ( mb.BoundaryPoints.Contains( p1 ) && mb.BoundaryPoints.Contains( p2 ) )
                        //            mb.LineConstraints.Add( newLC );
                        //    } );

                        canvas.IsSaved = false;
                        canvas.IsVerified = false;
                    }

                    added = true;
                }
            }

            // ... otherwise, indicate that a constraint cannot be applied in this manner
            else
            {
                MessageBox.Show( "Points must be either the same or directly adjacent." , "Error" );
                return added;
            }

            // remove any line constraints that are both unfixed
            canvas.MaterialBlocks.ForEach(
                delegate( MaterialBlock mb )
                {
                    mb.LineConstraints.RemoveAll( delegate( LineConstraint lc ) { return (!lc.IsFixedX && !lc.IsFixedY); } );
                } );

            return added;
        }
Example #3
0
        /// <summary>
        /// Override for left-click selection
        /// </summary>
        /// <param name="sender">Reference to sending object.</param>
        /// <param name="e">Mouse event arguments.</param>
        private void fixLines_MouseLeftButtonUp( object sender , MouseEventArgs e )
        {
            if ( canvas != null )
            {
                if ( canvas.DrawMode == DrawModes.Select
                    || canvas.DrawMode == DrawModes.LineLoad )
                {
                    // start dialog for user input
                    SetFixityDialog dlg = new SetFixityDialog( canvas , this );
                    dlg.ShowDialog();

                    if ( dlg.DialogResult == true )
                    {
                        canvas.IsSaved = false;
                        canvas.IsVerified = false;
                    }
                }
            }
            else if ( defineCanvas != null )
            {
                ActivateFixityDialog dlg = new ActivateFixityDialog( defineCanvas , this );
                dlg.ShowDialog();
            }
        }