Results 1 to 3 of 3

Thread: Conway's life visualization

  1. #1
    Join Date
    Oct 2010
    Posts
    12
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Conway's life visualization

    I'm writing simple Conway's life using qt and MVC design pattern.
    My program consists of 3 classes: lifeModel, Controller and Window. Window class visualizes every generation of cells (it's 2d matrix, as it's generally known). So I'm looking for the best way to implement this class.
    For example, I picked QSpinBox to set matrix size, QPushButton to start generation, QGraphicsView to display matrix and QLayout to place elements on main QWidget.
    Is QGraphicsView optimal for this case? Are there any better solutions?
    Last edited by qutron; 30th December 2010 at 14:07.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Conway's life visualization

    Is QGraphicsView optimal for this case?
    Well, it depends what is 'optimal' in your case...
    QGraphicsView is not pixel based, which allows you to work on logical coordinates, and resize the view to any size you like, with out worrying about sizes and pixels - and their real position during paint time.
    So in that sense you probably are better off with QGraphicsView.
    But there might be other considerations that might counter that, which I don't see at the moment.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    qutron (30th December 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Conway's life visualization

    It will depend on how you intend to display your matrix. If you use thousands of individual QGraphicsItems, you will run into trouble pretty quickly, as the view calls each individual paint() method; you'll probably start noticing slowdowns with several hundred items on display.

    On the other hand, if you have a single QGraphicsItem that paints all of the matrix cells, painting will be much more efficient. You could similarly paint the view's background to achieve the same effect.

    Side note: I read the original Mathematical Games column where Life was introduced to the public at large back in the early 70s. I spent a shameful amount of time working simple configurations by hand, with a pencil and graph paper. Much later, my first foray into assembly language was a Life program written for the Commodore 64; this was followed a few years later with a progarm on the Amiga that made use of the specialized graphics hardware to turn the blitter chip into a half-adder for a pretty astonishing (at the time) speedup.

    I would imagine that today's machines would handle high resolution at very high speeds, even when wrapped in several abstraction layers. Have fun.

  5. The following user says thank you to SixDegrees for this useful post:

    qutron (3rd January 2011)

Similar Threads

  1. Strange output: Can't compile for WinCE to save my life!
    By codeslicer in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2010, 14:55
  2. Visualization and Threads
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2009, 13:13
  3. Graph visualization library for QT4
    By YaK in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2009, 15:18
  4. freeing my memory (life should be lived forwards)
    By baray98 in forum General Programming
    Replies: 13
    Last Post: 25th September 2007, 23:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.