Commit 8f1c179f authored by Claes Sjofors's avatar Claes Sjofors

Ge, implementation of dynamics for subgraphs in subgraphs

parent e3b14589
......@@ -383,6 +383,8 @@ GeDyn::GeDyn( const GeDyn& x) :
{
GeDynElem *elem, *e;
strcpy(recursive_hostobject, x.recursive_hostobject);
for ( elem = x.elements; elem; elem = elem->next) {
e = 0;
switch( elem->dyn_type1) {
......@@ -909,12 +911,17 @@ void GeDyn::set_hostobject( char *hostobject)
void GeDyn::get_hostobject( char *hostobject)
{
bool found = false;
for ( GeDynElem *elem = elements; elem; elem = elem->next) {
if ( elem->dyn_type1 == ge_mDynType1_HostObject) {
strcpy( hostobject, ((GeHostObject *)elem)->hostobject);
found = true;
break;
}
}
if ( !found && strcmp(recursive_hostobject, "") != 0)
strcpy( hostobject, recursive_hostobject);
}
// Replace " by \"
......@@ -937,7 +944,7 @@ graph_eDatabase GeDyn::parse_attr_name( char *name, char *parsed_name,
{
char *s;
if ( total_dyn_type1 & ge_mDynType1_HostObject &&
if ( (total_dyn_type1 & ge_mDynType1_HostObject || strcmp(recursive_hostobject, "") != 0) &&
(s = strstr( name, "$hostobject"))) {
// Replace string $hostobject with host object
pwr_tAName hostobject;
......@@ -9515,6 +9522,29 @@ void GeHostObject::open( ifstream& fp)
}
}
int GeHostObject::connect( grow_tObject object, glow_sTraceData *trace_data)
{
if ( grow_GetObjectRecursiveTrace(object)) {
grow_tObject *objectlist, *object_p;
int object_cnt;
grow_tNodeClass nodeclass;
grow_GetObjectClass( object, &nodeclass);
grow_GetNodeClassObjectList( nodeclass, &objectlist, &object_cnt);
object_p = objectlist;
for ( int i = 0; i < object_cnt; i++) {
if ( grow_GetObjectType( *object_p) == glow_eObjectType_GrowNode) {
GeDyn *gm_dyn;
grow_GetUserData( *object_p, (void **)&gm_dyn);
strncpy( gm_dyn->recursive_hostobject, hostobject, sizeof(gm_dyn->recursive_hostobject));
}
object_p++;
}
}
return 1;
}
int GeHostObject::export_java( grow_tObject object, ofstream& fp, bool first, char *var_name)
{
GeDyn *nodeclass_dyn;
......
......@@ -731,6 +731,7 @@ class GeDyn {
glow_eCycle cycle; //!< Cycle in which the scan is executed.
bool display_access; //!< Display acess in attrbute editor.
ge_eDynAttr attr_editor; //!< Controls attributes displayed in attribute editor.
pwr_tAName recursive_hostobject; //!< Hostobject from parent dynamics.
//! Constructor.
/*! \param d_graph Graph.
......@@ -743,7 +744,9 @@ class GeDyn {
total_dyn_type2(ge_mDynType2_No), action_type1(ge_mActionType1_Inherit), action_type2(ge_mActionType2_No),
total_action_type1(ge_mActionType1_Inherit), total_action_type2(ge_mActionType2_No),
access(glow_mAccess_RtDefault), cycle(glow_eCycle_Inherit), attr_editor( d_attr_editor)
{}
{
strcpy(recursive_hostobject, "");
}
//! Copy constructor.
GeDyn( const GeDyn& x);
......@@ -1693,6 +1696,7 @@ class GeHostObject : public GeDynElem {
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
int connect( grow_tObject object, glow_sTraceData *trace_data);
void set_attribute( grow_tObject object, const char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
......
......@@ -1162,6 +1162,7 @@ typedef enum {
glow_eSave_NodeClass_userdata_cb = 329,
glow_eSave_NodeClass_dyn_type2 = 330,
glow_eSave_NodeClass_dyn_action_type2 = 331,
glow_eSave_NodeClass_recursive_trace = 332,
glow_eSave_ConClass_cc_name = 400,
glow_eSave_ConClass_con_type = 401,
glow_eSave_ConClass_corner = 402,
......@@ -1367,6 +1368,7 @@ typedef enum {
glow_eSave_GrowCtx_bitmap_fonts = 2245,
glow_eSave_GrowCtx_dyn_type2 = 2246,
glow_eSave_GrowCtx_dyn_action_type2 = 2247,
glow_eSave_GrowCtx_recursive_trace = 2248,
glow_eSave_GrowSubAnnot_x_right = 2300,
glow_eSave_GrowSubAnnot_x_left = 2301,
glow_eSave_GrowSubAnnot_y_high = 2302,
......@@ -1869,8 +1871,7 @@ typedef enum {
/*@}*/
/** \addtogroup GlowStruct */
/*@{*/
/** \addtogroup GlowStruct *//*@{*/
//! Default data structure for events
typedef struct {
......
......@@ -3133,6 +3133,11 @@ int grow_GetSubGraphAttrInfo( grow_tCtx ctx, char *transtab, grow_sAttrInfo **in
attrinfo[i].type = glow_eType_InputFocusMark;
attrinfo[i++].size = sizeof( ctx->input_focus_mark);
strcpy( attrinfo[i].name, "RecursiveTrace");
attrinfo[i].value_p = &ctx->recursive_trace;
attrinfo[i].type = glow_eType_Int;
attrinfo[i++].size = sizeof( ctx->recursive_trace);
strcpy( attrinfo[i].name, "Dynamic");
ctx->get_dynamic( &dynamic, &dynsize);
attrinfo[i].value_p = malloc( 1024);
......@@ -5249,6 +5254,18 @@ void grow_EventLogEnable( int enable)
GlowCtx::eventlog_enabled = enable;
}
void grow_GetObjectClass( grow_tObject object, grow_tNodeClass *nodeclass)
{
*nodeclass = ((GrowNode *)object)->nc->get_base_nc();
}
int grow_GetObjectRecursiveTrace( grow_tObject object)
{
GlowNodeClass *nodeclass = ((GrowNode *)object)->nc->get_base_nc();
return nodeclass->recursive_trace;
}
/*@}*/
......
......@@ -3063,6 +3063,8 @@ void grow_GetObjectClassDynType( grow_tObject object, int *dyn_type1, int *dyn_t
void grow_SetTextCoding( grow_tCtx ctx, glow_eTextCoding coding);
void grow_EventExec( grow_tCtx ctx, void *event, unsigned int size);
void grow_EventLogEnable( int enable);
void grow_GetObjectClass( grow_tObject object, grow_tNodeClass *nodeclass);
int grow_GetObjectRecursiveTrace( grow_tObject object);
/*@}*/
#if defined __cplusplus
......
......@@ -1963,6 +1963,7 @@ void GrowCtx::save_grow( ofstream& fp, glow_eSaveMode mode)
fp << int(glow_eSave_GrowCtx_mb3_action) << FSPACE << int(mb3_action) << endl;
fp << int(glow_eSave_GrowCtx_translate_on) << FSPACE << translate_on << endl;
fp << int(glow_eSave_GrowCtx_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
fp << int(glow_eSave_GrowCtx_recursive_trace) << FSPACE << recursive_trace << endl;
fp << int(glow_eSave_GrowCtx_bitmap_fonts) << FSPACE << bitmap_fonts << endl;
if ( user_data && userdata_save_callback) {
fp << int(glow_eSave_GrowCtx_userdata_cb) << endl;
......@@ -2159,6 +2160,7 @@ void GrowCtx::open_grow( ifstream& fp)
fp >> tmp;
input_focus_mark = (glow_eInputFocusMark)tmp;
break;
case glow_eSave_GrowCtx_recursive_trace: fp >> recursive_trace; break;
case glow_eSave_GrowCtx_userdata_cb:
if ( userdata_open_callback)
(userdata_open_callback)(&fp, this, glow_eUserdataCbType_Ctx);
......@@ -2273,6 +2275,7 @@ int GrowCtx::save_subgraph( char *filename, glow_eSaveMode mode)
fp << int(glow_eSave_NodeClass_x0) << FSPACE << x0 << endl;
fp << int(glow_eSave_NodeClass_x1) << FSPACE << x1 << endl;
fp << int(glow_eSave_NodeClass_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
fp << int(glow_eSave_NodeClass_recursive_trace) << FSPACE << int(recursive_trace) << endl;
if ( user_data && userdata_save_callback) {
fp << int(glow_eSave_NodeClass_userdata_cb) << endl;
(userdata_save_callback)(&fp, this, glow_eUserdataCbType_Ctx);
......
......@@ -939,6 +939,7 @@ class GrowCtx : public GlowCtx {
int bitmap_fonts; //!< Use bitmap fonts
glow_eEnv environment; //!< Environment Development or Runtime.
glow_eTextCoding text_coding; //!< Text coding
int recursive_trace; //!< Subgraph recursive trace
};
void grow_auto_scrolling( GrowCtx *ctx);
......
......@@ -105,6 +105,11 @@ GrowNode::~GrowNode()
if ( annotsize[i] > 0)
free( annotv[i]);
}
if ( local_nc) {
delete nc;
nc = 0;
}
}
void GrowNode::copy_from( const GrowNode& n)
......@@ -572,7 +577,7 @@ int GrowNode::event_handler( GlowWind *w, glow_eEvent event, int x, int y, doubl
sts = 0;
else {
if ( !is_sensitive()) {
if ( type() == glow_eObjectType_GrowGroup) {
if ( type() == glow_eObjectType_GrowGroup || nc->recursive_trace) {
sts = nc->a.event_handler( w, event, x, y, rx, ry);
sts = 0;
}
......@@ -640,7 +645,7 @@ int GrowNode::event_handler( GlowWind *w, glow_eEvent event, int x, int y, doubl
sts = nc->event_handler( w, event, rx, ry);
}
if ( sts) {
if ( ctx->trace_started && type() == glow_eObjectType_GrowGroup) {
if ( (ctx->trace_started && type() == glow_eObjectType_GrowGroup) || nc->recursive_trace) {
// If group, only register i sensitive (group member might be sensitive)
if ( is_sensitive())
ctx->register_callback_object( glow_eObjectType_Node, this);
......
......@@ -224,7 +224,7 @@ class GrowNode : public GlowNode {
glow_eGradient gradient; //!< Type of gradient.
glow_eDrawType text_type; //!< Text type, bold or normal.
glow_eFont text_font; //!< Text font.
//! Set dynamic code
/*!
\param code Dynamic code.
......
......@@ -55,7 +55,7 @@ GlowNode::GlowNode( GrowCtx *glow_ctx, const char *name, GlowNodeClass *node_cla
obst_x_right(x1), obst_x_left(x1), obst_y_high(y1), obst_y_low(y1),
hot(0), ctx(glow_ctx), nc(node_class), nc_root(node_class),
pos(glow_ctx, x1,y1), stored_pos(glow_ctx, x1, y1),
highlight(0), inverse(0), user_data(0), level(0), node_open(0),
highlight(0), inverse(0), local_nc(0), user_data(0), level(0), node_open(0),
relative_annot_pos(rel_annot_pos), relative_annot_x(0), input_active(0),
input_focus(0)
{
......@@ -237,6 +237,12 @@ void GlowNode::open( ifstream& fp)
}
if ( !nc)
cout << "GlowNode:nodeclass not found: " << nc_name << endl;
if ( nc && ctx->environment == glow_eEnv_Runtime && nc->recursive_trace) {
// Create local copy of nodeclass
nc = new GlowNodeClass(*nc);
local_nc = 1;
}
nc_root = nc;
}
break;
......@@ -402,6 +408,9 @@ void GlowNode::trace_scan()
{
if ( ctx->trace_scan_func && trace.p)
ctx->trace_scan_func( (void *) this, trace.p);
if ( nc->recursive_trace)
nc->a.trace_scan();
}
int GlowNode::trace_init()
......@@ -412,6 +421,10 @@ int GlowNode::trace_init()
// return 1;
sts = ctx->trace_connect_func( (void *) this, &trace);
if ( nc->recursive_trace)
nc->a.trace_init();
return sts;
}
......@@ -422,6 +435,9 @@ void GlowNode::trace_close()
if ( trace.p)
ctx->trace_disconnect_func( (void *) this);
if ( nc->recursive_trace)
nc->a.trace_close();
}
......
......@@ -154,6 +154,7 @@ class GlowNode : public GlowArrayElem {
int refcon_cnt[MAX_CONPOINTS]; //!< Number of reference connections for each connection point.
GlowTraceData trace;
GlowNode *link; //!< Link in list used for routing of connections.
int local_nc; //!< Local nodeclass instance.
//! Insert in list used for routing of connections.
/*!
......
......@@ -55,7 +55,7 @@ GlowNodeClass::GlowNodeClass( GrowCtx *glow_ctx, const char *name,
arg_cnt(0), nc_extern(0), dyn_type1(0), dyn_type2(0), dyn_action_type1(0), dyn_action_type2(0),
no_con_obstacle(0), slider(0), animation_count(1),
y0(0), y1(0), x0(0), x1(0),
next_nc(0), prev_nc(0), cycle(glow_eCycle_Slow), user_data(0)
next_nc(0), prev_nc(0), cycle(glow_eCycle_Slow), user_data(0), recursive_trace(0)
{
memset( dyn_color, 0, sizeof( dyn_color));
memset( dyn_attr, 0, sizeof( dyn_attr));
......@@ -164,6 +164,7 @@ void GlowNodeClass::save( ofstream& fp, glow_eSaveMode mode)
fp << int(glow_eSave_NodeClass_x0) << FSPACE << x0 << endl;
fp << int(glow_eSave_NodeClass_x1) << FSPACE << x1 << endl;
fp << int(glow_eSave_NodeClass_input_focus_mark) << FSPACE << int(input_focus_mark) << endl;
fp << int(glow_eSave_NodeClass_recursive_trace) << FSPACE << recursive_trace << endl;
if ( user_data && ctx->userdata_save_callback) {
fp << int(glow_eSave_NodeClass_userdata_cb) << endl;
(ctx->userdata_save_callback)(&fp, this, glow_eUserdataCbType_NodeClass);
......@@ -281,6 +282,7 @@ void GlowNodeClass::open( ifstream& fp)
fp >> tmp;
input_focus_mark = (glow_eInputFocusMark)tmp;
break;
case glow_eSave_NodeClass_recursive_trace: fp >> recursive_trace; break;
case glow_eSave_NodeClass_userdata_cb:
if ( ctx->userdata_open_callback)
(ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_NodeClass);
......
......@@ -426,6 +426,7 @@ class GlowNodeClass : public GlowArrayElem {
glow_eCycle cycle; //!< Cycle, i.e. if dynamics is executed at fast or slow scantime.
glow_eInputFocusMark input_focus_mark; //!< How input focus in marked.
void *user_data; //!< User data.
int recursive_trace; //!< Call trace callback also for nodeclass elements.
};
/*@}*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment