Hi Chris,

I've had some time to play around with this and I'm stuck on a particular
issue with the center of rotation parameter on wx.Image. I've also
subscribed to the mailing list, so hopefully this message isn't rejected.

To show you what I mean, here's a short screen capture:

https://vid.me/GuFR

Also, here's an even shorter video that uses a box placed at (0,0) rather
than that circular image arrow icon placed on the line's midpoint - which
shows the bouncing effect I'm getting a little better:

http://gfycat.com/ThoseHugeElver

The angle of the box and the arrow is updated in the OnMove function in
logicCanvas.py. In that same file, here is the section of code where I'm
grabbing a rotated image from self.Image:

https://github.com/Castronova/EMIT/blob/mike-experiment/gui/controller/logicCanvas.py#L52-69

As you suggested, I tried to make a subclass of ScaledBitmap with a
rotation feature. I'm still fairly new to Python, so I apologize if any of
this a poor implementation. Perhaps there is something I'm doing wrong
there, because it does not appear to rotate around the CENTER of the image,
as you can see in those videos. It's just off by a small, but quite
noticeable amount. Another thing that might be happening is that the
midpoint is changing as we rotate the image. I'm just not sure what the
issue is here.

If you'd like to run this yourself, feel free to pull down the latest
commit of my branch called 'mike-experiment':
https://github.com/Castronova/EMIT/tree/mike-experiment

All of the relevant code for these issues is in
gui/controller/logicCanvas.py. The way you'd actually test the arrow and
line is shown in the first video I linked to. You simply add the
"Multiplier" and "Random Number Generator" boxes by double-clicking them,
right click anywhere in the canvas and select Add Link. Then you just click
both boxes. The angle should update once you drag a box, which calls
OnMove.

One more issue that we're having that you might be able to help with is
bindings. For some reason, the bindings are not being added. There is no
warning or error - they simply don't work. Here is where we add them:

https://github.com/Castronova/EMIT/blob/mike-experiment/gui/controller/logicCanvas.py#L368-369

When our arrow was a simple Polygon object, it worked just fine. You can
see the code for that old function in createArrowOld. If you have any ideas
what might be causing either of those issues, it would be greatly helpful
for us!

Thank you again for all the help you've provided.

Mike




On Tue, Jun 23, 2015 at 9:17 AM, Chris Barker <[email protected]> wrote:

> On Tue, Jun 23, 2015 at 7:33 AM, Michael Gallagher <
> [email protected]> wrote:
>
>> Thank you very much for getting back to me. I had a quick glance over the
>> ScaledBitmap class, and I think I have a grasp on what might need to
>> happen. I'll be able to dig back into this next week most likely, and I'm
>> sure I'll have more questions.
>>
>
> Sounds good -- feel free to send question, and also be sure to let us know
> once you get it all figured out!
>
> -Chris
>
>
>
>> Mike
>>
>> On Mon, Jun 22, 2015 at 2:11 PM, Chris Barker <[email protected]>
>> wrote:
>>
>>> By the way,
>>>
>>> If you do add rotation to bitmaps, I'll probably want to add it to FC as
>>> a regular feature. So let me know how it works out.
>>>
>>> -CHB
>>>
>>>
>>> On Mon, Jun 22, 2015 at 12:03 PM, Chris Barker <[email protected]>
>>> wrote:
>>>
>>>> Note: I've cc-d this to the floatcanvas mailing list:
>>>>
>>>> http://mail.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas
>>>>
>>>> please keep the conversation there, so it will get archived.
>>>>
>>>> It is a VERY low traffic list!
>>>>
>>>>
>>>> Hi Michael,
>>>>
>>>> Glad you're finding FC useful!
>>>>
>>>> I'm currently a CS student for Utah State University and I'm working
>>>>> with the Utah Water Research Lab on this project
>>>>> <https://github.com/Castronova/EMIT>, where we're using wxPython and
>>>>> your wonderful project, FloatCanvas. I'm not a hydrologist, and I'm fairly
>>>>> new on this project so I'm not quite sure what our project is entirely 
>>>>> for.
>>>>> Needless to say though, it's going to help the University's research.
>>>>>
>>>>
>>>> at a glance it does look pretty cool.
>>>>
>>>>
>>>>> One of the things I've been assigned is to improve the UI a bit.
>>>>> Here's our FloatCanvas part of the application:
>>>>>
>>>>> [image: Inline image 1]
>>>>>
>>>>> Unfortunately the way this spline is being drawn (the folks who wrote
>>>>> this didn't realize that there was an existing spline object in
>>>>> floatcanvas) is very inefficient.
>>>>>
>>>>
>>>> at a glance, I saw a bunch of code for drawing the arrow -- did you
>>>> look at the code for the Arrow and ArrowLIne objects?
>>>>
>>>> but it looks like you may want to use a bitmap for the arrow anyway --
>>>> it does let you make it prettier.
>>>>
>>>>
>>>>
>>>>> When these boxes are dragged around, we get major frame-rate drops.
>>>>> Luckily I've been able to begin the work on sorting this out to improve
>>>>> dragging-and-dropping, and one of the things I'm struggling with is 
>>>>> knowing
>>>>> what to do about rotating a bitmap. I have this icon here:
>>>>>
>>>>> [image: Inline image 2]
>>>>>
>>>>> I would like this PNG to replace the arrow you see above in the main
>>>>> screenshot. However, this requires us to rotate the bitmap as these boxes
>>>>> are dragged around.
>>>>>
>>>> Currently I don't think there's a way to do this in FloatCanvas.
>>>>>
>>>>
>>>> nope -- I only supported axis-aligned bitmaps so far.
>>>>
>>>> The best solution I can come up with for now is to remove, and rotate
>>>>> the icon as a wxImage, and then re-add it on each frame draw. I'm not sure
>>>>> this is the best way of doing it though, and I thought I'd reach out to 
>>>>> you
>>>>> and get your opinion on the matter.
>>>>>
>>>>
>>>> yeah, you should be able to do better.
>>>>
>>>> You probably don't want the arrow to change size as you zoom, so you
>>>> are likely using a Bitmap object.
>>>>
>>>> But take a look at the ScaledBitmap object code to get an idea:
>>>>
>>>> it stores a wx.Image object.
>>>>
>>>> In the _Draw method, it scales the Image, then draws it.
>>>>
>>>> Note that it caches the scaled version, so that it doesn't need to
>>>> re-scale unless the size changes.
>>>>
>>>> So: I'd subclass, or simply copy the Bitmap object, and add an
>>>> attribute for rotation angle, then write a _Draw method that does the
>>>> rotation on the fly, similarly to how the ScaledImage object does the
>>>> re-scaling.
>>>>
>>>> That should be pretty fast, and if you cache the rotated bitmap, then
>>>> it will be blazingly fast when the angle hasn't changed.
>>>>
>>>> Also -- once you'
>>>> ve got that working, I'd either:
>>>>
>>>> Make a Group object that puts teh line and the arrow together.
>>>>
>>>> or
>>>>
>>>> make Custom DrawObject that draws both the line and the arrow.
>>>>
>>>> I always intended it to be easy to write your own DrawObjects -- but
>>>> never documented it very well...
>>>>
>>>> Do take a look at:
>>>>
>>>> http://trac.paulmcnett.com/floatcanvas
>>>>
>>>> if you haven't already -- there are a few examples there.
>>>>
>>>> And I hope you've found the examples in the demos dir in teh source:
>>>>
>>>> http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/
>>>>
>>>> There is a lot there!
>>>>
>>>> -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]
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> 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]
>>>
>>
>>
>
>
> --
>
> 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

Reply via email to