Auto adjust corner annotation font size.
This commit is contained in:
@@ -21,7 +21,7 @@ FastCornerAnnotationActor::FastCornerAnnotationActor()
|
|||||||
Actors[i]->SetTextScaleModeToNone();
|
Actors[i]->SetTextScaleModeToNone();
|
||||||
Actors[i]->SetUseBorderAlign(true);
|
Actors[i]->SetUseBorderAlign(true);
|
||||||
Actors[i]->GetTextProperty()->SetFontFamilyToCourier();
|
Actors[i]->GetTextProperty()->SetFontFamilyToCourier();
|
||||||
Actors[i]->GetTextProperty()->SetFontSize(13);
|
Actors[i]->GetTextProperty()->SetFontSize(6);
|
||||||
Actors[i]->GetTextProperty()->BoldOn();
|
Actors[i]->GetTextProperty()->BoldOn();
|
||||||
Actors[i]->GetTextProperty()->ShadowOn();
|
Actors[i]->GetTextProperty()->ShadowOn();
|
||||||
Actors[i]->GetActualPositionCoordinate()->SetCoordinateSystemToDisplay();
|
Actors[i]->GetActualPositionCoordinate()->SetCoordinateSystemToDisplay();
|
||||||
@@ -107,9 +107,22 @@ vtkTypeBool FastCornerAnnotationActor::HasTranslucentPolygonalGeometry() {
|
|||||||
void FastCornerAnnotationActor::ResetTextPosition(vtkRenderer* renderer) {
|
void FastCornerAnnotationActor::ResetTextPosition(vtkRenderer* renderer) {
|
||||||
double x = 1.0, y = 1.0;
|
double x = 1.0, y = 1.0;
|
||||||
renderer->NormalizedDisplayToDisplay(x, y);
|
renderer->NormalizedDisplayToDisplay(x, y);
|
||||||
|
|
||||||
|
double width = renderer->GetSize()[0] + 0.5;
|
||||||
|
double height = renderer->GetSize()[1] + 0.5;
|
||||||
|
double newFontSize = 6.0;
|
||||||
|
//文字的宽一般是高的一半
|
||||||
|
if (renderer->GetTiledAspectRatio()>0.5){
|
||||||
|
newFontSize = (width / 300) + 10.0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
newFontSize = (height / 200) + 10.0;
|
||||||
|
}
|
||||||
|
newFontSize = newFontSize > 16 ? 16 : (newFontSize < 10 ? 10 : newFontSize);
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
Actors[i]->GetActualPosition2Coordinate()->SetCoordinateSystemToDisplay();
|
Actors[i]->GetActualPosition2Coordinate()->SetCoordinateSystemToDisplay();
|
||||||
Actors[i]->SetPosition2(x - 5,y - 5);
|
Actors[i]->SetPosition2(x - 5,y - 5);
|
||||||
|
Actors[i]->GetTextProperty()->SetFontSize(newFontSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user