CloudCompare Survey 2018

CloudCompare is open source software for viewing and manipulating 3D point clouds and meshes. I started participating in the project several years ago to build and package it for macOS and have continued to contribute to it since then.

CloudCompare

CloudCompare on macOS

(The source code for CloudCompare is available on GitHub.)

Last year (2018) I initiated a user survey to get a better idea who is using CloudCompare and to solicit feedback from our users. I set it up using Google Forms and we received 330 responses over the course of about 10 months.

I really intended the survey for internal use to help guide us, but Noemi Roecklinger asked via Twitter about the results so I thought I would put some of them up here in case others are interested.

Continue reading

Crash Reporting For MinGW 32 (Windows) and Clang (macOS) With Qt

I recently had a customer describe some very random crashes with my software. There didn’t seem to be a pattern or a way for me to reproduce the problems locally to debug them. So my first thought was to get him to install a version with some kind of crash reporting tooling so I could get a stack trace to help track down the issue.

I’d looked into implementing some form of crash reporting quite a while ago, but it was never a very high priority for me because I don’t get a lot of bug reports. In this case though it seemed like it would be easiest if I could produce a version of my software with some built-in stack tracing.

The first thing I did was to look at what libraries were available for this. My criteria were:

  • simple to use/integrate with a Qt application
  • works with the MinGW 32-bit compiler on Windows and the clang compiler on macOS
  • inexpensive (or free!)
  • usable in commercial software

The most promising were BreakPad (older) or CrashPad (newer) from Google. From what I understand, Breakpad no longer works on macOS which is why they switched to CrashPad. Unfortunately CrashPad doesn’t handle 32-bit MinGW builds. The reason I’m stuck with the 32-bit version is that Qt currently ships its MinGW builds of the libraries and toolchain using the 32-bit MinGW 4.9.2 compiler.

So after a lot of searching and piecing things together, I’ve created something that works and fits my criteria. It’s very simple – all it does is save the stack trace to a file that the user can send me – and requires some instructions to the user to work with it. If I wanted to get fancier I could have it automatically post the information to a web server, but for now this is simple and it works.

It might work on Linux too since the code path for macOS should be POSIX compliant, though I haven’t tried it. It could also be extended to handle MSVC compiles (or maybe it already does!), but I don’t use that compiler so I can’t test it.

I used many different sites in my search, but my primary sources were Catching Exceptions and Printing Stack Traces for C on Windows, Linux, & Mac by Job Vranish, Printing a Stack Trace with MinGW by Daniel Holden, and the C++ name mangling article on Wikipedia.

Continue reading

Code Coverage Of Unit Tests Using Qt 5 On macOS

Qt Library

Qt Framework

I was inspired while watching a talk by Kevin Ottens about refactoring OpenGL code in Qt to take a look at gcov & lcov. gcov is used to analyze code coverage – which lines of code have actually been executed while running an application. lcov is a tool that can produce HTML reports from the gcov output.

If you have a suite of unit tests that you run on your code, you can use these tools to see which the lines of code are covered by your tests and which are not.

I couldn’t find a decent primer on how to set this up properly for my Qt projects on macOS so I could run it from Qt Creator, so I thought I’d write up how I did it.

Continue reading

Using C++11 Lambdas As Qt Slots

Qt Library

Qt Framework

I have an old codebase I started writing using the Qt 3.x framework—a little while before Qt4 was released. It’s still alive! I still work on it, keeping up-to-date with Qt and C++ as much as possible, and I still ship the product. Over the years I have moved the codebase along through Qt4 to Qt5, and on to compilers supporting C++11. One of the things I’ve sometimes found a little excessive is declaring slots for things that are super short and won’t be reused.

Here’s a simplified example from my older code that changes the title when a project is “dirty” (needs to be saved):

(Aside: If you are wondering about my naming convention, I developed a style when using Qt early on (c. 2000) where signals are named signalFoo() and slots are named slotFoo(). This way I know at a glance what the intent is. If I’m about to modify a slot function I might take an extra minute to look around since most IDEs can’t tell syntactically where it’s used in a SLOT() macro. In this case you have to search for it textually.)

Thanks to C++11 lambdas and Qt’s ongoing evolution, these short slots can be replaced by a more succinct syntax. This avoids having to declare a method in your class declaration and shortens your implementation code. Both desirable goals!

Let’s take a look.

Continue reading

QSignalMapper Example Revisited

Qt Library

Qt Library

Several years ago I wrote a short piece on QSignalMapper to give a quick example of how it can be used. Since then, Qt5 has been released and C++11 is now A Thing.

One of the cool things introduced in Qt5 is a new overload for the QObject::connect() method:

This means we can use function pointers instead of the old (char *) based method. One of the big advantages of using the new method is that it can check signal/slot connections at compile-time instead of only at run-time. If the signature of either the sender or receiver changes the code will fail to compile. (If you are using C++11 and like to write “clever” code, you can now use lambda expressions as well!) There’s a decent overview of the new method in this blog post by Olivier Goffart.

I recently started updating my aging codebase to Qt5 and C++11 and one of the things I’m changing is all my connections to use the new format. I ran into an issue almost immediately that I thought I’d document in case I can save someone some time.

Continue reading

Qt Patches: QGraphicsView & QImageWriter

QGraphicsView

Two and a half years ago I wrote about a UX bug with QGraphicsView where it would reset the selection in the view if you tried to extend it with a rubberband selection. I have been using those changes in the version of Qt I maintain for my software.

I finally took the time to figure out how to use the gerrit code review system for submitting patches to the Qt project, and worked with several other developers to get it in shape for merging into the codebase for Qt 5.5.

Qt Library

Qt Library

The way I implemented the changes in my old post was inelegant but functional, so I cleaned it up for submission. Then, based on suggestions from Andreas Hanssen, Dominik Haumann, and Thorbjørn Martsum, took it to the next level to make it elegant. I was even forced to add tests before it would be accepted! <gasp> (Thanks again guys!)

The changes will appear in Qt 5.5, but they will not be backported to Qt4. I have, however, created patches for both if you need to use them:

Qt4 Patch: QGraphicsView_Rubberband_Select_Qt4_patch.diff

Qt5 Patch: QGraphicsView_Rubberband_Select_Qt5_patch.diff


QImageWriter

I also revisited my patch from three years ago for QImageWriter which added the ability to turn on the optimize and progressive scan switches for writing JPEGs, which I also was maintaining in my own version of Qt.

This work had input from another developer, Gunnar Sletta, and became a better commit because of it (thanks Gunnar!).

These changes will also be part of Qt 5.5 and won’t be backported to Qt4. I have created patches for both Qt4 and Qt5 if you need them:

Qt4 Patch: QImageWriter_Qt4_patch.diff

Qt5 Patch: QImageWriter_Qt5_patch.diff


I hope these changes and patches are useful to someone out there. Based on this positive experience I hope to contribute more small changes I have lying around somewhere…

Converting Between cv::Mat and QImage or QPixmap

In a previous article, I outlined how to compile OpenCV for Mac OS X and to build and run a small example. In that post I used OpenCV‘s High-Level GUI (highgui) module to display a simple interface using the Qt framework. This is great if you’re writing a one-off program or are just experimenting with OpenCV, but how do you interface with your own Qt-based project if you don’t want to (or can’t) use the highgui module?

OpenCV Library

OpenCV Library

+

Qt Library

Qt Library

The first hurdle is converting between data formats so you can work with images in both OpenCV and Qt. So how do you move an image’s data between a cv::Mat and a QImage or QPixmap so you can display it in a widget?

In this article, I present some functions to handle these conversions and explain how to use them.

Continue reading