]> SALOME platform Git repositories - modules/gui.git/blob - src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx
Salome HOME
716cc8fcac8f1aa6c2325fe0521f907e5e685a4c
[modules/gui.git] / src / SUPERVGraph / SUPERVGraph_ViewFrame.cxx
1 //  SALOME SUPERVGraph : build Supervisor viewer into desktop
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SUPERVGraph_ViewFrame.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #include "SUPERVGraph_ViewFrame.h"
30
31 #include <SUIT_ResourceMgr.h>
32 #include <SUIT_Session.h>
33
34 //QT Include
35 #include <qlayout.h>
36 #include <qcolordialog.h>
37
38 using namespace std;
39
40
41 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
42 {
43   init(theParent);
44 }
45
46 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
47 {
48   init(theParent);
49 }
50
51 void SUPERVGraph_View::contextMenuPopup( QPopupMenu* )
52 {
53   // to be implemented
54 }
55
56 void SUPERVGraph_View::init( QWidget* theParent )
57 {
58   if ( theParent->inherits( "QMainWindow" ) ) {
59     ( ( QMainWindow* )theParent )->setCentralWidget( this );
60   }
61   else {
62     QBoxLayout* layout = new QVBoxLayout( theParent );
63     layout->addWidget( this );
64   }
65
66 }
67
68 /*!
69     Constructor
70 */
71 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop ) 
72   : SUIT_ViewWindow( theDesktop )
73 {
74   myView = 0;
75
76   //myView = new SUPERVGraph_View(this); 
77   // Set BackgroundColor
78   /*
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));*/
83
84   myToolBar = new QToolBar(this);
85   myToolBar->setCloseMode(QDockWindow::Undocked);
86   myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
87   createActions();
88   createToolBar();
89 }
90
91 void SUPERVGraph_ViewFrame::createActions()
92 {
93   if (!myActionsMap.isEmpty()) return;
94   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
95   QAction* aAction;
96
97   // Panning
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;
103
104   // Reset
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;
110 }
111
112 //================================================================
113 // Function : createToolBar
114 // Purpose  : 
115 //================================================================
116 void SUPERVGraph_ViewFrame::createToolBar()
117 {
118   myActionsMap[PanId]->addTo(myToolBar);
119   myActionsMap[ResetId]->addTo(myToolBar);
120 }
121
122 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
123
124 /*!
125   Returns widget containing 3D-Viewer
126 */
127 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
128 {
129   return myView;
130 }
131
132
133 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
134 {
135   myView = theView;
136   setFocusProxy( myView ); // mkr : IPAL11388
137 }
138
139
140 /*!
141   Display/hide Trihedron
142 */
143 void SUPERVGraph_ViewFrame::onViewTrihedron()
144 {
145 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
146 }
147
148 /*!
149   Provides top projection of the active view
150 */
151 void SUPERVGraph_ViewFrame::onViewTop()
152 {
153 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
154 }
155
156 /*!
157   Provides bottom projection of the active view
158 */
159 void SUPERVGraph_ViewFrame::onViewBottom()
160 {
161 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
162 }
163
164 /*!
165   Provides left projection of the active view
166 */
167 void SUPERVGraph_ViewFrame::onViewLeft()    
168 {
169 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
170 }
171
172 /*!
173   Provides right projection of the active view
174 */
175 void SUPERVGraph_ViewFrame::onViewRight()
176 {
177 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
178 }
179
180 /*!
181   Provides back projection of the active view
182 */
183 void SUPERVGraph_ViewFrame::onViewBack()
184 {
185 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
186 }
187
188 /*!
189   Provides front projection of the active view
190 */
191 void SUPERVGraph_ViewFrame::onViewFront()
192 {
193 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
194 }
195
196 /*!
197   Reset the active view
198 */
199 void SUPERVGraph_ViewFrame::onViewReset()    
200 {
201 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
202     if (myView)
203       myView->ResetView();
204 }
205
206 /*!
207   Rotates the active view
208 */
209 void SUPERVGraph_ViewFrame::onViewRotate()
210 {
211 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
212 }
213
214 /*!
215   Sets a new center of the active view
216 */
217 void SUPERVGraph_ViewFrame::onViewGlobalPan()
218 {
219 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
220 }
221
222 /*!
223   Zooms the active view
224 */
225 void SUPERVGraph_ViewFrame::onViewZoom()
226 {
227 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
228 }
229
230 /*!
231   Moves the active view
232 */
233 void SUPERVGraph_ViewFrame::onViewPan()
234 {
235 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
236     if (myView != NULL)
237       myView->ActivatePanning();
238 }
239
240 /*!
241   Fits all obejcts within a rectangular area of the active view
242 */
243 void SUPERVGraph_ViewFrame::onViewFitArea()
244 {
245 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
246 }
247
248 /*!
249   Fits all objects in the active view
250 */
251 void SUPERVGraph_ViewFrame::onViewFitAll()
252 {
253 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
254 }
255
256 /*!
257     Set background of the viewport
258 */
259 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
260 {
261     if (myView)
262       myView->setPaletteBackgroundColor(color);
263 }
264
265 /*!
266     Returns background of the viewport
267 */
268 QColor SUPERVGraph_ViewFrame::backgroundColor() const
269 {
270   if (myView)
271     return myView->paletteBackgroundColor();
272   return QMainWindow::backgroundColor();
273 }
274
275 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
276 {
277 //  MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )  
278 }
279
280 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, 
281                                     QString newName )
282 {
283 //  MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
284 }
285
286 void SUPERVGraph_ViewFrame::unHighlightAll() 
287 {
288 //  MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
289 }
290
291 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, 
292                                        bool highlight, bool immediatly ) 
293 {
294 //  MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
295 }
296
297 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) 
298 {
299 //  MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
300   return false;
301 }
302
303 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) 
304 {
305 //  MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
306   return false;
307 }
308
309 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
310 {
311   QMainWindow::resizeEvent( theEvent );
312   if ( myView ) myView->resizeView( theEvent );
313 }