To display in an annotatedcube-like things, I tried to use vtkAssembly
as well. This is the solution2 to fix the problem.
I thought that if I defined a cube and just map the pictures to each plane of the cube will work, so I don’t have to worry about the font stuff.
I refered to examples.vtk.org/site/Cxx/Visualization/TextureMapPlane/, and tried to load JPEG/PNG pictures to vtkTextures
like heres:
vtkSmartPointer<vtkActor> LoadTextureFace(const char* filename, const std::array<double, 3>& center, const std::array<double, 3>& normal) {
// create plane
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
plane->SetCenter(center[0], center[1], center[2]);
plane->SetNormal(normal[0], normal[1], normal[2]);
plane->Update();
vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();
reader->SetFileName(filename);
// load texture
vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(reader->GetOutputPort());
texture->Update();
vtkNew<vtkTextureMapToPlane> texturePlane;
texturePlane->SetInputConnection(plane->GetOutputPort());
texturePlane->Update();
vtkSmartPointer<vtkPolyDataMapper> planeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
planeMapper->SetInputConnection(texturePlane->GetOutputPort());
vtkSmartPointer<vtkActor> faceActor = vtkSmartPointer<vtkActor>::New();
faceActor->SetMapper(planeMapper);
faceActor->SetTexture(texture);
faceActor->Modified();
return faceActor;
}
Outside the functions, I defined the assembly like here:
vtkSmartPointer<vtkAssembly> m_pWidget2 = vtkSmartPointer<vtkAssembly>::New();
double cubeSize = 1;
m_pWidget2->AddPart(LoadTextureFace(**path1**, { -cubeSize / 2, 0, 0 }, { -cubeSize, 0, 0 })); // X-
m_pWidget2->AddPart(LoadTextureFace(**path2**, { cubeSize / 2, 0, 0 }, { cubeSize, 0, 0 })); // X+
m_pWidget2->AddPart(LoadTextureFace(**path3**, { 0, -cubeSize / 2, 0 }, { 0, -cubeSize, 0 })); // Y-
m_pWidget2->AddPart(LoadTextureFace(**path4**, { 0, cubeSize / 2, 0 }, { 0, cubeSize, 0 })); // Y+
m_pWidget2->AddPart(LoadTextureFace(**path5**, { 0, 0, -cubeSize / 2 }, { 0, 0, -cubeSize })); // Z-
m_pWidget2->AddPart(LoadTextureFace(**path6**, { 0, 0, cubeSize / 2 }, { 0, 0, cubeSize })); // Z+
m_pWidget2->DragableOff();
// TO ACTIVATE IT
m_pWidget->SetOrientationMarker(m_pWidget2);
m_pWidget->SetCurrentRenderer(renderer);
m_pWidget->SetInteractor(renderwindowiterator);
m_pWidget->SetViewport(0.85, 0, 1, 0.15);
m_pWidget->SetEnabled(1);
m_pWidget->On();
m_pWidget->InteractiveOff();
But as a result, nothing shows. I have no idea if I just ignore to define a vtkCubeSource
or something else.
Here is the solution 2 to [display other languages at annotation cube], sorry for the TOO MUCH long issues and great thanks for your patience.
Could you please give me some advice? Best wishes.