]> SALOME platform Git repositories - modules/gui.git/blob - src/Plot2d/Plot2d_ViewWindow.cxx
Salome HOME
6fcdd26427612c1fb6fae3e3dce38fa7536eba1e
[modules/gui.git] / src / Plot2d / Plot2d_ViewWindow.cxx
1 //  Copyright (C) 2007-2008  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.
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 // File   : Plot2d_ViewWindow.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 //
25 #include "Plot2d_ViewWindow.h"
26 #include "Plot2d_ViewFrame.h"
27
28 #include <SUIT_ViewManager.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
31 #include <SUIT_Desktop.h>
32
33 #include <QtxAction.h>
34 #include <QtxMultiAction.h>
35 #include <QtxActionToolMgr.h>
36
37 #include <QStatusBar>
38 #include <QLayout>
39 #include <QApplication>
40 #include <QMenu>
41 #include <QImage>
42 #include <QToolBar>
43 #include <QPaintEvent>
44 #include <QActionGroup>
45
46 /*!
47   \class Plot2d_ViewWindow
48   \brief Plot2d view window.
49 */
50
51 /*!
52   \brief Constructor.
53   \param theDesktop parent desktop window
54   \param theModel plt2d view model
55 */
56 Plot2d_ViewWindow::Plot2d_ViewWindow( SUIT_Desktop* theDesktop, Plot2d_Viewer* theModel )
57 : SUIT_ViewWindow( theDesktop )
58 {
59   myModel = theModel;
60   myDumpImage = QImage();
61
62   myViewFrame = new Plot2d_ViewFrame( this, "plotView" );
63   setCentralWidget( myViewFrame );
64
65   createActions();
66   createToolBar();
67
68   connect( myViewFrame, SIGNAL( vpModeHorChanged() ), this, SLOT( onChangeHorMode() ) );
69   connect( myViewFrame, SIGNAL( vpModeVerChanged() ), this, SLOT( onChangeVerMode() ) );
70   connect( myViewFrame, SIGNAL( vpCurveChanged() ),   this, SLOT( onChangeCurveMode() ) );
71   connect( myViewFrame, SIGNAL( contextMenuRequested( QContextMenuEvent* ) ),
72            this,        SIGNAL( contextMenuRequested( QContextMenuEvent* ) ) );
73
74   myViewFrame->installEventFilter( this );
75 }
76
77 /*!
78   \brief Destructor.
79 */
80 Plot2d_ViewWindow::~Plot2d_ViewWindow()
81 {
82 }
83
84 /*!
85   \brief Get view model.
86   \return Plot2d view model
87 */
88 Plot2d_Viewer* Plot2d_ViewWindow::getModel()
89 {
90   return myModel;
91 }
92
93 /*!
94   \brief Put message to the status bar.
95   \param theMsg message text
96 */
97 void Plot2d_ViewWindow::putInfo( const QString& theMsg )
98 {
99   QStatusBar* aStatusBar = myDesktop->statusBar();
100   aStatusBar->showMessage( theMsg/*, 3000*/ );
101 }
102
103 /*!
104   \brief Get view frame window.
105   \return view frame window
106 */
107 Plot2d_ViewFrame* Plot2d_ViewWindow::getViewFrame()
108
109   return myViewFrame;
110 }
111
112 /*!
113   \brief Get view window's toolbar.
114   \return toolbar
115 */
116 QToolBar* Plot2d_ViewWindow::getToolBar()
117 {
118   return toolMgr()->toolBar( myToolBar );
119 }
120
121 /*!
122   \brief Fill popup menu with the actions,
123   \param thePopup popup menu
124 */
125 void Plot2d_ViewWindow::contextMenuPopup( QMenu* thePopup )
126 {
127   QtxActionToolMgr* mgr = toolMgr();
128   // scaling
129   QMenu* scalingPopup = thePopup->addMenu( tr( "SCALING_POPUP" ) );
130   scalingPopup->addAction( mgr->action( PModeXLinearId ) );
131   scalingPopup->addAction( mgr->action( PModeXLogarithmicId ) );
132   scalingPopup->addSeparator();
133   scalingPopup->addAction( mgr->action( PModeYLinearId ) );
134   scalingPopup->addAction( mgr->action( PModeYLogarithmicId ) );
135
136   // fit data
137   thePopup->addAction( tr( "TOT_PLOT2D_FITDATA" ), myViewFrame, SLOT( onFitData() ) );
138
139   // curve type
140   QMenu* curTypePopup = thePopup->addMenu( tr( "CURVE_TYPE_POPUP" ) );
141   curTypePopup->addAction( mgr->action( CurvPointsId ) );
142   curTypePopup->addAction( mgr->action( CurvLinesId ) );
143   curTypePopup->addAction( mgr->action( CurvSplinesId ) );
144
145   // legend
146   thePopup->addAction( mgr->action( LegendId ) );
147
148   // settings
149   thePopup->addAction( mgr->action( CurvSettingsId ) );
150 }
151
152 /*!
153   \brief Custom event filter.
154   \param watched event receiver object
155   \param e event
156   \return \c true if further event processing should be stopped
157 */
158 bool Plot2d_ViewWindow::eventFilter( QObject* watched, QEvent* e )
159 {
160   if ( watched == myViewFrame ) {
161     switch( e->type() ) {
162     case QEvent::MouseButtonPress:
163       emit mousePressed( this, (QMouseEvent*)e );
164       return true;
165     case QEvent::MouseButtonRelease:
166       emit mouseReleased( this, (QMouseEvent*)e );
167       return true;
168     case QEvent::MouseMove:
169       emit mouseMoving( this, (QMouseEvent*)e );
170       return true;
171     default:
172       break;
173     }
174   }
175   return SUIT_ViewWindow::eventFilter( watched, e );
176 }
177
178 /*!
179   \brief Create actions for the view window.
180 */
181 void Plot2d_ViewWindow::createActions()
182 {
183   QtxActionToolMgr* mgr = toolMgr();
184   QtxAction* aAction;
185   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
186
187   // 1. Dump View
188   aAction = new QtxAction( tr( "MNU_DUMP_VIEW" ),
189                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_DUMP" ) ),
190                            tr( "MNU_DUMP_VIEW" ),
191                            0, this);
192   aAction->setStatusTip( tr( "DSC_DUMP_VIEW" ) );
193   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onDumpView() ) );
194   mgr->registerAction( aAction, DumpId );
195
196   // 2. Scaling operations
197
198   // 2.1. Fit All
199   aAction = new QtxAction( tr( "MNU_FITALL" ),
200                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_FIT_ALL" ) ),
201                            tr( "MNU_FITALL" ),
202                            0, this);
203   aAction->setStatusTip( tr( "DSC_FITALL" ) );
204   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onFitAll() ) );
205   mgr->registerAction( aAction, FitAllId );
206
207   // 2.2. Fit Rect
208   aAction = new QtxAction( tr( "MNU_FITRECT" ),
209                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_FIT_AREA" ) ),
210                            tr( "MNU_FITRECT" ),
211                            0, this);
212   aAction->setStatusTip( tr( "DSC_FITRECT" ) );
213   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onFitRect() ) );
214   mgr->registerAction( aAction, FitRectId );
215
216   // 2.3. Zoom
217   aAction = new QtxAction( tr( "MNU_ZOOM_VIEW" ),
218                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_ZOOM" ) ),
219                            tr( "MNU_ZOOM_VIEW" ),
220                            0, this);
221   aAction->setStatusTip( tr( "DSC_ZOOM_VIEW" ) );
222   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onZoom() ) );
223   mgr->registerAction( aAction, ZoomId );
224
225   // 2.4. Create multi-action for scaling operations
226   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
227   aScaleAction->insertAction( mgr->action( FitAllId  ) );
228   aScaleAction->insertAction( mgr->action( FitRectId ) );
229   aScaleAction->insertAction( mgr->action( ZoomId    ) );
230   mgr->registerAction( aScaleAction, ScaleOpId );
231
232   // 3. Moving operations
233
234   // 3.1. Panning
235   aAction = new QtxAction( tr( "MNU_PAN_VIEW" ),
236                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_PAN" ) ),
237                            tr( "MNU_PAN_VIEW" ), 
238                            0, this);
239   aAction->setStatusTip( tr( "DSC_PAN_VIEW" ) );
240   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onPanning() ) );
241   mgr->registerAction( aAction, PanId );
242
243   // 3.2. Global Panning
244   aAction = new QtxAction( tr( "MNU_GLOBALPAN_VIEW" ),
245                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_GLOBALPAN" ) ),
246                            tr( "MNU_GLOBALPAN_VIEW" ),
247                            0, this);
248   aAction->setStatusTip( tr( "DSC_GLOBALPAN_VIEW" ) );
249   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onGlobalPanning() ) );
250   mgr->registerAction( aAction, GlobalPanId );
251
252   // 3.3. Create multi-action for moving operations
253   QtxMultiAction* aPanAction = new QtxMultiAction( this );
254   aPanAction->insertAction( mgr->action( PanId ) );
255   aPanAction->insertAction( mgr->action( GlobalPanId ) );
256   mgr->registerAction( aPanAction, MoveOpId );
257
258   // 4. Curve type operations
259   
260   // 4.1. Points
261   aAction = new QtxAction( tr( "TOT_PLOT2D_CURVES_POINTS" ),
262                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_CURVES_POINTS" ) ),
263                            tr( "MEN_PLOT2D_CURVES_POINTS" ),
264                            0, this );
265   aAction->setStatusTip( tr( "PRP_PLOT2D_CURVES_POINTS" ) );
266   aAction->setCheckable( true );
267   mgr->registerAction( aAction, CurvPointsId );
268
269   // 4.2. Lines
270   aAction = new QtxAction( tr( "TOT_PLOT2D_CURVES_LINES" ),
271                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_CURVES_LINES" ) ),
272                            tr( "MEN_PLOT2D_CURVES_LINES" ),
273                            0, this );
274   aAction->setStatusTip( tr( "PRP_PLOT2D_CURVES_LINES" ) );
275   aAction->setCheckable( true );
276   mgr->registerAction( aAction, CurvLinesId );
277
278   // 4.3. Splines
279   aAction = new QtxAction( tr( "TOT_PLOT2D_CURVES_SPLINES" ),
280                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_CURVES_SPLINES" ) ),
281                            tr( "MEN_PLOT2D_CURVES_SPLINES" ),
282                            0, this );
283   aAction->setStatusTip( tr( "PRP_PLOT2D_CURVES_SPLINES" ) );
284   aAction->setCheckable( true );
285   mgr->registerAction( aAction, CurvSplinesId );
286
287   // 4.4. Create action group for curve type operations
288   QActionGroup* aCurveGroup = new QActionGroup( this );
289   aCurveGroup->addAction( mgr->action( CurvPointsId ) );
290   aCurveGroup->addAction( mgr->action( CurvLinesId ) );
291   aCurveGroup->addAction( mgr->action( CurvSplinesId ) );
292   connect( aCurveGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( onCurves() ) );
293
294   // 5. Horizontal scaling mode operations
295
296   // 5.1. Linear
297   aAction = new QtxAction( tr( "TOT_PLOT2D_MODE_LINEAR_HOR" ),
298                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_MODE_LINEAR_HOR" ) ),
299                            tr( "MEN_PLOT2D_MODE_LINEAR_HOR" ),
300                            0, this );
301   aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LINEAR_HOR" ) );
302   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewHorMode() ) );
303   aAction->setCheckable( true );
304   mgr->registerAction( aAction, PModeXLinearId );
305   
306   // 5.2. Logarithmic
307   aAction = new QtxAction( tr( "TOT_PLOT2D_MODE_LOGARITHMIC_HOR" ),
308                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_MODE_LOGARITHMIC_HOR" ) ),
309                            tr( "MEN_PLOT2D_MODE_LOGARITHMIC_HOR" ),
310                            0, this );
311   aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LOGARITHMIC_HOR" ) );
312   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewHorMode() ) );
313   aAction->setCheckable( true );
314   mgr->registerAction( aAction, PModeXLogarithmicId );
315
316   // 5.3. Create action group for horizontal scaling mode operations
317   QActionGroup* aHorGroup = new QActionGroup( this );
318   aHorGroup->addAction( mgr->action( PModeXLinearId ) );
319   aHorGroup->addAction( mgr->action( PModeXLogarithmicId ) );
320
321   // 6. Vertical scaling mode operations
322
323   // 6.1. Linear
324   aAction = new QtxAction( tr( "TOT_PLOT2D_MODE_LINEAR_VER" ),
325                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_MODE_LINEAR_VER" ) ),
326                            tr( "MEN_PLOT2D_MODE_LINEAR_VER" ),
327                            0, this );
328   aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LINEAR_VER" ) );
329   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewVerMode() ) );
330   aAction->setCheckable( true );
331   mgr->registerAction( aAction, PModeYLinearId );
332
333   // 6.2. Logarithmic
334   aAction = new QtxAction( tr( "TOT_PLOT2D_MODE_LOGARITHMIC_VER" ),
335                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_MODE_LOGARITHMIC_VER" ) ),
336                            tr( "MEN_PLOT2D_MODE_LOGARITHMIC_VER" ),
337                            0, this );
338   aAction->setStatusTip( tr( "PRP_PLOT2D_MODE_LOGARITHMIC_VER" ) );
339   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onViewVerMode() ) );
340   aAction->setCheckable( true );
341   mgr->registerAction( aAction, PModeYLogarithmicId );
342
343   // 6.3. Create action group for vertical scaling mode operations
344   QActionGroup* aVerGroup = new QActionGroup( this );
345   aVerGroup->addAction( mgr->action( PModeYLinearId ) );
346   aVerGroup->addAction( mgr->action( PModeYLogarithmicId ) );
347
348   // 7. Legend
349   aAction = new QtxAction( tr( "TOT_PLOT2D_SHOW_LEGEND" ),
350                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_SHOW_LEGEND" ) ),
351                            tr( "MEN_PLOT2D_SHOW_LEGEND" ),
352                            0, this );
353   aAction->setStatusTip( tr( "PRP_PLOT2D_SHOW_LEGEND" ) );
354   connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onLegend() ) );
355   aAction->setCheckable( true );
356   mgr->registerAction( aAction, LegendId );
357
358   // 8. Settings
359   aAction = new QtxAction( tr( "TOT_PLOT2D_SETTINGS" ),
360                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_SETTINGS" ) ),
361                            tr( "MEN_PLOT2D_SETTINGS" ),
362                            0, this );
363   aAction->setStatusTip( tr( "PRP_PLOT2D_SETTINGS" ) );
364   connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onSettings() ) );
365   mgr->registerAction( aAction, CurvSettingsId );
366
367   // 9. Clone
368   aAction = new QtxAction( tr( "MNU_CLONE_VIEW" ),
369                            aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_CLONE_VIEW" ) ),
370                            tr( "MNU_CLONE_VIEW" ),
371                            0, this);
372   aAction->setStatusTip( tr( "DSC_CLONE_VIEW" ) );
373   connect( aAction, SIGNAL( triggered( bool ) ), this, SIGNAL( cloneView() ) );
374   mgr->registerAction( aAction, CloneId );
375
376   // Set initial values
377   onChangeCurveMode();
378   onChangeHorMode();
379   onChangeVerMode();
380   onChangeLegendMode();
381 }
382
383 /*!
384   \brief Create toolbar for the view window.
385 */
386 void Plot2d_ViewWindow::createToolBar()
387 {
388   QtxActionToolMgr* mgr = toolMgr();
389   myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) );
390   mgr->append( DumpId, myToolBar );
391   mgr->append( ScaleOpId, myToolBar );
392   mgr->append( MoveOpId, myToolBar );
393   mgr->append( toolMgr()->separator(), myToolBar );
394   mgr->append( CurvPointsId, myToolBar );
395   mgr->append( CurvLinesId, myToolBar );
396   mgr->append( CurvSplinesId, myToolBar );
397   mgr->append( toolMgr()->separator(), myToolBar );
398   mgr->append( PModeXLinearId, myToolBar );
399   mgr->append( PModeXLogarithmicId, myToolBar );
400   mgr->append( toolMgr()->separator(), myToolBar );
401   mgr->append( PModeYLinearId, myToolBar );
402   mgr->append( PModeYLogarithmicId, myToolBar );
403   mgr->append( toolMgr()->separator(), myToolBar );
404   mgr->append( LegendId, myToolBar );
405   mgr->append( CurvSettingsId, myToolBar );
406   mgr->append( CloneId, myToolBar );
407 }
408
409 /*!
410   \brief Get the visual parameters of the view window.
411   \return visual parameters of this view window formatted to the string
412 */
413 QString Plot2d_ViewWindow::getVisualParameters()
414 {
415   return myViewFrame->getVisualParameters();
416 }
417
418 /*!
419   \brief Restore visual parameters of the view window from the formated string
420   \param parameters view window visual parameters
421 */
422 void Plot2d_ViewWindow::setVisualParameters( const QString& parameters )
423 {
424   myViewFrame->setVisualParameters( parameters );
425 }
426
427 /*!
428   \brief Grab the view window to the internal image.
429 */
430 void Plot2d_ViewWindow::RefreshDumpImage()
431 {
432   QPixmap px = QPixmap::grabWindow( myViewFrame->winId() );
433   myDumpImage = px.toImage();
434 }
435
436 /*!
437   \brief Called when the scale mode for the horizontal axis is changed.
438 */
439 void Plot2d_ViewWindow::onChangeHorMode()
440 {
441   bool aHorLinear = myViewFrame->isModeHorLinear();
442   bool aVerLinear = myViewFrame->isModeVerLinear();
443
444   if ( aHorLinear )
445     toolMgr()->action( PModeXLinearId )->setChecked( true );
446   else
447     toolMgr()->action( PModeXLogarithmicId )->setChecked( true );
448
449   toolMgr()->action( GlobalPanId )->setEnabled( aHorLinear && aVerLinear );
450 }
451
452 /*!
453   \brief Called when the scale mode for the vertical axis is changed.
454 */
455 void Plot2d_ViewWindow::onChangeVerMode()
456 {
457   bool aHorLinear = myViewFrame->isModeHorLinear();
458   bool aVerLinear = myViewFrame->isModeVerLinear();
459
460   if ( aVerLinear )
461     toolMgr()->action( PModeYLinearId )->setChecked( true );
462   else
463     toolMgr()->action( PModeYLogarithmicId )->setChecked( true );
464
465   toolMgr()->action( GlobalPanId )->setEnabled( aHorLinear && aVerLinear );
466 }
467
468 /*!
469   \brief Called when the curve type is changed.
470 */
471 void Plot2d_ViewWindow::onChangeCurveMode()
472 {
473   switch ( myViewFrame->getCurveType() ) {
474   case 0:
475     toolMgr()->action( CurvPointsId )->setChecked( true );
476     break;
477   case 1:
478     toolMgr()->action( CurvLinesId )->setChecked( true );
479     break;
480   case 2:
481     toolMgr()->action( CurvSplinesId )->setChecked( true );
482     break;
483   default:
484     break;
485   }
486 }
487
488 /*!
489   \brief Called when the legend mode is changed.
490 */
491 void Plot2d_ViewWindow::onChangeLegendMode()
492 {
493   toolMgr()->action( LegendId )->setChecked( myViewFrame->isLegendShow() );
494 }
495
496 /*!
497   \brief Called when the "Fit all" action is activated.
498 */
499 void Plot2d_ViewWindow::onFitAll()
500 {
501   myViewFrame->onViewFitAll();
502 }
503
504 /*!
505   \brief Called when the "Fit rect" action is activated.
506 */
507 void Plot2d_ViewWindow::onFitRect()
508 {
509   myViewFrame->onViewFitArea();
510 }
511
512 /*!
513   \brief Called when the "Zoom" action is activated.
514 */
515 void Plot2d_ViewWindow::onZoom()
516 {
517   myViewFrame->onViewZoom();
518 }
519
520 /*!
521   \brief Called when the "Panning" action is activated.
522 */
523 void Plot2d_ViewWindow::onPanning()
524 {
525   myViewFrame->onViewPan();
526 }
527
528 /*!
529   \brief Called when the "Global panning" action is activated.
530 */
531 void Plot2d_ViewWindow::onGlobalPanning()
532 {
533   myViewFrame->onViewGlobalPan();
534 }
535
536 /*!
537   \brief Called when horizontal axis scale mode action is activated.
538 */
539 void Plot2d_ViewWindow::onViewHorMode()
540 {
541   myViewFrame->setHorScaleMode( toolMgr()->action( PModeXLinearId )->isChecked() ? 0 : 1 );
542 }
543
544 /*!
545   \brief Called when vertical axis scale mode action is activated.
546 */
547 void Plot2d_ViewWindow::onViewVerMode()
548 {
549   myViewFrame->setVerScaleMode( toolMgr()->action( PModeYLinearId )->isChecked() ? 0 : 1 );
550 }
551
552 /*!
553   \brief Called when the "Show legend" action is activated.
554 */
555 void Plot2d_ViewWindow::onLegend()
556 {
557   myViewFrame->showLegend( !myViewFrame->isLegendShow() );
558   onChangeLegendMode();
559 }
560
561 /*!
562   \brief Called when the "Change curve type" action is activated.
563 */
564 void Plot2d_ViewWindow::onCurves()
565 {
566   if( toolMgr()->action( CurvPointsId )->isChecked() )
567     myViewFrame->setCurveType( 0 );
568   else if ( toolMgr()->action( CurvLinesId )->isChecked() )
569     myViewFrame->setCurveType( 1 );
570   else if ( toolMgr()->action( CurvSplinesId )->isChecked() )
571     myViewFrame->setCurveType( 2 );
572 }
573  
574 /*!
575   \brief Called when the "Dump view" action is activated.
576 */
577 void Plot2d_ViewWindow::onDumpView()
578 {
579   qApp->postEvent( myViewFrame, new QPaintEvent( QRect( 0, 0, myViewFrame->width(), myViewFrame->height() ) ) );
580   SUIT_ViewWindow::onDumpView();
581 }
582
583 /*!
584   \brief Dump the contents of the view window to the image.
585   \return image, containing all scene rendered in the window
586 */
587 QImage Plot2d_ViewWindow::dumpView()
588 {
589   if ( getToolBar()->underMouse() || myDumpImage.isNull() ) {
590     QPixmap px = QPixmap::grabWindow( myViewFrame->winId() );
591     return px.toImage();
592   }
593   
594   return myDumpImage;
595 }
596
597 /*!
598   \brief Dump scene rendered in the view window to the file.
599   \param img image
600   \param fileName name of file
601   \param format image format ("BMP" [default], "JPEG", "JPG", "PNG")
602 */
603 bool Plot2d_ViewWindow::dumpViewToFormat( const QImage&  img,
604                                           const QString& fileName, 
605                                           const QString& format )
606 {
607   bool res = myViewFrame ? myViewFrame->print( fileName, format ) : false;
608   if( !res )
609     res = SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
610
611   return res;
612 }
613
614 /*!
615   \brief Get supported image files wildcards.
616   \return image files wildcards (list of wildcards, separated by ";;")
617 */
618 QString Plot2d_ViewWindow::filter() const
619 {
620   QStringList filters = SUIT_ViewWindow::filter().split( ";;", QString::SkipEmptyParts );
621   filters << tr( "POSTSCRIPT_FILES" );
622   filters << tr( "ENCAPSULATED_POSTSCRIPT_FILES" );
623   return filters.join( ";;" );
624 }
625
626 /*!
627   \fn void Plot2d_ViewWindow::cloneView();
628   \brief Emitted when the "Clone View" action is activated.
629 */