Gabrielle wrote:
I have other questions about the package wx.lib.ogl, and I hope you can
give me some advice.
You need to understand that "wx.lib.ogl" is a wrapper around the OpenGL
3D graphics library. OpenGL is extremely large, very flexible, and as a
result quite complicated. The Python interface can abstract some of
this, but it you try to use the abstraction without at least SOME
understanding the OpenGL framework that lives underneath, you will find
yourself in a lot of trouble.
I chose wx.lib.ogl to develop my project for drawing function. But I found
there are same methods in different classes. For example, the class Diagram
and ShapeCanvas in package wx.lib.ogl, they all have methods to delete
shapes, add shapes, rescale shapes and rotate shapes.
No, ShapeCanvas can add and remove, but it can't rescale or rotate.
So what should I do
now? Both classes can do things I want, and there is no specific
introduction for these classes, just some methods, I don't know how to
choose...Oh,it's always difficult for me to make a choice.
A Diagram contains other drawing objects, but it doesn't know how to
draw itself. To do that, it has to be associated with a ShapeCanvas.
So, you need both, but you'd do your manipulation in the more capable
Diagram object.
About this demo, first question is, must I put a diagram onto canvas? I
tried not to set diagram,and it came an error. So why it's must to set
diagram on canvas?
The Diagram knows how to do drawing, but it doesn't have a drawing
surface -- it isn't connected to a window. To do that, you use a
ShapeCanvas. The ShapeCanvas is the glue between the window and the
Diagram. That adds flexibility, because the Diagram can be associated
with several different kinds of canvas, should the need arise.
Can you tell me the steps to draw using high level
drawing package? I mean, what should I do first and next, for example, I
should set up a canvas, then put on a diagram.
You have the steps here, in this sample. Do you doubt them? Note that
I would not necessarily call wx.lib.ogl "high level".
Based on the last question, I want to know that's the difference between
canvas and shapeCanvas, Do you have some experience to use them? I found
canvas is the direct subclass of windows and shapeCanvas is subclass of
panel.
Which "canvas" do you mean here? In this sample, "canvas" is an object
of type "ShapeCanvas".
What's more, if I use wx.lib.ogl to draw, is that mean I don't need Device
Context anymore?
In general, that's true. Speaking directly about Windows, the native
Windows drawing system is called GDI. DCs are the main mechanism you
use to do drawing in GDI. When you decide to use OpenGL, you are
allowing OpenGL to do all of the drawing for you. You don't work with
GDI anymore. As far as GDI knows, your window is just a blank white
square. The drawing goes on behind its back, so to speak.
But there is still some methods in wx.lib.ogl related to
DC, such as RecentreAll(self, dc) ,Redraw(self, dc) in class Diagram. Do you
know why?
Yes, because even though you are using OpenGL to do your drawing, your
application is still a Windows application, and your window is still a
GDI window. OpenGL will take over the drawing, but you still have to
interface with GDI sometimes.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.