1 // Copyright (C) 2007-2013 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
23 // SALOME SUPERVGraph : build Supervisor viewer into desktop
24 // File : SUPERVGraph_ViewFrame.cxx
25 // Author : Nicolas REJNERI
27 #include "SUPERVGraph_ViewFrame.h"
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
33 #include <QVBoxLayout>
39 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
47 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
53 Builds popup for SUPERVGraph viewer
55 void SUPERVGraph_View::contextMenuPopup( QMenu* )
63 void SUPERVGraph_View::init( QWidget* theParent )
65 if ( theParent->inherits( "QMainWindow" ) ) {
66 ( ( QMainWindow* )theParent )->setCentralWidget( this );
69 QBoxLayout* layout = new QVBoxLayout( theParent );
70 layout->addWidget( this );
78 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop )
79 : SUIT_ViewWindow( theDesktop )
83 //myView = new SUPERVGraph_View(this);
84 // Set BackgroundColor
86 int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
87 int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
88 int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
89 setBackgroundColor(QColor(R,G,B));*/
91 myToolBar = new QToolBar(this);
92 myToolBar->setFloatable(false);
93 //myToolBar->setCloseMode(QDockWindow::Undocked);
94 myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL"));
100 Creates actions of SUPERVGraph view window
102 void SUPERVGraph_ViewFrame::createActions()
104 if (!myActionsMap.isEmpty()) return;
105 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
109 aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
110 tr( "MNU_PAN_VIEW" ), 0, this);
111 aAction->setStatusTip(tr("DSC_PAN_VIEW"));
112 connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
113 myActionsMap[ PanId ] = aAction;
116 aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_RESET" ) ),
117 tr( "MNU_RESET_VIEW" ), 0, this);
118 aAction->setStatusTip(tr("DSC_RESET_VIEW"));
119 connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
120 myActionsMap[ ResetId ] = aAction;
124 Creates toolbar of SUPERVGraph view window
126 void SUPERVGraph_ViewFrame::createToolBar()
128 myToolBar->addAction( myActionsMap[PanId] );
129 myToolBar->addAction( myActionsMap[ResetId] );
135 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
138 Returns widget containing 3D-Viewer
140 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
148 \param theView - new view widget
150 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
157 Display/hide Trihedron
159 void SUPERVGraph_ViewFrame::onViewTrihedron()
161 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
165 Provides top projection of the active view
167 void SUPERVGraph_ViewFrame::onViewTop()
169 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
173 Provides bottom projection of the active view
175 void SUPERVGraph_ViewFrame::onViewBottom()
177 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
181 Provides left projection of the active view
183 void SUPERVGraph_ViewFrame::onViewLeft()
185 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
189 Provides right projection of the active view
191 void SUPERVGraph_ViewFrame::onViewRight()
193 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
197 Provides back projection of the active view
199 void SUPERVGraph_ViewFrame::onViewBack()
201 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
205 Provides front projection of the active view
207 void SUPERVGraph_ViewFrame::onViewFront()
209 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
213 Reset the active view
215 void SUPERVGraph_ViewFrame::onViewReset()
217 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
223 Rotates the active view
225 void SUPERVGraph_ViewFrame::onViewRotate()
227 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
231 Sets a new center of the active view
233 void SUPERVGraph_ViewFrame::onViewGlobalPan()
235 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
239 Zooms the active view
241 void SUPERVGraph_ViewFrame::onViewZoom()
243 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
247 Moves the active view
249 void SUPERVGraph_ViewFrame::onViewPan()
251 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
253 myView->ActivatePanning();
257 Fits all obejcts within a rectangular area of the active view
259 void SUPERVGraph_ViewFrame::onViewFitArea()
261 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
265 Fits all objects in the active view
267 void SUPERVGraph_ViewFrame::onViewFitAll()
269 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
273 Set background of the viewport
275 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
279 palette.setColor(myView->backgroundRole(), color);
280 myView->setPalette(palette);
285 Returns background of the viewport
287 QColor SUPERVGraph_ViewFrame::backgroundColor() const
290 return myView->palette().color( myView->backgroundRole() );
291 return palette().color( backgroundRole() );
296 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
298 // MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )
302 Changes name of object
303 \param obj - object to be renamed
304 \param name - new name
306 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject,
309 // MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
313 Unhilights all object in viewer
314 \param updateviewer - update current viewer
316 void SUPERVGraph_ViewFrame::unHighlightAll()
318 // MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
322 Hilights/unhilights object in viewer
323 \param obj - object to be updated
324 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
325 \param update - update current viewer
327 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject,
328 bool highlight, bool immediatly )
330 // MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
334 \return true if object is in viewer or in collector
335 \param obj - object to be checked
336 \param onlyInViewer - search object only in viewer (so object must be displayed)
338 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject )
340 // MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
345 \return true if object is displayed in viewer
346 \param obj - object to be checked
348 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
350 // MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
355 Custom resize event handler
357 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
359 QMainWindow::resizeEvent( theEvent );
360 if ( myView ) myView->resizeView( theEvent );