-// 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"
-//QT Include
-#include <qlayout.h>
-#include <qcolordialog.h>
-
-using namespace std;
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+//QT Include
+#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" ) ) {
int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
setBackgroundColor(QColor(R,G,B));*/
+
+ myToolBar = new QToolBar(this);
+ 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();
+ QtxAction* aAction;
+
+ // Panning
+ 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 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;
}
+/*!
+ Creates toolbar of SUPERVGraph view window
+*/
+void SUPERVGraph_ViewFrame::createToolBar()
+{
+ myToolBar->addAction( myActionsMap[PanId] );
+ myToolBar->addAction( myActionsMap[ResetId] );
+}
+
+/*!
+ Destructor
+*/
SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
/*!
}
+/*!
+ Sets new view widget
+ \param theView - new view widget
+*/
void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
{
myView = theView;
*/
void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
{
- if (myView)
- myView->setPaletteBackgroundColor(color);
+ if (myView) {
+ QPalette palette;
+ palette.setColor(myView->backgroundRole(), color);
+ myView->setPalette(palette);
+ }
}
/*!
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 );