Author |
Topic |
|
tylin123
Taiwan
25 Posts |
Posted - Oct 08 2018 : 02:54:30
|
Dear sir,
There are three questions about iekRuler:
Q1. I have created many iekRuler objects on ImageEnVect, but why does the label text on the object have different background colors? (Please refer to the image below):
Q2. Why is the length display value of the iekRuler object different from the value calculated by the following code?
function FixedGetObjDiagLen(ie: TImageEnVect; hobj: integer): double;
var
lx, ly: double;
r: TRect;
begin
ie.GetObjRect(hobj, r);
lx := abs(r.Right-r.Left) * ie.MeasureCoefX;
ly := abs(r.Bottom-r.Top) * ie.MeasureCoefY;
result := sqrt(lx * lx + ly * ly);
end;
Q3. How do I get the length caption on an iekRuler object?
Best regard, James T.Y Lin
|
|
xequte
38127 Posts |
Posted - Oct 08 2018 : 22:46:18
|
Hi James
Firstly, unless you have a good reason, you should use TIELayers to draw rulers, rather than the older ImageEnVect methods.
Here is an example:
// Allow users to draw rulers (lines with measurement values)
With ImageEnView1.LayerDefaults do
begin
Clear();
Add( IELP_IsRuler + '=True' );
Add( IELP_RulerUnits + '=' + IntToStr( ord( ieuCentimeters )));
Add( IELP_LabelPosition + '=' + IntToStr( ord( ielpAutoAbove )));
Add( IELP_LineStartShape + '=' + IntToStr( ord( ieesBar )));
Add( IELP_LineEndShape + '=' + IntToStr( ord( ieesBar )));
Add( IELP_LineWidth + '= 2' );
end;
IEGlobalSettings().MeasureDecimalPlaces := 1;
ImageEnView1.MouseInteract := [ miClickCreateLineLayers, miEditLayerPoints ];
More Info: https://www.imageen.com/help/TIELineLayer.IsRuler.html
You can get the current length using:
https://www.imageen.com/help/TIELineLayer.RulerValue.html
Nigel Xequte Software www.imageen.com |
|
|
tylin123
Taiwan
25 Posts |
Posted - Oct 09 2018 : 03:36:32
|
Hi, Nigel:
Thank you for your reply.
Because I have to maintain this old project, then I still have to follow ImageEnVect.
I know and also like to use TImageEnView, but convert TImageEnVect to TImageEnView is very trouble and complexity. So I still have to use TImageEnVect.
OK. Now, if I ignore problem of Q1 and Q2, I just want to know how to get the title text on iekRuler. Can this request be made?
Thank you.
Best regards, James Lin
|
|
|
xequte
38127 Posts |
Posted - Oct 10 2018 : 00:15:18
|
Hi James
OK, regarding Q1, what is the value for ObjBrushStyle?
https://www.imageen.com/help/TImageEnVect.ObjBrushStyle.html
To calculate the ruler length, try:
function CalcRulerLen(x1, y1, x2, y2: integer; mu: TIEUnits): double;
var
cx, cy: double;
quotelenx, quoteleny: double;
begin
IECalcUnitsPerPixel( ImageEnVect1.IO.Params.DpiX, ImageEnVect1.IO.Params.DpiY, mu, cx, cy );
quotelenx := abs( x2 - x1 ) * cx * ImageEnVect1.ScaleFactor;
quoteleny := abs( y2 - y1 ) * cy * ImageEnVect1.ScaleFactor;
Result := sqrt( quotelenx * quotelenx + quoteleny * quoteleny );
end;
Nigel Xequte Software www.imageen.com |
|
|
tylin123
Taiwan
25 Posts |
Posted - Oct 11 2018 : 01:32:21
|
Hi, Nigel:
The ObjBrushStyle setting is 'bsClear'. I think it should be no problem. Because when I adjust the zoom in/out, the background of the label on iekRuler will always change.
About another question, I tried to use the code you provided, but the calculated result is still different from the value indicated on iekRuler. for example: The iekRuler is marked 28.19, but the result of the calculation is 28.2791. Although the difference between the two is small, but it is still different. In my application, the accuracy requirements are strict. so,please help me again. Thank you!
James Lin. 2018/10/11
|
|
|
xequte
38127 Posts |
Posted - Oct 11 2018 : 18:18:50
|
Hi James
I cannot reproduce the background color issue. Can you reproduce in any of our demos, such as Vectorial\VectorEditor\
The following works for me...
function CalcRulerLen(x1, y1, x2, y2: integer; DpiX, DpiY: Integer; mu: TIEUnits; Scale: double): double;
var
cx, cy: double;
quotelenx, quoteleny: double;
begin
IECalcUnitsPerPixel( DpiX, DpiY, mu, cx, cy );
quotelenx := abs( x2 - x1 ) * cx * Scale;
quoteleny := abs( y2 - y1 ) * cy * Scale;
Result := sqrt( quotelenx * quotelenx + quoteleny * quoteleny );
end;
var
len: double;
rect: TRect;
begin
ImageEnVect1.GetObjRect( -1, rect );
len := CalcRulerLen( rect.Left, rect.Top, rect.Right, rect.Bottom,
ImageEnVect1.IO.Params.DpiX, ImageEnVect1.IO.Params.DpiY,
ImageEnVect1.ObjRulerUnit[-1],
ImageEnVect1.ScaleFactor );
lblLen.Caption := FloatToStr( len );
end;
Nigel Xequte Software www.imageen.com
|
|
|
tylin123
Taiwan
25 Posts |
Posted - Oct 11 2018 : 21:48:12
|
Hi Nigel:
Thank you for your patience. About the calculation of the CalcRulerLen(...) function, after the program check. Yes, you are right. Because I ignored the scale factor.
Unfortunately, the problem of background coloring on the label is still not knowing what the problem is. That's OK. I will continue to find out the problem.
Thanks again for your help.
James Lin Taiwan 2018/10/12 |
|
|
wealsh
13 Posts |
Posted - Nov 18 2018 : 22:28:09
|
ver:5.20 has IECalcUnitsPerPixel? |
|
|
xequte
38127 Posts |
Posted - Nov 19 2018 : 02:10:38
|
No, I don't believe so. Check hyieutils.pas to be sure.
Nigel Xequte Software www.imageen.com
|
|
|
|
Topic |
|
|
|