Opened 7 years ago

Last modified 6 years ago

#3320 new defect

d.text does not show anything with screen position in geographic coordinates or pixels

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: 7.2.4
Component: Display Version: 7.2.0
Keywords: d.text d.graph Cc:
CPU: Unspecified Platform: Unspecified

Description

G7:d.text works only with the default settings. I get nothing when using the -g (map/geo coordinates) or -p (screen pixels). Same in trunk and 7.2 (likely also 7.0).

Relevant flags and option:

  -p   Screen position in pixels ([0,0] is top left)
  -g   Screen position in geographic coordinates
  at   Screen position at which text will begin to be drawn (percentage, [0,0] is lower left)

How to reproduce:

Error: Failed to load processor bash
No macro or processor named 'bash' found

Workaround with G7:d.graph:

Error: Failed to load processor bash
No macro or processor named 'bash' found

Here is the initialization code in d.text and in d.graph:

/* d.text */
D_setup_unity(0);

/* d.graph */
if (mapcoords->answer) {
    mapunits = TRUE;
    D_setup(0);
}
else {
    D_setup2(0, 0, 100, 0, 0, 100);
    mapunits = FALSE;
}

Attachments (2)

cairo.png (7.9 KB ) - added by hcho 7 years ago.
d.text with the cairo driver
png.png (7.9 KB ) - added by hcho 7 years ago.
d.text with the png driver

Download all attachments as: .zip

Change History (13)

comment:1 by mlennert, 7 years ago

I can confirm.

Interestingly in 7.0, -p seems to work, but -g doesn't (it seems to work like -p).

Moritz

comment:2 by hcho, 7 years ago

In 70840:

d.text: Fix -p, -g (See #3320)

comment:3 by hcho, 7 years ago

I fixed d.text, but d.mon still has the same problem. I think this issue is related to d.mon rendering. If I use the cairo or png driver directly, it works fine.

d.mon start=cairo output=cairo.png --o
d.text percent size=5 at=70,70
d.text pixel size=5 at=50,50 -p
d.text mapcoors size=5 at=-402022,924563 -g   # any map coordinates inside the monitor
d.mon stop=cairo

If I use the wx0 monitor, only percent (default) works.

Last edited 7 years ago by hcho (previous) (diff)

by hcho, 7 years ago

Attachment: cairo.png added

d.text with the cairo driver

by hcho, 7 years ago

Attachment: png.png added

d.text with the png driver

comment:4 by hcho, 7 years ago

I found the default at=50,50 in DtextController in decorations.py. The default for d.text is actually the upper-left corner. This option is empty in GUI, so at=50,50 is totally unexpected. I think it shouldn't have any hard-coded default. Because of this forced default, we cannot run:

d.text input=text.txt

to display text from the upper-left corner.

in reply to:  2 comment:5 by annakrat, 7 years ago

Replying to hcho:

In 70840:

d.text: Fix -p, -g (See #3320)

Thanks for fixing this, in r70841 I hopefully fixed the background color, but otherwise it works nicely. I suggest backporting.

Last edited 7 years ago by annakrat (previous) (diff)

in reply to:  4 comment:6 by annakrat, 7 years ago

Replying to hcho:

I found the default at=50,50 in DtextController in decorations.py. The default for d.text is actually the upper-left corner. This option is empty in GUI, so at=50,50 is totally unexpected. I think it shouldn't have any hard-coded default. Because of this forced default, we cannot run:

d.text input=text.txt

to display text from the upper-left corner.

Positioning in GUI is handled separately, because it needs to be more interactive. The 50,50 is there to make sure the entire text is rendered and not cut off anywhere. Flags -p and -g won't work here easily, the GUI would have to recompute the coordinates. But that should be a separate ticket I think.

comment:7 by hcho, 7 years ago

Not only in GUI, it happens in d.mon wx0 as well (command line monitor). Flags -p and -g don't work both in g.gui GUI and d.mon WX monitors. They only work for direct cairo and png. Would it be difficult to fix -p & -g in GUI & d.mon WX monitors?

Also, I don't understand why forcing the default position at the center (50%,50%) would make sure the entire text is rendered without being cut off. We're losing a lot more space by placing text at the center instead of starting it from the upper-left corner. We also lost the capability of starting from the default upper-left corner because now we have to guess where that would be and type it in the at option. That's not ideal at all.

comment:8 by martinl, 7 years ago

Milestone: 7.2.17.2.2

comment:9 by neteler, 7 years ago

Milestone: 7.2.27.2.3

Ticket retargeted after milestone closed

comment:10 by martinl, 6 years ago

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:11 by martinl, 6 years ago

Milestone: 7.2.4
Note: See TracTickets for help on using tickets.