Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.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 "QAD_Settings.h"
32 #include "QAD_Config.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "SALOME_Selection.h"
36
37 #include "utilities.h"
38
39 //QT Include
40 #include <qlayout.h>
41 #include <qcolordialog.h>
42 using namespace std;
43
44 SUPERVGraph_View::SUPERVGraph_View(QWidget* theParent): QWidget(theParent){
45   init(theParent);
46 }
47 SUPERVGraph_View::SUPERVGraph_View(SUPERVGraph_View* theParent): QWidget(theParent){
48   setPopupServer(theParent->getPopupServer());
49   init(theParent);
50 }
51 void SUPERVGraph_View::init(QWidget* theParent){
52   if ( theParent->inherits( "QMainWindow" ) ) {
53     ( ( QMainWindow* )theParent )->setCentralWidget( this );
54   }
55   else {
56     QBoxLayout* layout = new QVBoxLayout( theParent );
57     layout->addWidget( this );
58   }
59
60 }
61 void SUPERVGraph_View::onCreatePopup(){
62   /*
63   if ( myPopup ) {      
64     QAD_Desktop*     Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
65     QAD_Study*   ActiveStudy = Desktop->getActiveStudy();
66     SALOME_Selection*      Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() );
67     
68     QString theContext;
69     QString theParent("Viewer");
70     QString theObject;
71     
72     Desktop->definePopup( theContext, theParent, theObject );
73     Desktop->createPopup( myPopup, theContext, theParent, theObject);
74     Desktop->customPopup( myPopup, theContext, theParent, theObject );
75     if (Sel->IObjectCount() == 0 && myPopup->count()<1) {
76       int id;
77       myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) );    
78       QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) );
79     }
80   }
81   */
82  }
83 /*!
84     Constructor
85 */
86 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame(QWidget* parent, const char* name) 
87   : QAD_ViewFrame(parent, name)
88 {
89   myView = 0;
90   //myView = new SUPERVGraph_View(this); 
91   // Set BackgroundColor
92   /*
93   int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
94   int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
95   int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
96   setBackgroundColor(QColor(R,G,B));*/
97 }
98 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame(){}
99
100 /*!
101   Returns widget containing 3D-Viewer
102 */
103 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget(){
104   return myView;
105 }
106
107
108 void SUPERVGraph_ViewFrame::setViewWidget(SUPERVGraph_View* theView) {
109   myView = theView;
110   if (myApp) {
111     myView->setPopupServer(myApp);
112   }
113 }
114
115
116 /*!
117   Display/hide Trihedron
118 */
119 void SUPERVGraph_ViewFrame::onViewTrihedron()
120 {
121   MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
122 }
123
124 /*!
125   Provides top projection of the active view
126 */
127 void SUPERVGraph_ViewFrame::onViewTop()
128 {
129   MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
130 }
131
132 /*!
133   Provides bottom projection of the active view
134 */
135 void SUPERVGraph_ViewFrame::onViewBottom()
136 {
137   MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
138 }
139
140 /*!
141   Provides left projection of the active view
142 */
143 void SUPERVGraph_ViewFrame::onViewLeft()    
144 {
145   MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
146 }
147
148 /*!
149   Provides right projection of the active view
150 */
151 void SUPERVGraph_ViewFrame::onViewRight()
152 {
153   MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
154 }
155
156 /*!
157   Provides back projection of the active view
158 */
159 void SUPERVGraph_ViewFrame::onViewBack()
160 {
161   MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
162 }
163
164 /*!
165   Provides front projection of the active view
166 */
167 void SUPERVGraph_ViewFrame::onViewFront()
168 {
169   MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
170 }
171
172 /*!
173   Reset the active view
174 */
175 void SUPERVGraph_ViewFrame::onViewReset()    
176 {
177   MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
178     if (myView)
179       myView->ResetView();
180 }
181
182 /*!
183   Rotates the active view
184 */
185 void SUPERVGraph_ViewFrame::onViewRotate()
186 {
187    MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
188 }
189
190 /*!
191   Sets a new center of the active view
192 */
193 void SUPERVGraph_ViewFrame::onViewGlobalPan()
194 {
195    MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
196 }
197
198 /*!
199   Zooms the active view
200 */
201 void SUPERVGraph_ViewFrame::onViewZoom()
202 {
203   MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
204 }
205
206 /*!
207   Moves the active view
208 */
209 void SUPERVGraph_ViewFrame::onViewPan()
210 {
211   MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
212     if (myView != NULL)
213       myView->ActivatePanning();
214 }
215
216 /*!
217   Fits all obejcts within a rectangular area of the active view
218 */
219 void SUPERVGraph_ViewFrame::onViewFitArea()
220 {
221   MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
222 }
223
224 /*!
225   Fits all objects in the active view
226 */
227 void SUPERVGraph_ViewFrame::onViewFitAll()
228 {
229   MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
230 }
231
232 /*!
233     Set background of the viewport
234 */
235 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color)
236 {
237     if (myView)
238       myView->setPaletteBackgroundColor(color);
239 }
240
241 /*!
242     Returns background of the viewport
243 */
244 QColor SUPERVGraph_ViewFrame::backgroundColor() const
245 {
246   if (myView)
247     return myView->paletteBackgroundColor();
248   return QMainWindow::backgroundColor();
249 }
250
251
252 void SUPERVGraph_ViewFrame::SetSelectionMode( Selection_Mode mode )
253 {
254   MESSAGE ( "SUPERVGraph_ViewFrame::SetSelectionMode" )
255 }
256
257 void SUPERVGraph_ViewFrame::onAdjustTrihedron(  )
258 {
259   MESSAGE ( "SUPERVGraph_ViewFrame::onAdjustTrihedron" )  
260 }
261
262 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, 
263                                     QString newName )
264 {
265   MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
266 }
267
268 void SUPERVGraph_ViewFrame::unHighlightAll() 
269 {
270   MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
271 }
272
273 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, 
274                                        bool highlight, bool immediatly ) 
275 {
276   MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
277 }
278
279 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) 
280 {
281   MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
282   return false;
283 }
284
285 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) 
286 {
287   MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
288   return false;
289 }
290
291 void SUPERVGraph_ViewFrame::setPopupServer( QAD_Application* App )
292 {
293   myApp = App;
294   if (myView) {
295     myView->setPopupServer(myApp);
296   }
297 }
298
299 void SUPERVGraph_ViewFrame::undo(SALOMEDS::Study_var aStudy,
300                                  const char* StudyFrameEntry)
301 {
302   MESSAGE ( "SUPERVGraph_ViewFrame::undo" )
303 }
304
305 void SUPERVGraph_ViewFrame::redo(SALOMEDS::Study_var aStudy,
306                                  const char* StudyFrameEntry)
307 {
308   MESSAGE ( "SUPERVGraph_ViewFrame::redo" )
309 }
310