How to make a Block builder \drag and drop layout program? - c++

Im new to GUI programming and i want to create a program that has modules and enables its user to connect these modules together by draging and dropping them then connecting them together visually in order to create a structure for simulation.
Example software already in market :
Proteus , EV3 lego software , matlab simulink
Im planning to use glade with gtkmm although all I found on the subject is the drag and drop tutorial which isnt that usefull
I really just need guide lines and where to start on learning how to make my project
Thank you

I don't know of any GTK+ or gtkmm API that will help much, though I wish something suitably high-level existed. I have implemented something fairly similar, for designing database table diagrams:
http://www.murrayc.com/permalink/2007/02/17/glom-relationships-overview/
and for designing print layouts for database records.
I used GooCanvas via goocanvasmm, but had to implement several classes to provide generic functionality such as drag-to-move, drag-corner-to-resize, snap-to-grid, snap-to-lines, etc. My code works but I'm not very proud of it:
https://git.gnome.org/browse/glom/tree/glom/utility_widgets/canvas
Glade won't help you much with this. It's for laying out normal widgets, not for implementing specialized UIs such as this.

Related

Qt Quick controls 2.0 for embedded device

My long term goal is to make HCI development for embedded devices, and by embedded I really mean it, not phone devices.
I've been working on Qt Widgets for a month now, avoiding Qt Quick for some reasons (I feared that QML code wasn't optimize), but yesterday I have watched this video :Youtube
The speaker says at the end : "If you're making an embedded product these days, use Qt Quick, especially now in 5.8. There's no excuse not to use Qt Quick"
But on the contrary, he explains that for embedded devices we should use c++ code, not JavaScript.
I don't really get it, does it means that I have to create all my objects in c++ code and make my architecture using Qt Quick ?
I don't really get what Qt want us to do. Is it just communication, since they don't want to optimize the old and stable Qt widgets, or is Qt Quick really the solution for embedded devices ?
I personally think that Qt is not the solution for embedded devices, as they keep evolving, changing strategy, and seems not to know where they are going.
I apologize for this non-algorithmic question, and thank you for all your answers.
I can't speak to the developer's intent, nor can I speak for other developers. I can only speak to what I understand, as a developer that has been designing embedded devices for 40 years (sorry for being a number dropper).
C++ or JavaScript? I don't feel that question has too much to do with whether you use QtQuick or not. Sure, you can embed some JaveScript in QML code (with limitations), but you can also use C++ in the same code base (just not embedded in the QML). Then there's Python. Both Qt and QtQuick are programming frameworks, and are somewhat language agnostic.
My perspective is that QtQuick is a good, portable way to create your user-interface code. In my current project (a multi-axis industrial servo-control system) I use QML for the user-interface (with a little JavaScript where needed), C++ for the bulk of the higher level processing (like network control and data-streaming), C and assembly language for the lower levels (those routines executed in uC's and DSP's). QML and C++ interface together nicely, in my opinion.
I believe the speaker is getting at the idea that most if not all your business logic should be done using a C++ model back-end. It is possible to do all your logic just in QML with embedded JavaScript however, because JS is an interpreted language its performance at run-time can possibly be less than compiled C++ code(dependent on how well the C++ is written).
Essentially you only want to use JS to manipulate graphical components while using C++ with QObject models to update the QtQuick elements' individual properties.
This is mentioned in the Qt Quick Best Practices wiki,
https://wiki.qt.io/Qt_Quick_Best_Practices

Creating GUIs in Win32 C++

