[vtkusers] Read data from Callback function

Massinissa Bandou Massinissa.Bandou at USherbrooke.ca
Wed May 22 19:00:51 EDT 2013


Hi David,
thank you for your reply!

Yes, I have seen those examples. I'm really confused about the interaction
with callback functions. I'm sorry for that, my problem seems simple and
BASIC, I have a second class called A and I want to get the matrix of vector
from the callback function (matrix filled with the picked positions). 
I decided to create an object of A class to extract the matrix. I have no
error but it seems not working. Is there something I missed out?

Again I really appreciate your help!
 
class A{
public:
   void ReadPolyData();
   void GetMatrix(std::vector<std::vector&lt;double>> &p){GetMat = p;};
private:
std::vector<std::vector&lt;double>> GetMat;
};

void A::ReadPolyDAta(){
    /*
     * read polydata
     *
    */
     vtkMyLandmark *callback = vtkMyLandmark::New();
     QVTKwidget->GetInteractor()->AddObserver(vtkMyLandmark::EndPickEvent,
callback);
     
// How can I extract the matrix from the callback

}/h3>

class vtkMyLandmark : public vtkCommand 
{ 
public: 
        A mat; // object of the first class
        vtkMyLandmark::vtkMyLandmark(){SelectedActor = NULL;} 
        static vtkMyLandmark *New(){return new vtkMyLandmark;} 
	std::vector<std::vector&lt;double>> ReturnMatrix(){
		std::vector<std::vector&lt;double>> a = this->matrix;
		mat.GetMatrix(a);
		return a;
	}

        void SetSelectionActor(vtkActor* pvtkActorSelection) { 
                SelectedActor = pvtkActorSelection; 
                }; 


        virtual void Execute(vtkObject *caller, unsigned long, void*){ 
                vtkRenderWindowInteractor *iren =
reinterpret_cast<vtkRenderWindowInteractor*>(caller); 
                vtkPointPicker *picker = (vtkPointPicker
*)iren->GetPicker(); 
                double picked[3]; 
                picker->GetPickPosition(picked); 
                                
                if (picker->GetPointId() != -1) { 
                        if(SelectedActor){ 
                               
SelectedActor->SetPosition(picker->GetPickPosition()); 

                                for(unsigned int i=0;i<3;i++){ 
                                        this->row.push_back(picked[i]); 
                                } 
                                this->matrix.push_back(row); 

                                iren->Render(); 
                        }	
                } 
        } 
private: 
        std::vector<double> row; 
        std::vector<std::vector&lt;double>> matrix; 
private: 
        vtkActor* SelectedActor; 

};




--
View this message in context: http://vtk.1045678.n5.nabble.com/Read-data-from-Callback-function-tp5720847p5720895.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list