src/ui/canvas.cpp

changeset 118
8e1c9f18ae15
parent 115
ed884a2fb009
child 119
24275a4064f4
equal deleted inserted replaced
117:121a40d5e34c 118:8e1c9f18ae15
17 Q_ASSERT(not selectedIds.contains(ldraw::NULL_ID)); 17 Q_ASSERT(not selectedIds.contains(ldraw::NULL_ID));
18 this->selection.subtract(deselectedIds); 18 this->selection.subtract(deselectedIds);
19 this->selection.unite(selectedIds); 19 this->selection.unite(selectedIds);
20 this->compiler->setSelectedObjects(this->selection); 20 this->compiler->setSelectedObjects(this->selection);
21 this->update(); 21 this->update();
22 }
23
24 void Canvas::rebuildVertices(Document* document)
25 {
26 if (this->vertexProgram.has_value())
27 {
28 this->vertexProgram->build(document);
29 this->update();
30 }
22 } 31 }
23 32
24 void Canvas::mouseMoveEvent(QMouseEvent* event) 33 void Canvas::mouseMoveEvent(QMouseEvent* event)
25 { 34 {
26 const ldraw::id_t id = this->pick(event->pos()); 35 const ldraw::id_t id = this->pick(event->pos());
103 // functions so that when initialization sets up, the signals also set up the matrices on our side. 112 // functions so that when initialization sets up, the signals also set up the matrices on our side.
104 this->gridProgram.emplace(this); 113 this->gridProgram.emplace(this);
105 this->gridProgram->initialize(); 114 this->gridProgram->initialize();
106 this->axesProgram.emplace(this); 115 this->axesProgram.emplace(this);
107 this->axesProgram->initialize(); 116 this->axesProgram->initialize();
117 this->vertexProgram.emplace(this);
118 this->vertexProgram->initialize();
108 for (AbstractBasicShaderProgram* program : { 119 for (AbstractBasicShaderProgram* program : {
109 static_cast<AbstractBasicShaderProgram*>(&*this->gridProgram), 120 static_cast<AbstractBasicShaderProgram*>(&*this->gridProgram),
110 static_cast<AbstractBasicShaderProgram*>(&*this->axesProgram), 121 static_cast<AbstractBasicShaderProgram*>(&*this->axesProgram),
122 static_cast<AbstractBasicShaderProgram*>(&*this->vertexProgram),
111 }) 123 })
112 { 124 {
113 connect(this, &PartRenderer::projectionMatrixChanged, 125 connect(this, &PartRenderer::projectionMatrixChanged,
114 program, &AbstractBasicShaderProgram::setProjectionMatrix); 126 program, &AbstractBasicShaderProgram::setProjectionMatrix);
115 connect(this, &PartRenderer::modelMatrixChanged, 127 connect(this, &PartRenderer::modelMatrixChanged,
153 { 165 {
154 glEnable(GL_BLEND); 166 glEnable(GL_BLEND);
155 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 167 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
156 this->gridProgram->draw(); 168 this->gridProgram->draw();
157 glDisable(GL_BLEND); 169 glDisable(GL_BLEND);
170 }
171 // Render vertices
172 {
173 glLineWidth(2);
174 glEnable(GL_LINE_SMOOTH);
175 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
176 this->vertexProgram->draw();
177 glDisable(GL_LINE_SMOOTH);
158 } 178 }
159 if (this->worldPosition.has_value()) 179 if (this->worldPosition.has_value())
160 { 180 {
161 QPainter painter{this}; 181 QPainter painter{this};
162 painter.setRenderHint(QPainter::Antialiasing); 182 painter.setRenderHint(QPainter::Antialiasing);

mercurial