2 Advanced qustions

First question is:

I Have a problem that the nodes are arranged in one part of the view.
Like so:


| O----O----O
| |
| O
|
|
| 0------0
| |
| 0------0


This happens after I call the
layout.PerformLayout() method
(layout is a GoLayoutLeyerdDigraph type)
call the fit-to-size method
and becaus the two trees are so far apart the nodes are very very small and I can’t read waht’s inside them.

This problem happens also when I’m using the
GoLayoutTree & GoLayoutForceDirected
types instead of GoLayoutLeyerdDigraph.

Another exapmle:


| O----O----O 0----0----0-----0-----0----0------0
| | | | | |
| O O O O O
|
|
|
|
|
|
|
|


Instead of moving one of the trees to the buttom it lays them all in one row.

Does the GoDiagram have any built-in option for filling the view area in the best way so that the nodes will spread on all the view and not be very far apart from eachother?

Second question is:
GoToolZooming lets the user to drag a pre-defined-fixed-ratio rectangle.
Is there a way or tool for having a zoomer that have a non-fixed-ratio
rectangle for selecting the zoom area?

Thanks in advance.

  1. GoLayoutTree.Arrangement and the other Arrangement… properties can be used to specify how to arrange multiple trees in the network.
    The other layout algorithms don’t have these properties, but you can do this yourself by using the GoLayoutLayeredDigraphNetwork.SplitIntoSubNetworks method. For each of the resulting networks, you can perform the layout and then move the resulting graph (GetNodesAndLinks) where you want to in your document. GoLayoutForceDirectedNetwork has the same methods too.
  2. You are right about GoToolZooming. The reason for that limitation is because the ZoomedView has a particular aspect ratio, and the purpose of the drawn box is to show the area that the ZoomedView will show.
    However, you can easily customize GoToolRubberBanding to do what you want by overriding the DoRubberBand method. The purpose of “zooming” is to just set the “ZoomedView”'s DocScale and DocPosition properties in the way that the user draws. GoToolZooming.ComputeRubberBandBox was overridden to keep the aspect ratio constant, but you don’t need to do that if you don’t want to.

what does the DoRubberBand method do so I’d know how to customize it?..

Thank you very much.

I’ll try them some day in the following weeks and let you knew how it went. :)

Well, GoToolRubberBanding.DoRubberBand selects everything that is in the box.

GoToolZooming.DoRubberBand changes the ZoomedView.DocScale and .DocPosition so that the view's DocExtent matches the box.
I don't know exactly what you want to do in your tool.

It became more importent now, so I'm back. :)

I don’t want the RubberBand to be in fixed ratio style.
I want the user to be able to select any rectange he wants (like the regular GoToolRubberBanding.DoRubberBand) and because the
GoView has its ratio I’d take the smaller sides of the rectangle and extend
them so they’ll fit the GoView ratio. That’s what’s done in every zoom tool I
know- in maps for example.

Do you understand me now?..

Sorry about that – I don’t think I ever saw your reply of 27 January.

You can override ComputeRubberBandBox to return any value you want.

GoToolRubberBanding.ComputeRubberBandBox just returns the Rectangle formed by the difference in FirstInput.ViewPoint and LastInput.ViewPoint.

GoToolZooming.ComputeRubberBandBox does the same thing but constrains the rectangle to match the aspect ratio of the GoToolZooming.ZoomedView.DisplayRectangle.

Hi again.

Is there a way for removing that fixed ratio constraint? Then, after the user has finished selecting the area he wants to zoom into i can manually fix it so it’ll fit the ratio size so he’ll get all the area he selected and sometimes a bit more (because of the view’s fixed ratio over the control).

thank you.

Yes, you can override ComputeRubberBandBox to return whatever value you want.

You can also override DoRubberBand to set the observed GoView’s DocScale and DocPosition the way you want, too. But be aware that there are limits on the GoView.DocScale and DocPosition properties, as governed by the GoView.LimitDocScale and LimitDocPosition methods, which in turn are affected by the GoView.SheetStyle, DocumentTopLeft, DocumentSize, and DocExtentSize properties.

As I saw, By overriding the ComputeRubberBandBox I can only change the given ratio but not removing it completely. Correct me if wrong.

I'll try the second suggestion but what DoRubberBand method do I need to override?

The standard behavior of GoToolZooming.ComputeRubberBandBox is to have the same aspect ratio as the ZoomedView, so that the “box” faithfully represents the area of the document that the view shows.

Both methods are on GoToolZooming, which inherits from GoToolRubberBanding.

[QUOTE=walter]Yes, you can override ComputeRubberBandBox to return whatever value you want.

You can also override DoRubberBand to set the observed GoView’s DocScale and DocPosition the way you want, too. But be aware that there are limits on the GoView.DocScale and DocPosition properties, as governed by the GoView.LimitDocScale and LimitDocPosition methods, which in turn are affected by the GoView.SheetStyle, DocumentTopLeft, DocumentSize, and DocExtentSize properties.
[/quote]

I did override it and it worked partially. I used the code from this thread:

[code]

float xScale = ((float)View.ClientSize.Height * View.DocScale) / (float)box.Height;

float yScale = ((float)View.ClientSize.Width * View.DocScale) / (float)box.Width;

float newScale = Math.Min(xScale, yScale);

View.DocPosition = new PointF(box.Left, box.Top);

View.DocScale = newScale;

[/code]

And the same code with a slight change- the last row and the row before it swiched lines. In both, the docScale changes perfectly but I don't really see why won't it let me change the docPosition to what it gets assigned to. How can I work with the limitDocPosition or how can I manipulate the GoView.SheetStyle, DocumentTopLeft, DocumentSize, and DocExtentSize properties to meet my needs?

Thanks a lot.

By default, GoView.LimitDocPosition tries to keep the view within the document. However, when the SheetStyle is not None, there are no limits–the DocumentTopLeft and DocumentSize properties automatically adjust themselves to accomodate viewing any part of the document or the Sheet at any DocScale given the size of this view control.