[vtkusers] Changing Cell Color After picking

Ricardo Seco VTK secolasUA at gmail.com
Sun Jan 7 14:47:14 EST 2007


Hello. I am trying to change the color of the cell after picking but 
nothing happens...
Could someone help me?

Best Regards
Ricardo Seco

class vtkMyCallback : public vtkCommand
{
public:
        vtkMyCallback::vtkMyCallback() { m_pvtkActorSelection = NULL; };
        static vtkMyCallback *New() { return new vtkMyCallback; }
        void SetSelectionActor(vtkActor* pvtkActorSelection) { 
m_pvtkActorSelection = pvtkActorSelection; };
        void SetSelectionList(vtkIdList* pvtkIdDeletion) { 
m_pvtkIdDeletion = pvtkIdDeletion; };
        void SetSelectionDataSet(vtkPolyData* pvtkDataSet) { 
m_pvtkDataSet = pvtkDataSet; };
        void SetIren(vtkRenderWindowInteractor* pvtkIren) { m_pvtkIren = 
pvtkIren; };
        virtual void Execute(vtkObject *caller, unsigned long, void*)
        {
                double coords[3];
                int pId;
                float ptr;
                vtkCellPicker *picker = (vtkCellPicker 
*)m_pvtkIren->GetPicker();
                picker->GetPickPosition(coords);
                // Obter o Id da cell que acabamos de fazer pickin
                pId = picker->GetCellId();
                
m_pvtkDataSet->GetPointData()->GetScalars()->SetTuple1(pId,0);-------------------------------------------------- 
HERE
               
                printf("Cell ID a remover: %d \n",pId);
                // Inserção da cell na vtkIdList
                m_pvtkIdDeletion->InsertNextId(pId);
                // Caso a cell já esteja na vtkIdList ou seja NULL(-1)
                for(int k=0; k<m_pvtkIdDeletion->GetNumberOfIds(); k++)
                {
                    if ((pId) == (m_pvtkIdDeletion->GetId(k)) && (k!=0))
                    {
                        m_pvtkIdDeletion->DeleteId(pId);
                        m_pvtkIdDeletion->InsertNextId(pId);
                    }
                    if ((pId) == -1)
                        m_pvtkIdDeletion->DeleteId(pId);
                }
                
printf("-------------------------------------------------------------------------\n");
                printf("Numero de Cells para 
remocao:%d\n",m_pvtkIdDeletion->GetNumberOfIds());
                printf("Lista de Cells para remocao:\n");
                for(int k=0; k<m_pvtkIdDeletion->GetNumberOfIds(); k++)
                    printf("Pos:%d 
CellId:%d\n",k,m_pvtkIdDeletion->GetId(k));
                // Renderizar a nossa esfera de picking para a cell 
seleccionada
                if (picker->GetCellId() != -1)
                {
                      if (m_pvtkActorSelection)          
                          m_pvtkActorSelection->SetPosition(coords);
                }
                m_pvtkIren->Render();
                
m_pvtkDataSet->GetPointData()->GetScalars()->SetTuple1(pId,1);
        }
private:
        vtkActor* m_pvtkActorSelection;
        vtkIdList* m_pvtkIdDeletion;
        vtkPolyData* m_pvtkDataSet;
        vtkRenderWindowInteractor* m_pvtkIren;
};



More information about the vtkusers mailing list