Thanks Mathias and Chris for your prompt comments,

I will work with fc2; its new functionalities and simplicity are what I need.

For now, I am going to be a user bothering you and I hope to at least
help to improve fc2 with my feedback. Something that would help is the
API documentation (just like the fc doxygen site would be enough).

I have some very basic questions about fc2, in fact I think they are
more python&wxpython doubts (see the attached program and add your own
image in line 23):
1. Line 27: How to set the order of appearance of drawed objects?
2. Line 49: How to delete a node selected with the mouse (the hit test
works fine to find the node but I can't delete it)?
3. Line 72: I am trying to show the mouse position in a status bar but
after I use the menu bar (fc2 guimode), it stops to work.

Thanks in advance,

Marcos Duarte
http://lob.iv.fapesp.br/
University of Sao Paulo, Brazil



On Mon, Nov 17, 2008 at 4:53 PM, Christopher Barker
<[EMAIL PROTECTED]> wrote:
> Marco,
>
> Thanks for your interest in FloatCanvas, and Matt, thanks for your
> assessment of the situation. A few comments:
>
>  > I am not sure whether FloatCanvas1 can handle images which are rotated
>  > and zoomed at the same time, maybe Chris will answer this.
>
> Matt is correct, FC1 does not do rotation of images. It wouldn't be too
> hard to add to the ScaledBitmap class, but it might get a bit tricky to
> translate coordinates from world to the pixel coords of the image --
> FloatCanvas doesn't have any concept of rotation, so that would have to
> be handled by the ScaledBitmap class itself.
>
>> It works quite well on windows, but other platforms like mac and gtk
>> have problems which render it unusable at this time.
>
> I thought we'd fixed the Mac issue -- I'll have to check that out again.
> And if you are on GTK, we could use a GTK tester/developer. It'll be a
> bit tricky to find the issue, but it's probably only a couple lines of
> code when you do!
>
>> From what I gathered so far this looks like we could replace
>> wx.GC with the cairo version of it. However it seems text rendering and
>> fonts are not yet implemented. Replacing wx.GC with the cairo GC would
>> probably need some testing, but it seems it's able to make floatcanvas2
>> work without the problems and on all platforms.
>
> I'm not sure about that -- you still need to get the image to the
> screen, and I think that's where the issues are. But Cairo would get us
> fully floating point coords, exactly the same rendering everywhere, and
> other output options: PDF, printing, PS, SVG?
>
>  > Of course you'd need to
>> install cairo on windows then to make it work.
>
> Yes, though I think Robin is open to the idea of bundling Cairo with
> wxPython in the future if it starts getting wider use.
>
>
>>> It sounds floatcanvas2 is going to be the official library soon.
>
> Well, I'm not sure. I think FC1 will be around for a while. I will
> hopefully soon be putting substantial efforts into an app that needs one
> or the other, and I haven't made my decision as to which I'm using.
>
> The key problem now is that with the rewrite, we've gotten some great
> new functionality and more flexibility, but also lost some features and
> maturity.
>
>>> so, I'd prefer to program with this library since the beginning but I
>>> am afraid that some functionality I might need in the next months is
>>> not implemented in floatcanvas2 yet.
>
> I'd say give it a try and post questions here, and you'll see where you
> stand.
>
> We really do need to make sure GTK and MAc are working right soon, and
> maybe you can help get it there.
>
>> Yes, as stated above there are some things that don't work. If you are
>> on windows and don't need constant-screen-sized lines fc2 should be
>> usable for your task.
>
> About the constant-screen-sized lines -- it seems with GCs, we should be
> able do it, at least for when the world-coord size of the lines or fonts
>  are greater than one, and we can kind of fudge that by scaling world
> coords up if need be, at least to get the infrastructure in place.
>
>> I think both FloatCanvasses provide the ability to do this. In fc2 you
>> can call canvas.pointToWorld( mouse_pos )
>
> if FC1, it's Canvas.PixelToWorld()
>
>> Instead of calling
>> pointToWorld yourself you can instead use the fc2 event handling for
>> this.
>
> same in FC1 - the mouse events have an extra attribute: event.Coords()
> that is the coords of the event in World Coords. See various demos.
>
>
> Do let us know what you discover.
>
> -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://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas
>
'''
Select coordinates and draw with mouse selection
'''

# import wxPython
import wx
# import the floatcanvas module
try:
    import wx.lib.floatcanvas.floatcanvas2 as fc
except:
    import floatcanvas as fc

class Drawer(object):
    def __init__(self, canvas):
        self.point = None
        self.canvas = canvas
        #Event handlers
        self.canvas.subscribe( self.OnLeftDown, 'left_down' )
        #canvas.subscribe( self.OnMove, 'move' )
        #canvas.subscribe( self.OnRightUp, 'left_up' )
        self.canvas.subscribe( self.OnRightDown, 'right_down' )
        #Show image
        img = wx.Image( 'spine2.jpg' )
        imgData = fc.arrayFromImage( img )
        self.canvas.create( 'Bitmap', imgData, pos = (0,0), look = ('white','white'), InBackground = True )
        self.canvas.create('Circle', 300, pos = (0,0), look=('red', 'red'))
        ##why the bitmap is in front of everything? How to set the order appearance of the objects?
        self.canvas.zoomToExtents()

    def OnLeftDown(self, evt):
        pos = evt.coords
        self.point = (pos[0], pos[1])
        self.drawNode = self.canvas.create('Circle', 10, pos=self.point, look=('black', 'white'))
        self.drawNode.subscribe( self.OnRightDown, 'right_down' )
        print 'Point: ', self.point
        print self.drawNode

    def onMove(self, evt):
        evt.Skip()

    def onRightUp(self, evt):
        evt.Skip()

    def OnRightDown(self, evt):
        #print evt.coords
        print evt.wx_event.GetPosition()
        node = self.canvas.hitTest(evt.wx_event.GetPosition())
        print node
        ##How to delete a node selected with the mouse?
        self.canvas.removeChild(node)

class Frame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, title="Xc3", size=(800,600))

        #Status bar
        self.statusbar = self.CreateStatusBar()
        
        #MenuBar
        self.menuBar = wx.MenuBar()
        file_menu = wx.Menu()
        item = file_menu.Append(-1, "&Exit")
        self.Bind(wx.EVT_MENU, self.OnExit, item)
        self.menuBar.Append(file_menu, "&File")
        self.SetMenuBar(self.menuBar)

        #The canvas
        canvas = fc.NavCanvas( self, backgroundColor = 'white' )
        drawer = Drawer(canvas)

        #Event handlers
        ##Neither of these event bindings work after toolbar (guimode) is used, why?:
        canvas.Bind(wx.EVT_MOTION, self.OnMotion)
        #canvas.canvasPanel.Bind(wx.EVT_MOTION, self.OnMotion)

    def OnMotion(self, event):
        #print self.canvas.events.
        self.statusbar.SetStatusText("Coordinates: %s" % str(event.GetPositionTuple()), 0)
        event.Skip()

    def OnExit(self,event):
        self.Close(True)
        #self.Destroy()


class App(wx.App):
    """Application class"""
    def OnInit(self):
        self.frame = Frame(None)
        self.frame.Show(True)
        self.SetTopWindow(self.frame)
        return True

def main():
    app = App()
    app.MainLoop()

if __name__ == '__main__':
    main()
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to