-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing global RenderingManager access from QmitkRenderWindowWidget and QmitkStdMultiWidget. #248
base: master
Are you sure you want to change the base?
Conversation
Hi, can you please explain your changes and why they are necessary? Thx! edit: Nevermind, found your email on the mitk-users list. :-) However, there are some formatting issues and modified lines that go beyond the declared scope. Please check again to really narrow down this pull request to the absolutely necessary. |
Hi, I reviewed the code and I believe all changes are needed to solve the global access to RenderingManager. Can you indicate which line is causing trouble? I think an explanation in the changes made on The original code had those lines:
This sets
Different from Using
NOTE: I have a minimal test application for the changes in the code, but I don't know how/where I should add to the project. |
My original idea was to use But |
So first of all thank you for your time and code suggestions. It is definitely worth taking a look at the different ways to initialize the view / geometry of the render windows. The I will review your changes but in the meantime it might be useful to understand your use case and why you think it is necessary to extend the render window widget. |
mitk::BaseRenderer::GetInstance(m_RenderWindow->GetRenderWindow())->SetDataStorage(dataStorage); | ||
} | ||
mitk::BaseRenderer::GetInstance(m_RenderWindow->GetRenderWindow())->SetDataStorage(dataStorage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed here. Please don't change formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the indentation, in my IDE everything looks normal.This happened after my push to github, I will see how to solve this formatting issue.
@@ -633,7 +637,7 @@ void QmitkStdMultiWidget::AddDisplayPlaneSubTree() | |||
// ... of widget 1 | |||
mitk::BaseRenderer* renderer1 = mitk::BaseRenderer::GetInstance(GetRenderWindow1()->GetRenderWindow()); | |||
m_PlaneNode1 = renderer1->GetCurrentWorldPlaneGeometryNode(); | |||
m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true)); | |||
m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed here. Please don't change formatting.
@@ -196,8 +198,8 @@ void QmitkRenderWindowWidget::InitializeGUI() | |||
|
|||
connect(m_RenderWindow, &QVTKOpenGLWidget::mouseEvent, this, &QmitkRenderWindowWidget::MouseEvent); | |||
|
|||
mitk::TimeGeometry::ConstPointer timeGeometry = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()); | |||
mitk::RenderingManager::GetInstance()->InitializeViews(timeGeometry); | |||
mitk::BaseRenderer::GetInstance(m_RenderWindow->GetRenderWindow())->SetDataStorage(m_DataStorage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree setting the data storage individually for the current render window is the correct way to do it (as it is done in QmitkRenderWindowWidget::SetDataStorage
).
mitk::RenderingManager::GetInstance()->InitializeView(GetRenderWindow1()->GetRenderWindow(), geo); | ||
mitk::RenderingManager::GetInstance()->InitializeView(GetRenderWindow2()->GetRenderWindow(), geo); | ||
mitk::RenderingManager::GetInstance()->InitializeView(GetRenderWindow3()->GetRenderWindow(), geo); | ||
mitk::RenderingManager::GetInstance()->InitializeView(GetRenderWindow4()->GetRenderWindow(), geo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your idea here? You are still initializing each render window to the same geometry, the bounding geometry of every data object in the data storage. This is what mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage);
is actually supposed to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are displaying QmitkStdMultiWidget
and QmitkRenderWindow
both at the same time, each one rendering a different data set, mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage);
would set the geometry from datastorage
rendered by QmitkStdMultiWidget
to QmitkRenderWindow
, the last one may contain different data with different geometries. This is not a issue in MitkWorkbench because, usually, QmitkStdMultiWidget
is the only active render widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you are explicitly initializing only the four render windows of the QmitkStdMultiWidget
so that other render windows (that are registered with the global rendering manager) are not affected here.
I think that is reasonable and makes sense here.
@@ -742,7 +744,7 @@ void QmitkStdMultiWidget::CreateRenderWindowWidgets() | |||
auto renderWindow2 = renderWindowWidget2->GetRenderWindow(); | |||
renderWindow2->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal); | |||
renderWindowWidget2->SetDecorationColor(GetDecorationColor(1)); | |||
renderWindowWidget2->setStyleSheet("border: 0px"); | |||
// renderWindowWidget2->setStyleSheet("border: 0px"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove instead of commenting out.
@@ -196,8 +198,8 @@ void QmitkRenderWindowWidget::InitializeGUI() | |||
|
|||
connect(m_RenderWindow, &QVTKOpenGLWidget::mouseEvent, this, &QmitkRenderWindowWidget::MouseEvent); | |||
|
|||
mitk::TimeGeometry::ConstPointer timeGeometry = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()); | |||
mitk::RenderingManager::GetInstance()->InitializeViews(timeGeometry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this instead of using the code that you added in RequestUpdate
and ForceImmediateUpdate
:
auto geo = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll());
mitk::RenderingManager::GetInstance()->InitializeView(m_RenderWindow->GetRenderWindow(), geo);
This will initialize the view for this specific render window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have two problems:
-
mitk::RenderingManager::GetInstance()->InitializeViews(timeGeometry);
has global scope, it creates the same problem that we have with:
mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage);
See the example I described below. To avoid this I choose to useInitializeView()
instead ofInitializeViews()
. -
I moved the location to
RequestUpdate
andForceImmediateUpdate
, because in the case where data is loaded dynamically, lets say the user clicks an open file button, in this casem_DataStorage
wouldn't have any data atQmitkRenderWidget
's construction time, in which case computing the geometry from an emptym_DataStorage
wouldn't be necessary. Maintaining this piece of code here is actually useful if the path to the data set is specified through command line or has been hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm totally fine with 1.
I think 2. is a fix after changing the render window initialization of the QmitkStdMultiWidget
: Here we do not re-initialize all render windows anymore but only the four render windows of the multi widget. So a single render window widget won't be affected. We need to be able to explicitly re-initialize a single render window widget, right?
Would it make sense to request an update inside InitializeGUI
in case we actually do have some data loaded in the data storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to request an update inside InitializeGUI in case we actually do have some data loaded in the data storage?
Yes it will make sense, I will add a geometry initialization inside the function.
I think 2. is a fix after changing the render window initialization of the
QmitkStdMultiWidget
:
Actually I explicitly initialized the geometries inside QmitkStdMultiWidget
, would you prefer a call to RequestUpdate
instead of mitk::RenderingManager::GetInstance()->InitializeView(GetRenderWindow1()->GetRenderWindow(), geo);
? The result will be the same.
Here we do not re-initialize all render windows anymore but only the four render windows of the multi widget. So a single render window widget won't be affected. We need to be able to explicitly re-initialize a single render window widget, right?
Yes this is the intention, although I ended up not calling RequesUpdate
.
@@ -63,11 +63,15 @@ mitk::SliceNavigationController* QmitkRenderWindowWidget::GetSliceNavigationCont | |||
|
|||
void QmitkRenderWindowWidget::RequestUpdate() | |||
{ | |||
auto geo = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()); | |||
mitk::RenderingManager::GetInstance()->InitializeView(m_RenderWindow->GetRenderWindow(), geo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put this inside the InitializeGUI
-function?
mitk::RenderingManager::GetInstance()->RequestUpdate(m_RenderWindow->GetRenderWindow()); | ||
} | ||
|
||
void QmitkRenderWindowWidget::ForceImmediateUpdate() | ||
{ | ||
auto geo = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()); | ||
mitk::RenderingManager::GetInstance()->InitializeView(m_RenderWindow->GetRenderWindow(), geo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put this inside the InitializeGUI
-function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you again.
We have an experimental version of a QmitkMxNMultiWidget
that allows to have a more general set of render window widgets. After we included your PR it might be worth checking this widget again to see how it behaves with the changes concerning the view initialization of specific render window widgets.
Thanks for your patience. |
@CFornari |
No description provided.