perf: Improve polygon render performance

This commit is contained in:
kradchen
2025-07-11 16:30:10 +08:00
parent a9e870c06b
commit f55a81e4c7

View File

@@ -34,6 +34,7 @@ void OpenPolyAnnotationActor::BuildShape() {
QString stamp = QString("%1-%2").arg(BaseDataPoints->GetMTime())
.arg(Renderer->GetActiveCamera()->GetMTime());
if (mRenderTime == stamp) return;
mRenderTime = stamp;
RebuildRenderPoint();
vtkNew<vtkPolyLineSource> source;
source->SetClosed(this->Closed);
@@ -65,6 +66,7 @@ void OpenPolyAnnotationActor::BuildShape() {
void OpenPolyAnnotationActor::SetPointWorldPosition(vtkIdType index, double x, double y, double z) {
BaseDataPoints->SetPoint(index, x, y, z);
BaseDataPoints->Modified();
}
bool OpenPolyAnnotationActor::onMeasureLeftButtonDown(vtkRenderWindowInteractor * iren) {
@@ -84,6 +86,7 @@ bool OpenPolyAnnotationActor::onMeasureLeftButtonDown(vtkRenderWindowInteractor
controlP->AddObserver(vtkCommand::LeaveEvent, this, &OpenPolyAnnotationActor::HighlightOff);
controlPointList.push_back(controlP);
controlP->Index = BaseDataPoints->InsertNextPoint( p);
BaseDataPoints->Modified();
this->SetRenderer(renderer);
iren->Render();
return true;
@@ -152,6 +155,7 @@ void OpenPolyAnnotationActor::selfDragCb(vtkObject *, unsigned long event, void
MapScreenPointToWorld(pos[0], pos[1], this->Renderer, result);
controlPointList[i]->SetWorldPosition(result);
}
BaseDataPoints->Modified();
}
void OpenPolyAnnotationActor::controlPointCb(vtkObject *sender, unsigned long event, void *data) {
@@ -161,6 +165,7 @@ void OpenPolyAnnotationActor::controlPointCb(vtkObject *sender, unsigned long ev
double result[3] = {0, 0, 0};
MapScreenPointToWorld(pos[0], pos[1], this->Renderer, result);
BaseDataPoints->SetPoint(index, result);
BaseDataPoints->Modified();
UpdatePerimeterAndAreaText();
}