示例#1
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;
            }
        }