Inheritance: GlobalizedObject, AnalysisCaseAppliedLoad, INamed
        /// <summary>
        /// Executes the command. 
        /// Gets the Load Case properties from the User, adds it to the Model and sets it as Active.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            string name = Culture.Get("defaultLoadCase");
            LoadCase lCase = new LoadCase(name, LoadCase.LoadCaseType.Dead);
            lCase.Name = name;
            //            services.GetProperties(lCase.Name, lCase, false);

            EditLoadCaseDialog dlg = new EditLoadCaseDialog(lCase);
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!services.Model.LoadCases.ContainsKey(lCase.Name))
                    services.Model.LoadCases.Add(lCase.Name, lCase);
                services.Model.ActiveLoadCase = lCase;

                AnalysisCase aCase = new AnalysisCase(lCase.Name);
                StaticCaseProps props = aCase.Properties as StaticCaseProps;
                if (props != null)
                {
                    List<StaticCaseFactor> list = props.Loads;
                    list.Add(new StaticCaseFactor(lCase));
                    props.Loads = list;
                    services.Model.AbstractCases.Add(aCase);
                }
            }
            else
                services.Model.Undo.Rollback();
        }
        public EditLoadCaseDialog(LoadCase loadCase)
        {
            load = loadCase;
            InitializeComponent();

            foreach (LoadCase.LoadCaseType type in Enum.GetValues(typeof(LoadCase.LoadCaseType)))
                caseTypes.Add(Culture.Get(type.ToString()), type);

            foreach (string type in caseTypes.Keys)
                typeComboBox.Items.Add(type);
        }
示例#3
0
 /// <summary>
 /// Wrapper de Dictionary.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public ItemList <Load> this[LoadCase key]
 {
     get
     {
         if (loads != null && key != null && loads.ContainsKey(key))
         {
             return(loads[key]);
         }
         return(null);
     }
 }
示例#4
0
        /// <summary>
        /// Elimina un LoadCase,
        /// Si no está registrado, se ignora
        /// </summary>
        /// <param name="loadCase"></param>
        public void Remove(LoadCase loadCase)
        {
            if (loads == null || !loads.ContainsKey(loadCase))
            {
                return;
            }
            ItemList <Load> list = loads[loadCase];

            Model.Instance.Undo.Remove(loadCase, list, loads);
            loads.Remove(loadCase);
        }
示例#5
0
        /// <summary>
        /// Agrega una carga a un LoadCase específico
        /// </summary>
        /// <param name="load"></param>
        /// <param name="loadCase"></param>
        public void Add(Load load, LoadCase loadCase)
        {
            if (loads == null)
            {
                loads = new Dictionary <LoadCase, ItemList <Load> >();
            }

            ItemList <Load> list = this[loadCase];

            if (list == null)
            {
                list = new ItemList <Load>();
                Model.Instance.Undo.Add(loadCase, list, loads);
                loads.Add(loadCase, list);
            }
            Model.Instance.Undo.Add(load, list);
            list.Add(load);
        }
示例#6
0
        /// <summary>
        /// Quita una carga de un LoadCase específico
        /// Si la carga no está registrada, se lanza una InvalidIndexException
        /// </summary>
        /// <param name="load"></param>
        /// <param name="loadCase"></param>
        public void Remove(Load load, LoadCase loadCase)
        {
            if (loads == null || !loads.ContainsKey(loadCase))
            {
                throw new InvalidIndexException();
            }
            ItemList <Load> list = loads[loadCase];

            if (!list.Contains(load))
            {
                throw new InvalidIndexException();
            }
            Model.Instance.Undo.Remove(load, list);
            list.Remove(load);

            if (list.Count == 0)
            {
                Model.Instance.Undo.Remove(loadCase, list, loads);
                loads.Remove(loadCase);
            }
        }
示例#7
0
        private void readLoadCase(XmlNode node)
        {
            string name = readAttribute(node, "LoadCase", "").Trim();
            name = (name.Length > 0) ? name : Culture.Get("Case");
            string desType = readAttribute(node, "DesignType", "");
            // Exception. Has a blank.
            desType = ("REDUCIBLE LIVE".Equals(desType)) ? LoadCase.LoadCaseType.ReduceLive.ToString() : desType;

            float sw = float.Parse(readAttribute(node, "SelfWtMult", "0"));
            string al = readAttribute(node, "AutoLoad", "");
            LoadCase lCase = new LoadCase(name, (LoadCase.LoadCaseType)Enum.Parse(typeof(LoadCase.LoadCaseType), desType, true));
            lCase.AutoLoad = al;
            lCase.SelfWeight = sw;
            model.LoadCases[name] = lCase;
        }
