- Timestamp:
- 02/23/10 10:58:11 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 12 added
- 9 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3.sln
r2852 r2853 490 490 {C664305E-497C-4533-A140-967DEDB05C19}.Debug|x64.ActiveCfg = Debug|x64 491 491 {C664305E-497C-4533-A140-967DEDB05C19}.Debug|x64.Build.0 = Debug|x64 492 {C664305E-497C-4533-A140-967DEDB05C19}.Debug|x86.ActiveCfg = Debug|x86 493 {C664305E-497C-4533-A140-967DEDB05C19}.Debug|x86.Build.0 = Debug|x86 492 {C664305E-497C-4533-A140-967DEDB05C19}.Debug|x86.ActiveCfg = Debug|x64 494 493 {C664305E-497C-4533-A140-967DEDB05C19}.Release|Any CPU.ActiveCfg = Release|Any CPU 495 494 {C664305E-497C-4533-A140-967DEDB05C19}.Release|Any CPU.Build.0 = Release|Any CPU … … 522 521 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Debug|x64.ActiveCfg = Debug|x64 523 522 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Debug|x64.Build.0 = Debug|x64 524 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Debug|x86.ActiveCfg = Debug|x86 525 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Debug|x86.Build.0 = Debug|x86 523 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Debug|x86.ActiveCfg = Debug|x64 526 524 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Release|Any CPU.ActiveCfg = Release|Any CPU 527 525 {958B43BC-CC5C-4FA2-8628-2B3B01D890B6}.Release|Any CPU.Build.0 = Release|Any CPU … … 600 598 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Debug|x64.ActiveCfg = Debug|x64 601 599 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Debug|x64.Build.0 = Debug|x64 602 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Debug|x86.ActiveCfg = Debug|x86 603 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Debug|x86.Build.0 = Debug|x86 600 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Debug|x86.ActiveCfg = Debug|x64 604 601 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Release|Any CPU.ActiveCfg = Release|Any CPU 605 602 {56F9106A-079F-4C61-92F6-86A84C2D84B7}.Release|Any CPU.Build.0 = Release|Any CPU … … 610 607 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Debug|x64.ActiveCfg = Debug|x64 611 608 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Debug|x64.Build.0 = Debug|x64 612 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Debug|x86.ActiveCfg = Debug|x86 613 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Debug|x86.Build.0 = Debug|x86 609 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Debug|x86.ActiveCfg = Debug|x64 614 610 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Release|Any CPU.ActiveCfg = Release|Any CPU 615 611 {AE5B1CE5-9862-4D6F-A700-D72CD9AEA295}.Release|Any CPU.Build.0 = Release|Any CPU -
trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs
r2796 r2853 67 67 } 68 68 69 [Storable] 70 private IDeepCloneable visualizationInfo; 71 /// <summary> 72 /// Gets or sets the visualizationInfo. 73 /// </summary> 74 /// /// <remarks>The VisualizationInfo can only be set once and fires afterwards and InvalidOperationException</remarks> 75 public IDeepCloneable VisualizationInfo { 76 get { return visualizationInfo; } 77 set { 78 if (visualizationInfo != null) 79 throw new InvalidOperationException("The value of the property VisualizationInfo is already set and cannot be set again."); 80 visualizationInfo = value; 81 } 82 } 83 69 84 /// <summary> 70 85 /// Initializes a new instance of <see cref="OperatorGraph"/>. … … 73 88 Operators = new OperatorSet(); 74 89 initialOperator = null; 90 visualizationInfo = null; 75 91 } 76 92 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/HeuristicLab.Operators.Views.GraphVisualization-3.3.csproj
r2819 r2853 83 83 <ItemGroup> 84 84 <Compile Include="HeuristicLabOperatorsViewsGraphVisualizationPlugin.cs" /> 85 <Compile Include="OperatorGraphVi sualizationView.cs">85 <Compile Include="OperatorGraphView.cs"> 86 86 <SubType>UserControl</SubType> 87 87 </Compile> 88 <Compile Include="OperatorGraphVi sualizationView.Designer.cs">89 <DependentUpon>OperatorGraphVi sualizationView.cs</DependentUpon>88 <Compile Include="OperatorGraphView.Designer.cs"> 89 <DependentUpon>OperatorGraphView.cs</DependentUpon> 90 90 </Compile> 91 91 <Compile Include="Properties\AssemblyInfo.cs" /> … … 95 95 <None Include="HeuristicLabOperatorsViewsGraphVisualizationPlugin.cs.frame" /> 96 96 <None Include="Properties\AssemblyInfo.frame" /> 97 <Compile Include="Model\ConnectionInfo.cs" /> 98 <Compile Include="Model\IConnectionInfo.cs" /> 99 <Compile Include="Model\OperatorShapeInfo.cs" /> 100 <Compile Include="Model\OperatorGraphVisualizationInfo.cs" /> 101 <Compile Include="BidirectionalLookup.cs" /> 102 <Compile Include="Model\IShapeInfo.cs" /> 103 <Compile Include="Model\OperatorShape.cs" /> 104 <Compile Include="Model\ShapeInfo.cs"> 105 <SubType>Code</SubType> 106 </Compile> 107 <Compile Include="Model\ShapeInfoFactory.cs" /> 97 108 <Compile Include="ToolBarItems\SelectToolBarItem.cs" /> 98 109 <Compile Include="ToolBarItems\PanToolBarItem.cs" /> … … 100 111 <Compile Include="ToolBarItems\ZoomInToolBarItem.cs" /> 101 112 <Compile Include="ToolBarItems\ZoomToolBarItem.cs" /> 102 <Compile Include="ToolBarItems\ OperatorGraphVisualizationToolBarItemSeparator.cs" />113 <Compile Include="ToolBarItems\ToolBarItemSeparator.cs" /> 103 114 <Compile Include="ToolBarItems\RelayoutToolBarItem.cs" /> 104 115 </ItemGroup> … … 153 164 </ProjectReference> 154 165 </ItemGroup> 166 <ItemGroup> 167 <EmbeddedResource Include="OperatorGraphView.resx"> 168 <DependentUpon>OperatorGraphView.cs</DependentUpon> 169 </EmbeddedResource> 170 </ItemGroup> 155 171 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 156 172 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.cs
r2825 r2853 33 33 using Netron.Diagramming.Core; 34 34 using HeuristicLab.Parameters; 35 using HeuristicLab.MainForm.WindowsForms; 35 36 36 37 namespace HeuristicLab.Operators.Views.GraphVisualization { 37 [Content(typeof(IOperator), false)] 38 public partial class OperatorGraphVisualizationView : ItemView { 39 private Dictionary<IOperator, IShape> operatorShapeMapping; 40 private Dictionary<KeyValuePair<IOperator, IValueParameter<IOperator>>, IConnection> connectionMapping; 41 private HashSet<IValueParameter<IOperator>> parameters; 42 /// <summary> 43 /// Initializes a new instance of <see cref="OperatorGraphVisualizationView"/> with caption "Operator Graph". 44 /// </summary> 45 public OperatorGraphVisualizationView() { 38 [Content(typeof(OperatorGraph), false)] 39 public partial class OperatorGraphView : ContentView { 40 private BidirectionalLookup<IShapeInfo, IShape> shapeMapping; 41 private BidirectionalLookup<IConnectionInfo, IConnection> connectionMapping; 42 43 private bool causedUpdateOfShapeInfo; 44 public OperatorGraphView() { 46 45 InitializeComponent(); 46 this.causedUpdateOfShapeInfo = false; 47 47 Caption = "Operator Graph"; 48 this.operatorShapeMapping = new Dictionary<IOperator, IShape>(); 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); 53 } 54 55 /// <summary> 56 /// Initializes a new instance of <see cref="OperatorGraphVisualizationView"/> 57 /// with the given <paramref name="operatorGraph"/>. 58 /// </summary> 59 /// <remarks>Calls <see cref="OperatorGraphView()"/>.</remarks> 60 /// <param name="operatorGraph">The operator graph to represent visually.</param> 61 public OperatorGraphVisualizationView(IOperator content) 48 this.shapeMapping = new BidirectionalLookup<IShapeInfo, IShape>(); 49 this.connectionMapping = new BidirectionalLookup<IConnectionInfo, IConnection>(); 50 } 51 52 public OperatorGraphView(OperatorGraph content) 62 53 : this() { 63 54 this.Content = content; 64 55 } 65 56 66 /// <summary> 67 /// Gets or sets the operator graph to represent visually. 68 /// </summary> 69 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>. 70 /// No own data storage present.</remarks> 71 public new IOperator Content { 72 get { return (IOperator)base.Content; } 57 public new OperatorGraph Content { 58 get { return (OperatorGraph)base.Content; } 73 59 set { base.Content = value; } 74 60 } 75 61 76 private IModel GraphModel {77 get { return this.graphVisualization.Controller.Model; }78 }79 80 81 62 protected override void OnContentChanged() { 82 base.OnContentChanged(); 83 this.ClearGraph(); 84 85 this.CreateGraph(null, new OperatorParameter(string.Empty, this.Content)); 86 foreach (IShape shape in this.operatorShapeMapping.Values) 87 this.GraphModel.AddShape(shape); 88 89 foreach (IConnection connection in this.connectionMapping.Values) 90 this.GraphModel.AddConnection(connection); 91 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(); 97 } 98 99 private void opParam_ValueChanged(object sender, EventArgs e) { 100 if (InvokeRequired) 101 Invoke(new EventHandler(opParam_ValueChanged), sender, e); 102 else { 103 this.OnContentChanged(); 63 if (this.VisualizationInfo == null) 64 this.VisualizationInfo = new OperatorGraphVisualizationInfo(this.Content); 65 this.UpdateVisualizationInfo(); 66 } 67 68 private OperatorGraphVisualizationInfo VisualizationInfo { 69 get { return Content.VisualizationInfo as OperatorGraphVisualizationInfo; } 70 set { this.Content.VisualizationInfo = value; } 71 } 72 73 private void UpdateVisualizationInfo() { 74 foreach (IShapeInfo shapeInfo in this.shapeMapping.FirstValues) 75 this.RemoveShapeInfo(shapeInfo); 76 this.shapeMapping.Clear(); 77 78 foreach (IShapeInfo shapeInfo in this.VisualizationInfo.ShapeInfos) 79 this.AddShapeInfo(shapeInfo); 80 } 81 82 protected override void RegisterContentEvents() { 83 base.RegisterContentEvents(); 84 this.VisualizationInfo.ObserveableShapeInfos.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsAdded); 85 this.VisualizationInfo.ObserveableShapeInfos.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved); 86 this.VisualizationInfo.ObserveableShapeInfos.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset); 87 } 88 89 protected override void DeregisterContentEvents() { 90 base.DeregisterContentEvents(); 91 this.VisualizationInfo.ObserveableShapeInfos.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsAdded); 92 this.VisualizationInfo.ObserveableShapeInfos.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved); 93 this.VisualizationInfo.ObserveableShapeInfos.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset); 94 } 95 96 97 private void ShapeInfos_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) { 98 foreach (IShapeInfo shapeInfo in e.OldItems) 99 this.RemoveShapeInfo(shapeInfo); 100 foreach (IShapeInfo shapeInfo in e.Items) 101 this.AddShapeInfo(shapeInfo); 102 this.graphVisualization.Invalidate(); 103 } 104 105 private void ShapeInfos_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) { 106 foreach (IShapeInfo shapeInfo in e.Items) 107 this.AddShapeInfo(shapeInfo); 108 this.graphVisualization.Invalidate(); 109 } 110 111 private void ShapeInfos_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) { 112 foreach (IShapeInfo shapeInfo in e.Items) 113 this.RemoveShapeInfo(shapeInfo); 114 this.graphVisualization.Invalidate(); 115 } 116 117 private void AddShapeInfo(IShapeInfo shapeInfo) { 118 IShape shape = shapeInfo.CreateShape(); 119 this.graphVisualization.Controller.Model.AddShape(shape); 120 this.shapeMapping.Add(shapeInfo, shape); 121 122 shape.OnEntityChange += new EventHandler<EntityEventArgs>(shape_OnEntityChange); 123 shapeInfo.Changed += new ChangedEventHandler(shapeInfo_Changed); 124 } 125 126 private void RemoveShapeInfo(IShapeInfo shapeInfo) { 127 IShape shape = this.shapeMapping.GetByFirst(shapeInfo); 128 shape.OnEntityChange -= new EventHandler<EntityEventArgs>(shape_OnEntityChange); 129 shapeInfo.Changed -= new ChangedEventHandler(shapeInfo_Changed); 130 131 this.shapeMapping.RemoveByFirst(shapeInfo); 132 if (this.graphVisualization.Controller.Model.Shapes.Contains(shape)) 133 this.graphVisualization.Controller.Model.RemoveShape(shape); 134 } 135 136 private void shapeInfo_Changed(object sender, ChangedEventArgs e) { 137 IShapeInfo shapeInfo = (IShapeInfo)sender; 138 this.UpdateShape(shapeInfo); 139 } 140 141 private void shape_OnEntityChange(object sender, EntityEventArgs e) { 142 this.causedUpdateOfShapeInfo = true; 143 IShape shape = e.Entity as IShape; 144 IShapeInfo shapeInfo = this.shapeMapping.GetBySecond(shape); 145 146 shapeInfo.Location = shape.Location; 147 this.graphVisualization.Invalidate(); 148 this.causedUpdateOfShapeInfo = false; 149 } 150 151 private void UpdateShape(IShapeInfo shapeInfo) { 152 if (!this.causedUpdateOfShapeInfo) { 153 IShape shape = this.shapeMapping.GetByFirst(shapeInfo); 154 shape.Location = shapeInfo.Location; 104 155 } 105 156 } 106 157 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) 121 return; 122 123 IShape shape; 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) { 129 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 130 if (opParam != null) { 131 HandleOperatorParameter(opParam); 132 this.CreateGraph(op.Value, opParam); 133 } 134 } 158 private void graphVisualization_OnEntityRemoved(object sender, EntityEventArgs e) { 159 IShape shape = (IShape)e.Entity; 160 if (this.shapeMapping.ContainsSecond(shape)) { 161 IShapeInfo shapeInfo = this.shapeMapping.GetBySecond(shape); 162 this.VisualizationInfo.RemoveShapeInfo(shapeInfo); 135 163 } 136 137 if (parent != null) 138 ConnectShapes(parent, op); 139 } 140 141 private void HandleOperatorParameter(IValueParameter<IOperator> opParam) { 142 if (opParam == null) 143 return; 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]; 150 IShape parentShape = this.operatorShapeMapping[parent]; 151 IConnector operatorConnector = parentShape.Connectors.Where(c => c.Name == "Bottom connector").First(); 152 IConnector parentConnector = operatorShape.Connectors.Where(c => c.Name == "Top connector").First(); 153 154 IConnection connection = new Connection(parentConnector.Point, operatorConnector.Point); 155 parentConnector.AttachConnector(connection.From); 156 operatorConnector.AttachConnector(connection.To); 157 158 this.connectionMapping[new KeyValuePair<IOperator, IValueParameter<IOperator>>(parent, opParam)] = connection; 159 return connection; 160 } 161 162 private IShape CreateOperatorShape(IOperator op) { 163 ClassShape shape = new ClassShape(); 164 shape.Name = op.Name; 165 shape.Text = op.Name; 166 shape.Title = op.Name; 167 shape.SubTitle = op.GetType().ToString(); 168 169 return shape; 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 } 164 } 165 166 167 168 169 //protected override void OnContentChanged() { 170 // base.OnContentChanged(); 171 // this.ClearGraph(); 172 173 // this.CreateGraph(null, new OperatorParameter(string.Empty, this.Content)); 174 // foreach (IShape shape in this.operatorShapeMapping.Values) 175 // this.GraphModel.AddShape(shape); 176 177 // foreach (IConnection connection in this.connectionMapping.Values) 178 // this.GraphModel.AddConnection(connection); 179 180 // if (this.Content == null) 181 // this.graphVisualization.Controller.Model.LayoutRoot = null; 182 // else 183 // this.graphVisualization.Controller.Model.LayoutRoot = this.operatorShapeMapping[this.Content]; 184 // this.RelayoutOperatorGraph(); 185 //} 186 187 //private void opParam_ValueChanged(object sender, EventArgs e) { 188 // if (InvokeRequired) 189 // Invoke(new EventHandler(opParam_ValueChanged), sender, e); 190 // else { 191 // this.OnContentChanged(); 192 // } 193 //} 194 195 //private void ClearGraph() { 196 // this.GraphModel.Clear(); 197 // foreach (IValueParameter<IOperator> opParam in this.parameters) 198 // opParam.ValueChanged -= opParam_ValueChanged; 199 200 // this.operatorShapeMapping.Clear(); 201 // this.parameters.Clear(); 202 // this.connectionMapping.Clear(); 203 //} 204 205 206 207 //private void CreateGraph(IOperator parent, IValueParameter<IOperator> op) { 208 // if (op == null || op.Value == null) 209 // return; 210 211 // IShape shape; 212 // if (!this.operatorShapeMapping.ContainsKey(op.Value)) { 213 // //shape = GraphVisualizationInfo.CreateShape(op.Value); 214 // //this.operatorShapeMapping[op.Value] = shape; 215 216 // foreach (IParameter param in op.Value.Parameters) { 217 // IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 218 // if (opParam != null) { 219 // HandleOperatorParameter(opParam); 220 // this.CreateGraph(op.Value, opParam); 221 // } 222 // } 223 // } 224 225 // if (parent != null) { 226 // IShape from = this.operatorShapeMapping[parent]; 227 // IShape to = this.operatorShapeMapping[op.Value]; 228 // //IConnection connection = GraphVisualizationInfo.CreateConnection(from,to); 229 // //this.connectionMapping[new KeyValuePair<IOperator, IValueParameter<IOperator>>(parent, op)] = connection; 230 // } 231 //} 232 233 //private void DeleteGraph(IOperator parent, IValueParameter<IOperator> op) { 234 235 //} 236 237 //private void HandleOperatorParameter(IValueParameter<IOperator> opParam) { 238 // if (opParam == null) 239 // return; 240 // opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 241 // parameters.Add(opParam); 242 //} 243 244 //private void Model_OnEntityRemoved(object sender, EntityEventArgs e) { 245 // IShape shape = e.Entity as IShape; 246 // if (shape != null) { 247 // IOperator op = operatorShapeMapping.Where(os => os.Value == shape).First().Key; 248 // if (op == this.Content) 249 // this.Content = null; 250 // else { 251 // //clear all connections to the removed operator 252 // IEnumerable<IValueParameter<IOperator>> parentOperator = this.connectionMapping.Where(cs => cs.Key.Value.Value == op).Select(x => x.Key.Value); 253 // foreach (IValueParameter<IOperator> opParam in parentOperator.ToArray()) 254 // opParam.Value = null; 255 256 // //remove connections from graph view 257 // IEnumerable<IConnection> connections = this.connectionMapping.Where(cs => cs.Key.Value.Value == op).Select(x => x.Value); 258 // foreach (IConnection connection in connections) 259 // this.GraphModel.Remove(connection); 260 261 // this.graphVisualization.Invalidate(); 262 // } 263 264 265 // } 266 //} 195 267 196 268 #region methods for toolbar items 197 269 198 270 internal void RelayoutOperatorGraph() { 199 if (this.operatorShapeMapping.Count > 0 && this.connectionMapping.Count > 0) { //otherwise the layout does not work200 this.graphVisualization.Invalidate();201 this.graphVisualization.Controller.RunActivity("Standard TreeLayout");202 }271 //if (this.operatorShapeMapping.Count > 0 && this.connectionMapping.Count > 0) { //otherwise the layout does not work 272 this.graphVisualization.Controller.RunActivity("Standard TreeLayout"); 273 this.graphVisualization.Invalidate(); 274 //} 203 275 } 204 276 … … 221 293 internal void ActivateSelectTool() { 222 294 this.graphVisualization.Controller.ActivateTool(ControllerBase.SelectionToolName); 295 } 296 297 #endregion 298 299 #region drag and drop 300 private void OperatorGraphView_DragEnter(object sender, DragEventArgs e) { 301 e.Effect = DragDropEffects.None; 302 Type type = e.Data.GetData("Type") as Type; 303 if ((type != null) && (typeof(IOperator).IsAssignableFrom(type))) { 304 e.Effect = DragDropEffects.Copy; 305 } 306 } 307 308 private void OperatorGraphView_DragDrop(object sender, DragEventArgs e) { 309 if (e.Effect != DragDropEffects.None) { 310 IOperator op = e.Data.GetData("Value") as IOperator; 311 IShapeInfo shapeInfo = ShapeInfoFactory.CreateShapeInfo(op); 312 Point controlCoordinates = this.PointToClient(new Point(e.X, e.Y)); 313 PointF viewCoordinates = this.graphVisualization.Controller.View.DeviceToView(controlCoordinates); 314 shapeInfo.Location = new Point((int)viewCoordinates.X, (int)viewCoordinates.Y); 315 this.VisualizationInfo.AddShapeInfo(op, shapeInfo); 316 } 223 317 } 224 318 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/PanToolBarItem.cs
r2819 r2853 42 42 protected override void OnActiveViewChanged(object sender, System.EventArgs e) { 43 43 base.OnActiveViewChanged(sender, e); 44 this.ToolStripItem. Visible = MainFormManager.MainForm.ActiveView is OperatorGraphVisualizationView;44 this.ToolStripItem.Enabled = MainFormManager.MainForm.ActiveView is OperatorGraphView; 45 45 } 46 46 47 47 public override void Execute() { 48 OperatorGraphVi sualizationView view = MainFormManager.MainForm.ActiveView as OperatorGraphVisualizationView;48 OperatorGraphView view = MainFormManager.MainForm.ActiveView as OperatorGraphView; 49 49 if (view != null) 50 50 view.ActivatePanTool(); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/RelayoutToolBarItem.cs
r2819 r2853 40 40 protected override void OnActiveViewChanged(object sender, System.EventArgs e) { 41 41 base.OnActiveViewChanged(sender, e); 42 this.ToolStripItem. Visible = MainFormManager.MainForm.ActiveView is OperatorGraphVisualizationView;42 this.ToolStripItem.Enabled = MainFormManager.MainForm.ActiveView is OperatorGraphView; 43 43 } 44 44 45 45 public override void Execute() { 46 OperatorGraphVi sualizationView view = MainFormManager.MainForm.ActiveView as OperatorGraphVisualizationView;46 OperatorGraphView view = MainFormManager.MainForm.ActiveView as OperatorGraphView; 47 47 if (view != null) 48 48 view.RelayoutOperatorGraph(); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/SelectToolBarItem.cs
r2819 r2853 42 42 protected override void OnActiveViewChanged(object sender, System.EventArgs e) { 43 43 base.OnActiveViewChanged(sender, e); 44 this.ToolStripItem. Visible = MainFormManager.MainForm.ActiveView is OperatorGraphVisualizationView;44 this.ToolStripItem.Enabled = MainFormManager.MainForm.ActiveView is OperatorGraphView; 45 45 } 46 46 47 47 public override void Execute() { 48 OperatorGraphVi sualizationView view = MainFormManager.MainForm.ActiveView as OperatorGraphVisualizationView;48 OperatorGraphView view = MainFormManager.MainForm.ActiveView as OperatorGraphView; 49 49 if (view != null) 50 50 view.ActivateSelectTool(); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/ToolBarItemSeparator.cs
r2825 r2853 21 21 22 22 namespace HeuristicLab.Operators.Views.GraphVisualization { 23 internal class OperatorGraphVisualizationToolBarItemSeparator : HeuristicLab.MainForm.ToolBarSeparatorItem, HeuristicLab.Optimizer.IOptimizerUserInterfaceItemProvider {23 internal class ToolBarItemSeparator : HeuristicLab.MainForm.ToolBarSeparatorItem, HeuristicLab.Optimizer.IOptimizerUserInterfaceItemProvider { 24 24 public override int Position { 25 25 get { return 100; } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/ZoomInToolBarItem.cs
r2819 r2853 42 42 protected override void OnActiveViewChanged(object sender, System.EventArgs e) { 43 43 base.OnActiveViewChanged(sender, e); 44 this.ToolStripItem. Visible = MainFormManager.MainForm.ActiveView is OperatorGraphVisualizationView;44 this.ToolStripItem.Enabled = MainFormManager.MainForm.ActiveView is OperatorGraphView; 45 45 } 46 46 47 47 public override void Execute() { 48 OperatorGraphVi sualizationView view = MainFormManager.MainForm.ActiveView as OperatorGraphVisualizationView;48 OperatorGraphView view = MainFormManager.MainForm.ActiveView as OperatorGraphView; 49 49 if (view != null) 50 50 view.ActivateZoomInTool(); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/ZoomOutToolBarItem.cs
r2819 r2853 42 42 protected override void OnActiveViewChanged(object sender, System.EventArgs e) { 43 43 base.OnActiveViewChanged(sender, e); 44 this.ToolStripItem. Visible = MainFormManager.MainForm.ActiveView is OperatorGraphVisualizationView;44 this.ToolStripItem.Enabled = MainFormManager.MainForm.ActiveView is OperatorGraphView; 45 45 } 46 46 47 47 public override void Execute() { 48 OperatorGraphVi sualizationView view = MainFormManager.MainForm.ActiveView as OperatorGraphVisualizationView;48 OperatorGraphView view = MainFormManager.MainForm.ActiveView as OperatorGraphView; 49 49 if (view != null) 50 50 view.ActivateZoomOutTool(); -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/ToolBarItems/ZoomToolBarItem.cs
r2819 r2853 42 42 protected override void OnActiveViewChanged(object sender, System.EventArgs e) { 43 43 base.OnActiveViewChanged(sender, e); 44 this.ToolStripItem. Visible = MainFormManager.MainForm.ActiveView is OperatorGraphVisualizationView;44 this.ToolStripItem.Enabled = MainFormManager.MainForm.ActiveView is OperatorGraphView; 45 45 } 46 46 47 47 public override void Execute() { 48 OperatorGraphVi sualizationView view = MainFormManager.MainForm.ActiveView as OperatorGraphVisualizationView;48 OperatorGraphView view = MainFormManager.MainForm.ActiveView as OperatorGraphView; 49 49 if (view != null) 50 50 view.ActivateZoomAreaTool();
Note: See TracChangeset
for help on using the changeset viewer.