1111
(Tomonari Hayakawa )
September 13, 2019, 9:00am
1
Hi,
Currently, I am developing imaging using vtkImplicitPlaneWidget2.
I’m thinking about saving to my file by pressing a certain key on the window.
First, identify the keys and create code to operate them.
Can you give me some tips on how to make certain keys work?
Also, can you tell me if there are any good examples?
1111
(Tomonari Hayakawa )
September 17, 2019, 10:14am
2
For example, when you press the “w” key on the vtkImplicitPlaneWidget2 window, you want to save the slice plane image as a two-dimensional image (.raw).
I don’t know how to make it work by pressing a key.
If you know how to do it, can you give me some tips on how to solve it?
@dgobbi
dgobbi
(David Gobbi)
September 18, 2019, 3:12pm
3
1111
(Tomonari Hayakawa )
September 19, 2019, 4:26am
4
Hi Gobbi,
Thank you for your usual reply.
I will create a program with reference to the sample.
1111
(Tomonari Hayakawa )
September 24, 2019, 10:40am
5
Hi Gobbi,
I am creating a program to save raw data of slice plane by pressing “c” based on KeypressEvents.
The program of key press partunder construction is shown below:
class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
{
public:
static KeyPressInteractorStyle* New();
vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyleTrackballCamera);
virtual void OnKeyPress() override
{
// Get the keypress
vtkRenderWindowInteractor *rwi = this->Interactor;
std::string key = rwi->GetKeySym();
// Output the key that was pressed
std::cout << "Pressed " << key << std::endl;
// Handle a "normal" key
if(key == "c")
{
std::cout << "The a key was pressed." << std::endl;
std::string filePathRaw = "reslice_512x512x512.raw";
vtkSmartPointer<vtkImageCast> castFilter =
vtkSmartPointer<vtkImageCast>::New();
castFilter->SetOutputScalarTypeToUnsignedChar();
castFilter->SetInputConnection(reslice->GetOutputPort());
castFilter->Update();
vtkSmartPointer<vtkImageWriter> writer =
vtkSmartPointer<vtkImageWriter>::New();
writer->SetInputConnection(castFilter->GetOutputPort());
writer->SetFileName(filePathRaw.c_str());
writer->Write();
}
// Forward events
vtkInteractorStyleTrackballCamera::OnKeyPress();
}
};
vtkStandardNewMacro(KeyPressInteractorStyle);
I don’t know how to adapt the updated plane to the castFilter’s SetInputConnection by callback.
vtkSmartPointer<vtkImageCast> castFilter =
vtkSmartPointer<vtkImageCast>::New();
castFilter->SetOutputScalarTypeToUnsignedChar();
castFilter->SetInputConnection(reader1->GetOutputPort());
castFilter->Update();
Could you advise how to apply the plane information to the key press part?
@dgobbi