I'm developing my first Windows desktop application and I'm trying to figure out what the best approach would be to create the program's GUI.
I know, I know... I feel stupid for asking considering the amount of data on the subject on SO. However most answers seem outdated and I'm not sure if they fit my specific project. Also tutorials for Windows 8 'metro apps' are clogging my Google search results, which is NOT what I'm looking for.
I use Visual Studio. I've followed tutorials. I have basic knowledge of C and Java and extensive experience with PHP. I'm excited to learn C++, so I'm not looking for GUIs to create a GUI (like WinForms). I also don't care about managed code and portability for now, especially since I'm trying to avoid dependencies (i.e. users having to install .NET). As long as it runs smoothly on Vista and up, I'm happy.
The application
The software will teach basic physics to kids. I'd like to create a main area and a sidebar. The main area will feature a physics animation, say a bouncing ball, along with some Q&A. Users can zoom in to the animation to measure some stuff and answer the question. Users can track their progress in the sidebar. That's pretty much it.
What I've found so far
I'm getting a bit frustrated with MSDN. Most of their examples are given in four different languages (C#, C++, etc). I can't seem to get more than a bit of Hello World code from them.
I found a GDI API on MSDN and it seems like a good start for me. However I've read quite a few answers on SO saying creating layouts in pure C++ is really hard, that we're better of using frameworks like ATL and WTL. Since I'm also going to create (somewhat interactive) animations, I've wondered whether I should use gaming-targeted APIs like Direct2D.
Since all of this is new to me, and there are a lot of options, I don't know where to start for my particular application. Any tips would be greatly appreciated!
Using the raw Win32 API (no additional downloads or third-party helpers):
Here's a good primer (introduces dialog boxes, text boxes, buttons, etc): theForger's Win32 API Tutorial
And here's where you go from there (numeric up-downs, list boxes, combo boxes, tooltips, and more): Common Controls on MSDN. Most of these require you to #include <commctrl.h>.
I also found this to be a good resource that covered what the other two didn't: Win32 Developer - Window Assets
But the Win32 API doesn't seem like it does exactly what you want. A physics app for kids should have a more visual GUI than the API can provide. Good luck, though!
If you're ok with adding additional Frameworks, I'd suggest looking at Qt.
It allows to create the GUI from code only, has a good structure, and has an Interface for 2D drawing, if required.
If you are concerned about dependencies, you only have to include the Qt DLLs to your executables; no installation is required for the user.
To get started, see my (old) tutorial "Lessons in Windows API Programming".
But you really need a good book, such as edition 5 or earlier of Charles Petzold's classic "Programming Windows".
The problem with latest edition is that it's for C# and .NET, with Charles grabbing the tail of the "new way" at just the wrong timeā€¦
Disclaimer: I haven't checked the details of edition numbers.
Using the Windows API is the simplest, but producing advanced GUIs can take a very long time. Microsoft Foundation Class is a way to make the Windows API more user friendly and OOP. Does anyone have any experience with MFC?
Why not use some 2D C++ game engine, like HGE: http://hge.relishgames.com/overview.html.

How to switch from Qt4 MVC to Gtk MVC?

