]> SALOME platform Git repositories - modules/gui.git/blob - src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx
Salome HOME
1a8362daac37138cb1dadb623ea4aaa57012b990
[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 }
137
138
139 /*!
140   Display/hide Trihedron
141 */
142 void SUPERVGraph_ViewFrame::onViewTrihedron()
143 {
144 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
145 }
146
147 /*!
148   Provides top projection of the active view
149 */
150 void SUPERVGraph_ViewFrame::onViewTop()
151 {
152 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
153 }
154
155 /*!
156   Provides bottom projection of the active view
157 */
158 void SUPERVGraph_ViewFrame::onViewBottom()
159 {
160 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
161 }
162
163 /*!
164   Provides left projection of the active view
165 */
166 void SUPERVGraph_ViewFrame::onViewLeft()    
167 {
168 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
169 }
170
171 /*!
172   Provides right projection of the active view
173 */
174 void SUPERVGraph_ViewFrame::onViewRight()
175 {
176 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
177 }
178
179 /*!
180   Provides back projection of the active view
181 */
182 void SUPERVGraph_ViewFrame::onViewBack()
183 {
184 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
185 }
186
187 /*!
188   Provides front projection of the active view
189 */
190 void SUPERVGraph_ViewFrame::onViewFront()
191 {
192 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
193 }
194
195 /*!
196   Reset the active view
197 */
198 void SUPERVGraph_ViewFrame::onViewReset()    
199 {
200 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
201     if (myView)
202       myView->ResetView();
203 }
204
205 /*!
206   Rotates the active view
207 */
208 void SUPERVGraph_ViewFrame::onViewRotate()
209 {
210 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
211 }
212
213 /*!
214   Sets a new center of the active view
215 */
216 void SUPERVGraph_ViewFrame::onViewGlobalPan()
217 {
218 //   MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
219 }
220
221 /*!
222   Zooms the active view
223 */
224 void SUPERVGraph_ViewFrame::onViewZoom()
225 {
226 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
227 }
228
229 /*!
230   Moves the active view
231 */
232 void SUPERVGraph_ViewFrame::onViewPan()
233 {
234 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
235     if (myView != NULL)
236       myView->ActivatePanning();
237 }
238
239 /*!
240   Fits all obejcts within a rectangular area of the active view
241 */
242 void SUPERVGraph_ViewFrame::onViewFitArea()
243 {
244 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
245 }
246
247 /*!
248   Fits all objects in the active view
249 */
250 void SUPERVGraph_ViewFrame::onViewFitAll()
251 {
252 //  MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
253 }
254
255 /*!
256     Set background of the viewport
257 */
258 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color )
259 {
260     if (myView)
261       myView->setPaletteBackgroundColor(color);
262 }
263
264 /*!
265     Returns background of the viewport
266 */
267 QColor SUPERVGraph_ViewFrame::backgroundColor() const
268 {
269   if (myView)
270     return myView->paletteBackgroundColor();
271   return QMainWindow::backgroundColor();
272 }
273
274 void SUPERVGraph_ViewFrame::onAdjustTrihedron()
275 {
276 //  MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )  
277 }
278
279 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, 
280                                     QString newName )
281 {
282 //  MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
283 }
284
285 void SUPERVGraph_ViewFrame::unHighlightAll() 
286 {
287 //  MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
288 }
289
290 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, 
291                                        bool highlight, bool immediatly ) 
292 {
293 //  MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
294 }
295
296 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) 
297 {
298 //  MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
299   return false;
300 }
301
302 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) 
303 {
304 //  MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
305   return false;
306 }
307
308 void SUPERVGraph_ViewFrame::resizeEvent( QResizeEvent* theEvent )
309 {
310   QMainWindow::resizeEvent( theEvent );
311   if ( myView ) myView->resizeView( theEvent );
312 }