<div dir="ltr"><div><div><div>Hi Elvis,<br><br></div>The problem is this:  Declaring vtkNew<Foo> should be fine when Foo is forward declared.  But when the vtkNew<Foo> is deleted in your destructor, the vtkNew<Foo>'s destructor needs to call Foo->Delete().  So at that point it needs the full definition of Foo.  In your example, if you declare your class's destructor and implement it as {} (use the default) in an implementation file where Foo's header is included this should work.  One of my projects uses vtkNew this way.<br><br></div>HTH,<br></div>Shawn<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 10, 2016 at 8:39 AM, Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">2016-08-10 14:32 GMT+02:00 Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span><wbr>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>The overview at<br><br>    <a href="https://blog.kitware.com/a-tour-of-vtk-pointer-classes/" target="_blank">https://blog.kitware.com/a-tou<wbr>r-of-vtk-pointer-classes/</a><br><br></div>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").<br><br></div>But when I try e.g:<br><br>class vtkCompositeTransferFunctionIt<wbr>em;<br>...<br>vtkNew<vtkCompositeTransferFun<wbr>ctionItem> m_functionsItem;<br><br></div>I get<br><br>    error: invalid use of incomplete type ‘class vtkCompositeTransferFunctionIt<wbr>em’<br><br></div><div>Do I really need to include vtkCompositeTransferFunctionIt<wbr>em.h to declare a vtkNew<vtkCompositeTransferFun<wbr>ctionItem> ?<br></div></div></blockquote><div><br></div></span><div>To show more of the context where I'm trying this:<br><br>#pragma once<br><br>#include "VTKWidget.h"<br><br>#include <QObject><br>#include <Qt><br><br>#include <vtkNew.h><br><br>#include <vtkChartXY.h><br>#include <vtkContextView.h><br>#include <<wbr>vtkCompositeControlPointsItem.<wbr>h><br>#include <<wbr>vtkCompositeTransferFunctionIt<wbr>em.h><br><br>class QWidget;<br><br>class vtkColorTransferFunction;<br>// Apparently I can't just forward declare these.<br>//class vtkChartXY;<br>//class vtkCompositeTransferFunctionIt<wbr>em;<br>//class vtkCompositeControlPointsItem;<br>//class vtkContextView;<br>class vtkPiecewiseFunction;<br><br>class CompositeTransferFunctionEdito<wbr>r : public VTKWidget<br>{<br>    Q_OBJECT<br><br>public:<br>    enum Mode {<br>        EditColor,<br>        EditOpacity<br>    };<br>    Q_ENUM(Mode)<br><br>public:<br>    CompositeTransferFunctionEdito<wbr>r(vtkColorTransferFunction *colorFunction,<br>                              <wbr>      vtkPiecewiseFunction *opacityFunction,<br>                              <wbr>      Mode mode = EditColor,<br>                              <wbr>      QWidget *parent = 0,<br>                              <wbr>      Qt::WindowFlags flags = Qt::WindowFlags());<br><br>    void setColorFunction(<wbr>vtkColorTransferFunction *colorFunction);<br>    void setOpacityFunction(<wbr>vtkPiecewiseFunction *opacityFunction);<br><br>signals:<br>    void functionsModified();<br><br>private:<br>    void editColorPoint();<br><br>private:<br>    vtkNew<<wbr>vtkCompositeTransferFunctionIt<wbr>em> m_functionsItem;<br>    vtkNew<<wbr>vtkCompositeControlPointsItem> m_pointsItem;<br>    vtkNew<vtkChartXY> m_chart;<br>    vtkNew<vtkContextView> m_contextView;<br>};<br><br></div><div>I had hoped I would only have to forward declare the types used in the instantiations of vtkNew here, not include the full headers.<br><br></div><div>Elvis<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,<br></div><div>Elvis<br></div></div>
</blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>