Commit f9ddf83b authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Merge branch 'feature/decorator_collection' of...

Merge branch 'feature/decorator_collection' of gitlab.inria.fr:dtk/dtk-visualization into feature/decorator_collection
parents bf97ac53 5f7efad2
......@@ -71,6 +71,7 @@ public:
QComboBox *glyphs_source_cb = nullptr;
public:
double size_multiplier = 1.;
QHash<QString, double> glyphs_sizes;
QHash<QString, QString> glyphs_sources;
};
......@@ -86,13 +87,21 @@ dtkVisualizationDecoratorScalarGlyphs::dtkVisualizationDecoratorScalarGlyphs(voi
d->source_arrow = vtkSmartPointer<vtkArrowSource>::New();
d->source_cube = vtkSmartPointer<vtkCubeSource>::New();
d->source_cylinder = vtkSmartPointer<vtkCylinderSource>::New();
d->source_polygon = vtkSmartPointer<vtkRegularPolygonSource>::New();
d->source_sphere = vtkSmartPointer<vtkSphereSource>::New();
d->source_sphere->SetThetaResolution(12.);
d->source_sphere->SetPhiResolution(12.);
d->source_sphere->SetRadius(1.);
d->source_polygon = vtkSmartPointer<vtkRegularPolygonSource>::New();
double default_size = 1.;
d->source_arrow->SetShaftRadius(default_size);
d->source_arrow->SetTipRadius(default_size);
d->source_cube->SetXLength(default_size);
d->source_cube->SetYLength(default_size);
d->source_cube->SetZLength(default_size);
d->source_cylinder->SetRadius(default_size);
d->source_polygon->SetRadius(default_size);
d->source_sphere->SetRadius(default_size);
d->cell_centers = vtkSmartPointer<vtkCellCenters>::New();
......@@ -195,6 +204,17 @@ void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
return;
}
//size_multiplier to be able to see glyph for big datasets
// from 1 to 10 % of max_dim
double bounds[6];
dataset->GetBounds(bounds);
double max_dim = bounds[1] - bounds[0];
max_dim = std::max(max_dim, bounds[3] - bounds[2]);
max_dim = std::max(max_dim, bounds[5] - bounds[4]);
d->size_multiplier = max_dim/100;
d_func()->clear();
d_func()->retrieveScalarPoints(dataset);
d_func()->retrieveScalarCells(dataset);
......@@ -212,10 +232,10 @@ void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
d->glyphs_sizes.clear();
d->glyphs_sources.clear();
for(auto field_name : d_func()->eligible_field_names) {
d->glyphs_sizes[field_name] = 0.5;
d->glyphs_sizes[field_name] = 1.;
d->glyphs_sources[field_name] = "Sphere";
}
emit this->currentGlyphsSizeChanged(0.5);
emit this->currentGlyphsSizeChanged(1.);
emit this->currentGlyphsSourceChanged("Sphere");
d_func()->sortEligibleFields();
......@@ -271,24 +291,25 @@ void dtkVisualizationDecoratorScalarGlyphs::setCurrentGlyphsSize(double size)
d->glyphs_sizes[current_field_name] = size;
double scaled_size = size*d->size_multiplier;
QString source = d->glyphs_sources[current_field_name];
if(source == "Arrow") {
d->source_arrow->SetShaftRadius(size);
d->source_arrow->SetTipRadius(size);
d->source_arrow->SetShaftRadius(scaled_size);
d->source_arrow->SetTipRadius(scaled_size);
d->source_arrow->Modified();
} else if (source == "Cube") {
d->source_cube->SetXLength(size);
d->source_cube->SetYLength(size);
d->source_cube->SetZLength(size);
d->source_cube->SetXLength(scaled_size);
d->source_cube->SetYLength(scaled_size);
d->source_cube->SetZLength(scaled_size);
d->source_cube->Modified();
} else if (source == "Cylinder") {
d->source_cylinder->SetRadius(size);
d->source_cylinder->SetRadius(scaled_size);
d->source_cylinder->Modified();
} else if (source == "Sphere") {
d->source_sphere->SetRadius(size);
d->source_sphere->SetRadius(scaled_size);
d->source_sphere->Modified();
} else if (source == "Polygon") {
d->source_polygon->SetRadius(size);
d->source_polygon->SetRadius(scaled_size);
d->source_polygon->Modified();
}
......@@ -305,15 +326,31 @@ void dtkVisualizationDecoratorScalarGlyphs::setCurrentGlyphsSource(const QString
return;
}
double scaled_size = d->glyphs_size_sb->value() * d->size_multiplier;
if(source == "Arrow") {
d->source_arrow->SetShaftRadius(scaled_size);
d->source_arrow->SetTipRadius(scaled_size);
d->source_arrow->Modified();
d->glyphs->SetSourceConnection(d->source_arrow->GetOutputPort());
} else if (source == "Cube") {
d->source_cube->SetXLength(scaled_size);
d->source_cube->SetYLength(scaled_size);
d->source_cube->SetZLength(scaled_size);
d->source_cube->Modified();
d->glyphs->SetSourceConnection(d->source_cube->GetOutputPort());
} else if (source == "Cylinder") {
d->source_cylinder->SetRadius(scaled_size);
d->source_cylinder->Modified();
d->glyphs->SetSourceConnection(d->source_cylinder->GetOutputPort());
} else if (source == "Sphere") {
d->source_sphere->SetRadius(scaled_size);
d->source_sphere->Modified();
d->glyphs->SetSourceConnection(d->source_sphere->GetOutputPort());
} else if (source == "Polygon") {
d->source_polygon->SetRadius(scaled_size);
d->source_polygon->Modified();
d->glyphs->SetSourceConnection(d->source_polygon->GetOutputPort());
}
......@@ -332,27 +369,28 @@ bool dtkVisualizationDecoratorScalarGlyphs::setCurrentFieldName(const QString& f
double glyphs_size = d->glyphs_sizes[field_name];
QString glyphs_source = d->glyphs_sources[field_name];
double scaled_size = glyphs_size * d->size_multiplier;
if(glyphs_source == "Arrow") {
d->source_arrow->SetShaftRadius(glyphs_size);
d->source_arrow->SetTipRadius(glyphs_size);
d->source_arrow->SetShaftRadius(scaled_size);
d->source_arrow->SetTipRadius(scaled_size);
d->glyphs->SetSourceConnection(d->source_arrow->GetOutputPort());
d->source_arrow->Modified();
} else if (glyphs_source == "Cube") {
d->source_cube->SetXLength(glyphs_size);
d->source_cube->SetYLength(glyphs_size);
d->source_cube->SetZLength(glyphs_size);
d->source_cube->SetXLength(scaled_size);
d->source_cube->SetYLength(scaled_size);
d->source_cube->SetZLength(scaled_size);
d->glyphs->SetSourceConnection(d->source_cube->GetOutputPort());
d->source_cube->Modified();
} else if (glyphs_source == "Cylinder") {
d->source_cylinder->SetRadius(glyphs_size);
d->source_cylinder->SetRadius(scaled_size);
d->glyphs->SetSourceConnection(d->source_cylinder->GetOutputPort());
d->source_cylinder->Modified();
} else if (glyphs_source == "Sphere") {
d->source_sphere->SetRadius(glyphs_size);
d->source_sphere->SetRadius(scaled_size);
d->glyphs->SetSourceConnection(d->source_sphere->GetOutputPort());
d->source_sphere->Modified();
} else if (glyphs_source == "Polygon") {
d->source_polygon->SetRadius(glyphs_size);
d->source_polygon->SetRadius(scaled_size);
d->glyphs->SetSourceConnection(d->source_polygon->GetOutputPort());
d->source_polygon->Modified();
}
......
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