Scale the rendering in ogl

Hello,

I am a newbie to wxPython and love using it. Simple and very effective.

I started with the ogl example from demo code and added my rectangles and lines into the drawing area. As my drawing area is 1200x1000, they go out of visible area. How do I make the entire drawing visible and not use the scrolling. I think I need to map the real world (1200x1000) to the visible area. How and where I do it?

Thank you

Someone else may be able to tell you if OGL is scalable, but if not, you’ll have to scale yourself.

But check out wx.lib.floatcanvas – it is designed to be fully scalable.

HTH,

-Chris

···

On Aug 8, 2014, at 7:53 AM, kruvva kruvva@gmail.com wrote:

Hello,

I am a newbie to wxPython and love using it. Simple and very effective.

I started with the ogl example from demo code and added my rectangles and lines into the drawing area. As my drawing area is 1200x1000, they go out of visible area. How do I make the entire drawing visible and not use the scrolling. I think I need to map the real world (1200x1000) to the visible area. How and where I do it?

Thank you

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

You might be able to take a screenshot, scale the image, draw it onscreen,
then tranlate mouse events to the ogl area coordinates for dragging.

you are really using the wrong tool if you need to do that!

-CHB

···

On Fri, Aug 8, 2014 at 1:53 PM, Nathan McCorkle <nmz787@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

Thank you, Chris. That’s what I have been reading on the posts. I’ll look for an example that is using FloatCanvas with scaling. If you know some example please forward me.

Basically my drawing has couple of rectangles with labels and are connected by broken line segments with arrows at one end. The real world dimensions of the drawing may change from case to case. That is why I need to scale the drawing to fit in to the canvas.

···

On Friday, August 8, 2014 1:56:36 PM UTC-7, Chris Barker wrote:

On Fri, Aug 8, 2014 at 1:53 PM, Nathan McCorkle nmz...@gmail.com wrote:

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

you are really using the wrong tool if you need to do that!

-CHB

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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....@noaa.gov

Hi,

Thank you, Chris. That's what I have been reading on the posts. I'll look for an example that is using FloatCanvas with scaling. If you know some example please forward me.

Check out the wxPython demo for FloatCanvas.

BTW, I looked and played a bit with your code as drawing with wxPython is something I don't fully understand. One thing I didn't understand in your code was the use of two different buffers.

When I tried your code I couldn't get it to work when using wxPython Phoenix, so I started to change things around and came up with the attached. Heavily inspired by the code Chris did some time ago on DoubleBufferedDrawing - DoubleBufferedDrawing - wxPyWiki

I could not get transparency to work on drawn objects. I only got it on the whole frame, but I don't think that is what you were looking for.

Anyhow attached is what I came up with which does behave the same with 2.9 and 3.0Phoenix. It doesn't do any scaling but the buffer auto adapts to the screen size.

Werner

bitmapDrawing.py (2.49 KB)

···

On 8/9/2014 0:44, kruvva wrote:

I switched from OGL to FloatCanvas and it was real good decision. I was able to do scaling and coordinate transformation pretty easily. Thanks for the direction.

I have a problem with AddArrowLines for vertical lines. The arrows are upside down. Here is the code I used:

self.canvas.AddArrowLine((edge.points[nPoints-2], edge.points[nPoints-1]), LineWidth = 3, ArrowHeadSize = 10, ArrowHeadAngle = 45)

BTW, I use the YDownProjection in my Canvas, as I need my top left corner to be (0, 0).

Could some one help.

···

On Friday, August 8, 2014 3:44:02 PM UTC-7, kruvva wrote:

Thank you, Chris. That’s what I have been reading on the posts. I’ll look for an example that is using FloatCanvas with scaling. If you know some example please forward me.

Basically my drawing has couple of rectangles with labels and are connected by broken line segments with arrows at one end. The real world dimensions of the drawing may change from case to case. That is why I need to scale the drawing to fit in to the canvas.

On Friday, August 8, 2014 1:56:36 PM UTC-7, Chris Barker wrote:

On Fri, Aug 8, 2014 at 1:53 PM, Nathan McCorkle nmz...@gmail.com wrote:

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

you are really using the wrong tool if you need to do that!

-CHB

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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....@noaa.gov

I switched from OGL to FloatCanvas and it was real good decision. I was
able to do scaling and coordinate transformation pretty easily. Thanks for
the direction.

