00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef INDICATORPLOT_HPP
00023 #define INDICATORPLOT_HPP
00024
00025 #include <qwidget.h>
00026 #include <qstring.h>
00027 #include <qpixmap.h>
00028 #include <qdatetime.h>
00029 #include <qcolor.h>
00030 #include <qmemarray.h>
00031 #include <qfont.h>
00032 #include <qdict.h>
00033 #include <qstringlist.h>
00034 #include <qpopupmenu.h>
00035
00036 #include "PlotLine.h"
00037 #include "Setting.h"
00038 #include "Indicator.h"
00039 #include "Scaler.h"
00040 #include "Config.h"
00041 #include "BarData.h"
00042 #include "COBase.h"
00043 #include "DBIndex.h"
00044
00045 class IndicatorPlot : public QWidget
00046 {
00047 Q_OBJECT
00048
00049 signals:
00050 void statusMessage (QString);
00051 void infoMessage (Setting *);
00052 void leftMouseButton (int, int, bool);
00053 void keyPressed (QKeyEvent *);
00054 void signalEditIndicator (QString);
00055 void signalNewIndicator ();
00056 void signalMinPixelspace (int);
00057 void signalDraw ();
00058 void signalDateFlag (bool);
00059 void signalLogFlag (bool);
00060 void signalEditChart (QString);
00061 void signalDeleteAllCO ();
00062 void signalDeleteCO (QString);
00063 void signalSaveCO (Setting);
00064
00065 public:
00066 enum MouseStatus
00067 {
00068 None,
00069 ClickWait,
00070 COSelected,
00071 Moving
00072 };
00073
00074 IndicatorPlot (QWidget *, DBIndex *);
00075 ~IndicatorPlot ();
00076 void clear ();
00077 void setData (BarData *);
00078 void setLogScale (bool);
00079 void updateStatusBar (int, int);
00080 void setInfoFlag (bool);
00081 void drawCrossHair ();
00082 void addIndicator (Indicator *);
00083 Indicator * getIndicator ();
00084 bool deleteIndicator ();
00085 void addChartObject (Setting &);
00086 int getWidth ();
00087 void strip (double, int, QString &);
00088 int convertXToDataIndex (int);
00089 void setGridFlag (bool);
00090 void setScaleToScreen (bool);
00091 void setDrawMode (bool);
00092 void setDateFlag (bool);
00093 void setCrosshairsFlag (bool);
00094 void setScaler (Scaler &);
00095 Scaler & getScaler ();
00096 void getInfo (int);
00097 void setXGrid (QMemArray<int> &);
00098 void setMenuFlag (bool);
00099
00100 void drawLine ();
00101 void drawHorizontalLine ();
00102 void drawHistogram ();
00103 void drawHistogramBar ();
00104 void drawDot ();
00105 void drawBar ();
00106 void drawCandle ();
00107 void drawPF ();
00108
00109 public slots:
00110 void draw();
00111 void drawRefresh();
00112 void setPixelspace (int);
00113 void setBackgroundColor (QColor &);
00114 void setBorderColor (QColor &);
00115 void setGridColor (QColor &);
00116 void setPlotFont (QFont &);
00117 void setIndex (int);
00118 void crossHair (int, int, bool);
00119 void printChart ();
00120 void showPopupMenu ();
00121 void setChartPath (QString &);
00122 void setCrosshairsStatus (bool);
00123 void slotSliderChanged (int);
00124 void slotGridChanged (bool);
00125 void slotScaleToScreenChanged (bool);
00126 void slotDrawModeChanged (bool);
00127 void slotLogScaleChanged (bool);
00128 void setInterval(BarData::BarLength);
00129 void slotEditChart();
00130 void slotIndicatorHelp();
00131
00132 protected:
00133 virtual void paintEvent (QPaintEvent *);
00134 virtual void resizeEvent (QResizeEvent *);
00135 virtual void mousePressEvent (QMouseEvent *);
00136 virtual void mouseMoveEvent (QMouseEvent *);
00137 virtual void keyPressEvent (QKeyEvent *);
00138 virtual void mouseDoubleClickEvent (QMouseEvent *);
00139 virtual void contextMenuEvent (QContextMenuEvent *);
00140
00141 private slots:
00142 void drawObjects ();
00143 void drawLines ();
00144 void drawXGrid ();
00145 void drawYGrid ();
00146 void drawInfo ();
00147 void setScale ();
00148 int getXFromDate (QDateTime &);
00149 void getXY (int, int);
00150 void slotMessage (QString);
00151 void slotEditIndicator ();
00152 void slotNewIndicator ();
00153 void slotNewChartObject (int);
00154 void slotDeleteAllChartObjects ();
00155 void slotChartObjectDeleted (QString);
00156 void toggleDate ();
00157 void toggleLog ();
00158 void saveChartObjects ();
00159 void saveChartObject (QString);
00160
00161 private:
00162 QFont plotFont;
00163 QFontMetrics *plotFontMetrics;
00164 PlotLine *currentLine;
00165 QPixmap buffer;
00166 Config config;
00167 int pixelspace;
00168 int startX;
00169 int startIndex;
00170 BarData::BarLength interval;
00171 QColor backgroundColor;
00172 QColor gridColor;
00173 QColor borderColor;
00174 bool gridFlag;
00175 bool scaleToScreen;
00176 bool logScale;
00177 bool crossHairFlag;
00178 bool drawMode;
00179 bool crosshairs;
00180 bool infoFlag;
00181 bool dateFlag;
00182 bool menuFlag;
00183 QDateTime crossHairX;
00184 double crossHairY;
00185 Scaler scaler;
00186 double y1;
00187 QDateTime x1;
00188 MouseStatus mouseFlag;
00189 QDict<COBase> coList;
00190 COBase *coSelected;
00191 QString chartPath;
00192 BarData *data;
00193 Indicator *indy;
00194 QMemArray<int> xGrid;
00195 QPopupMenu *chartMenu;
00196 QPopupMenu *chartObjectMenu;
00197 DBIndex *chartIndex;
00198 QString helpFilePath;
00199 QString userDocsPath;
00200 };
00201
00202 #endif
00203
00204