- Timestamp:
- 02/17/10 11:17:15 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3
- Files:
-
- 8 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/HeuristicLab.Operators.Views.GraphVisualization-3.3.csproj
r2803 r2819 95 95 <None Include="HeuristicLabOperatorsViewsGraphVisualizationPlugin.cs.frame" /> 96 96 <None Include="Properties\AssemblyInfo.frame" /> 97 <Compile Include="ToolBarItems\SelectToolBarItem.cs" /> 98 <Compile Include="ToolBarItems\PanToolBarItem.cs" /> 99 <Compile Include="ToolBarItems\ZoomOutToolBarItem.cs" /> 100 <Compile Include="ToolBarItems\ZoomInToolBarItem.cs" /> 101 <Compile Include="ToolBarItems\ZoomToolBarItem.cs" /> 102 <Compile Include="ToolBarItems\OperatorGraphVisualizationToolBarItemSeparator.cs" /> 103 <Compile Include="ToolBarItems\RelayoutToolBarItem.cs" /> 97 104 </ItemGroup> 98 105 <ItemGroup> … … 100 107 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 101 108 <Name>HeuristicLab.Collections-3.3</Name> 109 </ProjectReference> 110 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.2\HeuristicLab.Common.Resources-3.2.csproj"> 111 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project> 112 <Name>HeuristicLab.Common.Resources-3.2</Name> 102 113 </ProjectReference> 103 114 <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj"> … … 129 140 <Name>HeuristicLab.Operators-3.3</Name> 130 141 </ProjectReference> 142 <ProjectReference Include="..\..\HeuristicLab.Optimizer\3.3\HeuristicLab.Optimizer-3.3.csproj"> 143 <Project>{C664305E-497C-4533-A140-967DEDB05C19}</Project> 144 <Name>HeuristicLab.Optimizer-3.3</Name> 145 </ProjectReference> 146 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 147 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> 148 <Name>HeuristicLab.Parameters-3.3</Name> 149 </ProjectReference> 131 150 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 132 151 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualizationView.Designer.cs
r2801 r2819 35 35 this.graphVisualization.BackColor = System.Drawing.Color.DarkGray; 36 36 this.graphVisualization.BackgroundType = global::Netron.Diagramming.Core.CanvasBackgroundTypes.FlatColor; 37 this.graphVisualization.Dock = System.Windows.Forms.DockStyle.Fill; 38 this.graphVisualization.Document = ((global::Netron.Diagramming.Core.Document)(resources.GetObject("netronVisualization1.Document"))); 37 this.graphVisualization.Dock = System.Windows.Forms.DockStyle.Fill; 39 38 this.graphVisualization.EnableAddConnection = true; 40 39 this.graphVisualization.FileName = ""; … … 43 42 this.graphVisualization.Name = "graphVisualization"; 44 43 this.graphVisualization.Origin = new System.Drawing.Point(0, 0); 45 this.graphVisualization.PageSettings = ((System.Drawing.Printing.PageSettings)(resources.GetObject("netronVisualization1.PageSettings")));46 44 this.graphVisualization.ShowConnectors = true; 47 45 this.graphVisualization.ShowRulers = false; -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualizationView.cs
r2801 r2819 32 32 using HeuristicLab.Core.Views; 33 33 using Netron.Diagramming.Core; 34 using HeuristicLab.Parameters; 34 35 35 36 namespace HeuristicLab.Operators.Views.GraphVisualization { … … 37 38 public partial class OperatorGraphVisualizationView : ItemView { 38 39 private Dictionary<IOperator, IShape> operatorShapeMapping; 39 private Dictionary<KeyValuePair<IOperator, IOperator>, IConnection> connectionMapping; 40 private Dictionary<KeyValuePair<IOperator, IValueParameter<IOperator>>, IConnection> connectionMapping; 41 private HashSet<IValueParameter<IOperator>> parameters; 40 42 /// <summary> 41 43 /// Initializes a new instance of <see cref="OperatorGraphVisualizationView"/> with caption "Operator Graph". … … 45 47 Caption = "Operator Graph"; 46 48 this.operatorShapeMapping = new Dictionary<IOperator, IShape>(); 47 this.connectionMapping = new Dictionary<KeyValuePair<IOperator, IOperator>, IConnection>(); 49 this.connectionMapping = new Dictionary<KeyValuePair<IOperator, IValueParameter<IOperator>>, IConnection>(); 50 this.parameters = new HashSet<IValueParameter<IOperator>>(); 51 52 this.graphVisualization.Controller.Model.OnEntityRemoved += new EventHandler<EntityEventArgs>(Model_OnEntityRemoved); 48 53 } 49 54 … … 59 64 } 60 65 61 62 66 /// <summary> 63 67 /// Gets or sets the operator graph to represent visually. … … 74 78 } 75 79 80 76 81 protected override void OnContentChanged() { 77 82 base.OnContentChanged(); 78 this.GraphModel.Shapes.Clear(); 79 this.operatorShapeMapping.Clear(); 80 this.connectionMapping.Clear(); 81 82 this.CreateGraph(null, this.Content); 83 this.ClearGraph(); 84 85 this.CreateGraph(null, new OperatorParameter(string.Empty, this.Content)); 83 86 foreach (IShape shape in this.operatorShapeMapping.Values) 84 87 this.GraphModel.AddShape(shape); … … 87 90 this.GraphModel.AddConnection(connection); 88 91 89 this.graphVisualization.Controller.View.Invalidate(); 90 this.graphVisualization.Controller.Model.LayoutRoot = this.operatorShapeMapping[this.Content]; 91 this.graphVisualization.Controller.RunActivity("Standard TreeLayout"); 92 if (this.Content == null) 93 this.graphVisualization.Controller.Model.LayoutRoot = null; 94 else 95 this.graphVisualization.Controller.Model.LayoutRoot = this.operatorShapeMapping[this.Content]; 96 this.RelayoutOperatorGraph(); 92 97 } 93 98 … … 96 101 Invoke(new EventHandler(opParam_ValueChanged), sender, e); 97 102 else { 98 //IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender; 99 //foreach (TreeNode node in opParamNodeTable[opParam].ToArray()) 100 // //remove nodes 101 //foreach (TreeNode node in opParamNodeTable[opParam]) { 102 // //add nodes 103 //} 104 } 105 } 106 107 private void CreateGraph(IOperator parent, IOperator op) { 108 if (op == null) 103 this.OnContentChanged(); 104 } 105 } 106 107 private void ClearGraph() { 108 this.GraphModel.Clear(); 109 foreach (IValueParameter<IOperator> opParam in this.parameters) 110 opParam.ValueChanged -= opParam_ValueChanged; 111 112 this.operatorShapeMapping.Clear(); 113 this.parameters.Clear(); 114 this.connectionMapping.Clear(); 115 } 116 117 118 119 private void CreateGraph(IOperator parent, IValueParameter<IOperator> op) { 120 if (op == null || op.Value == null) 109 121 return; 110 122 111 123 IShape shape; 112 if (!this.operatorShapeMapping.ContainsKey(op )) {113 shape = CreateOperatorShape(op );114 this.operatorShapeMapping[op ] = shape;115 116 foreach (IParameter param in op. Parameters) {124 if (!this.operatorShapeMapping.ContainsKey(op.Value)) { 125 shape = CreateOperatorShape(op.Value); 126 this.operatorShapeMapping[op.Value] = shape; 127 128 foreach (IParameter param in op.Value.Parameters) { 117 129 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 118 130 if (opParam != null) { 119 opParam.ValueChanged += new EventHandler(opParam_ValueChanged);120 this.CreateGraph(op , opParam.Value);131 HandleOperatorParameter(opParam); 132 this.CreateGraph(op.Value, opParam); 121 133 } 122 134 } … … 127 139 } 128 140 129 private void RemoveGraph(IOperator op) {130 if (op== null)141 private void HandleOperatorParameter(IValueParameter<IOperator> opParam) { 142 if (opParam == null) 131 143 return; 132 IShape shape = this.operatorShapeMapping[op];133 this.GraphModel.RemoveShape(shape);134 } 135 136 private IConnection ConnectShapes(IOperator parent, I Operator op) {137 IShape operatorShape = this.operatorShapeMapping[op ];144 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 145 parameters.Add(opParam); 146 } 147 148 private IConnection ConnectShapes(IOperator parent, IValueParameter<IOperator> opParam) { 149 IShape operatorShape = this.operatorShapeMapping[opParam.Value]; 138 150 IShape parentShape = this.operatorShapeMapping[parent]; 139 151 IConnector operatorConnector = parentShape.Connectors.Where(c => c.Name == "Bottom connector").First(); … … 144 156 operatorConnector.AttachConnector(connection.To); 145 157 146 this.connectionMapping[new KeyValuePair<IOperator, I Operator>(parent, op)] = connection;158 this.connectionMapping[new KeyValuePair<IOperator, IValueParameter<IOperator>>(parent, opParam)] = connection; 147 159 return connection; 148 160 } … … 157 169 return shape; 158 170 } 171 172 private void Model_OnEntityRemoved(object sender, EntityEventArgs e) { 173 IShape shape = e.Entity as IShape; 174 if (shape != null) { 175 IOperator op = operatorShapeMapping.Where(os => os.Value == shape).First().Key; 176 if (op == this.Content) 177 this.Content = null; 178 else { 179 //clear all connections to the removed operator 180 IEnumerable<IValueParameter<IOperator>> parentOperator = this.connectionMapping.Where(cs => cs.Key.Value.Value == op).Select(x => x.Key.Value); 181 foreach(IValueParameter<IOperator> opParam in parentOperator.ToArray()) 182 opParam.Value = null; 183 184 //remove connections from graph view 185 IEnumerable<IConnection> connections = this.connectionMapping.Where(cs => cs.Key.Value.Value == op).Select(x => x.Value); 186 foreach (IConnection connection in connections) 187 this.GraphModel.Remove(connection); 188 189 this.graphVisualization.Invalidate(); 190 } 191 192 193 } 194 } 195 196 #region methods for toolbar items 197 198 internal void RelayoutOperatorGraph() { 199 if (this.operatorShapeMapping.Count > 0 && this.connectionMapping.Count > 0) { //otherwise the layout does not work 200 this.graphVisualization.Invalidate(); 201 this.graphVisualization.Controller.RunActivity("Standard TreeLayout"); 202 } 203 } 204 205 internal void ActivateZoomAreaTool() { 206 this.graphVisualization.Controller.ActivateTool(ControllerBase.ZoomAreaToolName); 207 } 208 209 internal void ActivateZoomInTool() { 210 this.graphVisualization.Controller.ActivateTool(ControllerBase.ZoomInToolName); 211 } 212 213 internal void ActivateZoomOutTool() { 214 this.graphVisualization.Controller.ActivateTool(ControllerBase.ZoomOutToolName); 215 } 216 217 internal void ActivatePanTool() { 218 this.graphVisualization.Controller.ActivateTool(ControllerBase.PanToolName); 219 } 220 221 internal void ActivateSelectTool() { 222 this.graphVisualization.Controller.ActivateTool(ControllerBase.SelectionToolName); 223 } 224 225 #endregion 159 226 } 160 227 }
Note: See TracChangeset
for help on using the changeset viewer.