On Mar 21, 2014, at 4:54 PM, Nouvelle Collection < [email protected]> wrote:
Thanks Chris, I tried this demo, but here we easily get 0 to 308 because scale = 1.0 so it's easy : it's 1:1 scale, and so it's normal that everything is integer. Exactly -- if you need exact, then you need to use round numbers. The more tricky thing is to have 0 to 308 (or even 0 to 306/ 307) when scale = 0.87 or scale = 1.03. Do you have an idea on how to avoid having so many "lost pixels" ? Example : I had x = -0.34 ... 299.60 when scale = 1.03 ==> this means that 299.60 to 308 are "lost pixels". Well, 3% doesn't seem like much, but 3% of 300 is 9. So you are drawing your 308 pixel image with about 318 pixels on the screen. Though it does seem like you should be able to get within 1 pixel of the "right" value. I think I was kn my machine. One thing to check is when you get mouse move events. Perhaps they are not coming every single pixel? Try calling canvas.PixelToWorld() for points from 300-320. And see what you get. Or capture the raw mouse move event, and see what pixel cords you get. What's you use case here? Why does this precision matter? -Chris Jo 2014-03-22 0:39 GMT+01:00 Chris Barker <[email protected]>: > On Fri, Mar 21, 2014 at 12:30 PM, Chris Barker <[email protected]>wrote: > >> if you want to suggest a cleaner API for that, I could add it. >> > > got it. > > I made .Scale and .ViewPOrtCenter properties, so tehy can do the right > thing if you set them directly. So you can now do: > > class TestFrame(wx.Frame): > def __init__(self, *args, **kwargs): > wx.Frame.__init__(self, *args, **kwargs) > self.canvas =FloatCanvas.FloatCanvas(self, BackgroundColor = "DARK > SLATE BLUE") > MainSizer = wx.BoxSizer(wx.VERTICAL) > MainSizer.Add(self.canvas, 4, wx.EXPAND) > self.SetSizer(MainSizer) > img = wx.Image('mypng(309x34).png') > A = self.canvas.AddScaledBitmap(img, (0,0), > Height=img.GetHeight(), Position = 'tl') > A.Bind(FloatCanvas.EVT_FC_MOTION, self.OnMotion) > > self.canvas.Scale = 1.0 > self.canvas.ViewPortCenter = (154, -17) > > def OnMotion(self, event): > x, y = event.HitCoords[0] - event.BoundingBox[0,0], > event.BoundingBox[1,1] - event.HitCoords[1] > print self.canvas.Scale, x, y > > app = wx.App(0) > frame = TestFrame(None, title="Image hitcoords", size=(350,200)) > frame.Show(True) > app.MainLoop() > > now in SVN, along with this demo. > > -Chris > > > -- > > 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 > > [email protected] > > _______________________________________________ > FloatCanvas mailing list > [email protected] > http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas > > _______________________________________________ FloatCanvas mailing list [email protected] http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
_______________________________________________ FloatCanvas mailing list [email protected] http://mailman.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
