]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Dumping of the segmented view is implemented.
authorouv <ouv@opencascade.com>
Wed, 11 Jan 2006 15:01:24 +0000 (15:01 +0000)
committerouv <ouv@opencascade.com>
Wed, 11 Jan 2006 15:01:24 +0000 (15:01 +0000)
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_MainWindow.h
src/VVTK/VVTK_ViewModel.cxx
src/VVTK/VVTK_ViewWindow.cxx
src/VVTK/VVTK_ViewWindow.h

index c3fddbc7685086b7fbe5f32d8159bb7f729f23ea..de0ebfd064e7131f2300a2daebd154a876fd5e31 100644 (file)
 #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 <qimage.h>
 #include <qtoolbar.h>
 #include <qsplitter.h>
 #include <qfiledialog.h>
+#include <qapplication.h>
 
 //----------------------------------------------------------------------------
 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
index 7541c0b54d3d3f9443c51fab2456899b481821db..1d0b0bc38244f835a1f2beb53bc0caa3d8a56e17 100644 (file)
@@ -47,6 +47,11 @@ public:
   ~VVTK_MainWindow();
 
  public slots:
+
+  virtual
+  void
+  onDumpView();
+
    //! To change active interactor style at run-time
   virtual
   void
index d2618e99ffabc98268a3c664bf0e3375f8de50d5..e37788166805c9682d024b21562287cde436e73c 100644 (file)
@@ -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<TViewWindow*>(aViewWindow)){
-       aView->getMainWindow()->SetBackgroundColor(theColor);
+       aView->setBackgroundColor(theColor);
       }
     }
   }
index e9a66aded1e2c63c3eb512524ac4d42ed0aaa621..a181ad6ab21925511e82e4d4e2e6ac2e8f4c0872 100755 (executable)
@@ -41,6 +41,7 @@
 
 #include <qsplitter.h>
 #include <qlayout.h>
+#include <qimage.h>
 
 //----------------------------------------------------------------------------
 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 );
+}
+
index 8f952ab964723edf06a807cefebd6372df966c8f..54e4745d03240bd4000d35b22049b5d180687f8c 100755 (executable)
@@ -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