From 84e25d96d776afc672fe28ad9a7fcf5a6dee05c5 Mon Sep 17 00:00:00 2001 From: ouv Date: Wed, 11 Jan 2006 15:01:24 +0000 Subject: [PATCH] Dumping of the segmented view is implemented. --- src/VVTK/VVTK_MainWindow.cxx | 36 ++++++++++++++++++++++++++++++++++++ src/VVTK/VVTK_MainWindow.h | 5 +++++ src/VVTK/VVTK_ViewModel.cxx | 2 +- src/VVTK/VVTK_ViewWindow.cxx | 29 +++++++++++++++++++++++++++++ src/VVTK/VVTK_ViewWindow.h | 7 +++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index c3fddbc7..de0ebfd0 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -39,14 +39,20 @@ #include "VVTK_PickingDlg.h" #include "VVTK_SegmentationCursorDlg.h" +#include "SUIT_Application.h" +#include "SUIT_Session.h" +#include "SUIT_Tools.h" +#include "SUIT_ViewWindow.h" #include "SUIT_ResourceMgr.h" #include "SUIT_ToolButton.h" #include "SUIT_Accel.h" #include "QtxAction.h" +#include #include #include #include +#include //---------------------------------------------------------------------------- VVTK_MainWindow @@ -130,6 +136,12 @@ VVTK_MainWindow myRecorder->SetUseSkippedFrames(true); myRecorder->SetRenderWindow(theInteractor->getRenderWindow()); + disconnect( myActionsMap[ DumpId ], SIGNAL( activated() ), + myViewWindow, SLOT( onDumpView() ) ); + + connect( myActionsMap[ DumpId ], SIGNAL( activated() ), + this, SLOT( onDumpView() ) ); + SVTK_MainWindow::Initialize(theInteractor); } @@ -139,6 +151,30 @@ VVTK_MainWindow::~VVTK_MainWindow() myRecorder->Delete(); } +//---------------------------------------------------------------------------- +void VVTK_MainWindow::onDumpView() +{ + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + QString fileName = app->getFileName( false, QString::null, + tr( "TLT_IMAGE_FILES" ), + tr( "TLT_DUMP_VIEW" ), 0 ); + if( fileName.isEmpty() ) + return; + + QImage img = dumpView(); + if( img.isNull() ) + return; + + QString fmt = SUIT_Tools::extension( fileName ).upper(); + if( fmt.isEmpty() ) + fmt = QString( "BMP" ); // default format + else if( fmt == "JPG" ) + fmt = "JPEG"; + + QApplication::setOverrideCursor( Qt::waitCursor ); + bool res = img.save( fileName, fmt.latin1() ); + QApplication::restoreOverrideCursor(); +} //---------------------------------------------------------------------------- void diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index 7541c0b5..1d0b0bc3 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -47,6 +47,11 @@ public: ~VVTK_MainWindow(); public slots: + + virtual + void + onDumpView(); + //! To change active interactor style at run-time virtual void diff --git a/src/VVTK/VVTK_ViewModel.cxx b/src/VVTK/VVTK_ViewModel.cxx index d2618e99..e3778816 100644 --- a/src/VVTK/VVTK_ViewModel.cxx +++ b/src/VVTK/VVTK_ViewModel.cxx @@ -142,7 +142,7 @@ VVTK_Viewer for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ if(TViewWindow* aView = dynamic_cast(aViewWindow)){ - aView->getMainWindow()->SetBackgroundColor(theColor); + aView->setBackgroundColor(theColor); } } } diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index e9a66ade..a181ad6a 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -41,6 +41,7 @@ #include #include +#include //---------------------------------------------------------------------------- VVTK_ViewWindow @@ -266,3 +267,31 @@ VVTK_ViewWindow if(myMainWindow2->hasFocus()) myMainWindow2->action(accelAction); } + +//---------------------------------------------------------------------------- +QImage +VVTK_ViewWindow +::dumpView() +{ + if( myMainWindow1->GetInteractor()->hasFocus() ) + return myMainWindow1->dumpView(); + + if( myMainWindow2->GetInteractor()->hasFocus() ) + return myMainWindow2->dumpView(); + + return QImage(); +} + +//---------------------------------------------------------------------------- +void +VVTK_ViewWindow +::setBackgroundColor( const QColor& theColor ) +{ + if( myMainWindow1->GetInteractor()->hasFocus() ) + myMainWindow1->SetBackgroundColor( theColor ); + else if( myMainWindow2->GetInteractor()->hasFocus() ) + myMainWindow2->SetBackgroundColor( theColor ); + else + myMainWindow->SetBackgroundColor( theColor ); +} + diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index 8f952ab9..54e4745d 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -80,6 +80,11 @@ public: void unHighlightAll(); + //! Redefine SVTK_ViewWindow::setBackgroundColor method + virtual + void + setBackgroundColor( const QColor& ); + //---------------------------------------------------------------------------- public slots: //! Redefine SVTK_ViewWindow::onSelectionChanged method @@ -103,6 +108,8 @@ protected: void action( const int ); + virtual QImage dumpView(); + VVTK_MainWindow1* myMainWindow1; //!< The manage base view SVTK_View* myView1; //!< The manage base view -- 2.39.2