Commit 07be6e4d authored by Ken Martin's avatar Ken Martin
Browse files

added new helper file from main

parent 05dc408a
/*=========================================================================
Program: ParaView
Module: vtkPVAnimationBatchHelper.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPVAnimationBatchHelper.h"
#include "vtkObjectFactory.h"
#include "vtkSMDomain.h"
#include "vtkSMIntVectorProperty.h"
#include "vtkSMStringListDomain.h"
vtkStandardNewMacro(vtkPVAnimationBatchHelper);
vtkCxxRevisionMacro(vtkPVAnimationBatchHelper, "1.1.2.1");
//---------------------------------------------------------------------------
void vtkPVAnimationBatchHelper::SetAnimationValueInBatch(
ofstream* file, vtkSMDomain *domain, vtkSMProperty *property,
vtkClientServerID sourceID, int idx, double value)
{
if (!file || !property || !sourceID.ID)
{
return;
}
if (!strcmp(domain->GetClassName(), "vtkSMDoubleRangeDomain"))
{
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << idx << " " << value
<< endl;
}
else if (!strcmp(domain->GetClassName(), "vtkSMExtentDomain"))
{
vtkSMIntVectorProperty *ivp =
vtkSMIntVectorProperty::SafeDownCast(property);
if (!ivp)
{
return;
}
int animValue = (int)(floor(value));
int compare;
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << idx << " "
<< animValue << endl;
switch (idx)
{
case 0:
case 2:
case 4:
compare = ivp->GetElement(idx+1);
if (animValue > compare)
{
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << idx+1 << " "
<< animValue << endl;
}
break;
case 1:
case 3:
case 5:
compare = ivp->GetElement(idx-1);
if (animValue < compare)
{
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << idx-1 << " "
<< animValue << endl;
}
break;
}
}
else if (!strcmp(domain->GetClassName(), "vtkSMIntRangeDomain"))
{
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << idx << " "
<< (int)(floor(value)) << endl;
}
else if (!strcmp(domain->GetClassName(), "vtkSMStringListDomain"))
{
vtkSMStringListDomain *sld = vtkSMStringListDomain::SafeDownCast(domain);
if (!sld)
{
return;
}
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << idx << " {"
<< sld->GetString((int)(floor(value))) << "}" << endl;
}
else if (!strcmp(domain->GetClassName(), "vtkSMStringListRangeDomain"))
{
char val[128];
sprintf(val, "%d", static_cast<int>(floor(value)));
*file << " [$pvTemp" << sourceID << " GetProperty "
<< property->GetXMLName() << "] SetElement " << 2*idx+1 << " " << val
<< endl;
}
*file << " $pvTemp" << sourceID << " UpdateVTKObjects" << endl;
}
//---------------------------------------------------------------------------
void vtkPVAnimationBatchHelper::PrintSelf(ostream &os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkPVAnimationBatchHelper.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVAnimationBatchHelper - helper class for doing animation in batch mode
// .SECTION Description
#ifndef __vtkPVAnimationBatchHelper_h
#define __vtkPVAnimationBatchHelper_h
#include "vtkObject.h"
#include "vtkClientServerID.h" // needed for vtkClientServerID
class vtkSMDomain;
class vtkSMProperty;
class VTK_EXPORT vtkPVAnimationBatchHelper : public vtkObject
{
public:
static vtkPVAnimationBatchHelper* New();
vtkTypeRevisionMacro(vtkPVAnimationBatchHelper, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
void SetAnimationValueInBatch(ofstream* file, vtkSMDomain *domain,
vtkSMProperty *property,
vtkClientServerID sourceID, int idx,
double value);
protected:
vtkPVAnimationBatchHelper() {}
~vtkPVAnimationBatchHelper() {}
private:
vtkPVAnimationBatchHelper(const vtkPVAnimationBatchHelper&); // Not implemented
void operator=(const vtkPVAnimationBatchHelper&); // Not implemented
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment