]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for
authorapo <apo@opencascade.com>
Fri, 5 May 2006 08:47:46 +0000 (08:47 +0000)
committerapo <apo@opencascade.com>
Fri, 5 May 2006 08:47:46 +0000 (08:47 +0000)
Bug12353
   TC: Recorder in Gauss viewer doesn't record picking after "Pause".
Bug12341
  TC: Temp JPEG files are not deleted after Gauss AVI creation

src/VVTK/VVTK_ImageWriter.cxx
src/VVTK/VVTK_ImageWriter.h
src/VVTK/VVTK_ImageWriterMgr.cxx
src/VVTK/VVTK_ImageWriterMgr.h
src/VVTK/VVTK_Recorder.cxx
src/VVTK/VVTK_Recorder.h
src/VVTK/VVTK_SegmentationCursorDlg.cxx

index 9d04759878202e582e0d658e41de7e7b9b80376d..079557b1a7f24fa564f450cf39f612eda636bcc4 100755 (executable)
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   :\r
-//  Author :\r
-//  Module :\r
-//  $Header$\r
-\r
-#include "VVTK_ImageWriter.h"\r
-\r
-#include <qsemaphore.h>\r
-\r
-#include <vtkImageData.h>\r
-#include <vtkImageClip.h>\r
-#include <vtkJPEGWriter.h>\r
-#include <vtkSmartPointer.h>\r
-\r
-#ifdef _DEBUG_\r
-static int MYDEBUG = 0;\r
-#else\r
-static int MYDEBUG = 0;\r
-#endif\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_ImageWriter\r
-::VVTK_ImageWriter(QSemaphore* theSemaphore,\r
-                  vtkImageData* theImageData,\r
-                  const std::string& theName,\r
-                  int theProgressive,\r
-                  int theQuality):\r
-  mySemaphore(theSemaphore),\r
-  myImageData(theImageData),\r
-  myName(theName),\r
-  myProgressive(theProgressive),\r
-  myQuality(theQuality),\r
-  myConstraint16Flag(true)\r
-{}\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_ImageWriter\r
-::~VVTK_ImageWriter()\r
-{\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriter::~VVTK_ImageWriter - this = "<<this<<endl;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_ImageWriter\r
-::run()\r
-{\r
-  vtkJPEGWriter *aWriter = vtkJPEGWriter::New();\r
-  vtkImageData *anImageData = myImageData;\r
-  vtkSmartPointer<vtkImageClip> anImageClip;\r
-  //\r
-  if(myConstraint16Flag){ \r
-    int uExtent[6];\r
-    myImageData->GetUpdateExtent(uExtent);\r
-    unsigned int width = uExtent[1] - uExtent[0] + 1;\r
-    unsigned int height = uExtent[3] - uExtent[2] + 1;\r
-    width = (width / 16) * 16;\r
-    height= (height / 16) * 16;\r
-    uExtent[1] = uExtent[0] + width - 1;\r
-    uExtent[3] = uExtent[2] + height - 1;\r
-    //\r
-    anImageClip = vtkImageClip::New();\r
-    anImageClip->Delete();\r
-\r
-    anImageClip->SetInput(myImageData);\r
-    anImageClip->SetOutputWholeExtent(uExtent);\r
-    anImageClip->ClipDataOn();\r
-    anImageData = anImageClip->GetOutput();\r
-  }\r
-  //\r
-  aWriter->WriteToMemoryOff();\r
-  aWriter->SetFileName(myName.c_str());\r
-  aWriter->SetQuality(myQuality);\r
-  aWriter->SetProgressive(myProgressive);\r
-  aWriter->SetInput(anImageData);\r
-  aWriter->Write();\r
-\r
-  aWriter->Delete();\r
-  myImageData->Delete();\r
-\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriter::run "<<\r
-               "- this = "<<this<<\r
-               "; total = "<<mySemaphore->total()<<\r
-               "; available = "<<mySemaphore->available()<<endl;\r
-  *mySemaphore -= 1;\r
-}\r
-\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   :
+//  Author :
+//  Module :
+//  $Header$
+
+#include "VVTK_ImageWriter.h"
+
+#include <qsemaphore.h>
+
+#include <vtkImageData.h>
+#include <vtkImageClip.h>
+#include <vtkJPEGWriter.h>
+#include <vtkSmartPointer.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriter
+::VVTK_ImageWriter(QSemaphore* theSemaphore,
+                  vtkImageData* theImageData,
+                  const std::string& theName,
+                  int theProgressive,
+                  int theQuality):
+  mySemaphore(theSemaphore),
+  myImageData(theImageData),
+  myName(theName),
+  myProgressive(theProgressive),
+  myQuality(theQuality),
+  myConstraint16Flag(true)
+{}
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriter
+::~VVTK_ImageWriter()
+{
+  if(MYDEBUG) cout<<"VVTK_ImageWriter::~VVTK_ImageWriter - this = "<<this<<endl;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriter
+::run()
+{
+  vtkJPEGWriter *aWriter = vtkJPEGWriter::New();
+  vtkImageData *anImageData = myImageData;
+  vtkSmartPointer<vtkImageClip> anImageClip;
+  //
+  if(myConstraint16Flag){ 
+    int uExtent[6];
+    myImageData->GetUpdateExtent(uExtent);
+    unsigned int width = uExtent[1] - uExtent[0] + 1;
+    unsigned int height = uExtent[3] - uExtent[2] + 1;
+    width = (width / 16) * 16;
+    height= (height / 16) * 16;
+    uExtent[1] = uExtent[0] + width - 1;
+    uExtent[3] = uExtent[2] + height - 1;
+    //
+    anImageClip = vtkImageClip::New();
+    anImageClip->Delete();
+
+    anImageClip->SetInput(myImageData);
+    anImageClip->SetOutputWholeExtent(uExtent);
+    anImageClip->ClipDataOn();
+    anImageData = anImageClip->GetOutput();
+  }
+  //
+  aWriter->WriteToMemoryOff();
+  aWriter->SetFileName(myName.c_str());
+  aWriter->SetQuality(myQuality);
+  aWriter->SetProgressive(myProgressive);
+  aWriter->SetInput(anImageData);
+  aWriter->Write();
+
+  aWriter->Delete();
+  myImageData->Delete();
+
+  if(MYDEBUG) cout<<"VVTK_ImageWriter::run "<<
+               "- this = "<<this<<
+               "; total = "<<mySemaphore->total()<<
+               "; available = "<<mySemaphore->available()<<endl;
+  *mySemaphore -= 1;
+}
+
index 341fc0de2c6dd16943a79dd319a19ae87cf039e1..283790cb979da03cf51a6e9aec3be355a9f4056d 100755 (executable)
@@ -1,64 +1,64 @@
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   :\r
-//  Author :\r
-//  Module :\r
-//  $Header$\r
-\r
-\r
-#ifndef _VVTK_ImageWriter_Header_File_\r
-#define _VVTK_ImageWriter_Header_File_\r
-\r
-#include <qthread.h>\r
-#include <string>\r
-\r
-class vtkImageData;\r
-class QSemaphore;\r
-\r
-\r
-class VVTK_ImageWriter : public QThread \r
-{\r
-public:\r
-  VVTK_ImageWriter(QSemaphore* theSemaphore,\r
-                  vtkImageData* theImageData,\r
-                  const std::string& theName,\r
-                  int theProgressive,\r
-                  int theQuality);\r
-\r
-  ~VVTK_ImageWriter();\r
-\r
- protected:\r
-  virtual\r
-  void\r
-  run();\r
-  \r
- protected:\r
-  QSemaphore* mySemaphore;\r
-  vtkImageData *myImageData;\r
-  std::string myName;\r
-  int   myProgressive;\r
-  int   myQuality;\r
-  bool  myConstraint16Flag;\r
-};\r
-#endif\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   :
+//  Author :
+//  Module :
+//  $Header$
+
+
+#ifndef _VVTK_ImageWriter_Header_File_
+#define _VVTK_ImageWriter_Header_File_
+
+#include <qthread.h>
+#include <string>
+
+class vtkImageData;
+class QSemaphore;
+
+
+class VVTK_ImageWriter : public QThread 
+{
+public:
+  VVTK_ImageWriter(QSemaphore* theSemaphore,
+                  vtkImageData* theImageData,
+                  const std::string& theName,
+                  int theProgressive,
+                  int theQuality);
+
+  ~VVTK_ImageWriter();
+
+ protected:
+  virtual
+  void
+  run();
+  
+ protected:
+  QSemaphore* mySemaphore;
+  vtkImageData *myImageData;
+  std::string myName;
+  int   myProgressive;
+  int   myQuality;
+  bool  myConstraint16Flag;
+};
+#endif
index bc9d364e0145f2d5b7321cc195a41f65d32cfab5..944f15b8f1d2269c13a5dc37465eaa2eb7762511 100755 (executable)
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   :\r
-//  Author :\r
-//  Module :\r
-//  $Header$\r
-\r
-#include "VVTK_ImageWriterMgr.h"\r
-#include "VVTK_ImageWriter.h"\r
-\r
-#include <vtkImageData.h>\r
-\r
-#include <qsemaphore.h>\r
-\r
-#include <limits>\r
-\r
-\r
-#ifdef _DEBUG_\r
-static int MYDEBUG = 0;\r
-#else\r
-static int MYDEBUG = 0;\r
-#endif\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_ImageWriterMgr\r
-::VVTK_ImageWriterMgr()\r
-{\r
-  int aMax = std::numeric_limits<int>::max() / 2;\r
-  mySemaphore = new QSemaphore(aMax);\r
-  *mySemaphore += aMax;\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::VVTK_ImageWriterMgr "<<\r
-               "- total = "<<mySemaphore->total()<<\r
-               "; available = "<<mySemaphore->available()<<endl;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_ImageWriterMgr\r
-::~VVTK_ImageWriterMgr()\r
-{\r
-  Stop();\r
-  delete mySemaphore;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_ImageWriterMgr\r
-::StartImageWriter(vtkImageData *theImageData,\r
-                  const std::string& theName,\r
-                  const int theProgressive,\r
-                  const int theQuality)\r
-{\r
-  VVTK_ImageWriter *anImageWriter = \r
-    new VVTK_ImageWriter(mySemaphore,\r
-                        theImageData,\r
-                        theName,\r
-                        theProgressive,\r
-                        theQuality);\r
-  myThreads.push_back(anImageWriter);\r
-\r
-  anImageWriter->start();\r
-\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_ImageWriterMgr\r
-::Stop()\r
-{\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::Stop "<<\r
-               "- total = "<<mySemaphore->total()<<\r
-               "; available = "<<mySemaphore->available()<<endl;\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::Stop - *mySemaphore += "<<myThreads.size()<<endl;\r
-  *mySemaphore += myThreads.size();\r
-\r
-  for(size_t anId = 0, anEnd = myThreads.size(); anId < anEnd; anId++){\r
-    VVTK_ImageWriter* anImageWriter = myThreads[anId];\r
-    anImageWriter->wait();\r
-    delete anImageWriter;\r
-  }\r
-  myThreads.clear();\r
-}\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   :
+//  Author :
+//  Module :
+//  $Header$
+
+#include "VVTK_ImageWriterMgr.h"
+#include "VVTK_ImageWriter.h"
+
+#include <vtkImageData.h>
+
+#include <qsemaphore.h>
+
+#include <limits>
+
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriterMgr
+::VVTK_ImageWriterMgr()
+{
+  int aMax = std::numeric_limits<int>::max() / 2;
+  mySemaphore = new QSemaphore(aMax);
+  *mySemaphore += aMax;
+  if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::VVTK_ImageWriterMgr "<<
+               "- total = "<<mySemaphore->total()<<
+               "; available = "<<mySemaphore->available()<<endl;
+}
+
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriterMgr
+::~VVTK_ImageWriterMgr()
+{
+  Stop();
+  delete mySemaphore;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriterMgr
+::StartImageWriter(vtkImageData *theImageData,
+                  const std::string& theName,
+                  const int theProgressive,
+                  const int theQuality)
+{
+  VVTK_ImageWriter *anImageWriter = 
+    new VVTK_ImageWriter(mySemaphore,
+                        theImageData,
+                        theName,
+                        theProgressive,
+                        theQuality);
+  myThreads.push_back(anImageWriter);
+
+  anImageWriter->start();
+
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriterMgr
+::Stop()
+{
+  if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::Stop "<<
+               "- total = "<<mySemaphore->total()<<
+               "; available = "<<mySemaphore->available()<<endl;
+  if(MYDEBUG) cout<<"VVTK_ImageWriterMgr::Stop - *mySemaphore += "<<myThreads.size()<<endl;
+  *mySemaphore += myThreads.size();
+
+  for(size_t anId = 0, anEnd = myThreads.size(); anId < anEnd; anId++){
+    VVTK_ImageWriter* anImageWriter = myThreads[anId];
+    anImageWriter->wait();
+    delete anImageWriter;
+  }
+  myThreads.clear();
+}
index 81ca97fbdb3554ea2468f3bb152f05e898232f34..b88400ef46496c45929951f8ef469aa3714b459a 100755 (executable)
@@ -1,65 +1,65 @@
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   :\r
-//  Author :\r
-//  Module :\r
-//  $Header$\r
-\r
-#ifndef _VVTK_ImageWriterMgr_Header_File_\r
-#define _VVTK_ImageWriterMgr_Header_File_\r
-\r
-#include <string>\r
-#include <vector>\r
-\r
-class QString;\r
-class vtkImageData;\r
-class VVTK_ImageWriter;\r
-class QSemaphore;\r
-\r
-class VVTK_ImageWriterMgr\r
-{\r
- public:\r
-  VVTK_ImageWriterMgr();\r
-  ~VVTK_ImageWriterMgr();\r
-  \r
-  void\r
-  StartImageWriter(vtkImageData *theImageData,\r
-                  const std::string& theName,\r
-                  const int theProgressive,\r
-                  const int theQuality);\r
-\r
-  void\r
-  Stop();\r
-\r
-  typedef std::vector<VVTK_ImageWriter*> TWriterThreads;\r
-\r
- protected:\r
-  TWriterThreads myThreads;\r
-\r
-  QSemaphore* mySemaphore;\r
-};\r
-\r
-\r
-#endif\r
-\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   :
+//  Author :
+//  Module :
+//  $Header$
+
+#ifndef _VVTK_ImageWriterMgr_Header_File_
+#define _VVTK_ImageWriterMgr_Header_File_
+
+#include <string>
+#include <vector>
+
+class QString;
+class vtkImageData;
+class VVTK_ImageWriter;
+class QSemaphore;
+
+class VVTK_ImageWriterMgr
+{
+ public:
+  VVTK_ImageWriterMgr();
+  ~VVTK_ImageWriterMgr();
+  
+  void
+  StartImageWriter(vtkImageData *theImageData,
+                  const std::string& theName,
+                  const int theProgressive,
+                  const int theQuality);
+
+  void
+  Stop();
+
+  typedef std::vector<VVTK_ImageWriter*> TWriterThreads;
+
+ protected:
+  TWriterThreads myThreads;
+
+  QSemaphore* mySemaphore;
+};
+
+
+#endif
+
index f5e9b4774ae5ab741bed45dbb7b91379d59efd33..bc44cb1dadc6bd326c9a5ad4df07c9908bd0735a 100755 (executable)
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   :\r
-//  Author :\r
-//  Module :\r
-//  $Header$\r
-\r
-#include "VVTK_Recorder.h"\r
-\r
-#include "VVTK_ImageWriter.h"\r
-#include "VVTK_ImageWriterMgr.h"\r
-\r
-#include <vtkObjectFactory.h>\r
-#include <vtkObject.h>\r
-#include <vtkCallbackCommand.h>\r
-#include <vtkRenderWindow.h>\r
-#include <vtkTimerLog.h>\r
-#include <vtkWindowToImageFilter.h>\r
-#include <vtkJPEGWriter.h>\r
-#include <vtkImageData.h>\r
-\r
-#include <sstream>\r
-#include <iomanip>\r
-#include <iostream>\r
-\r
-#include <unistd.h>\r
-#include <qapplication.h>\r
-#include <qfileinfo.h>\r
-\r
-#include "utilities.h"\r
-\r
-#ifdef _DEBUG_\r
-static int MYDEBUG = 0;\r
-#else\r
-static int MYDEBUG = 0;\r
-#endif\r
-\r
-\r
-namespace\r
-{\r
-  //----------------------------------------------------------------------------\r
-  inline\r
-  void\r
-  GetNameJPEG(const std::string& thePreffix,  \r
-             const int theIndex,\r
-             std::string& theName)\r
-  {\r
-    using namespace std;\r
-    ostringstream aStream;\r
-    aStream<<thePreffix<<"_"<<setw(6)<<setfill('0')<<theIndex<<".jpeg";\r
-    theName = aStream.str();\r
-  }\r
-}\r
-\r
-//----------------------------------------------------------------------------\r
-vtkCxxRevisionMacro(VVTK_Recorder,"$Revision$");\r
-vtkStandardNewMacro(VVTK_Recorder);\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_Recorder\r
-::VVTK_Recorder():\r
-  myRenderWindow(NULL),\r
-  myState(VVTK_Recorder_Stop),\r
-  myNbFPS(5.5),\r
-  myQuality(100),\r
-  myProgressiveMode(true),\r
-  myUseSkippedFrames(true),\r
-  myErrorStatus(0),\r
-  myCommand(vtkCallbackCommand::New()),\r
-  myPriority(0.0),\r
-  myTimeStart(0.0),\r
-  myFrameIndex(0),\r
-  myPaused(0),\r
-  myFilter(vtkWindowToImageFilter::New()),\r
-  myWriterMgr(new VVTK_ImageWriterMgr),\r
-  myNbWrittenFrames(0),\r
-  myNameAVIMaker("jpeg2yuv")\r
-{\r
-  myCommand->SetClientData(this); \r
-  myCommand->SetCallback(VVTK_Recorder::ProcessEvents);\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_Recorder\r
-::~VVTK_Recorder()\r
-{\r
-  myCommand->Delete();\r
-  myFilter->Delete();\r
-  delete myWriterMgr;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::CheckExistAVIMaker()\r
-{\r
-  myErrorStatus = 0;\r
-  using namespace std;\r
-  ostringstream aStream;\r
-  aStream<<"which "<<myNameAVIMaker<<" >& /dev/null";\r
-  std::string anAVIMakeCheck = aStream.str();\r
-  int iErr = system(anAVIMakeCheck.c_str());\r
-  if(iErr != 0)\r
-    myErrorStatus = 127;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::SetName(const char* theName)\r
-{\r
-  myName = theName;\r
-}\r
-\r
-const char* \r
-VVTK_Recorder::Name() const\r
-{\r
-  return myName.c_str();\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::SetNbFPS(const double theNbFPS)\r
-{\r
-  myNbFPS = theNbFPS;\r
-}\r
-\r
-double\r
-VVTK_Recorder\r
-::NbFPS() const\r
-{\r
-  return myNbFPS;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::SetQuality(int theQuality)\r
-{\r
-  myQuality = theQuality;\r
-}\r
-\r
-int\r
-VVTK_Recorder\r
-::GetQuality() const\r
-{\r
-  return myQuality;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void \r
-VVTK_Recorder\r
-::SetRenderWindow(vtkRenderWindow* theRenderWindow)\r
-{\r
-  myRenderWindow = theRenderWindow;\r
-}\r
-\r
-vtkRenderWindow* \r
-VVTK_Recorder\r
-::RenderWindow()\r
-{\r
-  return myRenderWindow;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::SetProgressiveMode(bool theProgressiveMode)\r
-{\r
-  myProgressiveMode = theProgressiveMode;\r
-}\r
-\r
-bool\r
-VVTK_Recorder\r
-::GetProgressiveMode() const\r
-{\r
-  return myProgressiveMode;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::SetUseSkippedFrames(bool theUseSkippedFrames)\r
-{\r
-  myUseSkippedFrames = theUseSkippedFrames;\r
-}\r
-\r
-bool\r
-VVTK_Recorder\r
-::UseSkippedFrames() const\r
-{\r
-  return myUseSkippedFrames;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-int\r
-VVTK_Recorder\r
-::ErrorStatus() const\r
-{\r
-  return myErrorStatus;\r
-}\r
-\r
-int\r
-VVTK_Recorder\r
-::State() const\r
-{\r
-  return myState;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::ProcessEvents(vtkObject* vtkNotUsed(theObject), \r
-               unsigned long theEvent,\r
-               void* theClientData, \r
-               void* vtkNotUsed(theCallData))\r
-{\r
-  if(vtkObject* anObj = reinterpret_cast<vtkObject*>(theClientData)){ \r
-    if(VVTK_Recorder* aSelf = dynamic_cast<VVTK_Recorder*>(anObj)){\r
-      if(theEvent==vtkCommand::EndEvent){\r
-       if(aSelf->State() == VVTK_Recorder::VVTK_Recorder_Record){\r
-         aSelf->DoRecord();\r
-       }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::Record()\r
-{\r
-  if(myState == VVTK_Recorder_Stop){\r
-    if(myRenderWindow){\r
-      myState = VVTK_Recorder_Record;\r
-      myFilter->SetInput(myRenderWindow);\r
-      myFrameIndex = -1;\r
-      myNbWrittenFrames = 0;\r
-      myRenderWindow->RemoveObserver(myCommand);\r
-      myRenderWindow->AddObserver(vtkCommand::EndEvent,\r
-                                  myCommand,\r
-                                  myPriority);\r
-      myRenderWindow->Render();\r
-    }\r
-  }\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::Stop()\r
-{\r
-  QApplication::setOverrideCursor( Qt::waitCursor );\r
-\r
-  if(myState == VVTK_Recorder_Record){ \r
-    if(!myPaused)\r
-      DoRecord();\r
-\r
-    myWriterMgr->Stop();\r
-\r
-    if(myUseSkippedFrames)\r
-      AddSkippedFrames();\r
-\r
-    myFrameIndexes.clear();\r
-\r
-    MakeFileAVI();\r
-  }\r
-  myState = VVTK_Recorder_Stop;\r
-  myPaused = 0;\r
-\r
-  QApplication::restoreOverrideCursor();\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::Pause()\r
-{\r
-  myPaused = myPaused ? 0 : 1;\r
-  if(myPaused && !myFrameIndexes.empty()){\r
-    size_t aLastId = myFrameIndexes.size() - 1;\r
-    myFrameIndexes[aLastId] *= -1;\r
-  }\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::DoRecord()\r
-{\r
-  if(myPaused)\r
-    return;\r
-\r
-  if(myFrameIndex < 0){\r
-    myFrameIndex = 0;\r
-    myTimeStart = vtkTimerLog::GetCurrentTime();\r
-  }else{\r
-    double aTimeNow = vtkTimerLog::GetCurrentTime();\r
-    double aDelta = aTimeNow - myTimeStart;\r
-    if(aDelta < 0.0)\r
-      return;\r
-\r
-    int aFrameIndex = int(aDelta*myNbFPS);\r
-    if(aFrameIndex == myFrameIndex)\r
-      return;\r
-\r
-    myFrameIndex = aFrameIndex;\r
-  }\r
-\r
-  myFrameIndexes.push_back(myFrameIndex);\r
-  if(MYDEBUG) cout<<"VVTK_Recorder::DoRecord - myFrameIndex = "<<myFrameIndex<<endl;\r
-\r
-  myRenderWindow->RemoveObserver(myCommand);\r
-  myFilter->Modified();\r
-\r
-  std::string aName;\r
-  GetNameJPEG(myName,myFrameIndex,aName);\r
-\r
-  PreWrite();\r
-\r
-  vtkImageData *anImageData = vtkImageData::New(); \r
-  anImageData->DeepCopy(myFilter->GetOutput());\r
-\r
-  myWriterMgr->StartImageWriter(anImageData,aName,myProgressiveMode,myQuality);\r
-  myNbWrittenFrames++;\r
-\r
-  myRenderWindow->AddObserver(vtkCommand::EndEvent,\r
-                              myCommand,\r
-                              myPriority);\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::PreWrite()\r
-{\r
-  vtkImageData *anImageData = myFilter->GetOutput();\r
-  //\r
-  if(!anImageData){\r
-    myErrorStatus = 20;\r
-    return;\r
-  }\r
-  anImageData->UpdateInformation();\r
-  int *anExtent = anImageData->GetWholeExtent();\r
-  anImageData->SetUpdateExtent(anExtent[0], anExtent[1],\r
-                              anExtent[2], anExtent[3],\r
-                              0,0);\r
-  anImageData->UpdateData();\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::AddSkippedFrames()\r
-{\r
-  myErrorStatus = 0;\r
-\r
-  if(myFrameIndexes.size() < 2)\r
-    return;\r
-\r
-  size_t anId = 0, anEnd = myFrameIndexes.size() - 1;\r
-  for(; anId < anEnd; anId++){\r
-    int aStartIndex = myFrameIndexes[anId];\r
-    if(aStartIndex < 0)\r
-      continue;\r
-\r
-    int aFinishIndex = abs(myFrameIndexes[anId + 1]);\r
-    if(aStartIndex + 1 == aFinishIndex)\r
-      continue;\r
-\r
-    std::string anInitialName;\r
-    std::ostringstream aStream;\r
-    GetNameJPEG(myName,aStartIndex,anInitialName);\r
-    for(int anIndex = aStartIndex + 1; anIndex < aFinishIndex; anIndex++){\r
-      myNbWrittenFrames++;\r
-      std::string anCurrentName;\r
-      GetNameJPEG(myName,anIndex,anCurrentName);\r
-      aStream<<"ln -s "<< anInitialName<<" "<<anCurrentName<<";";\r
-      if(anIndex + 1 < aFinishIndex)\r
-       aStream<<" \\";\r
-      aStream<<endl;\r
-    }\r
-    std::string aString(aStream.str());\r
-    system(aString.c_str());\r
-    if(MYDEBUG) cout<<"VVTK_Recorder::AddSkippedFrames - "<<aString<<endl;\r
-  }\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_Recorder\r
-::MakeFileAVI()\r
-{\r
-  myErrorStatus = 0;\r
-  std::ostringstream aStream;\r
-  aStream<<myNameAVIMaker<<\r
-    " -I p"<<\r
-    " -v 0"<<\r
-    //" -f "<<int(myNbFPS)<<" "<<\r
-    " -f "<<myNbFPS<<" "<<\r
-    " -n "<<myNbWrittenFrames<<" "<<\r
-    " -j "<<myName<<"_\%06d.jpeg "<<\r
-    "| yuv2lav"<<\r
-    " -o "<<myName;\r
-   \r
-  std::string aString(aStream.str());\r
-  myErrorStatus = system(aString.c_str());\r
-\r
-  if(MYDEBUG) cout<<"VVTK_Recorder::MakeFileAVI - "<<aString<<endl;\r
-\r
-  QFileInfo aFileInfo(myName.c_str());\r
-  QString aDirPath = aFileInfo.dirPath(TRUE);\r
-  QString aBaseName = aFileInfo.fileName();\r
-  QString aCommand = \r
-    QString("(cd ") + aDirPath + \r
-    "; ls " +\r
-    " | egrep '" + aBaseName + "_[0-9]*.jpeg'" +\r
-    " | xargs rm " +\r
-    ")";\r
-\r
-  if(MYDEBUG) cout<<"VVTK_Recorder::MakeFileAVI - "<<aCommand.latin1()<<endl;\r
-  system(aCommand.latin1());\r
-}\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   :
+//  Author :
+//  Module :
+//  $Header$
+
+#include "VVTK_Recorder.h"
+
+#include "VVTK_ImageWriter.h"
+#include "VVTK_ImageWriterMgr.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkObject.h>
+#include <vtkCallbackCommand.h>
+#include <vtkRenderWindow.h>
+#include <vtkTimerLog.h>
+#include <vtkWindowToImageFilter.h>
+#include <vtkJPEGWriter.h>
+#include <vtkImageData.h>
+
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+
+#include <unistd.h>
+#include <qapplication.h>
+#include <qfileinfo.h>
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+namespace
+{
+  //----------------------------------------------------------------------------
+  inline
+  void
+  GetNameJPEG(const std::string& thePreffix,  
+             const int theIndex,
+             std::string& theName)
+  {
+    using namespace std;
+    ostringstream aStream;
+    aStream<<thePreffix<<"_"<<setw(6)<<setfill('0')<<theIndex<<".jpeg";
+    theName = aStream.str();
+  }
+}
+
+//----------------------------------------------------------------------------
+vtkCxxRevisionMacro(VVTK_Recorder,"$Revision$");
+vtkStandardNewMacro(VVTK_Recorder);
+
+
+//----------------------------------------------------------------------------
+VVTK_Recorder
+::VVTK_Recorder():
+  myRenderWindow(NULL),
+  myState(VVTK_Recorder_Stop),
+  myNbFPS(5.5),
+  myQuality(100),
+  myProgressiveMode(true),
+  myUseSkippedFrames(true),
+  myErrorStatus(0),
+  myCommand(vtkCallbackCommand::New()),
+  myPriority(0.0),
+  myTimeStart(0.0),
+  myFrameIndex(0),
+  myPaused(0),
+  myFilter(vtkWindowToImageFilter::New()),
+  myWriterMgr(new VVTK_ImageWriterMgr),
+  myNbWrittenFrames(0),
+  myNameAVIMaker("jpeg2yuv")
+{
+  myCommand->SetClientData(this); 
+  myCommand->SetCallback(VVTK_Recorder::ProcessEvents);
+}
+
+
+//----------------------------------------------------------------------------
+VVTK_Recorder
+::~VVTK_Recorder()
+{
+  myCommand->Delete();
+  myFilter->Delete();
+  delete myWriterMgr;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::CheckExistAVIMaker()
+{
+  myErrorStatus = 0;
+  using namespace std;
+  ostringstream aStream;
+  aStream<<"which "<<myNameAVIMaker<<" >& /dev/null";
+  std::string anAVIMakeCheck = aStream.str();
+  int iErr = system(anAVIMakeCheck.c_str());
+  if(iErr != 0)
+    myErrorStatus = 127;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetName(const char* theName)
+{
+  myName = theName;
+}
+
+const char* 
+VVTK_Recorder::Name() const
+{
+  return myName.c_str();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetNbFPS(const double theNbFPS)
+{
+  myNbFPS = theNbFPS;
+}
+
+double
+VVTK_Recorder
+::NbFPS() const
+{
+  return myNbFPS;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetQuality(int theQuality)
+{
+  myQuality = theQuality;
+}
+
+int
+VVTK_Recorder
+::GetQuality() const
+{
+  return myQuality;
+}
+
+
+//----------------------------------------------------------------------------
+void 
+VVTK_Recorder
+::SetRenderWindow(vtkRenderWindow* theRenderWindow)
+{
+  myRenderWindow = theRenderWindow;
+}
+
+vtkRenderWindow* 
+VVTK_Recorder
+::RenderWindow()
+{
+  return myRenderWindow;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetProgressiveMode(bool theProgressiveMode)
+{
+  myProgressiveMode = theProgressiveMode;
+}
+
+bool
+VVTK_Recorder
+::GetProgressiveMode() const
+{
+  return myProgressiveMode;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetUseSkippedFrames(bool theUseSkippedFrames)
+{
+  myUseSkippedFrames = theUseSkippedFrames;
+}
+
+bool
+VVTK_Recorder
+::UseSkippedFrames() const
+{
+  return myUseSkippedFrames;
+}
+
+
+//----------------------------------------------------------------------------
+int
+VVTK_Recorder
+::ErrorStatus() const
+{
+  return myErrorStatus;
+}
+
+int
+VVTK_Recorder
+::State() const
+{
+  return myState;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
+               unsigned long theEvent,
+               void* theClientData, 
+               void* vtkNotUsed(theCallData))
+{
+  if(vtkObject* anObj = reinterpret_cast<vtkObject*>(theClientData)){ 
+    if(VVTK_Recorder* aSelf = dynamic_cast<VVTK_Recorder*>(anObj)){
+      if(theEvent==vtkCommand::EndEvent){
+       if(aSelf->State() == VVTK_Recorder::VVTK_Recorder_Record){
+         aSelf->DoRecord();
+       }
+      }
+    }
+  }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::Record()
+{
+  if(myState == VVTK_Recorder_Stop){
+    if(myRenderWindow){
+      myState = VVTK_Recorder_Record;
+      myFilter->SetInput(myRenderWindow);
+      myFrameIndex = -1;
+      myNbWrittenFrames = 0;
+      myRenderWindow->RemoveObserver(myCommand);
+      myRenderWindow->AddObserver(vtkCommand::EndEvent,
+                                  myCommand,
+                                  myPriority);
+      myRenderWindow->Render();
+    }
+  }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::Stop()
+{
+  QApplication::setOverrideCursor( Qt::waitCursor );
+
+  if(myState == VVTK_Recorder_Record){ 
+    if(!myPaused)
+      DoRecord();
+
+    myWriterMgr->Stop();
+
+    if(myUseSkippedFrames)
+      AddSkippedFrames();
+
+    myFrameIndexes.clear();
+
+    MakeFileAVI();
+  }
+  myState = VVTK_Recorder_Stop;
+  myPaused = 0;
+
+  QApplication::restoreOverrideCursor();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::Pause()
+{
+  myPaused = myPaused ? 0 : 1;
+  if(myPaused && !myFrameIndexes.empty()){
+    myFrameIndexes.back() *= -1;
+    if(MYDEBUG) cout<<"VVTK_Recorder::Pause - myFrameIndexes.back() = "<<myFrameIndexes.back()<<endl;
+  }
+}
+
+
+//----------------------------------------------------------------------------
+inline 
+int
+GetFrameIndex(double theStartTime,
+             double theFPS)
+{
+  double aTimeNow = vtkTimerLog::GetCurrentTime();
+  double aDelta = aTimeNow - theStartTime;
+  return int(aDelta*theFPS);
+}
+
+void
+VVTK_Recorder
+::DoRecord()
+{
+  if(myPaused)
+    return;
+
+  if(myFrameIndex < 0){
+    myFrameIndex = 0;
+    myTimeStart = vtkTimerLog::GetCurrentTime();
+  }else{
+    int aFrameIndex = GetFrameIndex(myTimeStart,myNbFPS);
+    if(aFrameIndex <= myFrameIndex)
+      return;
+
+    // If there was a "pause" we correct the myTimeStart
+    int aLastFrameIndex = myFrameIndexes.back();
+    if(aLastFrameIndex < 0){
+      myFrameIndexes.back() = abs(myFrameIndexes.back());
+      double aPauseTime = fabs(aFrameIndex - myFrameIndex - 1) / myNbFPS;
+      if(MYDEBUG) 
+       cout<<"VVTK_Recorder::DoRecord - aFrameIndex = "<<aFrameIndex<<
+         "; aPauseTime = "<<aPauseTime<<endl;
+      myTimeStart += aPauseTime;
+    }
+
+    aFrameIndex = GetFrameIndex(myTimeStart,myNbFPS);
+    if(aFrameIndex <= myFrameIndex)
+      return;
+
+    myFrameIndex = aFrameIndex;
+  }
+
+  myFrameIndexes.push_back(myFrameIndex);
+  if(MYDEBUG) cout<<"VVTK_Recorder::DoRecord - myFrameIndex = "<<myFrameIndex<<endl;
+
+  myRenderWindow->RemoveObserver(myCommand);
+  myFilter->Modified();
+
+  std::string aName;
+  GetNameJPEG(myName,myFrameIndex,aName);
+
+  PreWrite();
+
+  vtkImageData *anImageData = vtkImageData::New(); 
+  anImageData->DeepCopy(myFilter->GetOutput());
+
+  myWriterMgr->StartImageWriter(anImageData,aName,myProgressiveMode,myQuality);
+  myNbWrittenFrames++;
+
+  myRenderWindow->AddObserver(vtkCommand::EndEvent,
+                              myCommand,
+                              myPriority);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::PreWrite()
+{
+  vtkImageData *anImageData = myFilter->GetOutput();
+  //
+  if(!anImageData){
+    myErrorStatus = 20;
+    return;
+  }
+  anImageData->UpdateInformation();
+  int *anExtent = anImageData->GetWholeExtent();
+  anImageData->SetUpdateExtent(anExtent[0], anExtent[1],
+                              anExtent[2], anExtent[3],
+                              0,0);
+  anImageData->UpdateData();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::AddSkippedFrames()
+{
+  myErrorStatus = 0;
+
+  if(myFrameIndexes.size() < 2)
+    return;
+
+  size_t anId = 0, anEnd = myFrameIndexes.size() - 1;
+  for(; anId < anEnd; anId++){
+    int aStartIndex = myFrameIndexes[anId];
+    if(aStartIndex < 0)
+      continue;
+
+    int aFinishIndex = abs(myFrameIndexes[anId + 1]);
+    if(aStartIndex + 1 == aFinishIndex)
+      continue;
+
+    std::string anInitialName;
+    std::ostringstream aStream;
+    GetNameJPEG(myName,aStartIndex,anInitialName);
+    for(int anIndex = aStartIndex + 1; anIndex < aFinishIndex; anIndex++){
+      myNbWrittenFrames++;
+      std::string anCurrentName;
+      GetNameJPEG(myName,anIndex,anCurrentName);
+      aStream<<"ln -s "<< anInitialName<<" "<<anCurrentName<<";";
+      if(anIndex + 1 < aFinishIndex)
+       aStream<<" \\";
+      aStream<<endl;
+    }
+    std::string aString(aStream.str());
+    system(aString.c_str());
+    if(MYDEBUG) cout<<"VVTK_Recorder::AddSkippedFrames - "<<aString<<endl;
+  }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::MakeFileAVI()
+{
+  myErrorStatus = 0;
+  std::ostringstream aStream;
+  aStream<<myNameAVIMaker<<
+    " -I p"<<
+    " -v 0"<<
+    //" -f "<<int(myNbFPS)<<" "<<
+    " -f "<<myNbFPS<<" "<<
+    " -n "<<myNbWrittenFrames<<" "<<
+    " -j "<<myName<<"_\%06d.jpeg "<<
+    "| yuv2lav"<<
+    " -o "<<myName;
+   
+  std::string aString(aStream.str());
+  myErrorStatus = system(aString.c_str());
+
+  if(MYDEBUG) cout<<"VVTK_Recorder::MakeFileAVI - "<<aString<<endl;
+
+  QFileInfo aFileInfo(myName.c_str());
+  QString aDirPath = aFileInfo.dirPath(TRUE);
+  QString aBaseName = aFileInfo.fileName();
+  QString aCommand = 
+    QString("(cd ") + aDirPath + 
+    "; ls " +
+    " | egrep '" + aBaseName + "_[0-9]*.jpeg'" +
+    " | xargs rm " +
+    ")";
+
+  aCommand = 
+    QString("rm ") + aDirPath + "/" + aBaseName + "*.jpeg";
+
+  if(MYDEBUG) cout<<"VVTK_Recorder::MakeFileAVI - "<<aCommand.latin1()<<endl;
+  system(aCommand.latin1());
+}
index 82d39c275ae28d17cb2fa7c64d6fc982bbf15aec..cb398551d4cae91908e5b36a59b23a0cd0e899a0 100755 (executable)
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   : \r
-//  Author : \r
-//  Module : SALOME\r
-//  $Header$\r
-\r
-#ifndef _VVTK_Recorder_Header_File_\r
-#define _VVTK_Recorder_Header_File_\r
-\r
-#include <list>\r
-#include <string>\r
-#include <vector>\r
-\r
-#include <vtkObject.h>\r
-\r
-class vtkRenderWindow;\r
-class vtkCallbackCommand;\r
-class vtkWindowToImageFilter;\r
-class VVTK_ImageWriterMgr;\r
-//\r
-class VVTK_Recorder : public vtkObject \r
-{\r
- protected:\r
-  enum State {\r
-    VVTK_Recorder_Unknown=0,\r
-    VVTK_Recorder_Record,\r
-    VVTK_Recorder_Stop\r
-  };\r
-  \r
- public:\r
-  static VVTK_Recorder *New();\r
-  vtkTypeRevisionMacro(VVTK_Recorder,vtkObject);\r
-\r
-  void\r
-  SetRenderWindow(vtkRenderWindow* theRenderWindow);\r
-\r
-  vtkRenderWindow* \r
-  RenderWindow();\r
-\r
-  void \r
-  SetName(const char *theName);\r
-\r
-  const char* \r
-  Name() const;\r
-\r
-  void\r
-  SetNbFPS(const double theNbFPS);\r
-\r
-  double\r
-  NbFPS() const;\r
-\r
-  void\r
-  SetQuality(int theQuality);\r
-\r
-  int\r
-  GetQuality() const;\r
-\r
-  void\r
-  SetProgressiveMode(bool theProgressiveMode);\r
-\r
-  bool\r
-  GetProgressiveMode() const;\r
-\r
-  void\r
-  SetUseSkippedFrames(bool theUseSkippedFrames);\r
-\r
-  bool\r
-  UseSkippedFrames() const;\r
-\r
-  void\r
-  Record();\r
-\r
-  void\r
-  Pause();\r
-\r
-  void\r
-  Stop();\r
-\r
-  int\r
-  State() const;\r
-\r
-  int  \r
-  ErrorStatus() const;\r
-\r
-  void\r
-  CheckExistAVIMaker();\r
-\r
-protected :\r
-  VVTK_Recorder();\r
-\r
-  ~VVTK_Recorder();\r
-\r
-  void\r
-  DoRecord();\r
-\r
-  void\r
-  MakeFileAVI();\r
-\r
-  void\r
-  AddSkippedFrames();\r
-\r
-  void\r
-  PreWrite();\r
-\r
-  static\r
-  void\r
-  ProcessEvents(vtkObject* theObject, \r
-               unsigned long theEvent,\r
-               void* theClientData, \r
-               void* theCallData);\r
-\r
-protected :\r
-  int myState;\r
-  int myPaused;\r
-  int myErrorStatus;\r
-\r
-  float myPriority;\r
-  double myTimeStart;\r
-\r
-  int myFrameIndex;\r
-  int myNbWrittenFrames;\r
-\r
-  double myNbFPS;\r
-  int myQuality;\r
-  bool myProgressiveMode;\r
-\r
-  typedef std::vector<int> TFrameIndexes;\r
-  TFrameIndexes myFrameIndexes;\r
-  bool myUseSkippedFrames;\r
-\r
-  std::string myName;\r
-  std::string myNameAVIMaker;\r
-\r
-  vtkCallbackCommand *myCommand;\r
-  vtkRenderWindow *myRenderWindow;\r
-  vtkWindowToImageFilter *myFilter;\r
-  VVTK_ImageWriterMgr *myWriterMgr;\r
-\r
-\r
-private:\r
-  VVTK_Recorder(const VVTK_Recorder&);  //Not implemented\r
-  void operator=(const VVTK_Recorder&); //Not implemented\r
-};\r
-#endif\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#ifndef _VVTK_Recorder_Header_File_
+#define _VVTK_Recorder_Header_File_
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include <vtkObject.h>
+
+class vtkRenderWindow;
+class vtkCallbackCommand;
+class vtkWindowToImageFilter;
+class VVTK_ImageWriterMgr;
+//
+class VVTK_Recorder : public vtkObject 
+{
+ protected:
+  enum State {
+    VVTK_Recorder_Unknown=0,
+    VVTK_Recorder_Record,
+    VVTK_Recorder_Stop
+  };
+  
+ public:
+  static VVTK_Recorder *New();
+  vtkTypeRevisionMacro(VVTK_Recorder,vtkObject);
+
+  void
+  SetRenderWindow(vtkRenderWindow* theRenderWindow);
+
+  vtkRenderWindow* 
+  RenderWindow();
+
+  void 
+  SetName(const char *theName);
+
+  const char* 
+  Name() const;
+
+  void
+  SetNbFPS(const double theNbFPS);
+
+  double
+  NbFPS() const;
+
+  void
+  SetQuality(int theQuality);
+
+  int
+  GetQuality() const;
+
+  void
+  SetProgressiveMode(bool theProgressiveMode);
+
+  bool
+  GetProgressiveMode() const;
+
+  void
+  SetUseSkippedFrames(bool theUseSkippedFrames);
+
+  bool
+  UseSkippedFrames() const;
+
+  void
+  Record();
+
+  void
+  Pause();
+
+  void
+  Stop();
+
+  int
+  State() const;
+
+  int  
+  ErrorStatus() const;
+
+  void
+  CheckExistAVIMaker();
+
+protected :
+  VVTK_Recorder();
+
+  ~VVTK_Recorder();
+
+  void
+  DoRecord();
+
+  void
+  MakeFileAVI();
+
+  void
+  AddSkippedFrames();
+
+  void
+  PreWrite();
+
+  static
+  void
+  ProcessEvents(vtkObject* theObject, 
+               unsigned long theEvent,
+               void* theClientData, 
+               void* theCallData);
+
+protected :
+  int myState;
+  int myPaused;
+  int myErrorStatus;
+
+  float myPriority;
+  double myTimeStart;
+
+  int myFrameIndex;
+  int myNbWrittenFrames;
+
+  double myNbFPS;
+  int myQuality;
+  bool myProgressiveMode;
+
+  typedef std::vector<int> TFrameIndexes;
+  TFrameIndexes myFrameIndexes;
+  bool myUseSkippedFrames;
+
+  std::string myName;
+  std::string myNameAVIMaker;
+
+  vtkCallbackCommand *myCommand;
+  vtkRenderWindow *myRenderWindow;
+  vtkWindowToImageFilter *myFilter;
+  VVTK_ImageWriterMgr *myWriterMgr;
+
+
+private:
+  VVTK_Recorder(const VVTK_Recorder&);  //Not implemented
+  void operator=(const VVTK_Recorder&); //Not implemented
+};
+#endif
index 30eab72378282cf2ca33dea35e5939983e49f687..4f4d4e39d5ab4f7fdd1ea335cc4f44c6a41f2408 100644 (file)
@@ -182,9 +182,9 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c
 
   QLabel* ZOriginLabel = new QLabel( tr( "ORIGIN_Z" ), myOriginGroup );
   myZOriginSpinBox = new QtxDblSpinBox( -1000.0, 1000.0, 0.1, myOriginGroup );
-  myZOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  //myZOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   myZOriginSpinBox->setMinimumWidth( 100 );
-  myZOriginSpinBox->setValue( 0.0 );
+  myZOriginSpinBox->setValue( 1.0 );
 
   OriginGroupLayout->addWidget(   XOriginLabel,   0, 0 );
   OriginGroupLayout->addWidget( myXOriginSpinBox, 0, 1 );