+// Copyright (C) 2005 OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+// Author : OPEN CASCADE
+//
+
// File: GLViewer_ViewFrame.cxx
// Created: November, 2004
-// Author: OCC team
-// Copyright (C) CEA 2004
-
-/***************************************************************************
-** Class: GLViewer_ViewFrame
-** Descr: Frame window for viewport in QAD-based application
-** Module: QAD
-** Created: UI team, 05.09.00
-****************************************************************************/
+//#include <GLViewerAfx.h>
#include "GLViewer_ViewFrame.h"
-
#include "GLViewer_Viewer.h"
#include "GLViewer_Viewer2d.h"
#include "GLViewer_ViewPort2d.h"
#include <SUIT_Session.h>
#include <SUIT_ToolButton.h>
#include <SUIT_ResourceMgr.h>
-#include <QtxAction.h>
#include <SUIT_MessageBox.h>
#include <qcolor.h>
{
}
-//================================================================
-// Function : createActions
-// Purpose :
-//================================================================
+/*!
+ Creates actions of GL view frame
+*/
void GLViewer_ViewFrame::createActions()
{
- if ( !myActionsMap.isEmpty() )
- return;
-
- QtxAction* aAction;
+ if (!myActionsMap.isEmpty()) return;
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ QAction* aAction;
// Dump view
- aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
+ aAction = new QAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump()));
myActionsMap[ DumpId ] = aAction;
// FitAll
- aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ),
+ aAction = new QAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITALL" ) ),
tr( "MNU_FITALL" ), 0, this);
aAction->setStatusTip(tr("DSC_FITALL"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitAll()));
myActionsMap[ FitAllId ] = aAction;
// FitRect
- aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ),
+ aAction = new QAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITAREA" ) ),
tr( "MNU_FITRECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITRECT"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitArea()));
myActionsMap[ FitRectId ] = aAction;
// FitSelect
- aAction = new QtxAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ),
- tr( "MNU_FITSELECT" ), 0, this);
+ aAction = new QAction(tr("MNU_FITSELECT"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_FITSELECT" ) ),
+ tr( "MNU_FITSELECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITSELECT"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewFitSelect()));
myActionsMap[ FitSelectId ] = aAction;
// Zoom
- aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ),
+ aAction = new QAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_ZOOM" ) ),
tr( "MNU_ZOOM_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewZoom()));
myActionsMap[ ZoomId ] = aAction;
// Panning
- aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ),
+ aAction = new QAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_PAN" ) ),
tr( "MNU_PAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PAN_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
myActionsMap[ PanId ] = aAction;
// Global Panning
- aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ),
+ aAction = new QAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_GLOBALPAN" ) ),
tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewGlobalPan()));
myActionsMap[ GlobalPanId ] = aAction;
- aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ),
+ aAction = new QAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_RESET" ) ),
tr( "MNU_RESET_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_RESET_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
myActionsMap[ ResetId ] = aAction;
}
-//================================================================
-// Function : createToolBar
-// Purpose :
-//================================================================
+/*!
+ Creates toolbar of GL view frame
+*/
void GLViewer_ViewFrame::createToolBar()
{
myActionsMap[DumpId]->addTo(myToolBar);
disconnect( myVP, SIGNAL( vpDrawExternal( QPainter* ) ), this, SIGNAL( vfDrawExternal( QPainter* ) ) );
disconnect( myVP, SIGNAL( vpMouseEvent( QMouseEvent* ) ), this, SLOT( mouseEvent( QMouseEvent* ) ) );
disconnect( myVP, SIGNAL( vpKeyEvent( QKeyEvent* ) ), this, SLOT( keyEvent( QKeyEvent* ) ) );
- disconnect( myVP, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
- this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
disconnect( myVP, SIGNAL( vpWheelEvent( QWheelEvent* ) ), this, SLOT( wheelEvent( QWheelEvent* ) ) );
+ disconnect( myVP, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ),
+ this, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ) );
}
myVP = vp;
if ( myVP )
connect( myVP, SIGNAL( vpDrawExternal( QPainter* ) ), this, SIGNAL( vfDrawExternal( QPainter* ) ) );
connect( myVP, SIGNAL( vpMouseEvent( QMouseEvent* ) ), this, SLOT( mouseEvent( QMouseEvent* ) ) );
connect( myVP, SIGNAL( vpKeyEvent( QKeyEvent* ) ), this, SLOT( keyEvent( QKeyEvent* ) ) );
- connect( myVP, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
- this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
connect( myVP, SIGNAL( vpWheelEvent( QWheelEvent* ) ), this, SLOT( wheelEvent( QWheelEvent* ) ) );
+ connect( myVP, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ),
+ this, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ) );
}
}
{
QWidget* p = parentWidget();
if ( p && p->inherits( "QWorkspaceChild" ) )
- p = p->parentWidget(); /* QWorkspaceChild: internal impl class in QWorkspace */
+ p = p->parentWidget();
if ( !p )
return QMainWindow::sizeHint();
return QSize( 9 * p->width() / 10 , 9 * p->height() / 10 );
{
}
+//#include <windows.h>
+
+/*!
+ SLOT: called on dump view operation is activated, stores scene to raster file
+*/
void GLViewer_ViewFrame::onViewDump()
{
GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
if( aFileName.isEmpty() )
{
SUIT_MessageBox::error1( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
- tr( "BUT_OK" ) );
+ tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
+ tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
+ tr( "BUT_OK" ) );
}
QString aSaveOp = "BMP";
aFileName += ".png";
aSaveOp = "PNG";
- if( !anImage.save( aFileName, aSaveOp ) )
+//#ifdef WNT
+// if( !anImage.save( aFileName, aSaveOp ) )
+//#else
+ if( !aWidget->grabFrameBuffer().save( aFileName, aSaveOp ) )
+//#endif
{
SUIT_MessageBox::error1( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
- tr( "BUT_OK" ) );
+ tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
+ tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
+ tr( "BUT_OK" ) );
}
}
+/*!
+ Start panning
+*/
void GLViewer_ViewFrame::onViewPan()
{
myViewer->activateTransform( GLViewer_Viewer::Pan );
}
+/*!
+ Start zooming
+*/
void GLViewer_ViewFrame::onViewZoom()
{
myViewer->activateTransform( GLViewer_Viewer::Zoom );
}
+/*!
+ Start fit all
+*/
void GLViewer_ViewFrame::onViewFitAll()
{
myViewer->activateTransform( GLViewer_Viewer::FitAll );
}
+/*!
+ Start fit area
+*/
void GLViewer_ViewFrame::onViewFitArea()
{
myViewer->activateTransform( GLViewer_Viewer::FitRect );
}
+/*!
+ Start fit selected
+*/
void GLViewer_ViewFrame::onViewFitSelect()
{
myViewer->activateTransform( GLViewer_Viewer::FitSelect );
}
+/*!
+ Start global panning
+*/
void GLViewer_ViewFrame::onViewGlobalPan()
{
myViewer->activateTransform( GLViewer_Viewer::PanGlobal );
}
+/*!
+ Start rotating
+*/
void GLViewer_ViewFrame::onViewRotate()
{
//myViewer->activateTransform( GLViewer_Viewer::Rotate );
}
+/*!
+ Start reset default view aspects
+*/
void GLViewer_ViewFrame::onViewReset()
{
myViewer->activateTransform( GLViewer_Viewer::Reset );
}
-
-//================================================================
-// Function : mouseEvent
-// Purpose : dispatches mouse events
-//================================================================
+
+/*!
+ Dispatches mouse events
+*/
void GLViewer_ViewFrame::mouseEvent( QMouseEvent* e )
{
switch ( e->type() )
}
}
-//================================================================
-// Function : keyEvent
-// Purpose : dispatches key events
-//================================================================
+/*!
+ Dispatches key events
+*/
void GLViewer_ViewFrame::keyEvent( QKeyEvent* e )
{
switch ( e->type() )
}
}
-//================================================================
-// Function : wheelEvent
-// Purpose : dispatches wheel events
-//================================================================
+/*!
+ Dispatches wheel events
+*/
void GLViewer_ViewFrame::wheelEvent( QWheelEvent* e )
{
switch ( e->type() )
break;
}
}
+
+/*!
+ \return the visual parameters of this view as a formated string
+*/
+QString GLViewer_ViewFrame::getVisualParameters()
+{
+ QString retStr;
+ if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) ) {
+ GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP;
+ GLfloat xSc, ySc, xPan, yPan;
+ vp2d->getScale( xSc, ySc );
+ vp2d->getPan( xPan, yPan );
+ retStr.sprintf( "%.12e*%.12e*%.12e*%.12e", xSc, ySc, xPan, yPan );
+ }
+ return retStr;
+}
+
+/*!
+ The method restores visual parameters of this view from a formated string
+*/
+void GLViewer_ViewFrame::setVisualParameters( const QString& parameters )
+{
+ QStringList paramsLst = QStringList::split( '*', parameters, true );
+ if ( myVP && myVP->inherits( "GLViewer_ViewPort2d" ) && paramsLst.size() == 4) {
+ GLViewer_ViewPort2d* vp2d = (GLViewer_ViewPort2d*)myVP;
+
+ GLfloat xSc, ySc, xPan, yPan;
+ xSc = paramsLst[0].toDouble();
+ ySc = paramsLst[1].toDouble();
+ xPan = paramsLst[2].toDouble();
+ yPan = paramsLst[3].toDouble();
+
+ vp2d->getGLWidget()->setScale( xSc, ySc, 1. );
+ vp2d->getGLWidget()->setPan( xPan, yPan, 0. );
+ }
+}