MCPcopy Create free account
hub / github.com/MITK/MITK / BuildRepresentation

Method BuildRepresentation

Modules/Annotation/src/mitkVtkLogoRepresentation.cpp:54–152  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

52
53//-------------------------------------------------------------------------
54void mitkVtkLogoRepresentation::BuildRepresentation()
55{
56 if (this->GetMTime() > this->BuildTime || (this->Renderer && this->Renderer->GetVTKWindow() &&
57 this->Renderer->GetVTKWindow()->GetMTime() > this->BuildTime))
58 {
59 // Determine and adjust the size of the image
60 if (this->Image)
61 {
62 double imageSize[2], borderSize[2], o[2];
63 imageSize[0] = 0.0;
64 imageSize[1] = 0.0;
65 // this->Image->Update();
66 if (this->Image->GetDataDimension() == 2)
67 {
68 int dims[3];
69 this->Image->GetDimensions(dims);
70 imageSize[0] = static_cast<double>(dims[0]);
71 imageSize[1] = static_cast<double>(dims[1]);
72 }
73 int *p1 = this->PositionCoordinate->GetComputedDisplayValue(this->Renderer);
74 int *p2 = this->Position2Coordinate->GetComputedDisplayValue(this->Renderer);
75 borderSize[0] = p2[0];
76 borderSize[1] = p2[1];
77 o[0] = static_cast<double>(p1[0]);
78 o[1] = static_cast<double>(p1[1]);
79
80 // this preserves the image aspect ratio. The image is
81 // centered around the center of the bordered ragion.
82 this->AdjustImageSize(o, borderSize, imageSize);
83
84 // Update the points
85 this->Texture->SetInputData(this->Image);
86 int *size = this->Renderer->GetSize();
87
88 switch (this->cornerPosition)
89 {
90 case 0:
91 {
92 this->TexturePoints->SetPoint(0, o[0], o[1], 0.0);
93 this->TexturePoints->SetPoint(1, o[0] + imageSize[0], o[1], 0.0);
94 this->TexturePoints->SetPoint(2, o[0] + imageSize[0], o[1] + imageSize[1], 0.0);
95 this->TexturePoints->SetPoint(3, o[0], o[1] + imageSize[1], 0.0);
96 break;
97 }
98 case 1:
99 {
100 o[0] = size[0] - o[0];
101 this->TexturePoints->SetPoint(0, o[0] - imageSize[0], o[1], 0.0);
102 this->TexturePoints->SetPoint(1, o[0], o[1], 0.0);
103 this->TexturePoints->SetPoint(2, o[0], o[1] + imageSize[1], 0.0);
104 this->TexturePoints->SetPoint(3, o[0] - imageSize[0], o[1] + imageSize[1], 0.0);
105 break;
106 }
107 case 2:
108 {
109 o[0] = size[0] - o[0];
110 o[1] = size[1] - o[1];
111 this->TexturePoints->SetPoint(0, o[0] - imageSize[0], o[1] - imageSize[1], 0.0);

Callers 1

UpdateVtkAnnotationMethod · 0.80

Calls 6

AdjustImageSizeMethod · 0.95
GetDimensionsMethod · 0.80
GetMTimeMethod · 0.45
GetSizeMethod · 0.45
SetPointMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected