Commit 5a3ff742 authored by Claes Sjofors's avatar Claes Sjofors

Ge commmands build and create bar added

parent b33caab3
...@@ -4858,6 +4858,7 @@ Below is a description of commands in Ge ...@@ -4858,6 +4858,7 @@ Below is a description of commands in Ge
add <link>gecmd_add add <link>gecmd_add
<t>add polyline <link>gecmd_add_polyline <t>add polyline <link>gecmd_add_polyline
build <link>gecmd_build
create <link>gecmd_create create <link>gecmd_create
<t>create rectangle <link>gecmd_create_rect <t>create rectangle <link>gecmd_create_rect
<t>create arc <link>gecmd_create_arc <t>create arc <link>gecmd_create_arc
...@@ -4866,6 +4867,7 @@ create <link>gecmd_create ...@@ -4866,6 +4867,7 @@ create <link>gecmd_create
<t>create rectangle <link>gecmd_create_rect <t>create rectangle <link>gecmd_create_rect
<t>create text <link>gecmd_create_text <t>create text <link>gecmd_create_text
<t>create subgraph <link>gecmd_create_subgraph <t>create subgraph <link>gecmd_create_subgraph
<t>create bar <link>gecmd_create_bar
exit <link>gecmd_exit exit <link>gecmd_exit
group <link>gecmd_group group <link>gecmd_group
move <link>gecmd_move move <link>gecmd_move
...@@ -4939,6 +4941,17 @@ segments are created by 'add polyline'. ...@@ -4939,6 +4941,17 @@ segments are created by 'add polyline'.
/y1 <t>y-coordinate for the added segment. /y1 <t>y-coordinate for the added segment.
</topic> </topic>
<topic>gecmd_build
build
Build the current graph.
The pwg-file is copied to $pwrp_exe.
<b>Syntax
<c>ge> build
</topic>
<topic>gecmd_create <style>function <topic>gecmd_create <style>function
create create
...@@ -5047,6 +5060,21 @@ Create a subgraph object. ...@@ -5047,6 +5060,21 @@ Create a subgraph object.
/y2 /y2
</topic> </topic>
<topic>gecmd_create_bar
create bar
Create a bar object.
<b>Syntax
<c>ge> create bar /x1= /y1= [/x2= /y2=]
/x1 <t>x-coordinate for the upper left corner.
/y1 <t>y-coordinate for the upper left corner.
/x2 <t>If the point (x2, y2) is supplied, the bar is scaled to fit inside a
<t>rectangle with the corner points (x1, y1) and (x2, y2).
/y2
</topic>
<topic>gecmd_exit <topic>gecmd_exit
exit exit
...@@ -5634,6 +5662,7 @@ functions. Here follows a list of build in functions that also can be used in Ge ...@@ -5634,6 +5662,7 @@ functions. Here follows a list of build in functions that also can be used in Ge
GetCurrentObject <t>Returns the identity of the last created object.<link>GetCurrentObject() GetCurrentObject <t>Returns the identity of the last created object.<link>GetCurrentObject()
GetTextExtent <t>Calculate the extent of a text. <link>GetTextExtent() GetTextExtent <t>Calculate the extent of a text. <link>GetTextExtent()
SelectAdd <t>Add an object to select list. <link>SelectAdd() SelectAdd <t>Add an object to select list. <link>SelectAdd()
SetDraw <t>Set drawing on or off. <link>SetDraw()
SetExtern <t>Set subgraph extern. <link>SetExtern() SetExtern <t>Set subgraph extern. <link>SetExtern()
SetIntern <t>Set subgraph intern. <link>SetIntern() SetIntern <t>Set subgraph intern. <link>SetIntern()
...@@ -5748,6 +5777,36 @@ Returns the identity of the last created object. ...@@ -5748,6 +5777,36 @@ Returns the identity of the last created object.
<c> id = GetCurrentObject(); <c> id = GetCurrentObject();
</topic> </topic>
<topic>SetDraw() <style>function
SetDraw()
int SetDraw( int on)
<h2>Description
Set drawing on or off.
<h2>Argument
int <t>on <t>If 0, drawing is turned off. If 1, drawing is turned on.
<b>Example
<c> SetDraw(0);
<c> for ( i = 0; i < 10000; i++)
<c> x2 = x + 0.55;
<c> y2 = y + 0.55;
<c> create object/sub=pwr_indsquare/x1='x'/y1='y'/x2='x2'/y2='y2'
<c> set current attr DigLowColor.Attribute H1-DArray.Val['i']##Boolean
<c> x += 0.65;
<c> if ( i - (i / 100) * 100 == 99)
<c> y += 0.65;
<c> x = 0;
<c> endif
<c> endfor
<c> SetDraw(1);
</topic>
<topic>SetExtern() <style>function <topic>SetExtern() <style>function
SetExtern() SetExtern()
int SetExtern( string name) int SetExtern( string name)
......
...@@ -68,6 +68,7 @@ isbaseclass <Is baseclass> /info ...@@ -68,6 +68,7 @@ isbaseclass <Is baseclass> /info
fileopen <Unable to open file> /error fileopen <Unable to open file> /error
needconv <Unable to save, graph needs conversion> /error needconv <Unable to save, graph needs conversion> /error
javanamesyntax <Java name syntax error> /error javanamesyntax <Java name syntax error> /error
notsaved <Graph is not saved> /error
...@@ -115,6 +115,8 @@ static int graph_convert_func( void *client_data, ...@@ -115,6 +115,8 @@ static int graph_convert_func( void *client_data,
void *client_flag); void *client_flag);
static int graph_two_func( void *client_data, static int graph_two_func( void *client_data,
void *client_flag); void *client_flag);
static int graph_build_func( void *client_data,
void *client_flag);
dcli_tCmdTable graph_command_table[] = { dcli_tCmdTable graph_command_table[] = {
{ {
...@@ -232,6 +234,11 @@ dcli_tCmdTable graph_command_table[] = { ...@@ -232,6 +234,11 @@ dcli_tCmdTable graph_command_table[] = {
&graph_two_func, &graph_two_func,
{""} {""}
}, },
{
"BUILD",
&graph_build_func,
{""}
},
{"",}}; {"",}};
static void graph_store_graph( Graph *graph) static void graph_store_graph( Graph *graph)
...@@ -319,6 +326,26 @@ static int graph_quit_func(void *client_data, ...@@ -319,6 +326,26 @@ static int graph_quit_func(void *client_data,
return GE__SUCCESS; return GE__SUCCESS;
} }
static int graph_build_func(void *client_data,
void *client_flag)
{
Graph *graph = (Graph *)client_data;
char name[40];
pwr_tCmd cmd;
graph->get_name( name);
if ( strcmp( name, "") == 0 || graph->is_modified()) {
graph->message('E', "Build error, graph is not saved");
return GE__NOTSAVED;
}
sprintf( cmd, "cp -a $pwrp_pop/%s.pwg $pwrp_exe/", name);
system( cmd);
return GE__SUCCESS;
}
static int graph_exit_func(void *client_data, static int graph_exit_func(void *client_data,
void *client_flag) void *client_flag)
{ {
...@@ -2559,6 +2586,100 @@ static int graph_create_func( void *client_data, ...@@ -2559,6 +2586,100 @@ static int graph_create_func( void *client_data,
graph->current_cmd_object = n1; graph->current_cmd_object = n1;
grow_SetModified( graph->grow->ctx, 1); grow_SetModified( graph->grow->ctx, 1);
} }
else if ( cdh_NoCaseStrncmp( arg1_str, "BAR", strlen( arg1_str)) == 0)
{
char str[80];
int sts;
float value;
double x1, y1, x2, y2;
grow_tNode n1;
int scale_x, scale_y;
double sx, sy;
double ll_x, ll_y, ur_x, ur_y;
if ( EVEN( dcli_get_qualifier( "/X1", str, sizeof(str))))
{
graph->message('E', "Syntax error");
return GE__SYNTAX;
}
sts = sscanf( str, "%f", &value);
if ( sts != 1)
{
graph->message('E', "Syntax error");
return GE__SYNTAX;
}
x1 = value;
if ( EVEN( dcli_get_qualifier( "/Y1", str, sizeof(str))))
{
graph->message('E', "Syntax error");
return GE__SYNTAX;
}
sts = sscanf( str, "%f", &value);
if ( sts != 1)
{
graph->message('E', "Syntax error");
return GE__SYNTAX;
}
y1 = value;
if ( ODD( dcli_get_qualifier( "/X2", str, sizeof(str))))
{
sts = sscanf( str, "%f", &value);
if ( sts != 1)
{
graph->message('E', "Syntax error");
return GE__SYNTAX;
}
x2 = value;
if ( x1 == x2)
{
graph->message('E', "Invalid coordinate");
return GE__COORDINATE;
}
scale_x = 1;
}
else
scale_x = 0;
if ( ODD( dcli_get_qualifier( "/Y2", str, sizeof(str))))
{
sts = sscanf( str, "%f", &value);
if ( sts != 1)
{
graph->message('E', "Syntax error");
return GE__SYNTAX;
}
y2 = value;
if ( y1 == y2)
{
graph->message('E', "Invalid coordinate");
return GE__COORDINATE;
}
scale_y = 1;
}
else
scale_y = 0;
graph->create_bar( &n1, x1, y1);
if ( scale_x || scale_y) {
grow_MeasureNode( n1, &ll_x, &ll_y, &ur_x, &ur_y);
if ( scale_x)
sx = (x2 - x1)/(ur_x - ll_x);
else
sx = 1;
if ( scale_y)
sy = (y2 - y1)/(ur_y - ll_y);
else
sy = 1;
grow_StoreTransform( n1);
grow_SetObjectScale( n1, sx, sy, x1, y1, glow_eScaleType_LowerLeft);
}
graph->current_cmd_object = n1;
grow_SetModified( graph->grow->ctx, 1);
}
else else
{ {
graph->message('E', "Syntax error"); graph->message('E', "Syntax error");
...@@ -3024,6 +3145,35 @@ static int graph_false_func( ...@@ -3024,6 +3145,35 @@ static int graph_false_func(
return 1; return 1;
} }
static int graph_setdraw_func(
void *filectx,
ccm_sArg *arg_list,
int arg_count,
int *return_decl,
ccm_tFloat *return_float,
ccm_tInt *return_int,
char *return_string)
{
Graph *graph;
if ( arg_count != 1)
return CCM__ARGMISM;
if ( arg_list->value_decl != CCM_DECL_INT)
return CCM__ARGMISM;
graph_get_stored_graph( &graph);
if ( arg_list->value_int == 0)
grow_SetNodraw( graph->grow->ctx);
else {
grow_ResetNodraw( graph->grow->ctx);
grow_Redraw( graph->grow->ctx);
}
return 1;
}
static int graph_ccm_deffilename_func( char *outfile, char *infile, void *client_data) static int graph_ccm_deffilename_func( char *outfile, char *infile, void *client_data)
{ {
...@@ -3133,6 +3283,8 @@ int Graph::readcmdfile( char *incommand) ...@@ -3133,6 +3283,8 @@ int Graph::readcmdfile( char *incommand)
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "SetIntern", graph_setintern_func); sts = ccm_register_function( "SetIntern", graph_setintern_func);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "SetDraw", graph_setdraw_func);
if ( EVEN(sts)) return sts;
sts = ccm_register_function( "IsW1", graph_true_func); sts = ccm_register_function( "IsW1", graph_true_func);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "IsW2", graph_false_func); sts = ccm_register_function( "IsW2", graph_false_func);
......
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