Commit e54a53a4 authored by Claes Sjofors's avatar Claes Sjofors

Xtt script functions GetGraphInstance and GetGraphInstanceNext added

parent e99072bc
...@@ -5680,6 +5680,14 @@ void Graph::close_input_all() { ...@@ -5680,6 +5680,14 @@ void Graph::close_input_all() {
grow_ResetInputFocusAll( grow->ctx); grow_ResetInputFocusAll( grow->ctx);
} }
int Graph::get_object_name( unsigned int idx, int size, char *name)
{
if ( idx >= sizeof(object_name)/sizeof(object_name[0]))
return 0;
strncpy( name, object_name[idx], size);
return 1;
}
static void graph_free_dyn( grow_tObject object) static void graph_free_dyn( grow_tObject object)
{ {
if ( grow_GetObjectType( object) == glow_eObjectType_GrowNode || if ( grow_GetObjectType( object) == glow_eObjectType_GrowNode ||
......
...@@ -1412,6 +1412,7 @@ class Graph { ...@@ -1412,6 +1412,7 @@ class Graph {
int key_pressed( int key); int key_pressed( int key);
void close_input_all(); void close_input_all();
int get_object_name( unsigned int idx, int size, char *name);
static int get_colortheme_colors( char *file, double **colors, int *size); static int get_colortheme_colors( char *file, double **colors, int *size);
......
...@@ -94,6 +94,8 @@ class ApplList { ...@@ -94,6 +94,8 @@ class ApplList {
int find( applist_eType type, pwr_tObjid objid, void **ctx); int find( applist_eType type, pwr_tObjid objid, void **ctx);
int find( applist_eType type, void *ctx, char *name, char *instance); int find( applist_eType type, void *ctx, char *name, char *instance);
int find_graph( const char *name, const char *instance, void **ctx); int find_graph( const char *name, const char *instance, void **ctx);
int find_graph_first( const char *name, void **ctx);
int find_graph_next( const char *name, char *instance, void **ctx);
void swap( int mode); void swap( int mode);
}; };
......
...@@ -277,6 +277,11 @@ void XttGe::close_input_all() ...@@ -277,6 +277,11 @@ void XttGe::close_input_all()
graph->close_input_all(); graph->close_input_all();
} }
int XttGe::get_object_name( unsigned int idx, int size, char *name)
{
return graph->get_object_name( idx, size, name);
}
XttGe::XttGe( void *xg_parent_ctx, const char *xg_name, const char *xg_filename, XttGe::XttGe( void *xg_parent_ctx, const char *xg_name, const char *xg_filename,
int xg_scrollbar, int xg_menu, int xg_navigator, int xg_width, int xg_height, int xg_scrollbar, int xg_menu, int xg_navigator, int xg_width, int xg_height,
int x, int y, double scan_time, const char *object_name, int x, int y, double scan_time, const char *object_name,
......
...@@ -104,6 +104,7 @@ class XttGe : XttUtility { ...@@ -104,6 +104,7 @@ class XttGe : XttUtility {
void set_text_coding( lng_eCoding coding); void set_text_coding( lng_eCoding coding);
int key_pressed( int key); int key_pressed( int key);
void close_input_all(); void close_input_all();
int get_object_name( unsigned int idx, int size, char *name);
static void graph_init_cb( void *client_data); static void graph_init_cb( void *client_data);
static int graph_close_cb( void *client_data); static int graph_close_cb( void *client_data);
......
...@@ -4162,6 +4162,43 @@ int ApplList::find_graph( const char *name, const char *instance, void **ctx) ...@@ -4162,6 +4162,43 @@ int ApplList::find_graph( const char *name, const char *instance, void **ctx)
return 0; return 0;
} }
int ApplList::find_graph_first( const char *name, void **ctx)
{
ApplListElem *elem;
for ( elem = root; elem; elem = elem->next) {
if ( elem->type == applist_eType_Graph) {
if ( cdh_NoCaseStrcmp( name, elem->name) == 0) {
*ctx = elem->ctx;
return 1;
}
}
}
return 0;
}
int ApplList::find_graph_next( const char *name, char *instance, void **ctx)
{
ApplListElem *elem;
int found = 0;
for ( elem = root; elem; elem = elem->next) {
if ( elem->type == applist_eType_Graph) {
if ( cdh_NoCaseStrcmp( name, elem->name) == 0) {
if ( found) {
*ctx = elem->ctx;
return 1;
}
else {
if ( cdh_NoCaseStrcmp( instance, elem->instance) == 0)
found = 1;
}
}
}
}
return 0;
}
int ApplList::find( applist_eType type, void *ctx, char *name, char *instance) int ApplList::find( applist_eType type, void *ctx, char *name, char *instance)
{ {
ApplListElem *elem; ApplListElem *elem;
......
...@@ -8648,6 +8648,79 @@ static int xnav_getprivileges_func( ...@@ -8648,6 +8648,79 @@ static int xnav_getprivileges_func(
return 1; return 1;
} }
static int xnav_getgraphinstance_func(
void *filectx,
ccm_sArg *arg_list,
int arg_count,
int *return_decl,
ccm_tFloat *return_float,
ccm_tInt *return_int,
char *return_string)
{
XNav *xnav;
XttGe *gectx;
int sts;
if ( arg_count != 1)
return CCM__ARGMISM;
if ( arg_list->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
xnav_get_stored_xnav( &xnav);
if ( xnav->appl.find_graph_first( arg_list->value_string, (void **) &gectx)) {
sts = gectx->get_object_name( 0, sizeof(ccm_tString), return_string);
if ( EVEN(sts)) strcpy( return_string, "");
}
else
strcpy( return_string, "");
*return_decl = CCM_DECL_STRING;
return 1;
}
static int xnav_getgraphinstancenext_func(
void *filectx,
ccm_sArg *arg_list,
int arg_count,
int *return_decl,
ccm_tFloat *return_float,
ccm_tInt *return_int,
char *return_string)
{
XNav *xnav;
XttGe *gectx;
int sts;
ccm_sArg *arg_p2;
if ( arg_count != 2)
return CCM__ARGMISM;
arg_p2 = arg_list->next;
if ( arg_list->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
if ( arg_p2->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
xnav_get_stored_xnav( &xnav);
if ( xnav->appl.find_graph_next( arg_list->value_string, arg_p2->value_string,
(void **) &gectx)) {
sts = gectx->get_object_name( 0, sizeof(ccm_tString), return_string);
if ( EVEN(sts)) strcpy( return_string, "");
}
else
strcpy( return_string, "");
*return_decl = CCM_DECL_STRING;
return 1;
}
static int xnav_ccm_deffilename_func( char *outfile, char *infile, void *client_data) static int xnav_ccm_deffilename_func( char *outfile, char *infile, void *client_data)
{ {
pwr_tFileName fname; pwr_tFileName fname;
...@@ -8731,6 +8804,10 @@ int XNav::readcmdfile( char *incommand, char *buffer) ...@@ -8731,6 +8804,10 @@ int XNav::readcmdfile( char *incommand, char *buffer)
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetPrivileges", xnav_getprivileges_func); sts = ccm_register_function( "GetPrivileges", xnav_getprivileges_func);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetGraphInstance", xnav_getgraphinstance_func);
if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetGraphInstanceNext", xnav_getgraphinstancenext_func);
if ( EVEN(sts)) return sts;
sts = ccm_create_external_var( "GLOW__SUBTERMINATED", CCM_DECL_INT, 0, GLOW__SUBTERMINATED, 0); sts = ccm_create_external_var( "GLOW__SUBTERMINATED", CCM_DECL_INT, 0, GLOW__SUBTERMINATED, 0);
......
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