[vtkusers] A mistake
Andrew Maclean
andrew.amaclean at gmail.com
Mon Aug 13 20:17:12 EDT 2007
Your problem is that MyFunction should be a class derived from vtkCommand.
You should do somethinfg like this:
class vtkStartCommand: public vtkCommand
{
public:
static vtkStartCommand *New() { return new vtkStartCommand; }
virtual void Execute(vtkObject * caller, unsigned long, void * /* callData
*/)
{ std::cout << "Starting execution of " << caller->GetClassName() <<
std::endl; }
};
vtkSmartPointer<vtkStartCommand> sObserver =
vtkSmartPointer<vtkStartCommand>::New();
Then somewhere in your code:
...
sphereWidget->AddObserver(vtkCommand::StartEvent,sObserver);
...
I hope this helps,
Andrew
On 8/13/07, JohnMark <zhaojunxp at hotmail.com> wrote:
> Hi,
> I am writing a program by vtkSphereWidget ( using C++ ) ,and I want to
> connect my render window with the mouse event , so I use the AddObserver()
> function , at the same time , I write a new function that could be invoked
> , its name is MyFunction() . As the usage of AddObserver() , my code is :
> sphereWidget->AddObserver( InteractionEvent, MyFunction );
> but there is a error : 'unsigned long __thiscall
> vtkObject::AddObserver(unsigned long,class vtkCommand *,float)' : cannot
> convert parameter 2 from 'void' to 'class vtkCommand *' .
> So why is it ? and how can I use the AddObserver() ? Could you give me an
> example ? thank you !
>
> ------------------------------
> 中国十大热门旅游景点 了解更多信息!<http://search.msn.com/results.aspx?q=%E4%B8%AD%E5%9B%BD%E5%8D%81%E5%A4%A7%E9%A3%8E%E6%99%AF&mkt=zh-CN&form=QBRE>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney 2006 NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070814/a28f1f77/attachment.htm>
More information about the vtkusers
mailing list