ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkplotwidget.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "vtkplotwidget.h"
9 
10 #include <VtkUtils/vtkutils.h>
11 #include <vtkAxis.h>
12 #include <vtkChartXY.h>
13 #include <vtkChartXYZ.h>
14 #include <vtkContextScene.h>
15 #include <vtkContextView.h>
16 #include <vtkFloatArray.h>
17 #include <vtkPlot.h>
18 #include <vtkPlotLine3D.h>
19 #include <vtkPlotPoints3D.h>
20 #include <vtkPlotSurface.h>
21 #include <vtkRenderWindow.h>
22 #include <vtkRenderer.h>
23 #include <vtkTable.h>
24 #include <vtkVariant.h>
25 
26 namespace VtkUtils {
27 
28 class VtkPlotWidgetPrivate {
29 public:
30  ~VtkPlotWidgetPrivate();
31 
32  vtkContextView* contextView;
33 };
34 
35 VtkPlotWidgetPrivate::~VtkPlotWidgetPrivate() {
36  VtkUtils::vtkSafeDelete(contextView);
37 }
38 
39 VtkPlotWidget::VtkPlotWidget(QWidget* parent) : QVTKOpenGLNativeWidget(parent) {
40  setWindowTitle(tr("ChartXY"));
41  d_ptr = new VtkPlotWidgetPrivate;
42  init();
43 }
44 
45 VtkPlotWidget::~VtkPlotWidget() { delete d_ptr; }
46 
48  d_ptr->contextView = vtkContextView::New();
49  d_ptr->contextView->SetRenderWindow(this->GetRenderWindow());
50  d_ptr->contextView->GetRenderWindow()->SetMultiSamples(0);
51  d_ptr->contextView->GetRenderWindow()->Render();
52 }
53 
54 vtkContextView* VtkPlotWidget::contextView() const {
55  return d_ptr->contextView;
56 }
57 
58 } // namespace VtkUtils
vtkContextView * contextView() const
vtkRenderWindow * GetRenderWindow()
Definition: vtkplotwidget.h:44
VtkPlotWidget(QWidget *parent=nullptr)
void vtkSafeDelete(T *obj)
Definition: vtkutils.h:54