Commit 1b2c53d9 authored by CABEL Tristan's avatar CABEL Tristan

Merge branch 'release/2.15.1'

parents 2cbc321c b617b238
# Change Log:
# 2.15.1 05-Dec-2019
- bugfix plot2d dont clear old_fields on field_x->clear
- fix axes touch method
- bugfix plot2d block signals on field_y before clearing it
# 2.15.0 05-Dec-2019
- add setTransform in decorator API
- rewrite 2d plot class
......
......@@ -24,7 +24,7 @@ project(dtkVisualization)
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 15)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -175,10 +175,10 @@ void dtkVisualizationDecoratorAxes::setCanvas(dtkVisualizationCanvas *canvas)
d->cube_axes_actor->SetCamera(d->view->renderer()->GetActiveCamera());
if(!d->dataset){
d->cube_axes_actor->SetBounds(d->view->renderer()->ComputeVisiblePropBounds());
if(!d->dataset) {
d->cube_axes_actor->SetBounds(d->view->renderer()->ComputeVisiblePropBounds());
} else {
d->cube_axes_actor->SetBounds(d->dataset->GetBounds());
d->cube_axes_actor->SetBounds(d->dataset->GetBounds());
}
}
......@@ -186,6 +186,9 @@ void dtkVisualizationDecoratorAxes::unsetCanvas(void)
{
if (d->view) {
d->view->renderer()->RemoveActor(d->cube_axes_actor);
d->marker->SetEnabled(false);
d->marker->SetInteractor(nullptr);
}
d->view = nullptr;
......@@ -212,6 +215,7 @@ void dtkVisualizationDecoratorAxes::touch(void)
dtkWarn() << Q_FUNC_INFO << "No canvas was set, call setCanvas to call draw on a canvas.";
return;
}
d->cube_axes_actor->SetBounds(d->dataset->GetBounds());
this->draw();
}
......
......@@ -92,6 +92,7 @@ public:
vtkSmartPointer<vtkChartXY> chart = nullptr;
vtkSmartPointer<vtkFieldData> old_fields = nullptr;
QMap< QString, FieldParameters> old_fields_param;
QString old_field_x = "";
QString add_plot_suffix = "";
public:
......@@ -254,12 +255,16 @@ dtkVisualizationPlot2D::dtkVisualizationPlot2D(QWidget *parent) : dtkVisualizati
connect(d->field_x, &QComboBox::currentTextChanged, [=] ()
{
for(vtkIdType i=0; i < d->old_fields->GetNumberOfArrays() ; ++i) {
d->fields_table->RemoveColumnByName(d->old_fields->GetArray(i)->GetName());
d->old_fields->RemoveArray(i);
}
d->old_fields_param.clear();
if(d->field_x->currentText().isEmpty())
return;
if(d->old_field_x != d->field_x->currentText()) {
for(vtkIdType i=0; i < d->old_fields->GetNumberOfArrays() ; ++i) {
d->fields_table->RemoveColumnByName(d->old_fields->GetArray(i)->GetName());
d->old_fields->RemoveArray(i);
}
d->old_fields_param.clear();
}
this->render();
});
connect(d->field_y, &QListWidget::itemChanged, [=] ()
......@@ -270,6 +275,10 @@ dtkVisualizationPlot2D::dtkVisualizationPlot2D(QWidget *parent) : dtkVisualizati
connect(d->field_y, &QListWidget::currentRowChanged, [=] (int currentRow)
{
// it will happen if we call clear on the qlistwidget when a row is selected
if(!d->field_y->item(currentRow))
return;
QString row_text = d->field_y->item(currentRow)->text();
if(d->save_field->isChecked()) {
......@@ -286,11 +295,14 @@ dtkVisualizationPlot2D::dtkVisualizationPlot2D(QWidget *parent) : dtkVisualizati
}
if(!d->old_fields->HasArray(new_name.toStdString().c_str())) {
d->old_fields_param.insert(new_name, d->fields_parameters[row_text]);
d->old_field_x = d->field_x->currentText();
dtkVisualizationPlot2DPrivate::FieldParameters new_param = d->fields_parameters[row_text];
d->old_fields_param.insert(new_name, new_param);
vtkSmartPointer<vtkDoubleArray> new_field = vtkSmartPointer<vtkDoubleArray>::New();
new_field->DeepCopy(arr);
new_field->SetName(new_name.toStdString().c_str()) ;
d->old_fields->AddArray(new_field); // todo also save properties
d->old_fields->AddArray(new_field);
this->addFieldY(new_field,
false,
d->fields_parameters[row_text].chart_type,
......@@ -576,7 +588,11 @@ void dtkVisualizationPlot2D::addFieldY(vtkSmartPointer<vtkAbstractArray> field,
void dtkVisualizationPlot2D::clearFields(void)
{
d->field_x->clear();
d->field_y->blockSignals(true);
d->field_y->clear();
d->field_y->blockSignals(false);
d->fields_parameters.clear();
for(vtkIdType i=0; i < d->fields_table->GetNumberOfColumns(); ++i) {
d->fields_table->RemoveColumn(i);
......@@ -605,17 +621,6 @@ void dtkVisualizationPlot2D::removeField(const QString& field)
d->field_x->removeItem(idx);
}
// QList<int> rows_to_delete;
// for(int i=0; i < d->field_y->count(); ++i) {
// if(d->field_y->item(i)->text() == field)
// rows_to_delete << i;
// }
// for(int row : rows_to_delete) {
// auto *item = d->field_y->takeItem(row);
// delete item;
// }
qDeleteAll(d->field_y->findItems(field, Qt::MatchFixedString));
d->fields_parameters.remove(field);
......
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