From fc16e8e06e4a6c6225b25634768aed29836b43bb Mon Sep 17 00:00:00 2001
From: Michael Wild <themiwi@users.sourceforge.net>
Date: Fri, 17 Jul 2009 11:26:31 +0200
Subject: [PATCH 3/3] ENH: Integrated vtkOggTheoraWriter into ParaView

Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
---
 Applications/OverView/Core/AboutDialog.cxx         |    2 ++
 Qt/Components/pqAnimationManager.cxx               |    4 ++++
 Qt/Components/pqClientAboutDialog.cxx              |    2 ++
 Servers/Common/vtkPVServerInformation.cxx          |   13 +++++++++++++
 Servers/Common/vtkPVServerInformation.h            |    6 ++++++
 .../vtkSMAnimationSceneImageWriter.cxx             |    9 +++++++++
 6 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/Applications/OverView/Core/AboutDialog.cxx b/Applications/OverView/Core/AboutDialog.cxx
index 00ba766..891eec7 100755
--- a/Applications/OverView/Core/AboutDialog.cxx
+++ b/Applications/OverView/Core/AboutDialog.cxx
@@ -218,6 +218,8 @@ void AboutDialog::AddServerInformation(pqServer* server, QTreeWidget* tree)
     ::addItem(tree, "Tile Display", "Off");
     }
 
+  ::addItem(tree, "Write Ogg/Theora Animations",
+    serverInfo->GetOGVSupport()? "On": "Off");
   ::addItem(tree, "Write AVI Animations",
     serverInfo->GetAVISupport()? "On": "Off");
 }
diff --git a/Qt/Components/pqAnimationManager.cxx b/Qt/Components/pqAnimationManager.cxx
index 4ec1c3b..bbd92ac 100644
--- a/Qt/Components/pqAnimationManager.cxx
+++ b/Qt/Components/pqAnimationManager.cxx
@@ -427,6 +427,10 @@ bool pqAnimationManager::saveAnimation()
     }
 
   QString filters = "";
+  if (serverInfo && serverInfo->GetOGVSupport())
+    {
+    filters += "Ogg/Theora files (*.ogv);;";
+    }
   if (serverInfo && serverInfo->GetAVISupport())
     {
     filters += "AVI files (*.avi);;";
diff --git a/Qt/Components/pqClientAboutDialog.cxx b/Qt/Components/pqClientAboutDialog.cxx
index 4beae0c..8d748e6 100644
--- a/Qt/Components/pqClientAboutDialog.cxx
+++ b/Qt/Components/pqClientAboutDialog.cxx
@@ -218,6 +218,8 @@ void pqClientAboutDialog::AddServerInformation(pqServer* server, QTreeWidget* tr
     ::addItem(tree, "Tile Display", "Off");
     }
 
+  ::addItem(tree, "Write Ogg/Theora Animations",
+    serverInfo->GetOGVSupport()? "On": "Off");
   ::addItem(tree, "Write AVI Animations",
     serverInfo->GetAVISupport()? "On": "Off");
 }
diff --git a/Servers/Common/vtkPVServerInformation.cxx b/Servers/Common/vtkPVServerInformation.cxx
index c5bd771..f7b0aad 100755
--- a/Servers/Common/vtkPVServerInformation.cxx
+++ b/Servers/Common/vtkPVServerInformation.cxx
@@ -48,6 +48,7 @@ vtkPVServerInformation::vtkPVServerInformation()
   this->AVISupport = 1;
 # endif
 #endif
+  this->OGVSupport = 1;
 
   this->RenderModuleName = NULL;
   this->MachinesInternals = new vtkPVServerOptionsInternals;
@@ -73,6 +74,7 @@ void vtkPVServerInformation::PrintSelf(ostream& os, vtkIndent indent)
   os << indent << "UseIceT: " << this->UseIceT << endl;
   os << indent << "RenderModuleName: "
      << (this->RenderModuleName ? this->RenderModuleName : "(none)") << endl;
