From c3628f91c8923201564a571b158e254f271d7d35 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 5 Oct 2010 14:55:26 +0000 Subject: [PATCH] *** empty log message *** --- src/OCCViewer/OCCViewer_ViewFrame.cxx | 35 ++++++++++++++++++++++++--- src/OCCViewer/OCCViewer_ViewFrame.h | 8 +++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 28d368be1..3b45478cc 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -10,7 +10,7 @@ OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel) - : OCCViewer_ViewWindow( theDesktop, theModel ) + : OCCViewer_ViewWindow( theDesktop, theModel ), myPopupRequestedView(0) { QFrame* centralFrame = new QFrame( this ); setCentralWidget( centralFrame ); @@ -156,15 +156,24 @@ void OCCViewer_ViewFrame::connectViewSignals(OCCViewer_ViewWindow* theView) connect( theView, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ), this, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ) ); + // The signal is used to process get/set bacgrounf\d color from popup + connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), + this, SLOT( onContextMenuRequested(QContextMenuEvent*) ) ); + connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) ); + } void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor) { - foreach (OCCViewer_ViewWindow* aView, myViews) { - aView->setBackgroundColor(theColor); - } + if (myPopupRequestedView) + myPopupRequestedView->setBackgroundColor(theColor); + else + foreach (OCCViewer_ViewWindow* aView, myViews) { + if (aView->isVisible()) + aView->setBackgroundColor(theColor); + } } @@ -181,3 +190,21 @@ void OCCViewer_ViewFrame::onFitAll() aView->onFitAll(); } } + +QColor OCCViewer_ViewFrame::backgroundColor() const +{ + if (myPopupRequestedView) + return myPopupRequestedView->backgroundColor(); + + foreach (OCCViewer_ViewWindow* aView, myViews) { + if (aView->isVisible()) + return aView->backgroundColor(); + } + return getView(MAIN_VIEW)->backgroundColor(); +} + +void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*) +{ + myPopupRequestedView = dynamic_cast(sender()); +} + diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h index 4307479a0..0bf841632 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.h +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -71,9 +71,10 @@ public: virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); } - virtual QColor backgroundColor() const { return getView(MAIN_VIEW)->backgroundColor(); } + virtual QColor backgroundColor() const; virtual void setBackgroundColor( const QColor& ); + public slots: virtual void onFrontView() { getView(MAIN_VIEW)->onFrontView(); } virtual void onViewFitAll(); @@ -105,12 +106,17 @@ public slots: virtual void onDumpView() { getView(MAIN_VIEW)->onDumpView(); } +private slots: + void onContextMenuRequested(QContextMenuEvent*); + private: void connectViewSignals(OCCViewer_ViewWindow* theView); QList myViews; QGridLayout* myLayout; + + OCCViewer_ViewWindow* myPopupRequestedView; }; #endif -- 2.39.2