Merge pull request #1339 from openscad/export-to-clipboard

Add "Export to Clipboard" to copy the current 3d view to the system clipboard.
master
Marius Kintel 2015-05-18 22:20:28 -04:00
commit 42d6629156
5 changed files with 22 additions and 2 deletions

View File

@ -196,6 +196,7 @@ private slots:
void actionExportSVG();
void actionExportCSG();
void actionExportImage();
void actionCopyViewport();
void actionFlushCaches();
public:

View File

@ -302,6 +302,8 @@
<addaction name="editActionCopy"/>
<addaction name="editActionPaste"/>
<addaction name="separator"/>
<addaction name="editActionCopyViewport"/>
<addaction name="separator"/>
<addaction name="editActionIndent"/>
<addaction name="editActionUnindent"/>
<addaction name="editActionComment"/>
@ -1261,6 +1263,14 @@
<string>&amp;Cheat Sheet</string>
</property>
</action>
<action name="editActionCopyViewport">
<property name="text">
<string>Copy Viewport</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+C</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -294,11 +294,12 @@ void QGLView::mouseReleaseEvent(QMouseEvent*)
releaseMouse();
}
void QGLView::grabFrame()
const QImage & QGLView::grabFrame()
{
// Force reading from front buffer. Some configurations will read from the back buffer here.
glReadBuffer(GL_FRONT);
this->frame = grabFrameBuffer();
return this->frame;
}
bool QGLView::save(const char *filename)

View File

@ -43,7 +43,7 @@ public:
float getDPI() { return this->devicePixelRatio(); }
#endif
void grabFrame();
const QImage & grabFrame();
bool save(const char *filename);
void resetView();
void viewAll();

View File

@ -325,6 +325,7 @@ MainWindow::MainWindow(const QString &filename)
connect(this->editActionCut, SIGNAL(triggered()), editor, SLOT(cut()));
connect(this->editActionCopy, SIGNAL(triggered()), editor, SLOT(copy()));
connect(this->editActionPaste, SIGNAL(triggered()), editor, SLOT(paste()));
connect(this->editActionCopyViewport, SIGNAL(triggered()), this, SLOT(actionCopyViewport()));
connect(this->editActionIndent, SIGNAL(triggered()), editor, SLOT(indentSelection()));
connect(this->editActionUnindent, SIGNAL(triggered()), editor, SLOT(unindentSelection()));
connect(this->editActionComment, SIGNAL(triggered()), editor, SLOT(commentSelection()));
@ -2184,6 +2185,13 @@ void MainWindow::actionExportImage()
return;
}
void MainWindow::actionCopyViewport()
{
const QImage & image = qglview->grabFrame();
QClipboard *clipboard = QApplication::clipboard();
clipboard->setImage(image);
}
void MainWindow::actionFlushCaches()
{
GeometryCache::instance()->clear();