src/widgets/matrixeditor.cpp

changeset 1406
37fffb682d2f
parent 1403
7a2d84112983
child 1408
0d6162662040
--- a/src/widgets/matrixeditor.cpp	Sun Jun 17 14:06:03 2018 +0300
+++ b/src/widgets/matrixeditor.cpp	Sun Jun 17 16:13:24 2018 +0300
@@ -15,7 +15,7 @@
 			matrixCell(i, j),
 			qOverload<double>(&QDoubleSpinBox::valueChanged),
 			this,
-			&MatrixEditor::matrixChanged
+			&MatrixEditor::matrix3x3Changed
 		);
 	}
 
@@ -28,6 +28,15 @@
 			&MatrixEditor::scalingChanged
 		);
 	}
+
+	for (QDoubleSpinBox* spinbox : {ui.positionX, ui.positionY, ui.positionZ})
+	{
+		connect(
+			spinbox,
+			qOverload<double>(&QDoubleSpinBox::valueChanged),
+			[&](){ emit matrixChanged(this->matrix()); }
+		);
+	}
 }
 
 MatrixEditor::MatrixEditor(QWidget* parent) :
@@ -109,6 +118,7 @@
 					{
 						cellWidget->setValue(cellValue);
 					});
+					emit matrixChanged(this->matrix());
 				}
 			}
 
@@ -135,7 +145,7 @@
 /*
  * Updates the appropriate scaling vector element when a matrix cell is changed.
  */
-void MatrixEditor::matrixChanged()
+void MatrixEditor::matrix3x3Changed()
 {
 	QDoubleSpinBox* cellWidget = static_cast<QDoubleSpinBox*>(this->sender());
 
@@ -147,6 +157,7 @@
 		{
 			spinbox->setValue(this->matrixScaling(column));
 		});
+		emit matrixChanged(this->matrix());
 	}
 	catch (const std::out_of_range&) {}
 }
@@ -161,7 +172,13 @@
 		transformationMatrix(i, j) = this->matrixCell(i, j)->value();
 	}
 
-	transformationMatrix.translate(ui.positionX->value(), ui.positionY->value(), ui.positionZ->value());
+	QVector4D translation {
+		(float) ui.positionX->value(),
+		(float) ui.positionY->value(),
+		(float) ui.positionZ->value(),
+		0.0f
+	};
+	transformationMatrix.setColumn(3, translation);
 	return transformationMatrix;
 }
 

mercurial