octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for 2d or 3d plots


From: bpabbott
Subject: Re: Checking for 2d or 3d plots
Date: Thu, 05 Aug 2010 08:02:33 -0700 (PDT)

On 05 Aug, 2010,at 09:36 AM, Jordi Gutiérrez Hermoso <address@hidden> wrote:

What hopefully simple check can I make in graphics.cc in order to tell
if the plot is 2d or 3d? The use case is disabling rotation for 2d
plots.

Take a look at the function __calc_dimensions__ in __go_draw_axes__.m. I've cut-n-pasted it below. The input "obj" is the property structure for an axis. 

obj = get (gca);

function nd = __calc_dimensions__ (obj)
  kids = obj.children;
  nd = 2;
  for i = 1:length (kids)
    obj = get (kids(i));
    switch (obj.type)
      case {"image", "text"}
        ## ignore as they 
      case {"line", "patch"}
        if (! isempty (obj.zdata))
          nd = 3;
        endif
      case "surface"
        nd = 3;
      case "hggroup"
        obj_nd = __calc_dimensions__ (obj);
        if (obj_nd == 3)
          nd = 3;
        endif
    endswitch
  endfor
endfunction

Ben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]