diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2018-05-09 00:11:35 +0200 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2018-05-09 00:11:35 +0200 |
commit | 015bb675d6eb177900c8ac94a6d35edc5ad90576 (patch) | |
tree | edde4153ce9b2ba6bdaf9d3c0af0966ed6dfd717 /wx+/graph.h | |
parent | 9.8 (diff) | |
download | FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.tar.gz FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.tar.bz2 FreeFileSync-015bb675d6eb177900c8ac94a6d35edc5ad90576.zip |
9.9
Diffstat (limited to 'wx+/graph.h')
-rwxr-xr-x | wx+/graph.h | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/wx+/graph.h b/wx+/graph.h index 45129c4b..bf0e7a70 100755 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -101,12 +101,12 @@ private: struct VectorCurveData : public ArrayCurveData { - std::vector<double>& refData() { return data; } + std::vector<double>& refData() { return data_; } private: - double getValue(size_t pos) const override { return pos < data.size() ? data[pos] : 0; } - size_t getSize() const override { return data.size(); } + double getValue(size_t pos) const override { return pos < data_.size() ? data_[pos] : 0; } + size_t getSize() const override { return data_.size(); } - std::vector<double> data; + std::vector<double> data_; }; //------------------------------------------------------------------------------------------------------------ @@ -128,7 +128,7 @@ double nextNiceNumber(double blockSize); //round to next number which is conveni struct DecimalNumberFormatter : public LabelFormatter { double getOptimalBlockSize(double sizeProposed ) const override { return nextNiceNumber(sizeProposed); } - wxString formatText (double value, double optimalBlockSize) const override { return zen::numberTo<wxString>(value); } + wxString formatText (double value, double optimalBlockSize) const override { return numberTo<wxString>(value); } }; //------------------------------------------------------------------------------------------------------------ @@ -178,7 +178,7 @@ public: { public: CurveAttributes() {} //required by GCC - CurveAttributes& setColor (const wxColor& col) { color = col; autoColor = false; return *this; } + CurveAttributes& setColor (const wxColor& col) { color = col; autoColor = false; return *this; } CurveAttributes& fillCurveArea (const wxColor& col) { fillColor = col; fillMode = FILL_CURVE; return *this; } CurveAttributes& fillPolygonArea(const wxColor& col) { fillColor = col; fillMode = FILL_POLYGON; return *this; } CurveAttributes& setLineWidth(size_t width) { lineWidth = static_cast<int>(width); return *this; } @@ -240,26 +240,26 @@ public: class MainAttributes { public: - MainAttributes& setMinX(double newMinX) { minX = newMinX; minXauto = false; return *this; } - MainAttributes& setMaxX(double newMaxX) { maxX = newMaxX; maxXauto = false; return *this; } + MainAttributes& setMinX(double newMinX) { minX = newMinX; return *this; } + MainAttributes& setMaxX(double newMaxX) { maxX = newMaxX; return *this; } - MainAttributes& setMinY(double newMinY) { minY = newMinY; minYauto = false; return *this; } - MainAttributes& setMaxY(double newMaxY) { maxY = newMaxY; maxYauto = false; return *this; } + MainAttributes& setMinY(double newMinY) { minY = newMinY; return *this; } + MainAttributes& setMaxY(double newMaxY) { maxY = newMaxY; return *this; } - MainAttributes& setAutoSize() { minXauto = maxXauto = minYauto = maxYauto = true; return *this; } + MainAttributes& setAutoSize() { minX = maxX = minY = maxY = NoValue(); return *this; } - MainAttributes& setLabelX(PosLabelX posX, size_t height = 25, std::shared_ptr<LabelFormatter> newLabelFmt = std::make_shared<DecimalNumberFormatter>()) + MainAttributes& setLabelX(PosLabelX posX, int height = -1, std::shared_ptr<LabelFormatter> newLabelFmt = nullptr) { - labelposX = posX; - xLabelHeight = static_cast<int>(height); - labelFmtX = newLabelFmt; + labelposX = posX; + if (height >= 0) xLabelHeight = height; + if (newLabelFmt) labelFmtX = newLabelFmt; return *this; } - MainAttributes& setLabelY(PosLabelY posY, size_t width = 60, std::shared_ptr<LabelFormatter> newLabelFmt = std::make_shared<DecimalNumberFormatter>()) + MainAttributes& setLabelY(PosLabelY posY, int width = -1, std::shared_ptr<LabelFormatter> newLabelFmt = nullptr) { - labelposY = posY; - yLabelWidth = static_cast<int>(width); - labelFmtY = newLabelFmt; + labelposY = posY; + if (width >= 0) yLabelWidth = width; + if (newLabelFmt) labelFmtY = newLabelFmt; return *this; } @@ -272,22 +272,18 @@ public: private: friend class Graph2D; - bool minXauto = true; //autodetect range for X value - bool maxXauto = true; - double minX = 0; //x-range to visualize - double maxX = 0; // + Opt<double> minX; //x-range to visualize + Opt<double> maxX; // - bool minYauto = true; //autodetect range for Y value - bool maxYauto = true; - double minY = 0; //y-range to visualize - double maxY = 0; // + Opt<double> minY; //y-range to visualize + Opt<double> maxY; // PosLabelX labelposX = LABEL_X_BOTTOM; - int xLabelHeight = 25; + Opt<int> xLabelHeight; std::shared_ptr<LabelFormatter> labelFmtX = std::make_shared<DecimalNumberFormatter>(); PosLabelY labelposY = LABEL_Y_LEFT; - int yLabelWidth = 60; + Opt<int> yLabelWidth; std::shared_ptr<LabelFormatter> labelFmtY = std::make_shared<DecimalNumberFormatter>(); std::map<PosCorner, wxString> cornerTexts; @@ -295,6 +291,7 @@ public: wxColor backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); SelMode mouseSelMode = SELECT_RECTANGLE; }; + void setAttributes(const MainAttributes& newAttr) { attr_ = newAttr; Refresh(); } MainAttributes getAttributes() const { return attr_; } @@ -315,7 +312,6 @@ private: void onPaintEvent(wxPaintEvent& event); void onSizeEvent(wxSizeEvent& event) { Refresh(); event.Skip(); } - void onEraseBackGround(wxEraseEvent& event) {} void render(wxDC& dc) const; |