Results 1 to 8 of 8

Thread: Architecture Question on QGraphicsView, QGraphicsScene, QGraphicsItems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2015
    Posts
    50
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Architecture Question on QGraphicsView, QGraphicsScene, QGraphicsItems

    hmmm. That is something to think about for sure. I am doing this with a pseudo-spreadsheet portion of the app which is already done. I have a parallel data grid that mirrors the UI grid.

    Although I understand the purist route, I am going to take the easy way out for now in order to keep the deadline

    I'll have to take a look at the C++11 STL and see if it provides what we need as well. In our math-equation parser we use the following:

    #include <boost/multi_index_container.hpp>
    #include <boost/multi_index/member.hpp>
    #include <boost/multi_index/ordered_index.hpp>
    #include <boost/multi_index/mem_fun.hpp>
    #include <boost/lexical_cast.hpp>
    #include <boost/algorithm/string.hpp>

    Quote Originally Posted by d_stranz View Post
    This sounds like it might be one of those ugly cases where you need an external (topological) graph-like data structure to maintain the internal representation of the entities and their relationships, and a "parallel universe" that represents the visualization of those entities on screen and which manages the user interaction. The pragmatist in me says, "No, you could implement the entire thing in QGraphicsScene and put a serialization scheme on top of that to allow you to save and restore it" whereas the purist says "Yes, but what if you abandon Qt or Qt replaces the Graphics / View architecture with something much more flashy? Then you have to rewrite the whole thing. Better to keep the two parts of the functionality separate so your data representation can live independently of how you display it".

    I guess in my case the purist wins out most often, because I usually have a clear line between my data model and algorithms that manipulate it (written in as close to pure C++ with STL as I can manage - we've recently given the boot to boost, since most of what we use is in C++11 STL now) and the visualization and editing of the model (in Qt).

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,323
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Architecture Question on QGraphicsView, QGraphicsScene, QGraphicsItems

    I was able to replace lexical_cast, but without going back deep into the code repository I can't really tell you how. std::to_string() and std::to_wstring() work well for going the other way. lexical_cast gets many hits for being very slow because of all of the checking it does.

    You'll have trouble with multi_index, as I did with boost::bimap and boost::variant. There aren't any C++11 STL counterparts.

    There is nothing wrong with boost per se. Since we used so little of it in our data processing toolkit libraries, and the parts we used had been added to the C++11 standard, we decided to eliminate that dependency. We also have to make our libraries portable among multiple android, linux, Mac OS/X, and Windows platforms, so the less external code we have to manage the better. We also use our libraries in writing both Qt and MFC apps on Windows, so we can't use Qt's containers and algorithms there either.

    The templates I mention above are in an app built on top of our libraries. I got rid of bimap by implementing my own simple paired std::map<> template with some methods which keep the maps synchronized. boost::variant will be a lot harder.

    math-equation parser
    On my to do list is a similar spreadsheet and parser, with the addition that it also needs to understand how to parse chemical formulas and do chemical arithmetic , so that you can do things like put the molecular weight of the formula from cell A! into the cell at B1. Or add the formula from A1 to the formula from A2 and place the result in B1. Or count the number of carbon atoms in A1 and put that in B1.

  3. #3
    Join Date
    Sep 2015
    Posts
    50
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Architecture Question on QGraphicsView, QGraphicsScene, QGraphicsItems

    Thank you for the pointers. I'll look to it. The code I am working on is only Windows/Linux cross compatible so I do not have the issues that you're encountering with android, Mac OS, etc. ...

    Our app is similar idea but with physics. It's a sandbox, tutorial application for 1st year Engineering Physics courses. Our "spreadsheet" contains particles and the vectors on each row, that act on them. Each column is a time slice defineable by the user. Each cell in the spreadshee contains the calculation defined by the equation assigned to the vector. Each vector can be given an equation or a constant and it will then recursively search the rest of the spreadsheet looking for variables, which in turn recursively tries to resolve those as well. if it cannot resolve an equation (e.g.: a variable is undefined) it'll highlight it as red. It's pretty simple concept but implementation was complex, yet straight-forward. The particles and vectors added show up in the main screen (hence the question about graphics) and interact either by themselves or with each other.



    Quote Originally Posted by d_stranz View Post
    I was able to replace lexical_cast, but without going back deep into the code repository I can't really tell you how. std::to_string() and std::to_wstring() work well for going the other way. lexical_cast gets many hits for being very slow because of all of the checking it does.

    You'll have trouble with multi_index, as I did with boost::bimap and boost::variant. There aren't any C++11 STL counterparts.

    There is nothing wrong with boost per se. Since we used so little of it in our data processing toolkit libraries, and the parts we used had been added to the C++11 standard, we decided to eliminate that dependency. We also have to make our libraries portable among multiple android, linux, Mac OS/X, and Windows platforms, so the less external code we have to manage the better. We also use our libraries in writing both Qt and MFC apps on Windows, so we can't use Qt's containers and algorithms there either.

    The templates I mention above are in an app built on top of our libraries. I got rid of bimap by implementing my own simple paired std::map<> template with some methods which keep the maps synchronized. boost::variant will be a lot harder.



    On my to do list is a similar spreadsheet and parser, with the addition that it also needs to understand how to parse chemical formulas and do chemical arithmetic , so that you can do things like put the molecular weight of the formula from cell A! into the cell at B1. Or add the formula from A1 to the formula from A2 and place the result in B1. Or count the number of carbon atoms in A1 and put that in B1.
    Last edited by Caolan O'Domhnaill; 29th March 2016 at 18:19.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,323
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Architecture Question on QGraphicsView, QGraphicsScene, QGraphicsItems

    Cool. Sounds like a fun project.

Similar Threads

  1. How to render QGraphicsItems onto a QGraphicsScene properly
    By jshafferman in forum Qt Programming
    Replies: 6
    Last Post: 1st May 2014, 02:45
  2. QGraphicsScene and dynamic addition of QGraphicsItems
    By El Bazza in forum Qt Programming
    Replies: 7
    Last Post: 15th September 2012, 07:57
  3. Replies: 2
    Last Post: 28th April 2012, 08:58
  4. Question about behavior of QGraphicsView/QGraphicsScene
    By kennethadammiller in forum Newbie
    Replies: 0
    Last Post: 22nd July 2010, 09:56
  5. QGraphicsView/QGraphicsScene rendering question
    By onurozcelik in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2010, 11:23

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
  •  
Qt is a trademark of The Qt Company.