Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members Related Pages Search
expressiongraph.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EXPRESSIONGRAPH_H
00019 #define EXPRESSIONGRAPH_H
00020
00021 #include <vector>
00022
00023 #include "basicgraph.h"
00024 #include "animator.h"
00025
00026 class MathFunction;
00027 class Expression;
00028 class FungParser;
00029
00030 typedef std::vector<Expression*> ExpressionPtrVector;
00031
00036 class ExpressionGraph : public BasicGraph, public Animator
00037 {
00038 Q_OBJECT
00039
00040 public:
00041 ExpressionGraph(QWidget *parent=0, const char *name=0);
00042 ~ExpressionGraph();
00043
00044 void load_key( const char *key, const char *value );
00045
00047 void addExpression(const Expression &);
00048
00050
00051
00053 void removeExpression(unsigned int index);
00054
00055 inline unsigned int getCurrentExpressionIndex(){return expressionIndex;}
00056 inline void setCurrentExpressionIndex(int i){expressionIndex = i;}
00057 Expression getExpression(unsigned int i) const;
00058 inline unsigned int expressionCount(){return functions.size();}
00059
00060 #ifdef KDE_APP
00061 virtual void print(KPrinter *);
00062 #else
00063 virtual void print(QPrinter *);
00064 #endif //KDE_APP
00065
00066 void setAngle(int m){angle = m; reparseAll(); repaint(false);}
00067 int getAngle() const{return angle;}
00068
00070 inline bool isTracing() const{return doTrace;}
00071
00073 inline bool isDrawConnected() const{return drawConnected;}
00074
00075 void exportAsImage(const QString& file,const QString& fileType);
00076 void getPixmap(QPixmap &pm);
00077
00078 void onlyShowActive(bool b){only_show_active = b;}
00079
00080 void setDisplayExpressionText(bool b){displayExpressionText = b;}
00081
00082 public slots:
00083 void nextExpression();
00084 void prevExpression();
00085 inline void setDrawConnected(bool b){drawConnected = b; repaint(false);}
00086 void setShowCurrentExpression(bool state);
00087 void setTrace(bool);
00088
00089 void slotNextFrame(){nextFrame();}
00090
00091 signals:
00092 void animationValueChanged(double);
00093
00094 protected:
00095 friend class MathFunction;
00096
00097
00098 virtual int setXYForTrace(const double, const double, double *, double *, Expression &){return 0;}
00099
00100 virtual void drawExpression(QPainter *, Expression & expression) = 0;
00101 void drawExpressionAt(QPainter *painter, int i);
00102 virtual void putUndefinedMessage(double x, double y);
00103 virtual unsigned int var_count(){return 1;}
00104 virtual void drawAfterAxis(QPainter *);
00105
00109 virtual const char * independent_vars() = 0;
00113 virtual const char * dependent_var(int i=0) = 0;
00114
00115 inline virtual double traceDepX(double d){return d;}
00116 inline virtual double traceDepY(double d){return d;}
00117
00118 void reparseAll();
00119
00123 FungParser * getParsedCurrentExpression(int i=0);
00124
00128
00129 int parseExpression( std::string & expression, FungParser *fp, int i=0);
00130
00131 bool isValidExpression(const Expression &, std::string *errorMsg = 0);
00132
00133
00134 void paintEvent(QPaintEvent*);
00135 void mouseMoveEvent(QMouseEvent *);
00136
00137 virtual void nextFrameReady();
00138
00139 private:
00140 bool doTrace, drawConnected;
00141 unsigned int expressionIndex;
00142 int functionWidth;
00143 int angle;
00144 bool only_show_active, displayExpressionText;
00145
00146 ExpressionPtrVector functions;
00147
00155 void drawExpressions(QPainter*);
00156 };
00157
00158 #endif
|