[vtkusers] return vtkSmartPointers from a function and pass via signal/slot
Dean Inglis
inglis.dl at gmail.com
Wed Aug 14 09:43:29 EDT 2013
Hi Miro,
> What would be the preferred way to pass objects stored as
vtkSmartPointer<T> object?
Here is one way to do it:
class myclass{
myclass() { this->var = vtkSmartPointer<vtkClass>::New(); };
vtkSmartPointer<vtkClass> GetvtkClass(){ return this->var; };
// THIS IS ALSO VALID:
// vtkClass* GetvtkClass(){ return this->var; };
vtkSmartPointer<vtkClass> var;
};
> I want to pass the object via signal/slot mechanism. What would be the
best way?
look at vtk documentation for class vtkEventQtSlotConnect
Dean
On Wed, Aug 14, 2013 at 3:57 AM, Miro Drahos <miroslav.drahos at ucsf.edu>wrote:
> Hi all,
> I am having really hard times passing on reference to the objects that
> are stored as vtkSmartPointer<T> as private data within a class. E.g.:
> class MyClass
> {
> public:
> ...
> private:
> vtkSmartPointer<vtkPolyData> surface;
> };
>
> What is the best way to pass 'surface' via signal/slot mechanism of Qt?
> I thought I'd create a public method
> vtkPolyData * MyClass::getSurface() { return surface.GetPointer(); }
> The problem is that GetPointer() returns *const* T* which the compiler
> complains about when I later want to use it. As a matter of fact, all
> vtkSmartPointer's public methods return const something.
>
> What would be the preferred way to pass objects stored as
> vtkSmartPointer<T> object?
> 1.) T* MyClass::getT() const { return object.GetPointer(); }
> 2.) vtkSmartPointer<T> MyClass::getT() { return object; }
> 3.) something else?
>
> I want to pass the object via signal/slot mechanism. What would be the
> best way?
> A.) signal doneSurfaceProcessing(vtkPolyData &);
> B.) signal doneSurfaceProcessing(vtkPolyData *);
> C.) signal doneSurfaceProcessing(vtkSmartPointer<vtkPolyData>);
>
> Thank you!!
> Miro
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130814/16d22ae1/attachment.htm>
More information about the vtkusers
mailing list