vtkRenderWindow中添加按钮

时间:2021-11-21 10:32:19

vtkRenderWindow中添加按钮

图中黑白的的地方为按钮

demo:https://lorensen.github.io/VTKExamples/site/Cxx/Widgets/TexturedButtonWidget/

//将viewport坐标转为屏幕坐标

    vtkSmartPointer<vtkCoordinate> upperRight =
      vtkSmartPointer<vtkCoordinate>::New();
    upperRight->SetCoordinateSystemToNormalizedDisplay();
    upperRight->SetValue(1.0, 1.0);

    double bds[6];
    double sz = 50.0;
    bds[0] = upperRight->GetComputedDisplayValue(renderer)[0] - sz;
    bds[1] = bds[0] + sz;
    bds[2] = upperRight->GetComputedDisplayValue(renderer)[1] - sz;
    bds[3] = bds[2] + sz;
    bds[4] = bds[5] = 0.0;