1 // Plot2d_ViewModel.cxx: implementation of the Plot2d_ViewModel class.
3 //////////////////////////////////////////////////////////////////////
5 #include "Plot2d_ViewModel.h"
6 #include "Plot2d_ViewWindow.h"
9 Plot2d_Viewer::Plot2d_Viewer(bool theAutoDel)
13 myAutoDel = theAutoDel;
16 Plot2d_Viewer::~Plot2d_Viewer()
22 //*********************************************************************
23 SUIT_ViewWindow* Plot2d_Viewer::createView(SUIT_Desktop* theDesktop)
25 Plot2d_ViewWindow* aPlot2dView = new Plot2d_ViewWindow(theDesktop, this);
27 aPlot2dView->getViewFrame()->Display(myPrs);
31 //*********************************************************************
32 void Plot2d_Viewer::contextMenuPopup(QPopupMenu* thePopup)
34 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
36 aView->contextMenuPopup(thePopup);
38 if (thePopup->count() > 0) thePopup->insertSeparator();
39 thePopup->insertItem("Change background...", this, SLOT(onChangeBgColor()));
42 if ( !aView->getToolBar()->isVisible() ) {
43 if (thePopup->count() > 0) thePopup->insertSeparator();
44 thePopup->insertItem("Show toolbar", this, SLOT(onShowToolbar()));
50 //*********************************************************************
51 void Plot2d_Viewer::setPrs(Plot2d_Prs* thePrs)
56 myPrs->setAutoDel(myAutoDel);
59 //*********************************************************************
60 void Plot2d_Viewer::update()
62 SUIT_ViewManager* aMgr = getViewManager();
63 QPtrVector<SUIT_ViewWindow> aViews = aMgr->getViews();
64 unsigned int aSize = aViews.size();
65 for (uint i = 0; i < aSize; i++) {
66 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)aViews[i];
68 aView->getViewFrame()->Display(myPrs);
72 //*********************************************************************
73 void Plot2d_Viewer::clearPrs()
75 SUIT_ViewManager* aMgr = getViewManager();
76 QPtrVector<SUIT_ViewWindow> aViews = aMgr->getViews();
77 unsigned int aSize = aViews.size();
78 for (uint i = 0; i < aSize; i++) {
79 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)aViews[i];
81 aView->getViewFrame()->Erase(myPrs);
83 if (myAutoDel && myPrs) {
89 //*********************************************************************
90 void Plot2d_Viewer::setAutoDel(bool theDel)
94 myPrs->setAutoDel(theDel);
97 //*********************************************************************
98 void Plot2d_Viewer::onChangeBgColor()
100 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
103 Plot2d_ViewFrame* aViewFrame = aView->getViewFrame();
104 aViewFrame->onChangeBackground();
107 //*********************************************************************
108 void Plot2d_Viewer::onShowToolbar() {
109 Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
111 aView->getToolBar()->show();