src/linetypes/quadrilateral.cpp

Wed, 25 May 2022 20:36:34 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 20:36:34 +0300
changeset 199
6988973515d2
parent 183
97b591813c8b
permissions
-rw-r--r--

Fix pick() picking from weird places on the screen with high DPI scaling

glReadPixels reads data from the frame buffer, which contains data after
high DPI scaling, so any reads to that need to take this scaling into account

#include "quadrilateral.h"

QString ldraw::Quadrilateral::textRepresentation() const
{
	return utility::format("%1 %2 %3 %4",
		utility::vertexToStringParens(this->points[0]),
		utility::vertexToStringParens(this->points[1]),
		utility::vertexToStringParens(this->points[2]),
		utility::vertexToStringParens(this->points[3]));
}

void ldraw::Quadrilateral::getPolygons(
	std::vector<gl::Polygon>& polygons,
	GetPolygonsContext* context) const
{
	Q_UNUSED(context)
	polygons.push_back(gl::quadrilateral(
		this->points[0],
		this->points[1],
		this->points[2],
		this->points[3],
		this->colorIndex,
		this->id));
}

void ldraw::Quadrilateral::invert(GetPolygonsContext *)
{
	//    0 1 2 3
	// -> 2 1 0 3
	std::swap(this->points[0], this->points[2]);
}

ldraw::Object::Type ldraw::Quadrilateral::typeIdentifier() const
{
	return Type::Quadrilateral;
}

QString ldraw::Quadrilateral::toLDrawCode() const
{
	return utility::format(
		"4 %1 %2 %3 %4 %5",
		this->colorIndex.index,
		utility::vertexToString(this->points[0]),
		utility::vertexToString(this->points[1]),
		utility::vertexToString(this->points[2]),
			utility::vertexToString(this->points[3]));
}

QString ldraw::Quadrilateral::iconName() const
{
	return ":/icons/linetype-quadrilateral.png";
}

QString ldraw::Quadrilateral::typeName() const
{
	return QObject::tr("quadrilateral");
}

mercurial