Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / SUPERVGraph / SUPERVGraph_ViewFrame.cxx
index 716cc8fcac8f1aa6c2325fe0521f907e5e685a4c..8cebe97db462c76c724ca82144ad301454fbba43 100755 (executable)
@@ -1,30 +1,28 @@
-//  SALOME SUPERVGraph : build Supervisor viewer into desktop
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  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 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+//  SALOME SUPERVGraph : build Supervisor viewer into desktop
 //  File   : SUPERVGraph_ViewFrame.cxx
 //  Author : Nicolas REJNERI
-//  Module : SALOME
-//  $Header$
 
 #include "SUPERVGraph_ViewFrame.h"
 
 #include <SUIT_Session.h>
 
 //QT Include
-#include <qlayout.h>
-#include <qcolordialog.h>
-
-using namespace std;
-
+#include <QVBoxLayout>
+#include <QToolBar>
 
+/*!
+  Constructor
+*/
 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
 {
   init(theParent);
 }
 
+/*!
+  Constructor
+*/
 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
 {
   init(theParent);
 }
 
-void SUPERVGraph_View::contextMenuPopup( QPopupMenu* )
+/*!
+  Builds popup for SUPERVGraph viewer
+*/
+void SUPERVGraph_View::contextMenuPopup( QMenu* )
 {
   // to be implemented
 }
 
+/*!
+  Initialization
+*/
 void SUPERVGraph_View::init( QWidget* theParent )
 {
   if ( theParent->inherits( "QMainWindow" ) ) {
@@ -82,43 +89,49 @@ SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop )
   setBackgroundColor(QColor(R,G,B));*/
 
   myToolBar = new QToolBar(this);
-  myToolBar->setCloseMode(QDockWindow::Undocked);
-  myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+  myToolBar->setFloatable(false);
+  //myToolBar->setCloseMode(QDockWindow::Undocked);
+  myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL"));
   createActions();
   createToolBar();
 }
 
+/*!
+  Creates actions of SUPERVGraph view window
+*/
 void SUPERVGraph_ViewFrame::createActions()
 {
   if (!myActionsMap.isEmpty()) return;
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-  QAction* aAction;
+  QtxAction* aAction;
 
   // Panning
-  aAction = new QAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
-                       tr( "MNU_PAN_VIEW" ), 0, this);
+  aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
+                          tr( "MNU_PAN_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_PAN_VIEW"));
   connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
   myActionsMap[ PanId ] = aAction;
 
   // Reset
-  aAction = new QAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_RESET" ) ),
-                       tr( "MNU_RESET_VIEW" ), 0, this);
+  aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_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 SUPERVGraph view window
+*/
 void SUPERVGraph_ViewFrame::createToolBar()
 {
-  myActionsMap[PanId]->addTo(myToolBar);
-  myActionsMap[ResetId]->addTo(myToolBar);
+  myToolBar->addAction( myActionsMap[PanId] );
+  myToolBar->addAction( myActionsMap[ResetId] );
 }
 
+/*!
+  Destructor
+*/
 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
 
 /*!
@@ -130,10 +143,13 @@ SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
 }
 
 
+/*!
+  Sets new view widget
+  \param theView - new view widget
+*/
 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
 {
   myView = theView;
-  setFocusProxy( myView ); // mkr : IPAL11388
 }
 
 
@@ -258,8 +274,11 @@ void SUPERVGraph_ViewFrame::onViewFitAll()
 */
 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
 {
-    if (myView)
-      myView->setPaletteBackgroundColor(color);
+  if (myView) {
+    QPalette palette;
+    palette.setColor(myView->backgroundRole(), color);
+    myView->setPalette(palette);
+  }
 }
 
 /*!
@@ -268,44 +287,73 @@ void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
 QColor SUPERVGraph_ViewFrame::backgroundColor() const
 {
   if (myView)
-    return myView->paletteBackgroundColor();
-  return QMainWindow::backgroundColor();
+    return myView->palette().color( myView->backgroundRole() );
+  return palette().color( backgroundRole() );
 }
 
+/*!
+*/
 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
 {
 //  MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )  
 }
 
+/*!
+  Changes name of object
+  \param obj - object to be renamed
+  \param name - new name
+*/
 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, 
-                                   QString newName )
+                                    QString newName )
 {
 //  MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
 }
 
+/*!
+  Unhilights all object in viewer
+  \param updateviewer - update current viewer
+*/
 void SUPERVGraph_ViewFrame::unHighlightAll() 
 {
 //  MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
 }
 
+/*!
+  Hilights/unhilights object in viewer
+  \param obj - object to be updated
+  \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
+  \param update - update current viewer
+*/
 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, 
-                                      bool highlight, bool immediatly ) 
+                                       bool highlight, bool immediatly ) 
 {
 //  MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
 }
 
+/*!
+  \return true if object is in viewer or in collector
+  \param obj - object to be checked
+  \param onlyInViewer - search object only in viewer (so object must be displayed)
+*/
 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) 
 {
 //  MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
   return false;
 }
 
+/*!
+  \return true if object is displayed in viewer
+  \param obj - object to be checked
+*/
 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) 
 {
 //  MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
   return false;
 }
 
+/*!
+  Custom resize event handler
+*/
 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
 {
   QMainWindow::resizeEvent( theEvent );