1 // SALOME SUPERVGraph : build Supervisor viewer into desktop
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SUPERVGraph_ViewFrame.cxx
25 // Author : Nicolas REJNERI
29 #include "SUPERVGraph_ViewFrame.h"
31 #include <SUIT_ResourceMgr.h>
32 #include <SUIT_Session.h>
36 #include <qcolordialog.h>
44 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
52 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
58 Builds popup for SUPERVGraph viewer
60 void SUPERVGraph_View::contextMenuPopup( QPopupMenu* )
68 void SUPERVGraph_View::init( QWidget* theParent )
70 if ( theParent->inherits( "QMainWindow" ) ) {
71 ( ( QMainWindow* )theParent )->setCentralWidget( this );
74 QBoxLayout* layout = new QVBoxLayout( theParent );
75 layout->addWidget( this );
83 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop )
84 : SUIT_ViewWindow( theDesktop )
88 //myView = new SUPERVGraph_View(this);
89 // Set BackgroundColor
91 int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
92 int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
93 int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
94 setBackgroundColor(QColor(R,G,B));*/
96 myToolBar = new QToolBar(this);
97 myToolBar->setCloseMode(QDockWindow::Undocked);
98 myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
104 Creates actions of SUPERVGraph view window
106 void SUPERVGraph_ViewFrame::createActions()
108 if (!myActionsMap.isEmpty()) return;
109 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
113 aAction = new QAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
114 tr( "MNU_PAN_VIEW" ), 0, this);
115 aAction->setStatusTip(tr("DSC_PAN_VIEW"));
116 connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
117 myActionsMap[ PanId ] = aAction;
120 aAction = new QAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_RESET" ) ),
121 tr( "MNU_RESET_VIEW" ), 0, this);
122 aAction->setStatusTip(tr("DSC_RESET_VIEW"));
123 connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
124 myActionsMap[ ResetId ] = aAction;
128 Creates toolbar of SUPERVGraph view window
130 void SUPERVGraph_ViewFrame::createToolBar()
132 myActionsMap[PanId]->addTo(myToolBar);
133 myActionsMap[ResetId]->addTo(myToolBar);
139 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
142 Returns widget containing 3D-Viewer
144 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
152 \param theView - new view widget
154 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
161 Display/hide Trihedron
163 void SUPERVGraph_ViewFrame::onViewTrihedron()
165 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
169 Provides top projection of the active view
171 void SUPERVGraph_ViewFrame::onViewTop()
173 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
177 Provides bottom projection of the active view
179 void SUPERVGraph_ViewFrame::onViewBottom()
181 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
185 Provides left projection of the active view
187 void SUPERVGraph_ViewFrame::onViewLeft()
189 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
193 Provides right projection of the active view
195 void SUPERVGraph_ViewFrame::onViewRight()
197 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
201 Provides back projection of the active view
203 void SUPERVGraph_ViewFrame::onViewBack()
205 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
209 Provides front projection of the active view
211 void SUPERVGraph_ViewFrame::onViewFront()
213 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
217 Reset the active view
219 void SUPERVGraph_ViewFrame::onViewReset()
221 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
227 Rotates the active view
229 void SUPERVGraph_ViewFrame::onViewRotate()
231 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
235 Sets a new center of the active view
237 void SUPERVGraph_ViewFrame::onViewGlobalPan()
239 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
243 Zooms the active view
245 void SUPERVGraph_ViewFrame::onViewZoom()
247 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
251 Moves the active view
253 void SUPERVGraph_ViewFrame::onViewPan()
255 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
257 myView->ActivatePanning();
261 Fits all obejcts within a rectangular area of the active view
263 void SUPERVGraph_ViewFrame::onViewFitArea()
265 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
269 Fits all objects in the active view
271 void SUPERVGraph_ViewFrame::onViewFitAll()
273 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
277 Set background of the viewport
279 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
282 myView->setPaletteBackgroundColor(color);
286 Returns background of the viewport
288 QColor SUPERVGraph_ViewFrame::backgroundColor() const
291 return myView->paletteBackgroundColor();
292 return QMainWindow::backgroundColor();
297 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
299 // MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )
303 Changes name of object
304 \param obj - object to be renamed
305 \param name - new name
307 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject,
310 // MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
314 Unhilights all object in viewer
315 \param updateviewer - update current viewer
317 void SUPERVGraph_ViewFrame::unHighlightAll()
319 // MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
323 Hilights/unhilights object in viewer
324 \param obj - object to be updated
325 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
326 \param update - update current viewer
328 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject,
329 bool highlight, bool immediatly )
331 // MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
335 \return true if object is in viewer or in collector
336 \param obj - object to be checked
337 \param onlyInViewer - search object only in viewer (so object must be displayed)
339 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject )
341 // MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
346 \return true if object is displayed in viewer
347 \param obj - object to be checked
349 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
351 // MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
356 Custom resize event handler
358 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
360 QMainWindow::resizeEvent( theEvent );
361 if ( myView ) myView->resizeView( theEvent );