]> SALOME platform Git repositories - modules/gui.git/blob - src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx
Salome HOME
9bbf6431d692e4e4f432dc53ffead77c4a53833e
[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 /*!
42   Constructor
43 */
44 SUPERVGraph_View::SUPERVGraph_View( QWidget* theParent ): QWidget( theParent )
45 {
46   init(theParent);
47 }
48
49 /*!
50   Constructor
51 */
52 SUPERVGraph_View::SUPERVGraph_View( SUPERVGraph_View* theParent ): QWidget( theParent )
53 {
54   init(theParent);
55 }
56
57 /*!
58   Builds popup for SUPERVGraph viewer
59 */
60 void SUPERVGraph_View::contextMenuPopup( QPopupMenu* )
61 {
62   // to be implemented
63 }
64
65 /*!
66   Initialization
67 */
68 void SUPERVGraph_View::init( QWidget* theParent )
69 {
70   if ( theParent->inherits( "QMainWindow" ) ) {
71     ( ( QMainWindow* )theParent )->setCentralWidget( this );
72   }
73   else {
74     QBoxLayout* layout = new QVBoxLayout( theParent );
75     layout->addWidget( this );
76   }
77
78 }
79
80 /*!
81     Constructor
82 */
83 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame( SUIT_Desktop* theDesktop ) 
84   : SUIT_ViewWindow( theDesktop )
85 {
86   myView = 0;
87
88   //myView = new SUPERVGraph_View(this); 
89   // Set BackgroundColor
90   /*
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));*/
95
96   myToolBar = new QToolBar(this);
97   myToolBar->setCloseMode(QDockWindow::Undocked);
98   myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
99   createActions();
100   createToolBar();
101 }
102
103 /*!
104   Creates actions of SUPERVGraph view window
105 */
106 void SUPERVGraph_ViewFrame::createActions()
107 {
108   if (!myActionsMap.isEmpty()) return;
109   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
110   QAction* aAction;
111
112   // Panning
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;
118
119   // Reset
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;
125 }
126
127 /*!
128   Creates toolbar of SUPERVGraph view window
129 */
130 void SUPERVGraph_ViewFrame::createToolBar()
131 {
132   myActionsMap[PanId]->addTo(myToolBar);
133   myActionsMap[ResetId]->addTo(myToolBar);
134 }
135
136 /*!
137   Destructor
138 */
139 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame() {}
140
141 /*!
142   Returns widget containing 3D-Viewer
143 */
144 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget()
145 {
146   return myView;
147 }
148
149
150 /*!
151   Sets new view widget
152   \param theView - new view widget
153 */
154 void SUPERVGraph_ViewFrame::setViewWidget( SUPERVGraph_View* theView )
155 {
156   myView = theView;
157 }
158
159
160 /*!
161   Display/hide Trihedron
162 */
163 void SUPERVGraph_ViewFrame::onViewTrihedron()
164 {
165 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
166 }
167
168 /*!
169   Provides top projection of the active view
170 */
171 void SUPERVGraph_ViewFrame::onViewTop()
172 {
173 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
174 }
175
176 /*!
177   Provides bottom projection of the active view
178 */
179 void SUPERVGraph_ViewFrame::onViewBottom()
180 {
181 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
182 }
183
184 /*!
185   Provides left projection of the active view
186 */
187 void SUPERVGraph_ViewFrame::onViewLeft()    
188 {
189 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
190 }
191
192 /*!
193   Provides right projection of the active view
194 */
195 void SUPERVGraph_ViewFrame::onViewRight()
196 {
197 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
198 }
199
200 /*!
201   Provides back projection of the active view
202 */
203 void SUPERVGraph_ViewFrame::onViewBack()
204 {
205 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
206 }
207
208 /*!
209   Provides front projection of the active view
210 */
211 void SUPERVGraph_ViewFrame::onViewFront()
212 {
213 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
214 }
215
216 /*!
217   Reset the active view
218 */
219 void SUPERVGraph_ViewFrame::onViewReset()    
220 {
221 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
222     if (myView)
223       myView->ResetView();
224 }
225
226 /*!
227   Rotates the active view
228 */
229 void SUPERVGraph_ViewFrame::onViewRotate()
230 {
231 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
232 }
233
234 /*!
235   Sets a new center of the active view
236 */
237 void SUPERVGraph_ViewFrame::onViewGlobalPan()
238 {
239 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
240 }
241
242 /*!
243   Zooms the active view
244 */
245 void SUPERVGraph_ViewFrame::onViewZoom()
246 {
247 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
248 }
249
250 /*!
251   Moves the active view
252 */
253 void SUPERVGraph_ViewFrame::onViewPan()
254 {
255 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
256     if (myView != NULL)
257       myView->ActivatePanning();
258 }
259
260 /*!
261   Fits all obejcts within a rectangular area of the active view
262 */
263 void SUPERVGraph_ViewFrame::onViewFitArea()
264 {
265 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
266 }
267
268 /*!
269   Fits all objects in the active view
270 */
271 void SUPERVGraph_ViewFrame::onViewFitAll()
272 {
273 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
274 }
275
276 /*!
277     Set background of the viewport
278 */
279 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
280 {
281     if (myView)
282       myView->setPaletteBackgroundColor(color);
283 }
284
285 /*!
286     Returns background of the viewport
287 */
288 QColor SUPERVGraph_ViewFrame::backgroundColor() const
289 {
290   if (myView)
291     return myView->paletteBackgroundColor();
292   return QMainWindow::backgroundColor();
293 }
294
295 /*!
296 */
297 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
298 {
299 //  MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )  
300 }
301
302 /*!
303   Changes name of object
304   \param obj - object to be renamed
305   \param name - new name
306 */
307 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, 
308                                     QString newName )
309 {
310 //  MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
311 }
312
313 /*!
314   Unhilights all object in viewer
315   \param updateviewer - update current viewer
316 */
317 void SUPERVGraph_ViewFrame::unHighlightAll() 
318 {
319 //  MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
320 }
321
322 /*!
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
327 */
328 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, 
329                                        bool highlight, bool immediatly ) 
330 {
331 //  MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
332 }
333
334 /*!
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)
338 */
339 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) 
340 {
341 //  MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
342   return false;
343 }
344
345 /*!
346   \return true if object is displayed in viewer
347   \param obj - object to be checked
348 */
349 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) 
350 {
351 //  MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
352   return false;
353 }
354
355 /*!
356   Custom resize event handler
357 */
358 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
359 {
360   QMainWindow::resizeEvent( theEvent );
361   if ( myView ) myView->resizeView( theEvent );
362 }