[vtkusers] Forward declaration of Foo enough for vtkNew<Foo> declaration?
Elvis Stansvik
elvis.stansvik at orexplore.com
Wed Aug 10 08:39:25 EDT 2016
2016-08-10 14:32 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> Hi,
>
> The overview at
>
> https://blog.kitware.com/a-tour-of-vtk-pointer-classes/
>
> seems to suggest that forward declaration of a class Foo should be enough
> to be able to declare a vtkNew<Foo> (e.g. see how vtkTable is used in the
> code example under "Use of Classes").
>
> But when I try e.g:
>
> class vtkCompositeTransferFunctionItem;
> ...
> vtkNew<vtkCompositeTransferFunctionItem> m_functionsItem;
>
> I get
>
> error: invalid use of incomplete type ‘class
> vtkCompositeTransferFunctionItem’
>
> Do I really need to include vtkCompositeTransferFunctionItem.h to declare
> a vtkNew<vtkCompositeTransferFunctionItem> ?
>
To show more of the context where I'm trying this:
#pragma once
#include "VTKWidget.h"
#include <QObject>
#include <Qt>
#include <vtkNew.h>
#include <vtkChartXY.h>
#include <vtkContextView.h>
#include <vtkCompositeControlPointsItem.h>
#include <vtkCompositeTransferFunctionItem.h>
class QWidget;
class vtkColorTransferFunction;
// Apparently I can't just forward declare these.
//class vtkChartXY;
//class vtkCompositeTransferFunctionItem;
//class vtkCompositeControlPointsItem;
//class vtkContextView;
class vtkPiecewiseFunction;
class CompositeTransferFunctionEditor : public VTKWidget
{
Q_OBJECT
public:
enum Mode {
EditColor,
EditOpacity
};
Q_ENUM(Mode)
public:
CompositeTransferFunctionEditor(vtkColorTransferFunction *colorFunction,
vtkPiecewiseFunction *opacityFunction,
Mode mode = EditColor,
QWidget *parent = 0,
Qt::WindowFlags flags =
Qt::WindowFlags());
void setColorFunction(vtkColorTransferFunction *colorFunction);
void setOpacityFunction(vtkPiecewiseFunction *opacityFunction);
signals:
void functionsModified();
private:
void editColorPoint();
private:
vtkNew<vtkCompositeTransferFunctionItem> m_functionsItem;
vtkNew<vtkCompositeControlPointsItem> m_pointsItem;
vtkNew<vtkChartXY> m_chart;
vtkNew<vtkContextView> m_contextView;
};
I had hoped I would only have to forward declare the types used in the
instantiations of vtkNew here, not include the full headers.
Elvis
> Thanks,
> Elvis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160810/b3114bf5/attachment.html>
More information about the vtkusers
mailing list