From 7011951954c5fac109f58182a66d68f117ebac00 Mon Sep 17 00:00:00 2001
From: Melanie Carriere <melanie.carriere@kitware.com>
Date: Thu, 9 Jul 2020 13:03:32 +0200
Subject: [PATCH] Wrap Start Recording function from vtkStream in paraview

We need to access this function in python file for specific client
The access is also needed to test the recording
---
 LidarPlugin/IO/vtkStream.cxx | 18 ++++++++++++++++++
 LidarPlugin/IO/vtkStream.h   | 11 +++++++++++
 LidarPlugin/xml/Stream.xml   | 18 ++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/LidarPlugin/IO/vtkStream.cxx b/LidarPlugin/IO/vtkStream.cxx
index cb7d34f6d..28d095390 100644
--- a/LidarPlugin/IO/vtkStream.cxx
+++ b/LidarPlugin/IO/vtkStream.cxx
@@ -203,6 +203,24 @@ bool vtkStream::IsRecording()
   return vtkStream::WriterThread ? true : false;
 }
 
+//-----------------------------------------------------------------------------
+void vtkStream::StartGlobalRecording()
+{
+  if(!vtkStream::IsRecording())
+  {
+    vtkStream::StartRecording(this->RecordingFilename);
+  }
+}
+
+//-----------------------------------------------------------------------------
+void vtkStream::StopGlobalRecording()
+{
+  if(vtkStream::IsRecording())
+  {
+    vtkStream::StopRecording();
+  }
+}
+
 //-----------------------------------------------------------------------------
 void vtkStream::EnqueuePacket(NetworkPacket* packet)
 {
diff --git a/LidarPlugin/IO/vtkStream.h b/LidarPlugin/IO/vtkStream.h
index c90224c2b..baba7e699 100644
--- a/LidarPlugin/IO/vtkStream.h
+++ b/LidarPlugin/IO/vtkStream.h
@@ -41,6 +41,12 @@ public:
   static void StopRecording();
   static bool IsRecording();
 
+  // Member function that start global recording
+  void StartGlobalRecording();
+
+  // Member function that stop global recording
+  void StopGlobalRecording();
+
   vtkGetMacro(ListeningPort, int)
   void SetListeningPort(int);
 
@@ -62,6 +68,9 @@ public:
   vtkGetMacro(IsCrashAnalysing, bool)
   void SetIsCrashAnalysing(bool value);
 
+  vtkGetMacro(RecordingFilename, std::string)
+  vtkSetMacro(RecordingFilename, std::string)
+
   /**
    * @brief GetNeedsUpdate
    * @return true if a new data is ready
@@ -141,6 +150,8 @@ private:
   /*!< The ip to send forwarded packets*/
   std::string ForwardedIpAddress = "127.0.0.1";
 
+  /*!< The filename to save the received pcaps*/
+  std::string RecordingFilename;
 
   bool IsCrashAnalysing = false;
 
diff --git a/LidarPlugin/xml/Stream.xml b/LidarPlugin/xml/Stream.xml
index b4b3c1d50..5a7b2ed50 100644
--- a/LidarPlugin/xml/Stream.xml
+++ b/LidarPlugin/xml/Stream.xml
@@ -91,6 +91,16 @@
       </Hints>
     </IntVectorProperty>
 
+    <StringVectorProperty
+        name="RecordingFilename"
+        command="SetRecordingFilename"
+        default_values=""
+        number_of_elements="1">
+      <Documentation>
+        Specify filename where the received pcaps will be saved with the command StartRecording.
+      </Documentation>
+    </StringVectorProperty>
+
     <Property
       name="Start"
       command="Start" />
@@ -99,6 +109,14 @@
       name="Stop"
       command="Stop" />
 
+    <Property
+      name="StartGlobalRecording"
+      command="StartGlobalRecording" />
+
+    <Property
+      name="StopGlobalRecording"
+      command="StopGlobalRecording" />
+
     <IntVectorProperty
         name="IsCrashAnalysing"
         command="SetIsCrashAnalysing"
-- 
GitLab