2018-10-07 03:40:25 +00:00
|
|
|
#pragma once
|
2018-07-18 07:39:26 +00:00
|
|
|
|
2019-08-25 09:42:24 +00:00
|
|
|
#include <array>
|
|
|
|
|
2018-08-04 22:05:01 +00:00
|
|
|
#include <QFrame>
|
2018-08-19 20:05:39 +00:00
|
|
|
#include <QJSEngine>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QStaticText>
|
|
|
|
|
|
|
|
#include "EditorWidget.hpp"
|
|
|
|
#include "ProjectModel.hpp"
|
|
|
|
|
|
|
|
#include <amuse/Common.hpp>
|
2018-08-04 22:05:01 +00:00
|
|
|
|
|
|
|
class CurveEditor;
|
|
|
|
|
2019-08-28 00:51:38 +00:00
|
|
|
class QLabel;
|
|
|
|
class QLineEdit;
|
|
|
|
class QPushButton;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class CurveView : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class CurveControls;
|
|
|
|
amuse::ObjToken<ProjectModel::CurveNode> m_node;
|
|
|
|
QFont m_gridFont;
|
2019-08-25 09:42:24 +00:00
|
|
|
std::array<QStaticText, 11> m_percentTexts;
|
|
|
|
std::array<QStaticText, 11> m_percentTextsCenter;
|
2018-12-08 05:20:09 +00:00
|
|
|
CurveEditor* getEditor() const;
|
|
|
|
|
2018-08-04 22:05:01 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit CurveView(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~CurveView() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void loadData(ProjectModel::CurveNode* node);
|
|
|
|
void unloadData();
|
|
|
|
ProjectModel::INode* currentNode() const;
|
2018-08-04 22:05:01 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
void paintEvent(QPaintEvent* ev) override;
|
|
|
|
void mousePressEvent(QMouseEvent* ev) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* ev) override;
|
2018-08-04 22:05:01 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class CurveControls : public QFrame {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class CurveView;
|
|
|
|
QLineEdit* m_lineEdit;
|
|
|
|
QLabel* m_errLabel;
|
|
|
|
QPushButton* m_setExpr;
|
|
|
|
QJSEngine m_engine;
|
|
|
|
CurveEditor* getEditor() const;
|
|
|
|
|
2018-08-04 22:05:01 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit CurveControls(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~CurveControls() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void loadData();
|
|
|
|
void unloadData();
|
2019-08-25 04:37:47 +00:00
|
|
|
void resizeEvent(QResizeEvent* ev) override;
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-04 22:05:01 +00:00
|
|
|
public slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void exprCommit();
|
2018-08-04 22:05:01 +00:00
|
|
|
};
|
2018-07-18 07:39:26 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class CurveEditor : public EditorWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class CurveView;
|
|
|
|
friend class CurveControls;
|
|
|
|
CurveView* m_curveView;
|
|
|
|
CurveControls* m_controls;
|
|
|
|
|
2018-07-18 07:39:26 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit CurveEditor(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~CurveEditor() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(ProjectModel::CurveNode* node);
|
2019-08-25 04:37:47 +00:00
|
|
|
void unloadData() override;
|
|
|
|
ProjectModel::INode* currentNode() const override;
|
2018-07-18 07:39:26 +00:00
|
|
|
};
|