Commit ff2e66bf authored by Claes Sjofors's avatar Claes Sjofors

Ge dynamics RefUpdate implemented

parent 4f54233d
...@@ -2159,6 +2159,21 @@ static void gdh_AttrToString( int type_id, void *value_ptr, ...@@ -2159,6 +2159,21 @@ static void gdh_AttrToString( int type_id, void *value_ptr,
*len = sprintf( str, "%s", hiername); *len = sprintf( str, "%s", hiername);
break; break;
} }
case pwr_eType_DataRef:
{
pwr_tAName hiername;
pwr_tDataRef *dataref;
dataref = (pwr_tDataRef *) value_ptr;
sts = gdh_AttrrefToName( &dataref->Aref, hiername, sizeof(hiername), cdh_mNName);
if (EVEN(sts)) {
strcpy( str, "");
*len = 0;
break;
}
*len = sprintf( str, "%s", hiername);
break;
}
case pwr_eType_Time: case pwr_eType_Time:
{ {
sts = time_AtoAscii( (pwr_tTime *) value_ptr, time_eFormat_DateAndTime, sts = time_AtoAscii( (pwr_tTime *) value_ptr, time_eFormat_DateAndTime,
......
This diff is collapsed.
...@@ -42,7 +42,6 @@ import java.util.*; ...@@ -42,7 +42,6 @@ import java.util.*;
public class Graph implements GraphIfc, GrowApplIfc { public class Graph implements GraphIfc, GrowApplIfc {
public GrowCmn cmn; public GrowCmn cmn;
public GrowCtx ctx; public GrowCtx ctx;
public GlowDraw gdraw; public GlowDraw gdraw;
...@@ -238,7 +237,7 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -238,7 +237,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
index = new Integer(str.substring(idx1+1, idx2)).intValue(); index = new Integer(str.substring(idx1+1, idx2)).intValue();
} }
catch( NumberFormatException e) { catch( NumberFormatException e) {
System.out.println("Element syntax error, " + str); System.out.println("stringToIndex: Element syntax error, " + str);
return 1; return 1;
} }
return index; return index;
...@@ -247,6 +246,10 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -247,6 +246,10 @@ public class Graph implements GraphIfc, GrowApplIfc {
} }
public DynParsedAttrName parseAttrName( String name) { public DynParsedAttrName parseAttrName( String name) {
return parseAttrName( name, 0);
}
public DynParsedAttrName parseAttrName( String name, int options) {
if ( name == null) if ( name == null)
return null; return null;
...@@ -324,6 +327,8 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -324,6 +327,8 @@ public class Graph implements GraphIfc, GrowApplIfc {
else else
break; break;
} }
if ( (options & GraphIfc.mParseOpt_KeepIndex) == 0) {
// Translate index variable // Translate index variable
for ( int i = 0; i < 4; i++) { for ( int i = 0; i < 4; i++) {
if ( (idx = str.indexOf("[&(")) != -1) { if ( (idx = str.indexOf("[&(")) != -1) {
...@@ -344,6 +349,7 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -344,6 +349,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
else else
break; break;
} }
}
for ( int i = 0; i < 4; i++) { for ( int i = 0; i < 4; i++) {
// Remove attribute before // Remove attribute before
...@@ -383,7 +389,7 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -383,7 +389,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
pname.elements = new Integer(str.substring(eidx+1)).intValue(); pname.elements = new Integer(str.substring(eidx+1)).intValue();
} }
catch( NumberFormatException e) { catch( NumberFormatException e) {
System.out.println("Element syntax error, " + str); System.out.println("parseAttrName: Element syntax error, " + str);
pname.elements = 1; pname.elements = 1;
} }
str = str.substring(0, eidx); str = str.substring(0, eidx);
...@@ -392,6 +398,7 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -392,6 +398,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
pname.elements = 1; pname.elements = 1;
} }
else { else {
if ( (options & GraphIfc.mParseOpt_KeepIndex) == 0 || str.indexOf("[&(") == -1)
pname.index = stringToIndex(str); pname.index = stringToIndex(str);
pname.elements = 1; pname.elements = 1;
// if ((eidx = str.lastIndexOf('#')) != -1 && // if ((eidx = str.lastIndexOf('#')) != -1 &&
...@@ -449,6 +456,146 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -449,6 +456,146 @@ public class Graph implements GraphIfc, GrowApplIfc {
return str; return str;
} }
public GdhrRefObjectInfo refObjectInfo( String attributeName) {
String str = new String(attributeName);
int idx;
// Replace references
if ( (idx = str.indexOf("&(")) != -1) {
String ref_name;
String end;
CdhrString ret;
int idx2;
if ( str.substring(idx+2).startsWith("&(")) {
idx2 = str.indexOf(")");
if ( idx2 == -1)
return null;
ref_name = str.substring( idx + 4, idx2);
end = str.substring( idx2 + 1);
ret = getGdh().getObjectInfoString( ref_name);
if ( ret.evenSts()) return null;
str = str.substring(0, idx+2) + ret.str + end;
}
idx2 = str.lastIndexOf(")");
if ( idx2 == -1)
return null;
ref_name = str.substring( idx + 2, idx2);
end = str.substring( idx2 + 1);
ret = getGdh().getObjectInfoString( ref_name);
if ( ret.evenSts()) return null;
str = str.substring(0, idx) + ret.str + end;
}
return getGdh().refObjectInfo(str);
}
public int getRefUpdate( String in, String ref_name[], int ref_tid[], int ref_size[],
String idx_ref_name[], int idx_ref_tid[], int idx_ref_size[],
int ref_cnt[], Object dyn) {
int idx, lidx;
ref_cnt[0] = 0;
ref_cnt[1] = 0;
String str = new String( in);
// Get index variable and replace
for ( int i = 0; i < 2; i++) {
if ( (idx = str.indexOf("[&(")) != -1) {
String iname = str.substring(idx+3);
int idx2 = iname.indexOf(')');
if ( idx2 != -1) {
String rest = iname.substring( idx2 + 1);
iname = iname.substring( 0, idx2);
idx_ref_name[ref_cnt[1]] = iname;
ref_cnt[1]++;
CdhrInt ret = getGdh().getObjectInfoInt( iname);
if ( ret.evenSts()) return 0;
str = str.substring( 0, idx + 1) + ret.value + rest;
}
else
break;
}
else
break;
}
// Get reference
if ( (idx = str.indexOf("&(")) != -1) {
if ( str.substring(idx+2).startsWith("&(")) {
int idx2 = str.indexOf(")");
if ( idx2 == -1)
return 0;
ref_name[ref_cnt[0]] = str.substring( idx + 4, idx2);
CdhrAttrRef attrRef = getGdh().nameToAttrRef(ref_name[ref_cnt[0]]);
if ( attrRef.oddSts()) {
CdhrTypeId cdhrTypeId = getGdh().getAttrRefTid( attrRef.aref );
ref_tid[ref_cnt[0]] = cdhrTypeId.getTypeId();
}
ref_cnt[0]++;
String end = str.substring( idx2 + 1);
CdhrString ret = getGdh().getObjectInfoString( ref_name[ref_cnt[0]-1]);
if ( ret.evenSts()) return 0;
str = str.substring(0, idx+2) + ret.str + end;
}
int idx2 = str.lastIndexOf(")");
if ( idx2 == -1)
return 0;
ref_name[ref_cnt[0]] = str.substring( idx + 2, idx2);
CdhrAttrRef attrRef = getGdh().nameToAttrRef(ref_name[ref_cnt[0]]);
if ( attrRef.oddSts()) {
CdhrTypeId cdhrTypeId = getGdh().getAttrRefTid( attrRef.aref );
ref_tid[ref_cnt[0]] = cdhrTypeId.getTypeId();
}
ref_cnt[0]++;
}
for ( int i = 0; i < 4; i++) {
// Remove attribute before
if ( (idx = str.indexOf(".<")) != -1) {
String rest = str.substring( idx + 2);
int idx2 = str.lastIndexOf( '.', idx - 2);
if ( idx2 != -1)
str = str.substring( 0, idx2) + rest;
else
break;
}
else
break;
}
for ( int i = 0; i < 4; i++) {
// Remove segment name before
if ( (idx = str.indexOf("-<")) != -1) {
String rest = str.substring( idx + 2);
int idx2 = str.lastIndexOf( '-', idx - 2);
if ( idx2 != -1)
str = str.substring( 0, idx2) + rest;
else
break;
}
else
break;
}
return 1;
}
public Object growUserdataOpen( BufferedReader reader, Object object, int type) { public Object growUserdataOpen( BufferedReader reader, Object object, int type) {
switch ( type) { switch ( type) {
case Glow.eUserdataCbType_Ctx: case Glow.eUserdataCbType_Ctx:
...@@ -467,6 +614,7 @@ public class Graph implements GraphIfc, GrowApplIfc { ...@@ -467,6 +614,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
return null; return null;
} }
@SuppressWarnings("fallthrough")
public void eventHandler(GlowEvent e) { public void eventHandler(GlowEvent e) {
boolean cmn_popped = false; boolean cmn_popped = false;
......
...@@ -46,7 +46,11 @@ public interface GraphIfc { ...@@ -46,7 +46,11 @@ public interface GraphIfc {
public static final int eType_Bit = (1 << 15) + 1; public static final int eType_Bit = (1 << 15) + 1;
public static final int mParseOpt_KeepIndex = 1 << 0;
public DynParsedAttrName parseAttrName( String name); public DynParsedAttrName parseAttrName( String name);
public DynParsedAttrName parseAttrName( String name, int options);
public Gdh getGdh(); public Gdh getGdh();
public GraphLocalDb getLdb(); public GraphLocalDb getLdb();
public GrowCtx getCtx(); public GrowCtx getCtx();
...@@ -70,6 +74,10 @@ public interface GraphIfc { ...@@ -70,6 +74,10 @@ public interface GraphIfc {
public double getFastScanTime(); public double getFastScanTime();
public double getAnimationScanTime(); public double getAnimationScanTime();
public String getCommand(String cmd); public String getCommand(String cmd);
public GdhrRefObjectInfo refObjectInfo( String attributeName);
public int getRefUpdate( String in, String ref_name[], int ref_tid[], int ref_size[],
String idx_ref_name[], int idx_ref_tid[], int idx_ref_size[],
int ref_cnt[], Object dyn);
public void setClickActive(int active); public void setClickActive(int active);
public void signalSend(String signalName); public void signalSend(String signalName);
} }
...@@ -69,6 +69,6 @@ fileopen <Unable to open file> /error ...@@ -69,6 +69,6 @@ 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 notsaved <Graph is not saved> /error
noref <Attribute is not of reference type> /error
...@@ -115,6 +115,7 @@ static attrnav_sEnumElement elem_dyn_type2[] = { ...@@ -115,6 +115,7 @@ static attrnav_sEnumElement elem_dyn_type2[] = {
{ (unsigned int) ge_mDynType2_DigBackgroundColor , "DigBackgroundColor"}, { (unsigned int) ge_mDynType2_DigBackgroundColor , "DigBackgroundColor"},
{ (unsigned int) ge_mDynType2_DigSwap , "DigSwap"}, { (unsigned int) ge_mDynType2_DigSwap , "DigSwap"},
{ (unsigned int) ge_mDynType2_DigScript , "DigScript"}, { (unsigned int) ge_mDynType2_DigScript , "DigScript"},
{ (unsigned int) ge_mDynType2_RefUpdate , "RefUpdate"},
{ 0, ""}}; { 0, ""}};
static attrnav_sEnumElement elem_dyn_type1_tone[] = { static attrnav_sEnumElement elem_dyn_type1_tone[] = {
......
This diff is collapsed.
This diff is collapsed.
...@@ -3773,7 +3773,7 @@ static int graph_trace_connect_bc( grow_tObject object, ...@@ -3773,7 +3773,7 @@ static int graph_trace_connect_bc( grow_tObject object,
} }
} }
dyn->connect( object, trace_data); dyn->connect( object, trace_data, false);
if ( ctx_popped) if ( ctx_popped)
graph->grow->push(); graph->grow->push();
...@@ -4774,8 +4774,242 @@ void Graph::get_command( char *in, char *out, GeDyn *dyn) ...@@ -4774,8 +4774,242 @@ void Graph::get_command( char *in, char *out, GeDyn *dyn)
} }
} }
int Graph::get_refupdate( char *in, pwr_tAName ref[], pwr_tTid ref_tid[], int ref_size[], int *ref_cnt,
pwr_tAName idx_ref[], pwr_tTid idx_ref_tid[], int idx_ref_size[], int *idx_ref_cnt,
GeDyn *dyn)
{
char *s, *t0;
char *s0 = in;
char str[500];
bool object_found = false;
char out[512];
*ref_cnt = 0;
*idx_ref_cnt = 0;
pwr_tAName oname[4];
if ( grow->stack_cnt == 0) {
for ( int i = 0; i < 4; i++)
strcpy( oname[i], object_name[i]);
}
else {
grow_GetOwner( grow->ctx, oname[0]);
if ( strcmp( object_name[0], "") != 0) {
pwr_tOName n;
t0 = n;
s0 = oname[0];
while ( (s = strstr( s0, "$object"))) {
strncpy( t0, s0, s-s0);
t0 += s - s0;
strcpy( t0, object_name[0]);
t0 += strlen(object_name[0]);
s0 = s + strlen("$object");
}
cdh_Strcpy( t0, s0);
strcpy( oname[0], n);
}
for ( int i = 1; i < 4; i++)
strcpy( oname[i], object_name[i]);
}
s0 = in;
if ( dyn && (dyn->total_dyn_type1 & ge_mDynType1_HostObject ||
strcmp( dyn->recursive_hostobject, "") != 0)) {
pwr_tAName hostobject;
dyn->get_hostobject( hostobject);
t0 = str;
s0 = in;
while ( (s = strstr( s0, "$hostobject"))) {
cdh_Strncpy( t0, s0, s-s0);
t0 += s - s0;
strcpy( t0, hostobject);
t0 += strlen(hostobject);
s0 = s + strlen("$hostobject");
}
cdh_Strcpy( t0, s0);
if ( strcmp( oname[0], "") == 0) {
strcpy( out, str);
}
s0 = str;
}
else if ( strcmp( oname[0], "") == 0) {
cdh_Strcpy( out, in);
}
if ( strcmp( oname[0], "") != 0) {
t0 = out;
while ( (s = strstr( s0, "$object"))) {
int idx;
object_found = true;
char *sidx = s + strlen("$object");
switch ( *sidx) {
case '2':
idx = 1;
break;
case '3':
idx = 2;
break;
case '4':
idx = 3;
break;
default:
idx = 0;
}
cdh_Strncpy( t0, s0, s-s0);
t0 += s - s0;
strcpy( t0, oname[idx]);
t0 += strlen(oname[idx]);
s0 = s + strlen("$object") + (idx > 0 ? 1 : 0);
}
cdh_Strcpy( t0, s0);
t0 = out;
}
// Get index variables and replace
for ( int i = 0; i < 2; i++) {
if ( (s = strstr( out, "[&("))) {
int idx;
pwr_tAName iname, rest;
pwr_tStatus sts;
int len;
char *s1;
s++;
strcpy( iname, s+2);
s1 = strchr( iname, ')');
strncpy( rest, s1+1, sizeof(rest));
if ( !s1)
return GE__SYNTAX;
*s1 = 0;
sts = gdh_GetObjectInfo( iname, &idx, sizeof(idx));
if ( ODD(sts) && idx >= 0 && idx <= 100) {
len = sprintf( s, "%d", idx);
strcpy( s + len, rest);
}
strcpy( idx_ref[*idx_ref_cnt], iname);
idx_ref_size[*ref_cnt] = sizeof(pwr_tInt32);
idx_ref_tid[*ref_cnt] = pwr_eType_Int32;
(*idx_ref_cnt)++;
}
else
break;
}
// Get references
if ( (s = strchr( out, '&')) && *(s+1) == '(') {
// Replace attribute in parenthesis with its value
if ( *(s+2) == '&' && *(s+3) == '(') {
pwr_tAName refname;
pwr_tStatus sts;
char *start, *end, *start2;
pwr_tTid atid;
pwr_tUInt32 asize;
start = s;
strcpy( refname, s+4);
if ( (s = strchr( refname, ')')) == 0)
return GE__SYNTAX;
*s = 0;
sts = gdh_GetAttributeCharacteristics( refname, &atid, &asize, 0, 0);
if ( EVEN(sts)) return sts;
strcpy( ref[*ref_cnt], refname);
ref_tid[*ref_cnt] = atid;
ref_size[*ref_cnt] = asize;
(*ref_cnt)++;
end = start + strlen(refname) + 5;
start2 = s + 1;
switch( atid) {
case pwr_eType_AttrRef: {
pwr_tAttrRef aref;
sts = gdh_GetObjectInfo( refname, &aref, sizeof(aref));
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( &aref, str, sizeof(str), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
break;
}
case pwr_eType_DataRef: {
pwr_tDataRef dref;
sts = gdh_GetObjectInfo( refname, &dref, sizeof(dref));
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( &dref.Aref, str, sizeof(str), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
break;
}
case pwr_eType_Objid: {
pwr_tOid oid;
sts = gdh_GetObjectInfo( refname, &oid, sizeof(oid));
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToName( oid, str, sizeof(str), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
break;
}
default:
return GE__NOREF;
}
if ( (s = strchr( start2, ')')) == 0)
return GE__SYNTAX;
*s = 0;
end = start2 + strlen(start2) + 1;
strncat( str, start2, sizeof(str));
strcpy( refname, str);
sts = gdh_GetAttributeCharacteristics( refname, &atid, &asize, 0, 0);
if ( EVEN(sts)) return sts;
strcpy( ref[*ref_cnt], refname);
ref_tid[*ref_cnt] = atid;
ref_size[*ref_cnt] = asize;
(*ref_cnt)++;
}
else {
pwr_tAName refname;
pwr_tStatus sts;
char *start, *end;
pwr_tTid atid;
pwr_tUInt32 asize;
start = s;
strcpy( refname, s+2);
if ( (s = strchr( refname, ')')) == 0)
return GE__SYNTAX;
*s = 0;
end = start + strlen(refname) + 3;
sts = gdh_GetAttributeCharacteristics( refname, &atid, &asize, 0, 0);
if ( EVEN(sts)) return sts;
strcpy( ref[*ref_cnt], refname);
ref_size[*ref_cnt] = asize;
ref_tid[*ref_cnt] = atid;
(*ref_cnt)++;
}
}
return GE__SUCCESS;
}
graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name, graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name,
int *inverted, int *type, int *size, int *elem) int *inverted, int *type, int *size, int *elem, graph_mParseOpt options)
{ {
pwr_tAName str; pwr_tAName str;
pwr_tAName str1; pwr_tAName str1;
...@@ -4936,6 +5170,7 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name, ...@@ -4936,6 +5170,7 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name,
break; break;
} }
if ( !(options & graph_mParseOpt_KeepIndex)) {
// Translate index variable // Translate index variable
for ( int i = 0; i < 2; i++) { for ( int i = 0; i < 2; i++) {
if ( (s = strstr( str, "[&("))) { if ( (s = strstr( str, "[&("))) {
...@@ -4962,6 +5197,7 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name, ...@@ -4962,6 +5197,7 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name,
else else
break; break;
} }
}
for ( int i = 0; i < 4; i++) { for ( int i = 0; i < 4; i++) {
// Remove attribute before // Remove attribute before
......
...@@ -139,6 +139,11 @@ typedef enum { ...@@ -139,6 +139,11 @@ typedef enum {
graph_eKeyboard_AlphabeticShifted, //!< Keyboard alphabetic opened in shifted mode. graph_eKeyboard_AlphabeticShifted, //!< Keyboard alphabetic opened in shifted mode.
} graph_eKeyboard; } graph_eKeyboard;
//! Parse options
typedef enum {
graph_mParseOpt_None = 0,
graph_mParseOpt_KeepIndex = 1 << 0
} graph_mParseOpt;
//! Extension of proview type pwr_eType. Should not collide with any pwr_eType. //! Extension of proview type pwr_eType. Should not collide with any pwr_eType.
typedef enum { typedef enum {
...@@ -1072,7 +1077,8 @@ class Graph { ...@@ -1072,7 +1077,8 @@ class Graph {
is inverted (!), of type pwr_eType_String with size 80. is inverted (!), of type pwr_eType_String with size 80.
*/ */
graph_eDatabase parse_attr_name( char *name, char *parsed_name, graph_eDatabase parse_attr_name( char *name, char *parsed_name,
int *inverted, int *type, int *size, int *elem = 0); int *inverted, int *type, int *size, int *elem = 0,
graph_mParseOpt options = graph_mParseOpt_None);
//! Get the default window size //! Get the default window size
/*! /*!
...@@ -1260,6 +1266,11 @@ class Graph { ...@@ -1260,6 +1266,11 @@ class Graph {
*/ */
int set_object_focus( const char *name, int empty); int set_object_focus( const char *name, int empty);
//! Replace the string $object and get references in attribute connection string.
int get_refupdate( char *in, pwr_tAName ref[], pwr_tTid ref_tid[], int ref_size[], int *ref_cnt,
pwr_tAName idx_ref[], pwr_tTid idx_ref_tid[], int idx_ref_size[], int *idx_ref_cnt,
GeDyn *dyn);
//! Replace the string $object with the object name for the graph. //! Replace the string $object with the object name for the graph.
/*! /*!
\param in Input command. \param in Input command.
......
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