mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
ScatterDraw: Changed text drawing to Draw
git-svn-id: svn://ultimatepp.org/upp/trunk@6080 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
dda7d314f9
commit
496505a0fb
3 changed files with 130 additions and 118 deletions
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
void DrawLine(Draw &w, double x0, double y0, double x1, double y1, double width, const Color &color);
|
||||
void DrawLine(Painter &w, double x0, double y0, double x1, double y1, double width, const Color &color);
|
||||
void DrawLineOpa(Draw& w, const int x0, const int y0, const int x1, const int y1, const int &scale, const double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawLineOpa(Painter& w, const int x0, const int y0, const int x1, const int y1, const int &scale, const double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, const int &scale, const double opacity, const Color &background, const Color &color);
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1, const int &scale, const double opacity, const Color &background, const Color &color);
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Point> &p, const int &scale, const double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Point> &p, const int &scale, const double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void FillPolylineOpa(Draw& w, const Vector<Point> &p, const int &scale, const double opacity, const Color &background, const Color &fillColor);
|
||||
void FillPolylineOpa(Painter& w, const Vector<Point> &p, const int &scale, const double opacity, const Color &background, const Color &fillColor);
|
||||
void DrawLineOpa(Draw& w, int x0, int y0, int x1, int y1, int scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void DrawLineOpa(Painter& w, int x0, int y0, int x1, int y1, int scale, double opacity, double thick, const Color &_color, String pattern, const Color &background = Null);
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, int scale, double opacity, const Color &background, const Color &color);
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1, int scale, double opacity, const Color &background, const Color &color);
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Point> &p, int scale, double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Point> &p, int scale, double opacity, double thick, const Color &color, String pattern = "", const Color &background = Null);
|
||||
void FillPolylineOpa(Draw& w, const Vector<Point> &p, int scale, double opacity, const Color &background, const Color &fillColor);
|
||||
void FillPolylineOpa(Painter& w, const Vector<Point> &p, int scale, double opacity, const Color &background, const Color &fillColor);
|
||||
void DrawVArrow(Draw &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color);
|
||||
void DrawVArrow(Painter &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color);
|
||||
void DrawHArrow(Draw &w, double x0, double y0, double x1, double y1, double width, double aWidth, double aHeight, const Color &color);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ ScatterDraw& ScatterDraw::SetLabelsColor(const Color& colorLabels)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaMargin(const int hLeft, const int hRight, const int vTop, const int vBottom)
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaMargin(int hLeft, int hRight, int vTop, int vBottom)
|
||||
{
|
||||
hPlotLeft = hLeft;
|
||||
hPlotRight = hRight;
|
||||
|
|
@ -77,22 +77,22 @@ ScatterDraw& ScatterDraw::SetPlotAreaMargin(const int hLeft, const int hRight, c
|
|||
return *this;
|
||||
}
|
||||
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaLeftMargin(const int margin) {
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaLeftMargin(int margin) {
|
||||
hPlotLeft = margin;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaRightMargin(const int margin) {
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaRightMargin(int margin) {
|
||||
hPlotRight = margin;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaTopMargin(const int margin) {
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaTopMargin(int margin) {
|
||||
vPlotTop = margin;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaBottomMargin(const int margin) {
|
||||
ScatterDraw& ScatterDraw::SetPlotAreaBottomMargin(int margin) {
|
||||
vPlotBottom = margin;
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -157,9 +157,9 @@ ScatterDraw &ScatterDraw::SetDrawY2Reticle(bool set)
|
|||
return *this;
|
||||
}
|
||||
|
||||
void ScatterDraw::DrawLegend(Draw& w, const int& scale) const
|
||||
void ScatterDraw::DrawLegend(Draw& w, const Size &size, int scale) const
|
||||
{
|
||||
int nmr = fround((GetSize().cx - 2*(hPlotLeft + hPlotRight))/legendWidth); // Max number of labels per row
|
||||
int nmr = fround((size.cx - 2*(hPlotLeft + hPlotRight))/legendWidth); // Max number of labels per row
|
||||
if (nmr <= 0)
|
||||
return;
|
||||
int nLab = series.GetCount(); //number of labels
|
||||
|
|
@ -461,7 +461,7 @@ MarkPlot *ScatterDraw::GetNewMarkPlot(int index)
|
|||
return new CircleMarkPlot();
|
||||
}
|
||||
|
||||
Color GetOpaqueColor(const Color &color, const Color &background, const double opacity)
|
||||
Color GetOpaqueColor(const Color &color, const Color &background, double opacity)
|
||||
{
|
||||
if (opacity == 1)
|
||||
return color;
|
||||
|
|
@ -795,7 +795,7 @@ ScatterDraw &ScatterDraw::SetMarkWidth(int index, double markWidth)
|
|||
return *this;
|
||||
}
|
||||
|
||||
double ScatterDraw::GetMarkWidth(int index) const
|
||||
double ScatterDraw::GetMarkWidth(int index)
|
||||
{
|
||||
ASSERT(IsValid(index));
|
||||
return series[index].markWidth;
|
||||
|
|
@ -919,49 +919,58 @@ void ScatterDraw::RemoveAllSeries()
|
|||
Refresh();
|
||||
}
|
||||
|
||||
Drawing ScatterDraw::GetDrawing()
|
||||
Drawing ScatterDraw::GetDrawing(bool ctrl)
|
||||
{
|
||||
DrawingDraw ddw(3*GetSize());
|
||||
|
||||
SetDrawing(ddw, 3);
|
||||
SetDrawing(ddw, GetSize(), 3);
|
||||
if (ctrl)
|
||||
PlotTexts(ddw, GetSize(), 3);
|
||||
|
||||
return ddw;
|
||||
}
|
||||
|
||||
Image ScatterDraw::GetImage(int scale)
|
||||
Image ScatterDraw::GetImage(const Size &size, int scale, bool ctrl)
|
||||
{
|
||||
#ifndef flagGUI
|
||||
ASSERT(mode != MD_DRAW);
|
||||
#endif
|
||||
|
||||
ImageBuffer ib(scale*GetSize());
|
||||
ImageBuffer ib(scale*size);
|
||||
BufferPainter bp(ib, mode);
|
||||
SetDrawing(bp, scale);
|
||||
|
||||
SetDrawing(bp, size, scale);
|
||||
if (ctrl)
|
||||
PlotTexts(bp, size, scale);
|
||||
|
||||
return ib;
|
||||
}
|
||||
|
||||
double ScatterDraw::GetXByPoint(const double x)
|
||||
Image ScatterDraw::GetImage(int scale)
|
||||
{
|
||||
return GetImage(GetSize(), scale, false);
|
||||
}
|
||||
|
||||
double ScatterDraw::GetXByPoint(double x)
|
||||
{
|
||||
return (x - hPlotLeft)*GetXRange()/(GetSize().cx - (hPlotLeft + hPlotRight) - 1) + GetXMin();
|
||||
}
|
||||
|
||||
double ScatterDraw::GetYByPoint(const double y)
|
||||
double ScatterDraw::GetYByPoint(double y)
|
||||
{
|
||||
return (GetSize().cy - vPlotTop - y - 1)*GetYRange()/(GetSize().cy - (vPlotTop + vPlotBottom) - GetTitleFont().GetHeight() - 1) + GetYMin();
|
||||
}
|
||||
|
||||
double ScatterDraw::GetY2ByPoint(const double y)
|
||||
double ScatterDraw::GetY2ByPoint(double y)
|
||||
{
|
||||
return (GetSize().cy - vPlotTop - y - 1)*GetY2Range()/(GetSize().cy - (vPlotTop + vPlotBottom) - GetTitleFont().GetHeight() - 1) + GetYMin2();
|
||||
}
|
||||
|
||||
double ScatterDraw::GetXPointByValue(const double x)
|
||||
double ScatterDraw::GetXPointByValue(double x)
|
||||
{
|
||||
return (x - GetXMin())/GetXRange()*(GetSize().cx - (hPlotLeft + hPlotRight) - 1) + hPlotLeft;
|
||||
}
|
||||
|
||||
double ScatterDraw::GetYPointByValue(const double y)
|
||||
double ScatterDraw::GetYPointByValue(double y)
|
||||
{
|
||||
return (GetSize().cy - vPlotTop - 1) - (y - GetYMin())/GetYRange()*(GetSize().cy - (vPlotTop + vPlotBottom) - GetTitleFont().GetHeight() - 1);
|
||||
}
|
||||
|
|
@ -1137,7 +1146,7 @@ Size GetTextSizeMultiline(Array <Size> &sizes) {
|
|||
ScatterDraw::ScatterDraw()
|
||||
{
|
||||
mode = MD_ANTIALIASED;
|
||||
size = Size(0, 0);
|
||||
size = Size(800, 600);
|
||||
titleColor = SColorText();
|
||||
graphColor = White();
|
||||
titleFont = Roman(20);
|
||||
|
|
@ -1241,13 +1250,10 @@ void DrawText(Draw &w, double x, double y, int angle, const String &text, Font f
|
|||
|
||||
void DrawText(Painter &w, double x, double y, int angle, const String &text, Font font, Color color)
|
||||
{
|
||||
if(font.GetHeight() > 15) {
|
||||
w.Begin();
|
||||
w.Translate(x, y).Rotate(-angle*M_PI/1800.);
|
||||
w.Text(0, 0, text, font).Fill(color);
|
||||
w.End();
|
||||
} else
|
||||
w.DrawText(fround(x), fround(y), angle, text, font, color);
|
||||
w.Begin();
|
||||
w.Translate(x, y).Rotate(-angle*M_PI/1800.);
|
||||
w.Text(0, 0, text, font).Fill(color);
|
||||
w.End();
|
||||
}
|
||||
|
||||
void Clip(Draw &w, double x, double y, double cx, double cy)
|
||||
|
|
@ -1270,9 +1276,8 @@ void ClipEnd(Painter &w)
|
|||
;
|
||||
}
|
||||
|
||||
void DrawLineOpa(Draw& w, const int x0, const int y0, const int x1, const int y1, const int &scale,
|
||||
const double opacity, double thick, const Color &_color, String dash,
|
||||
const Color &background)
|
||||
void DrawLineOpa(Draw& w, int x0, int y0, int x1, int y1, int scale, double opacity,
|
||||
double thick, const Color &_color, String dash, const Color &background)
|
||||
{
|
||||
Vector<Point> p;
|
||||
p << Point(x0, y0) << Point(x1, y1);
|
||||
|
|
@ -1297,8 +1302,8 @@ void DashScaled(Painter& w, const String dash, double scale)
|
|||
}
|
||||
}
|
||||
|
||||
void DrawLineOpa(Painter& w, const int x0, const int y0, const int x1, const int y1, const int &scale,
|
||||
const double opacity, double thick, const Color &color, String dash,
|
||||
void DrawLineOpa(Painter& w, int x0, int y0, int x1, int y1, int scale,
|
||||
double opacity, double thick, const Color &color, String dash,
|
||||
const Color &background)
|
||||
{
|
||||
w.Move(Pointf(x0, y0));
|
||||
|
|
@ -1308,8 +1313,8 @@ void DrawLineOpa(Painter& w, const int x0, const int y0, const int x1, const int
|
|||
w.Stroke(thick*scale, color);
|
||||
}
|
||||
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, const int &scale,
|
||||
const double opacity, const Color &background, const Color &color)
|
||||
void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, int scale,
|
||||
double opacity, const Color &background, const Color &color)
|
||||
{
|
||||
if (IsNull(color))
|
||||
return;
|
||||
|
|
@ -1321,15 +1326,15 @@ void FillRectangleOpa(Draw &w, double x0, double y0, double x1, double y1, const
|
|||
w.DrawRect(int(x0), int(y0), abs(int(x1 - x0)), abs(int(y1 - y0)), opacolor);
|
||||
}
|
||||
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1, const int &scale,
|
||||
const double opacity, const Color &background, const Color &color)
|
||||
void FillRectangleOpa(Painter &w, double x0, double y0, double x1, double y1, int scale,
|
||||
double opacity, const Color &background, const Color &color)
|
||||
{
|
||||
if (IsNull(color))
|
||||
return;
|
||||
w.Rectangle(x0, y0, x1 - x0, y1 - y0).Opacity(opacity).Fill(color);
|
||||
}
|
||||
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Point> &p, const int &scale, const double opacity,
|
||||
void DrawPolylineOpa(Draw& w, const Vector<Point> &p, int scale, double opacity,
|
||||
double thick, const Color &_color, String dash, const Color &background)
|
||||
{
|
||||
ASSERT(!p.IsEmpty());
|
||||
|
|
@ -1367,7 +1372,7 @@ void DrawPolylineOpa(Draw& w, const Vector<Point> &p, const int &scale, const do
|
|||
}
|
||||
}
|
||||
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Point> &p, const int &scale, const double opacity,
|
||||
void DrawPolylineOpa(Painter& w, const Vector<Point> &p, int scale, double opacity,
|
||||
double thick, const Color &color, String dash, const Color &background)
|
||||
{
|
||||
ASSERT(!p.IsEmpty());
|
||||
|
|
@ -1379,7 +1384,7 @@ void DrawPolylineOpa(Painter& w, const Vector<Point> &p, const int &scale, const
|
|||
w.Stroke(thick*scale, color);
|
||||
}
|
||||
|
||||
void FillPolylineOpa(Draw& w, const Vector<Point> &p, const int &scale, const double opacity,
|
||||
void FillPolylineOpa(Draw& w, const Vector<Point> &p, int scale, double opacity,
|
||||
const Color &background, const Color &fillColor)
|
||||
{
|
||||
ASSERT(!p.IsEmpty());
|
||||
|
|
@ -1388,7 +1393,7 @@ void FillPolylineOpa(Draw& w, const Vector<Point> &p, const int &scale, const do
|
|||
w.DrawPolygon(p, opacolor);
|
||||
}
|
||||
|
||||
void FillPolylineOpa(Painter& w, const Vector<Point> &p, const int &scale, const double opacity,
|
||||
void FillPolylineOpa(Painter& w, const Vector<Point> &p, int scale, double opacity,
|
||||
const Color &background, const Color &fillColor)
|
||||
{
|
||||
ASSERT(!p.IsEmpty());
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ public:
|
|||
Callback WhenSetRange;
|
||||
Callback WhenSetXYMin;
|
||||
|
||||
ScatterDraw& SetSize(Size sz) {size = sz; return *this;};
|
||||
virtual Size GetSize() const {return size;};
|
||||
ScatterDraw& SetSize(Size sz) {size = sz; return *this;};
|
||||
virtual Size GetSize() {return size;};
|
||||
|
||||
ScatterDraw& SetColor(const Color& _color);
|
||||
ScatterDraw& SetTitle(const String& _title);
|
||||
|
|
@ -328,7 +328,7 @@ public:
|
|||
Color GetFillColor(int index) const;
|
||||
|
||||
ScatterDraw &SetMarkWidth(int index, double width);
|
||||
double GetMarkWidth(int index) const;
|
||||
double GetMarkWidth(int index);
|
||||
void SetMarkColor(int index, const Color& pcolor);
|
||||
Color GetMarkColor(int index) const;
|
||||
void NoMark(int index);
|
||||
|
|
@ -353,8 +353,9 @@ public:
|
|||
ScatterDraw& Id(int index, int id);
|
||||
int GetId(int index);
|
||||
|
||||
Drawing GetDrawing();
|
||||
Image GetImage(int scale = 1);
|
||||
Drawing GetDrawing(bool ctrl = true);
|
||||
Image GetImage(const Size &size, int scale = 2, bool ctrl = true);
|
||||
Image GetImage(int scale = 2);
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
void SaveAsMetafile(const char* file) const;
|
||||
|
|
@ -419,7 +420,7 @@ protected:
|
|||
bool showLegend;
|
||||
int legendWidth;
|
||||
|
||||
void DrawLegend(Draw& w,const int& scale) const;
|
||||
void DrawLegend(Draw& w, const Size &size, int scale) const;
|
||||
|
||||
void Scrolling(bool down, Point &pt, bool isOut = false);
|
||||
|
||||
|
|
@ -441,62 +442,69 @@ protected:
|
|||
else return FormatDouble(d, 0);
|
||||
} else return FormatDoubleExp(d, 2);
|
||||
}
|
||||
String VariableFormatX(const double& d) const {return VariableFormat(xRange, d);}
|
||||
String VariableFormatY(const double& d) const {return VariableFormat(yRange, d);}
|
||||
String VariableFormatY2(const double& d) const {return VariableFormat(yRange2, d);}
|
||||
String VariableFormatX(double d) const {return VariableFormat(xRange, d);}
|
||||
String VariableFormatY(double d) const {return VariableFormat(yRange, d);}
|
||||
String VariableFormatY2(double d) const {return VariableFormat(yRange2, d);}
|
||||
|
||||
template<class T>
|
||||
void SetDrawing(T& w, const int& scale);
|
||||
void SetDrawing(T& w, const Size &size, int scale, bool ctrl = false);
|
||||
template<class T>
|
||||
void Plot(T& w, const int& scale,const int& l,const int& h);
|
||||
void Plot(T& w, const Size &size, int scale);
|
||||
template<class T>
|
||||
bool PlotTexts(T& w, const Size &size, int scale);
|
||||
|
||||
void AdjustMinUnitX();
|
||||
void AdjustMinUnitY();
|
||||
void AdjustMinUnitY2();
|
||||
|
||||
private:
|
||||
Size size;
|
||||
Size size; // Size to be used for all but screen painting
|
||||
static void ParseTextMultiline(const String &text, Font fnt,
|
||||
Upp::Array <String> &texts, Upp::Array <Size> &sizes);
|
||||
int plotW, plotH;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void ScatterDraw::SetDrawing(T& w, const int& scale)
|
||||
void ScatterDraw::SetDrawing(T& w, const Size& size, int scale, bool ctrl)
|
||||
{
|
||||
if (GetSize().cx == 0 || GetSize().cy == 0)
|
||||
if (size.cx == 0 || size.cy == 0)
|
||||
return;
|
||||
|
||||
w.DrawRect(scale*GetSize(), graphColor);
|
||||
|
||||
if (typeid(T) == typeid(BufferPainter)) {
|
||||
Painter &p = (Painter &)w;
|
||||
p.Translate(0, 0.5);
|
||||
}
|
||||
|
||||
Size sz(0, 0);
|
||||
w.DrawRect(scale*size, graphColor);
|
||||
|
||||
titleHeight = !title.IsEmpty() ? scale*titleFont.GetHeight() : 0;
|
||||
|
||||
plotW = scale*(size.cx - (hPlotLeft + hPlotRight));
|
||||
plotH = scale*(size.cy - (vPlotTop + vPlotBottom)) - titleHeight;
|
||||
|
||||
if (!ctrl) {
|
||||
if (!PlotTexts(w, GetSize(), scale))
|
||||
return;
|
||||
} else
|
||||
w.Offset(Point(scale*hPlotLeft, scale*vPlotTop + titleHeight));
|
||||
|
||||
Plot(w, size, scale);
|
||||
|
||||
ClipEnd(w);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ScatterDraw::PlotTexts(T& w, const Size &size, int scale)
|
||||
{
|
||||
if(titleHeight > 0) {
|
||||
Font fontTitle6;
|
||||
fontTitle6 = titleFont;
|
||||
fontTitle6.Height(titleHeight);
|
||||
fontTitle6.Width(scale*titleFont.GetWidth());
|
||||
sz = GetTextSize(title, fontTitle6);
|
||||
DrawText(w, (scale*GetSize().cx - sz.cx)/2., scale*2., 0, title, fontTitle6, titleColor);
|
||||
}
|
||||
|
||||
Size sz = GetTextSize(title, fontTitle6);
|
||||
DrawText(w, (scale*size.cx - sz.cx)/2., scale*2., 0, title, fontTitle6, titleColor);
|
||||
}
|
||||
w.Offset(Point(scale*hPlotLeft, scale*vPlotTop + titleHeight));
|
||||
if(showLegend)
|
||||
DrawLegend(w, scale);
|
||||
DrawLegend(w, size, scale);
|
||||
|
||||
int plotW = scale*(GetSize().cx - (hPlotLeft + hPlotRight));
|
||||
int plotH = scale*(GetSize().cy - (vPlotTop + vPlotBottom)) - titleHeight;
|
||||
|
||||
if (plotW < 0 || plotH < 0) {
|
||||
ClipEnd(w);
|
||||
return;
|
||||
}
|
||||
if (plotW < 0 || plotH < 0)
|
||||
return false;
|
||||
|
||||
Font fontLabel;
|
||||
fontLabel = labelsFont;
|
||||
|
|
@ -507,18 +515,11 @@ void ScatterDraw::SetDrawing(T& w, const int& scale)
|
|||
Size ly2 = GetTextSize(yLabel2, fontLabel);
|
||||
DrawText(w, (plotW - lx.cx)/2., plotH + scale*(vPlotBottom - 2) - lx.cy, 0, xLabel, fontLabel, labelsColor);
|
||||
DrawText(w, scale*(2 - hPlotLeft), (plotH + ly.cx)/2., 900, yLabel, fontLabel, labelsColor);
|
||||
DrawText(w, scale*GetSize().cx - ly2.cy - 42*scale, (plotH + ly2.cx)/2., 900, yLabel2, fontLabel, labelsColor);
|
||||
DrawText(w, scale*size.cx - ly2.cy - 42*scale, (plotH + ly2.cx)/2., 900, yLabel2, fontLabel, labelsColor);
|
||||
|
||||
if (xRange == 0 || xMajorUnit == 0 || yRange == 0 || yMajorUnit == 0 || yRange2 == 0) {
|
||||
ClipEnd(w);
|
||||
return;
|
||||
}
|
||||
if (xRange == 0 || xMajorUnit == 0 || yRange == 0 || yMajorUnit == 0 || yRange2 == 0)
|
||||
return false;
|
||||
|
||||
if (typeid(T) == typeid(BufferPainter)) {
|
||||
Painter &p = (Painter &)w;
|
||||
p.Translate(0.5, 0);
|
||||
}
|
||||
|
||||
Font standard6 = GetStdFont();
|
||||
standard6.Height(scale*GetStdFont().GetHeight());
|
||||
|
||||
|
|
@ -567,37 +568,43 @@ void ScatterDraw::SetDrawing(T& w, const int& scale)
|
|||
gridLabelY2 = VariableFormatY2(gridY2);
|
||||
DrawText(w, plotW + scale*10, reticleY - scale*8, 0, gridLabelY2, standard6, axisColor);
|
||||
}
|
||||
}
|
||||
Plot(w, scale, plotW, plotH);
|
||||
ClipEnd(w);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void ScatterDraw::Plot(T& w, const int& scale, const int& plotW, const int& plotH)
|
||||
{
|
||||
double d1 = xRange/xMajorUnit;
|
||||
double d2 = yRange/yMajorUnit;
|
||||
|
||||
w.DrawRect(1, 1, plotW - 2, plotH - 1, plotAreaColor);
|
||||
|
||||
if (drawVGrid)
|
||||
for(int i = 0; xMinUnit + i*xMajorUnit < xRange; i++)
|
||||
DrawLineOpa(w, fround(plotW*xMinUnit/xRange + i*plotW/d1), 0, fround(plotW*xMinUnit/xRange + i*plotW/d1), plotH,
|
||||
1, 1, gridWidth, gridColor, "2 2");
|
||||
|
||||
if (drawHGrid)
|
||||
for(int i = 0; yMinUnit + i*yMajorUnit < yRange; i++)
|
||||
DrawLineOpa(w, 0, fround(-plotH*yMinUnit/yRange + plotH - i*plotH/d2), plotW, fround(-plotH*yMinUnit/yRange + plotH - i*plotH/d2),
|
||||
1, 1, gridWidth, gridColor, "2 2");
|
||||
|
||||
}
|
||||
|
||||
w.DrawLine(0, plotH, plotW, plotH, fround(gridWidth*scale), Black);
|
||||
w.DrawLine(0, 0, plotW, 0, fround(gridWidth*scale), Black);
|
||||
w.DrawLine(0, 0, 0, plotH, fround(gridWidth*scale), Black);
|
||||
w.DrawLine(plotW, 0, plotW, plotH + 1, fround(gridWidth*scale), Black);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ScatterDraw::Plot(T& w, const Size &size, int scale)
|
||||
{
|
||||
double d1 = xRange/xMajorUnit;
|
||||
double d2 = yRange/yMajorUnit;
|
||||
|
||||
Clip(w, 0, 0, plotW, plotH);
|
||||
|
||||
w.DrawRect(0, 0, plotW, plotH, plotAreaColor);
|
||||
|
||||
if (drawVGrid) {
|
||||
double x0 = plotW*xMinUnit/xRange;
|
||||
for(int i = 0; xMinUnit + i*xMajorUnit < xRange; i++) {
|
||||
int xg = fround(x0 + i*plotW/d1);
|
||||
if (xg > gridWidth || xg < plotW - gridWidth)
|
||||
DrawLineOpa(w, xg, 0, xg, fround(plotH), 1, 1, gridWidth, gridColor, "2 2");
|
||||
}
|
||||
}
|
||||
if (drawHGrid) {
|
||||
double y0 = -plotH*yMinUnit/yRange + plotH;
|
||||
for(int i = 0; yMinUnit + i*yMajorUnit < yRange; i++) {
|
||||
int yg = fround(y0 - i*plotH/d2);
|
||||
if (yg > gridWidth || yg < plotH - gridWidth)
|
||||
DrawLineOpa(w, 0, yg, fround(plotW), yg, 1, 1, gridWidth, gridColor, "2 2");
|
||||
}
|
||||
}
|
||||
|
||||
if (!series.IsEmpty()) {
|
||||
for (int j = 0; j < series.GetCount(); j++) {
|
||||
if (series[j].opacity == 0 || (!series[j].seriesPlot && !series[j].markPlot))
|
||||
|
|
@ -691,7 +698,7 @@ void ScatterDraw::Plot(T& w, const int& scale, const int& plotW, const int& plot
|
|||
}
|
||||
}
|
||||
}
|
||||
w.End();
|
||||
ClipEnd(w);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue