David & Jacques,

Sorry for the delay in responding. Anyway, as a workaround for this bug, I 
think you can use a very small number for the text angle (0.1 worked for me, 
but 0.01 gave the same result as 0). That way it will look like it's not 
rotated, but will not "blow up". It might even return a MBR that's pretty 
darn close to the unrotated value, letting you replace the text with a truly 
unrotated text object, if that is what you really need...

-Keith Miller
[EMAIL PROTECTED]
----Original Message Follows----
From: "Jacques Paris" <[EMAIL PROTECTED]>
Reply-To: "Jacques Paris" <[EMAIL PROTECTED]>
To: "David M Haycraft" <[EMAIL PROTECTED]>,        "MAPINFO-L" 
<[EMAIL PROTECTED]>
Subject: RE: MI-L MapBasic:  How do you alter rotated Text objects 
programatically
Date: Tue, 19 Feb 2002 09:47:17 -0500

This is certainly not one on MI's aces. Its way to handle text objects is
quite pitiful.

One thing to notice among the results of your experiment is that the height
of the un-rotated text is 0.707 degrees (I would say 0.707106781) i.e. cos45
or sin45 but I will opt for the sine because the same operation with a 30
degree rotation will give a height to the un-rotated object of 0.5

I have conducted a similar experiment but by using the create text
statement. With a lon-lat table open and editable, in the Mbwindow I used
the following statements: (I prefer to use the selector in these conditions,
it brings in more flexibility)

Dim o as object
create text "MAPINFO" (0,-0.1) (1.0,0) angle 45
        select the object
o=selection.obj
alter object o geography 7,0
update lonlat set  obj=o

That will reproduce your results. Notice also that with that technique
(using the selection.obj) only a part of the text (M and 2/3 of A) will
appear in the highlighted box. If you want to deselect that object, a red
(highlighted) block corresponding to the remaining of the text will appear
and the only way to get rid of it is to "redraw" (ctrl-D) the window. What
appears initially (MA) is closely bounded by the MBR of the 45-rotated
object.

Now, if I rerun the above set of instructions in a different order I get a
different result.

create text "MAPINFO" (0,-0.1) (1.0,0)
        select the object
o=selection.obj
alter object o geography 7,45
update lonlat set  obj=o
alter object o geography 7,0
update lonlat set  obj=o

The text flip-flops by 45 degrees around the (0,0) point without any
"change".

I think it goes with the way the create text statement uses the 4
coordinates: mini X and maxi Y becomes the anchor point (upper left corner),
and the difference between maxi Y and mini Y is used to calculate the text
height. The X maxi is the "right" bound of the MBR and if the text with its
calculated height is too long, the "extra" will not show but if the "box" is
too long, its length will not be adjusted to the text.. With your data, the
minimum x (estimated) would be 0.42

Even knowing all that. I have not been able to handle correctly and
systematically the "height" and "angle" parameters in the create text
statement. One must visualize that the (rotated) rectangle into which the
text object is inscribed is itself inscribed in the object MBR. I imagine
that the MBR is first created to "house" the rotated text (the text is first
created with a 0 angle, then rotated, then the MBR registered) and when you
ask for a zero rotation, it will simply fill in the MBR with much larger
text.

This hypothesis seems to be supported by the second experiment: the text is
first created explicitly horizontal, and its proper MBR set, then when it is
rotated, its base MBR is not reset so to speak (but if asked for, it will
show to the same as the one for the text created rotated directly), so that
when it is un-rotated, it goes back to its original self.

My conclusion is that there is a bug in the "create text" that does not
record properly the un-rotated base MBR when a non-null angle is part of the
statement.

I prefer using the createtext() function. It requires of course setting up
before hand the font style to the proper definition. In your example, it
would be something like 34 points and the instruction

o=createtext(frontwindow(), 0,45, "MAPINFO",0,8,0)

The MBR of such an object fits closely to the text, and it is its main
advantage. Drawbacks: no font control, no angle.

Jacques Paris
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of David M
Haycraft
Sent: February 18, 2002 23:17
To: MAPINFO-L
Subject: MI-L MapBasic: How do you alter rotated Text objects
programatically

It is a fact that MapInfo Pro user interface supports the ability to rotate
existing
text objects in a map layer.   Specifically if you double-click on a text
object in an
editable layer then the Text Object dialog appears, displaying StartX,
StartY, and Rotation Angle properties of the text object in addition to the
text string itself.  If you key in a new number in the Rotation Angle
control
and click OK then MapInfo rotates the text as expected around its top
left-hand corner and its size is preserved.  This procedure works equally
well if the initial Rotation Angle is zero or if it's greater than zero.

However if you try to use the MapBasic statement
    alter Object objText GEOGRAPHY, OBJ_GEO_TEXTANGLE, newAngle
to change the rotation angle of a rotated text object (not a horizontal one)
then the result is very disappointing.

The text rotates to the new angle ok BUT THE TEXT SIZE IS GREATLY INCREASED
AND THE TOP-LEFT-HAND CORNER POSITION MOVES.

Here's a demonstration of the problem.

1. Create a Long/Lat table called "t1" containing a single text object by
importing a MIF file containing:

Text
     "MAPINFO"
     0 -0.1 1.0 0.0
     Font ("Arial",0,0,0)
     Angle 45

This text object is 1.0 degrees wide by 0.1 degrees high, rotated 45 degrees
anti-clockwise
about the point (0,0).

2. open t1 in Mapinfo Pro and double-click on the object to confirm the
above properties in the Text Object dialog

3. in the Mapbasic window type:

dim objText as object
fetch first from t1
objText=t1.obj
alter object objText Geography 7,0
update t1 set obj=objText

and watch the text get screwed up.  The resultant text is 0.707.. degrees
high, not 0.1 degrees high!

Q1.  why can MapInfo get it right through the Text Object dialog but not
through the Mapbasic "alter object" statement?

Q2. is there a known work-around to the problem of changing text rotation
angles programatically, other than exporting the table to MIF (where the
creation properties of text objects are exposed correctly) and editing this
stuff?

Q3.  How does one recover in Mapbasic the "creation coordinates" for a
rotated text object?
By that I mean the coordinates that appear in a MIF file or a create text
statement .
Because of the above problem, using "alter object" to set the rotation angle
to zero and then using ObjectGeography(OBJ_GEO_MINX) etc is useless.

PS. What I'm really trying to do is programatically re-size all the text in
a Map layer, but my program fails for all text objects that have a rotation
angle other than zero. :o(

Thanks in anticipation.


David M Haycraft
Information Analysis Associates  Pty Ltd
ABN 47 085 516 105
1 Cumming Place, Wanniassa, 2903
Aust Capital Territory,  Australia
Phone/Fax:  61 + 2 + 6231 8104
Mobile: 0412 001 134
Email:  [EMAIL PROTECTED]
Web :  www.acslink.aone.net.au/actaa/iaa.htm
A MapInfo Technology Partner





_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.


_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to