bugGNU Octave - Bugs: bug #54742, graphics root property...

 
 

bug #54742: graphics root property "Units" cannot be set to characters

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Thu 27 Sep 2018 10:38:29 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  mmuetzel
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 28 Sep 2018 05:45:29 PM UTC, comment #3: 

This works for me, with the caveat mentioned in the FIXME that it's a hard coded constant conversion from pixels to characters for now.

Mike Miller <mtmiller>
Group Member
Thu 27 Sep 2018 04:38:52 PM UTC, comment #2: 

For the second question, take a look at graphics.cc.  The code below is from the convert_position function.


  else if (from_units.compare ("characters"))
    {
      if (res <= 0)
        res = xget (0, "screenpixelsperinch").double_value ();

      double f = 0.0;

      // FIXME: this assumes the system font is Helvetica 10pt
      //        (for which "x" requires 6x12 pixels at 74.951 pixels/inch)
      f = 12.0 * res / 74.951;


I used these conversion factors in root_figure::properties::update_units to add a "characters" conversion.  It seems to work, so I also added a BIST test for it and pushed the change here: https://hg.savannah.gnu.org/hgweb/octave/rev/7d3f666d0ef8.

Marking as Ready for Test.

Rik <rik5>
Group administrator
Thu 27 Sep 2018 03:59:42 PM UTC, comment #1: 

Just offering up the ability to set/get the root property is quite easy.  That is line 2925 of graphics.in.h


      radio_property units U , "inches|centimeters|normalized|points|{pixels}"


Just change it to add "characters" as an option as is done for figure


      radio_property units Su , "{pixels}|normalized|inches|centimeters|points|characters"


I made that change here: https://hg.savannah.gnu.org/hgweb/octave/rev/06c41d1ae5b1.

I don't claim that this solves the question of the original poster which is how to determine the screen resolution in characters rather than pixels.

Rik <rik5>
Group administrator
Thu 27 Sep 2018 10:38:29 AM UTC, original submission:  

As reported on the mailing list [1], Octave errors if one tries to set the graphics root property "Units" to characters.
This should be possible at least for compatibility with Matlab. [2]

I'll try and upload a possible fix within the next days.

[1]: http://octave.1599824.n4.nabble.com/Cannot-set-units-of-graphics-root-to-characters-td4689467.html
[2]: https://de.mathworks.com/help/matlab/ref/matlab.ui.root-properties.html#buc8_0n-Units

Markus Mützel <mmuetzel>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-28 mtmiller StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-09-27 rik5 Item GroupUnexpected Error or Warning Matlab Compatibility
        StatusConfirmed Ready For Test

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code