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>
41 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
46 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
51 void SUPERVGraph_View::contextMenuPopup( QPopupMenu* )
56 void SUPERVGraph_View::init( QWidget* theParent )
58 if ( theParent->inherits( "QMainWindow" ) ) {
59 ( ( QMainWindow* )theParent )->setCentralWidget( this );
62 QBoxLayout* layout = new QVBoxLayout( theParent );
63 layout->addWidget( this );
71 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop )
72 : SUIT_ViewWindow( theDesktop )
76 //myView = new SUPERVGraph_View(this);
77 // Set BackgroundColor
79 int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
80 int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
81 int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
82 setBackgroundColor(QColor(R,G,B));*/
84 myToolBar = new QToolBar(this);
85 myToolBar->setCloseMode(QDockWindow::Undocked);
86 myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
91 void SUPERVGraph_ViewFrame::createActions()
93 if (!myActionsMap.isEmpty()) return;
94 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
98 aAction = new QAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_PAN" ) ),
99 tr( "MNU_PAN_VIEW" ), 0, this);
100 aAction->setStatusTip(tr("DSC_PAN_VIEW"));
101 connect(aAction, SIGNAL(activated()), this, SLOT(onViewPan()));
102 myActionsMap[ PanId ] = aAction;
105 aAction = new QAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "SUPERVGraph", tr( "ICON_SUPERVGraph_RESET" ) ),
106 tr( "MNU_RESET_VIEW" ), 0, this);
107 aAction->setStatusTip(tr("DSC_RESET_VIEW"));
108 connect(aAction, SIGNAL(activated()), this, SLOT(onViewReset()));
109 myActionsMap[ ResetId ] = aAction;
112 //================================================================
113 // Function : createToolBar
115 //================================================================
116 void SUPERVGraph_ViewFrame::createToolBar()
118 myActionsMap[PanId]->addTo(myToolBar);
119 myActionsMap[ResetId]->addTo(myToolBar);
122 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
125 Returns widget containing 3D-Viewer
127 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
133 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
136 setFocusProxy( myView ); // mkr : IPAL11388
141 Display/hide Trihedron
143 void SUPERVGraph_ViewFrame::onViewTrihedron()
145 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
149 Provides top projection of the active view
151 void SUPERVGraph_ViewFrame::onViewTop()
153 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
157 Provides bottom projection of the active view
159 void SUPERVGraph_ViewFrame::onViewBottom()
161 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
165 Provides left projection of the active view
167 void SUPERVGraph_ViewFrame::onViewLeft()
169 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
173 Provides right projection of the active view
175 void SUPERVGraph_ViewFrame::onViewRight()
177 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
181 Provides back projection of the active view
183 void SUPERVGraph_ViewFrame::onViewBack()
185 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
189 Provides front projection of the active view
191 void SUPERVGraph_ViewFrame::onViewFront()
193 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
197 Reset the active view
199 void SUPERVGraph_ViewFrame::onViewReset()
201 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
207 Rotates the active view
209 void SUPERVGraph_ViewFrame::onViewRotate()
211 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
215 Sets a new center of the active view
217 void SUPERVGraph_ViewFrame::onViewGlobalPan()
219 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
223 Zooms the active view
225 void SUPERVGraph_ViewFrame::onViewZoom()
227 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
231 Moves the active view
233 void SUPERVGraph_ViewFrame::onViewPan()
235 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
237 myView->ActivatePanning();
241 Fits all obejcts within a rectangular area of the active view
243 void SUPERVGraph_ViewFrame::onViewFitArea()
245 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
249 Fits all objects in the active view
251 void SUPERVGraph_ViewFrame::onViewFitAll()
253 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
257 Set background of the viewport
259 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
262 myView->setPaletteBackgroundColor(color);
266 Returns background of the viewport
268 QColor SUPERVGraph_ViewFrame::backgroundColor() const
271 return myView->paletteBackgroundColor();
272 return QMainWindow::backgroundColor();
275 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
277 // MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )
280 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject,
283 // MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
286 void SUPERVGraph_ViewFrame::unHighlightAll()
288 // MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
291 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject,
292 bool highlight, bool immediatly )
294 // MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
297 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject )
299 // MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
303 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
305 // MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
309 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
311 QMainWindow::resizeEvent( theEvent );
312 if ( myView ) myView->resizeView( theEvent );