1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME SUPERVGraph : build Supervisor viewer into desktop
23 // File : SUPERVGraph_ViewFrame.cxx
24 // Author : Nicolas REJNERI
28 #include "SUPERVGraph_ViewFrame.h"
30 #include <SUIT_ResourceMgr.h>
31 #include <SUIT_Session.h>
34 #include <QVBoxLayout>
43 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
51 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
57 Builds popup for SUPERVGraph viewer
59 void SUPERVGraph_View::contextMenuPopup( QMenu* )
67 void SUPERVGraph_View::init( QWidget* theParent )
69 if ( theParent->inherits( "QMainWindow" ) ) {
70 ( ( QMainWindow* )theParent )->setCentralWidget( this );
73 QBoxLayout* layout = new QVBoxLayout( theParent );
74 layout->addWidget( this );
82 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop )
83 : SUIT_ViewWindow( theDesktop )
87 //myView = new SUPERVGraph_View(this);
88 // Set BackgroundColor
90 int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
91 int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
92 int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
93 setBackgroundColor(QColor(R,G,B));*/
95 myToolBar = new QToolBar(this);
96 //myToolBar->setCloseMode(QDockWindow::Undocked);
97 myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL"));
103 Creates actions of SUPERVGraph view window
105 void SUPERVGraph_ViewFrame::createActions()
107 if (!myActionsMap.isEmpty()) return;
108 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
112 aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
113 tr( "MNU_PAN_VIEW" ), 0, this);
114 aAction->setStatusTip(tr("DSC_PAN_VIEW"));
115 connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
116 myActionsMap[ PanId ] = aAction;
119 aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_RESET" ) ),
120 tr( "MNU_RESET_VIEW" ), 0, this);
121 aAction->setStatusTip(tr("DSC_RESET_VIEW"));
122 connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
123 myActionsMap[ ResetId ] = aAction;
127 Creates toolbar of SUPERVGraph view window
129 void SUPERVGraph_ViewFrame::createToolBar()
131 myToolBar->addAction( myActionsMap[PanId] );
132 myToolBar->addAction( myActionsMap[ResetId] );
138 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
141 Returns widget containing 3D-Viewer
143 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
151 \param theView - new view widget
153 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
160 Display/hide Trihedron
162 void SUPERVGraph_ViewFrame::onViewTrihedron()
164 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
168 Provides top projection of the active view
170 void SUPERVGraph_ViewFrame::onViewTop()
172 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
176 Provides bottom projection of the active view
178 void SUPERVGraph_ViewFrame::onViewBottom()
180 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
184 Provides left projection of the active view
186 void SUPERVGraph_ViewFrame::onViewLeft()
188 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
192 Provides right projection of the active view
194 void SUPERVGraph_ViewFrame::onViewRight()
196 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
200 Provides back projection of the active view
202 void SUPERVGraph_ViewFrame::onViewBack()
204 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
208 Provides front projection of the active view
210 void SUPERVGraph_ViewFrame::onViewFront()
212 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
216 Reset the active view
218 void SUPERVGraph_ViewFrame::onViewReset()
220 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
226 Rotates the active view
228 void SUPERVGraph_ViewFrame::onViewRotate()
230 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
234 Sets a new center of the active view
236 void SUPERVGraph_ViewFrame::onViewGlobalPan()
238 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
242 Zooms the active view
244 void SUPERVGraph_ViewFrame::onViewZoom()
246 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
250 Moves the active view
252 void SUPERVGraph_ViewFrame::onViewPan()
254 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
256 myView->ActivatePanning();
260 Fits all obejcts within a rectangular area of the active view
262 void SUPERVGraph_ViewFrame::onViewFitArea()
264 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
268 Fits all objects in the active view
270 void SUPERVGraph_ViewFrame::onViewFitAll()
272 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
276 Set background of the viewport
278 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
282 palette.setColor(myView->backgroundRole(), color);
283 myView->setPalette(palette);
288 Returns background of the viewport
290 QColor SUPERVGraph_ViewFrame::backgroundColor() const
293 return myView->palette().color( myView->backgroundRole() );
294 return palette().color( backgroundRole() );
299 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
301 // MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )
305 Changes name of object
306 \param obj - object to be renamed
307 \param name - new name
309 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject,
312 // MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
316 Unhilights all object in viewer
317 \param updateviewer - update current viewer
319 void SUPERVGraph_ViewFrame::unHighlightAll()
321 // MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
325 Hilights/unhilights object in viewer
326 \param obj - object to be updated
327 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
328 \param update - update current viewer
330 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject,
331 bool highlight, bool immediatly )
333 // MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
337 \return true if object is in viewer or in collector
338 \param obj - object to be checked
339 \param onlyInViewer - search object only in viewer (so object must be displayed)
341 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject )
343 // MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
348 \return true if object is displayed in viewer
349 \param obj - object to be checked
351 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
353 // MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
358 Custom resize event handler
360 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
362 QMainWindow::resizeEvent( theEvent );
363 if ( myView ) myView->resizeView( theEvent );