Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) combine Table+shape? (Read 6159 times)
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
combine Table+shape?
Dec 9th, 2011 at 7:57am
Print Post  
Hi,

Is it possible to combine tablenode plus shape as one so that the auto layout can treat it as one shape? What I'm trying to do is to create a fault tree node (A tablenode with a logic gate shape connected to to the bottom).

Similar the the image below:


Do you know which is the best way for me to achieve this?

Thanks

Hai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: combine Table+shape?
Reply #1 - Dec 9th, 2011 at 8:05am
Print Post  
Hi,

You could call ShapeNode.AttachTo(TableNode) after placing the shape below a table, and then run layout algorithms with their KeepGroupLayout property set to true.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
Re: combine Table+shape?
Reply #2 - Dec 9th, 2011 at 5:42pm
Print Post  
Stoyo,

Thanks for the promptly reply.
Unfortunately, this will not work since I'm using a tree structure where the parent/child are already grouped (from the TreeLayout example).

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: combine Table+shape?
Reply #3 - Dec 10th, 2011 at 7:31am
Print Post  
I suppose you could temporarily detach the tree nodes and leave only the shape-to-table attachments. Another approach you could try is to keep all attachments, but set IgnoreLayout = true on the shapes. The layout method should preserve their positions relatively to the master tables then.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
Re: combine Table+shape?
Reply #4 - Dec 11th, 2011 at 5:35pm
Print Post  
Stoyo,

Your 2nd suggest works perfect for attaching the shape.

My only problem now is that the shape consume the the link's corner. Is there away to set the % between the layers that the cascading corner start?

|
|
------- <- (in this example 33% of .33)
| |

Thanks

Hai
  
Back to top
 
IP Logged
 
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
Re: combine Table+shape?
Reply #5 - Dec 11th, 2011 at 11:01pm
Print Post  
One other thing, is that the link is overlapping the shape when any related node (parent, child within group) are selected.

Is there a way to force not always on top?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: combine Table+shape?
Reply #6 - Dec 12th, 2011 at 7:05am
Print Post  
Hi,

The layout algorithm completely ignores nodes with IgnoreLayout set, so it does not consider their location to offset links. If you implement that by temporarily detaching tree nodes to run with KeepGroupLayout enabled, the algorithm should take into account the bounding rectangle of the whole group and place bends where expected.

If using IgnoreLayout, you could offset the bend points after applying the layout:

Code
Select All
layout.Arrange(diagram);

// assuming vertical TreeLayout with Cascading3 links
foreach (DiagramLink link in diagram.Links)
{
	PointCollection points = link.ControlPoints;
	for (int i = 1; i <= 2; ++i)
	{
		PointF p = points[i];
		p.Y += 10;
		points[i] = p;
	}
	link.UpdateFromPoints();
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
Re: combine Table+shape?
Reply #7 - Dec 12th, 2011 at 7:42am
Print Post  
Stoyo,

Would you be able to give me a quick example of this?
"If you implement that by temporarily detaching tree nodes to run with KeepGroupLayout enabled, the algorithm should take into account the bounding rectangle of the whole group and place bends where expected. "

I am able to test everything else but the detach one.

Again, I appreciate all your help.

Thanks

HL
  
Back to top
 
IP Logged
 
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
Re: combine Table+shape?
Reply #8 - Dec 12th, 2011 at 8:06am
Print Post  
Other options?

Should I use owner draw to add that shape? or image (just have to be right below the table).

Should I create a custom derived shaped?

Thanks

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: combine Table+shape?
Reply #9 - Dec 12th, 2011 at 3:53pm
Print Post  
Hi,

Here's a quick example, assuming all child nodes in the tree are attached to their parent nodes and there are no links between the shape and table nodes:

Code
Select All
foreach (DiagramLink link in diagram.Links)
	link.Destination.Detach();

var tl = new TreeLayout();
tl.KeepGroupLayout = true;
tl.Arrange(diagram);

foreach (DiagramLink link in diagram.Links)
	link.Destination.AttachTo(link.Origin, AttachToNode.TopLeft); 



Another option is to derive from TableNode and paint the shape from your class' Draw implementation. You will also have to override GetRepaintRect to allocate some space for the shape.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
himpact
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Dec 9th, 2011
Re: combine Table+shape?
Reply #10 - Dec 13th, 2011 at 6:47am
Print Post  
Oh that is almost perfect! except expand collapse is broken.

Am I deriving this correctly? Or heading in the right direction?

Code
Select All
      public override System.Drawing.RectangleF GetRepaintRect(bool includeConnected)
      {
         System.Drawing.RectangleF rectf = base.GetRepaintRect(includeConnected);
         rectf.Inflate(0, 5);
         return rectf;
      }
      public override void Draw(MindFusion.Drawing.IGraphics graphics, RenderOptions options)
      {
         graphics.FillRectangle(new SolidBrush(Color.FromArgb(50, Color.Gray)),options.VisibleRect);
         base.Draw(graphics, options);
      }
 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: combine Table+shape?
Reply #11 - Dec 13th, 2011 at 8:38am
Print Post  
Hi,

If you need expand/collapse to hide the attached nodes, you must set parentNode.SubordinateGroup.Expandable = true. However this will also hide the shape attached to a table when that table is collapsed. You could handle the +/- button clicks yourself to hide only some nodes by setting ExpandButtonAction = Custom and handling the ExpandButtonClicked event.

You can draw a shape below the table like this:

Code
Select All
public override RectangleF GetRepaintRect(bool includeConnected)
{
	RectangleF rectf = base.GetRepaintRect(includeConnected);
	rectf.Height += 20;
	return rectf;
}

public override void Draw(IGraphics graphics, RenderOptions options)
{
	base.Draw(graphics, options);

	RectangleF r = Bounds;
	r.Y = r.Bottom + 2;
	r.Height = 20;

	GraphicsPath path = new GraphicsPath();
	path.AddArc(r, 180, 180);
	path.CloseAllFigures();

	graphics.FillPath(Brushes.White, path);
	graphics.DrawPath(Pens.Black, path);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint