Commit 014d16e8 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

Merge branch 'release/2.14.2'

parents 868e9c49 99c9eb84
# Change Log:
# 2.14.2 28-Nov-2019
- add field method in dtkVisualizationDecoratorWithClut
- fix restoring settings of decorators
- fix Slice decorator
- display frame info in dtkVisualizationWidgetsVideoControls;
# 2.14.1 17-Oct-2019
- Non lazy instanciation scheme for specific situations in ScalarGlyph decorator
......
......@@ -24,7 +24,7 @@ project(dtkVisualization)
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 14)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION_PATCH 2)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -57,7 +57,6 @@ void dtkVisualizationDecorator::hide(void)
void dtkVisualizationDecorator::setObjectName(const QString & name)
{
QObject::setObjectName(name);
this->restoreSettings();
}
//
......
......@@ -180,6 +180,7 @@ void dtkVisualizationDecoratorDelaunay2D::setData(const QVariant& data)
}
d->data->SetPoints(d->points);
this->restoreSettings();
d->delaunay->SetInputData(d->data);
d->delaunay->Modified();
......
......@@ -44,7 +44,7 @@ public:
vtkSmartPointer<vtkActor> actor;
vtkSmartPointer<vtkDataSetMapper> mapper;
vtkSmartPointer<vtkTransform> transform;
public:
QCheckBox *show_actor_cb = nullptr;
......@@ -119,6 +119,7 @@ void dtkVisualizationDecoratorScalarColorMap::setData(const QVariant& data)
d->mapper->SetInputData(d_func()->dataset);
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if (this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
......
......@@ -270,6 +270,7 @@ void dtkVisualizationDecoratorScalarGlyphs::setData(const QVariant& data)
emit this->currentGlyphsSourceChanged(d->default_glyph_shape);
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if (this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
......
......@@ -202,6 +202,7 @@ void dtkVisualizationDecoratorScalarIsolines::setData(const QVariant& data)
d->mapper->Modified();
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if(this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
......
......@@ -276,6 +276,7 @@ void dtkVisualizationDecoratorSlices::setData(const QVariant& data)
d->c2p_filter->SetInputData(dataset);
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if (this->canvas()) {
d->volume_slice_x->SetInteractor(d_func()->view->renderer()->GetRenderWindow()->GetInteractor());
......@@ -306,6 +307,7 @@ void dtkVisualizationDecoratorSlices::setCanvas(dtkVisualizationCanvas *canvas)
d->setupSlices();
}
d_func()->enableScalarBar();
}
......@@ -341,24 +343,51 @@ void dtkVisualizationDecoratorSlices::restoreSettings(void)
d->show_actor_cb->blockSignals(false);
}
void dtkVisualizationDecoratorSlices::touch(void)
{
dtkVisualizationDecoratorWithClut::touch();
vtkSmartPointer<vtkImageData> data = vtkImageData::SafeDownCast(d->c2p_filter->GetOutput());
d->c2p_filter->Update();
data->GetPointData()->SetActiveScalars(qPrintable(d_func()->current_field_name));
d->volume_slice_x->SetInputData(data);
d->volume_slice_y->SetInputData(data);
d->volume_slice_z->SetInputData(data);
d->volume_slice_x->SetSlicePosition(d->enable_slicing_x->value());
d->volume_slice_y->SetSlicePosition(d->enable_slicing_y->value());
d->volume_slice_z->SetSlicePosition(d->enable_slicing_z->value());
}
bool dtkVisualizationDecoratorSlices::setCurrentFieldName(const QString& field_name)
{
if (!dtkVisualizationDecoratorWithClut::setCurrentFieldName(field_name))
if (!dtkVisualizationDecoratorWithClut::setCurrentFieldName(field_name)) {
return false;
}
using Support = dtkVisualizationDecoratorWithClut::Support;
int support = d_func()->supports[field_name];
if(support == Support::Cell) {
d->c2p_filter->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, qPrintable(field_name));
d->volume_slice_x->SetInputConnection(d->c2p_filter->GetOutputPort());
d->volume_slice_y->SetInputConnection(d->c2p_filter->GetOutputPort());
d->volume_slice_z->SetInputConnection(d->c2p_filter->GetOutputPort());
vtkSmartPointer<vtkImageData> data = vtkImageData::SafeDownCast(d->c2p_filter->GetOutput());
d->c2p_filter->Update();
data->GetPointData()->SetActiveScalars(qPrintable(field_name));
d->volume_slice_x->SetInputData(data);
d->volume_slice_y->SetInputData(data);
d->volume_slice_z->SetInputData(data);
} else {
d->volume_slice_x->SetInputData(d_func()->dataset);
d->volume_slice_y->SetInputData(d_func()->dataset);
d->volume_slice_z->SetInputData(d_func()->dataset);
}
d->volume_slice_x->SetSlicePosition(d->enable_slicing_x->value());
d->volume_slice_y->SetSlicePosition(d->enable_slicing_y->value());
d->volume_slice_z->SetSlicePosition(d->enable_slicing_z->value());
return true;
}
......
......@@ -30,7 +30,7 @@ public:
void setData(const QVariant&) override;
void setCanvas(dtkVisualizationCanvas *) override;
void unsetCanvas(void) override;
void touch(void) override;
public:
bool setCurrentFieldName(const QString&) override;
......
......@@ -218,6 +218,7 @@ void dtkVisualizationDecoratorVectorStreamlines::setData(const QVariant& data)
d->source->Modified();
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if (this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
......
......@@ -158,6 +158,7 @@ void dtkVisualizationDecoratorVolume::setData(const QVariant& data)
d->outline_contour->SetInputData(dataset);
d_func()->sortEligibleFields();
this->setCurrentFieldName(d_func()->current_field_name);
if (this->canvas()) {
this->canvas()->renderer()->AddActor(d->actor);
......
......@@ -206,15 +206,17 @@ void dtkVisualizationDecoratorWithClutPrivate::sortEligibleFields(void)
if (this->eligible_field_names.size() > 0) {
this->eligible_field_names.sort();
if (this->fields_box) {
if (this->fields_box->count() > 0) {
this->fields_box->clear();
this->fields_box->addItems(this->eligible_field_names);
}
if (this->default_field_name.isEmpty()) {
this->fields_box->setCurrentText(this->eligible_field_names.first());
} else {
this->fields_box->setCurrentText(this->default_field_name);
this->fields_box->blockSignals(true);
this->fields_box->addItems(this->eligible_field_names);
this->fields_box->blockSignals(false);
this->current_field_name = this->default_field_name;
if (this->default_field_name.isEmpty() || !this->eligible_field_names.contains(this->default_field_name)) {
this->current_field_name = this->eligible_field_names.first();
}
this->fields_box->setCurrentText(this->current_field_name);
}
}
......@@ -228,10 +230,8 @@ dtkVisualizationDecoratorWithClut::dtkVisualizationDecoratorWithClut(void): dtkV
// Inspectors connections
connect(d->fields_box, &QComboBox::currentTextChanged, [=] (const QString& field_name) {
d->fields_box->blockSignals(true);
this->setCurrentFieldName(field_name);
this->saveSettings("field_name", field_name);
d->fields_box->blockSignals(false);
this->touch();
});
......@@ -296,7 +296,7 @@ void dtkVisualizationDecoratorWithClut::restoreSettings(void)
bool fixed_range = settings.value(name+"_fixed_range", false).toBool();
settings.endGroup();
if (range_min != -1.0 && range_max != -1.0) {
if (fixed_range && !d->default_field_name.isEmpty() && range_min != -1.0 && range_max != -1.0) {
this->setCurrentRange(range_min, range_max);
}
......@@ -309,7 +309,14 @@ void dtkVisualizationDecoratorWithClut::restoreSettings(void)
d->show_scalar_bar->blockSignals(true);
d->show_scalar_bar->setChecked(d->default_show_scalar_bar);
d->show_scalar_bar->blockSignals(false);
d->scalar_bar->SetVisibility(d->default_show_scalar_bar);
if (d->default_visibility) {
d->scalar_bar->SetVisibility(d->default_show_scalar_bar);
}
}
QString dtkVisualizationDecoratorWithClut::fieldName(void) const
{
return d->current_field_name;
}
void dtkVisualizationDecoratorWithClut::touch(void)
......@@ -384,7 +391,9 @@ bool dtkVisualizationDecoratorWithClut::setCurrentFieldName(const QString& field
d->current_field_name = field_name;
d->fields_box->blockSignals(true);
d->fields_box->setCurrentText(d->current_field_name);
d->fields_box->blockSignals(false);
d->scalar_bar->UnconstrainedFontSizeOn();
d->scalar_bar->SetTitle(qPrintable(this->objectName()+"/"+d->current_field_name));
......
......@@ -53,6 +53,9 @@ public:
public:
virtual void setVisibility(bool visible) override;
public:
QString fieldName(void) const;
protected:
virtual void restoreSettings(void) override;
virtual void setCurrentRange(double, double);
......
......@@ -82,6 +82,7 @@ public:
QProgressBar *progress_bar_buffered = nullptr;
QLabel *label_duration = nullptr;
bool is_fullscreen = false;
bool display_frame_info = false;
};
// ///////////////////////////////////////////////////////////////////
......@@ -203,6 +204,7 @@ dtkVisualizationWidgetsVideoControls::State dtkVisualizationWidgetsVideoControls
void dtkVisualizationWidgetsVideoControls::setFrameNumber(qlonglong count)
{
d->display_frame_info = true;
d->progress_bar->setRange(1, count);
d->progress_bar->setValue(1);
d->progress_bar->reset();
......@@ -214,6 +216,7 @@ void dtkVisualizationWidgetsVideoControls::setFrameNumber(qlonglong count)
void dtkVisualizationWidgetsVideoControls::setDuration(qlonglong duration)
{
d->display_frame_info = false;
d->progress_bar->setRange(0, duration);
d->progress_bar_buffered->setRange(0, duration);
d->updateDurationInfo(0);
......@@ -260,6 +263,8 @@ void dtkVisualizationWidgetsVideoControls::mouseMoveEvent(QMouseEvent *event)
{
int size = d->progress_bar->width();
double percent = (event->pos().x() - d->progress_bar->x())/ (double)size ;
QString message;
int frame_index = percent * d->progress_bar->maximum() / 1000.0 ;
QTime currentTime((frame_index / 3600) % 60, (frame_index / 60) % 60,
......@@ -269,7 +274,14 @@ void dtkVisualizationWidgetsVideoControls::mouseMoveEvent(QMouseEvent *event)
if (frame_index > 3600)
format = "hh:mm:ss";
d->progress_bar->setToolTip(currentTime.toString(format));
message = currentTime.toString(format);
if (d->display_frame_info) {
int frame_index = std::round(percent * d->progress_bar->maximum() + (1-percent) * d->progress_bar->minimum());
message += "\n" + QString::number(frame_index) + "/" + QString::number(d->progress_bar->maximum());
}
d->progress_bar->setToolTip(message);
event->ignore();
QFrame::mouseMoveEvent(event);
......@@ -279,7 +291,7 @@ void dtkVisualizationWidgetsVideoControls::mousePressEvent(QMouseEvent *event)
{
int size = d->progress_bar->width();
double percent = (event->pos().x() - d->progress_bar->x())/ (double)size ;
int frame_index = percent * d->progress_bar->maximum();
int frame_index = std::round(percent * d->progress_bar->maximum() + (1.0-percent) * d->progress_bar->minimum());
emit seekTo(frame_index);
event->ignore();
......
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