[vtkusers] How to connect vtk mouse interaction class with QT UI

Clinton Stimpson clinton at elemtech.com
Tue Sep 27 10:38:09 EDT 2011


On Tuesday, September 27, 2011 06:46:51 am Xiaopeng Yang wrote:
> Sorry to raise this issue again. But please please help me.

I would suggest you study a C++ book more and practice on simple code.

> 
> Thank you so so so much!
> 
> -----Original Message-----
> From: Xiaopeng Yang [mailto:yxp233 at postech.ac.kr]
> Sent: Saturday, September 24, 2011 9:17 AM
> To: 'Alex Malyushytskyy'; 'David Doria'; 'vtk'
> Subject: RE: [vtkusers] How to connect vtk mouse interaction class with QT
> UI
> 
> Alex and David,
> 
> Thank you for your reply. Sorry to make you confused about my question. The
> first error is that "'ui' : is not a member of 'MouseInteractorStylePP'".
> That's why I am asking how to connect the mouse interaction class with QT
> ui.

Looking at the original code, can't you just call
 this->Interactor->GetRenderWindow()->Render()
instead of
 this->ui->qvtkWidget->GetRenderWindow()->Render()
You can see just a few lines above, how it gets access to the vtkRenderWindow.

> 
> The second problem is that if I would like to call addPoint() within the
> mouse interaction class, how to fulfill this?

Maybe you should move the addPoint() function to be a member of 
MouseInteractorStylePP instead of SimpleView.

Clint

> 
> Thank you very much.
> 
> Best,
> Xiaopeng
> 
> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
> Of Alex Malyushytskyy
> Sent: Saturday, September 24, 2011 7:39 AM
> To: vtk
> Subject: Re: [vtkusers] How to connect vtk mouse interaction class with QT
> UI
> 
> As far as I understand before getting renderer you have to add ( at least
> one ).
> 
> you may check with
> this->ui->qvtkWidget->GetRenderWindow()->GetRenders(); and check
> number of them in collection if you want,
> 
> If you need just one renderer you might create one and add
> (AddRenderer ) one in constructor.
> 
> Your code in green is pure black box for me.
> I failed to understand what you were trying to get there.
> As far as I can see ClientData is not a member of this class and not
> defined anywhere so result of compilation is predictable.
> 
> Alex
> 
> On Fri, Sep 23, 2011 at 5:16 AM, Xiaopeng Yang <yxp233 at postech.ac.kr> wrote:
> > Dear Users,
> > 
> > 
> > 
> > I would like to render my qvtkWidget when I right click the mouse. But
> > the following code has error in the red line. Could you point out where
> > I made
> 
> a
> 
> > mistake?
> > 
> > 
> > 
> > And also I would like to execute addpoint() when I right click the mouse.
> 
> So
> 
> > I tried the code in green line. But it also had error. Do you how to
> 
> execute
> 
> > addpoint by the mouse interaction?
> > 
> > 
> > 
> > 
> > 
> > SimpleView::SimpleView()
> > 
> > {
> > 
> >      this->ui = new Ui_SimpleView;
> > 
> >      this->ui->setupUi(this);
> > 
> > }
> > 
> > 
> > 
> > 
> > 
> > SimpleView:: addpoint()
> > 
> > {
> > 
> > }
> > 
> > 
> > 
> > class MouseInteractorStylePP : public vtkInteractorStyleTrackballCamera
> > 
> > {
> > 
> > public:
> > 
> >     static MouseInteractorStylePP* New();
> > 
> >     vtkTypeMacro(MouseInteractorStylePP,
> 
> vtkInteractorStyleTrackballCamera);
> 
> > virtual void OnRightButtonDown()
> > 
> > {
> 
>    this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()
> [ 0],
> 
> >                          this->Interactor->GetEventPosition()[1],
> > 
> >                          0,
> 
>                          this->Interactor->GetRenderWindow()->GetRenderers(
> ) ->GetFirstRenderer());
> 
> >          double picked[3];
> > 
> >          this->Interactor->GetPicker()->GetPickPosition(picked);
> > 
> >          std::cout << "Picked value: " << picked[0] << " " << picked[1]
> > <<
> 
> "
> 
> > " << picked[2] << std::endl;
> > 
> > 
> > 
> >          this->ui->qvtkWidget->GetRenderWindow()->Render();  ?? Error
> > here
> > 
> > 
> > 
> >          SimpleView *workspace = (SimpleView*)ClientData; //ClientData:
> > undefined
> > 
> >          workspace->addPoint();
> > 
> > }
> > 
> > 
> > 
> > Thanks a lot!
> > 
> > 
> > 
> > Best regards,
> > 
> > Xiaopeng
> > 
> > 



More information about the vtkusers mailing list