Ejemplo n.º 1
0
        public AddPointLoadDialog( SlopeCanvas canvas , PointLoad load )
        {
            InitializeComponent();

            this.canvas = canvas;
            this.load = load;

            // get units dependent scaling factor and strings
            double factor;
            string coordUnits , loadUnits;
            switch ( canvas.Units )
            {
                case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN"; break;
                case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN"; break;
                case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf"; break;
                default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf"; break;
            }

            // set units labels
            nodeUnits.Content = coordUnits;
            xLoadUnits.Content = loadUnits;
            yLoadUnits.Content = loadUnits;

            // set node coordinates
            double xCoord , yCoord;
            xCoord = (load.Node.Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale;
            yCoord = (canvas.ActualHeight - load.Node.Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale;
            coords.Content = string.Format( "({0}, {1})" , Math.Round( xCoord , 2 ) , Math.Round( yCoord , 2 ) );

            // set existing load values (if present)
            isLoadedX.IsChecked = xLoad.IsEnabled = load.IsLoadedX;
            xLoad.Text = string.Format( "{0}" , Math.Round( load.XLoad , 2 ) );
            isLoadedY.IsChecked = yLoad.IsEnabled = load.IsLoadedY;
            yLoad.Text = string.Format( "{0}" , Math.Round( load.YLoad , 2 ) );
        }
        public FactorPointLoadDialog( SlopeDefineCanvas canvas , PointLoad load )
        {
            InitializeComponent();

            this.canvas = canvas;
            this.load = load;

            // get units dependent scaling factor and strings
            double factor;
            string coordUnits , loadUnits;
            switch ( canvas.Units )
            {
                case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN"; break;
                case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN"; break;
                case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf"; break;
                default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf"; break;
            }

            // set units labels
            nodeUnits.Content = coordUnits;
            xLoadUnits.Content = loadUnits;
            yLoadUnits.Content = loadUnits;

            // set node coordinates
            double xCoord , yCoord;
            xCoord = (load.Node.Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale;
            yCoord = (canvas.ActualHeight - load.Node.Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale;
            coords.Content = string.Format( "({0}, {1})" , Math.Round( xCoord , 2 ) , Math.Round( yCoord , 2 ) );

            // set existing load values (if present)
            MaterialBlock parent = canvas.Substructs.Find( delegate( MaterialBlock mb ) { return mb.Material.Name != "NULL" && mb.PointLoads.Contains( load ); } );
            isLoadedX.IsEnabled = parent != null && load.IsLoadedX;
            isLoadedX.IsChecked = xFactor.IsEnabled = parent != null && load.IsActiveX;
            xFactor.Text = string.Format( "{0}" , Math.Round( load.XFactor , 3 ) );
            xLoad.Text = string.Format( "{0}" , Math.Round( load.XLoad , 2 ) );
            isLoadedY.IsEnabled = parent != null && load.IsLoadedY;
            isLoadedY.IsChecked = yFactor.IsEnabled = parent != null && load.IsActiveY;
            yFactor.Text = string.Format( "{0}" , Math.Round( load.YFactor , 3 ) );
            yLoad.Text = string.Format( "{0}" , Math.Round( load.YLoad , 2 ) );
        }
Ejemplo n.º 3
0
        public void ApplyPointLoad( DrawingPoint p )
        {
            // check if a point load has already been defined at this point
            PointLoad load = pointLoads.Find( delegate( PointLoad pl ) { return pl.Node == p; } );

            // if undefined, create a new point load object
            if ( load == null )
            {
                load = new PointLoad( canvas , p , false , 0 , false , 0 );
                //pointLoads.Add( load );
            }

            bool prevLoadedX = load.IsLoadedX , prevLoadedY = load.IsLoadedY;

            // start dialog for user input
            AddPointLoadDialog dlg = new AddPointLoadDialog( canvas , load );
            dlg.ShowDialog();

            // if there is no load in horizontal or vertical direction, delete the load ...
            if ( !load.IsLoadedX && !load.IsLoadedY )
            {
                load.Delete();
                //pointLoads.Remove( load );
                canvas.MaterialBlocks.ForEach( delegate( MaterialBlock mb ) { mb.PointLoads.Remove( load ); } );
            }

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

            if ( dlg.DialogResult == true )
            {
                bool newLoadedX = load.IsLoadedX;
                if ( newLoadedX != prevLoadedX )
                {
                    for ( int i = 0 ; i < load.PhaseActiveX.Count ; i++ )
                    {
                        load.PhaseActiveX[i] = newLoadedX;
                        load.PhaseFactorX[i] = newLoadedX ? 1.0 : 0.0;
                    }
                }

                bool newLoadedY = load.IsLoadedY;
                if ( newLoadedY != prevLoadedY )
                {
                    for ( int i = 0 ; i < load.PhaseActiveY.Count ; i++ )
                    {
                        load.PhaseActiveY[i] = newLoadedY;
                        load.PhaseFactorY[i] = newLoadedY ? 1.0 : 0.0;
                    }
                }

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