<P>
my pc on which i develop the code is isolated from all networks.<BR>
so i had to retype the code on my email client and send it.<BR>
so a mistake occured which Mr.West pointed out.<BR>
so iam resending the code after correcting the error.<BR>
please help me, if there are any typos please excuse.<BR>
<BR>
<BR>
<BR>
//all the header files go here<BR>
class grids : public vtkInteractorObserer<BR>
{<BR>
BOOL m_mousedown;<BR>
vtkRenderer *m_renderer;<BR>
vtkLineSource *m_linesource;<BR>
vtkPolyDataMapper *m_datamapper;<BR>
vtkActor *m_actor;<BR>
float m_lastpickposition[4];<BR>
<BR>
public:<BR>
grids(vtkRenderer *renderer)<BR>
{<BR>
m_renderer=renderer;<BR>
m_linesource=vtkLineSource::New();<BR>
m_datamapper=vtkDataMapper::New();<BR>
m_actor=vtkActor::New();<BR>
m_picker=vtkCellPicker::New();<BR>
m_linesource.Point1(0.0,0.0,0.0);<BR>
m_linesource.Point1(0.0,10.0,0.0);<BR>
m_datamapper->SetInput(linesource->GetOutput());<BR>
m_actor->SetMapper(m_datamapper);<BR>
m_picker->AddPickList(m_actor);<BR>
m_render->Render();<BR>
this->EventCallbackCommand->SetCallback(grids::ProcessEvents);<BR>
<BR>
}<BR>
<BR>
~grids()<BR>
{<BR>
//this->ReferenceCount--; //if i uncomment this line the program terminates normally, without<BR>
//this line the program displays a window saying, trying to delete<BR>
//object with non zero reference count <BR>
<BR>
m_actor->Delete();<BR>
m_datamapper->Delete();<BR>
m_linesource->Delete();<BR>
m_picker->Delete();<BR>
<BR>
}<BR>
<BR>
static void ProcessEvents(vtkObject object,unsigned long event, void *clientdata,void *calldata)<BR>
{<BR>
<BR>
grid *self=reinterpret_cast<grid *>(clientdata);<BR>
<BR>
switch(event)<BR>
{<BR>
case vtkCommand::LeftButtonPressEvent:<BR>
self->OnLeftButtonDown();<BR>
break;<BR>
<BR>
case vtkCommand::LeftButtonReleaseEvent:<BR>
self->OnLeftButtonUp();<BR>
break;<BR>
<BR>
case vtkCommand::MouseMoveEvent:<BR>
self->OnMouseMove();<BR>
break;<BR>
}<BR>
}<BR>
<BR>
void SetEnabled(int enabling)<BR>
{<BR>
if (!this->Interactor) return;<BR>
<BR>
if (enabling)<BR>
{<BR>
if (this->Enabled) return;<BR>
this->Enabled=1;<BR>
this->CurrentRenderer=m_renderer;<BR>
<BR>
vtkRenderWindowInteractor *i=this->Interactor;<BR>
i->AddObserver(vtkCommand::MouseMoveEvent,<BR>
this->EventCallbackCommand,this->priority);<BR>
i->AddObserver(vtkCommand::LeftButtonPressEvent,<BR>
this->EventCallbackCommand,this->priority);<BR>
i->AddObserver(vtkCommand::LeftButtonReleaseEvent,<BR>
this->EventCallbackCommand,this->priority);<BR>
<BR>
this->InvokeEvent(vtkCommand::EnableEvent,NULL);<BR>
}<BR>
else<BR>
{<BR>
if (!this->Enabled) return;<BR>
this->Enabled=0;<BR>
this->CurrentRenderer=NULL;<BR>
this->Interactor->RemoveObserver(this->EventCallbackCommand);<BR>
this->InvokeEvent(vtkCommand::DisableEvent,NULL);<BR>
}<BR>
<BR>
this->Interactor->Render();<BR>
}<BR>
<BR>
<BR>
<BR>
<BR>
void OnLeftButtonDown()<BR>
{<BR>
int x=this->Interactor->GetEventPosition()[0];<BR>
int y=this->Interactor->GetEventPosition()[1];<BR>
<BR>
vtkAssemblyPath *path;<BR>
<BR>
this->m_picker->Pick(x,y,0.0,this->m_renderer);<BR>
path=this->m_picker->GetPath();<BR>
<BR>
if (path!=NULL)<BR>
<BR>
{<BR>
m_picker->GetPickPosition(m_lastpickposition);<BR>
m_mousedown=TRUE;<BR>
this->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);<BR>
}<BR>
<BR>
else <BR>
return;<BR>
<BR>
this->EventCallbackCommand->SetAbortFlag(1);<BR>
this->StartInteraction();<BR>
this->Interactor->Render();<BR>
}<BR>
<BR>
<BR>
void OnLeftButtonUp()<BR>
{<BR>
if (m_mousedown) <BR>
{<BR>
m_mousedown=FALSE;<BR>
this->EventCallbackCommand->SetAbortFlag(1);<BR>
this->EndInteraction();<BR>
this->InvlokeEvent(vtkCommand::EndInteractionEvent,NULL);<BR>
this->Interactor->Render<BR>
}<BR>
<BR>
<BR>
}<BR>
<BR>
<BR>
<BR>
<BR>
virtual void OnMouseMove()<BR>
{<BR>
if (!m_mousedown) return;<BR>
<BR>
int x=this->Interactor->GetEventPosition()[0];<BR>
int y=this->Interactor->GetEventPosition()[1];<BR>
<BR>
double focalpoint[4],pickpoint[4];<BR>
<BR>
double z;<BR>
<BR>
vtkCamera *camera =m_renderer->GetActiveCamera();<BR>
<BR>
if (!camera) return;<BR>
<BR>
this->ComputeWorldToDisplay(m_lastpickposition[0],<BR>
m_lastpickposition[1],m_lastpickposition[2],focalpoint);<BR>
<BR>
this->ComputeDisplayToWorld(double(x),double(y),z,pickpoint);<BR>
<BR>
float e1[3],e2[3];<BR>
<BR>
m_linesource->GetPoint1(e1);<BR>
m_linesource->GetPoint1(e2);<BR>
<BR>
e1[0]+=pickpoint[0];<BR>
e1[1]+=pickpoint[1];<BR>
e1[2]+=pickpoint[2];<BR>
<BR>
e2[0]+=pickpoint[0];<BR>
e2[1]+=pickpoint[1];<BR>
e2[2]+=pickpoint[2];<BR>
<BR>
m_linesource->SetPoint1(e1);<BR>
m_linesource->SetPoint2(e2);<BR>
m_linesource->Update();<BR>
<BR>
this->EventCallbackCommand->SetAbortFlag(1);<BR>
this->InvlokeEvent(vtkCommand::InteractionEvent,NULL);<BR>
this->Interactor->Render();<BR>
}<BR>
<BR>
<BR>
<BR>
};<BR>
<BR>
<BR>
<BR>
<BR>
void main()<BR>
{<BR>
vtkrenderer *rn=vtkRenderer::New();<BR>
vtkRenderWindow *win=vtkRenderWindow::New();<BR>
vtkRenderWindowObserver *intr=vtkRenderWindowObserver::New();<BR>
<BR>
win->AddRenderer(rn);<BR>
intr->SetRenderWindow(win);<BR>
<BR>
grids *cg;<BR>
<BR>
cg=new grids(rn);<BR>
intr->Initialize();<BR>
rn->Render();<BR>
intr->Start();<BR>
<BR>
delete cg;<BR>
<BR>
}<BR>
<BR>
</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0 HEIGHT=74 WIDTH=496></a>