示例#8
0
 private void writeLoadCase(XmlTextWriter xml, LoadCase obj)
 {
     if (string.IsNullOrEmpty(obj.AutoLoad)) {
         xml.WriteStartElement("LoadCase");
         xml.WriteAttributeString("LoadCase", obj.Name);
         xml.WriteAttributeString("DesignType", obj.CaseType.ToString().ToUpper());
         xml.WriteAttributeString("SelfWtMult", obj.SelfWeight.ToString());
         xml.WriteAttributeString("AutoLoad", " ");
         xml.WriteEndElement();
       } else {
         xml.WriteStartElement("LoadCase");
         xml.WriteAttributeString("LoadCase", obj.Name);
         xml.WriteAttributeString("DesignType", obj.CaseType.ToString().ToUpper());
         xml.WriteAttributeString("SelfWtMult", obj.SelfWeight.ToString());
         xml.WriteAttributeString("AutoLoad", obj.AutoLoad.ToString());
         xml.WriteEndElement();
       }
 }
示例#9
0
 private void writeNamedSets2(XmlTextWriter xml, LoadCase aCase)
 {
     xml.WriteStartElement("DBNamedSet");
     xml.WriteAttributeString("DBNamedSet", "RESULTS");
     xml.WriteAttributeString("SelectType", "LoadCase");
     xml.WriteAttributeString("Selection", aCase.Name);
     xml.WriteEndElement();
 }
示例#10
0
 private void writeLoadCase(XmlWriter xml, LoadCase obj)
 {
     string desType = (obj.CaseType == LoadCase.LoadCaseType.ReduceLive) ? "REDUCIBLE LIVE" : obj.CaseType.ToString().ToUpper();
     if (string.IsNullOrEmpty(obj.AutoLoad))
     {
         xml.WriteStartElement("LoadCase");
         xml.WriteAttributeString("LoadCase", obj.Name);
         xml.WriteAttributeString("DesignType", desType);
         xml.WriteAttributeString("SelfWtMult", obj.SelfWeight.ToString());
         xml.WriteAttributeString("AutoLoad", " ");
         xml.WriteEndElement();
     }
     else
     {
         xml.WriteStartElement("LoadCase");
         xml.WriteAttributeString("LoadCase", obj.Name);
         xml.WriteAttributeString("DesignType", desType);
         xml.WriteAttributeString("SelfWtMult", obj.SelfWeight.ToString());
         xml.WriteAttributeString("AutoLoad", obj.AutoLoad);
         xml.WriteEndElement();
     }
 }
示例#11
0
        private void store(OleDbConnection cn, LoadCase obj)
        {
            string sql;
            if (string.IsNullOrEmpty(obj.AutoLoad))
                sql = "INSERT INTO [Load Case Definitions] " +
                    "(LoadCase, DesignType, SelfWtMult) VALUES " +
                    "(\"" + obj.Name + "\", \"" + obj.CaseType.ToString().ToUpper() + "\"," + obj.SelfWeight + ");";
            else
                sql = "INSERT INTO [Load Case Definitions] " +
                    "(LoadCase, DesignType, SelfWtMult, AutoLoad) VALUES " +
                    "(\"" + obj.Name + "\", \"" + obj.CaseType.ToString().ToUpper() + "\"," + obj.SelfWeight + ",\"" + obj.AutoLoad + "\");";

            new OleDbCommand(sql, cn).ExecuteNonQuery();

            // Insert record in RESULTS Named Set
            sql = " INSERT INTO [Named Sets - Database Tables 2 - Selections] " +
                "(DBNamedSet, SelectType, [Selection]) VALUES (\"RESULTS\", \"LoadCase\", \"" + obj.Name + "\");";
            new OleDbCommand(sql, cn).ExecuteNonQuery();
        }
