Back to index

salome-gui  6.5.0
SUPERVGraph_ViewFrame.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME SUPERVGraph : build Supervisor viewer into desktop
00024 //  File   : SUPERVGraph_ViewFrame.cxx
00025 //  Author : Nicolas REJNERI
00026 
00027 #include "SUPERVGraph_ViewFrame.h"
00028 
00029 #include <SUIT_ResourceMgr.h>
00030 #include <SUIT_Session.h>
00031 
00032 //QT Include
00033 #include <QVBoxLayout>
00034 #include <QToolBar>
00035 
00039 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
00040 {
00041   init(theParent);
00042 }
00043 
00047 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
00048 {
00049   init(theParent);
00050 }
00051 
00055 void SUPERVGraph_View::contextMenuPopup( QMenu* )
00056 {
00057   // to be implemented
00058 }
00059 
00063 void SUPERVGraph_View::init( QWidget* theParent )
00064 {
00065   if ( theParent->inherits( "QMainWindow" ) ) {
00066     ( ( QMainWindow* )theParent )->setCentralWidget( this );
00067   }
00068   else {
00069     QBoxLayout* layout = new QVBoxLayout( theParent );
00070     layout->addWidget( this );
00071   }
00072 
00073 }
00074 
00078 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop ) 
00079   : SUIT_ViewWindow( theDesktop )
00080 {
00081   myView = 0;
00082 
00083   //myView = new SUPERVGraph_View(this); 
00084   // Set BackgroundColor
00085   /*
00086   int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
00087   int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
00088   int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
00089   setBackgroundColor(QColor(R,G,B));*/
00090 
00091   myToolBar = new QToolBar(this);
00092   myToolBar->setFloatable(false);
00093   //myToolBar->setCloseMode(QDockWindow::Undocked);
00094   myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL"));
00095   createActions();
00096   createToolBar();
00097 }
00098 
00102 void SUPERVGraph_ViewFrame::createActions()
00103 {
00104   if (!myActionsMap.isEmpty()) return;
00105   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
00106   QtxAction* aAction;
00107 
00108   // Panning
00109   aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
00110                           tr( "MNU_PAN_VIEW" ), 0, this);
00111   aAction->setStatusTip(tr("DSC_PAN_VIEW"));
00112   connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
00113   myActionsMap[ PanId ] = aAction;
00114 
00115   // Reset
00116   aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_RESET" ) ),
00117                           tr( "MNU_RESET_VIEW" ), 0, this);
00118   aAction->setStatusTip(tr("DSC_RESET_VIEW"));
00119   connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
00120   myActionsMap[ ResetId ] = aAction;
00121 }
00122 
00126 void SUPERVGraph_ViewFrame::createToolBar()
00127 {
00128   myToolBar->addAction( myActionsMap[PanId] );
00129   myToolBar->addAction( myActionsMap[ResetId] );
00130 }
00131 
00135 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
00136 
00140 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
00141 {
00142   return myView;
00143 }
00144 
00145 
00150 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
00151 {
00152   myView = theView;
00153 }
00154 
00155 
00159 void SUPERVGraph_ViewFrame::onViewTrihedron()
00160 {
00161 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
00162 }
00163 
00167 void SUPERVGraph_ViewFrame::onViewTop()
00168 {
00169 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
00170 }
00171 
00175 void SUPERVGraph_ViewFrame::onViewBottom()
00176 {
00177 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
00178 }
00179 
00183 void SUPERVGraph_ViewFrame::onViewLeft()    
00184 {
00185 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
00186 }
00187 
00191 void SUPERVGraph_ViewFrame::onViewRight()
00192 {
00193 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
00194 }
00195 
00199 void SUPERVGraph_ViewFrame::onViewBack()
00200 {
00201 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
00202 }
00203 
00207 void SUPERVGraph_ViewFrame::onViewFront()
00208 {
00209 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
00210 }
00211 
00215 void SUPERVGraph_ViewFrame::onViewReset()    
00216 {
00217 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
00218     if (myView)
00219       myView->ResetView();
00220 }
00221 
00225 void SUPERVGraph_ViewFrame::onViewRotate()
00226 {
00227 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
00228 }
00229 
00233 void SUPERVGraph_ViewFrame::onViewGlobalPan()
00234 {
00235 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
00236 }
00237 
00241 void SUPERVGraph_ViewFrame::onViewZoom()
00242 {
00243 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
00244 }
00245 
00249 void SUPERVGraph_ViewFrame::onViewPan()
00250 {
00251 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
00252     if (myView != NULL)
00253       myView->ActivatePanning();
00254 }
00255 
00259 void SUPERVGraph_ViewFrame::onViewFitArea()
00260 {
00261 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
00262 }
00263 
00267 void SUPERVGraph_ViewFrame::onViewFitAll()
00268 {
00269 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
00270 }
00271 
00275 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
00276 {
00277   if (myView) {
00278     QPalette palette;
00279     palette.setColor(myView->backgroundRole(), color);
00280     myView->setPalette(palette);
00281   }
00282 }
00283 
00287 QColor SUPERVGraph_ViewFrame::backgroundColor() const
00288 {
00289   if (myView)
00290     return myView->palette().color( myView->backgroundRole() );
00291   return palette().color( backgroundRole() );
00292 }
00293 
00296 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
00297 {
00298 //  MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )  
00299 }
00300 
00306 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, 
00307                                     QString newName )
00308 {
00309 //  MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
00310 }
00311 
00316 void SUPERVGraph_ViewFrame::unHighlightAll() 
00317 {
00318 //  MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
00319 }
00320 
00327 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, 
00328                                        bool highlight, bool immediatly ) 
00329 {
00330 //  MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
00331 }
00332 
00338 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) 
00339 {
00340 //  MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
00341   return false;
00342 }
00343 
00348 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) 
00349 {
00350 //  MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
00351   return false;
00352 }
00353 
00357 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
00358 {
00359   QMainWindow::resizeEvent( theEvent );
00360   if ( myView ) myView->resizeView( theEvent );
00361 }