+  os << indent << "OGVSupport: " << this->OGVSupport << endl;
   os << indent << "AVISupport: " << this->AVISupport << endl;
   os << indent << "Timeout: " << this->Timeout << endl;
 }
@@ -167,6 +169,11 @@ void vtkPVServerInformation::AddInformation(vtkPVInformation* info)
       this->Timeout = serverInfo->GetTimeout();
       }
 
+    if (!serverInfo->GetOGVSupport())
+      {
+      this->OGVSupport = 0;
+      }
+
     if (!serverInfo->GetAVISupport())
       {
       this->AVISupport = 0;
@@ -199,6 +206,7 @@ void vtkPVServerInformation::CopyToStream(vtkClientServerStream* css)
   *css << this->Timeout;
   *css << this->UseIceT;
   *css << this->RenderModuleName;
+  *css << this->OGVSupport;
   *css << this->AVISupport;
   *css << this->GetNumberOfMachines();
   unsigned int idx;
@@ -257,6 +265,11 @@ void vtkPVServerInformation::CopyFromStream(const vtkClientServerStream* css)
     return;
     }
   this->SetRenderModuleName(rmName);
+  if (!css->GetArgument(0, 9, &this->OGVSupport))
+    {
+    vtkErrorMacro("Error parsing OGVSupport flag from message.");
+    return;
+    }
   if (!css->GetArgument(0, 9, &this->AVISupport))
     {
     vtkErrorMacro("Error parsing AVISupport flag from message.");
diff --git a/Servers/Common/vtkPVServerInformation.h b/Servers/Common/vtkPVServerInformation.h
index aafe6d6..cfc2fcd 100755
--- a/Servers/Common/vtkPVServerInformation.h
+++ b/Servers/Common/vtkPVServerInformation.h
@@ -80,6 +80,11 @@ public:
   vtkGetStringMacro(RenderModuleName);
 
   // Description:
+  // Get/Set if the server supports saving OGVs.
+  vtkSetMacro(OGVSupport, int);
+  vtkGetMacro(OGVSupport, int);
+
+  // Description:
   // Get/Set if the server supports saving AVIs.
   vtkSetMacro(AVISupport, int);
   vtkGetMacro(AVISupport, int);
@@ -120,6 +125,7 @@ protected:
   vtkPVServerInformation();
   ~vtkPVServerInformation();
 
+  int OGVSupport;
   int AVISupport;
   int RemoteRendering;
   int TileDimensions[2];
diff --git a/Servers/ServerManager/vtkSMAnimationSceneImageWriter.cxx b/Servers/ServerManager/vtkSMAnimationSceneImageWriter.cxx
index f7fa49e..f950588 100644
--- a/Servers/ServerManager/vtkSMAnimationSceneImageWriter.cxx
+++ b/Servers/ServerManager/vtkSMAnimationSceneImageWriter.cxx
@@ -45,6 +45,7 @@
 #   include "vtkFFMPEGWriter.h"
 # endif
 #endif
+#include "vtkOggTheoraWriter.h"
 
 vtkStandardNewMacro(vtkSMAnimationSceneImageWriter);
 vtkCxxRevisionMacro(vtkSMAnimationSceneImageWriter, "$Revision: 1.13 $");
@@ -376,6 +377,14 @@ bool vtkSMAnimationSceneImageWriter::CreateWriter()
     mwriter = aviwriter;
     }
 # endif
+  else if (extension == ".ogv" || extension == ".ogg")
+    {
+    vtkOggTheoraWriter *ogvwriter = vtkOggTheoraWriter::New();
+    ogvwriter->SetQuality(this->Quality);
+    ogvwriter->SetRate(
+      static_cast<int>(this->GetFrameRate()));
+    mwriter = ogvwriter;
+    }
 #endif
   else
     {
-- 
1.6.3.3

