1 // Plot2d_ViewModel.cxx: implementation of the Plot2d_ViewModel class.
3 //////////////////////////////////////////////////////////////////////
5 #include "Plot2d_ViewModel.h"
6 #include "Plot2d_ViewWindow.h"
7 #include "Plot2d_ViewManager.h"
8 #include "Plot2d_ViewFrame.h"
9 #include "Plot2d_Prs.h"
11 #include <qpopupmenu.h>
13 Plot2d_Viewer::Plot2d_Viewer(bool theAutoDel)
17 myAutoDel = theAutoDel;
20 Plot2d_Viewer::~Plot2d_Viewer()
26 //*********************************************************************
27 SUIT_ViewWindow* Plot2d_Viewer::createView(SUIT_Desktop* theDesktop)
29 Plot2d_ViewWindow* aPlot2dView = new Plot2d_ViewWindow(theDesktop, this);
31 aPlot2dView->getViewFrame()->Display(myPrs);
35 //*********************************************************************
36 void Plot2d_Viewer::contextMenuPopup(QPopupMenu* thePopup)
38 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
40 aView->contextMenuPopup(thePopup);
42 if (thePopup->count() > 0) thePopup->insertSeparator();
43 thePopup->insertItem( tr( "MNU_DUMP_VIEW" ), this, SLOT(onDumpView()));
44 thePopup->insertItem( tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), this, SLOT(onChangeBgColor()));
47 if ( !aView->getToolBar()->isVisible() ) {
48 if (thePopup->count() > 0) thePopup->insertSeparator();
49 thePopup->insertItem("Show toolbar", this, SLOT(onShowToolbar()));
55 //*********************************************************************
56 void Plot2d_Viewer::setPrs(Plot2d_Prs* thePrs)
61 myPrs->setAutoDel(myAutoDel);
64 //*********************************************************************
65 void Plot2d_Viewer::update()
67 SUIT_ViewManager* aMgr = getViewManager();
68 QPtrVector<SUIT_ViewWindow> aViews = aMgr->getViews();
69 unsigned int aSize = aViews.size();
70 for (uint i = 0; i < aSize; i++) {
71 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)aViews[i];
73 aView->getViewFrame()->Display(myPrs);
77 //*********************************************************************
78 void Plot2d_Viewer::clearPrs()
80 SUIT_ViewManager* aMgr = getViewManager();
81 QPtrVector<SUIT_ViewWindow> aViews = aMgr->getViews();
82 unsigned int aSize = aViews.size();
83 for (uint i = 0; i < aSize; i++) {
84 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)aViews[i];
86 aView->getViewFrame()->Erase(myPrs);
88 if (myAutoDel && myPrs) {
94 //*********************************************************************
95 void Plot2d_Viewer::setAutoDel(bool theDel)
99 myPrs->setAutoDel(theDel);
102 //*********************************************************************
103 void Plot2d_Viewer::onChangeBgColor()
105 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
108 Plot2d_ViewFrame* aViewFrame = aView->getViewFrame();
109 aViewFrame->onChangeBackground();
112 //*********************************************************************
113 void Plot2d_Viewer::onShowToolbar() {
114 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
116 aView->getToolBar()->show();
119 //*********************************************************************
120 void Plot2d_Viewer::onDumpView()
122 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
127 //*********************************************************************
128 void Plot2d_Viewer::onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* )
131 //*********************************************************************
132 void Plot2d_Viewer::setViewManager( SUIT_ViewManager* mgr )
134 SUIT_ViewModel::setViewManager( mgr );
135 if( mgr && mgr->inherits( "Plot2d_ViewManager" ) )
137 Plot2d_ViewManager* pmgr = ( Plot2d_ViewManager* )mgr;
138 connect( pmgr, SIGNAL( cloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ) ),
139 this, SLOT( onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ) ) );