I've also got the hang of making a graphics library, just with the elements I need.
The main trick of the library is its windowing engine:
it does not depend on graphics, you can say virtual windows without a single function to work with graphics, even absolutely windows will work correctly(events,properties)
sets of properties for a window that affect its behaviour, dependent properties of that window and others
as graphics you can use both standard objects and canvas, and DirectX, whatever you like
engine windows are the building blocks for building graphical elements
use of different optimizations for performance (exclusion of unnecessary calls of graphic system functions, as well as exclusion from drawing of invisible boxes)
Simplicity in creation of a new graphic item, both implementation of graphic design and creation of child graphic items/windows structure. All events and calculation of dependent properties will be performed at engine level, it does not distinguish custom graphic items, it works only at basic windows level
Creating and deleting the standard OBJ_RECTANGLE_LABEL object
This implements a method for changing the properties of the standard OBJ_RECTANGLE_LABEL object, rustling through the help and using the properties of interest
bool cV_object_rectangle::_Set_property(eV_object_property property,sV_property_value &property_value)
{
_is_redraw_object=true;
switch(property)
{
case vop_s_is_hidden:
{
if(property_value.data_long)
{
ObjectSetInteger(0,visual_object_name,OBJPROP_XSIZE,0);
ObjectSetInteger(0,visual_object_name,OBJPROP_YSIZE,0);
ObjectSetInteger(0,visual_object_name,OBJPROP_XDISTANCE,-20);
ObjectSetInteger(0,visual_object_name,OBJPROP_YDISTANCE,-20);
}
else
{
ObjectSetInteger(0,visual_object_name,OBJPROP_XSIZE,_property_values[vop_s_size_real_x].data_long);
ObjectSetInteger(0,visual_object_name,OBJPROP_YSIZE,_property_values[vop_s_size_real_y].data_long);
ObjectSetInteger(0,visual_object_name,OBJPROP_XDISTANCE,_property_values[vop_s_position_real_x].data_long);
ObjectSetInteger(0,visual_object_name,OBJPROP_YDISTANCE,_property_values[vop_s_position_real_y].data_long);
}
break;
}
case vop_s_color_back:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_BGCOLOR,property_value.data_long);
break;
}
case vop_border_type:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_BORDER_TYPE,property_value.data_long);
break;
}
case vop_s_color_borders:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_COLOR,property_value.data_long);
break;
}
case vop_s_position_real_x:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_XDISTANCE,property_value.data_long);
break;
}
case vop_s_position_real_y:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_YDISTANCE,property_value.data_long);
break;
}
case vop_s_size_real_x:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_XSIZE,property_value.data_long);
break;
}
case vop_s_size_real_y:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_YSIZE,property_value.data_long);
break;
}
case vop_font_size:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_FONTSIZE,property_value.data_long);
break;
}
case vop_line_width:
{
ObjectSetInteger(0,visual_object_name,OBJPROP_WIDTH,property_value.data_long);
break;
}
default:
{
_is_redraw_object=false;
}
}
returntrue;
}
easy event handling
This is an external event handler, the name of the object of interest (window/graphical item) can be specified when creating it
The text label is implemented via kanvas because the width and height cannot be changed in OBJ_LABEL object, and for this reason rendering is performed when a CHARTEVENT_ON_PAINT event occurs (requiring redrawing)
bool cV_object_label::_On_event(const sEvent &event)
{
if(event.id==CHARTEVENT_ON_PAINT)
{
color color_back=clrBlack;
if(CheckPointer(_object_parent))
{
color_back=color(_object_parent._property_values[vop_color_back].data_long);
}
int width=int(_property_values[vop_s_size_real_x].data_long);
int height=int(_property_values[vop_s_size_real_y].data_long);
int x=int(_property_values[vop_s_position_global_x].data_long-_property_values[vop_s_position_real_x].data_long);
int y=int(_property_values[vop_s_position_global_y].data_long-_property_values[vop_s_position_real_y].data_long);
_canvas.Resize(width,height);
width=int(_property_values[vop_size_x].data_long);
height=int(_property_values[vop_size_y].data_long);
_canvas.Erase(ColorToARGB(color_back));
switch(int(_property_values[vop_text_anchor].data_long))
{
caseTA_CENTER:
{
x=x+(width-_canvas.TextWidth(_property_values[vop_text].data_string))/2;
break;
}
caseTA_RIGHT:
{
x=x+(width-_canvas.TextWidth(_property_values[vop_text].data_string));
break;
}
}
_canvas.TextOut(x,y,_property_values[vop_text].data_string,ColorToARGB(color(_property_values[vop_s_color_back].data_long)));//);
_canvas.Update(false);
}
returntrue;
}
What to render and update is determined automatically. The properties are logged before calling ChartRedraw() . Events that have not caused the chart to be redrawn are skipped.
How is the library progressing?
everything is more than fine.
I've also got the hang of making a graphics library, just with the elements I need.
The main trick of the library is its windowing engine:
Creating and deleting the standard OBJ_RECTANGLE_LABEL object
This implements a method for changing the properties of the standard OBJ_RECTANGLE_LABEL object, rustling through the help and using the properties of interest
- easy event handling
This is an external event handler, the name of the object of interest (window/graphical item) can be specified when creating itThe text label is implemented via kanvas because the width and height cannot be changed in OBJ_LABEL object, and for this reason rendering is performed when a CHARTEVENT_ON_PAINT event occurs (requiring redrawing)
What to render and update is determined automatically. The properties are logged before calling ChartRedraw() . Events that have not caused the chart to be redrawn are skipped.
The demo is in attached file, above sources are used in it.
The demo doesn't display all possible properties, only some of them:
It's still a work in progress, so far.
The demo doesn't display all possible properties, only some of them:
It's still a work in progress, for now.
Good luck with the development! :)
Good luck with the development! :)
Thanks :)
Tested the functionality and potential of 3D graphics in MT5 on a weak computer with 4 GB of RAM and 2 processor cores.
It works fine even after a long pause in programming. But the thing is heavy and it takes a lot of hard work to create something serious.
Tested the functionality and potential of 3D graphics in MT5 on a weak computer with 4 GB of RAM and 2 processor cores.
It works fine even after a long pause in programming. But, the thing is heavy and it takes a lot of hard work to develop something serious.
For HFT, I think 3D will be useful for graphical analysis of the cup's volume and order flow.
But I don't know how to interpret such information.
My God! What is all this for?