#168 Merged in parallel projection

This commit is contained in:
Jacob Støren
2016-08-16 23:20:33 +02:00
26 changed files with 9904 additions and 26 deletions

View File

@@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
@@ -92,6 +93,7 @@ ${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp

View File

@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicTogglePerspectiveViewFeature.h"
#include "RiuViewer.h"
#include "RimView.h"
#include "RiuMainWindow.h"
#include "RiaApplication.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicTogglePerspectiveViewFeature, "RicTogglePerspectiveViewFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicTogglePerspectiveViewFeature::isCommandEnabled()
{
this->action(); // Retrieve the action to update the looks
return RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTogglePerspectiveViewFeature::onActionTriggered(bool isChecked)
{
if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer())
{
bool isPerspective = RiaApplication::instance()->activeReservoirView()->isPerspectiveView();
RiaApplication::instance()->activeReservoirView()->isPerspectiveView = !isPerspective;
RiaApplication::instance()->activeReservoirView()->viewer()->enableParallelProjection(isPerspective);
RiaApplication::instance()->activeReservoirView()->isPerspectiveView.uiCapability()->updateConnectedEditors();
this->action(); // Retrieve the action to update the looks
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicTogglePerspectiveViewFeature::setupActionLook(QAction* actionToSetup)
{
if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer())
{
if (RiaApplication::instance()->activeReservoirView()->isPerspectiveView())
{
actionToSetup->setText("Parallel View");
actionToSetup->setIcon(QIcon(":/Parallel16x16.png"));
return;
}
}
actionToSetup->setText("Perspective View");
actionToSetup->setIcon(QIcon(":/Perspective16x16.png"));
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
// Copyright (C) 2016- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicTogglePerspectiveViewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@@ -135,12 +135,24 @@ void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
std::vector<bool> faceVisibility(6, false);
for (size_t i = POS_X; i <= NEG_Z; i++)
{
bool isFaceVisible = false;
cvf::Vec3f sideNorm = sideNormalOutwards((FaceType)i);
cvf::Vec3d camToSide = camera->position() - pointOnSide((FaceType)i);
camToSide.normalize();
if (camera->projection() == cvf::Camera::PERSPECTIVE)
{
if (sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0)
cvf::Vec3d camToSide = camera->position() - pointOnSide((FaceType)i);
camToSide.normalize();
isFaceVisible = sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0;
}
else
{
cvf::Vec3d camToSide = camera->direction();
isFaceVisible = sideNorm.dot(cvf::Vec3f(camToSide)) > 0.0;
}
if (isFaceVisible)
{
m_gridBoxModel->addPart(m_gridBoxFaceParts[i].p());
faceVisibility[i] = true;

View File

@@ -35,6 +35,7 @@
#include <QFile>
#include <QTextStream>
#include "cvfUniform.h"
//--------------------------------------------------------------------------------------------------
@@ -196,6 +197,8 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect)
cvf::ref<cvf::ShaderProgram> prog = shaderGen.generate();
eff->setShaderProgram(prog.p());
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
// Set up textures
m_edgeTextureImage = new cvf::TextureImage;

View File

@@ -32,6 +32,7 @@
#include "cvfShaderSourceProvider.h"
#include "cvfTexture.h"
#include "cvfTexture2D_FF.h"
#include "cvfUniform.h"
@@ -81,6 +82,8 @@ void RivTernaryScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::E
cvf::ref<cvf::ShaderProgram> prog = gen.generate();
eff->setShaderProgram(prog.p());
if(!m_disableLighting) prog->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5, 5.0, 7.0)));
// Result mapping texture
m_textureImage = new cvf::TextureImage();

View File

@@ -75,11 +75,14 @@ RimView::RimView(void)
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
cameraPosition.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", "");
cameraPointOfInterest.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", "");
isPerspectiveView.uiCapability()->setUiHidden(true); // For now as this is experimental
double defaultScaleFactor = preferences->defaultScaleFactorZ;
CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "");
@@ -216,7 +219,12 @@ void RimView::updateViewerWidget()
RiuMainWindow::instance()->setActiveViewer(m_viewer->layoutWidget());
if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition);
if(isViewerCreated)
{
m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->setPointOfInterest(cameraPointOfInterest());
m_viewer->enableParallelProjection(!isPerspectiveView());
}
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
this->updateGridBoxData();
@@ -322,6 +330,7 @@ void RimView::createDisplayModelAndRedraw()
{
setDefaultView();
cameraPosition = m_viewer->mainCamera()->viewMatrix();
cameraPointOfInterest = m_viewer->pointOfInterest();
}
}
@@ -360,6 +369,7 @@ void RimView::setupBeforeSave()
{
hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice...
cameraPosition = m_viewer->mainCamera()->viewMatrix();
cameraPointOfInterest = m_viewer->pointOfInterest();
setMdiWindowGeometry(RiuMainWindow::instance()->windowGeometryForViewer(m_viewer->layoutWidget()));
}

View File

@@ -25,6 +25,7 @@
#include "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "RivCellSetEnum.h"
@@ -79,6 +80,7 @@ public:
caf::PdmField<bool> showWindow;
caf::PdmField<cvf::Mat4d> cameraPosition;
caf::PdmField<cvf::Vec3d> cameraPointOfInterest;
caf::PdmField<bool> isPerspectiveView;
caf::PdmField< cvf::Color3f > backgroundColor;

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

View File

@@ -61,6 +61,8 @@
<file>SummaryPlots16x16.png</file>
<file>SummaryCurve16x16.png</file>
<file>SummaryCurveFilter16x16.png</file>
<file>Parallel16x16.png</file>
<file>Perspective16x16.png</file>
</qresource>
<qresource prefix="/Shader/">

View File

@@ -514,6 +514,7 @@ void RiuMainWindow::createToolBars()
// View toolbar
m_viewToolBar = addToolBar(tr("View"));
m_viewToolBar->setObjectName(m_viewToolBar->windowTitle());
m_viewToolBar->addAction(cmdFeatureMgr->action("RicTogglePerspectiveViewFeature"));
m_viewToolBar->addAction(m_zoomAll);
m_viewToolBar->addAction(m_viewFromNorth);
m_viewToolBar->addAction(m_viewFromSouth);
@@ -723,7 +724,7 @@ void RiuMainWindow::slotRefreshViewActions()
updateScaleValue();
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature");
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature" << "RicTogglePerspectiveViewFeature");
}
//--------------------------------------------------------------------------------------------------

View File

@@ -183,6 +183,7 @@ RiuViewer::~RiuViewer()
m_rimView->uiCapability()->updateUiIconFromToggleField();
m_rimView->cameraPosition = m_mainCamera->viewMatrix();
m_rimView->cameraPointOfInterest = pointOfInterest();
}
delete m_infoLabel;
delete m_animationProgress;