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
 Vector drawing, resize the base area
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Kostas

Germany
19 Posts

Posted - Jun 29 2021 :  18:07:47  Show Profile  Reply
Hello all,

Please look at the picture.

I start drawing with a 2000 X 1000 rectangle that is the gray area.
Then I create the text elements outside the rectangle.

Using the LayersRect() method, I get a rectangle with the boundaries of all layers. This is the blue rectangle.

GetIdealZoom refers to the original 2000 x 1000 rectangle.

How can I adjust the original rectangle 2000 x 1000 to the dimensions of the blue rectangle so that the zooming works?



ImageEnView1.LockUpdate();
ImageEnView1.ClearAll;
ImageEnView1.Proc.Clear;
ImageEnView1.Proc.ImageResize(2000, 1000);

//Draw all elements here.

ImageEnView1.UnlockUpdate();
ImageEnView1.Zoom := ImageEnView1.GetIdealZoom * 0.9;



xequte

38191 Posts

Posted - Jun 29 2021 :  18:50:58  Show Profile  Reply
Hi Kostas

I'll need to come back to you on this later in the week when I have a chance to investigate the best solution. Perhaps, we need an extra parameter for GetIdealZoom().

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38191 Posts

Posted - Jul 02 2021 :  01:08:58  Show Profile  Reply
Hi Kostas

GetIdealZoom seems to be returning the correct dimensions even when layers are outside the background layer.

This works for me:

ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [loDynamicCanvas];
ImageEnView1.Zoom := ImageEnView1.GetIdealZoom;


Can you confirm what you are seeing?


These might also be useful to you:

https://www.imageen.com/help/TImageEnView.LayersRect.html


Enabling loDynamicCanvas:

https://www.imageen.com/help/TImageEnView.LayerOptions.html


Turning off Center:
https://www.imageen.com/help/TImageEnView.Center.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Kostas

Germany
19 Posts

Posted - Jul 02 2021 :  12:08:27  Show Profile  Reply
Hi Nogel,

Unfortunately it did not work.

These are my results










Do you have another idea?
Go to Top of Page

xequte

38191 Posts

Posted - Jul 03 2021 :  00:41:18  Show Profile  Reply
Hi

Can you give me the code to generate your content (I was testing again the version that you emailed me earlier, which is different).

I suspect the issue is related to the size/position of your layer 0 (perhaps make it a different color so it is easier to see its effect).


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Kostas

Germany
19 Posts

Posted - Jul 03 2021 :  09:50:22  Show Profile  Reply
Hi Nigel,

Thank you for taking the time to do it. I appreciate that.

I've revised the demo.

Please two more questions:
-I still have to draw a lot of complex graphics like this. Is my approach the right way to draw lines, texts and polilines? Texts are not always drawn cleanly depending on the zoom lavel.

-If you click the Draw button a second time, the next graphic is drawn slightly offset. Apparently I'm not removing everything right.

Draw vectors

attach/Kostas/2021739503_DrawVectors.zip
3.18 KB
Go to Top of Page

Kostas

Germany
19 Posts

Posted - Jul 05 2021 :  17:23:29  Show Profile  Reply
Hi Nigel,

Regarding the second question: Clear All for drawing new objects, I have found the solution.

I ran that to clean up.


  ImageEnView1.LockUpdate();
  ImageEnView1.ClearAll;
  ImageEnView1.LayersClear;
  ImageEnView1.Proc.Clear;

  //Draw new objects

  ImageEnView1.UnlockUpdate();


And that's how it works.


  ImageEnView1.LockUpdate();
  ImageEnView1.ClearAll;
  ImageEnView1.ResetState; //<<<<<<<<<<<<<<

  //Draw new objects

  ImageEnView1.UnlockUpdate();

Go to Top of Page

xequte

38191 Posts

Posted - Jul 05 2021 :  20:25:30  Show Profile  Reply
Hi Kostas

Sorry for the delay. The issue here is that because they layers are positioned offset (not originating at 0,0) then they are not adequately centered (rightly or wrongly ImageEn considers the origin position when centering the view.

The solution is to give your layer group the origin of 0,0:

var 
  rect: TIERectangle;
begin
  rect := ImageEnView1.LayersRect(False, True);
  ImageEnView1.LayersRepositionAll(-rect.X, - rect.Y);


Here's a full example:

// Zoom so layers fill entire view area

// Make IEView consider all layers when calculating image bounds
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [loDynamicCanvas];

// Position layers so origin is 0,0
rect := ImageEnView1.LayersRect(False, True);
ImageEnView1.LayersRepositionAll(-rect.X, - rect.Y);

// Adjust zoom so all layers fill the view area
ImageEnView1.Fit();


In v10.0.2 you can also do it this way:

// Adjust view to show all layers
var
  rect: TIERectangle;
begin
  // Make IEView consider all layers when calculating image bounds
  ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [loDynamicCanvas];

  // Position layers so origin is 0,0
  rect := ImageEnView1.LayersRect(False, True);
  ImageEnView1.LayersRepositionAll(-rect.X, - rect.Y);

  // Get updated layer rect and show it at size of control
  rect := ImageEnView1.LayersRect(False, True);
  ImageEnView1.VisibleBitmapRect := IERectangleToRect( rect );
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Kostas

Germany
19 Posts

Posted - Jul 06 2021 :  07:58:53  Show Profile  Reply
If I use your suggestion with LayersRepositionAll together with ResetState everything works perfectly.
Thank you very much, Nigel.
Go to Top of Page

Kostas

Germany
19 Posts

Posted - Jul 06 2021 :  17:10:13  Show Profile  Reply
Hi Nigel,

Unfortunately, I now have one more problem.

Depending on the zoom position, some text is cut off and it has nothing to do with the length.

If I change the zoom (change the height of the form) there are places where the texts are cut off.

I absolutely have to prevent that. Do you have any idea?

I've expanded the example.











attach/Kostas/202176171239_DrawVectors3.zip
2.98 KB
Go to Top of Page

xequte

38191 Posts

Posted - Jul 07 2021 :  06:57:25  Show Profile  Reply
Hi Kostas

Have you tried setting TextOverflow to ieoShrink?

https://www.imageen.com/help/TIETextLayer.TextOverflow.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Kostas

Germany
19 Posts

Posted - Jul 07 2021 :  08:09:56  Show Profile  Reply
ImageEN and their support is fantastic.
Now everything works perfectly.


procedure LabelinigXAxis;
          begin
            ImageEnView1.LayersAdd( ielkText );
            with TIETextLayer( ImageEnView1.CurrentLayer ) do
            begin
              Text := 'That is a very loooooooooooooooooooooooooooooooooooooong text.'; //'Headline Top';
              Font.Name := 'Arial';
              Font.Size := Round(5*multi);
              Font.Style := [fsBold];
              TextOverflow := ieoShrink;
              WordWrap := false;
              SizeToText();
              PosX := (LimitsRect.Width div 2) - (Width div 2);
              PosY := 0 + (Height div 2) - Round(15*multi);
            end;
          end;



Have a nice day, Nigel


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