Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to get the expected destination anchor? (Read 5359 times)
Joanna
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: May 15th, 2006
How to get the expected destination anchor?
Apr 2nd, 2007 at 12:15am
Print Post  
Hi, Stoyo

Now I had another question about the FlowChartX.

Before I created an arrow, I need to do some check work, so I use the function of RequestCreateArrow(LPDISPATCH arrow, BOOL *pbCreate); and in this function, I can get the expacted destination box, but it is not enough, I still need to get the expacted destination anchor of the expacted destination box. (Because in the expacted destination box, there are many anchors, I need to identify which anchor the arrow is intend to be connected to)

Is there any way to get the expected destination anchor of an arrow?

Thanks! Hope for your help.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the expected destination anchor?
Reply #1 - Apr 2nd, 2007 at 6:37am
Print Post  
Hi Joanna,

The only way I can think of doing this is to enumerate all points in the AnchorPattern object using the AnchorPointCount property and GetAnchorPoint method, and find the nearest point yourself. In FlowChartX that's done as shown below

Code
Select All
float nearestDist = 2 * (float)max(
	nodeRect.right - nodeRect.left, nodeRect.bottom - nodeRect.top);

for (unsigned i = 0; i < anchorPattern->points.size(); i++)
{
	AnchorPoint ap = anchorPattern->points[i];
	if (incoming && !ap.allowIncoming) continue;
	if (!incoming && !ap.allowOutgoing) continue;

	POINT pos = ap.getPos(nodeRect);
	float dx = float(pos.x - pt.x);
	float dy = float(pos.y - pt.y);
	float ptDist = (float)sqrt(dx*dx + dy*dy);
	if (ptDist < nearestDist)
	{
		nearestDist = ptDist;
		nearestPt = pos;
		anchorIdx = i;
	}
}

POINT AnchorPoint::getPos(RECT nodeRect)
{
	POINT pt = {
		nodeRect.left + (nodeRect.right - nodeRect.left) * x / 100,
		nodeRect.top + (nodeRect.bottom - nodeRect.top) * y / 100 };
	return pt;
}
 



You will need to replace the internal methods with ones from the public API.

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


I love YaBB 1G - SP1!

Posts: 37
Joined: May 15th, 2006
Re: How to get the expected destination anchor?
Reply #2 - Apr 2nd, 2007 at 10:41pm
Print Post  
Hi, Stoyan

I understand what you are suggestion, but I still have one questions about this method.

What's the define of the "nodeRect"?
Does it mean the expected destination of the arrow? Then how can I get it by the FlowChartX or Public API functions?


Thanks!
Joanna
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the expected destination anchor?
Reply #3 - Apr 3rd, 2007 at 6:47am
Print Post  
Hi Joanna,

Yes, nodeRect should contain the coordinates of the Arrow.ExpectedDestination node. You can use the Left/Top/Right/Bottom properties of the Box class to get the coordinates.

Stoyan
  
Back to top
 
IP Logged
 
Joanna
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: May 15th, 2006
Re: How to get the expected destination anchor?
Reply #4 - Apr 4th, 2007 at 4:06am
Print Post  
Hi, Stoyan

Thank you! With your help, I had solved this problem. Thank you very much!

And just give a small suggestion, you can add such "GetExpectDestAnchor" function into the CArrowItem in the next version, it might be very useful.

Thank you in advance.
Joanna
  
Back to top
 
IP Logged
 
Joanna
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: May 15th, 2006
Re: How to get the expected destination anchor?
Reply #5 - Apr 4th, 2007 at 5:50am
Print Post  
Hi, Stoyan

I had another question about the ArrowItem. Smiley

Is there any way to release following functions?
The function is like this: when the user create arrows on the GUI, the color of the arrows is the same with the color of the origin anchor of the arrow.
That is to say, when the user draw an arrow from a red anchor, the arrow is red; and from blue anchor, then the arrow is blue.

When I look over the Help File of FlowChartX, I found there is an event called "InitializeArrow", it seems can realize this kind of function.
But when I intent to get the information of the color of the origin anchor of the arrow, it gave out error. Because in the function of "InitializeArrow", the return value of the arrow.get_OrgnAnchor is (-1). It seems that in this function, we still cannot get the information of the origin anchor of the arrow.
Then is there any other way for me to get the information of the origin anchor of the arrow in the function of "InitializeArrow"?

Sorry for so many question. Smiley
Thanks!
Joanna
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the expected destination anchor?
Reply #6 - Apr 4th, 2007 at 6:42am
Print Post  
Hi Joanna,

Tough luck - InitializeArrow is raised just before FlowChartX determines what anchor point to use. For now, try the following:

- handle InitializeArrow and save a reference to the new arrow, e.g. call it newArrow
- handle MouseMove and if newArrow is != null set its color (the OrgnAnchor should already have a valid value)
-set newArrow = null before exiting the MouseMove handler

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


I love YaBB 1G - SP1!

Posts: 37
Joined: May 15th, 2006
Re: How to get the expected destination anchor?
Reply #7 - Apr 5th, 2007 at 3:22am
Print Post  
Hi, Stoyan

Thank you!
With your help, all things work just as I intent to. Thank you! Smiley

Another tough question, but if it is impossible or difficult to realize it, that's ok.
The question is like this:
When the segment of the arrow is set as "3", and the position of the arrowhead is in the center of the arrow, then there will be arrowhead in each segment of the arrow. Is it possible to only show arrowhead in the second or longest segment? It will make the diagram look cleaner.


Thanks in advance,
Joanna
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the expected destination anchor?
Reply #8 - Apr 5th, 2007 at 5:00am
Print Post  
Hi Joanna,

I'm afraid that's not possible. We could add a CustomDraw property and a DrawArrow event similar to the Box ones. Then you will be able to draw the arrowheads yourself by handling the Draw event.

Stoyan
  
Back to top
 
IP Logged
 
Joanna
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: May 15th, 2006
Re: How to get the expected destination anchor?
Reply #9 - Apr 8th, 2007 at 11:55pm
Print Post  
Ok, thank you the same in any way! Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint