#include <SUIT_MessageBox.h>
#include <qcolor.h>
-#include <qfiledialog.h>
#include <qimage.h>
#include <qlayout.h>
#include <qstring.h>
+#include <qclipboard.h>
+#include <qfiledialog.h>
+#include <qapplication.h>
/*!
Constructor
{
}
+/*!
+ Copy view content to clipboard [ virtual public ]
+*/
+void GLViewer_ViewFrame::copyView()
+{
+ //QImage anImage = dumpView();
+ //QClipboard* aClipboard = QApplication::clipboard();
+ //aClipboard->setImage( anImage, QClipboard::Clipboard );
+}
+
//#include <windows.h>
/*!
- SLOT: called on dump view operation is activated, stores scene to raster file
+ Return view content as QImage [ virtual public ]
*/
-void GLViewer_ViewFrame::onViewDump()
+QImage GLViewer_ViewFrame::dumpView()
{
GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
int width, height;
imageSize = (width+reserve_bytes)*height*3;
imageBits = new unsigned char[imageSize];
-
#ifdef WNT
-
int num;
HBITMAP hBmp;
HDC hdc_old, hdc;
if( !hdc )
{
cout << "Can't create compatible DC. Last Error Code: " << GetLastError() << endl;
- return;
+ return QImage();
}
int sizeBmi = Standard_Integer( sizeof(BITMAPINFO) + sizeof(RGBQUAD)*3 );
if( !hglrc )
{
cout << "Can't create new GL Context. Last Error Code: " << GetLastError() << endl;
- return;
+ return QImage();
}
if( !wglMakeCurrent( hdc, hglrc) )
{
cout << "Can't make current new context!" << endl;
- return;
+ return QImage();
}
glViewport( 0, 0, width, height );
wglMakeCurrent( hdc_old, hglrc_old );
wglDeleteContext( hglrc );
-
-
-#else //XWindows
#endif
unsigned int* aPix = NULL;
- QImage anImage( width, height, 32 );
+ QImage anImage( width, height, 32 );
for( int i = 0; i < height; i++ )
{
memset( anImage.scanLine( i ), 0, sizeof(unsigned int)*width );
delete [] imageBits;
+//#ifdef WNT
+// return anImage;
+//#else
+ return aWidget->grabFrameBuffer();
+//#endif
+}
+
+/*!
+ SLOT: called on dump view operation is activated, stores scene to raster file
+*/
+void GLViewer_ViewFrame::onViewDump()
+{
QString aFilter( "*.bmp\n*.png" );
QFileDialog aFileDlg( QDir::current().absPath(), aFilter, this );
aFileName += ".png";
aSaveOp = "PNG";
-//#ifdef WNT
-// if( !anImage.save( aFileName, aSaveOp ) )
-//#else
- if( !aWidget->grabFrameBuffer().save( aFileName, aSaveOp ) )
-//#endif
+ QImage anImage = dumpView();
+ if( !anImage.save( aFileName, aSaveOp ) )
{
SUIT_MessageBox::error1( this,
tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
SUIT_ViewModel::setViewManager(theViewManager);
if (theViewManager)
{
+ connect(theViewManager, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)),
+ this, SLOT(onKeyEvent(SUIT_ViewWindow*, QKeyEvent*)));
+
connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
this, SLOT(onMouseEvent(SUIT_ViewWindow*, QMouseEvent*)));
{ /* terminate all */
activateTransform( NoTransform );
activateSketching( NoSketching );
- //cout << "mouseClickedOutside || anyKeyPressed" << endl;
}
return QObject::eventFilter( o, e );
}
/*!
Listens to key events of the active view. [ virtual protected slot ]
*/
-void GLViewer_Viewer::onKeyEvent( SUIT_ViewWindow*, QKeyEvent* )
+void GLViewer_Viewer::onKeyEvent( SUIT_ViewWindow*, QKeyEvent* e )
{
+ switch( e->type() )
+ {
+ case QEvent::KeyRelease:
+ handleKeyRelease( e );
+ break;
+ default: break;
+ }
}
/*!
*/
void GLViewer_Viewer::onMouseEvent( SUIT_ViewWindow*, QMouseEvent* e )
{
- //cout << "GLViewer_Viewer::onMouseEvent" << endl;
switch( e->type() )
{
case QEvent::MouseButtonPress:
*/
void GLViewer_Viewer::onWheelEvent( SUIT_ViewWindow*, QWheelEvent* e )
{
- //cout << "GLViewer_Viewer::onMouseEvent" << endl;
switch( e->type() )
{
case QEvent::Wheel:
getSelector()->undetectAll();
}
+/*!
+ Key release handler
+*/
+void GLViewer_Viewer::handleKeyRelease( QKeyEvent* e )
+{
+}
+
/*!
Mouse press handler. If 'accelKey()' is pressed, activates default
transformations( Zoom or Pan ) in the active viewport. [ private ]