(#395) Moved code from RiuViewer to RimView and cleaned up includes

This commit is contained in:
Magne Sjaastad
2015-09-01 18:21:20 +02:00
parent 4730e10319
commit 379cf6b228
3 changed files with 63 additions and 74 deletions

View File

@@ -6,6 +6,7 @@
#include "Rim3dOverlayInfoConfig.h"
#include "RimCellRangeFilterCollection.h"
#include "RimLinkedViews.h"
#include "RimManagedViewConfig.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellPathCollection.h"
@@ -541,3 +542,49 @@ void RimView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc
{
m_overrideRangeFilterCollection = rfc;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::notifyCameraHasChanged()
{
std::vector<RimView*> viewsToUpdate;
viewsToUpdate.push_back(this);
RimProject* proj = NULL;
this->firstAnchestorOrThisOfType(proj);
RimLinkedViews* linkedViews = proj->findLinkedViewsGroupForView(this);
if (linkedViews)
{
RimManagedViewConfig* viewConf = linkedViews->viewConfigForView(this);
// There is no view config for a master view, but all views for sync must be updated
if (!viewConf || viewConf->syncCamera())
{
std::vector<RimView*> allViews;
linkedViews->allViewsForCameraSync(allViews);
for (size_t i = 0; i < allViews.size(); i++)
{
if (allViews[i] != this)
{
viewsToUpdate.push_back(allViews[i]);
}
}
}
}
// Propagate view matrix to all relevant views
const cvf::Mat4d mat = this->viewer()->mainCamera()->viewMatrix();
for (size_t i = 0; i < viewsToUpdate.size(); i++)
{
if (viewsToUpdate[i] && viewsToUpdate[i]->viewer())
{
viewsToUpdate[i]->viewer()->mainCamera()->setViewMatrix(mat);
viewsToUpdate[i]->viewer()->update();
}
}
}