Commit ab278e87 authored by Corona, Thomas Joseph's avatar Corona, Thomas Joseph Committed by Kitware Robot
Browse files

Merge topic 'release-rendering-review' into release

7789697d Fixed #17832: Observe NSView frame changes even for NSViews VTK didn't create
4a0b3b0a Fixed CAOpenGLLayer example being rendered as solid red
36350987 Create the NSOpenGLPixelFormat and NSOpenGLContext before the NSView/NSWindow
a12cdb6a Hoisted some duplicated code into a helper method
75a4aa97 Review of vtkCocoaRenderWindow SetSize and SetPosition
bf4a12a5 Added method separator comment lines in some files that missed some
3b14eb34 Fixed/improved a few incorrect comments
71a3fa44

 Cleanup SetSize and SetPosition methods
...
Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarSeun Odutola <seun@rogue-research.com>
Acked-by: default avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !6788
parents f9a7797e 7789697d
......@@ -75,12 +75,12 @@ void vtkWindow::SetSize(int a[2])
}
//-----------------------------------------------------------------------------
void vtkWindow::SetSize(int x, int y)
void vtkWindow::SetSize(int width, int height)
{
if (this->Size[0] != x || this->Size[1] != y)
if (this->Size[0] != width || this->Size[1] != height)
{
this->Size[0] = x;
this->Size[1] = y;
this->Size[0] = width;
this->Size[1] = height;
this->Modified();
this->InvokeEvent(vtkCommand::WindowResizeEvent, nullptr);
}
......
......@@ -56,20 +56,36 @@ public:
//@{
/**
* Set/Get the position in screen coordinates of the rendering window.
* Measured in pixels.
* Get the position (x and y) of the rendering window in
* screen coordinates (in pixels).
*/
virtual int* GetPosition() VTK_SIZEHINT(2);
virtual void SetPosition(int, int);
/**
* Set the position (x and y) of the rendering window in
* screen coordinates (in pixels). This resizes the operating
* system's view/window and redraws it.
*/
virtual void SetPosition(int x, int y);
virtual void SetPosition(int a[2]);
//@}
//@{
/**
* Set/Get the size of the window in screen coordinates in pixels.
* Get the size (width and height) of the rendering window in
* screen coordinates (in pixels).
*/
virtual int* GetSize() VTK_SIZEHINT(2);
virtual void SetSize(int, int);
/**
* Set the size (width and height) of the rendering window in
* screen coordinates (in pixels). This resizes the operating
* system's view/window and redraws it.
*
* If the size has changed, this method will fire
* vtkCommand::WindowResizeEvent.
*/
virtual void SetSize(int width, int height);
virtual void SetSize(int a[2]);
//@}
......
......@@ -24,9 +24,10 @@
// Tell VTK to render.
assert([customView renderWindowInteractor] -> GetInitialized());
vtkRenderWindow* renderWindow = [customView renderWindow];
vtkCocoaRenderWindow* renderWindow = [customView renderWindow];
if (renderWindow && renderWindow->GetMapped())
{
renderWindow->Superclass::InitializeFromCurrentContext();
renderWindow->Render();
}
......
......@@ -134,7 +134,7 @@
{
return;
}
int* wh = self.renderWindow->GetSize();
const int* wh = self.renderWindow->GetSize();
CGFloat scale = super.contentScaleFactor;
coordinates[0] = scale * touchPoint.x;
// UIKit => OpenGL == flip Y axis
......@@ -147,7 +147,7 @@
{
return;
}
int* wh = self.renderWindow->GetSize();
const int* wh = self.renderWindow->GetSize();
int display[2] = { 0 };
[self displayCoordinates:display ofTouch:touch];
coordinates[0] = (double)display[0] / wh[0];
......
......@@ -740,7 +740,7 @@ vtkMTimeType vtkAdaptiveDataSetSurfaceFilter::GetMTime()
}
// Check & Update renderer size
int* sz = this->Renderer->GetSize();
const int* sz = this->Renderer->GetSize();
if (this->LastRendererSize[0] != sz[0] || this->LastRendererSize[1] != sz[1])
{
this->LastRendererSize[0] = sz[0];
......
......@@ -176,7 +176,7 @@ void vtkMFCWindow::DrawDC(CDC* pDC)
int cyPage = pDC->GetDeviceCaps(VERTRES);
// Get the size of the window in pixels.
int* size = this->pvtkWin32OpenGLRW->GetSize();
const int* size = this->pvtkWin32OpenGLRW->GetSize();
int cxWindow = size[0];
int cyWindow = size[1];
float fx = float(cxPage) / float(cxWindow);
......
......@@ -68,8 +68,8 @@ int TestQtWidget(int argc, char* argv[])
detail::show(widgetOrWindow, QSize(300, 300));
detail::process_events_and_wait(1000); // let's wait a little longer for the resize
int* windowSize = window->GetSize();
int* screenSize = window->GetScreenSize();
const int* windowSize = window->GetSize();
const int* screenSize = window->GetScreenSize();
if (screenSize[0] < windowSize[0] || screenSize[1] < windowSize[1])
{
std::cout << "Expected vtkGenericOpenGLRenderWindow::GetScreenSize() "
......
......@@ -353,7 +353,7 @@ void vtkCompassRepresentation::BuildRepresentation()
return;
}
int* size = this->Renderer->GetSize();
const int* size = this->Renderer->GetSize();
if (0 == size[0] || 0 == size[1])
{
// Renderer has no size yet: wait until the next
......@@ -438,7 +438,7 @@ void vtkCompassRepresentation::BuildRepresentation()
this->DistanceRepresentation->Modified();
this->DistanceRepresentation->BuildRepresentation();
int* renSize = this->Renderer->GetSize();
const int* renSize = this->Renderer->GetSize();
vtkUnsignedCharArray* colors = vtkArrayDownCast<vtkUnsignedCharArray>(
this->BackdropMapper->GetInput()->GetPointData()->GetScalars());
unsigned char color[4];
......@@ -699,7 +699,7 @@ void vtkCompassRepresentation::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------
int vtkCompassRepresentation::ComputeInteractionState(int x, int y, int modify)
{
int* size = this->Renderer->GetSize();
const int* size = this->Renderer->GetSize();
if (0 == size[0] || 0 == size[1])
{
// Renderer has no size yet
......
......@@ -231,7 +231,7 @@ void vtkPOVExporter::WriteHeader(vtkRenderer* renderer)
// width and height of output image,
// and other default command line args to POVRay
int* size = renderer->GetSize();
const int* size = renderer->GetSize();
fprintf(this->FilePtr, "// +W%d +H%d\n\n", size[0], size[1]);
// global settings
......
......@@ -146,7 +146,7 @@ void vtkSVGExporter::WriteSVG()
//------------------------------------------------------------------------------
void vtkSVGExporter::PrepareDocument()
{
int* size = this->RenderWindow->GetSize();
const int* size = this->RenderWindow->GetSize();
this->RootNode = vtkXMLDataElement::New();
this->RootNode->SetName("svg");
......@@ -247,7 +247,7 @@ void vtkSVGExporter::RenderBackground(vtkRenderer* ren)
}
int* renOrigin = ren->GetOrigin();
int* renSize = ren->GetSize();
const int* renSize = ren->GetSize();
vtkRectf renRect(renOrigin[0], renOrigin[1], renSize[0], renSize[1]);
vtkNew<vtkContext2D> ctx;
......
......@@ -73,7 +73,7 @@ void vtkOpenGLGL2PSExporter::WriteData()
GLint options = static_cast<GLint>(this->GetGL2PSOptions());
GLint sort = static_cast<GLint>(this->GetGL2PSSort());
GLint format = static_cast<GLint>(this->GetGL2PSFormat());
int* winsize = this->RenderWindow->GetSize();
const int* winsize = this->RenderWindow->GetSize();
GLint viewport[4] = { 0, 0, static_cast<GLint>(winsize[0]), static_cast<GLint>(winsize[1]) };
// Setup helper class:
......
......@@ -126,7 +126,7 @@ public:
vtkInteractorStyleImage* isi = static_cast<vtkInteractorStyleImage*>(caller);
int* size = this->IV->GetRenderWindow()->GetSize();
const int* size = this->IV->GetRenderWindow()->GetSize();
double window = this->InitialWindow;
double level = this->InitialLevel;
......
......@@ -104,19 +104,36 @@ public:
//@{
/**
* Set/Get the position in screen coordinates of the rendering window.
* Get the position (x and y) of the rendering window in
* screen coordinates (in pixels).
*/
int* GetPosition() VTK_SIZEHINT(2) { return this->RenderWindow->GetPosition(); }
void SetPosition(int a, int b) { this->RenderWindow->SetPosition(a, b); }
/**
* Set the position (x and y) of the rendering window in
* screen coordinates (in pixels). This resizes the operating
* system's view/window and redraws it.
*/
void SetPosition(int x, int y) { this->RenderWindow->SetPosition(x, y); }
virtual void SetPosition(int a[2]);
//@}
//@{
/**
* Set/Get the size of the window in screen coordinates in pixels.
* Get the size (width and height) of the rendering window in
* screen coordinates (in pixels).
*/
int* GetSize() VTK_SIZEHINT(2) { return this->RenderWindow->GetSize(); }
void SetSize(int a, int b) { this->RenderWindow->SetSize(a, b); }
/**
* Set the size (width and height) of the rendering window in
* screen coordinates (in pixels). This resizes the operating
* system's view/window and redraws it.
*
* If the size has changed, this method will fire
* vtkCommand::WindowResizeEvent.
*/
void SetSize(int width, int height) { this->RenderWindow->SetSize(width, height); }
virtual void SetSize(int a[2]);
//@}
......
......@@ -179,9 +179,9 @@ void vtkImageViewer2::SetRenderer(vtkRenderer* arg)
}
//----------------------------------------------------------------------------
void vtkImageViewer2::SetSize(int a, int b)
void vtkImageViewer2::SetSize(int width, int height)
{
this->RenderWindow->SetSize(a, b);
this->RenderWindow->SetSize(width, height);
}
//----------------------------------------------------------------------------
......@@ -405,9 +405,9 @@ void vtkImageViewer2::UpdateDisplayExtent()
}
//----------------------------------------------------------------------------
void vtkImageViewer2::SetPosition(int a, int b)
void vtkImageViewer2::SetPosition(int x, int y)
{
this->RenderWindow->SetPosition(a, b);
this->RenderWindow->SetPosition(x, y);
}
//----------------------------------------------------------------------------
......@@ -496,7 +496,7 @@ public:
vtkInteractorStyleImage* isi = static_cast<vtkInteractorStyleImage*>(caller);
int* size = this->IV->GetRenderWindow()->GetSize();
const int* size = this->IV->GetRenderWindow()->GetSize();
double window = this->InitialWindow;
double level = this->InitialLevel;
......
......@@ -180,19 +180,36 @@ public:
//@{
/**
* Set/Get the position in screen coordinates of the rendering window.
* Get the position (x and y) of the rendering window in
* screen coordinates (in pixels).
*/
virtual int* GetPosition() VTK_SIZEHINT(2);
virtual void SetPosition(int a, int b);
/**
* Set the position (x and y) of the rendering window in
* screen coordinates (in pixels). This resizes the operating
* system's view/window and redraws it.
*/
virtual void SetPosition(int x, int y);
virtual void SetPosition(int a[2]) { this->SetPosition(a[0], a[1]); }
//@}
//@{
/**
* Set/Get the size of the window in screen coordinates in pixels.
* Get the size (width and height) of the rendering window in
* screen coordinates (in pixels).
*/
virtual int* GetSize() VTK_SIZEHINT(2);
virtual void SetSize(int a, int b);
/**
* Set the size (width and height) of the rendering window in
* screen coordinates (in pixels). This resizes the operating
* system's view/window and redraws it.
*
* If the size has changed, this method will fire
* vtkCommand::WindowResizeEvent.
*/
virtual void SetSize(int width, int height);
virtual void SetSize(int a[2]) { this->SetSize(a[0], a[1]); }
//@}
......
......@@ -42,7 +42,7 @@ public:
void Clear() { this->points.clear(); }
void DrawPixels(
const vtkVector2i& StartPos, const vtkVector2i& EndPos, unsigned char* pixels, int* size)
const vtkVector2i& StartPos, const vtkVector2i& EndPos, unsigned char* pixels, const int* size)
{
int x1 = StartPos.GetX(), x2 = EndPos.GetX();
int y1 = StartPos.GetY(), y2 = EndPos.GetY();
......@@ -107,7 +107,7 @@ void vtkInteractorStyleDrawPolygon::OnMouseMove()
this->EndPosition[0] = this->Interactor->GetEventPosition()[0];
this->EndPosition[1] = this->Interactor->GetEventPosition()[1];
int* size = this->Interactor->GetRenderWindow()->GetSize();
const int* size = this->Interactor->GetRenderWindow()->GetSize();
if (this->EndPosition[0] > (size[0] - 1))
{
this->EndPosition[0] = size[0] - 1;
......@@ -155,7 +155,7 @@ void vtkInteractorStyleDrawPolygon::OnLeftButtonDown()
this->PixelArray->Initialize();
this->PixelArray->SetNumberOfComponents(3);
int* size = renWin->GetSize();
const int* size = renWin->GetSize();
this->PixelArray->SetNumberOfTuples(size[0] * size[1]);
renWin->GetPixelData(0, 0, size[0] - 1, size[1] - 1, 1, this->PixelArray);
......@@ -174,7 +174,7 @@ void vtkInteractorStyleDrawPolygon::OnLeftButtonUp()
if (this->DrawPolygonPixels)
{
int* size = this->Interactor->GetRenderWindow()->GetSize();
const int* size = this->Interactor->GetRenderWindow()->GetSize();
unsigned char* pixels = this->PixelArray->GetPointer(0);
this->Interactor->GetRenderWindow()->SetPixelData(0, 0, size[0] - 1, size[1] - 1, pixels, 0);
this->Interactor->GetRenderWindow()->Frame();
......@@ -191,7 +191,7 @@ void vtkInteractorStyleDrawPolygon::DrawPolygon()
vtkNew<vtkUnsignedCharArray> tmpPixelArray;
tmpPixelArray->DeepCopy(this->PixelArray);
unsigned char* pixels = tmpPixelArray->GetPointer(0);
int* size = this->Interactor->GetRenderWindow()->GetSize();
const int* size = this->Interactor->GetRenderWindow()->GetSize();
// draw each line segment
for (vtkIdType i = 0; i < this->Internal->GetNumberOfPoints() - 1; i++)
......
......@@ -520,7 +520,7 @@ void vtkInteractorStyleFlight::UpdateMouseSteering(vtkCamera* cam)
//
// we want to steer by an amount proportional to window viewangle and size
// compute dx and dy increments relative to last mouse click
int* size = this->Interactor->GetSize();
const int* size = this->Interactor->GetSize();
double scalefactor = 5 * cam->GetViewAngle() / size[0];
double dx = -(thispos[0] - lastpos[0]) * scalefactor * aspeed;
double dy = (thispos[1] - lastpos[1]) * scalefactor * aspeed;
......
......@@ -478,7 +478,7 @@ void vtkInteractorStyleImage::WindowLevel()
}
else if (this->CurrentImageProperty)
{
int* size = this->CurrentRenderer->GetSize();
const int* size = this->CurrentRenderer->GetSize();
double window = this->WindowLevelInitial[0];
double level = this->WindowLevelInitial[1];
......@@ -570,7 +570,7 @@ void vtkInteractorStyleImage::Slice()
viewportHeight = 2.0 * distance * tan(0.5 * angle);
}
int* size = this->CurrentRenderer->GetSize();
const int* size = this->CurrentRenderer->GetSize();
double delta = dy * viewportHeight / size[1];
distance += delta;
......
......@@ -226,7 +226,7 @@ void vtkInteractorStyleJoystickCamera::Rotate()
double dy = rwi->GetEventPosition()[1] - center[1];
double* vp = this->CurrentRenderer->GetViewport();
int* size = rwi->GetSize();
const int* size = rwi->GetSize();
double delta_elevation = -20.0 / ((vp[3] - vp[1]) * size[1]);
double delta_azimuth = -20.0 / ((vp[2] - vp[0]) * size[0]);
......
......@@ -70,7 +70,7 @@ void vtkInteractorStyleRubberBand2D::OnLeftButtonDown()
this->PixelArray->Initialize();
this->PixelArray->SetNumberOfComponents(4);
int* size = renWin->GetSize();
const int* size = renWin->GetSize();
this->PixelArray->SetNumberOfTuples(size[0] * size[1]);
renWin->GetRGBACharPixelData(0, 0, size[0] - 1, size[1] - 1, 1, this->PixelArray);
......@@ -88,7 +88,7 @@ void vtkInteractorStyleRubberBand2D::OnLeftButtonUp()
this->Interaction = NONE;
// Clear the rubber band
int* size = this->Interactor->GetRenderWindow()->GetSize();
const int* size = this->Interactor->GetRenderWindow()->GetSize();
unsigned char* pixels = this->PixelArray->GetPointer(0);
this->Interactor->GetRenderWindow()->SetRGBACharPixelData(
0, 0, size[0] - 1, size[1] - 1, pixels, 0);
......@@ -205,7 +205,7 @@ void vtkInteractorStyleRubberBand2D::OnMouseMove()
{
this->EndPosition[0] = this->Interactor->GetEventPosition()[0];
this->EndPosition[1] = this->Interactor->GetEventPosition()[1];
int* size = this->Interactor->GetRenderWindow()->GetSize();
const int* size = this->Interactor->GetRenderWindow()->GetSize();
if (this->EndPosition[0] > (size[0] - 1))
{
this->EndPosition[0] = size[0] - 1;
......@@ -275,7 +275,7 @@ void vtkInteractorStyleRubberBand2D::OnMouseWheelBackward()
void vtkInteractorStyleRubberBand2D::RedrawRubberBand()
{
// Update the rubber band on the screen
int* size = this->Interactor->GetRenderWindow()->GetSize();
const int* size = this->Interactor->GetRenderWindow()->GetSize();
vtkUnsignedCharArray* tmpPixelArray = vtkUnsignedCharArray::New();
tmpPixelArray->DeepCopy(this->PixelArray);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment