I'm implementing a drawing system for inserting graph items on a opengl viewport.
For now i would insert a line and a point entity for semplicity , and more than anything else i'm search at a solid system.
A point or a line are CEntity and each CEntity has his controller(like MVC) that has all the functions that can modify the graphics properties of the CEntity owner.
This controller can be different from entity to entity
For ex:
class CControllerLine
{
public:
CControllerLine();
Move(int x, int y){...Line impl};
SetColor(int color){...line impl};
Scale(float toX, float toY){...Line impl}
Rotate(float angle){...Line impl}
};
class CControllerPoint
{
public:
CControllerLine();
Move(int x, int y){Point...impl};
SetColor(int color){Point...impl};
Scale(float toX, float toY){Point...impl}
//Rotate(float angle){WARNING In the point the Rotate function isn't implemented I disable the item of the context menu}
};
I wish manage all with the std::function of the c++11I wish create a current view::func generic in the view (compatible after the std::bind of parameters with all the possible modifiers :x,y,color,scale,position ecc...)
The generic std::function "view::func" has a void return type and is a "placeholder"(like a polymorphic pointer) where will insert depending of the user choosing on the ui(with buttons and other widgets) any different but compatible std::function extracted from a current widget's property (that is inherited from the base widget with a std::function property "widgetfunction" that contains the correct generic std::function typical of the widget)
When i do an action pressing the "Action" button :
1)extract the widget's typical function from the "widgetfunction" property of the pressed button (and place it in the current std::function view::func)
2)bind the view::function on the controller class of the entity pointer (can be a point or a line entity that i extract with a picking system)with all the needed parameters like x,y, ecc...
3)launch the function with view::func()
I wish do only a thing :
is possible know if any controller(that can be CControllerLine or CControllerPoint) has or not has a the specific function extracted from the widget function property?
For example if the widget property is Rotate(float angle)
i do:
if the CurrentEnttity's controller HAS( Rotate(float angle) ) calls CurrentEntity::Rotate(angle)
else
disable pressed widget or do nothing
1)if the current entity is a line i can call the rotate function on the selected current entity.
2)if the current entity is a point i can't call the rotate function on the selected current entity and i disable the widget dinamically.







