Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Items alligned to grid (Read 3075 times)
MagnusSpeychal
Junior Member
**
Offline



Posts: 53
Joined: Jun 18th, 2007
Items alligned to grid
Aug 28th, 2007 at 11:46am
Print Post  
Hi

When a user double-clicks the drawing area I create a box with the CreateBox() method. I use the x and y arguments to the "double-click-method" as arguments to the CreateBox() method. The size of the created box is 20,10 and it has anchor points defined as (0,50) and (100,50). The grid size is set to 1.
The problem is that the box is not alligned to the grid which in turn means the arrows connected to the anchor points is not drawn straight. I have tried using the SetRect() method after the box is created to try to allign the box to the grid but this does not work!
How can I allign this box to the grid?


Best regards,
Magnus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Items alligned to grid
Reply #1 - Aug 28th, 2007 at 1:28pm
Print Post  
Hi,

Use the following method to find the aligned point:

Code
Select All
POINT AlignPoint(POINT pt)
{
	if (m_bAlignToGrid)
	{
		pt.x = pt.x - pt.x % m_nGridSize + (pt.x >= 0 ? m_nGridSize/2 : -m_nGridSize/2);
		pt.y = pt.y - pt.y % m_nGridSize + (pt.y >= 0 ? m_nGridSize/2 : -m_nGridSize/2);
	}

	return pt;
}
 



Replace m_nGridSize with FlowChart.GridSize.

Stoyan
  
Back to top
 
IP Logged
 
MagnusSpeychal
Junior Member
**
Offline



Posts: 53
Joined: Jun 18th, 2007
Re: Items alligned to grid
Reply #2 - Aug 29th, 2007 at 6:35am
Print Post  
Hi Stoyan

Thanks for your answer.
Sadly it did not work so I started examine the most fundamental parts of my code. It seemed that before I have done anything with the grid size it is set to 5, not to 16 which is the default value according to the development guide. When I try to set the grid size to 1 it is set to 4. I have tried setting the grid size to different values around 4 and it seems that 4 is the minimum value for the grid size!
Is this correct?


Best regards,
Magnus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Items alligned to grid
Reply #3 - Aug 29th, 2007 at 6:42am
Print Post  
Hi Magnus,

Yes, the minimum value is 4, otherwise drawing the grid gets very slow.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint