ַי alexey,<br>
<br>
I wanted to subclass vtkActor too, and while looking into the<br>
archives I came across several usefull posts.. I believe the <br>
following methodology to be more-or-less correct, althought not very simple.<br>
<br>
First of all, when you create a vtkActor the object-factory<br>
methodology actually creates a vtkOpenGLActor or a vtkMesaActor, <br>
depending on your configuration.<br>
<br>
In order to create a custom Actor that contains some <br>
application-specific properties and methods, <br>
create first a subclass of vtkOpenGLActor (vtkMyOpenGLActor)<br>
<br>
Then subclass from vtkObjectFactory, <br>
override the method virtual vtkObject *CreateObject(const char* vtkclassname);<br>
so that when VTK request a vtkOpenGLActor object you can return a vtkMyOpenGLActor.<br>
(I also tried the RegisterFactory(...) method without sucess so far, but you can experiment on that)<br>
<br>
You have to register the new factory before you actually start creating actors<br>
by calling<br>
<br>
vtkMyOpenGLActorFactory *myOpenGLActorFactory = vtkMyOpenGLActorFactory ::New();<br>
vtkObjectFactory::RegisterFacto
<div id="mb_1">ry(myOpenGLActorFactory ); <br>
myOpenGLActorFactory->Delete();<br>
(I placed this code in the constructor of my application)<br>
<br>
the definition of these two classes follows...<br>
<br>
hope this helps,<br>
yianis nikolaou<br>
<br>
<br>
class vtkMyOpenGLActor : public vtkOpenGLActor<br>
{<br>
private:<br>
vtkMyOpenGLActor() { SetActorID(-1); SetPicked(false); }<br>
~vtkMyOpenGLActor() { }<br>
protected:<br>
vtkMyOpenGLActor (const vtkMyOpenGLActor&) { }<br>
operator=(const vtkMyOpenGLActor&) { }<br>
<br>
public:<br>
vtkTypeMacro(vtkMyOpenGLActor, vtkOpenGLActor);<br>
static vtkMyOpenGLActor *New();<br>
<br>
//custom members<br>
protected:<br>
int ActorID;<br>
bool picked;<br>
public:<br>
void SetActorID(int i) { ActorID=i; }<br>
int GetActorID() { return ActorID; }<br>
<br>
void SetPicked(bool enable) { picked=enable; }<br>
bool IsPicked() {return picked; }<br>
};<br>
<br>
<br>
class vtkMyOpenGLActorFactory : public vtkObjectFactory<br>
{<br>
private:<br>
vtkMyOpenGLActorFactory() { }<br>
~vtkMyOpenGLActorFactory() { }<br>
protected:<br>
vtkMyOpenGLActorFactory (const vtkMyOpenGLActor&) { }<br>
operator=(const vtkMyOpenGLActorFactory&) { }<br>
<br>
virtual vtkObject *CreateObject(const char* vtkclassname);<br>
public:<br>
vtkTypeMacro(vtkMyOpenGLActorFactory, vtkObjectFactory);<br>
<br>
static vtkMyOpenGLActorFactory *New();<br>
virtual const char* GetVTKSourceVersion();<br>
virtual const char* GetDescription();<br>
};</div>
<br><br><div><span class="gmail_quote">On 4/21/05, <b class="gmail_sendername">PETROV Alexey</b> <<a href="mailto:alexey.petrov@opencascade.com">alexey.petrov@opencascade.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Dear vtkusers,<br><br>I have problem with extending of vtkActor class under Win32.<br>I have defined a descendant of vtkActor class, something like -<br><br>class MyActor: public vtkActor<br>{<br> ...<br>}<br><br>But I can not render my actor.
<br>Is there any limitation?<br><br>Please help<br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br>