示例#12
0
        /// <summary>
        /// Destruye todo el modelo y lo deja limpio
        /// </summary>
        /// <TODO>Modified, Save, Load</TODO>
        public void Reset()
        {
            try
            {
                this.undoManager = new UndoManager(this);
                undoManager.Enabled = false;
                this.abstractCases = new ManagedList<Canguro.Model.Load.AbstractCase>();
                abstractCases.ElementRemoved += new ManagedList<AbstractCase>.ListChangedEventHandler(abstractCases_ElementRemoved);
                this.activeLoadCase = null;
                this.areaList = new ItemList<AreaElement>();
                this.constraintList = new ManagedList<Constraint>();
                this.isLocked = false;
                this.jointList = new ItemList<Joint>();
                this.layers = new ItemList<Layer>();
                layers.ElementRemoved += new ManagedList<Layer>.ListChangedEventHandler(layers_ElementRemoved);
                this.lineList = new ItemList<LineElement>();
                this.loadCases = new ManagedDictionary<string, LoadCase>();
                loadCases.ElementRemoved += new ManagedDictionary<string, LoadCase>.ListChangedEventHandler(loadCases_ElementRemoved);
                this.summary = new ModelSummary(this);

                this.designOptions = new List<DesignOptions>();
                designOptions.Add(NoDesign.Instance);
                designOptions.Add(new LRFD99());
                designOptions.Add(new ACI318_02());
                designOptions.Add(new ASD01());
                designOptions.Add(new RCDF2001());
                designOptions.Add(new UBC97_ASD());
                designOptions.Add(new UBC97_LRFD());
                designOptions.Add(new UBC97_Conc());
                steelDesignOptions = NoDesign.Instance;
                concreteDesignOptions = NoDesign.Instance;
                coldFormedDesignOptions = NoDesign.Instance;
                aluminumDesignOptions = NoDesign.Instance;

                this.results = new Canguro.Model.Results.Results(0);

                // Layer es un Item y todos los Items asignan su propiedad layer
                // de acuerdo a ActiveLayer, por lo que hay que asignarla en null
                // antes de crear el primer Layer, root de todos los demás
                activeLayer = null;
                Layer rootLayer = new Layer(Culture.Get("defaultLayerName"));
                ActiveLayer = rootLayer;

                activeLoadCase = new LoadCase(Culture.Get("defaultLoadCase"), LoadCase.LoadCaseType.Dead);
                activeLoadCase.SelfWeight = 1.0f;
                loadCases.Add(activeLoadCase.Name, activeLoadCase);

                AnalysisCase anc = new Canguro.Model.Load.AnalysisCase(Culture.Get("defaultLoadCase"));
                AbstractCases.Add(anc);
                if (anc != null)
                {
                    StaticCaseProps props = anc.Properties as StaticCaseProps;
                    if (props != null)
                    {
                        List<StaticCaseFactor> list = props.Loads;
                        list.Add(new StaticCaseFactor(ActiveLoadCase));
                        props.Loads = list;
                    }
                }

                MaterialManager.Instance.Initialize();
                SectionManager.Instance.Initialize(ref sections);
                sections.ElementRemoved += new Catalog<Canguro.Model.Section.Section>.ListChangedEventHandler(sections_ElementRemoved);
                this.currentPath = "";
                foreach (Canguro.Model.UnitSystem.UnitSystem us in UnitSystemsManager.Instance.UnitSystems)
                    if (Properties.Settings.Default.UnitSystem.Equals(us.GetType().Name))
                        UnitSystemsManager.Instance.CurrentSystem = us;

                viewManager = Canguro.View.GraphicViewManager.Instance;
                modified = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw e;
            }
            finally
            {
                if (ModelReset != null)
                    ModelReset(this, EventArgs.Empty);
                undoManager.Enabled = true;
            }
        }
示例#13
0
 protected List<AbstractCaseFactor> GetLoads(LoadCase.LoadCaseType type, float factor)
 {
     List<AbstractCaseFactor> list = new List<Canguro.Model.Load.AbstractCaseFactor>();
     foreach(AbstractCase ac in Model.Instance.AbstractCases)
     {
          if (ac is AnalysisCase && ((AnalysisCase)ac).Properties is StaticCaseProps)
          {
              StaticCaseProps props = (StaticCaseProps)((AnalysisCase)ac).Properties;
              if (!(props is PDeltaCaseProps))
              {
                  bool use = false;
                  foreach (StaticCaseFactor fact in props.Loads)
                  {
                      if (fact.AppliedLoad is LoadCase && ((LoadCase)fact.AppliedLoad).CaseType == type)
                      {
                          use = true;
                      }
                      else
                      {
                          use = false;
                          break;
                      }
                  }
                  if (use)
                      list.Add(new AbstractCaseFactor(ac, factor));
              }
          }
          else if (type == LoadCase.LoadCaseType.Quake && ac is AnalysisCase && ((AnalysisCase)ac).Properties is ResponseSpectrumCaseProps)
              list.Add(new AbstractCaseFactor(ac, factor));
     }
     return list;
 }
