perf: improve draggable actor render performance

This commit is contained in:
kradchen
2025-07-15 10:38:06 +08:00
parent 262673d109
commit 01effd4ec1
5 changed files with 15 additions and 22 deletions

View File

@@ -142,7 +142,14 @@ void DraggableActor::ReleaseGraphicsResources(vtkWindow *window) {
}
int DraggableActor::RenderOverlay(vtkViewport *viewport) {
BuildShape();
if (BaseDataPoints->GetNumberOfPoints()<=0) return vtkProp::RenderOverlay(viewport);
QString newRenderTime = QString("%1-%2-%3").arg(BaseDataPoints->GetMTime())
.arg(Renderer->GetMTime()).arg(Renderer->GetActiveCamera()->GetMTime());
if (mRenderTime != newRenderTime)
{
BuildShape();
mRenderTime=newRenderTime;
}
if (senseArea->GetVisibility())senseArea->RenderOverlay(viewport);
if (shadow2D->GetVisibility())shadow2D->RenderOverlay(viewport);
if (actor2D->GetVisibility())actor2D->RenderOverlay(viewport);

View File

@@ -159,6 +159,7 @@ protected:
PointMapMode MapMode = MapToSlice;
void RebuildRenderPoint();
QString mRenderTime;
private:
DraggableActor(const DraggableActor &) = delete;

View File

@@ -39,16 +39,11 @@ namespace {
}
void EllipseAnnotationActor::BuildShape() {
if (!BaseDataPoints->GetNumberOfPoints()) return;
QString stamp = QString("%1-%2").arg(BaseDataPoints->GetMTime())
.arg(Renderer->GetActiveCamera()->GetMTime());
if (mRenderTime == stamp) return;
QStringList stamps = stamp.split("-");
QStringList renderTimes = mRenderTime.split("-");
mRenderTime = stamp;
QString stamp = QString("%1").arg(BaseDataPoints->GetMTime());
QStringList renderTimes = mRenderTime.split('-');
RebuildRenderPoint();
//base data change change message
if (stamps[0] != renderTimes[0])
if (stamp != renderTimes[0])
{ double p_lt[3] = {0, 0, 0};
double* disp_lt = controlP_lt->GetRenderPosition();
MapScreenPointToWorld(disp_lt[0], disp_lt[1], this->Renderer, p_lt);

View File

@@ -30,11 +30,6 @@ void OpenPolyAnnotationActor::SetRenderer(vtkRenderer *ren) {
}
void OpenPolyAnnotationActor::BuildShape() {
if (!BaseDataPoints->GetNumberOfPoints()) return;
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);

View File

@@ -39,16 +39,11 @@ namespace {
}
void RoundAnnotationActor::BuildShape() {
if (!BaseDataPoints->GetNumberOfPoints()) return;
QString stamp = QString("%1-%2").arg(BaseDataPoints->GetMTime())
.arg(Renderer->GetActiveCamera()->GetMTime());
if (mRenderTime == stamp) return;
QStringList stamps = stamp.split("-");
QStringList renderTimes = mRenderTime.split("-");
mRenderTime = stamp;
QString stamp = QString("%1").arg(BaseDataPoints->GetMTime());
QStringList renderTimes = mRenderTime.split('-');
RebuildRenderPoint();
//base data change change message
if (stamps[0] != renderTimes[0])
if (stamp != renderTimes[0])
{ double p_lt[3] = {0, 0, 0};
double* disp_lt = controlP_lt->GetRenderPosition();
MapScreenPointToWorld(disp_lt[0], disp_lt[1], this->Renderer, p_lt);