[GRASS-dev] [GRASS GIS] #3320: d.text does not show anything with screen position in geographic coordinates or pixels

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
----------------------------+-------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Keywords: d.text d.graph | CPU: Unspecified
Platform: Unspecified |
----------------------------+-------------------------
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:

{{{
#!bash
d.mon wx0
# OK
d.text at=50,50 text=TestPer
# nothing
d.text at=635334.375,220456.25 -g text=TestCoor
# nothing
d.text at=200,200 -p text=TestPx
# d.mon stop=wx0
}}}

Workaround with G7:d.graph:

{{{
#!bash
d.graph -m << EOF
   color black
   move 635334.375,220456.25
   text TestGraph
EOF
}}}

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

{{{
#!c
/* 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;
}
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by mlennert):

I can confirm.

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

Moritz

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by hcho):

In [changeset:"70840" 70840]:
{{{
#!CommitTicketReference repository="" revision="70840"
d.text: Fix -p, -g (See #3320)
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by hcho):

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 -p works.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------
Changes (by hcho):

* Attachment "cairo.png" added.

d.text with the cairo driver

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------
Changes (by hcho):

* Attachment "png.png" added.

d.text with the png driver

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by 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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by annakrat):

Replying to [comment:2 hcho]:
> In [changeset:"70840" 70840]:
> {{{
> #!CommitTicketReference repository="" revision="70840"
> d.text: Fix -p, -g (See #3320)
> }}}

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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by annakrat):

Replying to [comment:4 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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:6&gt;
GRASS GIS <https://grass.osgeo.org>

#3320: d.text does not show anything with screen position in geographic
coordinates or pixels
--------------------------+----------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Display | Version: 7.2.0
Resolution: | Keywords: d.text d.graph
       CPU: Unspecified | Platform: Unspecified
--------------------------+----------------------------

Comment (by hcho):

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.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3320#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>