This project is read-only.

Incorrect drag behavior

Jan 5, 2010 at 8:32 PM

First of all: love this project!

Playing with it I noticed that the drag behavior sometimes is incorrect.

One of the way to see this is as follows:

  1. Create a line
  2. Create a parrallel line in relation to the first line
  3. Drag the second line (by the line itself, not the FreePoint on it)

(This is only one case but I verified that this behavior occurs for perpendular lines as well)

When dragging the second line the first line is dragged too. I think this should not be the case.

The reason why this happens is that inside Dragger.MouseDown DependencyAlgorithms.FindRoots is called to determine all roots of which all Dependents will be moved. In case of a parrallel line the original line will be added as a root and so it and all its Dependents will be moved. Only the direction of the line is dependent on the original line, not its position. This is why there is a need to distinguish between these different kinds of dependencies.

In my first attempt to fiddle around with the code I fixed this doing the following:

  1. Addition if IFigure: IEnumerable<IFigure> MoveDependencies { get; }
  2. Implementation in FigureBase: public virtual IEnumerable<IFigure> MoveDependencies { get { return mDependencies; } }
      public virtual IEnumerable<IFigure> MoveDependencies
  3. Implementation in FigureDecorator: public IEnumerable<IFigure> MoveDependencies { get { return Decorated.MoveDependencies; } }
  4. Implementation in FigureList: public virtual IEnumerable<IFigure> MoveDependencies { get; private set; }
  5. Override in ParrallelLine: public override IEnumerable<IFigure> MoveDependencies { get { return new FigureList { Dependencies.ToArray()[1] }; } }

I would love to participate in the improvement of this project as a developer.

Regards, Jacco

Jan 6, 2010 at 6:29 AM

Yes, it's also a problem for CircleByRadius. The current behavior is counterintuitive, I agree.

In the long term, I was thinking of solving the bigger problem behind it. For example, a parallel line doesn't really need a line, it just needs an angle value, a number from 0 to PI. Same for CircleByRadius, it doesn't really need two points, it just needs a numeric value > 0. If some of the dependencies are numbers (e.g. Func<double>), then while traversing the dependency graph, we won't follow through numbers and this problem will be solved automatically. But your solution seems fine for now.

You are welcome to contribute, I've added you as a developer. The only condition is that if I don't like something about the code, be prepared that I will change it my way :) Otherwise you're free to unleash your creativity :)