vtkSmartPointer<vtkTextActor> NoteViewerItemInterface::createTextActor(const QString &text, Double3 position)
{
auto data = text.toStdString();
auto textActor = vtkSmartPointer<vtkTextActor>::New();
textActor->SetInput(data.c_str());
textActor->GetTextProperty()->SetFontSize(12);
auto path = FileUtil::currentExeDir() + "/fonts/simhei.ttf";
textActor->GetTextProperty()->SetFontFamily(VTK_FONT_FILE);
textActor->GetTextProperty()->SetFontFile(path.toUtf8());
textActor->GetTextProperty()->SetFontSize(NoteViewerConfig::instance()->getFontSize());
textActor->SetPosition(position[0], position[1]);
textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
textActor->GetPositionCoordinate()->SetValue(position[0], position[1], 0.001);
return textActor;
}
void NoteViewerNotationItem::initActor()
{
{
auto source = vtkSmartPointer<vtkLineSource>::New();
source->SetPoint1(m_center[0], m_center[1], 0.001);
source->SetPoint2(m_position[0], m_position[1], 0.001);
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(source->GetOutputPort());
m_line = vtkSmartPointer<vtkActor>::New();
m_line->SetMapper(mapper);
m_line->GetProperty()->SetLineStipplePattern(0xFF00);
m_line->GetProperty()->SetLineStippleRepeatFactor(1);
m_viewer->getRenderer()->AddActor(m_line);
}
{
m_textActor = createTextActor(m_tip, m_position);
m_viewer->getRenderer()->AddActor(m_textActor);
}
m_viewer->updateRender();
}