[vtkusers] Add a menu item in VTK

Gishara Indeewarie gish.777 at gmail.com
Mon Feb 27 05:55:06 EST 2012


Yes, I have tried to use MFC dialog here.
But then when I try to update the data, I get an error as,  " Expression:
e->Component != 0", when closing the renderWindow.
Below is how I do it.

getData(){


vtkSmartPointer <vtkRenderer> Renderer =
 vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer <vtkRenderWindow> RenderWindow =
 vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer <vtkRenderWindowInteractor> Interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkPolyData> polydata =
 vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkDoubleArray> weights =
 vtkSmartPointer<vtkDoubleArray>::New();
vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
vtkSmartPointer<vtkSurfaceReconstructionFilter> surf=
 vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();
vtkSmartPointer<vtkContourFilter> cf=
vtkSmartPointer<vtkContourFilter>::New();
vtkSmartPointer<vtkPolyDataMapper> mapper =
 vtkSmartPointer<vtkPolyDataMapper>::New();
vtkSmartPointer<vtkPoints> newPts = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkActor> actor= vtkSmartPointer<vtkActor>::New();



newPts->Reset();
ScalarValues.RemoveAll();

 for (plane = 0; plane <t; plane++)
{
 newPts->InsertNextPoint(pt2->xx,pt2->y,pt2->z);
ScalarValues.Add(pt2->P0);

}

}

ViewData(){

polydata->SetPoints(newPts);
  polydata->Modified();

  weights->SetNumberOfValues(ScalarValues_pressure.GetSize());
  for(int i=0; i< ScalarValues_pressure.GetSize();i++){
  weights->SetValue(i, ScalarValues_pressure[i]);
  }


  glyphFilter->SetInputConnection(polydata->GetProducerPort());
  glyphFilter->Update();

  surf->SetInput(polydata);


  cf->SetInputConnection(surf->GetOutputPort());
  cf->Update();

 outputPolyData = cf->GetOutput();
 outputPolyData->Modified();

 outputPolyData->GetPointData()->SetScalars(weights);


  mapper->SetInputConnection(cf->GetOutputPort());
  mapper->Modified();
  mapper->ScalarVisibilityOn();
  actor->SetMapper(mapper);
  actor->Modified();


  Renderer->SetBackground( 1, 1, 1 );
  Renderer->Modified();

  Renderer->AddActor(actor);
  Renderer->Modified();

  RenderWindow->AddRenderer(Renderer);
  RenderWindow->Modified();
   Interactor->SetRenderWindow(RenderWindow);
  RenderWindow->Render();
  RenderWindow->Modified();
  nteractor->Start();
  Interactor->Modified();


}

On Mon, Feb 27, 2012 at 4:08 PM, Jothybasu Selvaraj <jothybasu at gmail.com>wrote:

> Then you better use your GUI library for more advanced interactions.
>
> Jothy
>
>
> On Mon, Feb 27, 2012 at 10:36 AM, Gishara Indeewarie <gish.777 at gmail.com>wrote:
>
>> Thanks Jothy. But I could not find any button like behavior in
>> vtkRectangularButtonSource .
>> Tracking the right click is not enough here, because I want to add set of
>> options for the user.
>>
>> On Mon, Feb 27, 2012 at 2:55 PM, Jothybasu Selvaraj <jothybasu at gmail.com>wrote:
>>
>>> May be vtkRectangularButtonSource could do what you need.
>>>
>>>
>>> Jothy
>>>
>>>
>>> On Mon, Feb 27, 2012 at 8:15 AM, Gishara Indeewarie <gish.777 at gmail.com>wrote:
>>>
>>>> Hi all,
>>>>
>>>> Could someone give me an example for adding a menu item in vtk in c++?
>>>>  I want to allow the user to change the data in vtk render by pressing
>>>> a button.
>>>> I thought of doing this by adding right click menu in vtk.
>>>> Thanks.
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>>>
>>>
>>>
>>> --
>>> Jothy
>>>
>>>
>>
>>
>> --
>> Gish
>>
>
>
>
> --
> Jothy
>
>


-- 
Gish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120227/b6754935/attachment.htm>


More information about the vtkusers mailing list