mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge remote-tracking branch 'refs/remotes/origin/dev'
This commit is contained in:
@@ -40,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -78,6 +79,7 @@ ${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuMessagePanel.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
@@ -106,6 +108,7 @@ ${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h
|
||||
)
|
||||
|
||||
list(APPEND QT_UI_FILES
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "RiuDragDrop.h"
|
||||
#include "RiuMdiSubWindow.h"
|
||||
#include "RiuMessagePanel.h"
|
||||
#include "RiuProcessMonitor.h"
|
||||
#include "RiuProjectPropertyView.h"
|
||||
#include "RiuPropertyViewTabWidget.h"
|
||||
@@ -587,6 +588,15 @@ void RiuMainWindow::createDockPanels()
|
||||
addDockWidget(Qt::BottomDockWidgetArea, dockPanel);
|
||||
}
|
||||
|
||||
{
|
||||
QDockWidget* dockWidget = new QDockWidget("Messages", this);
|
||||
dockWidget->setObjectName("dockMessages");
|
||||
m_messagePanel = new RiuMessagePanel(dockWidget);
|
||||
dockWidget->setWidget(m_messagePanel);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
|
||||
dockWidget->hide();
|
||||
}
|
||||
|
||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
|
||||
}
|
||||
@@ -801,6 +811,14 @@ RiuResultQwtPlot* RiuMainWindow::resultPlot()
|
||||
return m_resultQwtPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMessagePanel* RiuMainWindow::messagePanel()
|
||||
{
|
||||
return m_messagePanel;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -37,17 +37,20 @@ class QSpinBox;
|
||||
class QUndoView;
|
||||
|
||||
class RimCase;
|
||||
|
||||
class RiuMessagePanel;
|
||||
class RiuProcessMonitor;
|
||||
class RiuResultInfoPanel;
|
||||
class RiuViewer;
|
||||
class RiuResultQwtPlot;
|
||||
class RiuViewer;
|
||||
|
||||
struct RimMdiWindowGeometry;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiTreeView;
|
||||
class AnimationToolBar;
|
||||
class PdmObject;
|
||||
class PdmObject;
|
||||
class PdmUiPropertyView;
|
||||
class PdmUiItem;
|
||||
}
|
||||
@@ -109,7 +112,8 @@ public:
|
||||
QMdiSubWindow* findMdiSubWindow(QWidget* viewer);
|
||||
QList<QMdiSubWindow*> subWindowList(QMdiArea::WindowOrder order);
|
||||
|
||||
RiuResultQwtPlot* resultPlot();
|
||||
RiuResultQwtPlot* resultPlot();
|
||||
RiuMessagePanel* messagePanel();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
@@ -158,6 +162,7 @@ private:
|
||||
RiuViewer* m_mainViewer;
|
||||
RiuResultInfoPanel* m_resultInfoPanel;
|
||||
RiuProcessMonitor* m_processMonitor;
|
||||
QPointer<RiuMessagePanel> m_messagePanel;
|
||||
|
||||
RiuResultQwtPlot* m_resultQwtPlot;
|
||||
|
||||
|
||||
213
ApplicationCode/UserInterface/RiuMessagePanel.cpp
Normal file
213
ApplicationCode/UserInterface/RiuMessagePanel.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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 "RiuMessagePanel.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QMenu>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMessagePanel::RiuMessagePanel(QDockWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
|
||||
m_textEdit = new QPlainTextEdit;
|
||||
m_textEdit->setReadOnly(true);
|
||||
m_textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
m_textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(m_textEdit, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(slotShowContextMenu(const QPoint&)));
|
||||
|
||||
layout->addWidget(m_textEdit);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanel::addMessage(RILogLevel messageLevel, const QString& msg, const QString& srcInfo)
|
||||
{
|
||||
QColor clr(Qt::black);
|
||||
if (messageLevel == RI_LL_ERROR) clr = Qt::red;
|
||||
else if (messageLevel == RI_LL_WARNING) clr = QColor(220,100,10);
|
||||
else if (messageLevel == RI_LL_DEBUG) clr = QColor(100,100,200);
|
||||
|
||||
QTextCharFormat form = m_textEdit->currentCharFormat();
|
||||
form.setForeground(clr);
|
||||
form.setFontWeight(messageLevel == RI_LL_ERROR ? QFont::DemiBold : QFont::Normal);
|
||||
form.setFontItalic(messageLevel == RI_LL_DEBUG ? true : false);
|
||||
m_textEdit->setCurrentCharFormat(form);
|
||||
m_textEdit->appendPlainText(msg);
|
||||
|
||||
if (!srcInfo.isEmpty())
|
||||
{
|
||||
form.setForeground(clr);
|
||||
form.setFontWeight(QFont::Normal);
|
||||
form.setFontItalic(true);
|
||||
m_textEdit->setCurrentCharFormat(form);
|
||||
m_textEdit->appendPlainText(" " + srcInfo);
|
||||
}
|
||||
|
||||
m_textEdit->moveCursor(QTextCursor::End);
|
||||
m_textEdit->ensureCursorVisible();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuMessagePanel::sizeHint() const
|
||||
{
|
||||
return QSize(20, 20);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanel::slotShowContextMenu(const QPoint& pos)
|
||||
{
|
||||
QMenu* menu = m_textEdit->createStandardContextMenu();
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction("Clear All &Messages", this, SLOT(slotClearMessages()));
|
||||
|
||||
menu->exec(m_textEdit->mapToGlobal(pos));
|
||||
|
||||
delete menu;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanel::slotClearMessages()
|
||||
{
|
||||
m_textEdit->clear();
|
||||
RI_LOG_INFO("Message window cleared.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMessagePanelLogger::RiuMessagePanelLogger(RiuMessagePanel* messagePanel)
|
||||
: m_messagePanel(messagePanel),
|
||||
m_logLevel(RI_LL_WARNING)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuMessagePanelLogger::level() const
|
||||
{
|
||||
return m_logLevel;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanelLogger::setLevel(int logLevel)
|
||||
{
|
||||
m_logLevel = logLevel;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanelLogger::error(const char* message, const char* fileName, int lineNumber)
|
||||
{
|
||||
writeToMessagePanel(RI_LL_ERROR, message, fileName, lineNumber);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanelLogger::warning(const char* message, const char* fileName, int lineNumber)
|
||||
{
|
||||
writeToMessagePanel(RI_LL_WARNING, message, fileName, lineNumber);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanelLogger::info(const char* message, const char* fileName, int lineNumber)
|
||||
{
|
||||
writeToMessagePanel(RI_LL_INFO, message, fileName, lineNumber);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanelLogger::debug(const char* message, const char* fileName, int lineNumber)
|
||||
{
|
||||
writeToMessagePanel(RI_LL_DEBUG, message, fileName, lineNumber);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessagePanelLogger::writeToMessagePanel(RILogLevel messageLevel, const char* message, const char* fileName, int lineNumber)
|
||||
{
|
||||
if (messageLevel > m_logLevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_messagePanel)
|
||||
{
|
||||
QString codeLocation;
|
||||
if (messageLevel == RI_LL_ERROR)
|
||||
{
|
||||
codeLocation = QString("(file %1, line %2)").arg(RiaLogger::shortFileName(fileName)).arg(lineNumber);
|
||||
}
|
||||
|
||||
m_messagePanel->addMessage(messageLevel, message, codeLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
80
ApplicationCode/UserInterface/RiuMessagePanel.h
Normal file
80
ApplicationCode/UserInterface/RiuMessagePanel.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// 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 "RiaLogging.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
class QDockWidget;
|
||||
class QPlainTextEdit;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuMessagePanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RiuMessagePanel(QDockWidget* parent);
|
||||
|
||||
void addMessage(RILogLevel messageLevel, const QString& msg, const QString& srcInfo);
|
||||
virtual QSize sizeHint () const;
|
||||
|
||||
private slots:
|
||||
void slotShowContextMenu(const QPoint& pos);
|
||||
void slotClearMessages();
|
||||
|
||||
private:
|
||||
QPointer<QPlainTextEdit> m_textEdit;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiuMessagePanelLogger : public RiaLogger
|
||||
{
|
||||
public:
|
||||
RiuMessagePanelLogger(RiuMessagePanel* messagePanel);
|
||||
|
||||
virtual int level() const override;
|
||||
virtual void setLevel(int logLevel) override;
|
||||
|
||||
virtual void error( const char* message, const char* fileName, int lineNumber) override;
|
||||
virtual void warning(const char* message, const char* fileName, int lineNumber) override;
|
||||
virtual void info( const char* message, const char* fileName, int lineNumber) override;
|
||||
virtual void debug( const char* message, const char* fileName, int lineNumber) override;
|
||||
|
||||
private:
|
||||
void writeToMessagePanel(RILogLevel messageLevel, const char* message, const char* fileName, int lineNumber);
|
||||
|
||||
private:
|
||||
QPointer<RiuMessagePanel> m_messagePanel;
|
||||
int m_logLevel;
|
||||
};
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
#include "cvfOverlayAxisCross.h"
|
||||
#include "cvfOverlayScalarMapperLegend.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfTransform.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
|
||||
Reference in New Issue
Block a user