Commit 5aa49012 authored by Lefebvre, Jordan's avatar Lefebvre, Jordan

Merge branch 'qcp_submodule' into 'master'

radixplot removal in favor of qcpcontext.

See merge request !94
parents affa63e4 874e2bdd
Pipeline #101550 passed with stages
in 20 minutes and 53 seconds
......@@ -12,7 +12,6 @@ TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
glls radixglls SS OPTIONAL
io radixio SS OPTIONAL
geometry radixgeometry SS OPTIONAL
plot radixplot SS OPTIONAL
sparsegrids radixsparsegrids SS OPTIONAL
widgets radixwidgets SS OPTIONAL
ams radixams SS OPTIONAL
......
##---------------------------------------------------------------------------##
## radixplot/CMakeLists.txt
## Jordan P. Lefebvre
## Tuesday May 31 12:50:40 2016
##---------------------------------------------------------------------------##
## CMAKE for radixplot
##---------------------------------------------------------------------------##
TRIBITS_SUBPACKAGE(plot)
##---------------------------------------------------------------------------##
## PACKAGE CONFIGURE FILE
##---------------------------------------------------------------------------##
##---------------------------------------------------------------------------##
## HEADER AND SOURCE FILES
##---------------------------------------------------------------------------##
# C/C++ headers
SET(MOC_HEADERS
plot.hh
)
SET(HEADERS
graph2d.hh
${MOC_HEADERS}
)
#
# Moc the header files
#
IF(USE_QT4)
QT4_WRAP_CPP(MOC_FILES
${MOC_HEADERS}
)
#
# Process qt resource files
QT4_ADD_RESOURCES(RESOURCE_RESULT
${RESOURCE_FILES}
)
ELSE()
QT5_WRAP_CPP(MOC_FILES
${MOC_HEADERS}
)
#
# Process qt resource files
QT5_ADD_RESOURCES(RESOURCE_RESULT
${RESOURCE_FILES}
)
ENDIF()
# C/C++ source
SET(SOURCES
plot.cc
graph2d.cc
)
SET(RESOURCE_FILES
plot.qrc
)
##---------------------------------------------------------------------------##
## PACKAGE TARGETS AND INSTALL
##---------------------------------------------------------------------------##
TRIBITS_ADD_LIBRARY(
radixplot
SOURCES ${SOURCES} ${MOC_FILES} ${RESOURCE_RESULT}
)
INSTALL(FILES ${HEADERS}
DESTINATION include/radixplot)
#
# Add test directory for this package
#
#TRIBITS_ADD_TEST_DIRECTORIES(tests)
#
# Add example directory for this package
#
TRIBITS_ADD_EXAMPLE_DIRECTORIES(examples)
TRIBITS_SUBPACKAGE_POSTPROCESS()
##---------------------------------------------------------------------------##
## end of radixplot/CMakeLists.txt
##---------------------------------------------------------------------------##
##---------------------------------------------------------------------------##
## radixplot/cmake/Dependencies.cmake
## Jordan P. Lefebvre
## Tuesday May 31 12:57:18 2016
##---------------------------------------------------------------------------##
IF(NOT USE_QT5)
SET(USE_QT4 ON)
ENDIF()
IF(USE_QT4)
SET(QT_PACKAGES QT)
ELSE()
SET(QT_PACKAGES Qt5Widgets Qt5Core)
ENDIF()
TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
LIB_REQUIRED_PACKAGES QtSolutions QCustomPlot
LIB_REQUIRED_TPLS ${QT_PACKAGES}
)
##---------------------------------------------------------------------------##
## end of radixplot/cmake/Dependencies.cmake
##---------------------------------------------------------------------------##
# Provide access to QT-generated code
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
IF(USE_QT4)
QT4_WRAP_CPP(QMOC_FILES
mainwindow.hh
)
ELSE()
QT5_WRAP_CPP(QMOC_FILES
mainwindow.hh
)
ENDIF()
SET(SOURCE
mainwindow.cc
)
TRIBITS_ADD_EXECUTABLE(plot2d-examples
NOEXEPREFIX
SOURCES ${SOURCE} ${QMOC_FILES}
)
This diff is collapsed.
#ifndef RADIXPLOT_EXAMPLE_MAINWINDOW_HH_
#define RADIXPLOT_EXAMPLE_MAINWINDOW_HH_
#include <QMainWindow>
#include <QModelIndex>
#include <QStatusBar>
#include <QTimer>
#include <QWidget>
#include "radixplot/plot.hh"
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void setupQuadraticDemo();
void setupSimpleDemo();
void setupSincScatterDemo();
void setupScatterStyleDemo();
void setupLineStyleDemo();
void setupDiscontinuousLineDemo();
void setupDateDemo();
private slots:
void changeDemo(const QModelIndex &current, const QModelIndex &previous);
private:
radix::Plot *plot;
QWidget *plotWidget;
QString demoName;
QTimer dataTimer;
QCPItemTracer *itemDemoPhaseTracer;
int currentDemoIndex;
};
#endif // RADIXPLOT_EXAMPLE_MAINWINDOW_HH_
/*
* @file: graph2d.cc
* @author: Jordan P. Lefebvre, lefebvrejp@ornl.gov
*
* Created on May 31, 2016, 13:52 PM
*/
#include "radixplot/graph2d.hh"
#include <cmath>
namespace radix
{
Graph2D::Graph2D(QCPGraph *graph)
: qcpgraph(graph)
, dataMap(new QCPDataMap())
, keyUnit("")
, valueUnit("")
{
// make sure graph is backed with my dataset
// qcpgraph takes ownership of datamap
qcpgraph->setData(dataMap, false);
} // Graph2D::Graph2D
Graph2D::~Graph2D() {} // Graph2D::~Graph2D
void Graph2D::setName(std::string value)
{
qcpgraph->setName(QString::fromStdString(value));
} // Graph2D::setName
void Graph2D::setKeyUnit(QString value)
{
keyUnit = value;
qcpgraph->parentPlot()->xAxis->setLabel(value);
} // Graph2D::setKeyUnit
void Graph2D::setValueUnit(QString value)
{
valueUnit = value;
qcpgraph->parentPlot()->yAxis->setLabel(value);
} // Graph2D::setValueUnit
void Graph2D::setAdaptiveSampling(bool value)
{
qcpgraph->setAdaptiveSampling(value);
} // Graph2D::setAdaptiveSampling
void Graph2D::setChannelFillGraph(const Graph2D &fill)
{
qcpgraph->setChannelFillGraph(fill.qcpgraph);
} // Graph2D::sethannelFillGraph
void Graph2D::rescaleAxes(bool onlyEnlarge)
{
qcpgraph->rescaleAxes(onlyEnlarge);
} // Graph2D::rescaleAxes
void Graph2D::setPen(const QPen &pen)
{
qcpgraph->setPen(pen);
} // Graph2D::setPen
void Graph2D::setBrush(const QBrush &brush)
{
qcpgraph->setBrush(brush);
} // Graph2D::setBrush
void Graph2D::setLineStyle(QCPGraph::LineStyle style)
{
qcpgraph->setLineStyle(style);
} // Graph2D::setLineStyle
void Graph2D::setScatterStyle(const QCPScatterStyle &style)
{
qcpgraph->setScatterStyle(style);
} // Graph2D::setScatterStyle
void Graph2D::setErrorType(QCPGraph::ErrorType type)
{
qcpgraph->setErrorType(type);
} // Graph2D::setErrorType
void Graph2D::setErrorPen(const QPen &pen)
{
qcpgraph->setErrorPen(pen);
} // Graph2D::setErrorPen
void Graph2D::setData(const VecDouble &key, const VecDouble &value)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
dataMap->insertMulti(newData.key, newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etNone);
} // Graph2D::setData
void Graph2D::setDataValueError(const VecDouble &key, const VecDouble &value,
const VecDouble &valueError)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
n = qMin(n, valueError.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
newData.valueErrorMinus = valueError[i];
newData.valueErrorPlus = valueError[i];
dataMap->insertMulti(key[i], newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etValue);
qcpgraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
} // Graph2D::setDataValueError
void Graph2D::setDataValueError(const VecDouble &key, const VecDouble &value,
const VecDouble &valueErrorMinus,
const VecDouble &valueErrorPlus)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
n = qMin(n, valueErrorMinus.size());
n = qMin(n, valueErrorPlus.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
newData.valueErrorMinus = valueErrorMinus[i];
newData.valueErrorPlus = valueErrorPlus[i];
dataMap->insertMulti(key[i], newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etValue);
qcpgraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
} // Graph2D::setDataValueError
void Graph2D::setDataKeyError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyError)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
n = qMin(n, keyError.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
newData.keyErrorMinus = keyError[i];
newData.keyErrorPlus = keyError[i];
dataMap->insertMulti(key[i], newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etKey);
qcpgraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
} // Graph2D::setDataKeyError
void Graph2D::setDataKeyError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyErrorMinus,
const VecDouble &keyErrorPlus)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
n = qMin(n, keyErrorMinus.size());
n = qMin(n, keyErrorPlus.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
newData.keyErrorMinus = keyErrorMinus[i];
newData.keyErrorPlus = keyErrorPlus[i];
dataMap->insertMulti(key[i], newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etKey);
qcpgraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
} // Graph2D::setDataKeyError
void Graph2D::setDataBothError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyError,
const VecDouble &valueError)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
n = qMin(n, valueError.size());
n = qMin(n, keyError.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
newData.keyErrorMinus = keyError[i];
newData.keyErrorPlus = keyError[i];
newData.valueErrorMinus = valueError[i];
newData.valueErrorPlus = valueError[i];
dataMap->insertMulti(key[i], newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etBoth);
qcpgraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
} // Graph2D::setDataBothError
void Graph2D::setDataBothError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyErrorMinus,
const VecDouble &keyErrorPlus,
const VecDouble &valueErrorMinus,
const VecDouble &valueErrorPlus)
{
dataMap->clear();
size_t n = key.size();
n = qMin(n, value.size());
n = qMin(n, valueErrorMinus.size());
n = qMin(n, valueErrorPlus.size());
n = qMin(n, keyErrorMinus.size());
n = qMin(n, keyErrorPlus.size());
QCPData newData;
for (size_t i = 0; i < n; ++i)
{
newData.key = key[i];
newData.value = value[i];
newData.keyErrorMinus = keyErrorMinus[i];
newData.keyErrorPlus = keyErrorPlus[i];
newData.valueErrorMinus = valueErrorMinus[i];
newData.valueErrorPlus = valueErrorPlus[i];
dataMap->insertMulti(key[i], newData);
}
//
// Set error type also
//
qcpgraph->setErrorType(QCPGraph::etBoth);
qcpgraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2));
} // Graph2D::setDataBothError
} // namespace radix
/*
* @file: graph2d.hh
* @author: Jordan P. Lefebvre, lefebvrejp@ornl.gov
*
* Created on May 31, 2016, 13:52 PM
*/
#ifndef RADIXPLOT_GRAPH2D_HH_
#define RADIXPLOT_GRAPH2D_HH_
#include "qcustomplot.h"
#include <functional>
#include <memory>
#include <unordered_map>
namespace radix
{
/** namespace Scale Forward declarations */
class Graph2D;
class Plot;
typedef std::vector<double> VecDouble;
/**
* @brief The Graph2D class
* Graph 2D instance which provides basic 2d plot creation.
*/
class Graph2D
{
private:
/**
* @brief qcpgraph pointer to QCPGraph
*/
QCPGraph *qcpgraph;
/**
* @brief dataMap pointer to data in QCPGraph
*/
QCPDataMap *dataMap;
/**
* @brief keyUnit QString type
*/
QString keyUnit;
/**
* @brief valueUnit QString type
*/
QString valueUnit;
/**
* @brief Graph2D private constructor
* @param graph QCPGraph
*/
Graph2D(QCPGraph *graph);
public:
/** @brief typedef std::shared_ptr<Graph2D> SP*/
typedef std::shared_ptr<Graph2D> SP;
/**
* @brief destructor
*/
~Graph2D();
/**
* @brief graph retrieve native QCPGraph
* @return const QCPGraph*
*/
const QCPGraph *graph() const { return qcpgraph; }
/**
* @brief setName Set the graph's name
* @param value std::string
*/
void setName(std::string value);
/**
* @brief setKeyUnit Set the graph's unit type
* @param value QString
*/
void setKeyUnit(QString value);
QString getKeyUnit() const { return keyUnit; }
/**
* @brief setValueUnit Set the graph's unit type
* @param value QString
*/
void setValueUnit(QString value);
QString getValueUnit() const { return valueUnit; }
/**
* @brief setAdaptiveSampling Sets whether to adaptively sample data for plot
* This can significantly improve rerender of large data sets
* @param value bool
*/
void setAdaptiveSampling(bool value);
/**
* @brief setChannelFillGraph set the channel fill graph
* @param fill const Graph2D
*/
void setChannelFillGraph(const Graph2D &fill);
/**
* @brief rescaleAxes rescale axes to allow data to fit perfectly
*/
void rescaleAxes(bool onlyEnlarge = false);
/**
* @brief setPen set the pen for this graph
* @param pen const QPen&
*/
void setPen(const QPen &pen);
/**
* @brief setBrush set the brush for this graph
* @param brush const QBrush&
*/
void setBrush(const QBrush &brush);
/**
* @brief setLineStyle set the Line style for this graph
* @param style QCPGraph::LineStyle
*/
void setLineStyle(QCPGraph::LineStyle style);
/**
* @brief setScatterStyle set the scatter style
* @param style const QCPScatterStyle&
*/
void setScatterStyle(const QCPScatterStyle &style);
/**
* @brief setErrorType set the error type
* @param type QCPGraph::ErrorType
*/
void setErrorType(QCPGraph::ErrorType type);
/**
* @brief setErrorPen set the pen which draws the error
* @param pen const QPen&
*/
void setErrorPen(const QPen &pen);
/**
* @brief setData Sets the key and value data
* @param key const VecDouble&
* @param value const VecDouble&
*/
void setData(const VecDouble &key, const VecDouble &value);
/**
* @brief setDataKeyError Sets the key and value data and keyerror
* @param key const VecDouble&
* @param value const VecDouble&
* @param keyError const VecDouble&
*/
void setDataKeyError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyError);
/**
* @brief setDataKeyError Sets the key and value data and keyerror - & +
* @param key const VecDouble&
* @param value const VecDouble&
* @param keyErrorMinus const VecDouble&
* @param keyErrorPlus const VecDouble&
*/
void setDataKeyError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyErrorMinus,
const VecDouble &keyErrorPlus);
/**
* @brief setDataValueError Sets the key and value data and value error
* @param key const VecDouble&
* @param value const VecDouble&
* @param valueError const VecDouble&
*/
void setDataValueError(const VecDouble &key, const VecDouble &value,
const VecDouble &valueError);
/**
* @brief setDataValueError Sets the key and value data and value error - & +
* @param key const VecDouble&
* @param value const VecDouble&
* @param valueErrorMinus const VecDouble&
* @param valueErrorPlus const VecDouble&
*/
void setDataValueError(const VecDouble &key, const VecDouble &value,
const VecDouble &valueErrorMinus,
const VecDouble &valueErrorPlus);
/**
* @brief setDataBothError Sets the key and value data with key error and
* value error
* @param key const VecDouble&
* @param value const VecDouble&
* @param keyError const VecDouble&
* @param valueError const VecDouble&
*/
void setDataBothError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyError, const VecDouble &valueError);
/**
* @brief setDataBothError Sets the key and value data with key error and
* value error
* @param key const VecDouble&
* @param value const VecDouble&
* @param keyError const VecDouble&
* @param valueError const VecDouble&
*/
void setDataBothError(const VecDouble &key, const VecDouble &value,
const VecDouble &keyErrorMinus,
const VecDouble &keyErrorPlus,
const VecDouble &valueErrorMinus,
const VecDouble &valueErrorPlus);
/**
* Let Plot access Graph2D members/methods
*/
friend class Plot;
}; // class Graph2D
} // namespace radix
#endif /* RADIXPLOT_GRAPH2D_HH_ */