vtk vtkDistanceWidget测量距离 在不同widget中的问题
vtk吧
全部回复
仅看楼主
level 1
哈喽you6 楼主
在一个widget中根据vtkDistanceWiget测出了一段距离,想在另一个widget中同步显示这段距离,可是显示不出来,请大家帮忙看一下,或者给个思路
代码:
vtkDistanceWidget* distanceWidget = vtkDistanceWidget::New();
distanceWidget->SetInteractor(m_renderWindows[i]->GetInteractor());
vtkDistanceRepresentation3D* representation = vtkDistanceRepresentation3D::New();
distanceWidget->SetRepresentation(representation);
distanceWidget->SetPriority(0.9);
static_cast<vtkDistanceRepresentation*> (distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.3g px");
distanceWidget->ManagesCursorOn();
distanceWidget->On();
想在另外一个widget中显示:
vtkDistanceWidget* widget3 = dynamic_cast<vtkDistanceWidget*>(m_tempWidget[3]);
widget3->SetWidgetStateToManipulate();
vtkDistanceRepresentation* representation = static_cast<vtkDistanceRepresentation*>(widget3->GetRepresentation());
representation->SetPoint1WorldPosition(m_tempPos1);
representation->SetPoint2WorldPosition(m_tempPos2);
vtkSmartPointer<vtkLineRepresentation> pRepresent = vtkSmartPointer<vtkLineRepresentation>::New();
pRepresent->SetPoint1WorldPosition(m_tempPos1);
pRepresent->SetPoint2WorldPosition(m_tempPos2);
pRepresent->SetLineColor(0, 1, 0);
lineWidget->SetInteractor(m_renderWindows[3]->GetInteractor());
lineWidget->SetRepresentation(pRepresent);
lineWidget->On();
2017年11月14日 04点11分 1
level 1
https://www.vtk.org/doc/nightly/html/classvtkDistanceWidget.html
你得加一个widget->set state *****
virtual void vtkDistanceWidget::SetWidgetStateToStart() virtual
Set the state of the widget.
If the state is set to "Manipulate" then it is assumed that the widget and its representation will be initialized programmatically and is not interactively placed. Initially the widget state is set to "Start" which means nothing will appear and the user must interactively place the widget with repeated mouse selections. Set the state to "Start" if you want interactive placement. Generally state changes must be followed by a Render() for things to visually take effect.
virtual void vtkDistanceWidget::SetWidgetStateToManipulate() virtual
Set the state of the widget.
If the state is set to "Manipulate" then it is assumed that the widget and its representation will be initialized programmatically and is not interactively placed. Initially the widget state is set to "Start" which means nothing will appear and the user must interactively place the widget with repeated mouse selections. Set the state to "Start" if you want interactive placement. Generally state changes must be followed by a Render() for things to visually take effect.
2018年11月23日 02点11分 2
level 1
怎么解决的?
2024年12月17日 08点12分 3
1