101 m_window->renderer()->update(); |
101 m_window->renderer()->update(); |
102 } |
102 } |
103 |
103 |
104 void ViewToolset::screenshot() |
104 void ViewToolset::screenshot() |
105 { |
105 { |
106 setlocale (LC_ALL, "C"); |
106 const char* imageformats = "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;" |
107 |
107 "PPM images (*.ppm);;X11 Bitmaps (*.xbm);;X11 Pixmaps (*.xpm);;All Files (*.*)"; |
108 int w, h; |
108 int width = m_window->renderer()->width(); |
109 uchar* imgdata = m_window->renderer()->getScreencap (w, h); |
109 int height = m_window->renderer()->height(); |
110 QImage img = GetImageFromScreencap (imgdata, w, h); |
110 QByteArray capture = m_window->renderer()->capturePixels(); |
111 |
111 const uchar* imagedata = reinterpret_cast<const uchar*> (capture.constData()); |
|
112 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
|
113 QImage image = QImage (imagedata, width, height, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
112 QString root = Basename (currentDocument()->name()); |
114 QString root = Basename (currentDocument()->name()); |
113 |
115 |
114 if (root.right (4) == ".dat") |
116 if (root.right (4) == ".dat") |
115 root.chop (4); |
117 root.chop (4); |
116 |
118 |
117 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; |
119 QString defaultname = (root.length() > 0) ? format ("%1.png", root) : ""; |
118 QString fname = QFileDialog::getSaveFileName (m_window, "Save Screencap", defaultname, |
120 QString filename = QFileDialog::getSaveFileName (m_window, "Save Screencap", defaultname, imageformats); |
119 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
121 |
120 |
122 if (not filename.isEmpty() and not image.save (filename)) |
121 if (not fname.isEmpty() and not img.save (fname)) |
123 Critical (format ("Couldn't open %1 for writing to save screencap: %2", filename, strerror (errno))); |
122 Critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); |
|
123 |
|
124 delete[] imgdata; |
|
125 } |
124 } |
126 |
125 |
127 void ViewToolset::axes() |
126 void ViewToolset::axes() |
128 { |
127 { |
129 m_config->setDrawAxes (not m_config->drawAxes()); |
128 m_config->setDrawAxes (not m_config->drawAxes()); |
182 if (m_window->renderer()->camera() == EFreeCamera) |
181 if (m_window->renderer()->camera() == EFreeCamera) |
183 return; |
182 return; |
184 |
183 |
185 bool ok; |
184 bool ok; |
186 double depth = QInputDialog::getDouble (m_window, "Set Draw Depth", |
185 double depth = QInputDialog::getDouble (m_window, "Set Draw Depth", |
187 format ("Depth value for %1 Camera:", m_window->renderer()->getCameraName()), |
186 format ("Depth value for %1:", m_window->renderer()->currentCameraName()), |
188 m_window->renderer()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
187 m_window->renderer()->getDepthValue(), -10000.0f, 10000.0f, 3, &ok); |
189 |
188 |
190 if (ok) |
189 if (ok) |
191 m_window->renderer()->setDepthValue (depth); |
190 m_window->renderer()->setDepthValue (depth); |
192 } |
191 } |