perf: improve draggable actor render performance
This commit is contained in:
@@ -142,7 +142,14 @@ void DraggableActor::ReleaseGraphicsResources(vtkWindow *window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int DraggableActor::RenderOverlay(vtkViewport *viewport) {
|
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 (senseArea->GetVisibility())senseArea->RenderOverlay(viewport);
|
||||||
if (shadow2D->GetVisibility())shadow2D->RenderOverlay(viewport);
|
if (shadow2D->GetVisibility())shadow2D->RenderOverlay(viewport);
|
||||||
if (actor2D->GetVisibility())actor2D->RenderOverlay(viewport);
|
if (actor2D->GetVisibility())actor2D->RenderOverlay(viewport);
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ protected:
|
|||||||
|
|
||||||
PointMapMode MapMode = MapToSlice;
|
PointMapMode MapMode = MapToSlice;
|
||||||
void RebuildRenderPoint();
|
void RebuildRenderPoint();
|
||||||
|
QString mRenderTime;
|
||||||
private:
|
private:
|
||||||
DraggableActor(const DraggableActor &) = delete;
|
DraggableActor(const DraggableActor &) = delete;
|
||||||
|
|
||||||
|
|||||||
@@ -39,16 +39,11 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EllipseAnnotationActor::BuildShape() {
|
void EllipseAnnotationActor::BuildShape() {
|
||||||
if (!BaseDataPoints->GetNumberOfPoints()) return;
|
QString stamp = QString("%1").arg(BaseDataPoints->GetMTime());
|
||||||
QString stamp = QString("%1-%2").arg(BaseDataPoints->GetMTime())
|
QStringList renderTimes = mRenderTime.split('-');
|
||||||
.arg(Renderer->GetActiveCamera()->GetMTime());
|
|
||||||
if (mRenderTime == stamp) return;
|
|
||||||
QStringList stamps = stamp.split("-");
|
|
||||||
QStringList renderTimes = mRenderTime.split("-");
|
|
||||||
mRenderTime = stamp;
|
|
||||||
RebuildRenderPoint();
|
RebuildRenderPoint();
|
||||||
//base data change change message
|
//base data change change message
|
||||||
if (stamps[0] != renderTimes[0])
|
if (stamp != renderTimes[0])
|
||||||
{ double p_lt[3] = {0, 0, 0};
|
{ double p_lt[3] = {0, 0, 0};
|
||||||
double* disp_lt = controlP_lt->GetRenderPosition();
|
double* disp_lt = controlP_lt->GetRenderPosition();
|
||||||
MapScreenPointToWorld(disp_lt[0], disp_lt[1], this->Renderer, p_lt);
|
MapScreenPointToWorld(disp_lt[0], disp_lt[1], this->Renderer, p_lt);
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ void OpenPolyAnnotationActor::SetRenderer(vtkRenderer *ren) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OpenPolyAnnotationActor::BuildShape() {
|
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();
|
RebuildRenderPoint();
|
||||||
vtkNew<vtkPolyLineSource> source;
|
vtkNew<vtkPolyLineSource> source;
|
||||||
source->SetClosed(this->Closed);
|
source->SetClosed(this->Closed);
|
||||||
|
|||||||
@@ -39,16 +39,11 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RoundAnnotationActor::BuildShape() {
|
void RoundAnnotationActor::BuildShape() {
|
||||||
if (!BaseDataPoints->GetNumberOfPoints()) return;
|
QString stamp = QString("%1").arg(BaseDataPoints->GetMTime());
|
||||||
QString stamp = QString("%1-%2").arg(BaseDataPoints->GetMTime())
|
QStringList renderTimes = mRenderTime.split('-');
|
||||||
.arg(Renderer->GetActiveCamera()->GetMTime());
|
|
||||||
if (mRenderTime == stamp) return;
|
|
||||||
QStringList stamps = stamp.split("-");
|
|
||||||
QStringList renderTimes = mRenderTime.split("-");
|
|
||||||
mRenderTime = stamp;
|
|
||||||
RebuildRenderPoint();
|
RebuildRenderPoint();
|
||||||
//base data change change message
|
//base data change change message
|
||||||
if (stamps[0] != renderTimes[0])
|
if (stamp != renderTimes[0])
|
||||||
{ double p_lt[3] = {0, 0, 0};
|
{ double p_lt[3] = {0, 0, 0};
|
||||||
double* disp_lt = controlP_lt->GetRenderPosition();
|
double* disp_lt = controlP_lt->GetRenderPosition();
|
||||||
MapScreenPointToWorld(disp_lt[0], disp_lt[1], this->Renderer, p_lt);
|
MapScreenPointToWorld(disp_lt[0], disp_lt[1], this->Renderer, p_lt);
|
||||||
|
|||||||
Reference in New Issue
Block a user