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 )
140 Display/hide Trihedron
142 void SUPERVGraph_ViewFrame::onViewTrihedron()
144 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
148 Provides top projection of the active view
150 void SUPERVGraph_ViewFrame::onViewTop()
152 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
156 Provides bottom projection of the active view
158 void SUPERVGraph_ViewFrame::onViewBottom()
160 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
164 Provides left projection of the active view
166 void SUPERVGraph_ViewFrame::onViewLeft()
168 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
172 Provides right projection of the active view
174 void SUPERVGraph_ViewFrame::onViewRight()
176 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
180 Provides back projection of the active view
182 void SUPERVGraph_ViewFrame::onViewBack()
184 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
188 Provides front projection of the active view
190 void SUPERVGraph_ViewFrame::onViewFront()
192 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
196 Reset the active view
198 void SUPERVGraph_ViewFrame::onViewReset()
200 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
206 Rotates the active view
208 void SUPERVGraph_ViewFrame::onViewRotate()
210 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
214 Sets a new center of the active view
216 void SUPERVGraph_ViewFrame::onViewGlobalPan()
218 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
222 Zooms the active view
224 void SUPERVGraph_ViewFrame::onViewZoom()
226 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
230 Moves the active view
232 void SUPERVGraph_ViewFrame::onViewPan()
234 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
236 myView->ActivatePanning();
240 Fits all obejcts within a rectangular area of the active view
242 void SUPERVGraph_ViewFrame::onViewFitArea()
244 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
248 Fits all objects in the active view
250 void SUPERVGraph_ViewFrame::onViewFitAll()
252 // MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
256 Set background of the viewport
258 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
261 myView->setPaletteBackgroundColor(color);
265 Returns background of the viewport
267 QColor SUPERVGraph_ViewFrame::backgroundColor() const
270 return myView->paletteBackgroundColor();
271 return QMainWindow::backgroundColor();
274 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
276 // MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )
279 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject,
282 // MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
285 void SUPERVGraph_ViewFrame::unHighlightAll()
287 // MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
290 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject,
291 bool highlight, bool immediatly )
293 // MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
296 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject )
298 // MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
302 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
304 // MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
308 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
310 QMainWindow::resizeEvent( theEvent );
311 if ( myView ) myView->resizeView( theEvent );