mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1116 Added RiuNightchartsWidget
This commit is contained in:
@@ -40,6 +40,7 @@ ${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.h
|
${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.h
|
||||||
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h
|
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h
|
||||||
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
|
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -78,6 +79,7 @@ ${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.cpp
|
${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.cpp
|
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.cpp
|
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
@@ -105,6 +107,7 @@ ${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h
|
${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h
|
||||||
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h
|
${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h
|
||||||
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
|
${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND QT_UI_FILES
|
list(APPEND QT_UI_FILES
|
||||||
|
|||||||
79
ApplicationCode/UserInterface/RiuNightchartsWidget.cpp
Normal file
79
ApplicationCode/UserInterface/RiuNightchartsWidget.cpp
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RiuNightchartsWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiuNightchartsWidget::RiuNightchartsWidget(QWidget* parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuNightchartsWidget::setType(Nightcharts::type t)
|
||||||
|
{
|
||||||
|
m_chart.setType(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuNightchartsWidget::clear()
|
||||||
|
{
|
||||||
|
m_chart = Nightcharts();
|
||||||
|
m_chart.setType(Nightcharts::Pie);
|
||||||
|
m_chart.setLegendType(Nightcharts::Vertical);
|
||||||
|
|
||||||
|
m_marginLeft = 16;
|
||||||
|
m_marginTop = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuNightchartsWidget::paintEvent(QPaintEvent* e)
|
||||||
|
{
|
||||||
|
QWidget::paintEvent(e);
|
||||||
|
|
||||||
|
if(!m_chart.pieceCount()) return ;
|
||||||
|
|
||||||
|
QPainter painter;
|
||||||
|
QFont font;
|
||||||
|
painter.begin(this);
|
||||||
|
int w = (this->width() - m_marginLeft - 150);
|
||||||
|
int h = (this->height() - m_marginTop - 100);
|
||||||
|
int size = (w<h)?w:h;
|
||||||
|
m_chart.setCords(m_marginLeft, m_marginTop,size, size);
|
||||||
|
|
||||||
|
m_chart.draw(&painter);
|
||||||
|
m_chart.drawLegend(&painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuNightchartsWidget::addItem(QString name, QColor color, float value)
|
||||||
|
{
|
||||||
|
m_chart.addPiece(name,color,value);
|
||||||
|
}
|
||||||
48
ApplicationCode/UserInterface/RiuNightchartsWidget.h
Normal file
48
ApplicationCode/UserInterface/RiuNightchartsWidget.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "nightcharts/nightcharts.h"
|
||||||
|
|
||||||
|
#include "cafPdmPointer.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
|
||||||
|
|
||||||
|
class RiuNightchartsWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit RiuNightchartsWidget(QWidget* parent = 0);
|
||||||
|
|
||||||
|
void addItem(QString name, QColor color, float value);
|
||||||
|
void setType(Nightcharts::type type);
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paintEvent(QPaintEvent* e);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Nightcharts m_chart;
|
||||||
|
int m_marginLeft;
|
||||||
|
int m_marginTop;
|
||||||
|
};
|
||||||
|
|
||||||
Reference in New Issue
Block a user