Zoom to entities
Moderators: SDS, support, admin
-
- Posts: 2
- Joined: 01 Jul 2008, 15:51
Zoom to entities
Hello,
I want to zoom on an array of entity.
I have already made an union of each boxes of all entites to get the rectangle to zoom into but i don't know how to put these coordinates to zoom on it.
The best result is with PreviousPosition property :
but the result is not good.
Where to set theses coordinates to do a global zoom of the entities ?
Thank you.
I want to zoom on an array of entity.
I have already made an union of each boxes of all entites to get the rectangle to zoom into but i don't know how to put these coordinates to zoom on it.
The best result is with PreviousPosition property :
Code: Select all
internal static void zoomOnEntity(MyMapDisplay map, CADEntity[] entity)
{
if(entity.Length == 0)
return;
DRect rect = entity[0].Box;
RectangleF rectangleF;
foreach(CADEntity en in entity)
{
rectangleF = RectangleF.Union(new RectangleF((float)rect.left, (float)rect.top, (float)rect.Width, (float)rect.Height), new RectangleF((float)en.Box.left, (float)en.Box.top, (float)en.Box.Width, (float)en.Box.Height));
rect = new DRect(rectangleF.X, rectangleF.Y, 0, rectangleF.Right, rectangleF.Bottom, 0);
}
Point p = map.CADPicture.cadImage.GetPoint(new DPoint(rect.left + rect.Width / 2, rect.top + rect.Height / 2, 0), map.CADPicture.ImageRectangleF);
map.CADPicture.PreviousPosition = new PointF((float)p.X, (float)p.Y);
map.CADPicture.ImageScale = 20.0f;
map.CADPicture.Refresh();
}
Where to set theses coordinates to do a global zoom of the entities ?
Thank you.
Re: Zoom to entities
Hello!
Thank you for the question. We will answer you soon.
Sergey.
Thank you for the question. We will answer you soon.
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 2
- Joined: 01 Jul 2008, 15:51
Re: Zoom to entities
Hello,
Have you find a solution which let's me zoom on a special entity or a technic to zoom to see a list of entities ?
Thank you in advance.
Have you find a solution which let's me zoom on a special entity or a technic to zoom to see a list of entities ?
Thank you in advance.
Re: Zoom to entities
Hello,
Please try the following code (it is based on Viewer demo):
Sergey.
Please try the following code (it is based on Viewer demo):
Code: Select all
private float SetNewScale(Point topLeft, Point bottomRight)
{
Rectangle entRect = new Rectangle(topLeft.X - 2, topLeft.Y - 2, (bottomRight.X - topLeft.X) + 4, (bottomRight.Y - topLeft.Y) + 4);
float kf1 = (this.curClRect.Width * scale) / entRect.Width;
float kf2 = (this.curClRect.Height * scale) / entRect.Height;
if(kf1 > kf2)
kf1 = kf2;
return kf1;
}
private int cnt_ent = 0;
private void btnShowRect_Click(object sender, System.EventArgs e)
{
this.cadImage.UseDoubleBuffering = false;
cadPictBox.Invalidate();
if(cnt_ent >= this.cadImage.Converter.Entities.Count)
cnt_ent = 0;
CADEntity ent = this.cadImage.Converter.Entities[cnt_ent];
Point topLeft = this.cadImage.GetPoint(ent.Box.TopLeft);
Point bottomRight = this.cadImage.GetPoint(ent.Box.BottomRight);
//shift----------
float centerX = this.curClRect.Width / 2.0f - (bottomRight.X - topLeft.X) / 2.0f;
float centerY = this.curClRect.Height / 2.0f - (bottomRight.Y - topLeft.Y) / 2.0f;
this.pos.X = this.pos.X - topLeft.X + centerX;
this.pos.Y = this.pos.Y - topLeft.Y + centerY;
//--------------
old_Pos = new PointF(cadPictBox.ClientRectangle.Width / 2, cadPictBox.ClientRectangle.Height / 2);
this.scale = SetNewScale(topLeft, bottomRight);
cadPictBox.Invalidate();
cnt_ent++;
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support