Help to undestand of overloading DoResize() method.

Hi everyone could somebody explain me about overloading DoResize() method, in class inherited from Aspect_Window.
As in example /OCCT/samples/qt/OCCTOverview
file:OcctWindow.h

Aspect_TypeOfResize OcctWindow::DoResize()
{
  int                 aMask = 0;
  Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;

  if (!myWidget->isMinimized())
  {
    if (Abs(myWidget->rect().left() - myXLeft) > 2)
    {
      aMask |= 1;
    }
    if (Abs(myWidget->rect().right() - myXRight) > 2)
    {
      aMask |= 2;
    }
    if (Abs(myWidget->rect().top() - myYTop) > 2)
    {
      aMask |= 4;
    }
    if (Abs(myWidget->rect().bottom() - myYBottom) > 2)
    {
      aMask |= 8;
    }

    switch (aMask)
    {
    case 0:
      aMode = Aspect_TOR_NO_BORDER;
      break;
    case 1:
      aMode = Aspect_TOR_LEFT_BORDER;
      break;
    case 2:
      aMode = Aspect_TOR_RIGHT_BORDER;
      break;
    case 4:
      aMode = Aspect_TOR_TOP_BORDER;
      break;
    case 5:
      aMode = Aspect_TOR_LEFT_AND_TOP_BORDER;
      break;
    case 6:
      aMode = Aspect_TOR_TOP_AND_RIGHT_BORDER;
      break;
    case 8:
      aMode = Aspect_TOR_BOTTOM_BORDER;
      break;
    case 9:
      aMode = Aspect_TOR_BOTTOM_AND_LEFT_BORDER;
      break;
    case 10:
      aMode = Aspect_TOR_RIGHT_AND_BOTTOM_BORDER;
      break;
    default:
      break;
    }  // end switch

    myXLeft   = myWidget->rect().left();
    myXRight  = myWidget->rect().right();
    myYTop    = myWidget->rect().top();
    myYBottom = myWidget->rect().bottom();
  }

  return aMode;
}

I can't understand where is updating process triggered?

gkv311 n's picture

OCCT itself never calls Aspect_Window::DoResize() method. You may find it's being called only within application code using Aspect_Window subclasses in places like ViewerTest_EventManager (ViewerTest is a DRAW Harness plugin for 3D Viewer):

void ViewerTest_EventManager::ProcessConfigure (bool theIsResized)
{
...
  aParent->Window()->DoResize();
  aParent->MustBeResized();
  aParent->Invalidate();
...
  FlushViewEvents (myCtx, myView, true);
}

or GlfwOcctView (from samples/glfw):

void GlfwOcctView::onResize (int theWidth, int theHeight)
{
  if (theWidth  != 0
   && theHeight != 0
   && !myView.IsNull())
  {
    myView->Window()->DoResize();
    myView->MustBeResized();
    myView->Invalidate();
    myView->Redraw();
  }
}

Therefore, this method is called within routines handling resize/configure events coming from platform-specific window system. DoResize() usually doesn't do anything with windows itself or with 3D view - it is only one of the steps in updating the viewer, usually just updating cached values inside Aspect_Window storing window dimensions/position.

Note that returned Aspect_TypeOfResize has no practical usage nowadays. Subclasses still implement this interface but OCCT itself ignores returned values.