MgGraph

MgGraph — Data model to keep graphs' layout

Synopsis




            MgGraph;
enum        MgGraphType;
guint       mg_graph_get_type               (void);
GObject*    mg_graph_new                    (MgConf *conf,
                                             MgGraphType type);
MgGraphType mg_graph_get_graph_type         (MgGraph *graph);
void        mg_graph_add_item               (MgGraph *graph,
                                             MgGraphItem *item);
void        mg_graph_del_item               (MgGraph *graph,
                                             MgGraphItem *item);
MgGraphItem* mg_graph_get_item_from_obj     (MgGraph *graph,
                                             MgBase *ref_obj,
                                             gboolean create_if_needed);
GSList*     mg_graph_get_items              (MgGraph *graph);

Object Hierarchy


  GObject
   +----MgBase
         +----MgGraph

Implemented Interfaces

MgGraph implements MgXmlStorage.

Properties


  "ref-object"           gpointer              : Read / Write

Signal Prototypes


"item-added"
            void        user_function      (MgGraph *mggraph,
                                            gpointer arg1,
                                            gpointer user_data);
"item-dropped"
            void        user_function      (MgGraph *mggraph,
                                            gpointer arg1,
                                            gpointer user_data);
"item-moved"
            void        user_function      (MgGraph *mggraph,
                                            gpointer arg1,
                                            gpointer user_data);

Description

An instance of this object is required for each unique graph that is to be created. It is the "model" part of the graph. The "view" and "controler" parts are brought by the MgCanvas and associated widgets.

Details

MgGraph

typedef struct _MgGraph MgGraph;


enum MgGraphType

typedef enum {
        MG_GRAPH_DB_RELATIONS,
	MG_GRAPH_QUERY_JOINS,
        MG_GRAPH_MODELLING /* for future extensions */
} MgGraphType;

MG_GRAPH_DB_RELATIONS The graph represents a part (or all) of the database's relations between tables
MG_GRAPH_QUERY_JOINS The graph represents the joins between several targets in a query
MG_GRAPH_MODELLING The graph is a ERD modelling graph (not yet implemented...)

mg_graph_get_type ()

guint       mg_graph_get_type               (void);

Returns :

mg_graph_new ()

GObject*    mg_graph_new                    (MgConf *conf,
                                             MgGraphType type);

Creates a new MgGraph object. The graph type is used only to be able to sort out the different types of graphs. It brings no special functionnality.

conf : a MgConf object
type : the graph type (one of MgGraphType)
Returns : the newly created object

mg_graph_get_graph_type ()

MgGraphType mg_graph_get_graph_type         (MgGraph *graph);

Get the graph type of graph.

graph : a MgGraph object
Returns : the type

mg_graph_add_item ()

void        mg_graph_add_item               (MgGraph *graph,
                                             MgGraphItem *item);

Adds item to graph.

graph : a MgGraph object
item : a MgGraphItem object

mg_graph_del_item ()

void        mg_graph_del_item               (MgGraph *graph,
                                             MgGraphItem *item);

Removes item from graph

graph : a MgGraph object
item : a MgGraphItem object

mg_graph_get_item_from_obj ()

MgGraphItem* mg_graph_get_item_from_obj     (MgGraph *graph,
                                             MgBase *ref_obj,
                                             gboolean create_if_needed);

Get a pointer to a MgGraphItem item from the object is represents. If the searched MgGraphItem is not found and create_if_needed is TRUE, then a new MgGraphItem is created.

graph : a MgGraph object
ref_obj : the MgBase the returned item references
create_if_needed :
Returns : the MgGraphItem object, or NULL if not found

mg_graph_get_items ()

GSList*     mg_graph_get_items              (MgGraph *graph);

Get a list of MgGraphItem objects which are items of graph

graph : a MgGraph object
Returns : a new list of MgGraphItem objects

Properties

The "ref-object" property

  "ref-object"           gpointer              : Read / Write

Signals

The "item-added" signal

void        user_function                  (MgGraph *mggraph,
                                            gpointer arg1,
                                            gpointer user_data);

mggraph : the object which received the signal.
arg1 :
user_data : user data set when the signal handler was connected.

The "item-dropped" signal

void        user_function                  (MgGraph *mggraph,
                                            gpointer arg1,
                                            gpointer user_data);

mggraph : the object which received the signal.
arg1 :
user_data : user data set when the signal handler was connected.

The "item-moved" signal

void        user_function                  (MgGraph *mggraph,
                                            gpointer arg1,
                                            gpointer user_data);

mggraph : the object which received the signal.
arg1 :
user_data : user data set when the signal handler was connected.