--- a/src/document.cpp Sat Jun 11 15:20:24 2022 +0300 +++ b/src/document.cpp Sun Jun 12 20:47:04 2022 +0300 @@ -23,41 +23,38 @@ #include "model.h" #include "ui/objecteditor.h" -EditorTabWidget::EditorTabWidget( +EditTools::EditTools( Model* model, - DocumentManager* documents, const ColorTable& colorTable, - QWidget* parent) : - QWidget{parent}, + QObject* parent) : + QObject{parent}, colorTable{colorTable}, - canvas{new Canvas{model, this, documents, colorTable, this}}, model{model}, vertexMap{model} { - this->setMouseTracking(true); - connect(this->canvas, &Canvas::mouseClick, this, &EditorTabWidget::canvasMouseClick); - connect(this->canvas, &Canvas::mouseMove, this, &EditorTabWidget::canvasMouseMove); - connect(this->canvas, &Canvas::newStatusText, this, &EditorTabWidget::newStatusText); +#if 0 + connect(this->canvas, &Canvas::mouseClick, this, &EditTools::canvasMouseClick); + connect(this->canvas, &Canvas::mouseMove, this, &EditTools::canvasMouseMove); + connect(this->canvas, &Canvas::newStatusText, this, &EditTools::newStatusText); connect(this->model, &Model::dataChanged, this->canvas, qOverload<>(&Canvas::update)); connect(&this->vertexMap, &VertexMap::verticesChanged, [&]() { - this->canvas->rebuildVertices(this); + this->canvas->rebuildVertices(&this->vertexMap); }); this->canvas->drawState = &this->drawState; - QVBoxLayout* layout = new QVBoxLayout{this}; - layout->addWidget(this->canvas); +#endif } -EditorTabWidget::~EditorTabWidget() +EditTools::~EditTools() { } -void EditorTabWidget::applyToVertices(VertexMap::ApplyFunction fn) const +void EditTools::applyToVertices(VertexMap::ApplyFunction fn) const { this->vertexMap.apply(fn); } -void EditorTabWidget::setEditMode(EditingMode mode) +void EditTools::setEditMode(EditingMode mode) { this->drawState.mode = mode; } @@ -87,8 +84,9 @@ return any(points, std::bind(isclose, std::placeholders::_1, pos)); } -void EditorTabWidget::canvasMouseClick(QMouseEvent *event) +void EditTools::canvasMouseClick(QMouseEvent*) { +#if 0 switch(this->drawState.mode) { case SelectMode: @@ -104,15 +102,11 @@ } break; case DrawMode: - if (event->button() == Qt::LeftButton and this->canvas->worldPosition.has_value()) - { - const glm::vec3& pos = this->canvas->worldPosition.value(); - if (isCloseToExistingPoints(this->drawState.polygon, pos)) - { + if (event->button() == Qt::LeftButton) { + if (isCloseToExistingPoints(this->drawState.polygon, worldPosition)) { this->closeShape(); } - else - { + else { this->drawState.polygon.push_back(pos); updatePreviewPolygon(&this->drawState); } @@ -128,10 +122,11 @@ } break; } +#endif } - -void EditorTabWidget::canvasMouseMove(QMouseEvent *event) +void EditTools::canvasMouseMove(QMouseEvent*) { +#if 0 switch(this->drawState.mode) { case SelectMode: @@ -146,7 +141,9 @@ event->accept(); break; } +#endif } +#if 0 /* void EditorTabWidget::select(const QSet<ModelId> &selected) @@ -165,17 +162,17 @@ selectionModel->select(itemSelection, QItemSelectionModel::ClearAndSelect); } */ -const QSet<ModelId> EditorTabWidget::selectedObjects() const +const QSet<ModelId> EditTools::selectedObjects() const { return this->canvas->selectedObjects(); } - -EditingMode EditorTabWidget::currentEditingMode() const +#endif +EditingMode EditTools::currentEditingMode() const { return this->drawState.mode; } - -void EditorTabWidget::closeShape() +#if 0 +void EditTools::closeShape() { if (this->drawState.polygon.size() >= 2 and this->drawState.polygon.size() <= 4) { @@ -222,3 +219,5 @@ this->drawState.polygon.clear(); updatePreviewPolygon(&this->drawState); } + +#endif