ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 [IEvolution] Rotating vectorial objects
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Claus.Gerlach

Germany
18 Posts

Posted - Jul 24 2012 :  01:30:01  Show Profile  Reply
In our application we use your IEViewer-component to label significant parts of a picture by taking advantage of IEAnnotations object. More specifically, we use points (IEObjectEllipse) for that work. After all sometimes it's necessary to rotate the picture. This will be done by using an additional layer and the "EnableRotateLayers"-property. To put the points on the right place I calculated new coordinates of the objects via matrix tranformation for rotation. This worked fine with IEvolution 4.0.1 component. But with version 4.1.2 it doesn't work. It seems that after rotation you use a new coordinate system. Is there a builtin function where I can rotate objects over a free selectable rotation center and free selectable rotation angel? Or is there a method of anchoring objects to a layer, so rotation of layer means also rotation of objects?

Best regards

Claus Gerlach

fab

1310 Posts

Posted - Jul 26 2012 :  01:08:52  Show Profile  Reply
Please could you show the code used to rotate objects?
Go to Top of Page

Claus.Gerlach

Germany
18 Posts

Posted - Jul 26 2012 :  04:13:44  Show Profile  Reply
/// <summary>
/// rotate objects over given rotation center and rotation angle
/// </summary>
/// <param name="objects"></param>
/// <param name="drehpunkt_x"></param>
/// <param name="drehpunkt_y"></param>
/// <param name="drehwinkel_grad"></param>
private void dreheObjekte(IEAnnotations objects,
int drehpunkt_x,
int drehpunkt_y,
double drehwinkel_grad)
{
// transform rotation angle from degree to radians
double winkel = drehwinkel_grad / 180 * Math.PI;
for (int i = 0; i < objects.ObjectsCount; i++)
{
IEObject obj = objects.GetObjectFromIndex(i);
// moving coordinates in order to put rotation center to origin point
obj.Left = obj.Left - drehpunkt_x;
obj.Top = obj.Top - drehpunkt_y;
// processing the matrix transformation
int x_alt = obj.Left;
int y_alt = obj.Top;
obj.Left = (int) (x_alt * Math.Cos(winkel) + y_alt * Math.Sin(winkel));
obj.Top = (int) (-x_alt * Math.Sin(winkel) + y_alt * Math.Cos(winkel));
// moving coordinates back
obj.Left = obj.Left + drehpunkt_x;
obj.Top = obj.Top + drehpunkt_y;
}
}
Go to Top of Page

fab

1310 Posts

Posted - Jul 30 2012 :  13:03:49  Show Profile  Reply
Coordinate system has not been changed in 4.1.2. Instead of set obj.Left and obj.Top you could try to retrieve the object rect using obj.Rect, set top-left coordinates and re-set obj.Rect with the new rectangle:

IERect objRect = obj.Rect;
...rotate objRect rectangle...
obj.Rect = objRect;
Go to Top of Page

Claus.Gerlach

Germany
18 Posts

Posted - Aug 16 2012 :  01:13:06  Show Profile  Reply
Hello,

now I use this code without having a change in the result. It doesn't work, too:

/// <summary>
/// rotate objects over given rotation center and rotation angle
/// </summary>
/// <param name="objects"></param>
/// <param name="drehpunkt_x"></param>
/// <param name="drehpunkt_y"></param>
/// <param name="drehwinkel_grad"></param>
private void dreheObjekte(IEAnnotations objects,
int drehpunkt_x,
int drehpunkt_y,
double drehwinkel_grad)
{
// transform rotation angle from degree to radians
double winkel = drehwinkel_grad / 180 * Math.PI;
for (int i = 0; i < objects.ObjectsCount; i++)
{
IEObject obj = objects.GetObjectFromIndex(i);
IERect rect = obj.Rect;

int width_alt = rect.Rectangle.Width;
int height_alt = rect.Rectangle.Height;
// moving coordinates in order to put rotation center to origin point
rect.Left = rect.Left - drehpunkt_x;
rect.Top = rect.Top - drehpunkt_y;
// processing the matrix transformation
int x_alt = rect.Left;
int y_alt = rect.Top;
rect.Left = (int)(x_alt * Math.Cos(winkel) + y_alt * Math.Sin(winkel));
rect.Top = (int)(-x_alt * Math.Sin(winkel) + y_alt * Math.Cos(winkel));
// moving coordinates back
rect.Left = rect.Left + drehpunkt_x;
rect.Top = rect.Top + drehpunkt_y;
rect.Right = rect.Left + width_alt;
rect.Bottom = rect.Top + height_alt;

obj.Rect = rect;
}
}
Go to Top of Page

Claus.Gerlach

Germany
18 Posts

Posted - Sep 06 2012 :  01:00:39  Show Profile  Reply
I solved the problem:

Rotation of objects didn't fail because of code (posted here) for matrix transformation. It was a problem of the layers.
Using the following code works with IEvolution 4.1.2:

//Adjust position of annotations according to rotation angle of image
private void btnRotateOK_Click(object sender, EventArgs e)
{
    IELayer layer;
 
    //Original code:
    //ieViewerLeft.Image.LayersRemove(0);
    //layer = ieViewerLeft.Image.GetLayer(0);
 
    //New code:
    layer = ieViewerLeft.Image.GetLayer(1);
 
    int center_of_rotation_x = (int) (layer.RotateCenterX * ieViewerLeft.Image.Width);
    int center_of_rotation_y = (int) (layer.RotateCenterY * ieViewerLeft.Image.Height);
    double rotation_angle = layer.Rotate;
 
    //Calling a method, where the annotations are rotated via matrix-transformation
    rotateObjects(ieViewerLeft.Image.Annotations, center_of_rotation_x, center_of_rotation_y, rotation_angle);
 
    ieViewerLeft.EnableRotateLayers = false;
           
    //New code:
    ieViewerLeft.Image.LayersRemove(0);
 
    //some more code…
}



Best regards

Claus Gerlach
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: