Testing CGraphic - questions and suggestions - page 5

 
o_O:

- It's difficult with zoomo. As there are no scroll bars. And to be honest, I wouldn't want them to be implemented in this class. Right now it only uses CCanvas, and doesn't ask for other objects. And this is very good.

I plan to implement zoom independently by inheritance, put scrollbars and rescale as needed.

Scrollbars are evil. You can rotate a normal chart without any bars - with mouse and keyboard.
 
fxsaber:
Scroll bars are evil. You can spin a normal chart without any bars - with the mouse and the keyboard.

there are no chart events for scrolling. MQL does not send them.

But you can simply dragndrop with the mouse instead of spinning the wheel.

 
o_O:

but you can simply dragndrop with the mouse instead of spinning the wheel.

Yes, that's how I scroll and zoom in ZoomPrice.
 

@Roman Konopelko


What about #36?


And found another zero divide

 

I can clarify (to reproduce)

a CurveAdd(arrY, CURVE_HISTOGRAM, "P/L") curve was added; it has an array arrY of size 1 or 0 elements.

and judging by this curve constructor m_xmax=m_xmin=0.

 
o_O:

@Roman Konopelko

What about #36?
And found another zero divide

Implemented #36 and fixed the zero divide error.

The only thing is that ValuesFunctionFormat has not changed to:

void              ValuesFunctionFormat(DoubleToStringFunction func, void* cbdata) { m_values_func=func; m_cbdata=cbdata; }

And implemented methods to get/set a pointer to a function and a pointer to an object for it separately:

   DoubleToStringFunction ValuesFunctionFormat(void)    const { return(m_values_func);    }
   void              ValuesFunctionFormat(DoubleToStringFunction func) { m_values_func=func; }
   void             *ValuesFunctionFormatCBData(void)   const { return(m_values_cbdata);  }
   void              ValuesFunctionFormatCBData(void *cbdata) { m_values_cbdata=cbdata;   }
Files:
Axis.mqh  12 kb
Curve.mqh  21 kb
Graphic.mqh  86 kb
 

Please fix the colour handling in kanvas.

Now it does not take the alpha channel into account. color instead of uint is everywhere.

Because of this, when drawing on canvas, there are chart gaps everywhere (transparent grids and frames, because in color the alpha channel =0, i.e. completely transparent)

Only in some functions you fixed it by constantly calling ColorToARGB

e.g.

void CGraphic::CreateBackground(void)
  {
...
//--- create background
   m_canvas.FillRectangle(0,0,m_width,m_up-1,ColorToARGB(m_background.clr,255));
   m_canvas.FillRectangle(0,m_height-m_down+1,m_width,m_height,ColorToARGB(m_background.clr,255));
   m_canvas.FillRectangle(0,m_up,m_left-1,m_height-m_down,ColorToARGB(m_background.clr,255));
   m_canvas.FillRectangle(m_width-m_right+1,m_up,m_width,m_height-m_down,ColorToARGB(m_background.clr,255));


But why? if you want to make colour a uint type and set it with alpha channel

As here (and in other colour functions)

void CGraphic::SetDefaultParameters(void)
  {
...
//--- sets the default values for grid
   m_grid.clr_line=ColorToARGB(clrWhiteSmoke);
   m_grid.clr_axis_line=ColorToARGB(clrSilver);
   m_grid.clr_frame=ColorToARGB(clrBlack);
   m_grid.clr_background=ColorToARGB(clrWhite);

----

PS.

The fact that the canvas itself has COLOR_FORMAT_XRGB_NOALPHA is not important in this case.

 

decided to check the fixes in terminal update 1502

where are all the improvements made?

No ValuesFunctionFormat, no bug fixes zerodevide

LOL

happy holidays )

 

installed 1510.

ValuesFunctionFormat is there, it's OK.

--

@Roman Konopelko see sentence please.

In CGraphic code it is just a few variables and functions. The substitution is not difficult.

But it removes the problem of transparency in rendering. Because in color alpha channel =100% transparency, which is wrong.

 
o_O:

@Roman Konopelko see sentence please.

There are only a few variables and functions in CGraphic code. The substitution is not difficult.

But it removes the problem of transparency when rendering. In fact, in color alpha channel = 100% transparency, which is wrong.

In the CGraphic class I have replaced the color type by uint in all places, as you suggested.

Also I have added new methods in CCanvas class, which allow to draw primitives with a given thickness:
   void              LineThickVertical(const int x,const int y1,const int y2,const int size,const uint clr,const uint style,ENUM_LINE_END end_style);
   void              LineThickHorizontal(const int x1,const int x2,const int y,const int size,const uint clr,const uint style,ENUM_LINE_END end_style);
   void              LineThick(const int x1,const int y1,const int x2,const int y2,const int size,const uint clr,const uint style,ENUM_LINE_END end_style);
   void              PolylineThick(const int &x[],const int &y[],const int size,const uint clr,const uint style,ENUM_LINE_END end_style);
   void              PolygonThick(const int &x[],const int &y[],const int size,const uint clr,const uint style,ENUM_LINE_END end_style);
In line with the innovation of CCanvas, I expanded the properties of CCurve:
   ENUM_LINE_END     LinesEndStyle(void)                      const { return(m_lines_end_style); }
   int               LinesWidth(void)                         const { return(m_lines_width);     }
   void              LinesEndStyle(ENUM_LINE_END end_style)   { m_lines_end_style=end_style; }
   void              LinesWidth(const int width)              { m_lines_width=width;         }
You can now specify the thickness of the lines and the style of its ends when drawing a curve with lines.

Example:
#include <Graphics\Graphic.mqh>
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   double x[] = { -100, -40, -10, 20, 30, 40, 50, 60, 70, 80, 120 };
   double y[] = { -5, 4, -10, 23, 17, 18, -9, 13, 17, 4, 9 };
   CGraphic graphic;
   graphic.Create(0,"G",0,30,30,780,380);
//--- plot curve
   CCurve *curve=graphic.CurveAdd(x,y,CURVE_LINES);
   curve.LinesSmooth(true);
   curve.LinesStyle(STYLE_DOT);
   curve.LinesEndStyle(LINE_END_ROUND);
   curve.LinesWidth(10);
   graphic.CurvePlotAll();
   graphic.Update();
  }
Result:


The implementation of these methods is based on the Fast Prefiltered Lines algorithm, in which the degree of line smoothness is based on the selected filter. If necessary, I will describe it in more detail.
Files:
Canvas.mqh  144 kb
Axis.mqh  12 kb
Curve.mqh  22 kb
Graphic.mqh  86 kb