mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge branch 'dev' of https://github.com/OPM/ResInsight.git
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicExportMultipleSnapshotsFeature.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimMultiSnapshotDefinition.h"
|
||||
#include "RimProject.h"
|
||||
@@ -40,13 +42,14 @@
|
||||
#include <QTableView>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
#include <QHeaderView>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* parent, RimProject* project)
|
||||
: QDialog(parent),
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
m_rimProject(project)
|
||||
{
|
||||
setWindowTitle("Export Multiple Snapshots");
|
||||
@@ -66,6 +69,9 @@ RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* pare
|
||||
|
||||
m_pdmTableView->setListField(&(project->multiSnapshotDefinitions()));
|
||||
|
||||
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
|
||||
verticalHeader->setResizeMode(QHeaderView::Interactive);
|
||||
|
||||
// Set active child array to be able to use generic delete
|
||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(project->multiSnapshotDefinitions()));
|
||||
|
||||
@@ -80,13 +86,13 @@ RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* pare
|
||||
// Save images in snapshot catalog relative to project directory
|
||||
QString snapshotFolderName = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("snapshots");
|
||||
|
||||
m_lineEdit = new QLineEdit(snapshotFolderName);
|
||||
m_exportFolderLineEdit = new QLineEdit(snapshotFolderName);
|
||||
|
||||
QToolButton* button = new QToolButton;
|
||||
button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
|
||||
button->setText(QLatin1String("..."));
|
||||
|
||||
layout->addWidget(m_lineEdit);
|
||||
layout->addWidget(m_exportFolderLineEdit);
|
||||
layout->addWidget(button);
|
||||
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(folderSelectionClicked()));
|
||||
@@ -143,7 +149,6 @@ void RiuExportMultipleSnapshotsWidget::customMenuRequested(QPoint pos)
|
||||
menu.exec(globalPos);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -156,32 +161,29 @@ void RiuExportMultipleSnapshotsWidget::deleteAllSnapshotItems()
|
||||
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuExportMultipleSnapshotsWidget::exportSnapshots()
|
||||
{
|
||||
// TODO: wire up call of static method
|
||||
// RicExportMultipleSnapshotsFeature::staticMethod()
|
||||
RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(m_exportFolderLineEdit->text(), m_rimProject);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuExportMultipleSnapshotsWidget::folderSelectionClicked()
|
||||
{
|
||||
QString defaultPath = m_lineEdit->text();
|
||||
QString defaultPath = m_exportFolderLineEdit->text();
|
||||
|
||||
QString directoryPath = QFileDialog::getExistingDirectory(m_lineEdit,
|
||||
QString directoryPath = QFileDialog::getExistingDirectory(m_exportFolderLineEdit,
|
||||
tr("Get existing directory"),
|
||||
defaultPath,
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!directoryPath.isEmpty())
|
||||
{
|
||||
m_lineEdit->setText(directoryPath);
|
||||
m_exportFolderLineEdit->setText(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,54 +196,38 @@ void RiuExportMultipleSnapshotsWidget::addSnapshotItem()
|
||||
|
||||
RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition();
|
||||
|
||||
|
||||
//Getting default value from last entered line:
|
||||
if (m_rimProject->multiSnapshotDefinitions.size() > 0)
|
||||
{
|
||||
//Getting default value from last entered line:
|
||||
RimMultiSnapshotDefinition* other = m_rimProject->multiSnapshotDefinitions[m_rimProject->multiSnapshotDefinitions.size() - 1];
|
||||
|
||||
multiSnapshot->caseObject = other->caseObject();
|
||||
multiSnapshot->viewObject = other->viewObject();
|
||||
multiSnapshot->timeStepStart = other->timeStepStart();
|
||||
multiSnapshot->timeStepEnd = other->timeStepEnd();
|
||||
|
||||
|
||||
// Variant using copy based on xml string
|
||||
// QString copyOfOriginalObject = other->writeObjectToXmlString();
|
||||
// multiSnapshot->readObjectFromXmlString(copyOfOriginalObject, caf::PdmDefaultObjectFactory::instance());
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
RimCase* CaseExample = nullptr;
|
||||
RimView* ViewExample = nullptr;
|
||||
|
||||
if (cases.size() > 0)
|
||||
{
|
||||
CaseExample = cases.at(0);
|
||||
multiSnapshot->caseObject = CaseExample;
|
||||
RimCase* caseExample = cases.at(0);
|
||||
|
||||
std::vector<RimView*> viewExamples;
|
||||
viewExamples = CaseExample->views();
|
||||
viewExamples = caseExample->views();
|
||||
|
||||
if (viewExamples.size() > 0)
|
||||
{
|
||||
ViewExample = viewExamples.at(0);
|
||||
multiSnapshot->viewObject = ViewExample;
|
||||
RimView* viewExample = viewExamples.at(0);
|
||||
multiSnapshot->viewObject = viewExample;
|
||||
multiSnapshot->timeStepStart = viewExample->currentTimeStep();
|
||||
multiSnapshot->timeStepEnd = viewExample->currentTimeStep();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
|
||||
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
@@ -47,5 +47,5 @@ private slots:
|
||||
private:
|
||||
RimProject* m_rimProject;
|
||||
caf::PdmUiTableView* m_pdmTableView;
|
||||
QLineEdit* m_lineEdit;
|
||||
QLineEdit* m_exportFolderLineEdit;
|
||||
};
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "cafCategoryLegend.h"
|
||||
#include "cafCeetronPlusNavigation.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafFrameAnimationControl.h"
|
||||
|
||||
@@ -170,8 +171,9 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
|
||||
m_gridBoxGenerator = new RivGridBoxGenerator;
|
||||
}
|
||||
|
||||
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -408,6 +410,29 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
|
||||
m_versionInfoLabel->render(painter, pos);
|
||||
yPos += size.height() + margin;
|
||||
}
|
||||
|
||||
if (!m_cursorPositionDomainCoords.isUndefined())
|
||||
{
|
||||
if (mainCamera())
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
|
||||
|
||||
cvf::Vec3d displayCoord = trans->transformToDisplayCoord(m_cursorPositionDomainCoords);
|
||||
|
||||
cvf::Vec3d screenCoords;
|
||||
if (mainCamera()->project(displayCoord, &screenCoords))
|
||||
{
|
||||
int translatedMousePosY = height() - screenCoords.y();
|
||||
QPoint centerPos(screenCoords.x(), translatedMousePosY);
|
||||
|
||||
// Draw a cross hair marker
|
||||
int markerHalfLength = 6;
|
||||
|
||||
painter->drawLine(centerPos.x(), centerPos.y() - markerHalfLength, centerPos.x(), centerPos.y() + markerHalfLength);
|
||||
painter->drawLine(centerPos.x() - markerHalfLength, centerPos.y(), centerPos.x() + markerHalfLength, centerPos.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -658,6 +683,54 @@ void RiuViewer::resizeGL(int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
|
||||
{
|
||||
if (m_rimView)
|
||||
{
|
||||
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
||||
if (viewLinker)
|
||||
{
|
||||
int translatedMousePosX = mouseEvent->pos().x();
|
||||
int translatedMousePosY = height() - mouseEvent->pos().y();
|
||||
|
||||
cvf::Vec3d displayCoord(0, 0, 0);
|
||||
if (mainCamera()->unproject(cvf::Vec3d(static_cast<double>(translatedMousePosX), static_cast<double>(translatedMousePosY), 0), &displayCoord))
|
||||
{
|
||||
if (m_cursorPositionDomainCoords != cvf::Vec3d::UNDEFINED)
|
||||
{
|
||||
// Reset the extra cursor if the view currently is receiving mouse cursor events
|
||||
// Set undefined and redraw to remove the previously displayed cursor
|
||||
m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> trans = m_rimView->displayCoordTransform();
|
||||
cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord);
|
||||
|
||||
viewLinker->updateCursorPosition(m_rimView, domainCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
caf::Viewer::mouseMoveEvent(mouseEvent);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::leaveEvent(QEvent *)
|
||||
{
|
||||
if (m_rimView && m_rimView->assosiatedViewLinker())
|
||||
{
|
||||
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
|
||||
viewLinker->updateCursorPosition(m_rimView, cvf::Vec3d::UNDEFINED);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -755,6 +828,19 @@ void RiuViewer::updateParallelProjectionSettings(RiuViewer* sourceViewer)
|
||||
this->updateParallelProjectionCameraPosFromPointOfInterestMove(poi);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::setCursorPosition(const cvf::Vec3d& domainCoord)
|
||||
{
|
||||
if (m_cursorPositionDomainCoords != domainCoord)
|
||||
{
|
||||
m_cursorPositionDomainCoords = domainCoord;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -96,6 +96,8 @@ public:
|
||||
|
||||
void updateParallelProjectionSettings(RiuViewer* sourceViewer);
|
||||
|
||||
void setCursorPosition(const cvf::Vec3d& domainCoord);
|
||||
|
||||
public slots:
|
||||
virtual void slotSetCurrentFrame(int frameIndex);
|
||||
virtual void slotEndAnimation();
|
||||
@@ -103,6 +105,8 @@ public slots:
|
||||
protected:
|
||||
virtual void optimizeClippingPlanes();
|
||||
virtual void resizeGL(int width, int height);
|
||||
virtual void mouseMoveEvent(QMouseEvent* e) override;
|
||||
virtual void leaveEvent(QEvent *) override;
|
||||
|
||||
private:
|
||||
void updateTextAndTickMarkColorForOverlayItems();
|
||||
@@ -140,5 +144,7 @@ private:
|
||||
RiuViewerCommands* m_viewerCommands;
|
||||
|
||||
RivGridBoxGenerator* m_gridBoxGenerator;
|
||||
|
||||
cvf::Vec3d m_cursorPositionDomainCoords;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user