OpenCurves  0.9
expressionsview.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2013
5 //
6 #ifndef __EXPRESSIONVSIEW_H_
7 #define __EXPRESSIONVSIEW_H_
8 
9 #include "ocurvesconfig.h"
10 
11 #include <QWidget>
12 
13 #include <QList>
14 #include <QVector>
15 
16 class Expressions;
17 class FunctionDefinition;
18 class PlotExpression;
19 class QListWidgetItem;
20 class QTableWidget;
21 
22 namespace Ui
23 {
24  class ExpressionsView;
25 }
26 
33 class ExpressionsView : public QWidget
34 {
35  Q_OBJECT
36 
37 public:
41  explicit ExpressionsView(Expressions *expressions = nullptr, QWidget *parent = nullptr);
42 
45 
51 
53  const Expressions *expressions() const;
54 
55 protected:
69  PlotExpression *parseExpression(const QString &text, QStringList &errors) const;
70 
81 
82 protected slots:
86  void addExpr();
87 
89  void removeExpr();
90 
93  void updateExpr();
94 
98  void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
99 
103  void editingDone();
104 
107  void expressionAdded(PlotExpression *expression);
108 
111  void expressionRemoved(const PlotExpression *expression);
112 
113 protected:
117  void showExpressions();
118 
122  QListWidgetItem *createItem(PlotExpression *expression);
123 
127  bool removeExpression(QListWidgetItem *item);
128 
129 private:
140  QTableWidget *createFunctionsTable(const QVector<const FunctionDefinition *> &functions, QWidget *parent = nullptr);
141 
142  Ui::ExpressionsView *_ui;
143  Expressions *_expressions;
144  bool _suppressEvents;
145 };
146 
147 
149 {
150  return _expressions;
151 }
152 
153 #endif // __EXPRESSIONSVIEW_H_
void showExpressions()
Clears and repopulates the expressions display list.
const Expressions * expressions() const
Returns the Expressions object being viewed and edited.
Definition: expressionsview.h:148
Definition: coloursview.h:16
void removeExpr()
Removes the currently selected expression (if any).
void updateExpr()
Attempts to update the currently selected expression with the current UI editor text.
QListWidgetItem * createItem(PlotExpression *expression)
Create a list widget for expression.
void expressionRemoved(const PlotExpression *expression)
Handles removal from the Expressions object, removing the corresponding expression from the display l...
void addExpr()
Handler for add button presses.
void expressionAdded(PlotExpression *expression)
Handles additions to the Expressions object, adding the expression to the display list...
PlotExpression * parseExpression(const QString &text, QStringList &errors) const
Parses the text expression text returning a compiled PlotExpression.
bool removeExpression(QListWidgetItem *item)
Remove the expression associated with item.
Manages and edits current expressions.
Definition: expressionsview.h:33
~ExpressionsView()
Destructor.
ExpressionsView(Expressions *expressions=nullptr, QWidget *parent=nullptr)
Constructor.
PlotExpression * addExpression()
Attempts to add an expression based on the current UI state.
void editingDone()
Handles explicit completion of editing in the expression editor (i.e., the enter key).
void setExpressions(Expressions *expressions)
Sets the Expressions object to view and edit.
Defines a function which can be used with the FunctionRegister.
Definition: functiondefinition.h:34
Maintains the current expressions available for generation and plotting.
Definition: expressions.h:27
A PlotExpression represents an operation in a plot equation.
Definition: plotexpression.h:91
void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
Handles changes in the current expression selection, updating the editor text.