I have a problem with AddArrowLines for vertical lines. The arrows are
upside down. Here is the code I used:

self.canvas.AddArrowLine((edge.points[nPoints-2], edge.points[nPoints-1]),
LineWidth = 3, ArrowHeadSize = 10, ArrowHeadAngle = 45)

BTW, I use the YDownProjection in my Canvas, as I need my top left corner
to be (0, 0).

That's a key "BTW" -- while I attempted to make objects projection-clean,
there are some bugs. Flipping up and down is a bit tricky to get right.

Take a look at the ArrowLine code -- it'll need some fixing. Not sure when
I'll get a chance to do that myself, but if you figure it out, patches are
readily accepted.

You may also want to do the detailed discussion on the floatcanvas list:

http://mail.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

It's very low traffic, but I read it, and at last a few other fairly
sophisticated users sometimes chime in with good advice.

-Chris

···

On Sun, Aug 10, 2014 at 6:40 PM, kruvva <kruvva@gmail.com> wrote:

Could some one help.

On Friday, August 8, 2014 3:44:02 PM UTC-7, kruvva wrote:

Thank you, Chris. That's what I have been reading on the posts. I'll look
for an example that is using FloatCanvas with scaling. If you know some
example please forward me.

Basically my drawing has couple of rectangles with labels and are
connected by broken line segments with arrows at one end. The real world
dimensions of the drawing may change from case to case. That is why I need
to scale the drawing to fit in to the canvas.

On Friday, August 8, 2014 1:56:36 PM UTC-7, Chris Barker wrote:

On Fri, Aug 8, 2014 at 1:53 PM, Nathan McCorkle <nmz...@gmail.com> >>> wrote:

You might be able to take a screenshot, scale the image, draw it
onscreen, then tranlate mouse events to the ogl area coordinates for
dragging.

you are really using the wrong tool if you need to do that!

-CHB

--
You received this message because you are subscribed to the Google
Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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....@noaa.gov

--

You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

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

BTW,

There are a bunch of Demos of various FloatCanvas features here:

http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/FloatCanvas/Demos/

each of those is a stand-alone app demoing some feature or another.

  • Chris
···

On Mon, Aug 11, 2014 at 8:52 AM, Chris Barker chris.barker@noaa.gov 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

On Sun, Aug 10, 2014 at 6:40 PM, kruvva kruvva@gmail.com wrote:

I switched from OGL to FloatCanvas and it was real good decision. I was able to do scaling and coordinate transformation pretty easily. Thanks for the direction.

I have a problem with AddArrowLines for vertical lines. The arrows are upside down. Here is the code I used:

self.canvas.AddArrowLine((edge.points[nPoints-2], edge.points[nPoints-1]), LineWidth = 3, ArrowHeadSize = 10, ArrowHeadAngle = 45)

BTW, I use the YDownProjection in my Canvas, as I need my top left corner to be (0, 0).

That’s a key “BTW” – while I attempted to make objects projection-clean, there are some bugs. Flipping up and down is a bit tricky to get right.

Take a look at the ArrowLine code – it’ll need some fixing. Not sure when I’ll get a chance to do that myself, but if you figure it out, patches are readily accepted.

You may also want to do the detailed discussion on the floatcanvas list:

http://mail.paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

It’s very low traffic, but I read it, and at last a few other fairly sophisticated users sometimes chime in with good advice.

-Chris

Could some one help.

On Friday, August 8, 2014 3:44:02 PM UTC-7, kruvva wrote:

Thank you, Chris. That’s what I have been reading on the posts. I’ll look for an example that is using FloatCanvas with scaling. If you know some example please forward me.

Basically my drawing has couple of rectangles with labels and are connected by broken line segments with arrows at one end. The real world dimensions of the drawing may change from case to case. That is why I need to scale the drawing to fit in to the canvas.

On Friday, August 8, 2014 1:56:36 PM UTC-7, Chris Barker wrote:

On Fri, Aug 8, 2014 at 1:53 PM, Nathan McCorkle nmz...@gmail.com wrote:

You might be able to take a screenshot, scale the image, draw it onscreen, then tranlate mouse events to the ogl area coordinates for dragging.

you are really using the wrong tool if you need to do that!

-CHB

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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....@noaa.gov

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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