public AnalysisOptionsDialog(Canguro.Controller.CommandServices services) { this.services = services; InitializeComponent(); Init(); UpdateDialog(); }
/// <summary> /// Executes the command. /// Opens the properties window to edit the Active Load Case. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Canguro.Model.Load.LoadCase lCase = services.Model.ActiveLoadCase; string name = lCase.Name; //services.GetProperties(name, lCase, false); EditLoadCaseDialog dlg = new EditLoadCaseDialog(lCase); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!name.Equals(lCase.Name)) { foreach (Canguro.Model.Load.AbstractCase aCase in services.Model.AbstractCases) { if (name.Equals(aCase.Name) && aCase is Canguro.Model.Load.AnalysisCase) { aCase.Name = lCase.Name; } } } services.Model.ChangeModel(); } else { services.Model.Undo.Rollback(); } }
/// <summary> /// Executes the command. /// Deletes the selected Items. /// If none is selected, it requests a selection. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Canguro.Model.Model model = services.Model; if (model.LoadCases.Count > 1) { Canguro.Model.Load.LoadCase oldCase = model.ActiveLoadCase; // Remove associated AnalysisCase // Find the corresponding AbstractCase Canguro.Model.Load.AnalysisCase aCase = null; foreach (Canguro.Model.Load.AbstractCase ac in services.Model.AbstractCases) { if (ac is Canguro.Model.Load.AnalysisCase && ac.Name.Equals(oldCase.Name)) { aCase = (Canguro.Model.Load.AnalysisCase)ac; break; } } bool deleteLCase = true; // Now remove the AnalysisCase if (aCase != null) { deleteLCase = services.Model.AbstractCases.Remove(aCase); } if (deleteLCase) { services.Model.LoadCases.Remove(oldCase.Name); services.Model.ChangeModel(); } } }
public override void Run(Canguro.Controller.CommandServices services) { services.StoreSelection(); LineElement line = services.GetLine(); List <LinkedList <LineElement> > graph = GetLineGraph(services.Model); ItemList <Joint> joints = services.Model.JointList; int numJoints = joints.Count; bool[] colors = new bool[numJoints]; Stack <LineElement> stack = new Stack <LineElement>(); stack.Push(line); while (stack.Count > 0) { line = stack.Pop(); line.IsSelected = true; if (!colors[line.I.Id]) { line.I.IsSelected = true; visit(graph, (int)line.I.Id, stack, line); colors[line.I.Id] = true; } if (!colors[line.J.Id]) { line.J.IsSelected = true; visit(graph, (int)line.J.Id, stack, line); colors[line.J.Id] = true; } } services.RestoreSelection(); services.Model.ChangeSelection(null); }
/// <summary> /// Executes the command. /// Creates, gets parameters and add a Distributed line load to the selected line elements. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { services.GetProperties(this); DistributedSpanLoad newLoad = new DistributedSpanLoad(); newLoad.Da = 0; newLoad.Db = 1; newLoad.Direction = direction; newLoad.La = load; newLoad.Lb = load; newLoad.Type = type; //services.GetProperties(Title, load, false); if (Canguro.Controller.Grid.LoadEditFrm.EditLoad(newLoad) == System.Windows.Forms.DialogResult.OK) { List <Item> selection = GetSelection(services); foreach (Item item in selection) { if (item is LineElement) { ((LineElement)item).Loads.Add((DistributedSpanLoad)newLoad.Clone()); } } } }
/// <summary> /// Executes the command. /// If the CurrentPath is not set, displays the Save File Dialog. /// Saves the Model in a file. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { string path = ""; string currentPath = services.Model.CurrentPath; if (currentPath.Length == 0) { System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.Filter = "Treu Structure Model (*.tsm)|*.tsm"; dlg.DefaultExt = "tsm"; dlg.AddExtension = true; dlg.Title = Culture.Get("SaveTitle"); dlg.FileName = Culture.Get("defaultModelName"); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = dlg.FileName; } } else { path = currentPath; } if (path.Length > 0) { services.Model.Save(path); } }
/// <summary> /// Executes the command. /// Adds a new Layer with the given Name 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) { services.StoreSelection(); string name = services.GetString(Culture.Get("setLayerName")); string aux = name; bool valid = false; int i = 1; while (!valid) { valid = true; foreach (Layer l in services.Model.Layers) { if (l != null && l.Name.Equals(aux)) { valid = false; } } if (!valid) { aux = name + "(" + i++ + ")"; } } Layer layer = new Layer(aux); services.Model.Layers.Add(layer); services.Model.ActiveLayer = layer; services.RestoreSelection(); }
/// <summary> /// Executes the command. /// Sets the IsSelected property of all the Items to false. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { foreach (Joint j in services.Model.JointList) { if (j != null && !j.IsSelected) { j.IsVisible = j.IsSelected = false; } } foreach (LineElement l in services.Model.LineList) { if (l != null && !l.IsSelected) { l.IsVisible = l.IsSelected = false; } } if (services.Model.HasResults) { services.Model.Results.StressHelper.IsDirty = true; } services.Model.ChangeModel(); }
public void Start(Canguro.Controller.CommandServices services) { if (services == null) { this.services = null; Reset(); return; } Canguro.Model.Model m = Canguro.Model.Model.Instance; // If it's a new command asking for its first selection, throw current (past) selection away if (this.services != services) { m.UnSelectAll(); } this.services = services; Reset(); // Start selection command Canguro.Controller.Controller.Instance.Execute("select"); // If starting a Get Point Selection, start Snap if (services.SelectionFilter == Canguro.Controller.WaitingFor.Point) { Controller.Controller.Instance.TrackingController.SnapController.IsActive = true; } }
/// <summary> /// Executes the command. /// Creates, gets parameters and add a Distributed line load to the selected line elements. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { if (Canguro.Controller.Grid.LoadEditFrm.EditLoad(this) == System.Windows.Forms.DialogResult.OK) { DistributedSpanLoad newLoad = new DistributedSpanLoad(); newLoad.Da = 0; newLoad.Db = 0.5f; newLoad.Direction = direction; newLoad.La = 0; newLoad.Lb = load; newLoad.Type = type; DistributedSpanLoad newLoad2 = new DistributedSpanLoad(); newLoad2.Da = 0.5f; newLoad2.Db = 1; newLoad2.Direction = direction; newLoad2.La = load; newLoad2.Lb = 0; newLoad2.Type = type; List <Item> selection = services.GetSelection(); foreach (Item item in selection) { if (item is LineElement) { ((LineElement)item).Loads.Add((DistributedSpanLoad)newLoad.Clone()); ((LineElement)item).Loads.Add((DistributedSpanLoad)newLoad2.Clone()); } } } }
/// <summary> /// Executes the command. /// Executes Join with all the Items and asks to renumber the JointList and LineList objects. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Join(services.Model, services.Model.JointList, services.Model.LineList, services.Model.AreaList); RepairJoints(services.Model); string msg = ""; bool conn; Canguro.Utility.AnalysisUtils.CanAnalyze(services.Model, ref msg, out conn); services.Model.ChangeModel(); msg = Culture.Get("confirmCompactIDs"); if (!conn) { msg = Culture.Get("structureIsDisconnectedWrn") + "\n\n" + msg; } if (System.Windows.Forms.MessageBox.Show(msg, Culture.Get("confirm"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { services.Model.JointList.Compact(); services.Model.LineList.Compact(); services.Model.AreaList.Compact(); } services.Model.ChangeModel(); }
/// <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(); } }
/// <summary> /// Executes the command. /// Redoes the last undone action by calling UndoManager.Redo() /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { if (services.Model.Undo.CanRedo) { services.Model.Undo.Redo(); } services.Model.ChangeModel(); }
/// <summary> /// Executes the command. /// Opens the LoadCombinationsDialog /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { if (services.ShowDialog(new Canguro.Commands.Forms.LoadCombinationsDialog(services.Model)) == System.Windows.Forms.DialogResult.Cancel) { services.Model.Undo.Rollback(); } }
/// <summary> /// Executes the command. /// Opens the Materials Dialog. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Canguro.Commands.Forms.MaterialsGUI gui = new Canguro.Commands.Forms.MaterialsGUI(); if (services.ShowDialog(gui) != DialogResult.OK) { throw new Canguro.Controller.CancelCommandException(); } }
public override void Run(Canguro.Controller.CommandServices services) { ConstraintsDialog dlg = new ConstraintsDialog(services.Model); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { services.Model.Undo.Rollback(); } }
/// <summary> /// Executes the command. /// Sets the IsSelected property of all the Items in the Active Layer to true. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Layer layer = services.Model.ActiveLayer; foreach (Item item in layer.Items) { item.IsSelected = true; } services.Model.ChangeSelection(null); }
/// <summary> /// Executes the command. /// Sets the Layer property of all the selected Items to point to the Active Layer /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Layer layer = services.Model.ActiveLayer; foreach (Item item in services.Model.JointList) if (item != null && item.IsSelected) item.Layer = layer; foreach (Item item in services.Model.LineList) if (item != null && item.IsSelected) item.Layer = layer; }
/// <summary> /// Executes the command. /// Execute CopyCmd and PasteCmd until cancelled. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { services.Run(new CopyCmd()); PasteCmd cmd; do { services.Run(cmd = new PasteCmd()); services.Model.ChangeModel(); }while (cmd.ObjectCount > 0); }
public override void Run(Canguro.Controller.CommandServices services) { foreach (LineElement l in services.Model.LineList) { if (l != null && l.I != null && l.J != null && (l.I.IsSelected || l.J.IsSelected)) { l.IsSelected = true; } } services.Model.ChangeSelection(null); }
/// <summary> /// Executes the command. /// Opens the Sections Dialog /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { SectionsGUI gui = new SectionsGUI(); if (services.ShowDialog(gui) == System.Windows.Forms.DialogResult.Cancel) { throw new Canguro.Controller.CancelCommandException(); } services.Model.ChangeModel(true); }
/// <summary> /// Executes the command. /// Gets the parameters and creates the analysis case. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { string name = Culture.Get("defaultAnalysisCaseName"); Canguro.Model.Model model = services.Model; StaticCaseProps props = new StaticCaseProps(); AnalysisCase aCase = new AnalysisCase(name, props); services.GetProperties(aCase.Name, aCase, false); model.AbstractCases.Add(aCase); }
/// <summary> /// Executes the command. /// Deletes all Items in a Layer /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { int count = 0; foreach (Layer layer in services.Model.Layers) { if (layer != null) { count++; } } services.Model.UnSelectAll(); if (services.Model.ActiveLayer.Items.Count > 0) { System.Windows.Forms.MessageBox.Show(Culture.Get("layerHasObjectsError"), Culture.Get("error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } else if (count <= 1) { System.Windows.Forms.MessageBox.Show(Culture.Get("lastLayerError"), Culture.Get("error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } else { Layer deletedLayer = services.Model.ActiveLayer; foreach (Layer active in services.Model.Layers) { if (active != null && active != deletedLayer) { services.Model.ActiveLayer = active; break; } } Layer activeLayer = services.Model.ActiveLayer; foreach (Item item in services.Model.LineList) { if (item != null && item.IsSelected) { item.Layer = activeLayer; } } foreach (Item item in services.Model.JointList) { if (item != null && item.IsSelected) { item.Layer = activeLayer; } } services.Model.Layers.Remove(deletedLayer); } }
//public override void Run(Canguro.Controller.CommandServices services) //{ // List<Item> selection = GetSelection(services); // if (selection.Count == 0) // return; // Stream stream = new MemoryStream(); // try // { // BinaryFormatter bformatter = new BinaryFormatter(); // Magnet magnet = services.GetPoint("selectPivot"); // bformatter.Serialize(stream, magnet.SnapPosition); // bformatter.Serialize(stream, selection.Count); // foreach (Item item in selection) // { // bformatter.Serialize(stream, item); // item.IsSelected = true; // } // Clipboard.SetData("Canguro", stream); // } // finally // { // stream.Close(); // } //} /// <summary> /// Executes the command. /// Gets the selection and a pivot point, and adds them to the Clipboard with the key "Canguro" /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Dictionary <uint, Joint> joints = new Dictionary <uint, Joint>(); List <LineElement> lines = new List <LineElement>(); List <AreaElement> areas = new List <AreaElement>(); bool haveSelection = false; haveSelection = services.GetSelection(joints, lines, areas); if (!haveSelection) { services.GetMany(Culture.Get("selectItems")); haveSelection = services.GetSelection(joints, lines, areas); } if (haveSelection) { Magnet magnet = services.GetPoint(Culture.Get("selectPivot")); if (magnet != null) { Microsoft.DirectX.Vector3 pivot = magnet.SnapPosition; Clipboard.Clear(); object[] objs = new object[] { joints, lines, areas, pivot }; //// Test Serialization //System.IO.MemoryStream s = new MemoryStream(); //new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter().Serialize(s, objs); Clipboard.SetData("Canguro", objs); } } foreach (Item item in joints.Values) { if (item != null) { item.IsSelected = true; } } foreach (Item item in lines) { if (item != null) { item.IsSelected = true; } } foreach (Item item in areas) { if (item != null) { item.IsSelected = true; } } }
/// <summary> /// Executes the command. /// Activates the layer containing the selected items /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Layer layer = null; bool oneLayer = false; foreach (Joint j in services.Model.JointList) { if (j != null && j.IsSelected) { if (layer == null) { layer = j.Layer; oneLayer = true; } else if (layer.Id != j.Layer.Id) { oneLayer = false; break; } } } if (oneLayer || layer == null) { foreach (LineElement l in services.Model.LineList) { if (l != null && l.IsSelected) { if (layer == null) { layer = l.Layer; oneLayer = true; } else if (layer.Id != l.Layer.Id) { oneLayer = false; break; } } } } if (oneLayer) { services.Model.ActiveLayer = layer; } else { Item item = services.GetItem(); services.Model.ActiveLayer = item.Layer; } services.Model.ChangeModel(); }
/// <summary> /// Executes the command. /// Runs a test. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { foreach (Type t in Assembly.GetEntryAssembly().GetTypes()) { if ("Canguro.View.Reports".Equals(t.Namespace)) { Console.WriteLine("{0}{1}", t.Namespace.Replace(".", ""), t.Name); //foreach (PropertyInfo prop in t.GetProperties()) //{ // Console.WriteLine("{0}\t{1}", prop.ToString().Replace(".", ""), prop.Name); //} } } }
public override void Run(Canguro.Controller.CommandServices services) { List <Item> selection = services.GetSelection(); foreach (Item item in selection) { if (item is LineElement) { LineElement l = (LineElement)item; Joint tmp = l.I; l.I = l.J; l.J = tmp; } } }
/// <summary> /// Executes the command. /// Opens the Reports Window. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Canguro.Commands.Forms.ReportOptionsDialog opt = new Canguro.Commands.Forms.ReportOptionsDialog(services.Model); if (opt.ShowDialog() == System.Windows.Forms.DialogResult.OK) { List <Canguro.View.Reports.ReportOptions> options = opt.GetSelectedOptions(); bool onlySelected = opt.OnlySelected; if (options.Count > 0) { Canguro.View.Reports.ReportsWindow wnd = new Canguro.View.Reports.ReportsWindow(services, options, onlySelected); //wnd.ShowDialog(); wnd.Show(); } } }
/// <summary> /// Executes the command. /// Flips the joints in all selected AreaElements /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Canguro.Model.AreaElement area; List <Canguro.Model.Item> selection = services.GetSelection(); foreach (Canguro.Model.Item item in selection) { if ((area = item as Canguro.Model.AreaElement) != null) { area.FlipJoints++; } } //// Para que se refleje el cambio services.Model.ChangeModel(); }
/// <summary> /// Executes the command. /// Sets the IsVisible property to true in all the Items in the Active Layer. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Layer layer = services.Model.ActiveLayer; foreach (Item item in layer.Items) { item.IsVisible = true; } if (services.Model.HasResults) { services.Model.Results.StressHelper.IsDirty = true; } services.Model.ChangeModel(); }
public void Start(Canguro.Controller.CommandServices services) { if (services == null) { this.services = null; Reset(); return; } Canguro.Model.Model m = Canguro.Model.Model.Instance; // If it's a new command asking for its first selection, throw current (past) selection away if (this.services != services) m.UnSelectAll(); this.services = services; Reset(); // Start selection command Canguro.Controller.Controller.Instance.Execute("select"); // If starting a Get Point Selection, start Snap if (services.SelectionFilter == Canguro.Controller.WaitingFor.Point) Controller.Controller.Instance.TrackingController.SnapController.IsActive = true; }