Back to index

salome-gui  6.5.0
QxScene_ViewWindow.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  SALOME QxScene : build Supervisor viewer into desktop
00021 //
00022 #include "QxScene_ViewWindow.h"
00023 #include "QxScene_Def.h"
00024 
00025 #include <SUIT_ResourceMgr.h>
00026 #include <SUIT_Session.h>
00027 #include <SUIT_Desktop.h>
00028 
00029 #include <QtxAction.h>
00030 #include <QtxMultiAction.h>
00031 #include <QtxActionToolMgr.h>
00032 
00033 //QT Include
00034 #include <QToolBar>
00035 #include <QGraphicsRectItem>
00036 
00037 //#define _DEVDEBUG_
00038 #include "DebTrace.hxx"
00039 
00043 QxScene_ViewWindow::QxScene_ViewWindow( SUIT_Desktop* theDesktop, QxScene_Viewer* theModel)
00044   : SUIT_ViewWindow( theDesktop )
00045 {
00046   DEBTRACE("Construct QxScene_ViewWindow");
00047   myViewModel = theModel;
00048   _scene = 0;
00049   _sceneView = 0;
00050 }
00051 
00055 void QxScene_ViewWindow::initLayout()
00056 {
00057   DEBTRACE("QxScene_ViewWindow::initLayout");
00058   createActions();
00059   createToolBar();
00060   
00061   // --- QGraphics test
00062 
00063 //   _scene = new QGraphicsScene();
00064 //   _sceneView = new QGraphicsView(this);
00065 //   setCentralWidget(_sceneView);
00066 //   _sceneView->setScene(_scene);
00067 //   QGraphicsRectItem *rect = _scene->addRect(QRectF(0, 0, 100, 100));
00068 //   _sceneView->show();
00069 }
00070 
00074 void QxScene_ViewWindow::createActions()
00075 {
00076   DEBTRACE("QxScene_ViewWindow::createActions");
00077   QtxActionToolMgr* mgr = toolMgr();
00078   QtxAction* aAction;
00079   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
00080 
00081   // 2. Scaling operations
00082 
00083   // 2.1. Fit All
00084   aAction = new QtxAction( tr( "MNU_FITALL" ),
00085                            aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_FITALL" ) ),
00086                            tr( "MNU_FITALL" ),
00087                            0, this);
00088   aAction->setStatusTip( tr( "DSC_FITALL" ) );
00089   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewFitAll() ) );
00090   mgr->registerAction( aAction, FitAllId );
00091 
00092   // 2.2. Fit Rect
00093   aAction = new QtxAction( tr( "MNU_FITRECT" ),
00094                            aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_FITAREA" ) ),
00095                            tr( "MNU_FITRECT" ),
00096                            0, this);
00097   aAction->setStatusTip( tr( "DSC_FITRECT" ) );
00098   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewFitArea() ) );
00099   mgr->registerAction( aAction, FitRectId );
00100 
00101   // 2.3. Zoom
00102   aAction = new QtxAction( tr( "MNU_ZOOM_VIEW" ),
00103                            aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_ZOOM" ) ),
00104                            tr( "MNU_ZOOM_VIEW" ),
00105                            0, this);
00106   aAction->setStatusTip( tr( "DSC_ZOOM_VIEW" ) );
00107   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewZoom() ) );
00108   mgr->registerAction( aAction, ZoomId );
00109 
00110   // 2.4. Create multi-action for scaling operations
00111   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
00112   aScaleAction->insertAction( mgr->action( FitAllId  ) );
00113   aScaleAction->insertAction( mgr->action( FitRectId ) );
00114   aScaleAction->insertAction( mgr->action( ZoomId    ) );
00115   mgr->registerAction( aScaleAction, ScaleOpId );
00116 
00117   // 3. Moving operations
00118 
00119   // 3.1. Panning
00120   aAction = new QtxAction( tr( "MNU_PAN_VIEW" ),
00121                            aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_PAN" ) ),
00122                            tr( "MNU_PAN_VIEW" ), 
00123                            0, this);
00124   aAction->setStatusTip( tr( "DSC_PAN_VIEW" ) );
00125   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewPan() ) );
00126   mgr->registerAction( aAction, PanId );
00127 
00128   // 3.2. Global Panning
00129   aAction = new QtxAction( tr( "MNU_GLOBALPAN_VIEW" ),
00130                            aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_GLOBALPAN" ) ),
00131                            tr( "MNU_GLOBALPAN_VIEW" ),
00132                            0, this);
00133   aAction->setStatusTip( tr( "DSC_GLOBALPAN_VIEW" ) );
00134   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewGlobalPan() ) );
00135   mgr->registerAction( aAction, GlobalPanId );
00136 
00137   // 3.3. Create multi-action for moving operations
00138   QtxMultiAction* aPanAction = new QtxMultiAction( this );
00139   aPanAction->insertAction( mgr->action( PanId ) );
00140   aPanAction->insertAction( mgr->action( GlobalPanId ) );
00141   mgr->registerAction( aPanAction, MoveOpId );
00142 
00143   // reset
00144   aAction = new QtxAction( tr( "MNU_RESET_VIEW" ),
00145                            aResMgr->loadPixmap( "QxSceneViewer", tr( "ICON_QXSCENE_RESET" ) ),
00146                            tr( "MNU_RESET_VIEW" ), 
00147                            0, this);
00148   aAction->setStatusTip( tr( "DSC_RESET_VIEW" ) );
00149   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewReset() ) );
00150   mgr->registerAction( aAction, ResetId );
00151 }
00152 
00156 void QxScene_ViewWindow::createToolBar()
00157 {
00158   DEBTRACE("QxScene_ViewWindow::createToolBar");
00159   QtxActionToolMgr* mgr = toolMgr();
00160   myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false );
00161   mgr->append( ScaleOpId, myToolBar );
00162   mgr->append( MoveOpId, myToolBar );
00163   mgr->append( ResetId, myToolBar );
00164 }
00165 
00170 QToolBar* QxScene_ViewWindow::getToolBar()
00171 {
00172   DEBTRACE("QxScene_ViewWindow::getToolBar");
00173   return toolMgr()->toolBar( myToolBar );
00174 }
00175 
00179 QxScene_ViewWindow::~QxScene_ViewWindow()
00180 {
00181   DEBTRACE("destructor QxScene_ViewWindow");
00182 
00183 }
00184 
00188 void QxScene_ViewWindow::onViewReset()    
00189 {
00190   DEBTRACE( "QxScene_ViewWindow::onViewReset" );
00191 }
00192 
00196 void QxScene_ViewWindow::onViewGlobalPan()
00197 {
00198   DEBTRACE( "QxScene_ViewWindow::onViewGlobalPan" );
00199 }
00200 
00204 void QxScene_ViewWindow::onViewZoom()
00205 {
00206   DEBTRACE( "QxScene_ViewWindow::onViewZoom" );
00207 }
00208 
00212 void QxScene_ViewWindow::onViewPan()
00213 {
00214   DEBTRACE( "QxScene_ViewWindow::onViewPan" );
00215 }
00216 
00220 void QxScene_ViewWindow::onViewFitArea()
00221 {
00222   DEBTRACE( "QxScene_ViewWindow::onViewFitArea" );
00223 }
00224 
00228 void QxScene_ViewWindow::onViewFitAll()
00229 {
00230   DEBTRACE( "QxScene_ViewWindow::onViewFitAll" );
00231 }
00232 
00236 void QxScene_ViewWindow::setBackgroundColor( const QColor& color )
00237 {
00238   DEBTRACE("QxScene_ViewWindow::setBackgroundColor");
00239 }
00240 
00244 QColor QxScene_ViewWindow::backgroundColor() const
00245 {
00246   DEBTRACE("QxScene_ViewWindow::backgroundColor");
00247   QColor col;
00248   return col;
00249 }
00250 
00254 void QxScene_ViewWindow::resizeEvent( QResizeEvent* theEvent )
00255 {
00256   DEBTRACE("QxScene_ViewWindow::resizeEvent");
00257 }
00258 
00262 SUIT_ResourceMgr* QxScene_ViewWindow::resMgr() const
00263 { 
00264   DEBTRACE("QxScene_ViewWindow::resMgr");
00265   return SUIT_Session::session()->resourceMgr(); 
00266 }
00267 
00272 bool QxScene_ViewWindow::closeRequested()
00273 {
00274   DEBTRACE("QxScene_ViewWindow::closeRequested");
00275   bool isClosed = true;
00276   emit tryClose(isClosed, this);
00277   DEBTRACE("isClosed=" << isClosed);
00278   return isClosed;
00279 }