CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: UI programming

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    UI programming

    I've been wondering for a long time now what programs like AutoCAD, Mathematica, matlab, and OrCAD (an electrical engineering circuit designer and simulator suite) use to create their UIs. I know quite a bit of the Win32 API (I'm written a few UIs that use mainly only common controls) and I'm familiar with GDI but when I see programs that have interactive graphics such as the ones I've mentioned it kind of feels as if GDI's not what is being used. My question I guess is more along the lines of what technology I should use to achieve custom interactive graphs and charts where a user can move nodes/elements around and connect them in different ways, etc (this explanation is really vague, I apologize). I do realize that there's no magic library and that I will have to write something that even through numerous layers of abstraction will eventually have to deal at the pixel level and issue commands either through GDI or GTK or what have you, but as I've said before it feels as if it's not GDI that I should use for custom interactive graphics (my gut feeling says it might be a bit too slow). The multiple layers I was talking about were part of a contrived example where a class defining a schematic grid class that does the layout and arrangement of each one of the elements then proceeds to call their respective graph() functions, which then in turn do the actual drawing.
    For anyone that has created custom interactive graphs and graphics or can help me by throwing ideas at me, what underlying technologies should I rely on?
    Last edited by nuand; August 1st, 2009 at 01:59 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: UI programming

    There are several ways. One way is to use a complete software renderer. Take a look at the demos for AntiGrain. A lot of demos show some interactivity. You can also go the hardware accelerated way and use APIs like DirectX or OpenGL. You can also take a look at the new Direct2D API which is a hardware-accelerated, immediate-mode, 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and text and is designed to interoperate well with GDI, GDI+, and Direct3D.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Dec 2008
    Posts
    114

    Re: UI programming

    It's done with basic User, Shell and GDI apis.
    Nothing special (even 10 years old samples in MSDN CDs...)

  4. #4
    Join Date
    Nov 2006
    Posts
    1,611

    Re: UI programming

    Adobe Illustrator and CorelDraw are examples of applications which use mainly GDI for UI purposes. For a given level of density and complexity, if the features of GDI are sufficient for rendering, the speed is somewhat dependent on hardware and drivers.

    AutoCAD is a unique example and that series. AutoCAD is capable of 3D, and is always "running" in a 3D mode even if you're drawing in 2D - the primitives of GDI are not sufficient (entirely) to perform the "regen" in AutoCAD.

    That product was originally implemented in DOS, in C.

    Eventually it moved to 16 bit Windows, then to 32 bit Windows (now there's a 64 bit version). Along the way the moved to MFC based development.

    Early on they realized as the moved from DOS to Windows, they required a means of drawing not available in GDI, so the made their own "Heidi" layer (which can be substituted, like a plugin). This was a "mixture" of the DOS roots and Windows. All of the drawing primitives where implemented in Heidi, which somewhat took the position we now expect of a 3D graphics card, though there was a separation of 3D calculation and representation. AutoCAD must represent 3D information in ways that neither DirectX nor OpenGL can handle. At this point they have interfaces for DirectX (perhaps it's DirectShow internally I don't know)....

    The point is that such a product does use non-GDI methods to achieve feature and performance - because they're drawing requirements are not within the domain of GDI.

    3D Studio Max is another example of a "drawing program" which can be configured for GDI, OpenGL or DirectX implementation of the UI.

    GDI can draw lines and arcs, some bezier curves, ellipses, rounded rectangles, solid filled shapes and bitmaps.

    If your drawing needs go beyond that, you'll need to consider a graphics engine of some kind (2D or 3D).

    To gain leverage, you really need to work and think in C++ instead of win32.


    What you may be asking about is not just the drawing component of this subject (GDI vs DirectX or OpenGL), but of that layer of logic associated with object management which gives you a metaphor of "something to grab and move". Various graphics and game engine libraries offer features along those lines, though it may be pointing at something in order to shoot it rather than relocated a vertex.

    In an application where you need to implement the interactive UI of "rubber bands" and moving "selectable vertexes", there are example applications and yes, GDI is generally capable of that.

    There are LOTS of tricks and techniques.

    You'll need some examples, some time to practice, etc.

    The subject is full of tributaries, I could write a book. If you can narrow down a specific set of UI goals I might have more specific suggestions.
    Last edited by JVene; August 2nd, 2009 at 10:01 AM.
    If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured