Commit c2d12213 authored by CABEL Tristan's avatar CABEL Tristan

cast to dataset from other vtk types

parent a4c668be
......@@ -141,6 +141,19 @@ dtkVisualizationDecoratorAxes::~dtkVisualizationDecoratorAxes(void)
void dtkVisualizationDecoratorAxes::setData(const QVariant& data)
{
d->dataset = data.value<vtkDataSet *>();
if (!d->dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!d->dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -210,6 +210,18 @@ bool dtkVisualizationDecoratorClutEditor::isDecorating(void)
void dtkVisualizationDecoratorClutEditor::setData(const QVariant& data)
{
d->dataset = data.value<vtkDataSet *>();
if (!d->dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!d->dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -252,6 +252,18 @@ bool dtkVisualizationDecoratorClutEditorSimple::isDecorating(void)
void dtkVisualizationDecoratorClutEditorSimple::setData(const QVariant& data)
{
d->dataset = data.value<vtkDataSet *>();
if (!d->dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!d->dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -174,6 +174,17 @@ void dtkVisualizationDecoratorInfo::setVisibility(bool visible)
void dtkVisualizationDecoratorInfo::setData(const QVariant& data)
{
d->dataset = data.value<vtkDataSet *>();
if (!d->dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
d->dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (d->dataset) {
for (int row = 0; row < d->layout->rowCount(); ++row) {
......
......@@ -216,6 +216,19 @@ void dtkVisualizationDecoratorIsocontours::touchRange(void)
void dtkVisualizationDecoratorIsocontours::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -222,6 +222,19 @@ void dtkVisualizationDecoratorScalarGlyphs::restoreSettings(void)
void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -303,6 +303,20 @@ bool dtkVisualizationDecoratorSlices::isDecorating(void)
void dtkVisualizationDecoratorSlices::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -82,15 +82,15 @@ void dtkVisualizationDecoratorSurfaceColor::setData(const QVariant& data)
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
dataset = data.value<vtkUnstructuredGrid *>();
}
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if (!dataset) {
dataset = data.value<vtkStructuredGrid *>();
}
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if (!dataset) {
dataset = data.value<vtkPolyData *>();
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
......
......@@ -314,6 +314,19 @@ void dtkVisualizationDecoratorVectorCurvedGlyphs::restoreSettings(void)
void dtkVisualizationDecoratorVectorCurvedGlyphs::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -190,6 +190,19 @@ void dtkVisualizationDecoratorVectorGlyphs::restoreSettings(void)
void dtkVisualizationDecoratorVectorGlyphs::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -505,6 +505,19 @@ void dtkVisualizationDecoratorVectorStreamTracer::restoreSettings(void)
void dtkVisualizationDecoratorVectorStreamTracer::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -281,6 +281,19 @@ bool dtkVisualizationDecoratorVectorStreamlines::isCurrentFieldUniform(void)
void dtkVisualizationDecoratorVectorStreamlines::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
......@@ -136,6 +136,19 @@ bool dtkVisualizationDecoratorVolume::isDecorating(void)
void dtkVisualizationDecoratorVolume::setData(const QVariant& data)
{
vtkDataSet *dataset = data.value<vtkDataSet *>();
if (!dataset) {
//try to cast from other types of structures
if(dynamic_cast<vtkStructuredGrid *>(data.value<vtkStructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkStructuredGrid *>());
if(dynamic_cast<vtkUnstructuredGrid *>(data.value<vtkUnstructuredGrid *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkUnstructuredGrid *>());
if(dynamic_cast<vtkPolyData *>(data.value<vtkPolyData *>()))
dataset = vtkSmartPointer<vtkDataSet>(data.value<vtkPolyData *>());
}
if (!dataset) {
dtkWarn() << Q_FUNC_INFO << "vtkDataSet is expected. Input data is not stored.";
return;
......
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