src/openedmodel.cpp

changeset 383
530d23cd4e97
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/openedmodel.cpp	Thu Jun 15 16:18:03 2023 +0300
@@ -0,0 +1,35 @@
+#include "openedmodel.h"
+#include "settings.h"
+#include "ldrawsyntaxhighlighter.h"
+
+EditableModel::EditableModel(QTextDocument* model, DocumentManager* documents, ColorTable* colorTable)
+	: QObject{documents}, model{model}
+{
+	this->tools = std::make_unique<EditTools>();
+	this->canvas = std::make_unique<PartRenderer>(model, documents, *colorTable);
+	this->axesLayer = std::make_unique<AxesLayer>();
+	this->gridLayer = std::make_unique<GridLayer>();
+	this->gridLayer->setGridMatrix(DEFAULT_GRID_MATRIX);
+	this->tools->setGridMatrix(DEFAULT_GRID_MATRIX);
+	this->canvas->addRenderLayer(this->axesLayer.get());
+	this->canvas->setLayerEnabled(this->axesLayer.get(), setting<Setting::DrawAxes>());
+	this->canvas->addRenderLayer(this->gridLayer.get());
+	this->canvas->addRenderLayer(this->tools.get());
+	new LDrawSyntaxHighlighter{model};
+	this->textcursor = std::make_unique<QTextCursor>(model);
+	QObject::connect(
+		this->tools.get(),
+		&EditTools::modelAction,
+		this,
+		&EditableModel::modelAction);
+	QObject::connect(
+		this->tools.get(),
+		&EditTools::newStatusText,
+		this,
+		&EditableModel::newStatusText);
+	QObject::connect(
+		this->tools.get(),
+		&EditTools::select,
+		this,
+		&EditableModel::select);
+}

mercurial