Fixed a possible crash in the orthogonal map renderer

The function drawing tile layers was not always keeping the tiles it
would try to draw within bounds of the tile layer. This effected the
Terrain tool preview and possibly other tools as well.

Closes #756
Use Qt 4-compatible qmath.h header

The QtMath alias was apparently added with Qt 5.