Commit 3aa4f974 authored by Claes Sjofors's avatar Claes Sjofors

Curve window, second mark and export dialog added

parent 8feefb25
...@@ -219,6 +219,9 @@ int dcli_replace_env( char *str, char *newstr) ...@@ -219,6 +219,9 @@ int dcli_replace_env( char *str, char *newstr)
size = (long int) s - (long int) u; size = (long int) s - (long int) u;
strncpy( symbol, u, size); strncpy( symbol, u, size);
symbol[size] = 0; symbol[size] = 0;
if ( strcmp( symbol, "HOME") == 0)
strcpy( lower_symbol, symbol);
else
cdh_ToLower( lower_symbol, symbol); cdh_ToLower( lower_symbol, symbol);
if ( (value = getenv( lower_symbol)) == NULL) { if ( (value = getenv( lower_symbol)) == NULL) {
/* It was no symbol */ /* It was no symbol */
...@@ -467,7 +470,13 @@ int dcli_translate_filename( char *out, const char *in) ...@@ -467,7 +470,13 @@ int dcli_translate_filename( char *out, const char *in)
else else
{ {
// Already unix syntax // Already unix syntax
if ( in[0] == '~') {
strcpy( out_name, "$HOME");
strcat( &out_name[5], &in[1]);
}
else
strcpy( out_name, in); strcpy( out_name, in);
sts = dcli_replace_env( out_name, out); sts = dcli_replace_env( out_name, out);
return sts; return sts;
} }
......
...@@ -171,7 +171,7 @@ time_Aadd ( ...@@ -171,7 +171,7 @@ time_Aadd (
) )
{ {
pwr_tTime *r = result; pwr_tTime *r = result;
int tv_nsec; pwr_tInt64 tv_nsec;
assertAbs(t); assertAbs(t);
assertDelta(a); assertDelta(a);
...@@ -231,8 +231,8 @@ time_Adiff ( ...@@ -231,8 +231,8 @@ time_Adiff (
pwr_tTime *s pwr_tTime *s
) )
{ {
int tv_nsec = t->tv_nsec - s->tv_nsec; pwr_tInt64 tv_nsec = t->tv_nsec - s->tv_nsec;
int tv_sec = t->tv_sec - s->tv_sec; pwr_tInt64 tv_sec = t->tv_sec - s->tv_sec;
pwr_Assert(r != NULL); pwr_Assert(r != NULL);
assertAbs(t); assertAbs(t);
...@@ -267,8 +267,8 @@ time_Asub ( ...@@ -267,8 +267,8 @@ time_Asub (
pwr_tDeltaTime *s pwr_tDeltaTime *s
) )
{ {
int tv_nsec = t->tv_nsec - s->tv_nsec; pwr_tInt64 tv_nsec = t->tv_nsec - s->tv_nsec;
int tv_sec = (int)t->tv_sec - s->tv_sec; pwr_tInt64 tv_sec = t->tv_sec - s->tv_sec;
pwr_tTime *r = result; pwr_tTime *r = result;
assertAbs(t); assertAbs(t);
...@@ -329,7 +329,7 @@ time_Dadd ( ...@@ -329,7 +329,7 @@ time_Dadd (
) )
{ {
pwr_tDeltaTime *r = result; pwr_tDeltaTime *r = result;
int tv_nsec, tv_sec; pwr_tInt64 tv_nsec, tv_sec;
assertDelta(t); assertDelta(t);
assertDelta(a); assertDelta(a);
...@@ -423,8 +423,8 @@ time_Dsub ( ...@@ -423,8 +423,8 @@ time_Dsub (
pwr_tDeltaTime *s pwr_tDeltaTime *s
) )
{ {
int tv_nsec = t->tv_nsec - s->tv_nsec; pwr_tInt64 tv_nsec = t->tv_nsec - s->tv_nsec;
int tv_sec = t->tv_sec - s->tv_sec; pwr_tInt64 tv_sec = t->tv_sec - s->tv_sec;
pwr_tDeltaTime *r = result; pwr_tDeltaTime *r = result;
assertDelta(t); assertDelta(t);
......
...@@ -269,6 +269,8 @@ scan ( ...@@ -269,6 +269,8 @@ scan (
/* if (sts == TIME__CLKCHANGE) { /* if (sts == TIME__CLKCHANGE) {
tp->after_scan = tp->before_scan; tp->after_scan = tp->before_scan;
}*/ }*/
//if ( tp->PlcThread->Count % 10000 == 0)
// printf( "ba: %9lld %9lld %9lld %9lld\n", tp->before_scan.tv_sec, tp->before_scan.tv_nsec, tp->after_scan.tv_sec, tp->after_scan.tv_nsec);
time_GetTime(&tp->after_scan_abs); time_GetTime(&tp->after_scan_abs);
if (tp->log) if (tp->log)
pwrb_PlcThread_Exec(tp); pwrb_PlcThread_Exec(tp);
...@@ -279,6 +281,8 @@ scan ( ...@@ -279,6 +281,8 @@ scan (
plc_timerhandler(tp); plc_timerhandler(tp);
time_Aadd(NULL, &tp->sync_time, &tp->scan_time); time_Aadd(NULL, &tp->sync_time, &tp->scan_time);
time_Adiff(&delta, &tp->sync_time, &tp->after_scan); time_Adiff(&delta, &tp->sync_time, &tp->after_scan);
//if ( tp->PlcThread->Count % 10000 == 0)
// printf( "ff: %9lld %9lld %9lld %9lld %9lld %9lld\n", tp->sync_time.tv_sec, tp->sync_time.tv_nsec, tp->after_scan.tv_sec, tp->after_scan.tv_nsec, delta.tv_sec, delta.tv_nsec);
if (time_Dcomp(&delta, NULL) > 0) { if (time_Dcomp(&delta, NULL) > 0) {
pwr_tStatus sts; pwr_tStatus sts;
int phase = 0; int phase = 0;
...@@ -312,11 +316,22 @@ scan ( ...@@ -312,11 +316,22 @@ scan (
* END REMARK * END REMARK
*/ */
// phase = (int)que_Get(&sts, &tp->q_in, &delta, NULL); // phase = (int)que_Get(&sts, &tp->q_in, &delta, NULL);
struct timespec ts; struct timespec ts;
ts.tv_sec = tp->sync_time.tv_sec; ts.tv_sec = tp->sync_time.tv_sec;
ts.tv_nsec = tp->sync_time.tv_nsec; ts.tv_nsec = tp->sync_time.tv_nsec;
//if ( tp->PlcThread->Count % 10000 == 0)
//printf( "st: %9d %9d %9lld %9lld\n", ts.tv_sec, ts.tv_nsec, tp->scan_time.tv_sec, tp->scan_time.tv_nsec);
pwr_tTime sleep1, sleep2;
time_GetTimeMonotonic(&sleep1);
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL); clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL);
time_GetTimeMonotonic(&sleep2);
if ( tp->PlcThread->Count % 10000 == 0)
printf( "st: %9lld %9lld %9lld %9lld %9d %9d %11.9f\n", sleep1.tv_sec, sleep1.tv_nsec, sleep2.tv_sec, sleep2.tv_nsec, ts.tv_sec, ts.tv_nsec, ((float)sleep2.tv_nsec-sleep1.tv_nsec)/1000000000);
#endif #endif
if (phase > 0) { if (phase > 0) {
tp->exit = TRUE; tp->exit = TRUE;
......
...@@ -29,6 +29,7 @@ nodatatime <No data found in this time interval> /error ...@@ -29,6 +29,7 @@ nodatatime <No data found in this time interval> /error
noitems <No items found> /error noitems <No items found> /error
unknownnode <Unknown server nodename> /error unknownnode <Unknown server nodename> /error
init <Initialization done> /info init <Initialization done> /info
exportfile <Unable to open export file> /error
.end .end
......
...@@ -734,6 +734,23 @@ void CoWowGtk::CreateFileSelDia( const char *title, void *parent_ctx, ...@@ -734,6 +734,23 @@ void CoWowGtk::CreateFileSelDia( const char *title, void *parent_ctx,
gtk_file_filter_add_pattern( filter, "*"); gtk_file_filter_add_pattern( filter, "*");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
} }
else if ( file_type == wow_eFileSelType_History) {
pwr_tFileName folder;
dcli_translate_filename( folder, "~");
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), folder);
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter, "*.txt,*.csv,*.skv");
gtk_file_filter_add_pattern( filter, "*.txt");
gtk_file_filter_add_pattern( filter, "*.csv");
gtk_file_filter_add_pattern( filter, "*.skv");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter, "All Files");
gtk_file_filter_add_pattern( filter, "*");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
}
if ( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { if ( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
char *filename; char *filename;
......
...@@ -32,6 +32,7 @@ typedef enum { ...@@ -32,6 +32,7 @@ typedef enum {
wow_eFileSelType_WblClass, wow_eFileSelType_WblClass,
wow_eFileSelType_Graph, wow_eFileSelType_Graph,
wow_eFileSelType_Image, wow_eFileSelType_Image,
wow_eFileSelType_History,
wow_eFileSelType__ wow_eFileSelType__
} wow_eFileSelType; } wow_eFileSelType;
......
...@@ -291,6 +291,13 @@ void GeCurveGtk::activate_xlimits( GtkWidget *w, gpointer data) ...@@ -291,6 +291,13 @@ void GeCurveGtk::activate_xlimits( GtkWidget *w, gpointer data)
curve->open_minmax(0); curve->open_minmax(0);
} }
void GeCurveGtk::activate_export( GtkWidget *w, gpointer data)
{
GeCurve *curve = (GeCurve *)data;
curve->activate_export();
}
void GeCurveGtk::activate_help( GtkWidget *w, gpointer data) void GeCurveGtk::activate_help( GtkWidget *w, gpointer data)
{ {
GeCurve *curve = (GeCurve *)data; GeCurve *curve = (GeCurve *)data;
...@@ -328,11 +335,101 @@ void GeCurveGtk::activate_minmax_cancel( GtkWidget *w, gpointer data) ...@@ -328,11 +335,101 @@ void GeCurveGtk::activate_minmax_cancel( GtkWidget *w, gpointer data)
g_object_set( ((GeCurveGtk *)curve)->minmax_widget, "visible", FALSE, NULL); g_object_set( ((GeCurveGtk *)curve)->minmax_widget, "visible", FALSE, NULL);
} }
void GeCurveGtk::activate_export_ok( GtkWidget *w, gpointer data)
{
GeCurve *curve = (GeCurve *)data;
char *value;
pwr_tTime from, to;
int rows;
pwr_tFileName filename;
pwr_tStatus sts;
int nr;
int idx = 0;
value = gtk_combo_box_get_active_text( GTK_COMBO_BOX(((GeCurveGtk *)curve)->export_attrcombo_widget));
if ( !value) return;
for ( int i = 0; i < curve->cd->cols; i++) {
if ( strcmp( value, CoWowGtk::convert_utf8(curve->cd->y_name[i])) == 0) {
idx = i;
break;
}
}
g_free( value);
value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_fromtime_widget), 0, -1);
sts = time_AsciiToA( value, &from);
g_free( value);
if ( EVEN(sts)) {
curve->wow->DisplayError( "Syntax Error", "From time syntax error");
return;
}
value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_totime_widget), 0, -1);
sts = time_AsciiToA( value, &to);
g_free( value);
if ( EVEN(sts)) {
curve->wow->DisplayError( "Syntax Error", "To time syntax error");
return;
}
value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_rows_widget), 0, -1);
nr = sscanf( value, "%d", &rows);
g_free( value);
if ( nr != 1)
return;
value = gtk_editable_get_chars( GTK_EDITABLE(((GeCurveGtk *)curve)->export_filename_widget), 0, -1);
strcpy( filename, value);
g_free( value);
g_object_set( ((GeCurveGtk *)curve)->export_widget, "visible", FALSE, NULL);
if ( curve->export_cb) {
sts = (curve->export_cb)( curve->parent_ctx, &from, &to, rows, idx, filename);
if ( EVEN(sts)) {
curve->wow->DisplayError( "Export error", "Export error");
return;
}
}
}
void GeCurveGtk::activate_export_cancel( GtkWidget *w, gpointer data)
{
GeCurve *curve = (GeCurve *)data;
g_object_set( ((GeCurveGtk *)curve)->export_widget, "visible", FALSE, NULL);
}
void GeCurveGtk::activate_export_browse( GtkWidget *w, gpointer data)
{
GeCurve *curve = (GeCurve *)data;
curve->wow->CreateFileSelDia( CoWowGtk::translate_utf8("File Selection"), (void *)curve,
export_file_selected_cb, wow_eFileSelType_History);
}
void GeCurveGtk::export_file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type)
{
GeCurve *curve = (GeCurve *)ctx;
gint pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(((GeCurveGtk *)curve)->export_filename_widget), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(((GeCurveGtk *)curve)->export_filename_widget),
filename, strlen(filename), &pos);
}
void GeCurveGtk::enable_timebox() void GeCurveGtk::enable_timebox()
{ {
g_object_set( sea_timebox, "visible", TRUE, NULL); g_object_set( sea_timebox, "visible", TRUE, NULL);
} }
void GeCurveGtk::enable_export()
{
g_object_set( menu_export, "visible", TRUE, NULL);
}
void GeCurveGtk::pop() void GeCurveGtk::pop()
{ {
gtk_window_present( GTK_WINDOW(toplevel)); gtk_window_present( GTK_WINDOW(toplevel));
...@@ -391,6 +488,33 @@ void GeCurveGtk::open_minmax( int idx) ...@@ -391,6 +488,33 @@ void GeCurveGtk::open_minmax( int idx)
minmax_idx = idx; minmax_idx = idx;
} }
void GeCurveGtk::open_export( pwr_tTime *from, pwr_tTime *to, int rows, char *filename)
{
char fromtime_str[40];
char totime_str[40];
char rows_str[40];
gint pos = 0;
create_export_dialog();
time_AtoAscii( from, time_eFormat_DateAndTime, fromtime_str, sizeof(fromtime_str));
time_AtoAscii( to, time_eFormat_DateAndTime, totime_str, sizeof(totime_str));
sprintf( rows_str, "%d", rows);
gtk_editable_delete_text( GTK_EDITABLE(export_fromtime_widget), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(export_fromtime_widget),
fromtime_str, strlen(fromtime_str), &pos);
gtk_editable_delete_text( GTK_EDITABLE(export_totime_widget), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(export_totime_widget),
totime_str, strlen(totime_str), &pos);
gtk_editable_delete_text( GTK_EDITABLE(export_rows_widget), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(export_rows_widget),
rows_str, strlen(rows_str), &pos);
gtk_editable_delete_text( GTK_EDITABLE(export_filename_widget), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(export_filename_widget),
filename, strlen(filename), &pos);
}
void GeCurveGtk::set_times( pwr_tTime *from, pwr_tTime *to) void GeCurveGtk::set_times( pwr_tTime *from, pwr_tTime *to)
{ {
char timestr[32]; char timestr[32];
...@@ -486,7 +610,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx, ...@@ -486,7 +610,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
GeCurveData *curve_data, GeCurveData *curve_data,
int pos_right) : int pos_right) :
GeCurve( gc_parent_ctx, curve_name, filename, curve_data, pos_right), GeCurve( gc_parent_ctx, curve_name, filename, curve_data, pos_right),
minmax_widget(0), disable_timecombo_callback(0) minmax_widget(0), export_widget(0), disable_timecombo_callback(0)
{ {
const int window_width = 900; const int window_width = 900;
...@@ -527,6 +651,9 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx, ...@@ -527,6 +651,9 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU)); gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this); g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
menu_export = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Export"));
g_signal_connect(menu_export, "activate", G_CALLBACK(activate_export), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close")); GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close), gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU)); gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
...@@ -537,6 +664,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx, ...@@ -537,6 +664,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL); GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_refresh); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_refresh);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_export);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close); gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File")); GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
...@@ -814,6 +942,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx, ...@@ -814,6 +942,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
gtk_paned_set_position( GTK_PANED(vpaned1), names_height); gtk_paned_set_position( GTK_PANED(vpaned1), names_height);
gtk_paned_set_position( GTK_PANED(vpaned2), window_height - names_height - nav_height - 50); gtk_paned_set_position( GTK_PANED(vpaned2), window_height - names_height - nav_height - 50);
g_object_set( sea_timebox, "visible", FALSE, NULL); g_object_set( sea_timebox, "visible", FALSE, NULL);
g_object_set( menu_export, "visible", FALSE, NULL);
wow = new CoWowGtk( toplevel); wow = new CoWowGtk( toplevel);
...@@ -881,3 +1010,99 @@ void GeCurveGtk::create_minmax_dialog() ...@@ -881,3 +1010,99 @@ void GeCurveGtk::create_minmax_dialog()
gtk_widget_show_all( minmax_widget); gtk_widget_show_all( minmax_widget);
} }
static gint export_delete_event( GtkWidget *w, GdkEvent *event, gpointer curve)
{
g_object_set( ((GeCurveGtk *)curve)->export_widget, "visible", FALSE, NULL);
return TRUE;
}
void GeCurveGtk::create_export_dialog()
{
if ( export_widget) {
g_object_set( export_widget, "visible", TRUE, NULL);
return;
}
// Create an input dialog
export_widget = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 300,
"default-width", 600,
"title", "Export",
NULL);
g_signal_connect( export_widget, "delete_event", G_CALLBACK(export_delete_event), this);
GtkWidget *attr_label = gtk_label_new(CoWowGtk::translate_utf8("Attribute"));
gtk_widget_set_size_request( attr_label, 90, -1);
export_attrcombo_widget = gtk_combo_box_new_text();
for ( int i = 0; i < cd->cols; i++) {
gtk_combo_box_append_text( GTK_COMBO_BOX(export_attrcombo_widget), CoWowGtk::convert_utf8(cd->y_name[i]));
}
gtk_combo_box_set_active( GTK_COMBO_BOX(export_attrcombo_widget), 0);
export_fromtime_widget = gtk_entry_new();
gtk_widget_set_size_request( export_fromtime_widget, 200, -1);
GtkWidget *fromtime_label = gtk_label_new(CoWowGtk::translate_utf8("From"));
gtk_widget_set_size_request( fromtime_label, 90, -1);
export_totime_widget = gtk_entry_new();
gtk_widget_set_size_request( export_totime_widget, 200, -1);
GtkWidget *totime_label = gtk_label_new(CoWowGtk::translate_utf8("To"));
gtk_widget_set_size_request( totime_label, 90, -1);
export_rows_widget = gtk_entry_new();
gtk_widget_set_size_request( export_rows_widget, 80, -1);
GtkWidget *rows_label = gtk_label_new(CoWowGtk::translate_utf8("Max number of rows"));
gtk_widget_set_size_request( rows_label, 150, -1);
export_filename_widget = gtk_entry_new();
GtkWidget *filename_label = gtk_label_new(CoWowGtk::translate_utf8("Filename"));
gtk_widget_set_size_request( filename_label, 90, -1);
GtkWidget *export_browse = gtk_button_new_with_label( CoWowGtk::translate_utf8("Browse"));
gtk_widget_set_size_request( export_browse, 70, 25);
g_signal_connect( export_browse, "clicked",
G_CALLBACK(activate_export_browse), this);
GtkWidget *export_ok = gtk_button_new_with_label( CoWowGtk::translate_utf8("Ok"));
gtk_widget_set_size_request( export_ok, 70, 25);
g_signal_connect( export_ok, "clicked",
G_CALLBACK(activate_export_ok), this);
GtkWidget *export_cancel = gtk_button_new_with_label( CoWowGtk::translate_utf8("Cancel"));
gtk_widget_set_size_request( export_cancel, 70, 25);
g_signal_connect( export_cancel, "clicked",
G_CALLBACK(activate_export_cancel), this);
GtkWidget *export_hbox1 = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(export_hbox1), attr_label, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_hbox1), export_attrcombo_widget, TRUE, TRUE, 30);
GtkWidget *export_hbox2 = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(export_hbox2), fromtime_label, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_hbox2), export_fromtime_widget, FALSE, FALSE, 30);
gtk_box_pack_start( GTK_BOX(export_hbox2), totime_label, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_hbox2), export_totime_widget, FALSE, FALSE, 30);
GtkWidget *export_hbox4 = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(export_hbox4), rows_label, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_hbox4), export_rows_widget, FALSE, FALSE, 30);
GtkWidget *export_hbox5 = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(export_hbox5), filename_label, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_hbox5), export_filename_widget, TRUE, TRUE, 30);
gtk_box_pack_end( GTK_BOX(export_hbox5), export_browse, FALSE, FALSE, 10);
GtkWidget *export_hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(export_hboxbuttons), export_ok, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(export_hboxbuttons), export_cancel, FALSE, FALSE, 0);
GtkWidget *export_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(export_vbox), export_hbox1, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_vbox), export_hbox2, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(export_vbox), export_hbox4, TRUE, TRUE, 15);
gtk_box_pack_start( GTK_BOX(export_vbox), export_hbox5, TRUE, TRUE, 15);
gtk_box_pack_start( GTK_BOX(export_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(export_vbox), export_hboxbuttons, FALSE, FALSE, 15);
gtk_container_add( GTK_CONTAINER(export_widget), export_vbox);
gtk_widget_show_all( export_widget);
}
...@@ -47,6 +47,13 @@ class GeCurveGtk : public GeCurve { ...@@ -47,6 +47,13 @@ class GeCurveGtk : public GeCurve {
GtkWidget *minmax_widget; GtkWidget *minmax_widget;
GtkWidget *minmax_textmin_widget; GtkWidget *minmax_textmin_widget;
GtkWidget *minmax_textmax_widget; GtkWidget *minmax_textmax_widget;
GtkWidget *menu_export;
GtkWidget *export_widget;
GtkWidget *export_attrcombo_widget;
GtkWidget *export_fromtime_widget;
GtkWidget *export_totime_widget;
GtkWidget *export_rows_widget;
GtkWidget *export_filename_widget;
GtkWidget *sea_timebox; GtkWidget *sea_timebox;
GtkWidget *timebox_start_time; GtkWidget *timebox_start_time;
GtkWidget *timebox_stop_time; GtkWidget *timebox_stop_time;
...@@ -58,10 +65,13 @@ class GeCurveGtk : public GeCurve { ...@@ -58,10 +65,13 @@ class GeCurveGtk : public GeCurve {
void write_title( char *str); void write_title( char *str);
void resize(); void resize();
void open_minmax( int idx); void open_minmax( int idx);
void open_export( pwr_tTime *from, pwr_tTime *to, int rows, char *filename);
void axis_set_width( int width); void axis_set_width( int width);
void create_minmax_dialog(); void create_minmax_dialog();
void create_export_dialog();
void set_inputfocus(); void set_inputfocus();
void enable_timebox(); void enable_timebox();
void enable_export();
void set_times( pwr_tTime *from, pwr_tTime *to); void set_times( pwr_tTime *from, pwr_tTime *to);
void set_times_sensitivity( int sensitive); void set_times_sensitivity( int sensitive);
pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to); pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to);
...@@ -73,6 +83,7 @@ class GeCurveGtk : public GeCurve { ...@@ -73,6 +83,7 @@ class GeCurveGtk : public GeCurve {
static void activate_exit( GtkWidget *w, gpointer data); static void activate_exit( GtkWidget *w, gpointer data);
static void activate_configure( GtkWidget *w, gpointer data); static void activate_configure( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data); static void activate_print( GtkWidget *w, gpointer data);
static void activate_export( GtkWidget *w, gpointer data);
static void activate_zoomin( GtkWidget *w, gpointer data); static void activate_zoomin( GtkWidget *w, gpointer data);
static void activate_zoomout( GtkWidget *w, gpointer data); static void activate_zoomout( GtkWidget *w, gpointer data);
static void activate_zoomreset( GtkWidget *w, gpointer data); static void activate_zoomreset( GtkWidget *w, gpointer data);
...@@ -95,6 +106,10 @@ class GeCurveGtk : public GeCurve { ...@@ -95,6 +106,10 @@ class GeCurveGtk : public GeCurve {
static void activate_help( GtkWidget *w, gpointer data); static void activate_help( GtkWidget *w, gpointer data);
static void activate_minmax_ok( GtkWidget *w, gpointer data); static void activate_minmax_ok( GtkWidget *w, gpointer data);
static void activate_minmax_cancel( GtkWidget *w, gpointer data); static void activate_minmax_cancel( GtkWidget *w, gpointer data);
static void activate_export_ok( GtkWidget *w, gpointer data);
static void activate_export_cancel( GtkWidget *w, gpointer data);
static void activate_export_browse( GtkWidget *w, gpointer data);
static void export_file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data); static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
}; };
......
...@@ -63,6 +63,33 @@ void GeCurve::activate_configure() ...@@ -63,6 +63,33 @@ void GeCurve::activate_configure()
configure_axes(); configure_axes();
} }
void GeCurve::activate_export()
{
double ll_x, ll_y, ur_x, ur_y;
pwr_tTime to = pwr_cNTime;
pwr_tTime from = pwr_cNTime;
double from_time, to_time;
char filename[] = "~/history.txt";
grow_MeasureWindow( growcurve_ctx, &ll_x, &ll_y, &ur_x, &ur_y);
if ( !cd->x_reverse) {
from_time = cd->x_min_value_axis[0] + ll_x *
(cd->x_max_value_axis[0] - cd->x_min_value_axis[0]) / 200;
to_time = cd->x_min_value_axis[0] + ur_x *
(cd->x_max_value_axis[0] - cd->x_min_value_axis[0]) / 200;
}
else {
from_time = cd->x_min_value_axis[0] + (200.0 - ll_x) *
(cd->x_max_value_axis[0] - cd->x_min_value_axis[0]) / 200;
to_time = cd->x_min_value_axis[0] + (200.0 - ur_x) *
(cd->x_max_value_axis[0] - cd->x_min_value_axis[0]) / 200;
}
from.tv_sec = from_time;
to.tv_sec = to_time;
open_export( &from, &to, 1000, filename);
}
void GeCurve::activate_print() void GeCurve::activate_print()
{ {
pwr_tFileName fname; pwr_tFileName fname;
...@@ -215,38 +242,78 @@ int GeCurve::growcurve_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -215,38 +242,78 @@ int GeCurve::growcurve_cb( GlowCtx *ctx, glow_tEvent event)
double time; double time;
double values[CURVE_MAX_COLS]; double values[CURVE_MAX_COLS];
grow_MeasureNode( curve->curve_markobject, &ll_x, &ll_y, &ur_x, &ur_y); grow_MeasureNode( curve->curve_markobject1, &ll_x, &ll_y, &ur_x, &ur_y);
grow_MoveNode( curve->curve_markobject, event->any.x - (ur_x - ll_x)/2, ll_y); grow_MoveNode( curve->curve_markobject1, event->any.x - (ur_x - ll_x)/2, ll_y);
grow_Redraw( curve->growcurve_ctx);
curve->last_mark1_x = event->any.x;
curve->x_to_points( event->any.x, &time, values);
for ( int i = 0; i < curve->cd->cols; i++) {
sprintf( str, "%7.2f", values[i]);
grow_SetAnnotation( curve->mark1_annot[i], 0, str, strlen(str));
}
if ( !(strcmp( curve->cd->x_format[0], "%10t") == 0 ||
strcmp( curve->cd->x_format[0], "%11t") == 0)) {
sprintf( str, "%7.2f", time);
grow_SetAnnotation( curve->mark1_annot[curve->cd->cols], 0, str, strlen(str));
}
else {
// Time is a date
pwr_tTime t;
time_Float64ToD( (pwr_tDeltaTime *) &t, time);
time_AtoAscii( &t, time_eFormat_DateAndTime, str, sizeof(str));
grow_SetAnnotation( curve->mark1_annot[curve->cd->cols], 0, str, strlen(str));
}
break;
}
case glow_eEvent_MB1ClickCtrl: {
// Move mark slider to this position
double ll_x, ll_y, ur_x, ur_y;
char str[40];
double time;
double values[CURVE_MAX_COLS];
grow_MeasureNode( curve->curve_markobject2, &ll_x, &ll_y, &ur_x, &ur_y);
grow_MoveNode( curve->curve_markobject2, event->any.x - (ur_x - ll_x)/2, ll_y);
grow_Redraw( curve->growcurve_ctx); grow_Redraw( curve->growcurve_ctx);
curve->last_mark2_x = event->any.x;
curve->x_to_points( event->any.x, &time, values); curve->x_to_points( event->any.x, &time, values);
for ( int i = 0; i < curve->cd->cols; i++) { for ( int i = 0; i < curve->cd->cols; i++) {
sprintf( str, "%7.2f", values[i]); sprintf( str, "%7.2f", values[i]);
grow_SetAnnotation( curve->mark_annot[i], 0, str, strlen(str)); grow_SetAnnotation( curve->mark2_annot[i], 0, str, strlen(str));
} }
if ( !(strcmp( curve->cd->x_format[0], "%10t") == 0 || if ( !(strcmp( curve->cd->x_format[0], "%10t") == 0 ||
strcmp( curve->cd->x_format[0], "%11t") == 0)) { strcmp( curve->cd->x_format[0], "%11t") == 0)) {
sprintf( str, "%7.2f", time); sprintf( str, "%7.2f", time);
grow_SetAnnotation( curve->mark_annot[curve->cd->cols], 0, str, strlen(str)); grow_SetAnnotation( curve->mark2_annot[curve->cd->cols], 0, str, strlen(str));
} }
else { else {
// Time is a date // Time is a date
pwr_tTime t; pwr_tTime t;
time_Float64ToD( (pwr_tDeltaTime *) &t, time); time_Float64ToD( (pwr_tDeltaTime *) &t, time);
time_AtoAscii( &t, time_eFormat_DateAndTime, str, sizeof(str)); time_AtoAscii( &t, time_eFormat_DateAndTime, str, sizeof(str));
grow_SetAnnotation( curve->mark_annot[curve->cd->cols], 0, str, strlen(str)); grow_SetAnnotation( curve->mark2_annot[curve->cd->cols], 0, str, strlen(str));
} }
break; break;
} }
case glow_eEvent_SliderMoveStart: { case glow_eEvent_SliderMoveStart: {
if ( event->object.object_type == glow_eObjectType_NoObject) if ( event->object.object_type == glow_eObjectType_NoObject)
grow_SetMoveRestrictions( (GrowCtx *)ctx, glow_eMoveRestriction_Disable, 0, 0, NULL); grow_SetMoveRestrictions( (GrowCtx *)ctx, glow_eMoveRestriction_Disable, 0, 0, NULL);
else else {
if ( event->object.object == curve->curve_markobject1)
grow_SetMoveRestrictions( (GrowCtx *)ctx, glow_eMoveRestriction_HorizontalSlider,
200 - MARK_WIDTH/2, -MARK_WIDTH/2,
curve->curve_markobject1);
else if ( event->object.object == curve->curve_markobject2)
grow_SetMoveRestrictions( (GrowCtx *)ctx, glow_eMoveRestriction_HorizontalSlider, grow_SetMoveRestrictions( (GrowCtx *)ctx, glow_eMoveRestriction_HorizontalSlider,
200 - MARK_WIDTH/2, -MARK_WIDTH/2, 200 - MARK_WIDTH/2, -MARK_WIDTH/2,
curve->curve_markobject); curve->curve_markobject2);
}
break; break;
} }
case glow_eEvent_SliderMoved: { case glow_eEvent_SliderMoved: {
...@@ -255,89 +322,56 @@ int GeCurve::growcurve_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -255,89 +322,56 @@ int GeCurve::growcurve_cb( GlowCtx *ctx, glow_tEvent event)
double time; double time;
double values[CURVE_MAX_COLS]; double values[CURVE_MAX_COLS];
grow_MeasureNode( curve->curve_markobject, &ll_x, &ll_y, &ur_x, &ur_y); if ( event->object.object == curve->curve_markobject1) {
grow_MeasureNode( curve->curve_markobject1, &ll_x, &ll_y, &ur_x, &ur_y);
curve->last_mark_x = event->any.x; curve->last_mark1_x = event->any.x;
curve->x_to_points( event->any.x, &time, values); curve->x_to_points( event->any.x, &time, values);
for ( int i = 0; i < curve->cd->cols; i++) { for ( int i = 0; i < curve->cd->cols; i++) {
sprintf( str, "%7.2f", values[i]); sprintf( str, "%7.2f", values[i]);
grow_SetAnnotation( curve->mark_annot[i], 0, str, strlen(str)); grow_SetAnnotation( curve->mark1_annot[i], 0, str, strlen(str));
} }
if ( !(strcmp( curve->cd->x_format[0], "%10t") == 0 || if ( !(strcmp( curve->cd->x_format[0], "%10t") == 0 ||
strcmp( curve->cd->x_format[0], "%11t") == 0)) { strcmp( curve->cd->x_format[0], "%11t") == 0)) {
sprintf( str, "%7.2f", time); sprintf( str, "%7.2f", time);
grow_SetAnnotation( curve->mark_annot[curve->cd->cols], 0, str, strlen(str)); grow_SetAnnotation( curve->mark1_annot[curve->cd->cols], 0, str, strlen(str));
} }
else { else {
// Time is a date // Time is a date
pwr_tTime t; pwr_tTime t;
time_Float64ToD( (pwr_tDeltaTime *) &t, time); time_Float64ToD( (pwr_tDeltaTime *) &t, time);
time_AtoAscii( &t, time_eFormat_DateAndTime, str, sizeof(str)); time_AtoAscii( &t, time_eFormat_DateAndTime, str, sizeof(str));
grow_SetAnnotation( curve->mark_annot[curve->cd->cols], 0, str, strlen(str)); grow_SetAnnotation( curve->mark1_annot[curve->cd->cols], 0, str, strlen(str));
} }
#if 0 }
if ( !curve->cd->x_reverse) else if ( event->object.object == curve->curve_markobject2) {
time = event->any.x * grow_MeasureNode( curve->curve_markobject2, &ll_x, &ll_y, &ur_x, &ur_y);
(curve->cd->max_value_axis[0] - curve->cd->min_value_axis[0]) / 200;
else
time = (200.0 - event->any.x) *
(curve->cd->max_value_axis[0] - curve->cd->min_value_axis[0]) / 200;
// Approximate row curve->last_mark2_x = event->any.x;
row = int ((time - curve->cd->min_value[0]) /
(curve->cd->max_value[0] - curve->cd->min_value[0]) * curve->x_to_points( event->any.x, &time, values);
(curve->cd->rows[0] - 1) + 0.5);
if ( row > curve->cd->rows[0] - 1) for ( int i = 0; i < curve->cd->cols; i++) {
row = curve->cd->rows[0] - 1; sprintf( str, "%7.2f", values[i]);
else if ( row < 0) grow_SetAnnotation( curve->mark2_annot[i], 0, str, strlen(str));
row = 0;
else {
// Find exact row
double b1, b2;
int r = row;
for (int i = 0;; i++) {
if ( r == 0) {
b2 = (curve->cd->data[0][row] + curve->cd->data[0][r+1]) / 2;
if ( time < b2)
break;
r++;
} }
else if ( r == curve->cd->rows[0] - 1) {
b1 = (curve->cd->data[0][r] + curve->cd->data[0][r-1]) / 2; if ( !(strcmp( curve->cd->x_format[0], "%10t") == 0 ||
if ( time >= b1) strcmp( curve->cd->x_format[0], "%11t") == 0)) {
break; sprintf( str, "%7.2f", time);
r--; grow_SetAnnotation( curve->mark2_annot[curve->cd->cols], 0, str, strlen(str));
} }
else { else {
b1 = (curve->cd->data[0][r] + curve->cd->data[0][r-1]) / 2; // Time is a date
b2 = (curve->cd->data[0][r] + curve->cd->data[0][r+1]) / 2; pwr_tTime t;
if ( b1 <= time && time < b2) time_Float64ToD( (pwr_tDeltaTime *) &t, time);
break; time_AtoAscii( &t, time_eFormat_DateAndTime, str, sizeof(str));
if ( b1 <= time) grow_SetAnnotation( curve->mark2_annot[curve->cd->cols], 0, str, strlen(str));
r++;
else
r--;
}
if ( i > 100) {
// Corrupt data, se original row
r = row;
break;
}
}
row = r;
} }
for ( int i = 0; i < curve->cd->cols; i++) {
sprintf( str, "%7.2f", curve->cd->y_data[i][row]);
grow_SetAnnotation( curve->mark_annot[i], 0, str, strlen(str));
} }
sprintf( str, "%7.2f", curve->cd->x_data[0][row]);
grow_SetAnnotation( curve->mark_annot[curve->cd->cols], 0, str, strlen(str));
#endif
break; break;
} }
case glow_eEvent_CursorMotion: { case glow_eEvent_CursorMotion: {
...@@ -418,6 +452,8 @@ int GeCurve::init_growcurve_cb( GlowCtx *fctx, void *client_data) ...@@ -418,6 +452,8 @@ int GeCurve::init_growcurve_cb( GlowCtx *fctx, void *client_data)
grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_MB1Click, grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_MB1Click,
glow_eEventType_CallBack, growcurve_cb); glow_eEventType_CallBack, growcurve_cb);
grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_MB1ClickCtrl,
glow_eEventType_CallBack, growcurve_cb);
grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_CursorMotion, grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_CursorMotion,
glow_eEventType_CallBack, growcurve_cb); glow_eEventType_CallBack, growcurve_cb);
grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_SliderMoved, grow_EnableEvent( (GrowCtx *)curve->growcurve_ctx, glow_eEvent_SliderMoved,
...@@ -459,8 +495,11 @@ int GeCurve::init_growcurve_cb( GlowCtx *fctx, void *client_data) ...@@ -459,8 +495,11 @@ int GeCurve::init_growcurve_cb( GlowCtx *fctx, void *client_data)
glow_sPoint p2[3] = { {0.1, 30.3}, { MARK_WIDTH/2-0.1, 31},{ 0.1, 31.7}}; glow_sPoint p2[3] = { {0.1, 30.3}, { MARK_WIDTH/2-0.1, 31},{ 0.1, 31.7}};
grow_AddPolyLine( nc, "", p2, 3, glow_eDrawType_Line, 1, 0, 1, 0, 1, glow_eDrawType_Color38, grow_AddPolyLine( nc, "", p2, 3, glow_eDrawType_Line, 1, 0, 1, 0, 1, glow_eDrawType_Color38,
1, 0); 1, 0);
grow_CreateGrowSlider( curve->growcurve_ctx, "", nc, 1, 0, NULL, &curve->curve_markobject); grow_CreateGrowSlider( curve->growcurve_ctx, "", nc, 1, 0, NULL, &curve->curve_markobject2);
grow_SetSliderInfo( curve->curve_markobject, glow_eDirection_Right, grow_SetSliderInfo( curve->curve_markobject2, glow_eDirection_Right,
200, 0, 200, 0);
grow_CreateGrowSlider( curve->growcurve_ctx, "", nc, 1, 0, NULL, &curve->curve_markobject1);
grow_SetSliderInfo( curve->curve_markobject1, glow_eDirection_Right,
200, 0, 200, 0); 200, 0, 200, 0);
// grow_SetMode( curve->growcurve_ctx, grow_eMode_Edit); // grow_SetMode( curve->growcurve_ctx, grow_eMode_Edit);
...@@ -677,7 +716,7 @@ int GeCurve::config_names() ...@@ -677,7 +716,7 @@ int GeCurve::config_names()
int time_size; int time_size;
if ( date) if ( date)
time_size = 8; time_size = 7;
else else
time_size = 3; time_size = 3;
...@@ -711,7 +750,13 @@ int GeCurve::config_names() ...@@ -711,7 +750,13 @@ int GeCurve::config_names()
glow_eDrawType_Line, 2, glow_eFont_LucidaSans, glow_eDrawType_Line, 2, glow_eFont_LucidaSans,
glow_mDisplayLevel_1, NULL, &o1); glow_mDisplayLevel_1, NULL, &o1);
x += time_size + 0.2; x += time_size + 0.2;
grow_CreateGrowText( grownames_ctx, "", Lng::translate("Mark"), grow_CreateGrowText( grownames_ctx, "", Lng::translate("Mark 1"),
x, 0.6, glow_eDrawType_TextHelvetica,
glow_eDrawType_Line, 2, glow_eFont_LucidaSans,
glow_mDisplayLevel_1, NULL, &o1);
// TODO
x += time_size + 0.2;
grow_CreateGrowText( grownames_ctx, "", Lng::translate("Mark 2"),
x, 0.6, glow_eDrawType_TextHelvetica, x, 0.6, glow_eDrawType_TextHelvetica,
glow_eDrawType_Line, 2, glow_eFont_LucidaSans, glow_eDrawType_Line, 2, glow_eFont_LucidaSans,
glow_mDisplayLevel_1, NULL, &o1); glow_mDisplayLevel_1, NULL, &o1);
...@@ -761,7 +806,11 @@ int GeCurve::config_names() ...@@ -761,7 +806,11 @@ int GeCurve::config_names()
&cursor_annot[i]); &cursor_annot[i]);
x += time_size + 0.2; x += time_size + 0.2;
grow_CreateGrowNode( grownames_ctx, "", nc, x, (i+0.8)+0.05, NULL, grow_CreateGrowNode( grownames_ctx, "", nc, x, (i+0.8)+0.05, NULL,
&mark_annot[i]); &mark1_annot[i]);
// TODO
x += time_size + 0.2;
grow_CreateGrowNode( grownames_ctx, "", nc, x, (i+0.8)+0.05, NULL,
&mark2_annot[i]);
// Draw unit // Draw unit
x += time_size + 0.6; x += time_size + 0.6;
grow_CreateGrowText( grownames_ctx, "", cd->y_unit[i], grow_CreateGrowText( grownames_ctx, "", cd->y_unit[i],
...@@ -781,7 +830,8 @@ int GeCurve::config_names() ...@@ -781,7 +830,8 @@ int GeCurve::config_names()
glow_eDrawType_Line, 2, glow_eFont_LucidaSans, glow_eDrawType_Line, 2, glow_eFont_LucidaSans,
glow_mDisplayLevel_1, NULL, &t1); glow_mDisplayLevel_1, NULL, &t1);
grow_SetAnnotation( cursor_annot[i], 0, "0", 1); grow_SetAnnotation( cursor_annot[i], 0, "0", 1);
grow_SetAnnotation( mark_annot[i], 0, "0", 1); grow_SetAnnotation( mark1_annot[i], 0, "0", 1);
grow_SetAnnotation( mark2_annot[i], 0, "0", 1);
} }
// Draw nodes for time values // Draw nodes for time values
// Draw shadowed frame // Draw shadowed frame
...@@ -793,7 +843,11 @@ int GeCurve::config_names() ...@@ -793,7 +843,11 @@ int GeCurve::config_names()
&cursor_annot[cd->cols]); &cursor_annot[cd->cols]);
x += time_size + 0.2; x += time_size + 0.2;
grow_CreateGrowNode( grownames_ctx, "", nc, x, (cd->cols+0.8)+0.05, NULL, grow_CreateGrowNode( grownames_ctx, "", nc, x, (cd->cols+0.8)+0.05, NULL,
&mark_annot[cd->cols]); &mark1_annot[cd->cols]);
// TODO
x += time_size + 0.2;
grow_CreateGrowNode( grownames_ctx, "", nc, x, (cd->cols+0.8)+0.05, NULL,
&mark2_annot[cd->cols]);
// Draw unit // Draw unit
x += time_size + 0.6; x += time_size + 0.6;
grow_CreateGrowText( grownames_ctx, "", "s", grow_CreateGrowText( grownames_ctx, "", "s",
...@@ -813,7 +867,8 @@ int GeCurve::config_names() ...@@ -813,7 +867,8 @@ int GeCurve::config_names()
glow_eDrawType_Line, 2, glow_eFont_LucidaSans, glow_eDrawType_Line, 2, glow_eFont_LucidaSans,
glow_mDisplayLevel_1, NULL, &t1); glow_mDisplayLevel_1, NULL, &t1);
grow_SetAnnotation( cursor_annot[cd->cols], 0, "0", 1); grow_SetAnnotation( cursor_annot[cd->cols], 0, "0", 1);
grow_SetAnnotation( mark_annot[cd->cols], 0, "0", 1); grow_SetAnnotation( mark1_annot[cd->cols], 0, "0", 1);
grow_SetAnnotation( mark2_annot[cd->cols], 0, "0", 1);
return 1; return 1;
} }
...@@ -1153,7 +1208,12 @@ void GeCurve::points_added() ...@@ -1153,7 +1208,12 @@ void GeCurve::points_added()
e.any.x = last_cursor_x; e.any.x = last_cursor_x;
growcurve_cb( growcurve_ctx, &e); growcurve_cb( growcurve_ctx, &e);
e.any.event = glow_eEvent_SliderMoved; e.any.event = glow_eEvent_SliderMoved;
e.any.x = last_mark_x; e.any.x = last_mark1_x;
e.object.object = curve_markobject1;
growcurve_cb( growcurve_ctx, &e);
e.any.event = glow_eEvent_SliderMoved;
e.any.x = last_mark2_x;
e.object.object = curve_markobject2;
growcurve_cb( growcurve_ctx, &e); growcurve_cb( growcurve_ctx, &e);
} }
...@@ -1295,9 +1355,9 @@ GeCurve::GeCurve( void *gc_parent_ctx, ...@@ -1295,9 +1355,9 @@ GeCurve::GeCurve( void *gc_parent_ctx,
border_bright(glow_eDrawType_Color22), border_bright(glow_eDrawType_Color22),
cd(0), axis_window_width(0), auto_refresh(1), axis_displayed(1), cd(0), axis_window_width(0), auto_refresh(1), axis_displayed(1),
minmax_idx(0), close_cb(0), help_cb(0), increase_period_cb(0), decrease_period_cb(0), reload_cb(0), minmax_idx(0), close_cb(0), help_cb(0), increase_period_cb(0), decrease_period_cb(0), reload_cb(0),
prev_period_cb(0), next_period_cb(0), add_cb(0), remove_cb(0), prev_period_cb(0), next_period_cb(0), add_cb(0), remove_cb(0), export_cb(0),
initial_right_position(pos_right), last_cursor_x(0), last_mark_x(0), deferred_configure_axes(0), initial_right_position(pos_right), last_cursor_x(0), last_mark1_x(0), last_mark2_x(0),
center_from_window(0) deferred_configure_axes(0), center_from_window(0)
{ {
pwr_tStatus sts; pwr_tStatus sts;
...@@ -1308,7 +1368,8 @@ GeCurve::GeCurve( void *gc_parent_ctx, ...@@ -1308,7 +1368,8 @@ GeCurve::GeCurve( void *gc_parent_ctx,
memset( hide_l1, 0, sizeof(hide_l1)); memset( hide_l1, 0, sizeof(hide_l1));
memset( hide_l2, 0, sizeof(hide_l2)); memset( hide_l2, 0, sizeof(hide_l2));
memset( cursor_annot, 0, sizeof(cursor_annot)); memset( cursor_annot, 0, sizeof(cursor_annot));
memset( mark_annot, 0, sizeof(mark_annot)); memset( mark1_annot, 0, sizeof(mark1_annot));
memset( mark2_annot, 0, sizeof(mark2_annot));
curve_color = background_dark; curve_color = background_dark;
curve_border = border_dark; curve_border = border_dark;
for ( int i = TREND_MAX_CURVES; i < CURVE_MAX_COLS; i++) for ( int i = TREND_MAX_CURVES; i < CURVE_MAX_COLS; i++)
......
...@@ -124,7 +124,8 @@ class GeCurve { ...@@ -124,7 +124,8 @@ class GeCurve {
glow_eDrawType border_bright; glow_eDrawType border_bright;
grow_tObject curve_object; grow_tObject curve_object;
grow_tObject curve_axisobject; grow_tObject curve_axisobject;
grow_tObject curve_markobject; grow_tObject curve_markobject1;
grow_tObject curve_markobject2;
GeCurveData *cd; GeCurveData *cd;
double axis_window_width; double axis_window_width;
int hide[CURVE_MAX_COLS]; int hide[CURVE_MAX_COLS];
...@@ -133,7 +134,8 @@ class GeCurve { ...@@ -133,7 +134,8 @@ class GeCurve {
grow_tObject hide_l1[CURVE_MAX_COLS+1]; grow_tObject hide_l1[CURVE_MAX_COLS+1];
grow_tObject hide_l2[CURVE_MAX_COLS+1]; grow_tObject hide_l2[CURVE_MAX_COLS+1];
grow_tObject scale_rect[CURVE_MAX_COLS+1]; grow_tObject scale_rect[CURVE_MAX_COLS+1];
grow_tObject mark_annot[CURVE_MAX_COLS+1]; grow_tObject mark1_annot[CURVE_MAX_COLS+1];
grow_tObject mark2_annot[CURVE_MAX_COLS+1];
grow_tObject cursor_annot[CURVE_MAX_COLS+1]; grow_tObject cursor_annot[CURVE_MAX_COLS+1];
grow_tObject axis_rect[CURVE_MAX_COLS+1]; grow_tObject axis_rect[CURVE_MAX_COLS+1];
grow_tObject axis_object[CURVE_MAX_COLS+1]; grow_tObject axis_object[CURVE_MAX_COLS+1];
...@@ -150,10 +152,12 @@ class GeCurve { ...@@ -150,10 +152,12 @@ class GeCurve {
void (*next_period_cb)( void *); void (*next_period_cb)( void *);
void (*add_cb)( void *); void (*add_cb)( void *);
void (*remove_cb)( void *); void (*remove_cb)( void *);
int (*export_cb)( void *, pwr_tTime *, pwr_tTime *, int, int, char *);
int initial_right_position; int initial_right_position;
char title[300]; char title[300];
double last_cursor_x; double last_cursor_x;
double last_mark_x; double last_mark1_x;
double last_mark2_x;
int deferred_configure_axes; int deferred_configure_axes;
CoWow *wow; CoWow *wow;
int center_from_window; int center_from_window;
...@@ -165,8 +169,10 @@ class GeCurve { ...@@ -165,8 +169,10 @@ class GeCurve {
virtual void pop() {} virtual void pop() {}
virtual void resize() {} virtual void resize() {}
virtual void open_minmax( int idx) {} virtual void open_minmax( int idx) {}
virtual void open_export( pwr_tTime *from, pwr_tTime *to, int rows, char *filename) {}
virtual void axis_set_width( int width) {} virtual void axis_set_width( int width) {}
virtual void enable_timebox() {} virtual void enable_timebox() {}
virtual void enable_export() {}
virtual void set_times( pwr_tTime *from, pwr_tTime *to) {} virtual void set_times( pwr_tTime *from, pwr_tTime *to) {}
virtual void set_times_sensitivity( int sensitive) {} virtual void set_times_sensitivity( int sensitive) {}
virtual pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to) {return 0;} virtual pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to) {return 0;}
...@@ -186,6 +192,7 @@ class GeCurve { ...@@ -186,6 +192,7 @@ class GeCurve {
void measure_window( double *ll_x, double *ll_y, double *ur_x, double *ur_y); void measure_window( double *ll_x, double *ll_y, double *ur_x, double *ur_y);
void activate_exit(); void activate_exit();
void activate_configure(); void activate_configure();
void activate_export();
void activate_print(); void activate_print();
void activate_background(); void activate_background();
void activate_filledcurves( int set); void activate_filledcurves( int set);
......
...@@ -76,7 +76,9 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx, ...@@ -76,7 +76,9 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
curve->next_period_cb = sevhist_next_period_cb; curve->next_period_cb = sevhist_next_period_cb;
curve->add_cb = sevhist_add_cb; curve->add_cb = sevhist_add_cb;
curve->remove_cb = sevhist_remove_cb; curve->remove_cb = sevhist_remove_cb;
curve->export_cb = sevhist_export_cb;
curve->enable_timebox(); curve->enable_timebox();
curve->enable_export();
wow = new CoWowGtk( parent_widget); wow = new CoWowGtk( parent_widget);
timerid = wow->timer_new(); timerid = wow->timer_new();
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "rt_gdh_msg.h" #include "rt_gdh_msg.h"
#include "co_cdh.h" #include "co_cdh.h"
#include "co_time.h" #include "co_time.h"
#include "co_dcli.h"
#include "cow_wow.h" #include "cow_wow.h"
#include "rt_sev_msg.h" #include "rt_sev_msg.h"
...@@ -827,6 +828,78 @@ void XttSevHist::sevhist_remove_cb( void *ctx) ...@@ -827,6 +828,78 @@ void XttSevHist::sevhist_remove_cb( void *ctx)
// Do do // Do do
} }
int XttSevHist::sevhist_export_cb( void *ctx, pwr_tTime *from, pwr_tTime *to, int rows, int idx,
char *filename)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
pwr_tFileName fname;
pwr_tTime *tbuf;
void *vbuf;
pwr_eType vtype;
unsigned int vsize;
pwr_tStatus sts;
int rrows;
char timestr[40];
FILE *fp;
dcli_translate_filename( fname, filename);
sevcli_get_itemdata( &sts, sevhist->scctx, sevhist->oidv[idx], sevhist->anamev[idx], *from, *to,
rows, &tbuf, &vbuf, &rrows, &vtype, &vsize);
if ( EVEN(sts))
return sts;
if( rrows == 0 ) {
return SEV__NODATATIME;
}
fp = fopen( fname, "w");
if ( !fp)
return SEV__EXPORTFILE;
for ( int i = 0; i < rrows; i++) {
time_AtoAscii( &tbuf[i], time_eFormat_DateAndTime, timestr, sizeof(timestr));
fprintf( fp, "%s, ", timestr);
switch ( vtype) {
case pwr_eType_Int32:
case pwr_eType_Int64:
case pwr_eType_Int16:
case pwr_eType_Int8:
fprintf( fp, "%d", ((pwr_tInt32 *)vbuf)[i]);
break;
case pwr_eType_UInt64:
case pwr_eType_UInt32:
case pwr_eType_UInt16:
case pwr_eType_UInt8:
fprintf( fp, "%u", ((pwr_tUInt32 *)vbuf)[i]);
break;
case pwr_eType_Float32:
fprintf( fp, "%g", ((pwr_tFloat32 *)vbuf)[i]);
break;
case pwr_eType_Float64:
fprintf( fp, "%g", ((pwr_tFloat64 *)vbuf)[i]);
break;
case pwr_eType_Boolean:
fprintf( fp, "%d", ((pwr_tBoolean *)vbuf)[i]);
break;
default:
sts = SEV__CURVETYPE;
}
fprintf( fp, "\n");
}
free( tbuf);
free( vbuf);
fclose( fp);
printf( "Exported %d rows to file \"%s\" (%d)\n", rrows, fname, idx);
if ( EVEN(sts))
return sts;
return SEV__SUCCESS;
}
void XttSevHist::sevhist_help_cb( void *ctx) void XttSevHist::sevhist_help_cb( void *ctx)
{ {
XttSevHist *sevhist = (XttSevHist *) ctx; XttSevHist *sevhist = (XttSevHist *) ctx;
......
...@@ -107,6 +107,8 @@ class XttSevHist { ...@@ -107,6 +107,8 @@ class XttSevHist {
static void sevhist_next_period_cb( void *ctx); static void sevhist_next_period_cb( void *ctx);
static void sevhist_add_cb( void *ctx); static void sevhist_add_cb( void *ctx);
static void sevhist_remove_cb( void *ctx); static void sevhist_remove_cb( void *ctx);
static int sevhist_export_cb( void *ctx, pwr_tTime *from, pwr_tTime *to,
int rows, int idx, char *filename);
static void sevhist_help_cb( void *ctx); static void sevhist_help_cb( void *ctx);
static void sevhist_scan( void *data); static void sevhist_scan( void *data);
......
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