-// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <sstream>
#include <iomanip>
#include <iostream>
+#include <math.h>
#ifndef WIN32
#include <unistd.h>
#include <QFileInfo>
#include <QDir>
-//#include "utilities.h"
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
+#include "utilities.h"
namespace
//----------------------------------------------------------------------------
inline
void
- GetNameJPEG(const std::string& thePreffix,
+ GetNameJPEG(const std::string& thePreffix,
const int theIndex,
std::string& theName)
{
myFilter(vtkWindowToImageFilter::New()),
myWriterMgr(new SVTK_ImageWriterMgr)
{
- myCommand->SetClientData(this);
+ myCommand->SetClientData(this);
myCommand->SetCallback(SVTK_Recorder::ProcessEvents);
}
myName = theName;
}
-const char*
+const char*
SVTK_Recorder::Name() const
{
return myName.c_str();
//----------------------------------------------------------------------------
-void
+void
SVTK_Recorder
::SetRenderWindow(vtkRenderWindow* theRenderWindow)
{
myRenderWindow = theRenderWindow;
}
-vtkRenderWindow*
+vtkRenderWindow*
SVTK_Recorder
::RenderWindow()
{
//----------------------------------------------------------------------------
void
SVTK_Recorder
-::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
unsigned long theEvent,
- void* theClientData,
+ void* theClientData,
void* vtkNotUsed(theCallData))
{
- if(vtkObject* anObj = reinterpret_cast<vtkObject*>(theClientData)){
+ if(vtkObject* anObj = reinterpret_cast<vtkObject*>(theClientData)){
if(SVTK_Recorder* aSelf = dynamic_cast<SVTK_Recorder*>(anObj)){
if(theEvent==vtkCommand::EndEvent){
if(aSelf->State() == SVTK_Recorder::SVTK_Recorder_Record){
{
QApplication::setOverrideCursor( Qt::WaitCursor );
- if(myState == SVTK_Recorder_Record){
+ if(myState == SVTK_Recorder_Record){
if(!myPaused)
DoRecord();
myPaused = myPaused ? 0 : 1;
if(myPaused && !myFrameIndexes.empty()){
myFrameIndexes.back() *= -1;
- if(MYDEBUG) cout<<"SVTK_Recorder::Pause - myFrameIndexes.back() = "<<myFrameIndexes.back()<<endl;
+
+ if(SALOME::VerbosityActivated())
+ cout << "SVTK_Recorder::Pause - myFrameIndexes.back() = " << myFrameIndexes.back() << endl;
}
}
//----------------------------------------------------------------------------
-inline
+inline
int
GetFrameIndex(double theStartTime,
double theFPS)
if(aLastFrameIndex < 0){
myFrameIndexes.back() = abs(myFrameIndexes.back());
double aPauseTime = fabs((double)(aFrameIndex - myFrameIndex - 1)) / myNbFPS;
- if(MYDEBUG)
- cout<<"SVTK_Recorder::DoRecord - aFrameIndex = "<<aFrameIndex<<
- "; aPauseTime = "<<aPauseTime<<endl;
+
+ if(SALOME::VerbosityActivated())
+ cout << "SVTK_Recorder::DoRecord - aFrameIndex = " << aFrameIndex <<
+ "; aPauseTime = " << aPauseTime << endl;
+
myTimeStart += aPauseTime;
}
}
myFrameIndexes.push_back(myFrameIndex);
- if(MYDEBUG) cout<<"SVTK_Recorder::DoRecord - myFrameIndex = "<<myFrameIndex<<endl;
+ if(SALOME::VerbosityActivated())
+ cout << "SVTK_Recorder::DoRecord - myFrameIndex = " << myFrameIndex << endl;
myRenderWindow->RemoveObserver(myCommand);
myFilter->Modified();
PreWrite();
- vtkImageData *anImageData = vtkImageData::New();
+ vtkImageData *anImageData = vtkImageData::New();
anImageData->DeepCopy(myFilter->GetOutput());
myWriterMgr->StartImageWriter(myFilter,anImageData,aName,myProgressiveMode,myQuality);
}
std::string aString(aStream.str());
system(aString.c_str());
- if(MYDEBUG) cout<<"SVTK_Recorder::AddSkippedFrames - "<<aString<<endl;
+ if(SALOME::VerbosityActivated())
+ cout << "SVTK_Recorder::AddSkippedFrames - " << aString << endl;
}
}
" -j \""<<myName<<"_%06d.jpeg\" "<<
"| yuv2lav"<<" -o \""<<myName<<"\"";
#ifdef WIN32
- aStream<<" -f aA";
+ aStream<<" -f aA";
#endif
std::string aString(aStream.str());
myErrorStatus = system(aString.c_str());
- if(MYDEBUG) cout<<"SVTK_Recorder::MakeFileAVI - "<<aString<<endl;
+ if(SALOME::VerbosityActivated())
+ cout << "SVTK_Recorder::MakeFileAVI - " << aString << endl;
QFileInfo aFileInfo(myName.c_str());
QString aDirPath = aFileInfo.absoluteDir().path();
QString aBaseName = aFileInfo.fileName();
QString aCommand;
#ifndef WIN32
- aCommand = QString("(cd ") + aDirPath +
+ aCommand = QString("(cd ") + aDirPath +
"; ls " +
" | egrep '" + aBaseName + "_[0-9]*.jpeg'" +
" | xargs rm " +
#else
QString tmpFile = QString("_") + aBaseName + "_tempfile";
QString diskName = aDirPath.split("/")[0];
- aCommand = diskName + " && (cd " + aDirPath.replace("/","\\\\") +
- " && ((dir /b | findstr " + aBaseName + "_[0-9]*.jpeg > " + tmpFile +
+ aCommand = diskName + " && (cd " + aDirPath.replace("/","\\\\") +
+ " && ((dir /b | findstr " + aBaseName + "_[0-9]*.jpeg > " + tmpFile +
") & (for /f %i in (" + tmpFile + ") do (del \"%i\")) & (del " + tmpFile + "))) > NUL";
#endif
- if(MYDEBUG) cout<<"SVTK_Recorder::MakeFileAVI - "<<(const char*)aCommand.toUtf8()<<endl;
+ if(SALOME::VerbosityActivated())
+ cout << "SVTK_Recorder::MakeFileAVI - " << (const char*)aCommand.toUtf8() << endl;
+
system((const char*)aCommand.toUtf8());
}