Changeset 3422


Ignore:
Timestamp:
04/19/10 22:07:24 (12 years ago)
Author:
mkommend
Message:
  • corrected bugs in operator graph visualization (ticket #867)
  • changed multi call operators in graph visualization (ticket #979)
Location:
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs

    r3393 r3422  
    8181      foreach (IOperator oper in this.operatorShapeInfoMapping.FirstValues) {
    8282        foreach (IParameter param in oper.Parameters) {
     83          IValueParameter opParam = param as IValueParameter;
    8384          this.parameterOperatorMapping.Add(param, oper);
    84           IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    85           if (opParam != null)
     85          if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType))
    8686            this.RegisterOperatorParameterEvents(opParam);
    8787          else
     
    125125        foreach (IParameter param in oper.Parameters) {
    126126          clone.parameterOperatorMapping.Add(param, oper);
    127           IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    128           if (opParam != null)
     127          IValueParameter opParam = param as IValueParameter;
     128          if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType))
    129129            clone.RegisterOperatorParameterEvents(opParam);
    130130          else
     
    230230      IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From;
    231231      IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo);
    232       IValueParameter<IOperator> param = (IValueParameter<IOperator>)op.Parameters[connectionInfo.ConnectorFrom];
     232      IValueParameter param = (IValueParameter)op.Parameters[connectionInfo.ConnectorFrom];
    233233      param.Value = null;
     234    }
     235
     236    public override void AddConnectionInfo(IConnectionInfo connectionInfo) {
     237      IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From;
     238      IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo);
     239      IValueParameter param = (IValueParameter)op.Parameters.Where(p => p.Name == connectionInfo.ConnectorFrom).Single();
     240      IOperatorShapeInfo shapeInfoTo = (IOperatorShapeInfo)connectionInfo.To;
     241      IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo);
     242      param.Value = opTo;
    234243    }
    235244    #endregion
     
    321330    private void AddParameter(IOperator op, IParameter param) {
    322331      this.parameterOperatorMapping.Add(param, op);
    323       IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    324       if (opParam != null) {
     332      IValueParameter opParam = param as IValueParameter;
     333      if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) {
    325334        this.RegisterOperatorParameterEvents(opParam);
    326335        IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op);
     
    328337
    329338        if (opParam.Value != null) {
    330           if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value))
    331             this.AddOperator(opParam.Value);
    332           IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst(opParam.Value);
     339          if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value))
     340            this.AddOperator((IOperator)opParam.Value);
     341          IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value);
    333342          this.connectionInfos.Add(new ConnectionInfo(shapeInfoFrom, param.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector));
    334343        }
     
    338347
    339348    private void RemoveParameter(IOperator op, IParameter param) {
    340       IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    341       if (opParam != null) {
     349      IValueParameter opParam = param as IValueParameter;
     350      if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) {
    342351        this.DeregisterOperatorParameterEvents(opParam);
    343352        IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
     
    352361
    353362    private void opParam_ValueChanged(object sender, EventArgs e) {
    354       IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender;
     363      IValueParameter opParam = (IValueParameter)sender;
    355364      IOperator op = this.parameterOperatorMapping[opParam];
    356365      IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op);
     
    359368      this.connectionInfos.RemoveWhere(c => c.From == shapeInfoFrom && c.ConnectorFrom == opParam.Name);
    360369      if (opParam.Value != null) {
    361         if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value))
    362           this.AddOperator(opParam.Value);
    363         IShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst(opParam.Value);
    364         this.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector));
     370        if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value))
     371          this.AddOperator((IOperator)opParam.Value);
     372        IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value);
     373        base.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector));
    365374      }
    366375    }
     
    399408    }
    400409
    401     private void RegisterOperatorParameterEvents(IValueParameter<IOperator> opParam) {
     410    private void RegisterOperatorParameterEvents(IValueParameter opParam) {
    402411      opParam.ValueChanged += new EventHandler(opParam_ValueChanged);
    403412    }
    404     private void DeregisterOperatorParameterEvents(IValueParameter<IOperator> opParam) {
     413    private void DeregisterOperatorParameterEvents(IValueParameter opParam) {
    405414      opParam.ValueChanged -= new EventHandler(opParam_ValueChanged);
    406415    }
     
    426435
    427436    private void UpdateParameterLabels(IOperator op) {
    428       IEnumerable<IParameter> parameters = op.Parameters.Where(p => !(p is IValueParameter<IOperator>));
     437      IEnumerable<IParameter> parameters = op.Parameters.Where(p => !(p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType)));
    429438      IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
    430439      if (parameters.Count() > 0)
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShape.cs

    r3386 r3422  
    206206      this.Children.Add(expandIconMaterial);
    207207
    208       this.predecessor = this.CreateConnector("Predecessor", new Point(Rectangle.Left, Center.Y));
     208      this.predecessor = this.CreateConnector(OperatorShapeInfoFactory.PredecessorConnector, new Point(Rectangle.Left, Center.Y));
    209209      this.Connectors.Add(predecessor);
    210210
    211       this.successor = this.CreateConnector("Successor", (new Point(Rectangle.Right, Center.Y)));
     211      this.successor = this.CreateConnector(OperatorShapeInfoFactory.SuccessorConnector, (new Point(Rectangle.Right, Center.Y)));
    212212      this.Connectors.Add(successor);
    213213    }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs

    r3386 r3422  
    160160      shape.Collapsed = this.Collapsed;
    161161      foreach (string connectorName in this.connectorNames)
    162         shape.AddConnector(connectorName);
     162        if (connectorName != OperatorShapeInfoFactory.SuccessorConnector && connectorName != OperatorShapeInfoFactory.PredecessorConnector)
     163          shape.AddConnector(connectorName);
    163164
    164165      shape.UpdateLabels(this.labels);
     
    191192        operatorShape.RemoveConnector(oldConnectorNames[j]);
    192193
    193       //add new connectors
     194      //add new connectors except successor and connector
    194195      for (; i < this.connectorNames.Count; i++)
     196        if (this.connectorNames[i] != OperatorShapeInfoFactory.SuccessorConnector && this.connectorNames[i] != OperatorShapeInfoFactory.PredecessorConnector)
    195197        operatorShape.AddConnector(this.connectorNames[i]);
    196198
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfoFactory.cs

    r3386 r3422  
    3232  internal static class OperatorShapeInfoFactory {
    3333    public const string PredecessorConnector = "Predecessor";
     34    public const string SuccessorConnector = "Successor";
    3435    public static IOperatorShapeInfo CreateOperatorShapeInfo(IOperator op) {
    35       IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter<IOperator>).Select(p => p.Name);
    36       IEnumerable<string> paramaterNameValues = op.Parameters.Where(p => !(p is IValueParameter<IOperator>)).Select(p => p.ToString());
     36      IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType)).Select(p => p.Name);
     37      IEnumerable<string> paramaterNameValues = op.Parameters.Where(p => !(p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType))).Select(p => p.ToString());
    3738
    3839      OperatorShapeInfo operatorShapeInfo = new OperatorShapeInfo(operatorParameterNames, paramaterNameValues);
Note: See TracChangeset for help on using the changeset viewer.