Mon, 20 Jun 2022 21:14:17 +0300
Fix pick scene rendering: we cannot use glReadPixels when using multisampling, so we need to render the pick scene to a separate frame buffer
#include "circletooloptionswidget.h" static QString circularPrimitiveTypeName(CircularPrimitive::Type type) { switch (type) { case CircularPrimitive::Circle: return CircleToolOptionsWidget::tr("Circle"); case CircularPrimitive::Disc: return CircleToolOptionsWidget::tr("Disc"); case CircularPrimitive::Cylinder: return CircleToolOptionsWidget::tr("Cylinder"); case CircularPrimitive::CylinderOpen: return CircleToolOptionsWidget::tr("Cylinder open"); case CircularPrimitive::CylinderClosed: return CircleToolOptionsWidget::tr("Cylinder closed"); case CircularPrimitive::DiscNegative: return CircleToolOptionsWidget::tr("Disc negative"); case CircularPrimitive::Chord: return CircleToolOptionsWidget::tr("Chord"); } return ""; } CircleToolOptionsWidget::CircleToolOptionsWidget(QWidget *parent) : QWidget{parent} { this->ui.setupUi(this); for (int i = 0; i < CircularPrimitive::NUM_TYPES; ++i) { const auto type = static_cast<CircularPrimitive::Type>(i); this->ui.type->addItem(circularPrimitiveTypeName(type), type); } connect(ui.segments, qOverload<int>(&QSpinBox::valueChanged), this, &CircleToolOptionsWidget::handleInputChange); connect(ui.divisions, &QComboBox::currentTextChanged, this, &CircleToolOptionsWidget::handleInputChange); connect(ui.type, &QComboBox::currentTextChanged, this, &CircleToolOptionsWidget::handleInputChange); } CircleToolOptionsWidget::~CircleToolOptionsWidget() { } unsigned int CircleToolOptionsWidget::segments() const { return this->ui.segments->value(); } unsigned int CircleToolOptionsWidget::divisions() const { bool ok; const int divs = this->ui.divisions->currentText().toInt(&ok); if (ok) { return divs; } else { return 16; } } CircularPrimitive::Type CircleToolOptionsWidget::type() const { return this->ui.type->currentData().value<CircularPrimitive::Type>(); } void CircleToolOptionsWidget::handleInputChange() { const int olddivs = this->ui.segments->maximum(); const int newdivs = this->divisions(); if (olddivs != newdivs) { this->ui.segments->setMaximum(newdivs); this->ui.segments->setValue(this->segments() * newdivs / olddivs); } const qreal ratio = static_cast<qreal>(this->segments()) / newdivs; this->ui.ratio->setText(QString::number(ratio, 'g', 4)); Q_EMIT this->optionsChanged(CircleToolOptions{ .fraction = CircularFraction{this->segments(), this->divisions()}, .type = this->type(), }); }