I've used Qt for some time and now I want to try Gtk. I want to write simple database application, but it looks like there is no support for sql (I'm forced to fill manually model with data). In Qt we have QSqlQueryModel and QSqlTableModel, QTableView and QTreeView. Gtk approach is more like QTableWidget and QTreeWidget. I need somehow connect to the database, get data and fill the model. Ok, but what if my table is really big? How can I implement in-place editing (Gtk model can't modify data)? Can I chain models to provide filtering like QSortFilterProxyModel? These are basic things that I use all the time writing database applications with Qt. How this can be done with Gtk?
GTK+ is more modularized than Qt, so you'll need to look up your requirements in the GObject ecosystem. libgda is what you are looking for.
Here is a non-exhaustive overview of the platform for future references.
GTK literally stands for GIMP Toolkit. It's pretty much a purely graphically set of tools for developing GUI applications, Qt on the other hand is a graphics and a whole other stack on top for databases and so on. Your best starting point is working out what DB you're going to use, then getting the development package (if it has C++ bindings), and go through the API docs for it and you'll mostly be building the functionality on your own. There's other database abstraction layers out there, so that's another route you could take.

making a gui editor

For my school project, I would like to build a gui that someone else can use to create a gui. Upon some research I saw lot of gui builders but didn't see anything along the lines of what I am looking for.
But then I did find a tutorial using C# on here
I rather create this gui editor for linux environment.
Any suggestions to where I should start? what tools I can use? Any links to any tutorials?
Any help/direction would be greatly appreciated.
P.S. I would like to add that it only needs to be very simple. like few text input fields and some button type fields that user can arrange in the order desired.
I would recommend that you not try to build your own GUI builder. It is a daunting task that you will not be able to accomplish as a school project. C++ is fully-compiled, which means that it lacks almost every feature that enables people to build meta-tools (like GUI editors) for it. This mainly has to do with the fact that C++ does not have runtime reflection (natively, anyway). Beyond that, there is no "one GUI toolkit and/or paradigm to rule them all." This makes your problem incredibly difficult to deal with.
So: I would recommend Qt, because it works on a ton of platforms, is easy to use and is just plain awesome. You could also look at the billions of other GUI toolkits like Gtk+, Tk, FLTK, YAAF, GLUI, dlib, CLX...
I'm aware that this does not actually answer the question. However, I do not think that the author is aware of how incredibly difficult the task he has set in front of himself is.
I would recommend starting by implementing it like an interpreter. Start with a very simple command line tool that takes commands like window(300, 400, "window1") and button(50,100, "button1") etc and output the code (native or whatever other GUI code you want), to a file. The goal should be to output a file that can be run and show the GUI that was designed. Once you have that, build a GUI that uses the command line functions as a back-end.
I don't have any exact links to this, but here's an example of what you could do. Gtk has the option of loading a GUI by using a class called GtkBuilder. Glade (the usual Gtk gui editor) has support for outputting it's result as an XML file that the GtkBuilder class then reads.
It would be possible for your program to output an equivalently formed XML file that GtkBuilder could read.
I have no clue as to how difficult it would be to target that XML though.
You should use GTK+ or Qt if you are targeting the linux environment. I think the first step is to learn how to program gui, which takes some time considering you are writing c/c++ code wich is different from higher level languages. Don't you think learning to code gui programs and writing a gui builder at the same time is a little bit too much.? First you should master the basics about gui and then go on to harder projects.
Here's a link to an excellent book on gtk. (Foundations of gtk+ development - Andrew Krause)
http://books.google.com/books?id=L1BZZYRrqSgC&printsec=frontcover&dq=foundations+krause&hl=es&cd=1#v=onepage&q=&f=false
And here's a great tutorial/cookbook for gtk+.
http://zetcode.com/tutorials/gtktutorial/
The official documentation is on library.gnome.org
My final advice is learn one thing at a time.

Need a client-side interactive 2D world map: best map package? Or best C++ graphics/canvas library to make one?

I need a 2d political map of the world on which I will draw icons, text, and lines that move around. Users will interact with the map, placing and moving the icons, and they will zoom in and out of the map.
The Google Maps interface isn't very far from what I need, but this is NOT web related; it's a Windows MFC application and I want to talk to a C++ API for a map that lives in the application, not a web interface. Ideally I don't want a separate server, either, and any server MUST run locally (not on the Internet). What canned map package or graphics library should I use to do this? I have no graphics programming experience.
This is strictly 2D, so I don't think something like Google Earth or WorldWind would be appropriate. Good vector graphics support would be cool, and easy drawing of bitmaps is important.
All the canned options seem web oriented. SDL is about all I know of for flexible canvas programming, but it seems like making my own map would be a lot of work for what is probably a common problem. Is there anything higher level? Maybe there's a way to interact with an adobe Flash object? I'm fairly clueless.
Perhaps:
http://www.codeplex.com/SharpMap
ESRI MapObjects
http://www.esri.com/software/mapobjects/index.html
ESRI MapObjects LT
http://www.esri.com/software/mapobjectslt/index.html
See
http://www.esri.com/software/mapobjectslt/about/mo_vs_lt.html
for a comparison of the two MapObjects feature sets.
ESRI may have a replacement to the MapObjects libraries
You could extend your search by using the term GIS (Geographic Information System). I'm sure its gonna be easier. There's a lot of stuff out there on that subject.
Here's a page I found: http://www.ucancode.net/Gis-Source-Code.htm
or: http://opensourcegis.org/
You might want to try the Mapnik C++/Python GIS Toolkit.
You can take a look at the Marble Widget, which is part of KDE's Marble project. There are Windows binaries for this, too, but they might be dependent on Qt.
Yes, Marble has also the advantage that it provides kind of a ready made solution in a single control (called "widget" in Qt's technical terms).
The dependency on Qt (which is the only dependency btw.) might also be seen as an advantage: Qt's upcoming version is licensed under the LGPL, so even if you plan to use this in a proprietary application then there shouldn't be any real worries. And of course Qt and Marble are cross-plattform and provide an API that is very intuitive and easy to understand. Unlike common GIS solutions the Marble API and the usage of the widget is rather focused on people who don't know much about GIS. So its usage is quite easy to understand even if you feel scared by technical terms used in GIS.
Marble offers several interfaces to programming:
You can either create your own Marble plugins and paint inside those or you can subclass the MarbleWidget control. For a simple HelloWorld application see:
http://techbase.kde.org/Projects/Marble/MarbleCPlusPlus