Testing CGraphic - questions and suggestions - page 4

 
Roman Konopelko:

Even if you make them virtual , you won't be able to do normal overloading without full access to CGraphics class members, so they should all (most) be declared as protected.

and these functions ***Plot are just protected


 
o_O:

and these ***Plot functions are just as protected

class CGraphic
  {
private:
   CArrayObj         m_arr_curves;
   CCanvas           m_canvas;
   //--- parameters background
   int               m_height;
   int               m_width;
   //--- parameters work space
   int               m_left;
   int               m_right;
   int               m_up;
   int               m_down;
   //--- default parameters work space
   int               m_left0;
   int               m_right0;
   int               m_up0;
   int               m_down0;
   //--- size of dash on the axes
   int               m_mark_size;
   //--- scaling parameters
   double            m_dx;
   double            m_dy;
I was talking about CGraphic class members, now they are all private, and without access to m_canvas, m_dx, m_dy and other members in the descendant, overloading will not work.
 
Roman Konopelko:
I was talking about CGraphic class members, now they are all private, and without access to m_canvas, m_dx, m_dy and other members in the descendant, overloading will not work.

OK, then everything is in your hands) I'll wait.

So far, I've temporarily changed it locally

 

In some functions (not everywhere) if there is a division, it is without a 0 check.

e.g.

void CGraphic::CalculateXAxis(void)
  {
...
...
   double x_size=(m_x.Max()-m_x.Min());
   double xf_size=xf2-xf1;
//--- keep scaling parameters  
   m_dx=xf_size/x_size;

here zero_devide will occur if x.Max() == Min()

also in Axis::CalcStepSize / CalcBoundedStepSize / SelectAxisScale etc.

 
o_O:

In some functions (not everywhere) if there is a division, it is without a 0 check.

for example

void CGraphic::CalculateXAxis(void)
  {
...
...
   double x_size=(m_x.Max()-m_x.Min());
   double xf_size=xf2-xf1;
//--- keep scaling parameters  
   m_dx=xf_size/x_size;

zero_devide will occur if x.Max() == Min()

also in Axis::CalcStepSize / CalcBoundedStepSize / SelectAxisScale etc.

Thank you, I will correct it.

In order not to overload the library with multiple checks, I tried to take into account all cases in the Axis::SelectAxisScal method.

Files:
Axis.mqh  11 kb
 

1. this seems to be the file without this morning's edits on enum ENUM_AXIS_TYPE

---

2. tested ENUM_AXIS_TYPE from previous page

since you are doing ValuesFunctionFormat in callback function style, you have to return some void* parameter in the function.

typedef string(*DoubleToStringFunction)(double, void*);

in CAxis to add

   DoubleToStringFunction m_values_func;
   void* m_cbdata; // <---

...

// изменить
   void              ValuesFunctionFormat(DoubleToStringFunction func, void* cbdata) { m_values_func=func; m_cbdata=cbdata; }

// добавить получение этого void*
   void* ValuesFunctionFormatCBData(void)    const { return m_c bdata; }


in CGraphic::CalculateXAxis

   DoubleToStringFunction xfunc=m_x.ValuesFunctionFormat();
   void* cbdata=m_x.ValuesFunctionFormatCBData(); // <---

...

         case AXIS_TYPE_CUSTOM:
           {
            m_xvalues[i]=(xfunc==NULL) ? NULL : xfunc(x, cbdata); // <---


----

This callback parameter is needed to pass a pointer to an object that knows where the arrX array is.

Because the function is essentially static, it's impossible to know what exactly called it.


ZS.

And here's what the result of time series displaying looks like already (I'll ask more about lines with readings later, there's an inconvenience of getting coordinates there :)

 
o_O:

And this is what the result of the timeseries already looks like in principle (I'll ask more about the lines with readings later, there's the awkwardness of getting coordinates there :)

Please make a video or longer animation from the moment of empty chart. I don't understand from the GIF what it is.
 
fxsaber:
Please make a video or longer animation from the moment of the empty chart. I don't get it from the GIF.

is that better?

this expert works on roman's Canvas + CGraphic

In this case I'm building a P/L from several tools on it
 
o_O:

this expert works on Roman's Canvas + CGraphic

In this case, I build P/L from several instruments on it

Clearer now. Is crosshair (and possibly other interactivity) a built-in (necessary) functionality of Roman's library, or did you inherit it?

I want to see elements of interactivity in SB graphics - crosshair, zoom (in both directions) and highlighting of cursor values.

I.e. I do GraphPlot via EA/indicator, and I get such functionality at once.

 
fxsaber:

Now to be clearer. Is crosshair (and possibly other interactivity) a built-in (necessary) functionality of Roman's Bible, or did you add inheritance?

Yes, I inherited it.

I want to see some elements of interactivity in SB graphics - crosshair, zoom (both ways) and highlighting of cursor values.

We'll have a chat with the main one. I need something too.

- Backlighting (if not it, then at least the GetNearY/X function) is needed. The highlighting is better to be implemented by inheritance anyway. It's different in each of our representations )

- don't need crosshair itself yet, because it's the result of chart events that have nothing to do with the library yet.

- Obtaining scale values - which are determined by pixel coordinate - is a must.

- With zoomo it's tricky. 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 any other objects. And this is very good.
I plan to implement zoom independently by inheritance, put scrollbars and rescale as needed.

Reason: