Salome HOME
Merge branch 'hydro/imps_2015' of https://git.salome-platform.org/gitpub/modules...
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewFrame.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "OCCViewer_ViewFrame.h"
24 #include "OCCViewer_ViewWindow.h"
25 #include "OCCViewer_ViewModel.h"
26
27 #include <SUIT_ViewManager.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_ResourceMgr.h>
30
31 #include <QtxResourceMgr.h>
32 #include <QtxWorkstackAction.h>
33
34 #include <QFrame>
35 #include <QLayout>
36 #include <QApplication>
37
38 OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel)
39   : OCCViewer_ViewWindow( theDesktop, theModel ), myPopupRequestedView(0), mySplitMode(-1)
40 {
41   QFrame* centralFrame = new QFrame( this );
42   setCentralWidget( centralFrame );
43
44   OCCViewer_ViewWindow* view0 = theModel->createSubWindow();
45   updateWindowTitle( view0 );
46   view0->setParent( centralFrame );
47   myViews.append( view0 ); // MAIN_VIEW
48
49   myLayout = new QGridLayout( centralFrame );
50   myLayout->setMargin( 0 );
51   myLayout->setSpacing( 1 );
52
53   myLayout->addWidget( view0, 0, 0 );
54   myMaximizedView = view0;
55   myActiveView = view0;
56   connectViewSignals(view0);
57 }
58
59 OCCViewer_ViewFrame::~OCCViewer_ViewFrame()
60 {
61 }
62
63 bool OCCViewer_ViewFrame::event( QEvent* e )
64 {
65   if ( e->type() == QEvent::WindowTitleChange ) {
66     updateWindowTitle( getView( MAIN_VIEW ) );
67     updateWindowTitle( getView( BOTTOM_LEFT ) );
68     updateWindowTitle( getView( TOP_LEFT ) );
69     updateWindowTitle( getView( TOP_RIGHT ) );
70   }
71   return OCCViewer_ViewWindow::event( e );
72 }
73
74 //**************************************************************************************
75 OCCViewer_ViewWindow* OCCViewer_ViewFrame::getView( const int i ) const
76 {
77   return ( i >= 0 && i < myViews.count() ) ? myViews.at( i ) : 0 ;
78 }
79
80 //**************************************************************************************
81 OCCViewer_ViewWindow* OCCViewer_ViewFrame::getActiveView( ) const
82 {
83   return myActiveView;
84 }
85
86 //**************************************************************************************
87 void OCCViewer_ViewFrame::setViewManager( SUIT_ViewManager* theMgr )
88 {
89   OCCViewer_ViewWindow::setViewManager(theMgr);
90   foreach (OCCViewer_ViewWindow* aView, myViews) {
91     aView->setViewManager(theMgr); 
92   }
93 }
94
95 //**************************************************************************************
96 void OCCViewer_ViewFrame::returnTo3dView()
97 {
98   OCCViewer_ViewWindow* view = 0;
99   for (int i = BOTTOM_RIGHT; i <= TOP_RIGHT; i++ ) {
100     view = myViews.at(i);
101     view->setVisible( view->get2dMode() == No2dMode );
102     view->setMaximized( true, false );
103     if (view->get2dMode() == No2dMode) {
104       myMaximizedView = view;
105       myActiveView = view;
106     }
107   }
108   myLayout->setColumnStretch(0, 0);
109   myLayout->setColumnStretch(1, 0);
110   myLayout->addWidget( myMaximizedView, 0, 0 );
111   mySplitMode = -1;
112   myViewsMode.clear();
113   myLayout->invalidate();
114 }
115
116 //**************************************************************************************
117 void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool isMaximized)
118 {
119   myMaximizedView = theView;
120   myActiveView = theView;
121   if (isMaximized) {
122     if (myViews.count() <= 1)
123       return;
124     myLayout->setColumnStretch(0, 0);
125     myLayout->setColumnStretch(1, 0);
126     myLayout->addWidget( theView, 0, 0 );
127     int i = 0;
128     OCCViewer_ViewWindow* view = 0;
129     for ( i = BOTTOM_RIGHT; i <= TOP_RIGHT; i++ ) {
130       view = myViews.at(i);
131       view->setVisible( view == theView );
132       view->setMaximized( view == theView, false );
133     }
134     mySplitMode = -1;
135     myViewsMode.clear();
136   }
137   else {
138     createSubViews();
139
140     QtxSplitDlg CreateSubViewsDlg( this, NULL, CreateSubViews );
141     if ( CreateSubViewsDlg.exec() ) {
142       mySplitMode = CreateSubViewsDlg.getSplitMode();
143       myViewsMode = CreateSubViewsDlg.getViewsMode();
144       splitSubViews();
145       myMaximizedView->setMaximized(false, false);
146     }
147   }
148   myLayout->invalidate();
149 }
150
151 //**************************************************************************************
152 void OCCViewer_ViewFrame::createSubViews()
153 {
154   OCCViewer_Viewer* aModel = dynamic_cast<OCCViewer_Viewer*>(myManager->getViewModel());
155   if (!aModel) return;
156   int i = 0;
157   if (myViews.count() == 1) {
158     //QColor aColor = myViews.at( MAIN_VIEW )->backgroundColor();
159     OCCViewer_ViewWindow* view = 0;
160     for ( i = BOTTOM_LEFT; i <= TOP_RIGHT; i++) {
161       view = aModel->createSubWindow();
162       view->set2dMode( (Mode2dType) i );
163       view->setParent( centralWidget() );
164       view->setViewManager(myManager);
165       updateWindowTitle( view );
166       myViews.append( view );
167       aModel->initView(view);
168       view->setMaximized(false, false);
169       view->setDropDownButtons( dropDownButtons() );
170       connectViewSignals(view);
171       view->setBackground(aModel->background(i));
172     }
173   }
174 }
175
176 void OCCViewer_ViewFrame::splitSubViews()
177 {
178         if( mySplitMode == -1 )
179                 return;
180
181   int aNbViews;
182   if ( mySplitMode >= 0 && mySplitMode < 2)
183     aNbViews = 2;
184   else if( mySplitMode >= 2 && mySplitMode < 8 )
185     aNbViews = 3;
186   else if( mySplitMode >=8 && mySplitMode < 29 )
187     aNbViews = 4;
188
189   if( aNbViews != myViewsMode.count() )
190         return;
191
192   int SubViews3Map[6][3][4] = {
193     { {0,0,1,1}, {0,1,1,1}, {0,2,1,1} },
194     { {0,0,1,1}, {1,0,1,1}, {2,0,1,1} },
195     { {0,0,1,1}, {1,0,1,1}, {0,1,2,1} },
196     { {0,0,2,1}, {0,1,1,1}, {1,1,1,1} },
197     { {0,0,1,2}, {1,0,1,1}, {1,1,1,1} },
198     { {0,0,1,1}, {0,1,1,1}, {1,0,1,2} }
199   };
200
201   int SubViews4Map[21][4][4] = {
202     { {0,0,1,1}, {0,1,1,1}, {0,2,1,1}, {0,3,1,1} },
203     { {0,0,1,1}, {1,0,1,1}, {2,0,1,1}, {3,0,1,1} },
204     { {0,0,1,1}, {0,1,1,1}, {1,0,1,1}, {1,1,1,1} },
205     { {0,0,1,1}, {1,0,1,1}, {0,1,2,1}, {0,2,2,1} },
206     { {0,0,2,1}, {0,1,1,1}, {1,1,1,1}, {0,2,2,1} },
207     { {0,0,2,1}, {0,1,2,1}, {0,2,1,1}, {1,2,1,1} },
208     { {0,0,1,1}, {0,1,1,1}, {1,0,1,2}, {2,0,1,2} },
209     { {0,0,1,2}, {1,0,1,1}, {1,1,1,1}, {2,0,1,2} },
210     { {0,0,1,2}, {1,0,1,2}, {2,0,1,1}, {2,1,1,1} },
211     { {0,0,1,1}, {1,0,1,1}, {0,1,2,1}, {2,0,1,2} },
212     { {0,0,2,1}, {0,1,1,1}, {1,1,1,1}, {2,0,1,2} },
213     { {0,0,1,2}, {1,0,1,1}, {2,0,1,1}, {1,1,2,1} },
214     { {0,0,1,2}, {1,0,2,1}, {1,1,1,1}, {2,1,1,1} },
215     { {0,0,2,1}, {0,1,1,1}, {0,2,1,1}, {1,1,1,2} },
216     { {0,0,2,1}, {0,1,1,2}, {1,1,1,1}, {1,2,1,1} },
217     { {0,0,1,1}, {0,1,1,1}, {1,0,1,2}, {0,2,2,1} },
218     { {0,0,1,2}, {1,0,1,1}, {1,1,1,1}, {0,2,2,1} },
219     { {0,0,1,3}, {1,0,1,1}, {1,1,1,1}, {1,2,1,1} },
220     { {0,0,1,1}, {0,1,1,1}, {0,2,1,1}, {1,0,1,3} },
221     { {0,0,1,1}, {1,0,1,1}, {2,0,1,1}, {0,1,3,1} },
222     { {0,0,3,1}, {0,1,1,1}, {1,1,1,1}, {2,1,1,1} },
223   };
224
225   if( aNbViews == 2 ) {
226     if( mySplitMode == 0 ) {
227       myLayout->addWidget( myViews.at(myViewsMode[0]), 0,0,2,1 );
228       myLayout->addWidget( myViews.at(myViewsMode[1]), 0,1,2,1 );
229     }
230     else if( mySplitMode == 1 ) {
231       myLayout->addWidget( myViews.at(myViewsMode[0]), 0,0,1,2 );
232       myLayout->addWidget( myViews.at(myViewsMode[1]), 1,0,1,2 );
233     }
234   }
235   else if( aNbViews == 3 ) {
236         int aSplitMode = mySplitMode - 2;
237     for( int i = 0; i < 3; i++ ) {
238     myLayout->addWidget( myViews.at(myViewsMode[i]),
239                          SubViews3Map[aSplitMode][i][0],
240                          SubViews3Map[aSplitMode][i][1],
241                          SubViews3Map[aSplitMode][i][2],
242                          SubViews3Map[aSplitMode][i][3]);
243     }
244   }
245   else if( aNbViews == 4 ) {
246         int aSplitMode = mySplitMode - 8;
247     for( int i = 0; i < 4; i++ ) {
248     myLayout->addWidget( myViews.at(myViewsMode[i]),
249                          SubViews4Map[aSplitMode][i][0],
250                          SubViews4Map[aSplitMode][i][1],
251                          SubViews4Map[aSplitMode][i][2],
252                          SubViews4Map[aSplitMode][i][3]);
253     }
254   }
255
256   OCCViewer_ViewWindow* view = 0;
257   bool isVisible3dView = false;
258   for ( int i = 0; i< myViews.count(); i++ ) {
259     view = myViews.at(i);
260     bool isShowed = false;
261     for( int j = 0; j < myViewsMode.count(); j++ ) {
262       OCCViewer_ViewWindow* view2 = 0;
263       view2 = myViews.at( myViewsMode[j] );
264       if( view == view2 )
265         isShowed = true;
266     }
267     if( isShowed ) {
268       view->show();
269       view->setMaximized( false, false );
270       if ( view->get2dMode() == No2dMode ) isVisible3dView = true;
271       ///////////////QApplication::processEvents(); // VSR: hangs up ?
272       if ( view != myMaximizedView )
273         view->onViewFitAll();
274     }
275     else
276       view->setVisible( false );
277   }
278   if ( !isVisible3dView ) {
279     for ( int i = 0; i< myViews.count(); i++ ){
280       view = myViews.at(i);
281       if( view->isVisible() )
282         view->setReturnedTo3dView( false );
283     }
284   }
285 }
286
287 //**************************************************************************************
288 OCCViewer_ViewPort3d* OCCViewer_ViewFrame::getViewPort(int theView) 
289
290   return getView(theView)? getView(theView)->getViewPort() : 0;
291 }
292   
293 //**************************************************************************************
294 void OCCViewer_ViewFrame::updateEnabledDrawMode() 
295
296   foreach (OCCViewer_ViewWindow* aView, myViews) {
297     aView->updateEnabledDrawMode(); 
298   }
299 }
300
301 //**************************************************************************************
302 void OCCViewer_ViewFrame::setCuttingPlane( bool on, const double x , const double y , const double z,
303                                            const double dx, const double dy, const double dz)  
304
305   foreach (OCCViewer_ViewWindow* aView, myViews) {
306     aView->setCuttingPlane(on, x, y, z, dx, dy, dz); 
307     aView->update();
308   }
309 }
310
311 //**************************************************************************************
312 void OCCViewer_ViewFrame::setCuttingPlane( bool on, const gp_Pln thePln ) 
313
314   foreach (OCCViewer_ViewWindow* aView, myViews) {
315     aView->setCuttingPlane(on, thePln); 
316     aView->update();
317   }
318 }
319   
320 //**************************************************************************************
321 void OCCViewer_ViewFrame::setInteractionStyle( const int i ) 
322
323   foreach (OCCViewer_ViewWindow* aView, myViews) {
324     aView->setInteractionStyle(i); 
325   }
326 }
327
328 //**************************************************************************************
329 int OCCViewer_ViewFrame::projectionType() const
330 {
331   return getView(MAIN_VIEW)->projectionType();
332 }
333
334 //**************************************************************************************
335 void OCCViewer_ViewFrame::setProjectionType( int t)
336 {
337   foreach (OCCViewer_ViewWindow* aView, myViews) {
338     aView->setProjectionType(t);
339   }
340 }
341
342 //**************************************************************************************
343 int OCCViewer_ViewFrame::stereoType() const
344 {
345   return getView(MAIN_VIEW)->stereoType();
346 }
347
348 //**************************************************************************************
349 void OCCViewer_ViewFrame::setStereoType( int t)
350 {
351   foreach (OCCViewer_ViewWindow* aView, myViews) {
352     aView->setStereoType(t);
353   }
354 }
355
356 //**************************************************************************************
357 int OCCViewer_ViewFrame::anaglyphFilter() const
358 {
359   return getView(MAIN_VIEW)->anaglyphFilter();
360 }
361
362 //**************************************************************************************
363 void OCCViewer_ViewFrame::setAnaglyphFilter( int t)
364 {
365   foreach (OCCViewer_ViewWindow* aView, myViews) {
366     aView->setAnaglyphFilter(t);
367   }
368 }
369
370 //**************************************************************************************
371 int OCCViewer_ViewFrame::stereographicFocusType() const
372 {
373   return getView(MAIN_VIEW)->stereographicFocusType();
374 }
375
376 //**************************************************************************************
377 double OCCViewer_ViewFrame::stereographicFocusValue() const
378 {
379   return getView(MAIN_VIEW)->stereographicFocusValue();
380 }
381
382 //**************************************************************************************
383 void OCCViewer_ViewFrame::setStereographicFocus( int t, double v)
384 {
385   foreach (OCCViewer_ViewWindow* aView, myViews) {
386     aView->setStereographicFocus(t, v);
387   }
388 }
389
390 //**************************************************************************************
391 int OCCViewer_ViewFrame::interocularDistanceType() const
392 {
393   return getView(MAIN_VIEW)->interocularDistanceType();
394 }
395
396 //**************************************************************************************
397 double OCCViewer_ViewFrame::interocularDistanceValue() const
398 {
399   return getView(MAIN_VIEW)->interocularDistanceValue();
400 }
401
402 //**************************************************************************************
403 void OCCViewer_ViewFrame::setInterocularDistance( int t, double v)
404 {
405   foreach (OCCViewer_ViewWindow* aView, myViews) {
406     aView->setInterocularDistance(t, v);
407   }
408 }
409
410 //**************************************************************************************
411 bool OCCViewer_ViewFrame::isReverseStereo() const
412 {
413   return getView(MAIN_VIEW)->isReverseStereo();
414 }
415
416 //**************************************************************************************
417 void OCCViewer_ViewFrame::setReverseStereo( bool t)
418 {
419   foreach (OCCViewer_ViewWindow* aView, myViews) {
420     aView->setReverseStereo(t);
421   }
422 }
423
424 //**************************************************************************************
425 bool OCCViewer_ViewFrame::isVSync() const
426 {
427   return getView(MAIN_VIEW)->isVSync();
428 }
429
430 //**************************************************************************************
431 void OCCViewer_ViewFrame::setVSync( bool t)
432 {
433   foreach (OCCViewer_ViewWindow* aView, myViews) {
434     aView->setVSync(t);
435   }
436 }
437
438 //**************************************************************************************
439 bool OCCViewer_ViewFrame::isQuadBufferSupport() const
440 {
441   return getView(MAIN_VIEW)->isQuadBufferSupport();
442 }
443
444 //**************************************************************************************
445 void OCCViewer_ViewFrame::setQuadBufferSupport( bool t)
446 {
447   foreach (OCCViewer_ViewWindow* aView, myViews) {
448     aView->setQuadBufferSupport(t);
449   }
450 }
451
452 //**************************************************************************************
453 void OCCViewer_ViewFrame::setZoomingStyle( const int i ) 
454
455   foreach (OCCViewer_ViewWindow* aView, myViews) {
456     aView->setZoomingStyle(i); 
457   }
458 }
459   
460 //**************************************************************************************
461 void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView)
462 {
463   connect( theView, SIGNAL( returnedTo3d( ) ), this, SLOT( returnTo3dView( ) ) );
464
465   connect( theView, SIGNAL( maximized( OCCViewer_ViewWindow*, bool ) ), 
466            this, SLOT( onMaximizedView( OCCViewer_ViewWindow*, bool ) ) );
467
468   connect( theView, SIGNAL( wheeling(SUIT_ViewWindow*, QWheelEvent*) ), 
469            this, SIGNAL( wheeling(SUIT_ViewWindow*, QWheelEvent*) ) );
470
471   connect( theView, SIGNAL( keyReleased(SUIT_ViewWindow*, QKeyEvent*) ), 
472            this, SIGNAL( keyReleased(SUIT_ViewWindow*, QKeyEvent*) ) );
473   connect( theView, SIGNAL( keyPressed(SUIT_ViewWindow*, QKeyEvent*) ), 
474            this, SIGNAL( keyPressed(SUIT_ViewWindow*, QKeyEvent*) ) );
475
476   connect( theView, SIGNAL( mouseDoubleClicked(SUIT_ViewWindow*, QMouseEvent*) ), 
477            this, SIGNAL( mouseDoubleClicked(SUIT_ViewWindow*, QMouseEvent*) ) );
478   connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ), 
479            this, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ) );
480   // The signal is used to mouse pressed for choose the current window
481   connect( theView, SIGNAL( mousePressed(SUIT_ViewWindow*, QMouseEvent*) ),
482            this, SLOT( onMousePressed(SUIT_ViewWindow*, QMouseEvent*) ) );
483   connect( theView, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ), 
484            this, SIGNAL( mouseReleased(SUIT_ViewWindow*, QMouseEvent*) ) );
485   connect( theView, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ), 
486            this, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ) );
487
488   // The signal is used to process get/set background color from popup
489   connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), 
490            this, SLOT( onContextMenuRequested(QContextMenuEvent*) ) );
491
492   connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), 
493            this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) );
494
495   connect( theView, SIGNAL( viewCloned( SUIT_ViewWindow* ) ),
496            this,    SIGNAL( viewCloned( SUIT_ViewWindow* ) ) );
497 }
498
499 // obsolete
500 void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor )
501 {
502   if (myPopupRequestedView)
503     myPopupRequestedView->setBackgroundColor(theColor); 
504   else {
505     foreach (OCCViewer_ViewWindow* aView, myViews) {
506       if (aView->isVisible())
507         aView->setBackgroundColor(theColor); 
508     }
509   }
510 }
511 void OCCViewer_ViewFrame::setBackground( const Qtx::BackgroundData& theBackground )
512 {
513   if (myPopupRequestedView)
514     myPopupRequestedView->setBackground(theBackground); 
515   else {
516     foreach (OCCViewer_ViewWindow* aView, myViews) {
517       if (aView->isVisible())
518         aView->setBackground(theBackground); 
519     }
520   }
521 }
522
523 void OCCViewer_ViewFrame::onViewFitAll()
524 {
525   foreach (OCCViewer_ViewWindow* aView, myViews) {
526     aView->onViewFitAll(); 
527   }
528 }
529
530 void OCCViewer_ViewFrame::onFitAll()
531 {
532   foreach (OCCViewer_ViewWindow* aView, myViews) {
533     aView->onFitAll(); 
534   }
535 }
536
537 // obsolete  
538 QColor OCCViewer_ViewFrame::backgroundColor() const 
539
540   if (myPopupRequestedView)
541     return myPopupRequestedView->backgroundColor(); 
542
543   foreach (OCCViewer_ViewWindow* aView, myViews) {
544     if (aView->isVisible())
545       return aView->backgroundColor(); 
546   }
547   return getView(MAIN_VIEW)->backgroundColor(); 
548 }
549
550 Qtx::BackgroundData OCCViewer_ViewFrame::background() const 
551
552   if (myPopupRequestedView)
553     return myPopupRequestedView->background(); 
554
555   foreach (OCCViewer_ViewWindow* aView, myViews) {
556     if (aView->isVisible())
557       return aView->background(); 
558   }
559   return getView(MAIN_VIEW)->background(); 
560 }
561
562 void OCCViewer_ViewFrame::showStaticTrihedron( bool on )
563 {
564   if ( myPopupRequestedView )
565     myPopupRequestedView->showStaticTrihedron( on ); 
566   else {
567     foreach ( OCCViewer_ViewWindow* aView, myViews ) {
568       aView->showStaticTrihedron( on ); 
569     }
570   }
571 }
572
573 QImage OCCViewer_ViewFrame::dumpView()
574 {
575   foreach (OCCViewer_ViewWindow* aView, myViews) {
576     if (aView->isVisible())
577       return aView->dumpView();
578   }
579   return QImage();
580 }
581
582 bool OCCViewer_ViewFrame::dumpViewToFormat( const QImage& image, const QString& fileName, const QString& format )
583 {
584   foreach (OCCViewer_ViewWindow* aView, myViews) {
585     if (aView->isVisible())
586       return aView->dumpViewToFormat( image, fileName, format );
587   }
588   return false;
589 }
590
591 void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*)
592 {
593   myPopupRequestedView = dynamic_cast<OCCViewer_ViewWindow*>(sender());
594 }
595
596 void OCCViewer_ViewFrame::onMousePressed(SUIT_ViewWindow* view, QMouseEvent*)
597 {
598   myActiveView = dynamic_cast<OCCViewer_ViewWindow*>(view);
599 }
600
601 void OCCViewer_ViewFrame::onDumpView()
602 {
603   if (myPopupRequestedView) {
604     myPopupRequestedView->onDumpView(); 
605   }
606   else {
607     getView(MAIN_VIEW)->onDumpView(); 
608   }
609 }
610
611 void OCCViewer_ViewFrame::setDropDownButtons( bool on )
612 {
613   foreach( OCCViewer_ViewWindow* aView, myViews ) {
614     aView->setDropDownButtons( on );
615   }
616   OCCViewer_ViewWindow::setDropDownButtons( on );
617 }
618
619 QString OCCViewer_ViewFrame::getVisualParameters()
620 {
621   QStringList params;
622   QStringList splitParams;
623   if( mySplitMode != -1 && myViewsMode.count() != 0 ) {
624     splitParams << QString::number( mySplitMode );
625     foreach ( int aViewMode, myViewsMode )
626       splitParams << QString::number( aViewMode );
627     params.append( splitParams.join("*") );
628   }
629   else
630     params.append( QString::number( mySplitMode ) );
631   int maximizedView = 999;
632   for ( int i = BOTTOM_RIGHT; i <= TOP_RIGHT && i < myViews.count(); i++) {
633     if ( getView(i)->isVisible() )
634       maximizedView = ( maximizedView != -1 ) ? ( maximizedView == 999 ? i : -1 ) : ( maximizedView );
635     params << getView(i)->getVisualParameters();
636   }
637   params.prepend( QString::number( maximizedView ) );
638   return params.join( "|" );
639 }
640
641 void OCCViewer_ViewFrame::setVisualParameters( const QString& parameters ) 
642 {
643   QStringList params = parameters.split( "|" );
644   if ( params.count() > 1 ) {
645     int maximizedView = params[0].toInt();
646     if ( myViews.count() < params.count()-2 )
647       createSubViews(); // secondary views are not created yet, but should be
648
649     for ( int i = 2; i < params.count(); i++ ) {
650       int idx = i-2;
651       getView( idx )->setVisualParameters( params[i] );
652     }
653
654     QStringList aSplitParams = params[1].split("*");
655     if( aSplitParams.count() > 1 ) {
656       mySplitMode = aSplitParams[0].toInt();
657       for( int i = 1; i < aSplitParams.count(); i++ )
658         myViewsMode << aSplitParams[i].toInt();
659     }
660     if( mySplitMode != -1 )
661       splitSubViews();
662     else
663       onMaximizedView( getView( maximizedView ), true ); // set proper sub-window maximized
664   }
665   else {
666     // handle obsolete versions - no parameters for xy, yz, xz views
667     getView(MAIN_VIEW)->setVisualParameters( parameters );
668   }
669 }
670
671 SUIT_CameraProperties OCCViewer_ViewFrame::cameraProperties()
672 {
673   // view frame does not have camera properties
674   return SUIT_CameraProperties();
675 }
676
677 void OCCViewer_ViewFrame::updateWindowTitle(OCCViewer_ViewWindow* theView)
678 {
679   if ( !theView )
680     return;
681   QString title;
682   switch ( theView->get2dMode() ) {
683   case No2dMode:
684     title = "3D"; break;
685   case XYPlane:
686     title = "YX"; break;
687   case XZPlane:
688     title = "XZ"; break;
689   case YZPlane:
690     title = "YZ"; break;
691   default:
692     break;
693   }
694   if ( !title.isEmpty() )
695     theView->setWindowTitle( windowTitle() + " - " + title );
696 }
697
698 void OCCViewer_ViewFrame::enableSelection( bool isEnabled )
699 {
700   foreach (OCCViewer_ViewWindow* aView, myViews) {
701     aView->enableSelection(isEnabled); 
702   }
703 }
704
705 void OCCViewer_ViewFrame::enablePreselection( bool isEnabled )
706 {
707   foreach (OCCViewer_ViewWindow* aView, myViews) {
708     aView->enablePreselection(isEnabled); 
709   }
710 }
711
712 bool OCCViewer_ViewFrame::enableDrawMode( bool on )
713 {
714   bool prev = false;
715   foreach (OCCViewer_ViewWindow* aView, myViews) {
716     prev = prev || aView->enableDrawMode( on ); 
717   }
718   return prev;
719 }