96 } |
96 } |
97 } |
97 } |
98 |
98 |
99 void ViewToolset::resetView() |
99 void ViewToolset::resetView() |
100 { |
100 { |
101 m_window->renderer()->resetAngles(); |
101 m_window->currentRenderer()->resetAngles(); |
102 m_window->renderer()->update(); |
102 m_window->currentRenderer()->update(); |
103 } |
103 } |
104 |
104 |
105 void ViewToolset::screenshot() |
105 void ViewToolset::screenshot() |
106 { |
106 { |
107 const char* imageformats = "PNG images(*.png);;JPG images(*.jpg);;BMP images(*.bmp);;" |
107 const char* imageformats = "PNG images(*.png);;JPG images(*.jpg);;BMP images(*.bmp);;" |
108 "PPM images(*.ppm);;X11 Bitmaps(*.xbm);;X11 Pixmaps(*.xpm);;All Files(*.*)"; |
108 "PPM images(*.ppm);;X11 Bitmaps(*.xbm);;X11 Pixmaps(*.xpm);;All Files(*.*)"; |
109 int width = m_window->renderer()->width(); |
109 int width = m_window->currentRenderer()->width(); |
110 int height = m_window->renderer()->height(); |
110 int height = m_window->currentRenderer()->height(); |
111 QByteArray capture = m_window->renderer()->capturePixels(); |
111 QByteArray capture = m_window->currentRenderer()->capturePixels(); |
112 const uchar* imagedata = reinterpret_cast<const uchar*>(capture.constData()); |
112 const uchar* imagedata = reinterpret_cast<const uchar*>(capture.constData()); |
113 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
113 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
114 QImage image = QImage(imagedata, width, height, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
114 QImage image = QImage(imagedata, width, height, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
115 QString root = Basename(currentDocument()->name()); |
115 QString root = Basename(currentDocument()->name()); |
116 |
116 |
126 |
126 |
127 void ViewToolset::axes() |
127 void ViewToolset::axes() |
128 { |
128 { |
129 config->setDrawAxes(not config->drawAxes()); |
129 config->setDrawAxes(not config->drawAxes()); |
130 m_window->updateActions(); |
130 m_window->updateActions(); |
131 m_window->renderer()->update(); |
131 m_window->currentRenderer()->update(); |
132 } |
132 } |
133 |
133 |
134 void ViewToolset::visibilityToggle() |
134 void ViewToolset::visibilityToggle() |
135 { |
135 { |
136 for (LDObject* obj : selectedObjects()) |
136 for (LDObject* obj : selectedObjects()) |
150 } |
150 } |
151 |
151 |
152 void ViewToolset::wireframe() |
152 void ViewToolset::wireframe() |
153 { |
153 { |
154 config->setDrawWireframe(not config->drawWireframe()); |
154 config->setDrawWireframe(not config->drawWireframe()); |
155 m_window->renderer()->refresh(); |
155 m_window->currentRenderer()->refresh(); |
156 } |
156 } |
157 |
157 |
158 void ViewToolset::setOverlay() |
158 void ViewToolset::setOverlay() |
159 { |
159 { |
160 OverlayDialog dlg; |
160 OverlayDialog dlg; |
161 |
161 |
162 if (not dlg.exec()) |
162 if (not dlg.exec()) |
163 return; |
163 return; |
164 |
164 |
165 m_window->renderer()->setupOverlay((ECamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
165 m_window->currentRenderer()->setupOverlay((ECamera) dlg.camera(), dlg.fpath(), dlg.ofsx(), |
166 dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
166 dlg.ofsy(), dlg.lwidth(), dlg.lheight()); |
167 } |
167 } |
168 |
168 |
169 void ViewToolset::clearOverlay() |
169 void ViewToolset::clearOverlay() |
170 { |
170 { |
171 m_window->renderer()->clearOverlay(); |
171 m_window->currentRenderer()->clearOverlay(); |
172 } |
172 } |
173 |
173 |
174 void ViewToolset::drawAngles() |
174 void ViewToolset::drawAngles() |
175 { |
175 { |
176 config->setDrawAngles(not config->drawAngles()); |
176 config->setDrawAngles(not config->drawAngles()); |
177 m_window->renderer()->refresh(); |
177 m_window->currentRenderer()->refresh(); |
178 } |
178 } |
179 |
179 |
180 void ViewToolset::setDrawDepth() |
180 void ViewToolset::setDrawDepth() |
181 { |
181 { |
182 if (m_window->renderer()->camera() == EFreeCamera) |
182 if (m_window->currentRenderer()->camera() == EFreeCamera) |
183 return; |
183 return; |
184 |
184 |
185 bool ok; |
185 bool ok; |
186 double depth = QInputDialog::getDouble(m_window, "Set Draw Depth", |
186 double depth = QInputDialog::getDouble(m_window, "Set Draw Depth", |
187 format("Depth value for %1:", m_window->renderer()->currentCameraName()), |
187 format("Depth value for %1:", m_window->currentRenderer()->currentCameraName()), |
188 m_window->renderer()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
188 m_window->currentRenderer()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
189 |
189 |
190 if (ok) |
190 if (ok) |
191 m_window->renderer()->setDepthValue(depth); |
191 m_window->currentRenderer()->setDepthValue(depth); |
192 } |
192 } |
193 |
193 |
194 #if 0 |
194 #if 0 |
195 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
195 // This is a test to draw a dummy axle. Meant to be used as a primitive gallery, |
196 // but I can't figure how to generate these pictures properly. Multi-threading |
196 // but I can't figure how to generate these pictures properly. Multi-threading |
277 |
277 |
278 if (config->randomColors()) |
278 if (config->randomColors()) |
279 config->setBfcRedGreenView(false); |
279 config->setBfcRedGreenView(false); |
280 |
280 |
281 m_window->updateActions(); |
281 m_window->updateActions(); |
282 m_window->renderer()->refresh(); |
282 m_window->currentRenderer()->refresh(); |
283 } |
283 } |
284 |
284 |
285 void ViewToolset::drawSurfaces() |
285 void ViewToolset::drawSurfaces() |
286 { |
286 { |
287 config->setDrawSurfaces(not config->drawSurfaces()); |
287 config->setDrawSurfaces(not config->drawSurfaces()); |