removed extra code
authorAnatoly Baksheev <no@email>
Fri, 13 Dec 2013 15:35:48 +0000 (19:35 +0400)
committerAnatoly Baksheev <no@email>
Sun, 19 Jan 2014 14:38:42 +0000 (18:38 +0400)
modules/viz/src/interactor_style.cpp
modules/viz/src/interactor_style.hpp

index 1a7c8a4..5c2ee1c 100644 (file)
@@ -63,11 +63,6 @@ void cv::viz::InteractorStyle::Initialize()
     win_pos_ = Vec2i(0, 0);
     max_win_size_ = Vec2i(-1, -1);
 
-    // Create the image filter and PNG writer objects
-    wif_ = vtkSmartPointer<vtkWindowToImageFilter>::New();
-    snapshot_writer_ = vtkSmartPointer<vtkPNGWriter>::New();
-    snapshot_writer_->SetInputConnection(wif_->GetOutputPort());
-
     init_ = true;
     stereo_anaglyph_mask_default_ = true;
 
@@ -84,11 +79,14 @@ void cv::viz::InteractorStyle::Initialize()
 void cv::viz::InteractorStyle::saveScreenshot(const String &file)
 {
     FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]);
-    wif_->SetInput(Interactor->GetRenderWindow());
-    wif_->Modified(); // Update the WindowToImageFilter
-    snapshot_writer_->Modified();
-    snapshot_writer_->SetFileName(file.c_str());
-    snapshot_writer_->Write();
+
+    vtkSmartPointer<vtkWindowToImageFilter> wif = vtkSmartPointer<vtkWindowToImageFilter>::New();
+    wif->SetInput(Interactor->GetRenderWindow());
+
+    vtkSmartPointer<vtkPNGWriter> snapshot_writer = vtkSmartPointer<vtkPNGWriter>::New();
+    snapshot_writer->SetInputConnection(wif->GetOutputPort());
+    snapshot_writer->SetFileName(file.c_str());
+    snapshot_writer->Write();
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -196,21 +194,13 @@ int cv::viz::InteractorStyle::getModifiers()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
-void
-cv::viz::InteractorStyle::OnKeyDown()
+void cv::viz::InteractorStyle::OnKeyDown()
 {
     CV_Assert("Interactor style not initialized. Please call Initialize() before continuing" && init_);
     CV_Assert("No renderer given! Use SetRendererCollection() before continuing." && renderer_);
 
     FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]);
 
-    if (wif_->GetInput() == NULL)
-    {
-        wif_->SetInput(Interactor->GetRenderWindow());
-        wif_->Modified();
-        snapshot_writer_->Modified();
-    }
-
     // Save the initial windows width/height
     if (win_size_[0] == -1 || win_size_[1] == -1)
         win_size_ = Vec2i(Interactor->GetRenderWindow()->GetSize());
index 51f9863..7ae4fa7 100644 (file)
@@ -79,12 +79,6 @@ namespace cv
             Vec2i win_pos_;
             Vec2i max_win_size_;
 
-            /** \brief A PNG writer for screenshot captures. */
-            vtkSmartPointer<vtkPNGWriter> snapshot_writer_;
-
-            /** \brief Internal window to image filter. Needed by \a snapshot_writer_. */
-            vtkSmartPointer<vtkWindowToImageFilter> wif_;
-
             /** \brief Interactor style internal method. Gets called whenever a key is pressed. */
             virtual void OnChar();