src/document.cpp

changeset 118
8e1c9f18ae15
parent 117
121a40d5e34c
child 121
000781318c36
equal deleted inserted replaced
117:121a40d5e34c 118:8e1c9f18ae15
29 QWidget* parent) : 29 QWidget* parent) :
30 QWidget{parent}, 30 QWidget{parent},
31 model{model}, 31 model{model},
32 documents{documents}, 32 documents{documents},
33 colorTable{colorTable}, 33 colorTable{colorTable},
34 vertexMap{model},
34 renderer{new Canvas{model, documents, colorTable, this}}, 35 renderer{new Canvas{model, documents, colorTable, this}},
35 ui{*new Ui::Document}, 36 ui{*new Ui::Document},
36 objectEditor{model, ldraw::NULL_ID, this}, 37 objectEditor{model, ldraw::NULL_ID, this}
37 vertexMap{model}
38 { 38 {
39 this->ui.setupUi(this); 39 this->ui.setupUi(this);
40 this->ui.listView->setModel(model); 40 this->ui.listView->setModel(model);
41 this->ui.viewportFrame->setLayout(new QVBoxLayout{this->ui.listView}); 41 this->ui.viewportFrame->setLayout(new QVBoxLayout{this->ui.listView});
42 this->ui.viewportFrame->layout()->addWidget(this->renderer); 42 this->ui.viewportFrame->layout()->addWidget(this->renderer);
79 }); 79 });
80 connect(this->renderer, &Canvas::mouseMove, this, [this](Canvas* canvas) 80 connect(this->renderer, &Canvas::mouseMove, this, [this](Canvas* canvas)
81 { 81 {
82 Q_EMIT this->mouseMove(this, canvas); 82 Q_EMIT this->mouseMove(this, canvas);
83 }); 83 });
84 connect(&this->vertexMap, &VertexMap::verticesChanged, [&]()
85 {
86 this->renderer->rebuildVertices(this);
87 });
84 } 88 }
85 89
86 Document::~Document() 90 Document::~Document()
87 { 91 {
88 delete &this->ui; 92 delete &this->ui;
111 Model::EditContext Document::editModel() 115 Model::EditContext Document::editModel()
112 { 116 {
113 return this->model->edit(); 117 return this->model->edit();
114 } 118 }
115 119
120 void Document::applyToVertices(VertexMap::ApplyFunction fn) const
121 {
122 this->vertexMap.apply(fn);
123 }
124
116 void Document::selectionChanged(const QSet<ldraw::id_t>& newSelection) 125 void Document::selectionChanged(const QSet<ldraw::id_t>& newSelection)
117 { 126 {
118 if (newSelection.size() == 1) 127 if (newSelection.size() == 1)
119 { 128 {
120 this->objectEditor.setObjectId(*newSelection.begin()); 129 this->objectEditor.setObjectId(*newSelection.begin());

mercurial