Hello all,

I'm new to plplot.  While playing with examples I have found that x01
behaves strangely, in particular the "-locate" switch.

After reading some code, I've found that xcairo_get_cursor() in
drivers/cairo.c calls some X API to get a mouse event.  But X uses a
coordinate system where origin is located in top-left corner and Y
axis goes down, while plplot uses a coordinate system with Y axis
going up.

Thus, plGetCursor() call works incorrectly, that is, it returns wrong
world coordinates, Y axis is inverted.

I have reduced x01 to a small testcase.  Try clicking on the plot --
you'll get "plGetCursor() == 0".  Try clicking on the black area
below, you'll get some coordinates.

I've verified that the bug exists in the latest trunk.

Regards,
Dmitri Gribenko

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/
#include <math.h>
#include <string.h>
#include <ctype.h>

#include <plplot.h>
#include <plevent.h>

int main(int argc, const char *argv[])
{
  /* Parse and process command line arguments */
  plparseopts(&argc, argv, PL_PARSE_FULL);

  /* Initialize plplot */
  plsdev("xcairo");
  plssub(1, 2);
  plinit();

  /* Draw the box and grid */
  plenv(0.0, 15.0, 0, 1.0, 0, 2);

  /* Let's get some user input */
  PLGraphicsIn gin;
  for (;;) {
    if (! plGetCursor(&gin))
    {
      printf("plGetCursor() == 0\n");
      continue;
    }
    if (gin.keysym == PLK_Escape)
      break;

    pltext();
    if (gin.keysym < 0xFF && isprint(gin.keysym)) 
      printf("subwin = %d, wx = %f,  wy = %f, dx = %f,  dy = %f,  c = '%c'\n",
          gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY, gin.keysym);
    else
      printf("subwin = %d, wx = %f,  wy = %f, dx = %f,  dy = %f,  c = 0x%02x\n",
          gin.subwindow, gin.wX, gin.wY, gin.dX, gin.dY, gin.keysym);

    plgra();
  }

  plend();
  exit(0);
}

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to