src/main.h

Sun, 02 Feb 2020 00:49:32 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 02 Feb 2020 00:49:32 +0200
changeset 42
1d03dc1173cd
parent 35
98906a94732f
child 46
98645c8e7704
permissions
-rw-r--r--

made configurationoptions.txt visible in Qt Creator

/*
 *  LDForge: LDraw parts authoring CAD
 *  Copyright (C) 2013 - 2020 Teemu Piippo
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once
#include <QString>
#include <QVector>
#include <QSet>
#include <memory>
#include "basics.h"
#include "utility.h"
#include "maths.h"

namespace settingGroups
{
	// List of setting groups
	constexpr char mainwindow[] = "mainwindow";
}

namespace ldraw
{
	// Uniquely identifies a model body object
	struct Id
	{
		unsigned int value;
		constexpr bool operator<(ldraw::Id other) const
		{
			return this->value < other.value;
		}
	};
}

constexpr std::size_t operator""_z(const unsigned long long int x)
{
	return static_cast<std::size_t>(x);
}

inline QString operator""_q(const char* string, const unsigned long int length)
{
	Q_UNUSED(length)
	return QString{string};
}

inline QPointF pointToPointF(const QPoint& point)
{
	return {static_cast<qreal>(point.x()), static_cast<qreal>(point.y())};
}

inline QPoint pointFToPoint(const QPointF& point)
{
	return {static_cast<int>(std::round(point.x())), static_cast<int>(std::round(point.y()))};
}

/**
 * \brief Hints to the specified vector that a certain amount of new elements are going to be added.
 * \param vector vector to consider
 * \param amount amount of new elements to expect
 */
template<typename T>
void reserveMore(std::vector<T>& vector, std::size_t amount)
{
	vector.reserve(vector.size() + amount);
}

mercurial