How to change the default orgin of the FloatCanvas' to top left corner,

Why the default orign of the FloatCanvas is not on top left corner of the
canvas? Currently a float canvas instance is created as follow in my
project. But when try to add rectangle into it, it seems that the default
orgin is at the center of the canvas which means the (0, 0) point is at the
center of the canvas. It's a little difference between other lib's. Is it
possible to switch (0,0) upping left corner? Thanks in advance!

from wx.lib.floatcanvas import NavCanvas, FloatCanvas, Resources
FC = FloatCanvas.FloatCanvas(self, Debug=0)
Canvas.AddRectangle((-x0, y0), (size[0], -size[1]), LineWidth=0, LineColor =
(25,25,25), FillColor=(25,25,25))

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/How-to-change-the-default-orgin-of-the-FloatCanvas-to-top-left-corner-tp5719338.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Why the default orign of the FloatCanvas is not on top left corner of the
canvas?

Actually, as FloatCanvas is designed to allow arbitrary panning, the
origin isn't anywhere in particular (though maybe in the middle if you do
nothing, Ii.e not call ZoomToBB(), or Zoom() or ??? )

Currently a float canvas instance is created as follow in my

project. But when try to add rectangle into it, it seems that the default
orgin is at the center of the canvas which means the (0, 0) point is at the
center of the canvas. It's a little difference between other lib's. Is it
possible to switch (0,0) upping left corner? Thanks in advance!

You can move it anywhere you want, but I suspect what you may want is not
so much the origin moved, but the y-increasing-up convention changed to
y-increasing-down.

image software and drawing pixels on screen libs most often use
y-increasing-down convention, but math, science and also things like
postscript, use y-increasing-up, so that's what FC defaults to.

from wx.lib.floatcanvas import NavCanvas, FloatCanvas, Resources
FC = FloatCanvas.FloatCanvas(self, Debug=0)
Canvas.AddRectangle((-x0, y0), (size[0], -size[1]), LineWidth=0, LineColor

(25,25,25), FillColor=(25,25,25))

you can call one of:

FC.MoveImage(self, shift, CoordType, ReDraw=True)

FC.Zoom(self, factor, center=None, centerCoords='world')

FC.ZoomToBB(self, NewBB=None, DrawFlag=True)

to position is like you want.

You can also change the y-up convention by setting the projection function
-- there is an example somewhere I don't have time to dig up at the moment
-- though y-down projections are less well tested.

HTH,

   -Chris

···

On Thu, Dec 5, 2013 at 12:08 AM, Erxin <shangerxin@hotmail.com> wrote:

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Enclosed is a tiny app that demonstrates these methods -- comment.uncomment
them and see what they do.

By the way, no need to set a LineColor is LineWidth is zero: maybe use
LineStyle=None, for no outline.

-Chris

fc_test.py (868 Bytes)

···

On Fri, Dec 6, 2013 at 10:07 AM, Chris Barker <chris.barker@noaa.gov> wrote:

from wx.lib.floatcanvas import NavCanvas, FloatCanvas, Resources
FC = FloatCanvas.FloatCanvas(self, Debug=0)
Canvas.AddRectangle((-x0, y0), (size[0], -size[1]), LineWidth=0,
LineColor =
(25,25,25), FillColor=(25,25,25))

you can call one of:

FC.MoveImage(self, shift, CoordType, ReDraw=True)

FC.Zoom(self, factor, center=None, centerCoords='world')

FC.ZoomToBB(self, NewBB=None, DrawFlag=True)

--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython

Here it is.

-Chris

YDownDemo.py (2.16 KB)

···

On Fri, Dec 6, 2013 at 10:07 AM, Chris Barker <chris.barker@noaa.gov> wrote:

You can also change the y-up convention by setting the projection function
-- there is an example somewhere I don't have time to dig up at the moment
--

--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython

Sorry for the late replay. In the previous days I'm busy working on
developing new features for several projects in my work.

Currently the issue is bypassed by projective the coordinate by manually.
The relative codes are here:

    def __draw(self, diffinfo):
        wx.GetApp().Yield(True)
        canvas = self.__canvas
        canvas.ClearAll()

        self.__rects = rects = []
        x0, y0 = self.CanvasOrigin
        rect_width = self.CanvasWidth / diffinfo.TotalDiff
        rect_height = self.CanvasHeight / 2
        for i in xrange(diffinfo.TotalDiff):
            up_rect = Rectangle((x0 + i * rect_width, 0),
                                (rect_width, rect_height),
                                LineColor=colors0[i],
                                FillColor=colors0[i])
            down_rect = Rectangle((x0 + i * rect_width, -y0),
                                  (rect_width, rect_height),
                                  LineColor=colors1[i],
                                  FillColor=colors1[i])
            rects.append(up_rect)
            rects.append(down_rect)

I will try and learn your code samples. Thank your again! :slight_smile:

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/How-to-change-the-default-orgin-of-the-FloatCanvas-to-top-left-corner-tp5719338p5719378.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Christopher Barker wrote

You can also change the y-up convention by setting the projection
function
-- there is an example somewhere I don't have time to dig up at the
moment
--

The demo of the projection function is very clearly. It's the nice way to
solve my question. I counldn't find the detail doc about the projection
function, I guess the background logic may be:
[prj_x = [x + [orginal_center_x * [[projective_fun_x 0
]
prj_y] y] orginal_center_y] [0
projective_fun_y]]

Wish it is right. Thanks

···

On Fri, Dec 6, 2013 at 10:07 AM, Chris Barker &lt; > chris.barker@ > &gt; wrote:

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/How-to-change-the-default-orgin-of-the-FloatCanvas-to-top-left-corner-tp5719338p5719379.html
Sent from the wxPython-users mailing list archive at Nabble.com.

The demo of the projection function is very clearly. It's the nice way to
solve my question. I counldn't find the detail doc about the projection
function,

sorry about that -- there is no where near enough documentation

But the source is always there, and not TOO hard to read.

I guess the background logic may be:
[prj_x = [x + [orginal_center_x * [[projective_fun_x 0
]
prj_y] y] orginal_center_y] [0
projective_fun_y]]

at a glance, that does look about right.

-Chris

···

On Wed, Dec 11, 2013 at 10:08 PM, Erxin <shangerxin@hotmail.com> wrote:

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thank you for your helps again! :^D

Erxin

···

-----
I become to love to write program ever since got in university. The programming languages I have learned from collage lessons are C and Assembly. My interest drive me to learn all the other things. Currently I'm working at Ideal Energy (http://www.idealenergy.com) as a software developer.
My undergraduate degree is Electrical Engineering and Automation. Graduate degree is Power Electronics and Power Drives. Personal favorite programming languages are C, C++, C# and Python.
--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/How-to-change-the-default-orgin-of-the-FloatCanvas-to-top-left-corner-tp5719338p5719388.html
Sent from the wxPython-users mailing list archive at Nabble.com.