示例#14
0
        protected void AddCombination(string name, LoadCase.LoadCaseType[] types, float[] factors)
        {
            foreach (AbstractCase ac in Model.Instance.AbstractCases)
                if (ac.Name.Equals(name))
                {
                    if (ac is LoadCombination)
                        designCombinations.Add((LoadCombination)ac);
                    return;
                }

            LoadCombination combo = new LoadCombination(name);
            for (int i = 0; i < types.Length; i++)
            {
                float factor = 1;
                if (factors.Length > i)
                    factor = factors[i];
                List<AbstractCaseFactor> loads = GetLoads(types[i], factors[i]);
                if (loads.Count > 0)
                    combo.Cases.AddRange(loads);
                else
                    return;
            }
            if (combo.Cases.Count > 0) designCombinations.Add(combo);
        }
示例#15
0
        /// <summary>
        /// Distributes a DistributedSpanLoad between the line element where it is and a new adjacent line element.
        /// </summary>
        /// <param name="newLineLoads">The AssignedLoads object of the new Line Element</param>
        /// <param name="lc">The Load Case to which the load belongs.</param>
        /// <param name="x">The dividing point of the two line elements [0, 1]</param>
        /// <param name="load">The Load to distribute in two elements</param>
        /// <returns>true if the load was moved to the new Line Element (so the caller removes it). false otherwise.</returns>
        private static bool RelocateDistributedLoads(AssignedLoads newLineLoads, LoadCase lc, float x, DistributedSpanLoad load)
        {
            if (load.Da < x && load.Db < x)
            {
                load.Da = load.Da / x;
                load.Db = load.Db / x;
                return false;
            }
            if (load.Da >= x && load.Db >= x)
            {
                load = (DistributedSpanLoad)load.Clone();
                load.Id = 0;
                load.Da = (load.Da - x) / (1 - x);
                load.Db = (load.Db - x) / (1 - x);
                newLineLoads.Add(load, lc);
                return true;
            }
            if (load.Da > load.Db)
            {
                float tmp = load.Db;
                load.Db = load.Da;
                load.Da = tmp;
                tmp = load.Lb;
                load.Lb = load.La;
                load.La = tmp;
            }
            DistributedSpanLoad nLoad = (DistributedSpanLoad)load.Clone();
            nLoad.Id = 0;
            load.Da = load.Da / x;
            load.Db = 1f;
            load.Lb = (load.La) + (x - load.Da) * (load.Lb - load.La) / (load.Db - load.Da);

            nLoad.Da = 0;
            nLoad.Db = (nLoad.Db - x) / (1 - x);
            nLoad.La = load.Lb;
            newLineLoads.Add(nLoad, lc);
            return false;
        }
示例#16
0
 /// <summary>
 /// Relocates a ConcentratedSpanLoad between the line element where it is and a new adjacent line element.
 /// </summary>
 /// <param name="newLineLoads">The AssignedLoads object of the new Line Element</param>
 /// <param name="lc">The Load Case to which the load belongs.</param>
 /// <param name="x">The dividing point of the two line elements [0, 1]</param>
 /// <param name="load">The Load to distribute in two elements</param>
 /// <returns>true if the load was moved to the new Line Element (so the caller removes it). false otherwise.</returns>
 private static bool RelocateConcentratedLoads(AssignedLoads newLineLoads, LoadCase lc, float x, ConcentratedSpanLoad load)
 {
     if (x > load.D)
     {
         load.D = load.D / x;
         return false;
     }
     else
     {
         load = (ConcentratedSpanLoad)load.Clone();
         load.Id = 0;
         load.D = (load.D - x) / (1f - x);
         newLineLoads.Add(load, lc);
         return true;
     }
 }