Commit 88a72383 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

Merge branch 'release/2.25.0' into master

parents 29ad435d 9bc9f18c
Pipeline #193659 failed with stage
in 0 seconds
# Change Log:
# 2.25.0 04-Dec-2020
- add setTitle in dtkVisualizationCanvas API
# 2.24.0 31-Jul-2020
- fix: use previous setting of each slice when show is called
- vector glyph auto scale can be turned off
......
......@@ -23,7 +23,7 @@ project(dtkVisualization)
## ###################################################################
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 24)
set(${PROJECT_NAME}_VERSION_MINOR 25)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -14,6 +14,7 @@
#include "dtkVisualizationCanvas.h"
#include <dtkThemes>
#include <dtkWidgets>
#include <QtCore>
......@@ -30,6 +31,8 @@
#include <vtkScalarBarRepresentation.h>
#include <vtkScalarBarWidget.h>
#include <vtkSmartPointer.h>
#include <vtkTextActor.h>
#include <vtkTextProperty.h>
#include <vtkTransform.h>
#include <vtkProperty2D.h>
......@@ -69,11 +72,15 @@ public:
public:
dtkWidgetsHUD *hud = nullptr;
public:
QString title;
vtkSmartPointer<vtkTextActor> textActor;
public:
std::size_t nb_scalar_bars = 0;
};
// ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
dtkVisualizationCanvasPrivate::dtkVisualizationCanvasPrivate(QWidget *parent) : QVTKOpenGLNativeWidget(parent)
{
......@@ -114,8 +121,13 @@ QSize dtkVisualizationCanvasPrivate::sizeHint(void) const
void dtkVisualizationCanvasPrivate::resizeEvent(QResizeEvent *event)
{
if (!this->title.isEmpty()) {
QFontMetrics metrics(qApp->font());
int pos_x = this->size().width() / 2 - metrics.width(title)/2;
this->textActor->SetPosition ( pos_x, 10 );
this->textActor->Modified();
}
QVTKOpenGLNativeWidget::resizeEvent(event);
this->hud->resize(event->size());
}
......@@ -159,6 +171,47 @@ QWidget *dtkVisualizationCanvas::widget(void)
return d;
}
void dtkVisualizationCanvas::setTitle(const QString & title)
{
if (title.isEmpty()) {
if (d->textActor)
d->renderer->RemoveActor ( d->textActor );
return;
}
QColor fg = dtkThemesEngine::instance()->color("@fg");
QColor bg = dtkThemesEngine::instance()->color("@bg");
// Setup the text and add it to the renderer
if (!d->textActor)
d->textActor = vtkSmartPointer<vtkTextActor>::New();
d->textActor->SetInput ( qPrintable(title) );
d->textActor->GetTextProperty()->SetFontSize ( 12 );
d->textActor->GetTextProperty()->SetColor ( 1.0-fg.red(), 1.0-fg.green(), 1.0-fg.blue());
d->textActor->GetTextProperty()->SetBackgroundColor ( 1.0-bg.red(), 1.0-bg.green(), 1.0-bg.blue());
d->textActor->GetTextProperty()->SetBackgroundOpacity ( 0.6 );
d->renderer->AddActor2D ( d->textActor );
if (!d->title.isEmpty()) { // not the first call, skip connect
d->title = title;
return;
}
d->title = title;
connect(dtkThemesEngine::instance(), &dtkThemesEngine::changed, [=] ()
{
QColor fg = dtkThemesEngine::instance()->color("@fg");
QColor bg = dtkThemesEngine::instance()->color("@bg");
d->textActor->GetTextProperty()->SetColor ( 1.0-fg.red(), 1.0-fg.green(), 1.0-fg.blue());
d->textActor->GetTextProperty()->SetBackgroundColor ( 1.0-bg.red(), 1.0-bg.green(), 1.0-bg.blue());
this->draw();
});
}
void dtkVisualizationCanvas::link(dtkVisualizationCanvas *other)
{
d->renderer->SetActiveCamera(other->d->renderer->GetActiveCamera());
......
......@@ -57,6 +57,9 @@ public:
void addScalarBar(vtkScalarBarWidget *, bool scalar_bar_is_seek_bar = false);
void removeScalarBar(vtkScalarBarWidget *);
public:
virtual void setTitle(const QString &);
private:
class dtkVisualizationCanvasPrivate *d;
};
......
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