Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
9a970652
Commit
9a970652
authored
Mar 27, 2019
by
Purves, Murray
Browse files
Adding screenshot output to vtkchartwidget
parent
5cc877f9
Pipeline
#44107
passed with stages
in 16 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
radixwidgets/vtkchartwidget.cc
View file @
9a970652
...
...
@@ -4,6 +4,9 @@ VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT
(
vtkInteractionStyle
)
VTK_MODULE_INIT
(
vtkRenderingFreeType
)
#include <vtkPNGWriter.h>
#include <vtkWindowToImageFilter.h>
#include "radixwidgets/vtkchartwidget.hh"
namespace
radix
...
...
@@ -33,4 +36,19 @@ vtkSmartPointer<vtkContextView> VTKChartWidget::contextView()
return
mContextView
;
}
void
VTKChartWidget
::
savePNG
(
QString
outputFile
)
{
// Save the current view as a PNG file
vtkSmartPointer
<
vtkWindowToImageFilter
>
filter
=
vtkSmartPointer
<
vtkWindowToImageFilter
>::
New
();
filter
->
SetInput
(
mContextView
->
GetRenderWindow
());
filter
->
ReadFrontBufferOff
();
filter
->
Update
();
vtkSmartPointer
<
vtkPNGWriter
>
writer
=
vtkSmartPointer
<
vtkPNGWriter
>::
New
();
writer
->
SetFileName
(
outputFile
.
toStdString
().
c_str
());
writer
->
SetInputConnection
(
filter
->
GetOutputPort
());
writer
->
Write
();
}
}
// namespace radix
radixwidgets/vtkchartwidget.hh
View file @
9a970652
...
...
@@ -10,6 +10,8 @@
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <QString>
#include "radixcore/visibility.hh"
namespace
radix
...
...
@@ -32,6 +34,10 @@ class RADIX_PUBLIC VTKChartWidget : public QVTKOpenGLWidget
// Default values
static
double
mDefaultBackground
[
3
];
public
slots
:
// Save the current chart image as a PNG
void
savePNG
(
QString
outputFile
);
signals:
};
// class VTKChartWidget
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment